[PATCH] D30474: [InstCombine] Always Fold GEP chains where the first index is zero
Matthew Simpson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 1 09:55:45 PST 2017
mssimpso added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:1569-1575
// Note that if our source is a gep chain itself then we wait for that
// chain to be resolved before we perform this transformation. This
// avoids us creating a TON of code in some cases.
if (GEPOperator *SrcGEP =
dyn_cast<GEPOperator>(Src->getOperand(0)))
if (SrcGEP->getNumOperands() == 2 && shouldMergeGEPs(*Src, *SrcGEP))
return nullptr; // Wait until our source is folded to completion.
----------------
Hey Eli,
The single-use check is good enough for my purposes. But if we do that, I think it makes more sense to just guard the bail out check here with !Src->hasOneUse(). This will enable the full combine instead of just the zero simplification. So if GEP is the only user of Src, we go ahead with the combine and Src will be eliminated; otherwise, bail out and wait for Src to be simplified first.
I will test this approach and update the patch with the results.
https://reviews.llvm.org/D30474
More information about the llvm-commits
mailing list