[llvm] r321611 - [X86] Use CONCAT_VECTORS instead of INSERT_SUBVECTOR for padding v4i1/v2i1 vector to v8i1 pre-legalize.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 31 11:17:53 PST 2017
Author: ctopper
Date: Sun Dec 31 11:17:52 2017
New Revision: 321611
URL: http://llvm.org/viewvc/llvm-project?rev=321611&view=rev
Log:
[X86] Use CONCAT_VECTORS instead of INSERT_SUBVECTOR for padding v4i1/v2i1 vector to v8i1 pre-legalize.
The CONCAT_VECTORS will be lowered to INSERT_SUBVECTOR later. In the modified cases this seems to be enough to trick a later DAG combine into running in a different order than allows the ANDs to be removed.
I'll admit this is a bit of a hack that happens to work, but using CONCAT_VECTORS is more consistent with other legalization code anyway.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/avx512vl-vec-masked-cmp.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=321611&r1=321610&r2=321611&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Dec 31 11:17:52 2017
@@ -30436,9 +30436,10 @@ static SDValue combineBitcast(SDNode *N,
if ((SrcVT == MVT::v4i1 || SrcVT == MVT::v2i1) && VT.isScalarInteger() &&
Subtarget.hasVLX()) {
SDLoc dl(N);
- N0 = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, MVT::v8i1,
- DAG.getUNDEF(MVT::v8i1), N0,
- DAG.getIntPtrConstant(0, dl));
+ unsigned NumConcats = 8 / SrcVT.getVectorNumElements();
+ SmallVector<SDValue, 4> Ops(NumConcats, DAG.getUNDEF(SrcVT));
+ Ops[0] = N0;
+ N0 = DAG.getNode(ISD::CONCAT_VECTORS, dl, MVT::v8i1, Ops);
N0 = DAG.getBitcast(MVT::i8, N0);
return DAG.getNode(ISD::TRUNCATE, dl, VT, N0);
}
Modified: llvm/trunk/test/CodeGen/X86/avx512vl-vec-masked-cmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx512vl-vec-masked-cmp.ll?rev=321611&r1=321610&r2=321611&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/avx512vl-vec-masked-cmp.ll (original)
+++ llvm/trunk/test/CodeGen/X86/avx512vl-vec-masked-cmp.ll Sun Dec 31 11:17:52 2017
@@ -5333,9 +5333,7 @@ define zeroext i4 @test_vpcmpeqq_v2i1_v4
; VLX-LABEL: test_vpcmpeqq_v2i1_v4i1_mask:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpeqq %xmm1, %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpeqq_v2i1_v4i1_mask:
@@ -5362,9 +5360,7 @@ define zeroext i4 @test_vpcmpeqq_v2i1_v4
; VLX-LABEL: test_vpcmpeqq_v2i1_v4i1_mask_mem:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpeqq (%rdi), %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpeqq_v2i1_v4i1_mask_mem:
@@ -5393,9 +5389,7 @@ define zeroext i4 @test_masked_vpcmpeqq_
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpeqq %xmm1, %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpeqq_v2i1_v4i1_mask:
@@ -5433,9 +5427,7 @@ define zeroext i4 @test_masked_vpcmpeqq_
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpeqq (%rsi), %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpeqq_v2i1_v4i1_mask_mem:
@@ -5474,9 +5466,7 @@ define zeroext i4 @test_vpcmpeqq_v2i1_v4
; VLX-LABEL: test_vpcmpeqq_v2i1_v4i1_mask_mem_b:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpeqq (%rdi){1to2}, %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpeqq_v2i1_v4i1_mask_mem_b:
@@ -5507,9 +5497,7 @@ define zeroext i4 @test_masked_vpcmpeqq_
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpeqq (%rsi){1to2}, %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpeqq_v2i1_v4i1_mask_mem_b:
@@ -14449,9 +14437,7 @@ define zeroext i4 @test_vpcmpsgtq_v2i1_v
; VLX-LABEL: test_vpcmpsgtq_v2i1_v4i1_mask:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpgtq %xmm1, %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpsgtq_v2i1_v4i1_mask:
@@ -14478,9 +14464,7 @@ define zeroext i4 @test_vpcmpsgtq_v2i1_v
; VLX-LABEL: test_vpcmpsgtq_v2i1_v4i1_mask_mem:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpgtq (%rdi), %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpsgtq_v2i1_v4i1_mask_mem:
@@ -14509,9 +14493,7 @@ define zeroext i4 @test_masked_vpcmpsgtq
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpgtq %xmm1, %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpsgtq_v2i1_v4i1_mask:
@@ -14549,9 +14531,7 @@ define zeroext i4 @test_masked_vpcmpsgtq
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpgtq (%rsi), %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpsgtq_v2i1_v4i1_mask_mem:
@@ -14590,9 +14570,7 @@ define zeroext i4 @test_vpcmpsgtq_v2i1_v
; VLX-LABEL: test_vpcmpsgtq_v2i1_v4i1_mask_mem_b:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpgtq (%rdi){1to2}, %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpsgtq_v2i1_v4i1_mask_mem_b:
@@ -14623,9 +14601,7 @@ define zeroext i4 @test_masked_vpcmpsgtq
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpgtq (%rsi){1to2}, %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpsgtq_v2i1_v4i1_mask_mem_b:
@@ -23693,9 +23669,7 @@ define zeroext i4 @test_vpcmpsgeq_v2i1_v
; VLX-LABEL: test_vpcmpsgeq_v2i1_v4i1_mask:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpleq %xmm0, %xmm1, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpsgeq_v2i1_v4i1_mask:
@@ -23724,9 +23698,7 @@ define zeroext i4 @test_vpcmpsgeq_v2i1_v
; VLX-LABEL: test_vpcmpsgeq_v2i1_v4i1_mask_mem:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpnltq (%rdi), %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpsgeq_v2i1_v4i1_mask_mem:
@@ -23758,9 +23730,7 @@ define zeroext i4 @test_masked_vpcmpsgeq
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpleq %xmm0, %xmm1, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpsgeq_v2i1_v4i1_mask:
@@ -23798,9 +23768,7 @@ define zeroext i4 @test_masked_vpcmpsgeq
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpnltq (%rsi), %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpsgeq_v2i1_v4i1_mask_mem:
@@ -23840,9 +23808,7 @@ define zeroext i4 @test_vpcmpsgeq_v2i1_v
; VLX-LABEL: test_vpcmpsgeq_v2i1_v4i1_mask_mem_b:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpnltq (%rdi){1to2}, %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpsgeq_v2i1_v4i1_mask_mem_b:
@@ -23875,9 +23841,7 @@ define zeroext i4 @test_masked_vpcmpsgeq
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpnltq (%rsi){1to2}, %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpsgeq_v2i1_v4i1_mask_mem_b:
@@ -33093,9 +33057,7 @@ define zeroext i4 @test_vpcmpultq_v2i1_v
; VLX-LABEL: test_vpcmpultq_v2i1_v4i1_mask:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpltuq %xmm1, %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpultq_v2i1_v4i1_mask:
@@ -33125,9 +33087,7 @@ define zeroext i4 @test_vpcmpultq_v2i1_v
; VLX-LABEL: test_vpcmpultq_v2i1_v4i1_mask_mem:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpltuq (%rdi), %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpultq_v2i1_v4i1_mask_mem:
@@ -33159,9 +33119,7 @@ define zeroext i4 @test_masked_vpcmpultq
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpltuq %xmm1, %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpultq_v2i1_v4i1_mask:
@@ -33202,9 +33160,7 @@ define zeroext i4 @test_masked_vpcmpultq
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpltuq (%rsi), %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpultq_v2i1_v4i1_mask_mem:
@@ -33246,9 +33202,7 @@ define zeroext i4 @test_vpcmpultq_v2i1_v
; VLX-LABEL: test_vpcmpultq_v2i1_v4i1_mask_mem_b:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vpcmpltuq (%rdi){1to2}, %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vpcmpultq_v2i1_v4i1_mask_mem_b:
@@ -33282,9 +33236,7 @@ define zeroext i4 @test_masked_vpcmpultq
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vpcmpltuq (%rsi){1to2}, %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vpcmpultq_v2i1_v4i1_mask_mem_b:
@@ -39979,9 +39931,7 @@ define zeroext i4 @test_vcmpoeqpd_v2i1_v
; VLX-LABEL: test_vcmpoeqpd_v2i1_v4i1_mask:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vcmpeqpd %xmm1, %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vcmpoeqpd_v2i1_v4i1_mask:
@@ -40008,9 +39958,7 @@ define zeroext i4 @test_vcmpoeqpd_v2i1_v
; VLX-LABEL: test_vcmpoeqpd_v2i1_v4i1_mask_mem:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vcmpeqpd (%rdi), %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vcmpoeqpd_v2i1_v4i1_mask_mem:
@@ -40038,9 +39986,7 @@ define zeroext i4 @test_vcmpoeqpd_v2i1_v
; VLX-LABEL: test_vcmpoeqpd_v2i1_v4i1_mask_mem_b:
; VLX: # %bb.0: # %entry
; VLX-NEXT: vcmpeqpd (%rdi){1to2}, %xmm0, %k0
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_vcmpoeqpd_v2i1_v4i1_mask_mem_b:
@@ -40071,9 +40017,7 @@ define zeroext i4 @test_masked_vcmpoeqpd
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vcmpeqpd %xmm1, %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vcmpoeqpd_v2i1_v4i1_mask:
@@ -40106,9 +40050,7 @@ define zeroext i4 @test_masked_vcmpoeqpd
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vcmpeqpd (%rsi), %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vcmpoeqpd_v2i1_v4i1_mask_mem:
@@ -40142,9 +40084,7 @@ define zeroext i4 @test_masked_vcmpoeqpd
; VLX: # %bb.0: # %entry
; VLX-NEXT: kmovd %edi, %k1
; VLX-NEXT: vcmpeqpd (%rsi){1to2}, %xmm0, %k0 {%k1}
-; VLX-NEXT: kmovd %k0, %eax
-; VLX-NEXT: andb $3, %al
-; VLX-NEXT: movzbl %al, %eax
+; VLX-NEXT: kmovb %k0, %eax
; VLX-NEXT: retq
;
; NoVLX-LABEL: test_masked_vcmpoeqpd_v2i1_v4i1_mask_mem_b:
More information about the llvm-commits
mailing list