authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-31 22:50:26+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-19 18:20:21-07:00
log894b732630a59664525cfa5e184bc108c0444e63
tree86e97bc79301c5e5d094cb76e0f3ec1d21cfd6db
parent8c0902b7aec230b8149cc560ebcc3dc0bd7e2328

Partially revert "LLVM: work around `@floatFromInt` bug"

This partially reverts commit ab4d6bf468bd8cba4ffd2d700d83e9707f5307b1.

1 files changed, 1 insertions(+), 19 deletions(-)

src/codegen/llvm.zig+1-19
...@@ -6796,29 +6796,11 @@ pub const FuncGen = struct {...@@ -6796,29 +6796,11 @@ pub const FuncGen = struct {
6796 const zcu = pt.zcu;6796 const zcu = pt.zcu;
6797 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6797 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
67986798
6799 const workaround_operand = try self.resolveInst(ty_op.operand);6799 const operand = try self.resolveInst(ty_op.operand);
6800 const operand_ty = self.typeOf(ty_op.operand);6800 const operand_ty = self.typeOf(ty_op.operand);
6801 const operand_scalar_ty = operand_ty.scalarType(zcu);6801 const operand_scalar_ty = operand_ty.scalarType(zcu);
6802 const is_signed_int = operand_scalar_ty.isSignedInt(zcu);6802 const is_signed_int = operand_scalar_ty.isSignedInt(zcu);
68036803
6804 const operand = o: {
6805 // Work around LLVM bug. See https://github.com/ziglang/zig/issues/17381.
6806 const bit_size = operand_scalar_ty.bitSize(zcu);
6807 for ([_]u8{ 8, 16, 32, 64, 128 }) |b| {
6808 if (bit_size < b) {
6809 break :o try self.wip.cast(
6810 if (is_signed_int) .sext else .zext,
6811 workaround_operand,
6812 try o.builder.intType(b),
6813 "",
6814 );
6815 } else if (bit_size == b) {
6816 break :o workaround_operand;
6817 }
6818 }
6819 break :o workaround_operand;
6820 };
6821
6822 const dest_ty = self.typeOfIndex(inst);6804 const dest_ty = self.typeOfIndex(inst);
6823 const dest_scalar_ty = dest_ty.scalarType(zcu);6805 const dest_scalar_ty = dest_ty.scalarType(zcu);
6824 const dest_llvm_ty = try o.lowerType(dest_ty);6806 const dest_llvm_ty = try o.lowerType(dest_ty);