ac: fix f2b and i2b for doubles
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 26 Feb 2018 05:12:41 +0000 (16:12 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 27 Feb 2018 22:23:49 +0000 (09:23 +1100)
Without this llvm was asserting in debug builds.

V2: use LLVMConstNull()

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/common/ac_nir_to_llvm.c

index 3f0bfedfa7d4cf313d966e7b1bc4364b36bbf351..96bbecd110089f01998627b49bd0327b873b253c 100644 (file)
@@ -1437,8 +1437,9 @@ static LLVMValueRef emit_f2b(struct ac_llvm_context *ctx,
                             LLVMValueRef src0)
 {
        src0 = ac_to_float(ctx, src0);
+       LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(src0));
        return LLVMBuildSExt(ctx->builder,
-                            LLVMBuildFCmp(ctx->builder, LLVMRealUNE, src0, ctx->f32_0, ""),
+                            LLVMBuildFCmp(ctx->builder, LLVMRealUNE, src0, zero, ""),
                             ctx->i32, "");
 }
 
@@ -1457,8 +1458,9 @@ static LLVMValueRef emit_b2i(struct ac_llvm_context *ctx,
 static LLVMValueRef emit_i2b(struct ac_llvm_context *ctx,
                             LLVMValueRef src0)
 {
+       LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(src0));
        return LLVMBuildSExt(ctx->builder,
-                            LLVMBuildICmp(ctx->builder, LLVMIntNE, src0, ctx->i32_0, ""),
+                            LLVMBuildICmp(ctx->builder, LLVMIntNE, src0, zero, ""),
                             ctx->i32, "");
 }