[llvm] r322454 - [X86] Add X86ISD::VTRUNC to computeKnownBitsForTargetNode.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 14 00:11:33 PST 2018
Author: ctopper
Date: Sun Jan 14 00:11:33 2018
New Revision: 322454
URL: http://llvm.org/viewvc/llvm-project?rev=322454&view=rev
Log:
[X86] Add X86ISD::VTRUNC to computeKnownBitsForTargetNode.
We have to take special care to avoid the cases where the result of the truncate would be padded with zero elements.
Ideally we'd just use ISD::TRUNCATE for these cases instead.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/avx512-trunc.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=322454&r1=322453&r2=322454&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Jan 14 00:11:33 2018
@@ -27837,6 +27837,18 @@ void X86TargetLowering::computeKnownBits
Known.Zero.setBitsFrom(InBitWidth);
break;
}
+ case X86ISD::VTRUNC: {
+ // TODO: Add DemandedElts support.
+ SDValue N0 = Op.getOperand(0);
+ // We can only handle cases with the same number of elements. Otherwise
+ // the truncate fills with zero elements.
+ // TODO: Maybe we could just discard any 1s we found instead of skipping?
+ if (VT.getVectorNumElements() != N0.getValueType().getVectorNumElements())
+ break;
+ DAG.computeKnownBits(N0, Known, Depth+1);
+ Known = Known.trunc(BitWidth);
+ break;
+ }
case X86ISD::CMOV: {
DAG.computeKnownBits(Op.getOperand(1), Known, Depth+1);
// If we don't know any bits, early out.
Modified: llvm/trunk/test/CodeGen/X86/avx512-trunc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx512-trunc.ll?rev=322454&r1=322453&r2=322454&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/avx512-trunc.ll (original)
+++ llvm/trunk/test/CodeGen/X86/avx512-trunc.ll Sun Jan 14 00:11:33 2018
@@ -748,7 +748,7 @@ define <16 x i8> @usat_trunc_db_256(<8 x
; KNL-NEXT: vpbroadcastd {{.*#+}} ymm1 = [255,255,255,255,255,255,255,255]
; KNL-NEXT: vpminud %ymm1, %ymm0, %ymm0
; KNL-NEXT: vpmovdw %zmm0, %ymm0
-; KNL-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u]
+; KNL-NEXT: vpackuswb %xmm0, %xmm0, %xmm0
; KNL-NEXT: vzeroupper
; KNL-NEXT: retq
;
@@ -756,7 +756,7 @@ define <16 x i8> @usat_trunc_db_256(<8 x
; SKX: ## %bb.0:
; SKX-NEXT: vpminud {{.*}}(%rip){1to8}, %ymm0, %ymm0
; SKX-NEXT: vpmovdw %ymm0, %xmm0
-; SKX-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u]
+; SKX-NEXT: vpackuswb %xmm0, %xmm0, %xmm0
; SKX-NEXT: vzeroupper
; SKX-NEXT: retq
%tmp1 = icmp ult <8 x i32> %x, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
More information about the llvm-commits
mailing list