[llvm] [AMDGPU] Adding multiple use analysis to SIPeepholeSDWA (PR #94800)
Brian Favela via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 13:45:58 PDT 2024
================
@@ -327,7 +334,37 @@ uint64_t SDWASrcOperand::getSrcMods(const SIInstrInfo *TII,
return Mods;
}
-MachineInstr *SDWASrcOperand::potentialToConvert(const SIInstrInfo *TII) {
+MachineInstr *SDWASrcOperand::potentialToConvert(const SIInstrInfo *TII,
+ const GCNSubtarget &ST,
+ SDWAOperandsMap *PotentialMatches) {
+ // If PotentialMatches is not null, then fill out the map for all uses,
+ // if all can be converted
+ if (PotentialMatches != nullptr) {
+ MachineOperand *Reg = getReplacedOperand();
+ if (!Reg->isReg() || !Reg->isDef()) {
+ return nullptr;
+ }
+
+ for (MachineInstr &UseMI : getMRI()->use_nodbg_instructions(Reg->getReg())) {
+ // Check that all instructions that use Reg can be converted
+ if (!isConvertibleToSDWA(UseMI, ST, TII)) {
+ return nullptr;
+ }
+ }
+
+ // Now that it's guaranteed all uses are legal, iterate over the uses again
+ // to add them for later conversion.
+ for (MachineOperand &UseMO : getMRI()->use_nodbg_operands(Reg->getReg())) {
+ // Should not get a subregister here
+ assert(isSameReg(UseMO, *Reg));
+
+ SDWAOperandsMap& potentialMatchesMap = *PotentialMatches;
----------------
bfavela wrote:
I tried running clang-format, but it ended up changing way too much of the file. Still need to set it up for individual changes, sorry.
https://github.com/llvm/llvm-project/pull/94800
More information about the llvm-commits
mailing list