summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-11-22 20:05:57 +0000
committerCraig Topper <craig.topper@intel.com>2017-11-22 20:05:57 +0000
commit726968d6a2eee646a1c6f850bc6ad1a6999dbb87 (patch)
treec6a606107baa5046428c11400add57a38c88d3eb /llvm/lib
parent8ad818656af9f9589cde108fae5d423b5343930d (diff)
downloadbcm5719-llvm-726968d6a2eee646a1c6f850bc6ad1a6999dbb87.tar.gz
bcm5719-llvm-726968d6a2eee646a1c6f850bc6ad1a6999dbb87.zip
[X86] Support v32i16/v64i8 CTLZ using lookup table.
Had to tweak the setcc's used by the code to use a vXi1 result type with a sign extend back to vector size. llvm-svn: 318871
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 8e9658853dd..1cf410e7337 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -1493,11 +1493,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
setOperationAction(ISD::MSTORE, VT, Action);
}
- if (Subtarget.hasCDI()) {
- setOperationAction(ISD::CTLZ, MVT::v32i16, Custom);
- setOperationAction(ISD::CTLZ, MVT::v64i8, Custom);
- }
-
for (auto VT : { MVT::v64i8, MVT::v32i16 }) {
setOperationAction(ISD::BUILD_VECTOR, VT, Custom);
setOperationAction(ISD::VSELECT, VT, Custom);
@@ -1509,6 +1504,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
setOperationAction(ISD::MSTORE, VT, Legal);
setOperationAction(ISD::CTPOP, VT, Custom);
setOperationAction(ISD::CTTZ, VT, Custom);
+ setOperationAction(ISD::CTLZ, VT, Custom);
setOperationAction(ISD::SMAX, VT, Legal);
setOperationAction(ISD::UMAX, VT, Legal);
setOperationAction(ISD::SMIN, VT, Legal);
@@ -21677,7 +21673,14 @@ static SDValue LowerVectorCTLZInRegLUT(SDValue Op, const SDLoc &DL,
SDValue NibbleShift = DAG.getConstant(0x4, DL, CurrVT);
SDValue Lo = DAG.getNode(ISD::AND, DL, CurrVT, Op0, NibbleMask);
SDValue Hi = DAG.getNode(ISD::SRL, DL, CurrVT, Op0, NibbleShift);
- SDValue HiZ = DAG.getSetCC(DL, CurrVT, Hi, Zero, ISD::SETEQ);
+ SDValue HiZ;
+ if (CurrVT.is512BitVector()) {
+ MVT MaskVT = MVT::getVectorVT(MVT::i1, CurrVT.getVectorNumElements());
+ HiZ = DAG.getSetCC(DL, MaskVT, Hi, Zero, ISD::SETEQ);
+ HiZ = DAG.getNode(ISD::SIGN_EXTEND, DL, CurrVT, HiZ);
+ } else {
+ HiZ = DAG.getSetCC(DL, CurrVT, Hi, Zero, ISD::SETEQ);
+ }
Lo = DAG.getNode(X86ISD::PSHUFB, DL, CurrVT, InRegLUT, Lo);
Hi = DAG.getNode(X86ISD::PSHUFB, DL, CurrVT, InRegLUT, Hi);
@@ -21697,8 +21700,15 @@ static SDValue LowerVectorCTLZInRegLUT(SDValue Op, const SDLoc &DL,
SDValue Shift = DAG.getConstant(CurrScalarSizeInBits, DL, NextVT);
// Check if the upper half of the input element is zero.
- SDValue HiZ = DAG.getSetCC(DL, CurrVT, DAG.getBitcast(CurrVT, Op0),
- DAG.getBitcast(CurrVT, Zero), ISD::SETEQ);
+ if (CurrVT.is512BitVector()) {
+ MVT MaskVT = MVT::getVectorVT(MVT::i1, CurrVT.getVectorNumElements());
+ HiZ = DAG.getSetCC(DL, MaskVT, DAG.getBitcast(CurrVT, Op0),
+ DAG.getBitcast(CurrVT, Zero), ISD::SETEQ);
+ HiZ = DAG.getNode(ISD::SIGN_EXTEND, DL, CurrVT, HiZ);
+ } else {
+ HiZ = DAG.getSetCC(DL, CurrVT, DAG.getBitcast(CurrVT, Op0),
+ DAG.getBitcast(CurrVT, Zero), ISD::SETEQ);
+ }
HiZ = DAG.getBitcast(NextVT, HiZ);
// Move the upper/lower halves to the lower bits as we'll be extending to
OpenPOWER on IntegriCloud