mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
[X86] Remove a bunch of 'else' after returns in reduceVMULWidth. NFC
This reduces indentation and makes it obvious this function always returns something. llvm-svn: 349671
This commit is contained in:
parent
5e40209fa5
commit
d6124cff35
@ -34866,86 +34866,85 @@ static SDValue reduceVMULWidth(SDNode *N, SelectionDAG &DAG,
|
|||||||
// Generate the lower part of mul: pmullw. For MULU8/MULS8, only the
|
// Generate the lower part of mul: pmullw. For MULU8/MULS8, only the
|
||||||
// lower part is needed.
|
// lower part is needed.
|
||||||
SDValue MulLo = DAG.getNode(ISD::MUL, DL, ReducedVT, NewN0, NewN1);
|
SDValue MulLo = DAG.getNode(ISD::MUL, DL, ReducedVT, NewN0, NewN1);
|
||||||
if (Mode == MULU8 || Mode == MULS8) {
|
if (Mode == MULU8 || Mode == MULS8)
|
||||||
return DAG.getNode((Mode == MULU8) ? ISD::ZERO_EXTEND : ISD::SIGN_EXTEND,
|
return DAG.getNode((Mode == MULU8) ? ISD::ZERO_EXTEND : ISD::SIGN_EXTEND,
|
||||||
DL, VT, MulLo);
|
DL, VT, MulLo);
|
||||||
} else {
|
|
||||||
MVT ResVT = MVT::getVectorVT(MVT::i32, NumElts / 2);
|
|
||||||
// Generate the higher part of mul: pmulhw/pmulhuw. For MULU16/MULS16,
|
|
||||||
// the higher part is also needed.
|
|
||||||
SDValue MulHi = DAG.getNode(Mode == MULS16 ? ISD::MULHS : ISD::MULHU, DL,
|
|
||||||
ReducedVT, NewN0, NewN1);
|
|
||||||
|
|
||||||
// Repack the lower part and higher part result of mul into a wider
|
MVT ResVT = MVT::getVectorVT(MVT::i32, NumElts / 2);
|
||||||
// result.
|
// Generate the higher part of mul: pmulhw/pmulhuw. For MULU16/MULS16,
|
||||||
// Generate shuffle functioning as punpcklwd.
|
// the higher part is also needed.
|
||||||
SmallVector<int, 16> ShuffleMask(NumElts);
|
SDValue MulHi = DAG.getNode(Mode == MULS16 ? ISD::MULHS : ISD::MULHU, DL,
|
||||||
for (unsigned i = 0, e = NumElts / 2; i < e; i++) {
|
ReducedVT, NewN0, NewN1);
|
||||||
ShuffleMask[2 * i] = i;
|
|
||||||
ShuffleMask[2 * i + 1] = i + NumElts;
|
// Repack the lower part and higher part result of mul into a wider
|
||||||
}
|
// result.
|
||||||
SDValue ResLo =
|
// Generate shuffle functioning as punpcklwd.
|
||||||
DAG.getVectorShuffle(ReducedVT, DL, MulLo, MulHi, ShuffleMask);
|
SmallVector<int, 16> ShuffleMask(NumElts);
|
||||||
ResLo = DAG.getBitcast(ResVT, ResLo);
|
for (unsigned i = 0, e = NumElts / 2; i < e; i++) {
|
||||||
// Generate shuffle functioning as punpckhwd.
|
ShuffleMask[2 * i] = i;
|
||||||
for (unsigned i = 0, e = NumElts / 2; i < e; i++) {
|
ShuffleMask[2 * i + 1] = i + NumElts;
|
||||||
ShuffleMask[2 * i] = i + NumElts / 2;
|
|
||||||
ShuffleMask[2 * i + 1] = i + NumElts * 3 / 2;
|
|
||||||
}
|
|
||||||
SDValue ResHi =
|
|
||||||
DAG.getVectorShuffle(ReducedVT, DL, MulLo, MulHi, ShuffleMask);
|
|
||||||
ResHi = DAG.getBitcast(ResVT, ResHi);
|
|
||||||
return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, ResLo, ResHi);
|
|
||||||
}
|
}
|
||||||
} else {
|
SDValue ResLo =
|
||||||
// When VT.getVectorNumElements() < OpsVT.getVectorNumElements(), we want
|
DAG.getVectorShuffle(ReducedVT, DL, MulLo, MulHi, ShuffleMask);
|
||||||
// to legalize the mul explicitly because implicit legalization for type
|
ResLo = DAG.getBitcast(ResVT, ResLo);
|
||||||
// <4 x i16> to <4 x i32> sometimes involves unnecessary unpack
|
// Generate shuffle functioning as punpckhwd.
|
||||||
// instructions which will not exist when we explicitly legalize it by
|
for (unsigned i = 0, e = NumElts / 2; i < e; i++) {
|
||||||
// extending <4 x i16> to <8 x i16> (concatenating the <4 x i16> val with
|
ShuffleMask[2 * i] = i + NumElts / 2;
|
||||||
// <4 x i16> undef).
|
ShuffleMask[2 * i + 1] = i + NumElts * 3 / 2;
|
||||||
//
|
|
||||||
// Legalize the operands of mul.
|
|
||||||
// FIXME: We may be able to handle non-concatenated vectors by insertion.
|
|
||||||
unsigned ReducedSizeInBits = ReducedVT.getSizeInBits();
|
|
||||||
if ((RegSize % ReducedSizeInBits) != 0)
|
|
||||||
return SDValue();
|
|
||||||
|
|
||||||
SmallVector<SDValue, 16> Ops(RegSize / ReducedSizeInBits,
|
|
||||||
DAG.getUNDEF(ReducedVT));
|
|
||||||
Ops[0] = NewN0;
|
|
||||||
NewN0 = DAG.getNode(ISD::CONCAT_VECTORS, DL, OpsVT, Ops);
|
|
||||||
Ops[0] = NewN1;
|
|
||||||
NewN1 = DAG.getNode(ISD::CONCAT_VECTORS, DL, OpsVT, Ops);
|
|
||||||
|
|
||||||
if (Mode == MULU8 || Mode == MULS8) {
|
|
||||||
// Generate lower part of mul: pmullw. For MULU8/MULS8, only the lower
|
|
||||||
// part is needed.
|
|
||||||
SDValue Mul = DAG.getNode(ISD::MUL, DL, OpsVT, NewN0, NewN1);
|
|
||||||
|
|
||||||
// convert the type of mul result to VT.
|
|
||||||
MVT ResVT = MVT::getVectorVT(MVT::i32, RegSize / 32);
|
|
||||||
SDValue Res = DAG.getNode(Mode == MULU8 ? ISD::ZERO_EXTEND_VECTOR_INREG
|
|
||||||
: ISD::SIGN_EXTEND_VECTOR_INREG,
|
|
||||||
DL, ResVT, Mul);
|
|
||||||
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Res,
|
|
||||||
DAG.getIntPtrConstant(0, DL));
|
|
||||||
} else {
|
|
||||||
// Generate the lower and higher part of mul: pmulhw/pmulhuw. For
|
|
||||||
// MULU16/MULS16, both parts are needed.
|
|
||||||
SDValue MulLo = DAG.getNode(ISD::MUL, DL, OpsVT, NewN0, NewN1);
|
|
||||||
SDValue MulHi = DAG.getNode(Mode == MULS16 ? ISD::MULHS : ISD::MULHU, DL,
|
|
||||||
OpsVT, NewN0, NewN1);
|
|
||||||
|
|
||||||
// Repack the lower part and higher part result of mul into a wider
|
|
||||||
// result. Make sure the type of mul result is VT.
|
|
||||||
MVT ResVT = MVT::getVectorVT(MVT::i32, RegSize / 32);
|
|
||||||
SDValue Res = getUnpackl(DAG, DL, OpsVT, MulLo, MulHi);
|
|
||||||
Res = DAG.getBitcast(ResVT, Res);
|
|
||||||
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Res,
|
|
||||||
DAG.getIntPtrConstant(0, DL));
|
|
||||||
}
|
}
|
||||||
|
SDValue ResHi =
|
||||||
|
DAG.getVectorShuffle(ReducedVT, DL, MulLo, MulHi, ShuffleMask);
|
||||||
|
ResHi = DAG.getBitcast(ResVT, ResHi);
|
||||||
|
return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, ResLo, ResHi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When VT.getVectorNumElements() < OpsVT.getVectorNumElements(), we want
|
||||||
|
// to legalize the mul explicitly because implicit legalization for type
|
||||||
|
// <4 x i16> to <4 x i32> sometimes involves unnecessary unpack
|
||||||
|
// instructions which will not exist when we explicitly legalize it by
|
||||||
|
// extending <4 x i16> to <8 x i16> (concatenating the <4 x i16> val with
|
||||||
|
// <4 x i16> undef).
|
||||||
|
//
|
||||||
|
// Legalize the operands of mul.
|
||||||
|
// FIXME: We may be able to handle non-concatenated vectors by insertion.
|
||||||
|
unsigned ReducedSizeInBits = ReducedVT.getSizeInBits();
|
||||||
|
if ((RegSize % ReducedSizeInBits) != 0)
|
||||||
|
return SDValue();
|
||||||
|
|
||||||
|
SmallVector<SDValue, 16> Ops(RegSize / ReducedSizeInBits,
|
||||||
|
DAG.getUNDEF(ReducedVT));
|
||||||
|
Ops[0] = NewN0;
|
||||||
|
NewN0 = DAG.getNode(ISD::CONCAT_VECTORS, DL, OpsVT, Ops);
|
||||||
|
Ops[0] = NewN1;
|
||||||
|
NewN1 = DAG.getNode(ISD::CONCAT_VECTORS, DL, OpsVT, Ops);
|
||||||
|
|
||||||
|
if (Mode == MULU8 || Mode == MULS8) {
|
||||||
|
// Generate lower part of mul: pmullw. For MULU8/MULS8, only the lower
|
||||||
|
// part is needed.
|
||||||
|
SDValue Mul = DAG.getNode(ISD::MUL, DL, OpsVT, NewN0, NewN1);
|
||||||
|
|
||||||
|
// convert the type of mul result to VT.
|
||||||
|
MVT ResVT = MVT::getVectorVT(MVT::i32, RegSize / 32);
|
||||||
|
SDValue Res = DAG.getNode(Mode == MULU8 ? ISD::ZERO_EXTEND_VECTOR_INREG
|
||||||
|
: ISD::SIGN_EXTEND_VECTOR_INREG,
|
||||||
|
DL, ResVT, Mul);
|
||||||
|
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Res,
|
||||||
|
DAG.getIntPtrConstant(0, DL));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the lower and higher part of mul: pmulhw/pmulhuw. For
|
||||||
|
// MULU16/MULS16, both parts are needed.
|
||||||
|
SDValue MulLo = DAG.getNode(ISD::MUL, DL, OpsVT, NewN0, NewN1);
|
||||||
|
SDValue MulHi = DAG.getNode(Mode == MULS16 ? ISD::MULHS : ISD::MULHU, DL,
|
||||||
|
OpsVT, NewN0, NewN1);
|
||||||
|
|
||||||
|
// Repack the lower part and higher part result of mul into a wider
|
||||||
|
// result. Make sure the type of mul result is VT.
|
||||||
|
MVT ResVT = MVT::getVectorVT(MVT::i32, RegSize / 32);
|
||||||
|
SDValue Res = getUnpackl(DAG, DL, OpsVT, MulLo, MulHi);
|
||||||
|
Res = DAG.getBitcast(ResVT, Res);
|
||||||
|
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Res,
|
||||||
|
DAG.getIntPtrConstant(0, DL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDValue combineMulSpecial(uint64_t MulAmt, SDNode *N, SelectionDAG &DAG,
|
static SDValue combineMulSpecial(uint64_t MulAmt, SDNode *N, SelectionDAG &DAG,
|
||||||
|
Loading…
Reference in New Issue
Block a user