[PATCH] D152754: [PowerPC] Correct missue of getOperandConstraint in PPCInstrInfo::commuteInstructionImpl

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 15:05:22 PDT 2023


craig.topper created this revision.
craig.topper added a reviewer: nemanjai.
Herald added subscribers: shchenz, kbarton, hiraditya.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: LLVM.

getOperandConstraint does not return a bool, it returns an int. It
returns -1 if there is no TIED_TO.

Additionally, TIED_TO is only set on use operands not defs and it
points to the def that the use is tied to. So calling it on operand 0
is guaranteed to return -1.

As far as I can tell this code must have been copied from the
generic implementation prior to 6aa2744bed0b8.o

Unfortunately, this code is not executed in lit tests. I just happened
to notice it while looking for other uses of TIED_TO for something
I was working on.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152754

Files:
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp


Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -1175,7 +1175,7 @@
   // destination register as well.
   if (Reg0 == Reg1) {
     // Must be two address instruction!
-    assert(MI.getDesc().getOperandConstraint(0, MCOI::TIED_TO) &&
+    assert(MI.getDesc().getOperandConstraint(1, MCOI::TIED_TO) == 0 &&
            "Expecting a two-address instruction!");
     assert(MI.getOperand(0).getSubReg() == SubReg1 && "Tied subreg mismatch");
     Reg2IsKill = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152754.530679.patch
Type: text/x-patch
Size: 625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230612/afd81178/attachment.bin>


More information about the llvm-commits mailing list