[llvm] [GlobalISel] Check width of APInts in Reassoc PtrAdd combine (PR #84335)

Mirko BrkuĊĦanin via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 07:50:59 PST 2024


================
@@ -4653,7 +4653,8 @@ bool CombinerHelper::matchReassocFoldConstantsInSubTree(GPtrAdd &MI,
     return false;
 
   MatchInfo = [=, &MI](MachineIRBuilder &B) {
-    auto NewCst = B.buildConstant(MRI.getType(Src2Reg), *C1 + *C2);
+    auto NewCst = B.buildConstant(MRI.getType(Src2Reg),
+                                  C1->sextOrTrunc(C2->getBitWidth()) + *C2);
----------------
mbrkusanin wrote:

Should we always pick larger one instead?

https://github.com/llvm/llvm-project/pull/84335


More information about the llvm-commits mailing list