[PATCH] D71386: [AMDGPU] Remove unnecessary v_mov from a register to itself in WQM lowering.

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 03:43:28 PST 2019


foad added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp:877-878
+  for (MachineInstr *MI : LowerToCopyInstrs) {
+    for (unsigned i = MI->getNumExplicitOperands() - 1; i > 1; i--)
+      MI->RemoveOperand(i);
+
----------------
mjbedy wrote:
> nhaehnle wrote:
> > arsenm wrote:
> > > These should only ever have been moves to begin with? Just remove the one exec operand?
> > They were move-like: WQM, SOFT_WQM, V_SET_INACTIVE_xx. I think it makes sense though to just remove that one operand and maybe assert there are no other implicit uses.
> Now that I look closer at this, I'm not even sure what this loop is doing (or the one in the case above that I modeled it on)? The exec operands are implicit so this doesn't touch them. This is what comes into the phase:
> 
> %12:vgpr_32 = WQM %10:vgpr_32, implicit $exec, implicit $exec
> 
> And this is what comes out:
> 
> %12:vgpr_32 = COPY %10:vgpr_32, implicit $exec, implicit $exec
> 
The loop removes any extra explicit operands after the first two, which will become the destination and source of the copy. Currently the SET_INACTIVE instructions have an extra explicit operand called "inactive".

Several passes add an implicit use of exec without checking whether there was one already, so I'm not surprised this pass does not bother to remove any implicit operands. You can see instructions with multiple "implicit $exec" operands in debug output and even in some of our autogenerated lit tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71386/new/

https://reviews.llvm.org/D71386





More information about the llvm-commits mailing list