[Mesa-dev] [PATCH 11/38] ac/nir: make ac_build_fsign work on all bit sizes

Rhys Perry pendingchaos02 at gmail.com
Fri Dec 7 17:22:04 UTC 2018


Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
---
 src/amd/common/ac_llvm_build.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index fa5c68d1b6..c85f9a214e 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -2357,19 +2357,11 @@ LLVMValueRef ac_build_isign(struct ac_llvm_context *ctx, LLVMValueRef src0,
 LLVMValueRef ac_build_fsign(struct ac_llvm_context *ctx, LLVMValueRef src0,
 			    unsigned bitsize)
 {
-	LLVMValueRef cmp, val, zero, one;
-	LLVMTypeRef type;
-
-	if (bitsize == 32) {
-		type = ctx->f32;
-		zero = ctx->f32_0;
-		one = ctx->f32_1;
-	} else {
-		type = ctx->f64;
-		zero = ctx->f64_0;
-		one = ctx->f64_1;
-	}
+	LLVMTypeRef type = ac_float_of_size(ctx, bitsize);
+	LLVMValueRef zero = ac_get_zerof(ctx, type);
+	LLVMValueRef one = ac_get_onef(ctx, type);
 
+	LLVMValueRef cmp, val;
 	cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGT, src0, zero, "");
 	val = LLVMBuildSelect(ctx->builder, cmp, one, src0, "");
 	cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGE, val, zero, "");
-- 
2.19.2



More information about the mesa-dev mailing list