From: Sanjay Patel Date: Sun, 14 Aug 2016 21:36:22 +0000 (+0000) Subject: [InstCombine] add tests for missing vector icmp folds X-Git-Tag: llvmorg-4.0.0-rc1~12477 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b44ca3bfa94de03b722ec5066837e7f3b9a10370;p=platform%2Fupstream%2Fllvm.git [InstCombine] add tests for missing vector icmp folds llvm-svn: 278632 --- diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index aa2a504..c1a3d41 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -1348,6 +1348,21 @@ define i1 @icmp_add_and_shr_ne_0(i32 %X) { ret i1 %tobool } +; FIXME: Vectors should fold the same way. +define <2 x i1> @icmp_add_and_shr_ne_0_vec(<2 x i32> %X) { +; CHECK-LABEL: @icmp_add_and_shr_ne_0_vec( +; CHECK-NEXT: [[SHR:%.*]] = lshr <2 x i32> %X, +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[SHR]], +; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne <2 x i32> [[AND]], +; CHECK-NEXT: ret <2 x i1> [[TOBOOL]] +; + %shr = lshr <2 x i32> %X, + %and = and <2 x i32> %shr, + %add = add <2 x i32> %and, + %tobool = icmp ne <2 x i32> %add, zeroinitializer + ret <2 x i1> %tobool +} + ; PR16244 define i1 @test71(i8* %x) { ; CHECK-LABEL: @test71( @@ -1732,6 +1747,22 @@ define i1 @icmp_and_or_lshr(i32 %x, i32 %y) { ret i1 %ret } +; FIXME: Vectors should fold the same way. +define <2 x i1> @icmp_and_or_lshr_vec(<2 x i32> %x, <2 x i32> %y) { +; CHECK-LABEL: @icmp_and_or_lshr_vec( +; CHECK-NEXT: [[SHF:%.*]] = lshr <2 x i32> %x, %y +; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[SHF]], %x +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[OR]], +; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[RET]] +; + %shf = lshr <2 x i32> %x, %y + %or = or <2 x i32> %shf, %x + %and = and <2 x i32> %or, + %ret = icmp ne <2 x i32> %and, zeroinitializer + ret <2 x i1> %ret +} + define i1 @icmp_and_or_lshr_cst(i32 %x) { ; CHECK-LABEL: @icmp_and_or_lshr_cst( ; CHECK-NEXT: [[AND1:%.*]] = and i32 %x, 3 @@ -1745,6 +1776,22 @@ define i1 @icmp_and_or_lshr_cst(i32 %x) { ret i1 %ret } +; FIXME: Vectors should fold the same way. +define <2 x i1> @icmp_and_or_lshr_cst_vec(<2 x i32> %x) { +; CHECK-LABEL: @icmp_and_or_lshr_cst_vec( +; CHECK-NEXT: [[SHF:%.*]] = lshr <2 x i32> %x, +; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[SHF]], %x +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[OR]], +; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[RET]] +; + %shf = lshr <2 x i32> %x, + %or = or <2 x i32> %shf, %x + %and = and <2 x i32> %or, + %ret = icmp ne <2 x i32> %and, zeroinitializer + ret <2 x i1> %ret +} + define i1 @shl_ap1_zero_ap2_non_zero_2(i32 %a) { ; CHECK-LABEL: @shl_ap1_zero_ap2_non_zero_2( ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 %a, 29