[PATCH] D144184: [InstSimplify] fold LoadInst for uniformaly initialized constant global variables

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 17 05:38:13 PST 2023


nikic added a comment.

I think something went wrong with the patch upload, it seems like only part of the test diff is there?



================
Comment at: llvm/test/Transforms/InstSimplify/load.ll:64
+;
+  %gep1 = getelementptr inbounds i8, ptr @constzeroarrayi8, i64 0
+  %gep = getelementptr inbounds i8, ptr %gep1, i64 %idx
----------------
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.)


================
Comment at: llvm/test/Transforms/InstSimplify/load.ll:87
+;
+  %gep1 = getelementptr inbounds i8, ptr @constarrayi8, i64 0
+  %gep = getelementptr inbounds i8, ptr %gep1, i64 %idx
----------------
Same here, getelementptr with zero index is a no-op.


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

https://reviews.llvm.org/D144184



More information about the llvm-commits mailing list