[llvm] 1fdb0f6 - [InstSimplify] add tests for 'or' with logic ops; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 30 09:57:02 PST 2021
Author: Sanjay Patel
Date: 2021-11-30T12:55:36-05:00
New Revision: 1fdb0f6ffdffdb67ab9169aab39f0429eaae3a98
URL: https://github.com/llvm/llvm-project/commit/1fdb0f6ffdffdb67ab9169aab39f0429eaae3a98
DIFF: https://github.com/llvm/llvm-project/commit/1fdb0f6ffdffdb67ab9169aab39f0429eaae3a98.diff
LOG: [InstSimplify] add tests for 'or' with logic ops; NFC
The code for these transforms can be refactored,
but the existing tests are incomplete.
Added:
Modified:
llvm/test/Transforms/InstSimplify/or.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/or.ll b/llvm/test/Transforms/InstSimplify/or.ll
index a5e047ecd0f0..1d9d741fef2b 100644
--- a/llvm/test/Transforms/InstSimplify/or.ll
+++ b/llvm/test/Transforms/InstSimplify/or.ll
@@ -58,8 +58,9 @@ define i32 @test6(i32 %A) {
}
; A | ~A == -1
-define i32 @test7(i32 %A) {
-; CHECK-LABEL: @test7(
+
+define i32 @or_not(i32 %A) {
+; CHECK-LABEL: @or_not(
; CHECK-NEXT: ret i32 -1
;
%NotA = xor i32 %A, -1
@@ -67,6 +68,15 @@ define i32 @test7(i32 %A) {
ret i32 %B
}
+define <2 x i4> @or_not_commute_vec_undef(<2 x i4> %A) {
+; CHECK-LABEL: @or_not_commute_vec_undef(
+; CHECK-NEXT: ret <2 x i4> <i4 -1, i4 -1>
+;
+ %NotA = xor <2 x i4> %A, <i4 -1, i4 undef>
+ %B = or <2 x i4> %NotA, %A
+ ret <2 x i4> %B
+}
+
define i8 @test8(i8 %A) {
; CHECK-LABEL: @test8(
; CHECK-NEXT: ret i8 -1
@@ -244,6 +254,44 @@ define <2 x i399> @test8_apint(<2 x i399> %V, <2 x i399> %M) {
ret <2 x i399> %R
}
+; (A & B) | A = A
+
+define i8 @or_and_common_op_commute0(i8 %a, i8 %b) {
+; CHECK-LABEL: @or_and_common_op_commute0(
+; CHECK-NEXT: ret i8 [[A:%.*]]
+;
+ %and = and i8 %a, %b
+ %or = or i8 %and, %a
+ ret i8 %or
+}
+
+define <2 x i8> @or_and_common_op_commute1(<2 x i8> %a, <2 x i8> %b) {
+; CHECK-LABEL: @or_and_common_op_commute1(
+; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
+;
+ %and = and <2 x i8> %b, %a
+ %or = or <2 x i8> %and, %a
+ ret <2 x i8> %or
+}
+
+define i8 @or_and_common_op_commute2(i8 %a, i8 %b) {
+; CHECK-LABEL: @or_and_common_op_commute2(
+; CHECK-NEXT: ret i8 [[A:%.*]]
+;
+ %and = and i8 %a, %b
+ %or = or i8 %a, %and
+ ret i8 %or
+}
+
+define <2 x i8> @or_and_common_op_commute3(<2 x i8> %a, <2 x i8> %b) {
+; CHECK-LABEL: @or_and_common_op_commute3(
+; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
+;
+ %and = and <2 x i8> %b, %a
+ %or = or <2 x i8> %a, %and
+ ret <2 x i8> %or
+}
+
; A | ~(A & B) = -1
define i1 @or_with_not_op_commute1(i1 %a, i1 %b) {
More information about the llvm-commits
mailing list