authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-24 22:43:29+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-25 04:52:46+02:00
logbebfdc3661359bbf681de2676085432698363f16
tree231c2c167497526c333949175d46abe691974a4e
parentfeb05a716d1ae105cf0e8f9966b6ade7f32dc680

llvm: remove some workarounds in loadTruncate()

No longer needed with LLVM 21.

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

src/codegen/llvm.zig+1-18
...@@ -11399,16 +11399,6 @@ pub const FuncGen = struct {...@@ -11399,16 +11399,6 @@ pub const FuncGen = struct {
11399 const payload_llvm_ty = try o.lowerType(pt, payload_ty);11399 const payload_llvm_ty = try o.lowerType(pt, payload_ty);
11400 const abi_size = payload_ty.abiSize(zcu);11400 const abi_size = payload_ty.abiSize(zcu);
1140111401
11402 // llvm bug workarounds:
11403 const workaround_explicit_mask = o.target.cpu.arch == .powerpc and abi_size >= 4;
11404 const workaround_disable_truncate = o.target.cpu.arch == .wasm32 and abi_size >= 4;
11405
11406 if (workaround_disable_truncate) {
11407 // see https://github.com/llvm/llvm-project/issues/64222
11408 // disable the truncation codepath for larger than 32bits value - with this heuristic, the backend passes the test suite.
11409 return try fg.wip.load(access_kind, payload_llvm_ty, payload_ptr, payload_alignment, "");
11410 }
11411
11412 const load_llvm_ty = if (payload_ty.isAbiInt(zcu))11402 const load_llvm_ty = if (payload_ty.isAbiInt(zcu))
11413 try o.builder.intType(@intCast(abi_size * 8))11403 try o.builder.intType(@intCast(abi_size * 8))
11414 else11404 else
...@@ -11422,14 +11412,7 @@ pub const FuncGen = struct {...@@ -11422,14 +11412,7 @@ pub const FuncGen = struct {
11422 else11412 else
11423 loaded;11413 loaded;
1142411414
11425 const anded = if (workaround_explicit_mask and payload_llvm_ty != load_llvm_ty) blk: {11415 return fg.wip.conv(.unneeded, shifted, payload_llvm_ty, "");
11426 // this is rendundant with llvm.trunc. But without it, llvm17 emits invalid code for powerpc.
11427 const mask_val = try o.builder.intValue(payload_llvm_ty, -1);
11428 const zext_mask_val = try fg.wip.cast(.zext, mask_val, load_llvm_ty, "");
11429 break :blk try fg.wip.bin(.@"and", shifted, zext_mask_val, "");
11430 } else shifted;
11431
11432 return fg.wip.conv(.unneeded, anded, payload_llvm_ty, "");
11433 }11416 }
1143411417
11435 /// Load a by-ref type by constructing a new alloca and performing a memcpy.11418 /// Load a by-ref type by constructing a new alloca and performing a memcpy.