[PATCH] D137778: [GlobalISel] Correct constant type in matchReassocConstantInnerLHS

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 08:56:25 PST 2022


arsenm added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:4552-4561
     LHSPtrAdd->moveBefore(&MI);
     Register RHSReg = MI.getOffsetReg();
     Observer.changingInstr(MI);
-    MI.getOperand(2).setReg(LHSCstOff->VReg);
+    // set VReg will cause type mismatch if it comes from extend/trunc
+    auto NewCst = B.buildConstant(MRI.getType(RHSReg), LHSCstOff->Value);
+    MI.getOperand(2).setReg(NewCst.getReg(0));
     Observer.changedInstr(MI);
----------------
If you're going to potentially create a new constant anyway, can you just create the constant and get rid of all this moveBefore stuff?


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

https://reviews.llvm.org/D137778



More information about the llvm-commits mailing list