[llvm] [InstCombine] Make foldCmpLoadFromIndexedGlobal more resiliant to non-array geps. (PR #150639)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 26 12:54:31 PDT 2025
================
@@ -127,21 +133,27 @@ Instruction *InstCombinerImpl::foldCmpLoadFromIndexedGlobal(
return nullptr;
// There are many forms of this optimization we can handle, for now, just do
- // the simple index into a single-dimensional array.
+ // the simple index into a single-dimensional array or elements of equal size.
//
- // Require: GEP GV, 0, i {{, constant indices}}
- if (GEP->getNumOperands() < 3 || !isa<ConstantInt>(GEP->getOperand(1)) ||
- !cast<ConstantInt>(GEP->getOperand(1))->isZero() ||
- isa<Constant>(GEP->getOperand(2)))
+ // Require: GEP [n x i8] GV, 0, Idx {{, constant indices}}
+ // Or: GEP i8 GV, Idx
+
+ SmallVector<unsigned, 4> LaterIndices;
----------------
nikic wrote:
Why move the declaration of LaterIndices?
https://github.com/llvm/llvm-project/pull/150639
More information about the llvm-commits
mailing list