Skip to content

Commit

Permalink
Partially revert "LLVM: work around @floatFromInt bug"
Browse files Browse the repository at this point in the history
This partially reverts commit ab4d6bf.
  • Loading branch information
alexrp committed Sep 5, 2024
1 parent 73f46ca commit 3704ad0
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6766,29 +6766,11 @@ pub const FuncGen = struct {
const zcu = pt.zcu;
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;

const workaround_operand = try self.resolveInst(ty_op.operand);
const operand = try self.resolveInst(ty_op.operand);
const operand_ty = self.typeOf(ty_op.operand);
const operand_scalar_ty = operand_ty.scalarType(zcu);
const is_signed_int = operand_scalar_ty.isSignedInt(zcu);

const operand = o: {
// Work around LLVM bug. See https://github.com/ziglang/zig/issues/17381.
const bit_size = operand_scalar_ty.bitSize(zcu);
for ([_]u8{ 8, 16, 32, 64, 128 }) |b| {
if (bit_size < b) {
break :o try self.wip.cast(
if (is_signed_int) .sext else .zext,
workaround_operand,
try o.builder.intType(b),
"",
);
} else if (bit_size == b) {
break :o workaround_operand;
}
}
break :o workaround_operand;
};

const dest_ty = self.typeOfIndex(inst);
const dest_scalar_ty = dest_ty.scalarType(zcu);
const dest_llvm_ty = try o.lowerType(dest_ty);
Expand Down

0 comments on commit 3704ad0

Please sign in to comment.