Document what this check is doing. Also, no need to cast to ConstantInt.

llvm-svn: 60369
This commit is contained in:
Bill Wendling 2008-12-01 21:03:43 +00:00
parent e1908e393e
commit 84f6f2539f
1 changed files with 4 additions and 4 deletions

View File

@ -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));
}