diff options
author | Bill Wendling <isanbard@gmail.com> | 2008-11-30 12:38:24 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2008-11-30 12:38:24 +0000 |
commit | b9b1a6fc6e00dff21fedbc571cd59d3ffd2b8436 (patch) | |
tree | 323def3d1ded45fc9f7d34850a96f4803b794bf1 /lib/Transforms | |
parent | ae9c66ccdea00e3ed0bccb32137b2429c19b8c8e (diff) | |
download | external_llvm-b9b1a6fc6e00dff21fedbc571cd59d3ffd2b8436.zip external_llvm-b9b1a6fc6e00dff21fedbc571cd59d3ffd2b8436.tar.gz external_llvm-b9b1a6fc6e00dff21fedbc571cd59d3ffd2b8436.tar.bz2 |
getSExtValue() doesn't work for ConstantInts with bitwidth > 64 bits. Use all
APInt calls instead.
This fixes PR3144.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index f3cb747..93510f0 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2957,21 +2957,21 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) { return BinaryOperator::CreateNeg(Op0); ConstantInt *RHSNeg = cast<ConstantInt>(ConstantExpr::getNeg(RHS)); - APInt RHSNegAPI(RHSNeg->getBitWidth(), RHSNeg->getSExtValue(), true); + APInt RHSNegAPI(RHSNeg->getValue()); APInt NegOne = -APInt(RHSNeg->getBitWidth(), 1, true); APInt TwoToExp(RHSNeg->getBitWidth(), 1 << (RHSNeg->getBitWidth() - 1)); // -X/C -> X/-C, if and only if negation doesn't overflow. - if ((RHS->getSExtValue() < 0 && RHSNegAPI.slt(TwoToExp - 1)) || - (RHS->getSExtValue() > 0 && RHSNegAPI.sgt(TwoToExp * NegOne))) { + if ((RHS->getValue().isNegative() && RHSNegAPI.slt(TwoToExp - 1)) || + (RHS->getValue().isNonNegative() && RHSNegAPI.sgt(TwoToExp * NegOne))) { if (Value *LHSNeg = dyn_castNegVal(Op0)) { if (ConstantInt *CI = dyn_cast<ConstantInt>(LHSNeg)) { ConstantInt *CINeg = cast<ConstantInt>(ConstantExpr::getNeg(CI)); APInt CINegAPI(CINeg->getBitWidth(), CINeg->getSExtValue(), true); - if ((CI->getSExtValue() < 0 && CINegAPI.slt(TwoToExp - 1)) || - (CI->getSExtValue() > 0 && CINegAPI.sgt(TwoToExp * NegOne))) + if ((CI->getValue().isNegative() && CINegAPI.slt(TwoToExp - 1)) || + (CI->getValue().isNonNegative() && CINegAPI.sgt(TwoToExp*NegOne))) return BinaryOperator::CreateSDiv(LHSNeg, ConstantExpr::getNeg(RHS)); } |