From: Sanjay Patel Date: Mon, 16 Sep 2019 12:19:18 +0000 (+0000) Subject: [InstCombine] add icmp tests with extra uses; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8624cc4ae452179b333fd0ecca5b2784edb47ec2;p=llvm [InstCombine] add icmp tests with extra uses; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371979 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index 1e38a7b7f58..02c26ef58b8 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -728,6 +728,23 @@ define i1 @test37(i32 %x, i32 %y, i32 %z) { ret i1 %c } +define i1 @test37_extra_uses(i32 %x, i32 %y, i32 %z) { +; CHECK-LABEL: @test37_extra_uses( +; CHECK-NEXT: [[LHS:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]] +; 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: ret i1 [[C]] +; + %lhs = sub nsw i32 %x, %y + call void @foo(i32 %lhs) + %rhs = sub nsw i32 %x, %z + call void @foo(i32 %rhs) + %c = icmp sgt i32 %lhs, %rhs + ret i1 %c +} + ; X - Y > X - Z -> Z > Y if there is no overflow. define i1 @test38(i32 %x, i32 %y, i32 %z) { ; CHECK-LABEL: @test38( @@ -740,6 +757,23 @@ define i1 @test38(i32 %x, i32 %y, i32 %z) { ret i1 %c } +define i1 @test38_extra_uses(i32 %x, i32 %y, i32 %z) { +; CHECK-LABEL: @test38_extra_uses( +; CHECK-NEXT: [[LHS:%.*]] = sub nuw i32 [[X:%.*]], [[Y:%.*]] +; 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: ret i1 [[C]] +; + %lhs = sub nuw i32 %x, %y + call void @foo(i32 %lhs) + %rhs = sub nuw i32 %x, %z + call void @foo(i32 %rhs) + %c = icmp ugt i32 %lhs, %rhs + ret i1 %c +} + ; PR9343 #1 define i1 @test39(i32 %X, i32 %Y) { ; CHECK-LABEL: @test39(