[llvm] [SPIRV] Fix trunc nonstandard int types (PR #191393)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 02:50:18 PDT 2026


================
@@ -486,6 +501,39 @@ generateAssignInstrs(MachineFunction &MF, SPIRVGlobalRegistry *GR,
       ST->canUseExtension(SPIRV::Extension::SPV_KHR_bit_instructions) ||
       ST->canUseExtension(SPIRV::Extension::SPV_INTEL_int4);
 
+  if (!IsExtendedInts) {
+    // Some instructions' behavior relies on register size, e.g. G_TRUNC.
+    // Process them before general register widening.
+    for (MachineBasicBlock &MBB : MF) {
+      for (MachineInstr &MI : MBB) {
+        unsigned MIOp = MI.getOpcode();
+        if (MIOp == TargetOpcode::G_TRUNC) {
----------------
idubinov wrote:

I expect that we will have more if-cases in the future, but by now it is only one case (G_TRUNC), and we can replace it with early exit.

https://github.com/llvm/llvm-project/pull/191393


More information about the llvm-commits mailing list