[llvm] [InstCombine] Split GEPs with multiple variable indices (PR #137297)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 26 09:31:55 PDT 2025
================
@@ -2777,6 +2777,12 @@ Instruction *InstCombinerImpl::visitGEPOfGEP(GetElementPtrInst &GEP,
Indices.append(GEP.idx_begin()+1, GEP.idx_end());
}
+ // Don't create GEPs with more than one variable index.
+ unsigned NumVarIndices =
+ count_if(Indices, [](Value *Idx) { return !isa<Constant>(Idx); });
+ if (NumVarIndices > 1)
----------------
nikic wrote:
> Do you mean the call to `simplifyAddInst` above may produce a constant?
Yes, this is the motivation for the separate check.
https://github.com/llvm/llvm-project/pull/137297
More information about the llvm-commits
mailing list