diff options
| -rw-r--r-- | llvm/lib/Analysis/LazyValueInfo.cpp | 41 | 
1 files changed, 16 insertions, 25 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index f58e11e2df7..f41978f18ee 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -859,9 +859,8 @@ bool LazyValueInfoCache::solveBlockValuePHINode(LVILatticeVal &BBLV,    return true;  } -static bool getValueFromCondition(Value *Val, Value *Cond, -                                  LVILatticeVal &Result, -                                  bool isTrueDest = true); +static LVILatticeVal getValueFromCondition(Value *Val, Value *Cond, +                                           bool isTrueDest = true);  // If we can determine a constraint on the value given conditions assumed by  // the program, intersect those constraints with BBLV @@ -879,9 +878,7 @@ void LazyValueInfoCache::intersectAssumeBlockValueConstantRange(Value *Val,      if (!isValidAssumeForContext(I, BBI, DT))        continue; -    LVILatticeVal Result; -    if (getValueFromCondition(Val, I->getArgOperand(0), Result)) -      BBLV = intersect(BBLV, Result); +    BBLV = intersect(BBLV, getValueFromCondition(Val, I->getArgOperand(0)));    }  } @@ -952,14 +949,10 @@ bool LazyValueInfoCache::solveBlockValueSelect(LVILatticeVal &BBLV,    // condition itself?  This shows up with idioms like e.g. select(a > 5, a, 5).    // TODO: We could potentially refine an overdefined true value above.    Value *Cond = SI->getCondition(); -  LVILatticeVal TrueValTaken, FalseValTaken; -  if (!getValueFromCondition(SI->getTrueValue(), Cond, TrueValTaken, true)) -    TrueValTaken.markOverdefined(); -  if (!getValueFromCondition(SI->getFalseValue(), Cond, FalseValTaken, false)) -    FalseValTaken.markOverdefined(); - -  TrueVal = intersect(TrueVal, TrueValTaken); -  FalseVal = intersect(FalseVal, FalseValTaken); +  TrueVal = intersect(TrueVal, +                      getValueFromCondition(SI->getTrueValue(), Cond, true)); +  FalseVal = intersect(FalseVal, +                       getValueFromCondition(SI->getFalseValue(), Cond, false));    // Handle clamp idioms such as:    //   %24 = constantrange<0, 17> @@ -1174,14 +1167,13 @@ bool LazyValueInfoCache::solveBlockValueBinaryOp(LVILatticeVal &BBLV,    return true;  } -bool getValueFromCondition(Value *Val, Value *Cond, LVILatticeVal &Result, -                           bool isTrueDest) { +LVILatticeVal getValueFromCondition(Value *Val, Value *Cond, bool isTrueDest) {    assert(Cond && "precondition");    // For now we only support ICmpInst conditions    ICmpInst *ICI = dyn_cast<ICmpInst>(Cond);    if (!ICI) -    return false; +    return LVILatticeVal::getOverdefined();    Value *LHS = ICI->getOperand(0);    Value *RHS = ICI->getOperand(1); @@ -1192,15 +1184,14 @@ bool getValueFromCondition(Value *Val, Value *Cond, LVILatticeVal &Result,        // We know that V has the RHS constant if this is a true SETEQ or        // false SETNE.        if (isTrueDest == (Predicate == ICmpInst::ICMP_EQ)) -        Result = LVILatticeVal::get(cast<Constant>(RHS)); +        return LVILatticeVal::get(cast<Constant>(RHS));        else -        Result = LVILatticeVal::getNot(cast<Constant>(RHS)); -      return true; +        return LVILatticeVal::getNot(cast<Constant>(RHS));      }    }    if (!Val->getType()->isIntegerTy()) -    return false; +    return LVILatticeVal::getOverdefined();    // Use ConstantRange::makeAllowedICmpRegion in order to determine the possible    // range of Val guaranteed by the condition. Recognize comparisons in the from @@ -1236,11 +1227,10 @@ bool getValueFromCondition(Value *Val, Value *Cond, LVILatticeVal &Result,      if (Offset) // Apply the offset from above.        TrueValues = TrueValues.subtract(Offset->getValue()); -    Result = LVILatticeVal::getRange(std::move(TrueValues)); -    return true; +    return LVILatticeVal::getRange(std::move(TrueValues));    } -  return false; +  return LVILatticeVal::getOverdefined();  }  /// \brief Compute the value of Val on the edge BBFrom -> BBTo. Returns false if @@ -1269,7 +1259,8 @@ static bool getEdgeValueLocal(Value *Val, BasicBlock *BBFrom,        // If the condition of the branch is an equality comparison, we may be        // able to infer the value. -      if (getValueFromCondition(Val, BI->getCondition(), Result, isTrueDest)) +      Result = getValueFromCondition(Val, BI->getCondition(), isTrueDest); +      if (!Result.isOverdefined())          return true;      }    }  | 

