Fold loadInst for uniformly initialized global arrays.
Goal proof: https://alive2.llvm.org/ce/z/oZtVby
motivated by https://github.com/rust-lang/rust/issues/107208
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Looks basically fine to me.
llvm/lib/Analysis/InstructionSimplify.cpp | ||
---|---|---|
6590 | nit: regardless of? | |
6593 | nit: Add a newline after this. | |
llvm/test/Transforms/InstSimplify/load.ll | ||
56 | I would add an additional test that shows that this can look through multiple GEPs and doesn't depend on the GEP source element type ([4 x i32]) either. %gep1 = getelementptr inbounds i8, ptr @constzeroarray, i64 %idx1 %gep = getelementptr inbouds i8, ptr %gep1, i64 %idx2 |
I think something went wrong with the patch upload, it seems like only part of the test diff is there?
llvm/test/Transforms/InstSimplify/load.ll | ||
---|---|---|
62 | Using i64 0 doesn't really make sense, because it is a no-op. The instruction will be removed before we get to the fold. It should use a variable index as well. It's also fine to reuse constzeroarray rather than constzeroarrayi8 here -- in fact, that shows that we don't need a matching stride between the getelementptr and the globals declaration. (We do need it for the non-zero initializer case.) | |
85 | Same here, getelementptr with zero index is a no-op. |
I rebased commits and created a new diff. Maybe the cause is I combine the test commit and functional commit in the wrong way. I'm going to separate them next time.
Thanks a lot for review! Please use Kohei Asano <kk.asano.luxy@gmail.com>.
llvm/test/Transforms/InstSimplify/load.ll | ||
---|---|---|
56 | Seems reasonable. Thanks for the review! | |
62 |
Thanks. Used other variable indexes and reused constzeroarray for the second test case. |
nit: regardless of?