Commit 7a477a1110

Andrew Kelley <andrew@ziglang.org>
2022-03-14 06:22:19
LLVM: fix int_to_float signedness detection
It was checking if the result (float) type was a signed int rather than checking the operand (integer) type.
1 parent d42d31f
Changed files (1)
src
codegen
src/codegen/llvm.zig
@@ -3709,10 +3709,11 @@ pub const FuncGen = struct {
 
         const ty_op = self.air.instructions.items(.data)[inst].ty_op;
         const operand = try self.resolveInst(ty_op.operand);
+        const operand_ty = self.air.typeOf(ty_op.operand);
         const dest_ty = self.air.typeOfIndex(inst);
         const dest_llvm_ty = try self.dg.llvmType(dest_ty);
 
-        if (dest_ty.isSignedInt()) {
+        if (operand_ty.isSignedInt()) {
             return self.builder.buildSIToFP(operand, dest_llvm_ty, "");
         } else {
             return self.builder.buildUIToFP(operand, dest_llvm_ty, "");