}
// Unsigned comparison is the same as signed comparison when both the operands
- // are non-negative.
+ // are non-negative or negative.
if (CmpInst::isUnsigned(FoundPred) &&
CmpInst::getSignedPredicate(FoundPred) == Pred &&
- isKnownNonNegative(FoundLHS) && isKnownNonNegative(FoundRHS))
+ ((isKnownNonNegative(FoundLHS) && isKnownNonNegative(FoundRHS)) ||
+ (isKnownNegative(FoundLHS) && isKnownNegative(FoundRHS))))
return isImpliedCondOperands(Pred, LHS, RHS, FoundLHS, FoundRHS, Context);
// Check if we can make progress by sharpening ranges.
ret i32 0
}
-; FIXME: 2nd check is implied by the 1st one as both values are negative.
define i32 @test_02(i32* %p, i32* %s) {
; CHECK-LABEL: @test_02(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[C1:%.*]] = icmp ult i32 [[IV]], [[END]]
; CHECK-NEXT: br i1 [[C1]], label [[GUARDED:%.*]], label [[SIDE_EXIT:%.*]]
; CHECK: guarded:
-; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[IV]], [[END]]
-; CHECK-NEXT: br i1 [[C2]], label [[BACKEDGE]], label [[SIDE_EXIT]]
+; CHECK-NEXT: br i1 true, label [[BACKEDGE]], label [[SIDE_EXIT]]
; CHECK: backedge:
; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i32 [[IV]], 1
; CHECK-NEXT: [[LOOP_COND:%.*]] = call i1 @cond()