[llvm] [AMDGPU] Adding multiple use analysis to SIPeepholeSDWA (PR #94800)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 15 01:08:43 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;
----------------
jayfoad wrote:
If you have `clang/tools/clang-format/git-clang-format` on your path then you can run something like `git clang-format @^` to just reformat the code you touched in your most recent commit.
https://github.com/llvm/llvm-project/pull/94800
More information about the llvm-commits
mailing list