[PATCH] D144184: [InstSimplify] fold LoadInst for uniformaly initialized constant global variables
Kohei Asano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 16 05:30:03 PST 2023
khei4 created this revision.
khei4 added reviewers: nikic, spatel.
Herald added subscribers: StephenFan, JDevlieghere, hiraditya.
Herald added a project: All.
khei4 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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
https://reviews.llvm.org/D144184
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -6586,6 +6586,11 @@
if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer())
return nullptr;
+ // If GlobalVariable's initializer is uniform, then return the constant
+ // regardless its offset.
+ if (Constant *C =
+ ConstantFoldLoadFromUniformValue(GV->getInitializer(), LI->getType()))
+ return C;
// Try to convert operand into a constant by stripping offsets while looking
// through invariant.group intrinsics.
APInt Offset(Q.DL.getIndexTypeSizeInBits(PtrOp->getType()), 0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144184.497971.patch
Type: text/x-patch
Size: 734 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230216/343f1177/attachment.bin>
More information about the llvm-commits
mailing list