[llvm] [AMDGPU] Calc IsVALU correctly during UADDO/USUBO selection (PR #159814)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 24 08:28:51 PDT 2025


================
@@ -5963,9 +5963,9 @@ SITargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
         .add(Src1);
     // clang-format on
 
-    BuildMI(*BB, MI, DL, TII->get(AMDGPU::S_CSELECT_B64), Dest1.getReg())
-        .addImm(1)
-        .addImm(0);
+    unsigned SelOpc =
+        Subtarget->isWave64() ? AMDGPU::S_CSELECT_B64 : AMDGPU::S_CSELECT_B32;
+    BuildMI(*BB, MI, DL, TII->get(SelOpc), Dest1.getReg()).addImm(1).addImm(0);
----------------
jayfoad wrote:

Not your fault, but this code seems very suspicious. If you store a uniform boolean result in a wavesize register, why would you use the values 0 and 1? Wouldn't 0 and -1 be much safer, e.g. if someone decides to AND it with the exec mask?

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


More information about the llvm-commits mailing list