From b73d7aed71c3f750f2ca64b93eed83eac10e1458 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 22 Jul 2016 21:02:33 +0000 Subject: [PATCH] add tests for icmp vector folds llvm-svn: 276472 --- llvm/test/Transforms/InstCombine/add.ll | 37 ++++++++++++++++++++++++++++++++ llvm/test/Transforms/InstCombine/xor.ll | 38 +++++++++++++++++++++++++++------ 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/add.ll b/llvm/test/Transforms/InstCombine/add.ll index c3f24f3..e75c032 100644 --- a/llvm/test/Transforms/InstCombine/add.ll +++ b/llvm/test/Transforms/InstCombine/add.ll @@ -109,6 +109,19 @@ define i1 @test10(i8 %A, i8 %b) { ret i1 %c } +; FIXME: Vectors should fold the same way. + +define <2 x i1> @test10vec(<2 x i8> %a, <2 x i8> %b) { +; CHECK-LABEL: @test10vec( +; CHECK-NEXT: [[C:%.*]] = add <2 x i8> %a, %b +; CHECK-NEXT: [[D:%.*]] = icmp ne <2 x i8> [[C]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[D]] +; + %c = add <2 x i8> %a, %b + %d = icmp ne <2 x i8> %c, zeroinitializer + ret <2 x i1> %d +} + define i1 @test11(i8 %A) { ; CHECK-LABEL: @test11( ; CHECK-NEXT: [[C:%.*]] = icmp ne i8 %A, 1 @@ -120,6 +133,18 @@ define i1 @test11(i8 %A) { ret i1 %c } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test11vec(<2 x i8> %a) { +; CHECK-LABEL: @test11vec( +; CHECK-NEXT: [[B:%.*]] = add <2 x i8> %a, +; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i8> [[B]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %b = add <2 x i8> %a, + %c = icmp ne <2 x i8> %b, zeroinitializer + ret <2 x i1> %c +} + ; Should be transformed into shl A, 1? define i32 @test12(i32 %A, i32 %B) { @@ -243,6 +268,18 @@ define i1 @test21(i32 %x) { ret i1 %y } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test21vec(<2 x i32> %x) { +; CHECK-LABEL: @test21vec( +; CHECK-NEXT: [[T:%.*]] = add <2 x i32> %x, +; CHECK-NEXT: [[Y:%.*]] = icmp eq <2 x i32> [[T]], +; CHECK-NEXT: ret <2 x i1> [[Y]] +; + %t = add <2 x i32> %x, + %y = icmp eq <2 x i32> %t, + ret <2 x i1> %y +} + define i32 @test22(i32 %V) { ; CHECK-LABEL: @test22( ; CHECK-NEXT: switch i32 %V, label %Default [ diff --git a/llvm/test/Transforms/InstCombine/xor.ll b/llvm/test/Transforms/InstCombine/xor.ll index 951b446..3441997 100644 --- a/llvm/test/Transforms/InstCombine/xor.ll +++ b/llvm/test/Transforms/InstCombine/xor.ll @@ -105,6 +105,19 @@ define i1 @test9(i8 %A) { ret i1 %C } +; FIXME: Vectors should fold the same way. + +define <2 x i1> @test9vec(<2 x i8> %a) { +; CHECK-LABEL: @test9vec( +; CHECK-NEXT: [[B:%.*]] = xor <2 x i8> %a, +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i8> [[B]], +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %b = xor <2 x i8> %a, + %c = icmp eq <2 x i8> %b, + ret <2 x i1> %c +} + define i8 @test10(i8 %A) { ; CHECK-LABEL: @test10( ; CHECK-NEXT: [[B:%.*]] = and i8 %A, 3 @@ -137,6 +150,19 @@ define i1 @test12(i8 %A) { ret i1 %c } +; FIXME: Vectors should fold the same way. + +define <2 x i1> @test12vec(<2 x i8> %a) { +; CHECK-LABEL: @test12vec( +; CHECK-NEXT: [[B:%.*]] = xor <2 x i8> %a, +; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i8> [[B]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %b = xor <2 x i8> %a, + %c = icmp ne <2 x i8> %b, zeroinitializer + ret <2 x i1> %c +} + define i1 @test13(i8 %A, i8 %B) { ; CHECK-LABEL: @test13( ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i8 %A, %B @@ -233,8 +259,8 @@ define i32 @test21(i1 %C, i32 %A, i32 %B) { define i32 @test22(i1 %X) { ; CHECK-LABEL: @test22( -; CHECK-NEXT: [[TMP1:%.*]] = zext i1 %X to i32 -; CHECK-NEXT: ret i32 [[TMP1]] +; CHECK-NEXT: [[Z:%.*]] = zext i1 %X to i32 +; CHECK-NEXT: ret i32 [[Z]] ; %Y = xor i1 %X, true %Z = zext i1 %Y to i32 @@ -246,8 +272,8 @@ define i32 @test22(i1 %X) { define i32 @fold_zext_xor_sandwich(i1 %X) { ; CHECK-LABEL: @fold_zext_xor_sandwich( -; CHECK-NEXT: [[TMP1:%.*]] = zext i1 %X to i32 -; CHECK-NEXT: [[Q:%.*]] = xor i32 [[TMP1]], 3 +; CHECK-NEXT: [[Z:%.*]] = zext i1 %X to i32 +; CHECK-NEXT: [[Q:%.*]] = xor i32 [[Z]], 3 ; CHECK-NEXT: ret i32 [[Q]] ; %Y = xor i1 %X, true @@ -258,8 +284,8 @@ define i32 @fold_zext_xor_sandwich(i1 %X) { define <2 x i32> @fold_zext_xor_sandwich_vec(<2 x i1> %X) { ; CHECK-LABEL: @fold_zext_xor_sandwich_vec( -; CHECK-NEXT: [[TMP1:%.*]] = zext <2 x i1> %X to <2 x i32> -; CHECK-NEXT: [[Q:%.*]] = xor <2 x i32> [[TMP1]], +; CHECK-NEXT: [[Z:%.*]] = zext <2 x i1> %X to <2 x i32> +; CHECK-NEXT: [[Q:%.*]] = xor <2 x i32> [[Z]], ; CHECK-NEXT: ret <2 x i32> [[Q]] ; %Y = xor <2 x i1> %X, -- 2.7.4