From 17d26f1cbf5fdf2f45bcee5d1057c50a805c3917 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 25 Apr 2017 06:22:17 +0000 Subject: [PATCH] [InstCombine] Add test cases showing failures to handle commuted patterns after tricking the operand complexity sorting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301296 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/and.ll | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/Transforms/InstCombine/and.ll b/test/Transforms/InstCombine/and.ll index 9a4d1e5758b..1816b2402e3 100644 --- a/test/Transforms/InstCombine/and.ll +++ b/test/Transforms/InstCombine/and.ll @@ -613,3 +613,37 @@ final: %value = and <2 x i32> %A, ret <2 x i32> %value } + +define i32 @test42(i32 %a, i32 %c, i32 %d) { +; CHECK-LABEL: @test42( +; CHECK-NEXT: [[FORCE:%.*]] = mul i32 [[C:%.*]], [[D:%.*]] +; CHECK-NEXT: [[OR:%.*]] = or i32 [[FORCE]], [[A:%.*]] +; CHECK-NEXT: [[NOTA:%.*]] = xor i32 [[A]], -1 +; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[FORCE]], [[NOTA]] +; CHECK-NEXT: [[AND:%.*]] = and i32 [[XOR]], [[OR]] +; CHECK-NEXT: ret i32 [[AND]] +; + %force = mul i32 %c, %d ; forces the complexity sorting + %or = or i32 %a, %force + %nota = xor i32 %a, -1 + %xor = xor i32 %nota, %force + %and = and i32 %xor, %or + ret i32 %and +} + +define i32 @test43(i32 %a, i32 %c, i32 %d) { +; CHECK-LABEL: @test43( +; CHECK-NEXT: [[FORCE:%.*]] = mul i32 [[C:%.*]], [[D:%.*]] +; CHECK-NEXT: [[OR:%.*]] = or i32 [[FORCE]], [[A:%.*]] +; CHECK-NEXT: [[NOTA:%.*]] = xor i32 [[A]], -1 +; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[FORCE]], [[NOTA]] +; CHECK-NEXT: [[AND:%.*]] = and i32 [[OR]], [[XOR]] +; CHECK-NEXT: ret i32 [[AND]] +; + %force = mul i32 %c, %d ; forces the complexity sorting + %or = or i32 %a, %force + %nota = xor i32 %a, -1 + %xor = xor i32 %nota, %force + %and = and i32 %or, %xor + ret i32 %and +} -- 2.40.0