[llvm] a736306 - [X86] Add vector test coverage for or with no common bits tests
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 29 06:59:13 PST 2021
Author: Omer Aviram
Date: 2021-11-29T09:57:57-05:00
New Revision: a7363067e69a60442a1d52e93207ed7a86ce9d6a
URL: https://github.com/llvm/llvm-project/commit/a7363067e69a60442a1d52e93207ed7a86ce9d6a
DIFF: https://github.com/llvm/llvm-project/commit/a7363067e69a60442a1d52e93207ed7a86ce9d6a.diff
LOG: [X86] Add vector test coverage for or with no common bits tests
Ensure D113970 handles vector types patterns as well.
Differential Revision: https://reviews.llvm.org/D114575
Added:
llvm/test/CodeGen/X86/vec_no-common-bits.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/X86/vec_no-common-bits.ll b/llvm/test/CodeGen/X86/vec_no-common-bits.ll
new file mode 100644
index 000000000000..6e03edbe8b53
--- /dev/null
+++ b/llvm/test/CodeGen/X86/vec_no-common-bits.ll
@@ -0,0 +1,161 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK
+
+; In the following patterns, lhs and rhs of the or instruction have no common bits.
+; Therefore, "add" and "or" instructions are equal.
+
+define <2 x i32> @or_and_and_rhs_neg_vec_i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> %z) {
+; CHECK-LABEL: or_and_and_rhs_neg_vec_i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: pand %xmm1, %xmm2
+; CHECK-NEXT: pandn %xmm0, %xmm1
+; CHECK-NEXT: movdqa %xmm2, %xmm0
+; CHECK-NEXT: por %xmm1, %xmm0
+; CHECK-NEXT: paddd %xmm2, %xmm1
+; CHECK-NEXT: psubd %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %and1 = and <2 x i32> %z, %y
+ %xor = xor <2 x i32> %y, <i32 -1, i32 -1>
+ %and2 = and <2 x i32> %x, %xor
+ %or = or <2 x i32> %and1, %and2
+ %add = add <2 x i32> %and1, %and2
+ %sub = sub <2 x i32> %or, %add
+ ret <2 x i32> %sub
+}
+
+define <2 x i32> @or_and_and_lhs_neg_vec_i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> %z) {
+; CHECK-LABEL: or_and_and_lhs_neg_vec_i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: pand %xmm1, %xmm2
+; CHECK-NEXT: pandn %xmm0, %xmm1
+; CHECK-NEXT: movdqa %xmm2, %xmm0
+; CHECK-NEXT: por %xmm1, %xmm0
+; CHECK-NEXT: paddd %xmm2, %xmm1
+; CHECK-NEXT: psubd %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %and1 = and <2 x i32> %z, %y
+ %xor = xor <2 x i32> %y, <i32 -1, i32 -1>
+ %and2 = and <2 x i32> %xor, %x
+ %or = or <2 x i32> %and1, %and2
+ %add = add <2 x i32> %and1, %and2
+ %sub = sub <2 x i32> %or, %add
+ ret <2 x i32> %sub
+}
+
+define <2 x i32> @or_and_rhs_neg_and_vec_i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> %z) {
+; CHECK-LABEL: or_and_rhs_neg_and_vec_i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: pand %xmm1, %xmm0
+; CHECK-NEXT: pandn %xmm2, %xmm1
+; CHECK-NEXT: movdqa %xmm1, %xmm2
+; CHECK-NEXT: por %xmm0, %xmm2
+; CHECK-NEXT: paddd %xmm0, %xmm1
+; CHECK-NEXT: psubd %xmm1, %xmm2
+; CHECK-NEXT: movdqa %xmm2, %xmm0
+; CHECK-NEXT: retq
+ %xor = xor <2 x i32> %y, <i32 -1, i32 -1>
+ %and1 = and <2 x i32> %z, %xor
+ %and2 = and <2 x i32> %x, %y
+ %or = or <2 x i32> %and1, %and2
+ %add = add <2 x i32> %and1, %and2
+ %sub = sub <2 x i32> %or, %add
+ ret <2 x i32> %sub
+}
+
+define <2 x i32> @or_and_lhs_neg_and_vec_i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> %z) {
+; CHECK-LABEL: or_and_lhs_neg_and_vec_i32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: pand %xmm1, %xmm0
+; CHECK-NEXT: pandn %xmm2, %xmm1
+; CHECK-NEXT: movdqa %xmm1, %xmm2
+; CHECK-NEXT: por %xmm0, %xmm2
+; CHECK-NEXT: paddd %xmm0, %xmm1
+; CHECK-NEXT: psubd %xmm1, %xmm2
+; CHECK-NEXT: movdqa %xmm2, %xmm0
+; CHECK-NEXT: retq
+ %xor = xor <2 x i32> %y, <i32 -1, i32 -1>
+ %and1 = and <2 x i32> %xor, %z
+ %and2 = and <2 x i32> %x, %y
+ %or = or <2 x i32> %and1, %and2
+ %add = add <2 x i32> %and1, %and2
+ %sub = sub <2 x i32> %or, %add
+ ret <2 x i32> %sub
+}
+
+define <2 x i64> @or_and_and_rhs_neg_vec_i64(<2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {
+; CHECK-LABEL: or_and_and_rhs_neg_vec_i64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: pand %xmm1, %xmm2
+; CHECK-NEXT: pandn %xmm0, %xmm1
+; CHECK-NEXT: movdqa %xmm2, %xmm0
+; CHECK-NEXT: por %xmm1, %xmm0
+; CHECK-NEXT: paddq %xmm2, %xmm1
+; CHECK-NEXT: psubq %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %and1 = and <2 x i64> %z, %y
+ %xor = xor <2 x i64> %y, <i64 -1, i64 -1>
+ %and2 = and <2 x i64> %x, %xor
+ %or = or <2 x i64> %and1, %and2
+ %add = add <2 x i64> %and1, %and2
+ %sub = sub <2 x i64> %or, %add
+ ret <2 x i64> %sub
+}
+
+define <2 x i64> @or_and_and_lhs_neg_vec_i64(<2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {
+; CHECK-LABEL: or_and_and_lhs_neg_vec_i64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: pand %xmm1, %xmm2
+; CHECK-NEXT: pandn %xmm0, %xmm1
+; CHECK-NEXT: movdqa %xmm2, %xmm0
+; CHECK-NEXT: por %xmm1, %xmm0
+; CHECK-NEXT: paddq %xmm2, %xmm1
+; CHECK-NEXT: psubq %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %and1 = and <2 x i64> %z, %y
+ %xor = xor <2 x i64> %y, <i64 -1, i64 -1>
+ %and2 = and <2 x i64> %xor, %x
+ %or = or <2 x i64> %and1, %and2
+ %add = add <2 x i64> %and1, %and2
+ %sub = sub <2 x i64> %or, %add
+ ret <2 x i64> %sub
+}
+
+define <2 x i64> @or_and_rhs_neg_and_vec_i64(<2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {
+; CHECK-LABEL: or_and_rhs_neg_and_vec_i64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: pand %xmm1, %xmm0
+; CHECK-NEXT: pandn %xmm2, %xmm1
+; CHECK-NEXT: movdqa %xmm1, %xmm2
+; CHECK-NEXT: por %xmm0, %xmm2
+; CHECK-NEXT: paddq %xmm0, %xmm1
+; CHECK-NEXT: psubq %xmm1, %xmm2
+; CHECK-NEXT: movdqa %xmm2, %xmm0
+; CHECK-NEXT: retq
+ %xor = xor <2 x i64> %y, <i64 -1, i64 -1>
+ %and1 = and <2 x i64> %z, %xor
+ %and2 = and <2 x i64> %x, %y
+ %or = or <2 x i64> %and1, %and2
+ %add = add <2 x i64> %and1, %and2
+ %sub = sub <2 x i64> %or, %add
+ ret <2 x i64> %sub
+}
+
+define <2 x i64> @or_and_lhs_neg_and_vec_i64(<2 x i64> %x, <2 x i64> %y, <2 x i64> %z) {
+; CHECK-LABEL: or_and_lhs_neg_and_vec_i64:
+; CHECK: # %bb.0:
+; CHECK-NEXT: pand %xmm1, %xmm0
+; CHECK-NEXT: pandn %xmm2, %xmm1
+; CHECK-NEXT: movdqa %xmm1, %xmm2
+; CHECK-NEXT: por %xmm0, %xmm2
+; CHECK-NEXT: paddq %xmm0, %xmm1
+; CHECK-NEXT: psubq %xmm1, %xmm2
+; CHECK-NEXT: movdqa %xmm2, %xmm0
+; CHECK-NEXT: retq
+ %xor = xor <2 x i64> %y, <i64 -1, i64 -1>
+ %and1 = and <2 x i64> %xor, %z
+ %and2 = and <2 x i64> %x, %y
+ %or = or <2 x i64> %and1, %and2
+ %add = add <2 x i64> %and1, %and2
+ %sub = sub <2 x i64> %or, %add
+ ret <2 x i64> %sub
+}
More information about the llvm-commits
mailing list