aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-12-01 21:03:43 +0000
committerBill Wendling <isanbard@gmail.com>2008-12-01 21:03:43 +0000
commit69fffa5437db31eaa9cb2a4d004a4cd02e06bfa3 (patch)
treed71aee97275574a3fcebad49e23a5af7a263902f /lib/Transforms
parentc25c68305c5d595c5428f75280cfb56e4f623eb3 (diff)
downloadexternal_llvm-69fffa5437db31eaa9cb2a4d004a4cd02e06bfa3.zip
external_llvm-69fffa5437db31eaa9cb2a4d004a4cd02e06bfa3.tar.gz
external_llvm-69fffa5437db31eaa9cb2a4d004a4cd02e06bfa3.tar.bz2
Document what this check is doing. Also, no need to cast to ConstantInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60369 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index e4ddecf..9ee375c 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2933,10 +2933,10 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
// -X/C -> X/-C, if and only if negation doesn't overflow.
if (Value *LHSNeg = dyn_castNegVal(Op0)) {
if (ConstantInt *CI = dyn_cast<ConstantInt>(LHSNeg)) {
- ConstantInt *RHSNeg = cast<ConstantInt>(ConstantExpr::getNeg(RHS));
- if (RHS != RHSNeg) {
- ConstantInt *CINeg = cast<ConstantInt>(ConstantExpr::getNeg(CI));
- if (CI != CINeg)
+ Constant *RHSNeg = ConstantExpr::getNeg(RHS);
+ if (RHS != RHSNeg) { // Check that there is no overflow.
+ Constant *CINeg = ConstantExpr::getNeg(CI);
+ if (CI != CINeg) // Check that there is no overflow.
return BinaryOperator::CreateSDiv(LHSNeg,
ConstantExpr::getNeg(RHS));
}