[PATCH] D146622: [AggressiveInstCombine] folding load for constant global patterened arrays and structs by GEP indices

Kohei Asano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 08:17:02 PDT 2023


khei4 added a comment.

Thank you for the quick good catches!



================
Comment at: llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:847-848
+      else
+        Stride = APIntOps::GreatestCommonDivisor(
+            *Stride, APInt(BW, Scale.getZExtValue()));
+    }
----------------
nikic wrote:
> I don't think there's a need to create a separate APInt here?
Good catch! I believed this is necessary to match bit-width, but that was another place...


================
Comment at: llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:884
   Constant *C = GV->getInitializer();
+  unsigned BW = DL.getIndexTypeSizeInBits(PtrOp->getType());
 
----------------
nikic wrote:
> I think you can move BW into the if below now, it's not used otherwise.
The same goes for LoadTy! Thanks!


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

https://reviews.llvm.org/D146622



More information about the llvm-commits mailing list