[llvm] r294746 - [X86][SSE] Add support for extracting target constants from BUILD_VECTOR
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 10 06:04:12 PST 2017
Author: rksimon
Date: Fri Feb 10 08:04:11 2017
New Revision: 294746
URL: http://llvm.org/viewvc/llvm-project?rev=294746&view=rev
Log:
[X86][SSE] Add support for extracting target constants from BUILD_VECTOR
In some cases we call getTargetConstantBitsFromNode for nodes that haven't been lowered from BUILD_VECTOR yet
Note: We're getting very close to being able to move most of the constant extraction code from getTargetShuffleMaskIndices into getTargetConstantBitsFromNode
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/clear_upper_vector_element_bits.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=294746&r1=294745&r2=294746&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Feb 10 08:04:11 2017
@@ -5212,6 +5212,23 @@ static bool getTargetConstantBitsFromNod
return false;
};
+ // Extract constant bits from build vector.
+ if (ISD::isBuildVectorOfConstantSDNodes(Op.getNode())) {
+ unsigned SrcEltSizeInBits = VT.getScalarSizeInBits();
+ for (unsigned i = 0, e = Op.getNumOperands(); i != e; ++i) {
+ const SDValue &Src = Op.getOperand(i);
+ if (Src.isUndef()) {
+ APInt Undefs = APInt::getLowBitsSet(SizeInBits, SrcEltSizeInBits);
+ UndefBits |= Undefs.shl(i * SrcEltSizeInBits);
+ continue;
+ }
+ auto *Cst = cast<ConstantSDNode>(Src);
+ APInt Bits = Cst->getAPIntValue().zextOrTrunc(SrcEltSizeInBits);
+ MaskBits |= Bits.zext(SizeInBits).shl(i * SrcEltSizeInBits);
+ }
+ return SplitBitData();
+ }
+
// Extract constant bits from constant pool vector.
if (auto *Cst = getTargetConstantFromNode(Op)) {
Type *CstTy = Cst->getType();
Modified: llvm/trunk/test/CodeGen/X86/clear_upper_vector_element_bits.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/clear_upper_vector_element_bits.ll?rev=294746&r1=294745&r2=294746&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/clear_upper_vector_element_bits.ll (original)
+++ llvm/trunk/test/CodeGen/X86/clear_upper_vector_element_bits.ll Fri Feb 10 08:04:11 2017
@@ -901,23 +901,21 @@ define <16 x i16> @_clearupper16xi16b(<1
;
; AVX1-LABEL: _clearupper16xi16b:
; AVX1: # BB#0:
-; AVX1-NEXT: vpand {{.*}}(%rip), %xmm0, %xmm1
-; AVX1-NEXT: xorl %eax, %eax
-; AVX1-NEXT: vpinsrb $15, %eax, %xmm1, %xmm1
-; AVX1-NEXT: vblendpd {{.*#+}} ymm0 = ymm1[0,1],ymm0[2,3]
-; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1
-; AVX1-NEXT: vandpd {{.*}}(%rip), %xmm1, %xmm1
+; AVX1-NEXT: vmovapd {{.*#+}} xmm1 = [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0]
+; AVX1-NEXT: vandpd %xmm1, %xmm0, %xmm2
+; AVX1-NEXT: vblendpd {{.*#+}} ymm0 = ymm2[0,1],ymm0[2,3]
+; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
+; AVX1-NEXT: vandpd %xmm1, %xmm2, %xmm1
; AVX1-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
; AVX1-NEXT: retq
;
; AVX2-LABEL: _clearupper16xi16b:
; AVX2: # BB#0:
-; AVX2-NEXT: vpand {{.*}}(%rip), %xmm0, %xmm1
-; AVX2-NEXT: xorl %eax, %eax
-; AVX2-NEXT: vpinsrb $15, %eax, %xmm1, %xmm1
-; AVX2-NEXT: vpblendd {{.*#+}} ymm0 = ymm1[0,1,2,3],ymm0[4,5,6,7]
-; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1
-; AVX2-NEXT: vpand {{.*}}(%rip), %xmm1, %xmm1
+; AVX2-NEXT: vmovdqa {{.*#+}} xmm1 = [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0]
+; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm2
+; AVX2-NEXT: vpblendd {{.*#+}} ymm0 = ymm2[0,1,2,3],ymm0[4,5,6,7]
+; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm2
+; AVX2-NEXT: vpand %xmm1, %xmm2, %xmm1
; AVX2-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0
; AVX2-NEXT: retq
%x8 = bitcast <16 x i16> %0 to <32 x i8>
More information about the llvm-commits
mailing list