[llvm] 095dcee - [X86] Correct some isel patterns for v1i1 KNOT/KANDN/KXNOR.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 6 17:59:50 PDT 2020
Author: Craig Topper
Date: 2020-06-06T17:25:56-07:00
New Revision: 095dceefa3f7f9d83b7b7e3dfe609162d4a1a586
URL: https://github.com/llvm/llvm-project/commit/095dceefa3f7f9d83b7b7e3dfe609162d4a1a586
DIFF: https://github.com/llvm/llvm-project/commit/095dceefa3f7f9d83b7b7e3dfe609162d4a1a586.diff
LOG: [X86] Correct some isel patterns for v1i1 KNOT/KANDN/KXNOR.
The KNOT pattern was missing. The others were
looking for a v1i1 -1 instead of a vector all ones.
Added:
Modified:
llvm/lib/Target/X86/X86InstrAVX512.td
llvm/test/CodeGen/X86/avx512-mask-op.ll
llvm/test/CodeGen/X86/avx512-select.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td b/llvm/lib/Target/X86/X86InstrAVX512.td
index a781f3bcd560..3c693b1c66c4 100644
--- a/llvm/lib/Target/X86/X86InstrAVX512.td
+++ b/llvm/lib/Target/X86/X86InstrAVX512.td
@@ -2959,6 +2959,8 @@ def : Pat<(vnot VK4:$src),
(COPY_TO_REGCLASS (KNOTWrr (COPY_TO_REGCLASS VK4:$src, VK16)), VK4)>;
def : Pat<(vnot VK2:$src),
(COPY_TO_REGCLASS (KNOTWrr (COPY_TO_REGCLASS VK2:$src, VK16)), VK2)>;
+def : Pat<(vnot VK1:$src),
+ (COPY_TO_REGCLASS (KNOTWrr (COPY_TO_REGCLASS VK1:$src, VK16)), VK2)>;
// Mask binary operation
// - KAND, KANDN, KOR, KXNOR, KXOR
@@ -2988,8 +2990,6 @@ multiclass avx512_mask_binop_all<bits<8> opc, string OpcodeStr,
sched, HasBWI, IsCommutable>, VEX_4V, VEX_L, VEX_W, PS;
}
-def andn : PatFrag<(ops node:$i0, node:$i1), (and (not node:$i0), node:$i1)>;
-def xnor : PatFrag<(ops node:$i0, node:$i1), (not (xor node:$i0, node:$i1))>;
// These nodes use 'vnot' instead of 'not' to support vectors.
def vandn : PatFrag<(ops node:$i0, node:$i1), (and (vnot node:$i0), node:$i1)>;
def vxnor : PatFrag<(ops node:$i0, node:$i1), (vnot (xor node:$i0, node:$i1))>;
@@ -3002,7 +3002,7 @@ defm KXOR : avx512_mask_binop_all<0x47, "kxor", xor, SchedWriteVecLogic.XM
defm KANDN : avx512_mask_binop_all<0x42, "kandn", vandn, SchedWriteVecLogic.XMM, 0>;
defm KADD : avx512_mask_binop_all<0x4A, "kadd", X86kadd, SchedWriteVecLogic.XMM, 1, HasDQI>;
-multiclass avx512_binop_pat<SDPatternOperator VOpNode, SDPatternOperator OpNode,
+multiclass avx512_binop_pat<SDPatternOperator VOpNode,
Instruction Inst> {
// With AVX512F, 8-bit mask is promoted to 16-bit mask,
// for the DQI set, this type is legal and KxxxB instruction is used
@@ -3013,7 +3013,7 @@ multiclass avx512_binop_pat<SDPatternOperator VOpNode, SDPatternOperator OpNode,
(COPY_TO_REGCLASS VK8:$src2, VK16)), VK8)>;
// All types smaller than 8 bits require conversion anyway
- def : Pat<(OpNode VK1:$src1, VK1:$src2),
+ def : Pat<(VOpNode VK1:$src1, VK1:$src2),
(COPY_TO_REGCLASS (Inst
(COPY_TO_REGCLASS VK1:$src1, VK16),
(COPY_TO_REGCLASS VK1:$src2, VK16)), VK1)>;
@@ -3027,11 +3027,11 @@ multiclass avx512_binop_pat<SDPatternOperator VOpNode, SDPatternOperator OpNode,
(COPY_TO_REGCLASS VK4:$src2, VK16)), VK4)>;
}
-defm : avx512_binop_pat<and, and, KANDWrr>;
-defm : avx512_binop_pat<vandn, andn, KANDNWrr>;
-defm : avx512_binop_pat<or, or, KORWrr>;
-defm : avx512_binop_pat<vxnor, xnor, KXNORWrr>;
-defm : avx512_binop_pat<xor, xor, KXORWrr>;
+defm : avx512_binop_pat<and, KANDWrr>;
+defm : avx512_binop_pat<vandn, KANDNWrr>;
+defm : avx512_binop_pat<or, KORWrr>;
+defm : avx512_binop_pat<vxnor, KXNORWrr>;
+defm : avx512_binop_pat<xor, KXORWrr>;
// Mask unpacking
multiclass avx512_mask_unpck<string Suffix, X86KVectorVTInfo Dst,
diff --git a/llvm/test/CodeGen/X86/avx512-mask-op.ll b/llvm/test/CodeGen/X86/avx512-mask-op.ll
index a1e0b8d85c1b..4b3c52d16f01 100644
--- a/llvm/test/CodeGen/X86/avx512-mask-op.ll
+++ b/llvm/test/CodeGen/X86/avx512-mask-op.ll
@@ -1544,8 +1544,7 @@ define void @store_v1i1(<1 x i1> %c , <1 x i1>* %ptr) {
; KNL-LABEL: store_v1i1:
; KNL: ## %bb.0:
; KNL-NEXT: kmovw %edi, %k0
-; KNL-NEXT: kxnorw %k0, %k0, %k1
-; KNL-NEXT: kxorw %k1, %k0, %k0
+; KNL-NEXT: knotw %k0, %k0
; KNL-NEXT: kmovw %k0, %eax
; KNL-NEXT: movb %al, (%rsi)
; KNL-NEXT: retq
@@ -1553,16 +1552,14 @@ define void @store_v1i1(<1 x i1> %c , <1 x i1>* %ptr) {
; SKX-LABEL: store_v1i1:
; SKX: ## %bb.0:
; SKX-NEXT: kmovd %edi, %k0
-; SKX-NEXT: kxnorw %k0, %k0, %k1
-; SKX-NEXT: kxorw %k1, %k0, %k0
+; SKX-NEXT: knotw %k0, %k0
; SKX-NEXT: kmovb %k0, (%rsi)
; SKX-NEXT: retq
;
; AVX512BW-LABEL: store_v1i1:
; AVX512BW: ## %bb.0:
; AVX512BW-NEXT: kmovd %edi, %k0
-; AVX512BW-NEXT: kxnorw %k0, %k0, %k1
-; AVX512BW-NEXT: kxorw %k1, %k0, %k0
+; AVX512BW-NEXT: knotw %k0, %k0
; AVX512BW-NEXT: kmovd %k0, %eax
; AVX512BW-NEXT: movb %al, (%rsi)
; AVX512BW-NEXT: retq
@@ -1570,8 +1567,7 @@ define void @store_v1i1(<1 x i1> %c , <1 x i1>* %ptr) {
; AVX512DQ-LABEL: store_v1i1:
; AVX512DQ: ## %bb.0:
; AVX512DQ-NEXT: kmovw %edi, %k0
-; AVX512DQ-NEXT: kxnorw %k0, %k0, %k1
-; AVX512DQ-NEXT: kxorw %k1, %k0, %k0
+; AVX512DQ-NEXT: knotw %k0, %k0
; AVX512DQ-NEXT: kmovb %k0, (%rsi)
; AVX512DQ-NEXT: retq
;
@@ -1579,8 +1575,7 @@ define void @store_v1i1(<1 x i1> %c , <1 x i1>* %ptr) {
; X86: ## %bb.0:
; X86-NEXT: kmovd {{[0-9]+}}(%esp), %k0
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
-; X86-NEXT: kxnorw %k0, %k0, %k1
-; X86-NEXT: kxorw %k1, %k0, %k0
+; X86-NEXT: knotw %k0, %k0
; X86-NEXT: kmovb %k0, (%eax)
; X86-NEXT: retl
%x = xor <1 x i1> %c, <i1 1>
@@ -5529,44 +5524,36 @@ declare <1 x i1> @llvm.uadd.sat.v1i1(<1 x i1> %x, <1 x i1> %y)
define <1 x i1> @usub_sat_v1i1(<1 x i1> %x, <1 x i1> %y) nounwind {
; KNL-LABEL: usub_sat_v1i1:
; KNL: ## %bb.0:
-; KNL-NEXT: kmovw %edi, %k0
-; KNL-NEXT: kmovw %esi, %k1
-; KNL-NEXT: kxnorw %k0, %k0, %k2
-; KNL-NEXT: kxorw %k2, %k1, %k1
-; KNL-NEXT: kandw %k1, %k0, %k0
+; KNL-NEXT: kmovw %esi, %k0
+; KNL-NEXT: kmovw %edi, %k1
+; KNL-NEXT: kandnw %k1, %k0, %k0
; KNL-NEXT: kmovw %k0, %eax
; KNL-NEXT: ## kill: def $al killed $al killed $eax
; KNL-NEXT: retq
;
; SKX-LABEL: usub_sat_v1i1:
; SKX: ## %bb.0:
-; SKX-NEXT: kmovd %edi, %k0
-; SKX-NEXT: kmovd %esi, %k1
-; SKX-NEXT: kxnorw %k0, %k0, %k2
-; SKX-NEXT: kxorw %k2, %k1, %k1
-; SKX-NEXT: kandw %k1, %k0, %k0
+; SKX-NEXT: kmovd %esi, %k0
+; SKX-NEXT: kmovd %edi, %k1
+; SKX-NEXT: kandnw %k1, %k0, %k0
; SKX-NEXT: kmovd %k0, %eax
; SKX-NEXT: ## kill: def $al killed $al killed $eax
; SKX-NEXT: retq
;
; AVX512BW-LABEL: usub_sat_v1i1:
; AVX512BW: ## %bb.0:
-; AVX512BW-NEXT: kmovd %edi, %k0
-; AVX512BW-NEXT: kmovd %esi, %k1
-; AVX512BW-NEXT: kxnorw %k0, %k0, %k2
-; AVX512BW-NEXT: kxorw %k2, %k1, %k1
-; AVX512BW-NEXT: kandw %k1, %k0, %k0
+; AVX512BW-NEXT: kmovd %esi, %k0
+; AVX512BW-NEXT: kmovd %edi, %k1
+; AVX512BW-NEXT: kandnw %k1, %k0, %k0
; AVX512BW-NEXT: kmovd %k0, %eax
; AVX512BW-NEXT: ## kill: def $al killed $al killed $eax
; AVX512BW-NEXT: retq
;
; AVX512DQ-LABEL: usub_sat_v1i1:
; AVX512DQ: ## %bb.0:
-; AVX512DQ-NEXT: kmovw %edi, %k0
-; AVX512DQ-NEXT: kmovw %esi, %k1
-; AVX512DQ-NEXT: kxnorw %k0, %k0, %k2
-; AVX512DQ-NEXT: kxorw %k2, %k1, %k1
-; AVX512DQ-NEXT: kandw %k1, %k0, %k0
+; AVX512DQ-NEXT: kmovw %esi, %k0
+; AVX512DQ-NEXT: kmovw %edi, %k1
+; AVX512DQ-NEXT: kandnw %k1, %k0, %k0
; AVX512DQ-NEXT: kmovw %k0, %eax
; AVX512DQ-NEXT: ## kill: def $al killed $al killed $eax
; AVX512DQ-NEXT: retq
@@ -5575,9 +5562,7 @@ define <1 x i1> @usub_sat_v1i1(<1 x i1> %x, <1 x i1> %y) nounwind {
; X86: ## %bb.0:
; X86-NEXT: kmovd {{[0-9]+}}(%esp), %k0
; X86-NEXT: kmovd {{[0-9]+}}(%esp), %k1
-; X86-NEXT: kxnorw %k0, %k0, %k2
-; X86-NEXT: kxorw %k2, %k1, %k1
-; X86-NEXT: kandw %k1, %k0, %k0
+; X86-NEXT: kandnw %k1, %k0, %k0
; X86-NEXT: kmovd %k0, %eax
; X86-NEXT: ## kill: def $al killed $al killed $eax
; X86-NEXT: retl
@@ -5639,44 +5624,36 @@ declare <1 x i1> @llvm.sadd.sat.v1i1(<1 x i1> %x, <1 x i1> %y)
define <1 x i1> @ssub_sat_v1i1(<1 x i1> %x, <1 x i1> %y) nounwind {
; KNL-LABEL: ssub_sat_v1i1:
; KNL: ## %bb.0:
-; KNL-NEXT: kmovw %edi, %k0
-; KNL-NEXT: kmovw %esi, %k1
-; KNL-NEXT: kxnorw %k0, %k0, %k2
-; KNL-NEXT: kxorw %k2, %k1, %k1
-; KNL-NEXT: kandw %k1, %k0, %k0
+; KNL-NEXT: kmovw %esi, %k0
+; KNL-NEXT: kmovw %edi, %k1
+; KNL-NEXT: kandnw %k1, %k0, %k0
; KNL-NEXT: kmovw %k0, %eax
; KNL-NEXT: ## kill: def $al killed $al killed $eax
; KNL-NEXT: retq
;
; SKX-LABEL: ssub_sat_v1i1:
; SKX: ## %bb.0:
-; SKX-NEXT: kmovd %edi, %k0
-; SKX-NEXT: kmovd %esi, %k1
-; SKX-NEXT: kxnorw %k0, %k0, %k2
-; SKX-NEXT: kxorw %k2, %k1, %k1
-; SKX-NEXT: kandw %k1, %k0, %k0
+; SKX-NEXT: kmovd %esi, %k0
+; SKX-NEXT: kmovd %edi, %k1
+; SKX-NEXT: kandnw %k1, %k0, %k0
; SKX-NEXT: kmovd %k0, %eax
; SKX-NEXT: ## kill: def $al killed $al killed $eax
; SKX-NEXT: retq
;
; AVX512BW-LABEL: ssub_sat_v1i1:
; AVX512BW: ## %bb.0:
-; AVX512BW-NEXT: kmovd %edi, %k0
-; AVX512BW-NEXT: kmovd %esi, %k1
-; AVX512BW-NEXT: kxnorw %k0, %k0, %k2
-; AVX512BW-NEXT: kxorw %k2, %k1, %k1
-; AVX512BW-NEXT: kandw %k1, %k0, %k0
+; AVX512BW-NEXT: kmovd %esi, %k0
+; AVX512BW-NEXT: kmovd %edi, %k1
+; AVX512BW-NEXT: kandnw %k1, %k0, %k0
; AVX512BW-NEXT: kmovd %k0, %eax
; AVX512BW-NEXT: ## kill: def $al killed $al killed $eax
; AVX512BW-NEXT: retq
;
; AVX512DQ-LABEL: ssub_sat_v1i1:
; AVX512DQ: ## %bb.0:
-; AVX512DQ-NEXT: kmovw %edi, %k0
-; AVX512DQ-NEXT: kmovw %esi, %k1
-; AVX512DQ-NEXT: kxnorw %k0, %k0, %k2
-; AVX512DQ-NEXT: kxorw %k2, %k1, %k1
-; AVX512DQ-NEXT: kandw %k1, %k0, %k0
+; AVX512DQ-NEXT: kmovw %esi, %k0
+; AVX512DQ-NEXT: kmovw %edi, %k1
+; AVX512DQ-NEXT: kandnw %k1, %k0, %k0
; AVX512DQ-NEXT: kmovw %k0, %eax
; AVX512DQ-NEXT: ## kill: def $al killed $al killed $eax
; AVX512DQ-NEXT: retq
@@ -5685,9 +5662,7 @@ define <1 x i1> @ssub_sat_v1i1(<1 x i1> %x, <1 x i1> %y) nounwind {
; X86: ## %bb.0:
; X86-NEXT: kmovd {{[0-9]+}}(%esp), %k0
; X86-NEXT: kmovd {{[0-9]+}}(%esp), %k1
-; X86-NEXT: kxnorw %k0, %k0, %k2
-; X86-NEXT: kxorw %k2, %k1, %k1
-; X86-NEXT: kandw %k1, %k0, %k0
+; X86-NEXT: kandnw %k1, %k0, %k0
; X86-NEXT: kmovd %k0, %eax
; X86-NEXT: ## kill: def $al killed $al killed $eax
; X86-NEXT: retl
diff --git a/llvm/test/CodeGen/X86/avx512-select.ll b/llvm/test/CodeGen/X86/avx512-select.ll
index bb5e72bf18e7..634757ddbf9d 100644
--- a/llvm/test/CodeGen/X86/avx512-select.ll
+++ b/llvm/test/CodeGen/X86/avx512-select.ll
@@ -549,10 +549,8 @@ define void @vselect_v1i1(<1 x i1>* %w, <1 x i1>* %x, <1 x i1>* %y) nounwind {
; X86-AVX512F-NEXT: kmovw %ecx, %k1
; X86-AVX512F-NEXT: movzbl (%eax), %eax
; X86-AVX512F-NEXT: kmovw %eax, %k2
+; X86-AVX512F-NEXT: kandnw %k1, %k2, %k1
; X86-AVX512F-NEXT: kandw %k2, %k0, %k0
-; X86-AVX512F-NEXT: kxnorw %k0, %k0, %k3
-; X86-AVX512F-NEXT: kxorw %k3, %k2, %k2
-; X86-AVX512F-NEXT: kandw %k2, %k1, %k1
; X86-AVX512F-NEXT: korw %k1, %k0, %k0
; X86-AVX512F-NEXT: kmovw %k0, %eax
; X86-AVX512F-NEXT: movb %al, (%edx)
@@ -567,10 +565,8 @@ define void @vselect_v1i1(<1 x i1>* %w, <1 x i1>* %x, <1 x i1>* %y) nounwind {
; X64-AVX512F-NEXT: kmovw %eax, %k1
; X64-AVX512F-NEXT: movzbl (%rdi), %eax
; X64-AVX512F-NEXT: kmovw %eax, %k2
+; X64-AVX512F-NEXT: kandnw %k1, %k2, %k1
; X64-AVX512F-NEXT: kandw %k2, %k0, %k0
-; X64-AVX512F-NEXT: kxnorw %k0, %k0, %k3
-; X64-AVX512F-NEXT: kxorw %k3, %k2, %k2
-; X64-AVX512F-NEXT: kandw %k2, %k1, %k1
; X64-AVX512F-NEXT: korw %k1, %k0, %k0
; X64-AVX512F-NEXT: kmovw %k0, %eax
; X64-AVX512F-NEXT: movb %al, (%rsi)
@@ -588,10 +584,8 @@ define void @vselect_v1i1(<1 x i1>* %w, <1 x i1>* %x, <1 x i1>* %y) nounwind {
; X86-AVX512BW-NEXT: kmovd %ecx, %k1
; X86-AVX512BW-NEXT: movzbl (%eax), %eax
; X86-AVX512BW-NEXT: kmovd %eax, %k2
+; X86-AVX512BW-NEXT: kandnw %k1, %k2, %k1
; X86-AVX512BW-NEXT: kandw %k2, %k0, %k0
-; X86-AVX512BW-NEXT: kxnorw %k0, %k0, %k3
-; X86-AVX512BW-NEXT: kxorw %k3, %k2, %k2
-; X86-AVX512BW-NEXT: kandw %k2, %k1, %k1
; X86-AVX512BW-NEXT: korw %k1, %k0, %k0
; X86-AVX512BW-NEXT: kmovd %k0, %eax
; X86-AVX512BW-NEXT: movb %al, (%edx)
@@ -606,10 +600,8 @@ define void @vselect_v1i1(<1 x i1>* %w, <1 x i1>* %x, <1 x i1>* %y) nounwind {
; X64-AVX512BW-NEXT: kmovd %eax, %k1
; X64-AVX512BW-NEXT: movzbl (%rdi), %eax
; X64-AVX512BW-NEXT: kmovd %eax, %k2
+; X64-AVX512BW-NEXT: kandnw %k1, %k2, %k1
; X64-AVX512BW-NEXT: kandw %k2, %k0, %k0
-; X64-AVX512BW-NEXT: kxnorw %k0, %k0, %k3
-; X64-AVX512BW-NEXT: kxorw %k3, %k2, %k2
-; X64-AVX512BW-NEXT: kandw %k2, %k1, %k1
; X64-AVX512BW-NEXT: korw %k1, %k0, %k0
; X64-AVX512BW-NEXT: kmovd %k0, %eax
; X64-AVX512BW-NEXT: movb %al, (%rsi)
More information about the llvm-commits
mailing list