[PATCH] D146813: [LICM] Reassociate GEPs to allow hoisting

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 22:24:14 PDT 2023


mkazantsev accepted this revision.
mkazantsev added inline comments.
This revision is now accepted and ready to land.


================
Comment at: llvm/lib/Transforms/Scalar/LICM.cpp:2536
+      Builder.CreateGEP(GEP->getSourceElementType(), SrcPtr,
+                        SmallVector<Value *>(GEP->indices()), "", IsInBounds);
+  Builder.SetInsertPoint(GEP);
----------------
nikic wrote:
> mkazantsev wrote:
> > Can you please add a test where GEP and Src's indices have different dimensions? I'm a bit worried about type compatibility here.
> There is a test for different source element types in `@different_elem_types` and I've added `@different_index_types` with different index types. Not sure whether these are what you had in mind...
I meant something like:
```
Src = gep ptr %src_p, i32 %i1, i32 %i2

GEP = gep ptr %gep_p, i32 %j1
```
`different_index_count` will do, thanks!



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

https://reviews.llvm.org/D146813



More information about the llvm-commits mailing list