[llvm] [SPIRV] Sign-extend operands of sign-sensitive ops on sub-pow2 widths (PR #203661)
Faijul Amin via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 11 10:40:39 PDT 2026
================
@@ -564,6 +565,83 @@ generateAssignInstrs(MachineFunction &MF, SPIRVGlobalRegistry *GR,
}
for (MachineInstr *MI : TruncToRemove)
MI->eraseFromParent();
+
+ // The widening loop below only retypes registers, so sign-sensitive ops
+ // (G_ASHR, G_SDIV, G_SREM, signed G_ICMP) on sub-pow2 widths see the sign
+ // bit at the wrong position. Emit G_SEXT_INREG; the legalizer lowers it.
+ // TODO: handle vector operands.
+ auto IsSignSensitive = [](const MachineInstr &MI) {
----------------
mdfaijul wrote:
Thanks! I have refactored and moved to separate functions.
https://github.com/llvm/llvm-project/pull/203661
More information about the llvm-commits
mailing list