authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-13 22:22:19-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-14 00:11:46-07:00
log7a477a1110c9bf7b4a83a87dcbd5b160842b29e7
treece77e2c389d37dd7068a32d12b19bd1fc8507e46
parentd42d31f72f38165f70c2850e9cc63da44b3b470c

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 files changed, 2 insertions(+), 1 deletions(-)

src/codegen/llvm.zig+2-1
......@@ -3709,10 +3709,11 @@ pub const FuncGen = struct {
37093709
37103710 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
37113711 const operand = try self.resolveInst(ty_op.operand);
3712 const operand_ty = self.air.typeOf(ty_op.operand);
37123713 const dest_ty = self.air.typeOfIndex(inst);
37133714 const dest_llvm_ty = try self.dg.llvmType(dest_ty);
37143715
3715 if (dest_ty.isSignedInt()) {
3716 if (operand_ty.isSignedInt()) {
37163717 return self.builder.buildSIToFP(operand, dest_llvm_ty, "");
37173718 } else {
37183719 return self.builder.buildUIToFP(operand, dest_llvm_ty, "");