[llvm] 77fb8cb - [InstCombine] update tests for logic folds to exercise commuted patterns; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 15 11:38:06 PDT 2020
Author: Sanjay Patel
Date: 2020-10-15T14:37:49-04:00
New Revision: 77fb8cbd60cfd185b710886c4fe53e1865f24ce8
URL: https://github.com/llvm/llvm-project/commit/77fb8cbd60cfd185b710886c4fe53e1865f24ce8
DIFF: https://github.com/llvm/llvm-project/commit/77fb8cbd60cfd185b710886c4fe53e1865f24ce8.diff
LOG: [InstCombine] update tests for logic folds to exercise commuted patterns; NFC
This was the intent for D88551.
I also varied the types a bit for extra coverage
and tried to make better test/value names.
Added:
Modified:
llvm/test/Transforms/InstCombine/xor.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/xor.ll b/llvm/test/Transforms/InstCombine/xor.ll
index ba275a606641..c37983829fbb 100644
--- a/llvm/test/Transforms/InstCombine/xor.ll
+++ b/llvm/test/Transforms/InstCombine/xor.ll
@@ -1172,76 +1172,70 @@ define i8 @not_ashr_wrong_const(i8 %x) {
ret i8 %r
}
-; (~A & B) ^ A --> (A | B)
-; The division ops are here to thwart complexity-based canonicalization: all ops are binops.
+; (~A & B) ^ A --> A | B
-define i32 @test52(i32 %p1, i32 %p2) {
-; CHECK-LABEL: @test52(
-; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[P1:%.*]]
-; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[P2:%.*]]
-; CHECK-NEXT: [[O:%.*]] = xor i32 [[A]], -1
-; CHECK-NEXT: [[R:%.*]] = and i32 [[B]], [[O]]
-; CHECK-NEXT: [[Z:%.*]] = xor i32 [[R]], [[A]]
-; CHECK-NEXT: ret i32 [[Z]]
+define <2 x i32> @xor_andn_commute1(<2 x i32> %a, <2 x i32> %b) {
+; CHECK-LABEL: @xor_andn_commute1(
+; CHECK-NEXT: [[NOTA:%.*]] = xor <2 x i32> [[A:%.*]], <i32 -1, i32 -1>
+; CHECK-NEXT: [[R:%.*]] = and <2 x i32> [[NOTA]], [[B:%.*]]
+; CHECK-NEXT: [[Z:%.*]] = xor <2 x i32> [[R]], [[A]]
+; CHECK-NEXT: ret <2 x i32> [[Z]]
;
- %a = udiv i32 42, %p1
- %b = udiv i32 42, %p2
- %o = xor i32 %a, -1
- %r = and i32 %o, %b
- %z = xor i32 %r, %a
- ret i32 %z
+ %nota = xor <2 x i32> %a, <i32 -1, i32 -1>
+ %r = and <2 x i32> %nota, %b
+ %z = xor <2 x i32> %r, %a
+ ret <2 x i32> %z
}
-; (~B & A) ^ B --> (A | B)
-; The division ops are here to thwart complexity-based canonicalization: all ops are binops.
+; (B & ~A) ^ A --> A | B
-define i32 @test53(i32 %p1, i32 %p2) {
-; CHECK-LABEL: @test53(
-; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[P1:%.*]]
-; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[P2:%.*]]
-; CHECK-NEXT: [[O:%.*]] = xor i32 [[B]], -1
-; CHECK-NEXT: [[R:%.*]] = and i32 [[A]], [[O]]
-; CHECK-NEXT: [[Z:%.*]] = xor i32 [[R]], [[B]]
-; CHECK-NEXT: ret i32 [[Z]]
+define i33 @xor_andn_commute2(i33 %a, i33 %pb) {
+; CHECK-LABEL: @xor_andn_commute2(
+; CHECK-NEXT: [[B:%.*]] = udiv i33 42, [[PB:%.*]]
+; CHECK-NEXT: [[NOTA:%.*]] = xor i33 [[A:%.*]], -1
+; CHECK-NEXT: [[R:%.*]] = and i33 [[B]], [[NOTA]]
+; CHECK-NEXT: [[Z:%.*]] = xor i33 [[R]], [[A]]
+; CHECK-NEXT: ret i33 [[Z]]
;
- %a = udiv i32 42, %p1
- %b = udiv i32 42, %p2
- %o = xor i32 %b, -1
- %r = and i32 %o, %a
- %z = xor i32 %r, %b
- ret i32 %z
+ %b = udiv i33 42, %pb ; thwart complexity-based canonicalization
+ %nota = xor i33 %a, -1
+ %r = and i33 %b, %nota
+ %z = xor i33 %r, %a
+ ret i33 %z
}
-define i32 @test54(i32 %p1, i32 %p2) {
-; CHECK-LABEL: @test54(
-; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[P1:%.*]]
-; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[P2:%.*]]
-; CHECK-NEXT: [[O:%.*]] = xor i32 [[A]], -1
-; CHECK-NEXT: [[R:%.*]] = and i32 [[B]], [[O]]
-; CHECK-NEXT: [[Z:%.*]] = xor i32 [[R]], [[A]]
+; A ^ (~A & B) --> A | B
+
+define i32 @xor_andn_commute3(i32 %pa, i32 %b) {
+; CHECK-LABEL: @xor_andn_commute3(
+; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[PA:%.*]]
+; CHECK-NEXT: [[NOTA:%.*]] = xor i32 [[A]], -1
+; CHECK-NEXT: [[R:%.*]] = and i32 [[NOTA]], [[B:%.*]]
+; CHECK-NEXT: [[Z:%.*]] = xor i32 [[A]], [[R]]
; CHECK-NEXT: ret i32 [[Z]]
;
- %a = udiv i32 42, %p1
- %b = udiv i32 42, %p2
- %o = xor i32 %a, -1
- %r = and i32 %b, %o
- %z = xor i32 %r, %a
+ %a = udiv i32 42, %pa ; thwart complexity-based canonicalization
+ %nota = xor i32 %a, -1
+ %r = and i32 %nota, %b
+ %z = xor i32 %a, %r
ret i32 %z
}
-define i32 @test55(i32 %p1, i32 %p2) {
-; CHECK-LABEL: @test55(
-; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[P1:%.*]]
-; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[P2:%.*]]
-; CHECK-NEXT: [[O:%.*]] = xor i32 [[A]], -1
-; CHECK-NEXT: [[R:%.*]] = and i32 [[B]], [[O]]
+; A ^ (B & ~A) --> A | B
+
+define i32 @xor_andn_commute4(i32 %pa, i32 %pb) {
+; CHECK-LABEL: @xor_andn_commute4(
+; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[PA:%.*]]
+; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[PB:%.*]]
+; CHECK-NEXT: [[NOTA:%.*]] = xor i32 [[A]], -1
+; CHECK-NEXT: [[R:%.*]] = and i32 [[B]], [[NOTA]]
; CHECK-NEXT: [[Z:%.*]] = xor i32 [[A]], [[R]]
; CHECK-NEXT: ret i32 [[Z]]
;
- %a = udiv i32 42, %p1
- %b = udiv i32 42, %p2
- %o = xor i32 %a, -1
- %r = and i32 %o, %b
+ %a = udiv i32 42, %pa ; thwart complexity-based canonicalization
+ %b = udiv i32 42, %pb ; thwart complexity-based canonicalization
+ %nota = xor i32 %a, -1
+ %r = and i32 %b, %nota
%z = xor i32 %a, %r
ret i32 %z
}
More information about the llvm-commits
mailing list