@@ -1744,9 +1744,9 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
1744
1744
return NumElim;
1745
1745
}
1746
1746
1747
- Value * SCEVExpander::getRelatedExistingExpansion (const SCEV *S,
1748
- const Instruction *At,
1749
- Loop *L) {
1747
+ bool SCEVExpander::hasRelatedExistingExpansion (const SCEV *S,
1748
+ const Instruction *At,
1749
+ Loop *L) {
1750
1750
using namespace llvm ::PatternMatch;
1751
1751
1752
1752
SmallVector<BasicBlock *, 4 > ExitingBlocks;
@@ -1763,17 +1763,17 @@ Value *SCEVExpander::getRelatedExistingExpansion(const SCEV *S,
1763
1763
continue ;
1764
1764
1765
1765
if (SE.getSCEV (LHS) == S && SE.DT .dominates (LHS, At))
1766
- return LHS ;
1766
+ return true ;
1767
1767
1768
1768
if (SE.getSCEV (RHS) == S && SE.DT .dominates (RHS, At))
1769
- return RHS ;
1769
+ return true ;
1770
1770
}
1771
1771
1772
1772
// Use expand's logic which is used for reusing a previous Value in
1773
1773
// ExprValueMap. Note that we don't currently model the cost of
1774
1774
// needing to drop poison generating flags on the instruction if we
1775
1775
// want to reuse it. We effectively assume that has zero cost.
1776
- return FindValueInExprValueMap (S, At);
1776
+ return FindValueInExprValueMap (S, At) != nullptr ;
1777
1777
}
1778
1778
1779
1779
template <typename T> static InstructionCost costAndCollectOperands (
@@ -1951,7 +1951,7 @@ bool SCEVExpander::isHighCostExpansionHelper(
1951
1951
1952
1952
// If we can find an existing value for this scev available at the point "At"
1953
1953
// then consider the expression cheap.
1954
- if (getRelatedExistingExpansion (S, &At, L))
1954
+ if (hasRelatedExistingExpansion (S, &At, L))
1955
1955
return false ; // Consider the expression to be free.
1956
1956
1957
1957
TargetTransformInfo::TargetCostKind CostKind =
@@ -1993,7 +1993,7 @@ bool SCEVExpander::isHighCostExpansionHelper(
1993
1993
// At the beginning of this function we already tried to find existing
1994
1994
// value for plain 'S'. Now try to lookup 'S + 1' since it is common
1995
1995
// pattern involving division. This is just a simple search heuristic.
1996
- if (getRelatedExistingExpansion (
1996
+ if (hasRelatedExistingExpansion (
1997
1997
SE.getAddExpr (S, SE.getConstant (S->getType (), 1 )), &At, L))
1998
1998
return false ; // Consider it to be free.
1999
1999
0 commit comments