From: Sanjay Patel Date: Wed, 8 Feb 2017 17:37:17 +0000 (+0000) Subject: [InstCombine] add test for missed vector icmp fold; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bddd84197f0129de6871637070cd3a4137b4e8a4;p=llvm [InstCombine] add test for missed vector icmp fold; NFC Also, move the related existing scalar test to a renamed file where I'm planning to add more icmp-add tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294487 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/2008-01-29-AddICmp.ll b/test/Transforms/InstCombine/icmp-add.ll similarity index 75% rename from test/Transforms/InstCombine/2008-01-29-AddICmp.ll rename to test/Transforms/InstCombine/icmp-add.ll index a33eb9c1ddd..3bf1849c91c 100644 --- a/test/Transforms/InstCombine/2008-01-29-AddICmp.ll +++ b/test/Transforms/InstCombine/icmp-add.ll @@ -83,3 +83,26 @@ define <2 x i1> @test4vec(<2 x i32> %a) { ret <2 x i1> %c } +define i1 @slt_zero_add_nsw(i32 %a) { +; CHECK-LABEL: @slt_zero_add_nsw( +; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 %a, -1 +; CHECK-NEXT: ret i1 [[CMP]] +; + %add = add nsw i32 %a, 1 + %cmp = icmp slt i32 %add, 0 + ret i1 %cmp +} + +; FIXME: The same fold should work with vectors. + +define <2 x i1> @slt_zero_add_nsw_splat_vec(<2 x i8> %a) { +; CHECK-LABEL: @slt_zero_add_nsw_splat_vec( +; CHECK-NEXT: [[ADD:%.*]] = add nsw <2 x i8> %a, +; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[ADD]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %add = add nsw <2 x i8> %a, + %cmp = icmp slt <2 x i8> %add, zeroinitializer + ret <2 x i1> %cmp +} + diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index ad1f8654014..888fd95fb4a 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -2231,16 +2231,6 @@ define i1 @icmp_sge_zero_add_nsw(i32 %a) { ret i1 %cmp } -define i1 @icmp_slt_zero_add_nsw(i32 %a) { -; CHECK-LABEL: @icmp_slt_zero_add_nsw( -; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 %a, -1 -; CHECK-NEXT: ret i1 [[CMP]] -; - %add = add nsw i32 %a, 1 - %cmp = icmp slt i32 %add, 0 - ret i1 %cmp -} - define i1 @icmp_sle_zero_add_nsw(i32 %a) { ; CHECK-LABEL: @icmp_sle_zero_add_nsw( ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 %a, 0