[PATCH] D137664: [InstCombine][NFC] Baseline tests for D137212 Simplify chain of GEP with constant indices

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 11 07:52:56 PST 2022


spatel added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/gep-merge-constant-indices.ll:277
+  %2 = getelementptr inbounds i32, ptr %1, i64 %a
+  %3 = getelementptr inbounds [4 x i16], ptr %2, i64 1, i64 -4
+  ret ptr %3
----------------
huangjd wrote:
> spatel wrote:
> > It's not clear to me that this test is providing coverage for the intended constraint in the other patch. 
> > 
> > Should we add a simplify for any gep like %3?
> > https://alive2.llvm.org/ce/z/w89_Y5
> GEP with zero offset is simplified away by visitGEPOfGEP regardless what the preceding GEP is, so there is no way to keep it in the output 
Then do we really need this test?

Even with typed pointers, we could do this transform of a single GEP:
https://alive2.llvm.org/ce/z/EKc-rM
...but that transform does not exist. Is there a reason it does not exist?

To be clear, I don't think it has to delay this patch or D137212. I'm just curious if we are missing a more basic transform.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137664



More information about the llvm-commits mailing list