[llvm] [InstCombine] Split GEPs with multiple variable indices (PR #137297)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 26 05:43:15 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)
----------------
dtcxzyw wrote:
Is there any reason for not putting the logic into `shouldMergeGEPs`? Do you mean the call to `simplifyAddInst` above may produce a constant?
https://github.com/llvm/llvm-project/pull/137297
More information about the llvm-commits
mailing list