[PATCH] D144184: [InstSimplify] fold LoadInst for uniformaly initialized constant global variables
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 16 05:39:47 PST 2023
nikic added a comment.
Looks basically fine to me.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:6590
+ // If GlobalVariable's initializer is uniform, then return the constant
+ // regardless its offset.
+ if (Constant *C =
----------------
nit: regardless of?
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:6593
+ ConstantFoldLoadFromUniformValue(GV->getInitializer(), LI->getType()))
+ return C;
// Try to convert operand into a constant by stripping offsets while looking
----------------
nit: Add a newline after this.
================
Comment at: llvm/test/Transforms/InstSimplify/load.ll:53
+ ret i32 %load
+}
+
----------------
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
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144184/new/
https://reviews.llvm.org/D144184
More information about the llvm-commits
mailing list