[llvm] AMDGPU][True16][CodeGen] fold clamp update for true16 (PR #128919)
Brox Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 13 10:58:59 PDT 2025
================
@@ -1819,7 +1819,13 @@ bool SIFoldOperandsImpl::tryFoldClamp(MachineInstr &MI) {
if (!ClampSrc || !MRI->hasOneNonDBGUser(ClampSrc->getReg()))
return false;
- MachineInstr *Def = MRI->getVRegDef(ClampSrc->getReg());
+ // Look through COPY. COPY only observed with True16.
+ MachineOperand *DefSrc = lookUpCopyChain(*TII, *MRI, ClampSrc->getReg());
+ MachineInstr *Def = nullptr;
+ if (DefSrc && DefSrc->isReg() && !DefSrc->isImm())
+ Def = MRI->getVRegDef(DefSrc->getReg());
+ else
+ Def = MRI->getVRegDef(ClampSrc->getReg());
----------------
broxigarchen wrote:
It seems lookThruCopyLike might return a phy reg. But we shouldn't fold clamp with phy reg, right?
https://github.com/llvm/llvm-project/pull/128919
More information about the llvm-commits
mailing list