summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-04-25 06:22:17 +0000
committerCraig Topper <craig.topper@gmail.com>2017-04-25 06:22:17 +0000
commite4d7ac4cb1bbf8281433a15509c0fe284cf64ad5 (patch)
treef5cc1fc664122858618b5121ea0cde7cf8bfa8bb
parentb43729bc39b3df959d58864f20c54b659947ca04 (diff)
downloadbcm5719-llvm-e4d7ac4cb1bbf8281433a15509c0fe284cf64ad5.tar.gz
bcm5719-llvm-e4d7ac4cb1bbf8281433a15509c0fe284cf64ad5.zip
[InstCombine] Add test cases showing failures to handle commuted patterns after tricking the operand complexity sorting.
llvm-svn: 301296
-rw-r--r--llvm/test/Transforms/InstCombine/and.ll34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/and.ll b/llvm/test/Transforms/InstCombine/and.ll
index 9a4d1e5758b..1816b2402e3 100644
--- a/llvm/test/Transforms/InstCombine/and.ll
+++ b/llvm/test/Transforms/InstCombine/and.ll
@@ -613,3 +613,37 @@ final:
%value = and <2 x i32> %A, <i32 123, i32 333>
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
+}
OpenPOWER on IntegriCloud