@@ -6991,8 +6991,7 @@ static bool canExpandVectorCTPOP(const TargetLowering &TLI, EVT VT) {
6991
6991
TLI.isOperationLegalOrCustomOrPromote (ISD::AND, VT);
6992
6992
}
6993
6993
6994
- bool TargetLowering::expandCTPOP (SDNode *Node, SDValue &Result,
6995
- SelectionDAG &DAG) const {
6994
+ SDValue TargetLowering::expandCTPOP (SDNode *Node, SelectionDAG &DAG) const {
6996
6995
SDLoc dl (Node);
6997
6996
EVT VT = Node->getValueType (0 );
6998
6997
EVT ShVT = getShiftAmountTy (VT, DAG.getDataLayout ());
@@ -7002,11 +7001,11 @@ bool TargetLowering::expandCTPOP(SDNode *Node, SDValue &Result,
7002
7001
7003
7002
// TODO: Add support for irregular type lengths.
7004
7003
if (!(Len <= 128 && Len % 8 == 0 ))
7005
- return false ;
7004
+ return SDValue () ;
7006
7005
7007
7006
// Only expand vector types if we have the appropriate vector bit operations.
7008
7007
if (VT.isVector () && !canExpandVectorCTPOP (*this , VT))
7009
- return false ;
7008
+ return SDValue () ;
7010
7009
7011
7010
// This is the "best" algorithm from
7012
7011
// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
@@ -7043,12 +7042,10 @@ bool TargetLowering::expandCTPOP(SDNode *Node, SDValue &Result,
7043
7042
DAG.getNode (ISD::SRL, dl, VT, DAG.getNode (ISD::MUL, dl, VT, Op, Mask01),
7044
7043
DAG.getConstant (Len - 8 , dl, ShVT));
7045
7044
7046
- Result = Op;
7047
- return true ;
7045
+ return Op;
7048
7046
}
7049
7047
7050
- bool TargetLowering::expandCTLZ (SDNode *Node, SDValue &Result,
7051
- SelectionDAG &DAG) const {
7048
+ SDValue TargetLowering::expandCTLZ (SDNode *Node, SelectionDAG &DAG) const {
7052
7049
SDLoc dl (Node);
7053
7050
EVT VT = Node->getValueType (0 );
7054
7051
EVT ShVT = getShiftAmountTy (VT, DAG.getDataLayout ());
@@ -7057,10 +7054,8 @@ bool TargetLowering::expandCTLZ(SDNode *Node, SDValue &Result,
7057
7054
7058
7055
// If the non-ZERO_UNDEF version is supported we can use that instead.
7059
7056
if (Node->getOpcode () == ISD::CTLZ_ZERO_UNDEF &&
7060
- isOperationLegalOrCustom (ISD::CTLZ, VT)) {
7061
- Result = DAG.getNode (ISD::CTLZ, dl, VT, Op);
7062
- return true ;
7063
- }
7057
+ isOperationLegalOrCustom (ISD::CTLZ, VT))
7058
+ return DAG.getNode (ISD::CTLZ, dl, VT, Op);
7064
7059
7065
7060
// If the ZERO_UNDEF version is supported use that and handle the zero case.
7066
7061
if (isOperationLegalOrCustom (ISD::CTLZ_ZERO_UNDEF, VT)) {
@@ -7069,9 +7064,8 @@ bool TargetLowering::expandCTLZ(SDNode *Node, SDValue &Result,
7069
7064
SDValue CTLZ = DAG.getNode (ISD::CTLZ_ZERO_UNDEF, dl, VT, Op);
7070
7065
SDValue Zero = DAG.getConstant (0 , dl, VT);
7071
7066
SDValue SrcIsZero = DAG.getSetCC (dl, SetCCVT, Op, Zero, ISD::SETEQ);
7072
- Result = DAG.getNode (ISD::SELECT, dl, VT, SrcIsZero,
7073
- DAG.getConstant (NumBitsPerElt, dl, VT), CTLZ);
7074
- return true ;
7067
+ return DAG.getNode (ISD::SELECT, dl, VT, SrcIsZero,
7068
+ DAG.getConstant (NumBitsPerElt, dl, VT), CTLZ);
7075
7069
}
7076
7070
7077
7071
// Only expand vector types if we have the appropriate vector bit operations.
@@ -7081,7 +7075,7 @@ bool TargetLowering::expandCTLZ(SDNode *Node, SDValue &Result,
7081
7075
!canExpandVectorCTPOP (*this , VT)) ||
7082
7076
!isOperationLegalOrCustom (ISD::SRL, VT) ||
7083
7077
!isOperationLegalOrCustomOrPromote (ISD::OR, VT)))
7084
- return false ;
7078
+ return SDValue () ;
7085
7079
7086
7080
// for now, we do this:
7087
7081
// x = x | (x >> 1);
@@ -7098,23 +7092,19 @@ bool TargetLowering::expandCTLZ(SDNode *Node, SDValue &Result,
7098
7092
DAG.getNode (ISD::SRL, dl, VT, Op, Tmp));
7099
7093
}
7100
7094
Op = DAG.getNOT (dl, Op, VT);
7101
- Result = DAG.getNode (ISD::CTPOP, dl, VT, Op);
7102
- return true ;
7095
+ return DAG.getNode (ISD::CTPOP, dl, VT, Op);
7103
7096
}
7104
7097
7105
- bool TargetLowering::expandCTTZ (SDNode *Node, SDValue &Result,
7106
- SelectionDAG &DAG) const {
7098
+ SDValue TargetLowering::expandCTTZ (SDNode *Node, SelectionDAG &DAG) const {
7107
7099
SDLoc dl (Node);
7108
7100
EVT VT = Node->getValueType (0 );
7109
7101
SDValue Op = Node->getOperand (0 );
7110
7102
unsigned NumBitsPerElt = VT.getScalarSizeInBits ();
7111
7103
7112
7104
// If the non-ZERO_UNDEF version is supported we can use that instead.
7113
7105
if (Node->getOpcode () == ISD::CTTZ_ZERO_UNDEF &&
7114
- isOperationLegalOrCustom (ISD::CTTZ, VT)) {
7115
- Result = DAG.getNode (ISD::CTTZ, dl, VT, Op);
7116
- return true ;
7117
- }
7106
+ isOperationLegalOrCustom (ISD::CTTZ, VT))
7107
+ return DAG.getNode (ISD::CTTZ, dl, VT, Op);
7118
7108
7119
7109
// If the ZERO_UNDEF version is supported use that and handle the zero case.
7120
7110
if (isOperationLegalOrCustom (ISD::CTTZ_ZERO_UNDEF, VT)) {
@@ -7123,9 +7113,8 @@ bool TargetLowering::expandCTTZ(SDNode *Node, SDValue &Result,
7123
7113
SDValue CTTZ = DAG.getNode (ISD::CTTZ_ZERO_UNDEF, dl, VT, Op);
7124
7114
SDValue Zero = DAG.getConstant (0 , dl, VT);
7125
7115
SDValue SrcIsZero = DAG.getSetCC (dl, SetCCVT, Op, Zero, ISD::SETEQ);
7126
- Result = DAG.getNode (ISD::SELECT, dl, VT, SrcIsZero,
7127
- DAG.getConstant (NumBitsPerElt, dl, VT), CTTZ);
7128
- return true ;
7116
+ return DAG.getNode (ISD::SELECT, dl, VT, SrcIsZero,
7117
+ DAG.getConstant (NumBitsPerElt, dl, VT), CTTZ);
7129
7118
}
7130
7119
7131
7120
// Only expand vector types if we have the appropriate vector bit operations.
@@ -7137,7 +7126,7 @@ bool TargetLowering::expandCTTZ(SDNode *Node, SDValue &Result,
7137
7126
!isOperationLegalOrCustom (ISD::SUB, VT) ||
7138
7127
!isOperationLegalOrCustomOrPromote (ISD::AND, VT) ||
7139
7128
!isOperationLegalOrCustomOrPromote (ISD::XOR, VT)))
7140
- return false ;
7129
+ return SDValue () ;
7141
7130
7142
7131
// for now, we use: { return popcount(~x & (x - 1)); }
7143
7132
// unless the target has ctlz but not ctpop, in which case we use:
@@ -7149,14 +7138,11 @@ bool TargetLowering::expandCTTZ(SDNode *Node, SDValue &Result,
7149
7138
7150
7139
// If ISD::CTLZ is legal and CTPOP isn't, then do that instead.
7151
7140
if (isOperationLegal (ISD::CTLZ, VT) && !isOperationLegal (ISD::CTPOP, VT)) {
7152
- Result =
7153
- DAG.getNode (ISD::SUB, dl, VT, DAG.getConstant (NumBitsPerElt, dl, VT),
7154
- DAG.getNode (ISD::CTLZ, dl, VT, Tmp));
7155
- return true ;
7141
+ return DAG.getNode (ISD::SUB, dl, VT, DAG.getConstant (NumBitsPerElt, dl, VT),
7142
+ DAG.getNode (ISD::CTLZ, dl, VT, Tmp));
7156
7143
}
7157
7144
7158
- Result = DAG.getNode (ISD::CTPOP, dl, VT, Tmp);
7159
- return true ;
7145
+ return DAG.getNode (ISD::CTPOP, dl, VT, Tmp);
7160
7146
}
7161
7147
7162
7148
bool TargetLowering::expandABS (SDNode *N, SDValue &Result,
0 commit comments