diff options
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 7 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/icmp.ll | 4 | 
2 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index e23e85bb16a..f96d91527fa 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3695,6 +3695,7 @@ Instruction *InstCombiner::foldICmpBinOp(ICmpInst &I) {                          C == Op0 ? D : C);    // icmp (X+Y), (X+Z) -> icmp Y, Z for equalities or if there is no overflow. +  // TODO: The one-use checks should not be necessary.    if (A && C && (A == C || A == D || B == C || B == D) && NoOp0WrapProblem &&        NoOp1WrapProblem &&        // Try not to increase register pressure. @@ -3842,11 +3843,11 @@ Instruction *InstCombiner::foldICmpBinOp(ICmpInst &I) {      return new ICmpInst(Pred, C, D);    // icmp (Y-X), (Z-X) -> icmp Y, Z for equalities or if there is no overflow. -  if (B && D && B == D && NoOp0WrapProblem && NoOp1WrapProblem && -      // Try not to increase register pressure. -      BO0->hasOneUse() && BO1->hasOneUse()) +  if (B && D && B == D && NoOp0WrapProblem && NoOp1WrapProblem)      return new ICmpInst(Pred, A, C); +    // icmp (X-Y), (X-Z) -> icmp Z, Y for equalities or if there is no overflow. +  // TODO: The one-use checks should not be necessary.    if (A && C && A == C && NoOp0WrapProblem && NoOp1WrapProblem &&        // Try not to increase register pressure.        BO0->hasOneUse() && BO1->hasOneUse()) diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 07ec4e7b40f..1e38a7b7f58 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -562,7 +562,7 @@ define i1 @test27_extra_uses(i32 %x, i32 %y, i32 %z) {  ; CHECK-NEXT:    call void @foo(i32 [[LHS]])  ; CHECK-NEXT:    [[RHS:%.*]] = sub nsw i32 [[Y:%.*]], [[Z]]  ; CHECK-NEXT:    call void @foo(i32 [[RHS]]) -; CHECK-NEXT:    [[C:%.*]] = icmp sgt i32 [[LHS]], [[RHS]] +; CHECK-NEXT:    [[C:%.*]] = icmp sgt i32 [[X]], [[Y]]  ; CHECK-NEXT:    ret i1 [[C]]  ;    %lhs = sub nsw i32 %x, %z @@ -591,7 +591,7 @@ define i1 @test28_extra_uses(i32 %x, i32 %y, i32 %z) {  ; CHECK-NEXT:    call void @foo(i32 [[LHS]])  ; CHECK-NEXT:    [[RHS:%.*]] = sub nuw i32 [[Y:%.*]], [[Z]]  ; CHECK-NEXT:    call void @foo(i32 [[RHS]]) -; CHECK-NEXT:    [[C:%.*]] = icmp ugt i32 [[LHS]], [[RHS]] +; CHECK-NEXT:    [[C:%.*]] = icmp ugt i32 [[X]], [[Y]]  ; CHECK-NEXT:    ret i1 [[C]]  ;    %lhs = sub nuw i32 %x, %z  | 

