[llvm] r301296 - [InstCombine] Add test cases showing failures to handle commuted patterns after tricking the operand complexity sorting.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 23:22:17 PDT 2017
Author: ctopper
Date: Tue Apr 25 01:22:17 2017
New Revision: 301296
URL: http://llvm.org/viewvc/llvm-project?rev=301296&view=rev
Log:
[InstCombine] Add test cases showing failures to handle commuted patterns after tricking the operand complexity sorting.
Modified:
llvm/trunk/test/Transforms/InstCombine/and.ll
Modified: llvm/trunk/test/Transforms/InstCombine/and.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/and.ll?rev=301296&r1=301295&r2=301296&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/and.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/and.ll Tue Apr 25 01:22:17 2017
@@ -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
+}
More information about the llvm-commits
mailing list