Skip to content

Commit

Permalink
Revert "[LSR] Allow already invariant operand for ICmpZero matching"
Browse files Browse the repository at this point in the history
This reverts commit 9153515.  Builtbot crash was reported in the commit thread, reverting while investigating.
  • Loading branch information
preames committed Jul 15, 2022
1 parent ac14d5a commit 6fe766b
Show file tree
Hide file tree
Showing 3 changed files with 475 additions and 483 deletions.
26 changes: 8 additions & 18 deletions llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Expand Up @@ -3333,24 +3333,14 @@ void LSRInstance::CollectFixupsAndInitialFormulae() {

// x == y --> x - y == 0
const SCEV *N = SE.getSCEV(NV);
if (!NV->getType()->isPointerTy() ||
SE.getPointerBase(N) == SE.getPointerBase(S)) {
if (SE.isLoopInvariant(N, L) && Rewriter.isSafeToExpand(N)) {
// S is normalized, so normalize N before folding it into S
// to keep the result normalized.
N = normalizeForPostIncUse(N, TmpPostIncLoops, SE);
Kind = LSRUse::ICmpZero;
S = SE.getMinusSCEV(N, S);
} else if (L->isLoopInvariant(NV)) {
// If we can't generally expand the expression (e.g. it contains
// a divide), but it is already at a loop invariant point, wrap it
// in an unknwon (to prevent the expander from trying to re-expand
// in a potentially unsafe way.)
N = SE.getUnknown(NV);
N = normalizeForPostIncUse(N, TmpPostIncLoops, SE);
Kind = LSRUse::ICmpZero;
S = SE.getMinusSCEV(N, S);
}
if (SE.isLoopInvariant(N, L) && Rewriter.isSafeToExpand(N) &&
(!NV->getType()->isPointerTy() ||
SE.getPointerBase(N) == SE.getPointerBase(S))) {
// S is normalized, so normalize N before folding it into S
// to keep the result normalized.
N = normalizeForPostIncUse(N, TmpPostIncLoops, SE);
Kind = LSRUse::ICmpZero;
S = SE.getMinusSCEV(N, S);
}

// -1 and the negations of all interesting strides (except the negation
Expand Down

0 comments on commit 6fe766b

Please sign in to comment.