diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index a7732c475b45..5c443faf2f23 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3849,10 +3849,7 @@ Instruction *InstCombiner::foldICmpBinOp(ICmpInst &I) { return new ICmpInst(Pred, A, C); // icmp (A-B), (A-D) -> icmp D, B 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()) + if (A && C && A == C && NoOp0WrapProblem && NoOp1WrapProblem) return new ICmpInst(Pred, D, B); // icmp (0-X) < cst --> x > -cst diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 02c26ef58b8d..ec9fc77d9fc8 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -734,7 +734,7 @@ define i1 @test37_extra_uses(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: call void @foo(i32 [[LHS]]) ; CHECK-NEXT: [[RHS:%.*]] = sub nsw i32 [[X]], [[Z:%.*]] ; CHECK-NEXT: call void @foo(i32 [[RHS]]) -; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[LHS]], [[RHS]] +; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[Z]], [[Y]] ; CHECK-NEXT: ret i1 [[C]] ; %lhs = sub nsw i32 %x, %y @@ -763,7 +763,7 @@ define i1 @test38_extra_uses(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: call void @foo(i32 [[LHS]]) ; CHECK-NEXT: [[RHS:%.*]] = sub nuw i32 [[X]], [[Z:%.*]] ; CHECK-NEXT: call void @foo(i32 [[RHS]]) -; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[LHS]], [[RHS]] +; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[Z]], [[Y]] ; CHECK-NEXT: ret i1 [[C]] ; %lhs = sub nuw i32 %x, %y