[llvm] [InstCombine] Remove one-use restriction on icmp of gep fold (PR #76730)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 3 03:09:26 PST 2024
================
@@ -813,14 +813,29 @@ Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
}
}
- // Only lower this if the icmp is the only user of the GEP or if we expect
- // the result to fold to a constant!
- if ((GEPsInBounds || CmpInst::isEquality(Cond)) &&
- (GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse()) &&
- (GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse())) {
+ if (GEPsInBounds || CmpInst::isEquality(Cond)) {
+ auto EmitGEPOffsetAndRewrite = [&](GEPOperator *GEP) {
+ auto *Inst = dyn_cast<Instruction>(GEP);
----------------
dtcxzyw wrote:
IIRC we have removed constant expr support for `getelementptr`. I cannot find the pattern `(getelementptr` in the LLVM regression tests and my benchmarks.
If not, should we restore the insert point after offset expansion?
https://github.com/llvm/llvm-project/pull/76730
More information about the llvm-commits
mailing list