[llvm] b00ef89 - [X86] Custom legalize v1i1 UADDSAT/USUBSAT/SADDSAT/UADDSAT to match v2i1/v4i1/v8i1 etc.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 20 15:14:38 PST 2020
Author: Craig Topper
Date: 2020-02-20T15:13:46-08:00
New Revision: b00ef8951b52451eb31f9e41848246c8fb17a2bb
URL: https://github.com/llvm/llvm-project/commit/b00ef8951b52451eb31f9e41848246c8fb17a2bb
DIFF: https://github.com/llvm/llvm-project/commit/b00ef8951b52451eb31f9e41848246c8fb17a2bb.diff
LOG: [X86] Custom legalize v1i1 UADDSAT/USUBSAT/SADDSAT/UADDSAT to match v2i1/v4i1/v8i1 etc.
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/avx512-mask-op.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index e31d82442183..bf304fc0060b 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -1445,6 +1445,10 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
setOperationAction(ISD::ADD, VT, Custom);
setOperationAction(ISD::SUB, VT, Custom);
setOperationAction(ISD::MUL, VT, Custom);
+ setOperationAction(ISD::UADDSAT, VT, Custom);
+ setOperationAction(ISD::SADDSAT, VT, Custom);
+ setOperationAction(ISD::USUBSAT, VT, Custom);
+ setOperationAction(ISD::SSUBSAT, VT, Custom);
}
for (auto VT : { MVT::v2i1, MVT::v4i1, MVT::v8i1, MVT::v16i1 }) {
@@ -1453,10 +1457,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
setOperationAction(ISD::STRICT_FSETCCS, VT, Custom);
setOperationAction(ISD::SELECT, VT, Custom);
setOperationAction(ISD::TRUNCATE, VT, Custom);
- setOperationAction(ISD::UADDSAT, VT, Custom);
- setOperationAction(ISD::SADDSAT, VT, Custom);
- setOperationAction(ISD::USUBSAT, VT, Custom);
- setOperationAction(ISD::SSUBSAT, VT, Custom);
setOperationAction(ISD::BUILD_VECTOR, VT, Custom);
setOperationAction(ISD::CONCAT_VECTORS, VT, Custom);
diff --git a/llvm/test/CodeGen/X86/avx512-mask-op.ll b/llvm/test/CodeGen/X86/avx512-mask-op.ll
index 796d3586310c..b9f9ffba55d8 100644
--- a/llvm/test/CodeGen/X86/avx512-mask-op.ll
+++ b/llvm/test/CodeGen/X86/avx512-mask-op.ll
@@ -5528,6 +5528,226 @@ define i1 @test_v1i1_mul(i1 %x, i1 %y) {
ret i1 %ret
}
+define <1 x i1> @uadd_sat_v1i1(<1 x i1> %x, <1 x i1> %y) nounwind {
+; KNL-LABEL: uadd_sat_v1i1:
+; KNL: ## %bb.0:
+; KNL-NEXT: kmovw %edi, %k0
+; KNL-NEXT: kmovw %esi, %k1
+; KNL-NEXT: korw %k1, %k0, %k0
+; KNL-NEXT: kmovw %k0, %eax
+; KNL-NEXT: ## kill: def $al killed $al killed $eax
+; KNL-NEXT: retq
+;
+; SKX-LABEL: uadd_sat_v1i1:
+; SKX: ## %bb.0:
+; SKX-NEXT: kmovd %edi, %k0
+; SKX-NEXT: kmovd %esi, %k1
+; SKX-NEXT: korw %k1, %k0, %k0
+; SKX-NEXT: kmovd %k0, %eax
+; SKX-NEXT: ## kill: def $al killed $al killed $eax
+; SKX-NEXT: retq
+;
+; AVX512BW-LABEL: uadd_sat_v1i1:
+; AVX512BW: ## %bb.0:
+; AVX512BW-NEXT: kmovd %edi, %k0
+; AVX512BW-NEXT: kmovd %esi, %k1
+; AVX512BW-NEXT: korw %k1, %k0, %k0
+; AVX512BW-NEXT: kmovd %k0, %eax
+; AVX512BW-NEXT: ## kill: def $al killed $al killed $eax
+; AVX512BW-NEXT: retq
+;
+; AVX512DQ-LABEL: uadd_sat_v1i1:
+; AVX512DQ: ## %bb.0:
+; AVX512DQ-NEXT: kmovw %edi, %k0
+; AVX512DQ-NEXT: kmovw %esi, %k1
+; AVX512DQ-NEXT: korw %k1, %k0, %k0
+; AVX512DQ-NEXT: kmovw %k0, %eax
+; AVX512DQ-NEXT: ## kill: def $al killed $al killed $eax
+; AVX512DQ-NEXT: retq
+;
+; X86-LABEL: uadd_sat_v1i1:
+; X86: ## %bb.0:
+; X86-NEXT: kmovd {{[0-9]+}}(%esp), %k0
+; X86-NEXT: kmovd {{[0-9]+}}(%esp), %k1
+; X86-NEXT: korw %k1, %k0, %k0
+; X86-NEXT: kmovd %k0, %eax
+; X86-NEXT: ## kill: def $al killed $al killed $eax
+; X86-NEXT: retl
+ %z = call <1 x i1> @llvm.uadd.sat.v1i1(<1 x i1> %x, <1 x i1> %y)
+ ret <1 x i1> %z
+}
+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 %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 %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 %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 %k0, %eax
+; AVX512DQ-NEXT: ## kill: def $al killed $al killed $eax
+; AVX512DQ-NEXT: retq
+;
+; X86-LABEL: usub_sat_v1i1:
+; 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: kmovd %k0, %eax
+; X86-NEXT: ## kill: def $al killed $al killed $eax
+; X86-NEXT: retl
+ %z = call <1 x i1> @llvm.usub.sat.v1i1(<1 x i1> %x, <1 x i1> %y)
+ ret <1 x i1> %z
+}
+declare <1 x i1> @llvm.usub.sat.v1i1(<1 x i1> %x, <1 x i1> %y)
+
+define <1 x i1> @sadd_sat_v1i1(<1 x i1> %x, <1 x i1> %y) nounwind {
+; KNL-LABEL: sadd_sat_v1i1:
+; KNL: ## %bb.0:
+; KNL-NEXT: kmovw %edi, %k0
+; KNL-NEXT: kmovw %esi, %k1
+; KNL-NEXT: korw %k1, %k0, %k0
+; KNL-NEXT: kmovw %k0, %eax
+; KNL-NEXT: ## kill: def $al killed $al killed $eax
+; KNL-NEXT: retq
+;
+; SKX-LABEL: sadd_sat_v1i1:
+; SKX: ## %bb.0:
+; SKX-NEXT: kmovd %edi, %k0
+; SKX-NEXT: kmovd %esi, %k1
+; SKX-NEXT: korw %k1, %k0, %k0
+; SKX-NEXT: kmovd %k0, %eax
+; SKX-NEXT: ## kill: def $al killed $al killed $eax
+; SKX-NEXT: retq
+;
+; AVX512BW-LABEL: sadd_sat_v1i1:
+; AVX512BW: ## %bb.0:
+; AVX512BW-NEXT: kmovd %edi, %k0
+; AVX512BW-NEXT: kmovd %esi, %k1
+; AVX512BW-NEXT: korw %k1, %k0, %k0
+; AVX512BW-NEXT: kmovd %k0, %eax
+; AVX512BW-NEXT: ## kill: def $al killed $al killed $eax
+; AVX512BW-NEXT: retq
+;
+; AVX512DQ-LABEL: sadd_sat_v1i1:
+; AVX512DQ: ## %bb.0:
+; AVX512DQ-NEXT: kmovw %edi, %k0
+; AVX512DQ-NEXT: kmovw %esi, %k1
+; AVX512DQ-NEXT: korw %k1, %k0, %k0
+; AVX512DQ-NEXT: kmovw %k0, %eax
+; AVX512DQ-NEXT: ## kill: def $al killed $al killed $eax
+; AVX512DQ-NEXT: retq
+;
+; X86-LABEL: sadd_sat_v1i1:
+; X86: ## %bb.0:
+; X86-NEXT: kmovd {{[0-9]+}}(%esp), %k0
+; X86-NEXT: kmovd {{[0-9]+}}(%esp), %k1
+; X86-NEXT: korw %k1, %k0, %k0
+; X86-NEXT: kmovd %k0, %eax
+; X86-NEXT: ## kill: def $al killed $al killed $eax
+; X86-NEXT: retl
+ %z = call <1 x i1> @llvm.sadd.sat.v1i1(<1 x i1> %x, <1 x i1> %y)
+ ret <1 x i1> %z
+}
+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 %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 %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 %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 %k0, %eax
+; AVX512DQ-NEXT: ## kill: def $al killed $al killed $eax
+; AVX512DQ-NEXT: retq
+;
+; X86-LABEL: ssub_sat_v1i1:
+; 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: kmovd %k0, %eax
+; X86-NEXT: ## kill: def $al killed $al killed $eax
+; X86-NEXT: retl
+ %z = call <1 x i1> @llvm.ssub.sat.v1i1(<1 x i1> %x, <1 x i1> %y)
+ ret <1 x i1> %z
+}
+declare <1 x i1> @llvm.ssub.sat.v1i1(<1 x i1> %x, <1 x i1> %y)
+
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"ProfileSummary", !1}
!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
More information about the llvm-commits
mailing list