diff --git a/llvm/test/Transforms/InstCombine/and.ll b/llvm/test/Transforms/InstCombine/and.ll index 5b48f3304959..cf2390c4bd1c 100644 --- a/llvm/test/Transforms/InstCombine/and.ll +++ b/llvm/test/Transforms/InstCombine/and.ll @@ -255,11 +255,24 @@ define i1 @test23(i32 %A) { ; %B = icmp sgt i32 %A, 1 %C = icmp sle i32 %A, 2 - ;; A == 2 %D = and i1 %B, %C ret i1 %D } +; FIXME: Vectors should fold too. +define <2 x i1> @test23vec(<2 x i32> %A) { +; CHECK-LABEL: @test23vec( +; CHECK-NEXT: [[B:%.*]] = icmp sgt <2 x i32> %A, <i32 1, i32 1> +; CHECK-NEXT: [[C:%.*]] = icmp slt <2 x i32> %A, <i32 3, i32 3> +; CHECK-NEXT: [[D:%.*]] = and <2 x i1> [[B]], [[C]] +; CHECK-NEXT: ret <2 x i1> [[D]] +; + %B = icmp sgt <2 x i32> %A, <i32 1, i32 1> + %C = icmp sle <2 x i32> %A, <i32 2, i32 2> + %D = and <2 x i1> %B, %C + ret <2 x i1> %D +} + define i1 @test24(i32 %A) { ; CHECK-LABEL: @test24( ; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 %A, 2 @@ -280,11 +293,24 @@ define i1 @test25(i32 %A) { ; %B = icmp sge i32 %A, 50 %C = icmp slt i32 %A, 100 - ;; (A-50) <u 50 %D = and i1 %B, %C ret i1 %D } +; FIXME: Vectors should fold too. +define <2 x i1> @test25vec(<2 x i32> %A) { +; CHECK-LABEL: @test25vec( +; CHECK-NEXT: [[B:%.*]] = icmp sgt <2 x i32> %A, <i32 49, i32 49> +; CHECK-NEXT: [[C:%.*]] = icmp slt <2 x i32> %A, <i32 100, i32 100> +; CHECK-NEXT: [[D:%.*]] = and <2 x i1> [[B]], [[C]] +; CHECK-NEXT: ret <2 x i1> [[D]] +; + %B = icmp sge <2 x i32> %A, <i32 50, i32 50> + %C = icmp slt <2 x i32> %A, <i32 100, i32 100> + %D = and <2 x i1> %B, %C + ret <2 x i1> %D +} + define i1 @test26(i32 %A) { ; CHECK-LABEL: @test26( ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 %A, -49 diff --git a/llvm/test/Transforms/InstCombine/and2.ll b/llvm/test/Transforms/InstCombine/and2.ll index 49ce38421374..3d043b0864cd 100644 --- a/llvm/test/Transforms/InstCombine/and2.ll +++ b/llvm/test/Transforms/InstCombine/and2.ll @@ -85,6 +85,20 @@ define i1 @test8(i32 %i) { ret i1 %cond } +; FIXME: Vectors should fold too. +define <2 x i1> @test8vec(<2 x i32> %i) { +; CHECK-LABEL: @test8vec( +; CHECK-NEXT: [[CMP1:%.*]] = icmp ne <2 x i32> %i, zeroinitializer +; CHECK-NEXT: [[CMP2:%.*]] = icmp ult <2 x i32> %i, <i32 14, i32 14> +; CHECK-NEXT: [[COND:%.*]] = and <2 x i1> [[CMP1]], [[CMP2]] +; CHECK-NEXT: ret <2 x i1> [[COND]] +; + %cmp1 = icmp ne <2 x i32> %i, zeroinitializer + %cmp2 = icmp ult <2 x i32> %i, <i32 14, i32 14> + %cond = and <2 x i1> %cmp1, %cmp2 + ret <2 x i1> %cond +} + ; combine -x & 1 into x & 1 define i64 @test9(i64 %x) { ; CHECK-LABEL: @test9( diff --git a/llvm/test/Transforms/InstCombine/or.ll b/llvm/test/Transforms/InstCombine/or.ll index b31e9a6d0a92..4fb1978615d1 100644 --- a/llvm/test/Transforms/InstCombine/or.ll +++ b/llvm/test/Transforms/InstCombine/or.ll @@ -189,11 +189,24 @@ define i1 @test18(i32 %A) { ; %B = icmp sge i32 %A, 100 %C = icmp slt i32 %A, 50 - ;; (A-50) >u 50 %D = or i1 %B, %C ret i1 %D } +; FIXME: Vectors should fold too. +define <2 x i1> @test18vec(<2 x i32> %A) { +; CHECK-LABEL: @test18vec( +; CHECK-NEXT: [[B:%.*]] = icmp sgt <2 x i32> %A, <i32 99, i32 99> +; CHECK-NEXT: [[C:%.*]] = icmp slt <2 x i32> %A, <i32 50, i32 50> +; CHECK-NEXT: [[D:%.*]] = or <2 x i1> [[B]], [[C]] +; CHECK-NEXT: ret <2 x i1> [[D]] +; + %B = icmp sge <2 x i32> %A, <i32 100, i32 100> + %C = icmp slt <2 x i32> %A, <i32 50, i32 50> + %D = or <2 x i1> %B, %C + ret <2 x i1> %D +} + define i1 @test19(i32 %A) { ; CHECK-LABEL: @test19( ; CHECK-NEXT: [[TMP1:%.*]] = or i32 %A, 1