[llvm] [AMDGPU] Fix folding clamp into pseudo scalar instructions (PR #100568)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 07:04:57 PDT 2024


================
@@ -1581,7 +1581,18 @@ bool SIFoldOperands::tryFoldClamp(MachineInstr &MI) {
 
   // Clamp is applied after omod, so it is OK if omod is set.
   DefClamp->setImm(1);
-  MRI->replaceRegWith(MI.getOperand(0).getReg(), Def->getOperand(0).getReg());
+
+  Register DefReg = Def->getOperand(0).getReg();
+  Register MIDstReg = MI.getOperand(0).getReg();
+  if (TRI->isSGPRReg(*MRI, DefReg)) {
+    // Psuedo scalar instructions have a SGPR for dst and clamp is a v_max*
----------------
arsenm wrote:

Typo Psuedo

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


More information about the llvm-commits mailing list