From 322db476f3243ecdbe59645410b24c28cad036ae Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 8 May 2017 18:16:04 +0000 Subject: [PATCH] [InstCombine] move/add tests for not(shr (not X), Y); NFC llvm-svn: 302451 --- llvm/test/Transforms/InstCombine/not.ll | 66 +++++++++++++++++++++++++++++--- llvm/test/Transforms/InstCombine/xor2.ll | 11 ------ 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/not.ll b/llvm/test/Transforms/InstCombine/not.ll index 2760d4a..9f57b6a 100644 --- a/llvm/test/Transforms/InstCombine/not.ll +++ b/llvm/test/Transforms/InstCombine/not.ll @@ -11,8 +11,8 @@ define i32 @test1(i32 %A) { define i1 @invert_icmp(i32 %A, i32 %B) { ; CHECK-LABEL: @invert_icmp( -; CHECK-NEXT: [[NOT:%.*]] = icmp sgt i32 %A, %B -; CHECK-NEXT: ret i1 [[NOT]] +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 %A, %B +; CHECK-NEXT: ret i1 [[CMP]] ; %cmp = icmp sle i32 %A, %B %not = xor i1 %cmp, true @@ -23,8 +23,8 @@ define i1 @invert_icmp(i32 %A, i32 %B) { define i1 @invert_fcmp(float %X, float %Y) { ; CHECK-LABEL: @invert_fcmp( -; CHECK-NEXT: [[NOT:%.*]] = fcmp uge float %X, %Y -; CHECK-NEXT: ret i1 [[NOT]] +; CHECK-NEXT: [[CMP:%.*]] = fcmp uge float %X, %Y +; CHECK-NEXT: ret i1 [[CMP]] ; %cmp = fcmp olt float %X, %Y %not = xor i1 %cmp, true @@ -48,11 +48,65 @@ define zeroext i8 @test6(i32 %a, i32 %b) { define <2 x i1> @test7(<2 x i32> %A, <2 x i32> %B) { ; CHECK-LABEL: @test7( -; CHECK-NEXT: [[RET:%.*]] = icmp sgt <2 x i32> %A, %B -; CHECK-NEXT: ret <2 x i1> [[RET]] +; CHECK-NEXT: [[COND:%.*]] = icmp sgt <2 x i32> %A, %B +; CHECK-NEXT: ret <2 x i1> [[COND]] ; %cond = icmp sle <2 x i32> %A, %B %Ret = xor <2 x i1> %cond, ret <2 x i1> %Ret } +define i32 @not_ashr_not(i32 %A, i32 %B) { +; CHECK-LABEL: @not_ashr_not( +; CHECK-NEXT: [[NOT2:%.*]] = ashr i32 %A, %B +; CHECK-NEXT: ret i32 [[NOT2]] +; + %not1 = xor i32 %A, -1 + %ashr = ashr i32 %not1, %B + %not2 = xor i32 %ashr, -1 + ret i32 %not2 +} + +define i8 @not_ashr_const(i8 %x) { +; CHECK-LABEL: @not_ashr_const( +; CHECK-NEXT: [[NOT:%.*]] = lshr i8 41, %x +; CHECK-NEXT: ret i8 [[NOT]] +; + %shr = ashr i8 -42, %x + %not = xor i8 %shr, -1 + ret i8 %not +} + +define <2 x i8> @not_ashr_const_splat(<2 x i8> %x) { +; CHECK-LABEL: @not_ashr_const_splat( +; CHECK-NEXT: [[SHR:%.*]] = ashr <2 x i8> , %x +; CHECK-NEXT: [[NOT:%.*]] = xor <2 x i8> [[SHR]], +; CHECK-NEXT: ret <2 x i8> [[NOT]] +; + %shr = ashr <2 x i8> , %x + %not = xor <2 x i8> %shr, + ret <2 x i8> %not +} + +define i8 @not_lshr_const(i8 %x) { +; CHECK-LABEL: @not_lshr_const( +; CHECK-NEXT: [[SHR:%.*]] = lshr i8 42, %x +; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[SHR]], -1 +; CHECK-NEXT: ret i8 [[NOT]] +; + %shr = lshr i8 42, %x + %not = xor i8 %shr, -1 + ret i8 %not +} + +define <2 x i8> @not_lshr_const_splat(<2 x i8> %x) { +; CHECK-LABEL: @not_lshr_const_splat( +; CHECK-NEXT: [[SHR:%.*]] = lshr <2 x i8> , %x +; CHECK-NEXT: [[NOT:%.*]] = xor <2 x i8> [[SHR]], +; CHECK-NEXT: ret <2 x i8> [[NOT]] +; + %shr = lshr <2 x i8> , %x + %not = xor <2 x i8> %shr, + ret <2 x i8> %not +} + diff --git a/llvm/test/Transforms/InstCombine/xor2.ll b/llvm/test/Transforms/InstCombine/xor2.ll index f817ac5..3afbf63 100644 --- a/llvm/test/Transforms/InstCombine/xor2.ll +++ b/llvm/test/Transforms/InstCombine/xor2.ll @@ -57,17 +57,6 @@ define i32 @test3(i32 %tmp1) { ret i32 %ov110 } -define i32 @test4(i32 %A, i32 %B) { -; CHECK-LABEL: @test4( -; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 %A, %B -; CHECK-NEXT: ret i32 [[TMP1]] -; - %1 = xor i32 %A, -1 - %2 = ashr i32 %1, %B - %3 = xor i32 %2, -1 - ret i32 %3 -} - ; defect-2 in rdar://12329730 ; (X^C1) >> C2) ^ C3 -> (X>>C2) ^ ((C1>>C2)^C3) ; where the "X" has more than one use -- 2.7.4