[llvm] [AMDGPU] Account for existing SDWA selections (PR #123221)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 01:11:11 PST 2025
================
@@ -451,13 +497,33 @@ bool SDWASrcOperand::convertToSDWA(MachineInstr &MI, const SIInstrInfo *TII) {
}
copyRegOperand(*Src, *getTargetOperand());
if (!IsPreserveSrc) {
- SrcSel->setImm(getSrcSel());
+ SdwaSel ExistingSel = static_cast<SdwaSel>(SrcSel->getImm());
+ SrcSel->setImm(combineSdwaSel(ExistingSel, getSrcSel()).value());
SrcMods->setImm(getSrcMods(TII, Src));
}
getTargetOperand()->setIsKill(false);
return true;
}
+bool SDWASrcOperand::canCombineSelections(const MachineInstr &MI,
+ const SIInstrInfo *TII) {
+ if (!TII->isSDWA(MI.getOpcode()))
+ return true;
+
+ auto canCombineSel = [&](auto SrcOpName, auto SrcSelOpName) {
+ const MachineOperand *Src = TII->getNamedOperand(MI, SrcOpName);
+ const MachineOperand *SrcSel = TII->getNamedOperand(MI, SrcSelOpName);
+ return !Src || !isSameReg(*Src, *getReplacedOperand()) ||
+ combineSdwaSel(static_cast<SdwaSel>(SrcSel->getImm()), getSrcSel())
+ .has_value();
----------------
arsenm wrote:
```suggestion
!combineSdwaSel(static_cast<SdwaSel>(SrcSel->getImm()), getSrcSel());
```
https://github.com/llvm/llvm-project/pull/123221
More information about the llvm-commits
mailing list