diff options
Diffstat (limited to 'contrib/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
| -rw-r--r-- | contrib/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 11 | 
1 files changed, 10 insertions, 1 deletions
diff --git a/contrib/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/contrib/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 199902aa41f8..82c734e0b829 100644 --- a/contrib/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/contrib/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -30,6 +30,14 @@ static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale,    }    if (BinaryOperator *I = dyn_cast<BinaryOperator>(Val)) { +    // Cannot look past anything that might overflow. +    OverflowingBinaryOperator *OBI = dyn_cast<OverflowingBinaryOperator>(Val); +    if (OBI && !OBI->hasNoUnsignedWrap()) { +      Scale = 1; +      Offset = 0; +      return Val; +    } +      if (ConstantInt *RHS = dyn_cast<ConstantInt>(I->getOperand(1))) {        if (I->getOpcode() == Instruction::Shl) {          // This is a value scaled by '1 << the shift amt'. @@ -1208,7 +1216,8 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {    CallInst *Call = dyn_cast<CallInst>(CI.getOperand(0));    if (Call && Call->getCalledFunction() &&        Call->getCalledFunction()->getName() == "sqrt" && -      Call->getNumArgOperands() == 1) { +      Call->getNumArgOperands() == 1 && +      Call->hasOneUse()) {      CastInst *Arg = dyn_cast<CastInst>(Call->getArgOperand(0));      if (Arg && Arg->getOpcode() == Instruction::FPExt &&          CI.getType()->isFloatTy() &&  | 
