summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2017-10-14 17:37:42 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2017-10-14 17:37:42 +0000
commitf5b9f353c3324a4144e75f1072aa5f3e69cbef96 (patch)
tree800779a89839cb2e47b4034f75ad730b9ae22911 /llvm/lib
parent5bd4431aecd8bb8b0c9aec0fab72607634d6f2da (diff)
downloadbcm5719-llvm-f5b9f353c3324a4144e75f1072aa5f3e69cbef96.tar.gz
bcm5719-llvm-f5b9f353c3324a4144e75f1072aa5f3e69cbef96.zip
Pull out repeated calls to VT.getVectorNumElements(). NFCI.
llvm-svn: 315818
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 6b15433720f..ad633747071 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -31475,15 +31475,16 @@ static SDValue reduceVMULWidth(SDNode *N, SelectionDAG &DAG,
SDValue N0 = N->getOperand(0);
SDValue N1 = N->getOperand(1);
EVT VT = N->getOperand(0).getValueType();
+ unsigned NumElts = VT.getVectorNumElements();
unsigned RegSize = 128;
MVT OpsVT = MVT::getVectorVT(MVT::i16, RegSize / 16);
- EVT ReducedVT =
- EVT::getVectorVT(*DAG.getContext(), MVT::i16, VT.getVectorNumElements());
+ EVT ReducedVT = EVT::getVectorVT(*DAG.getContext(), MVT::i16, NumElts);
+
// Shrink the operands of mul.
SDValue NewN0 = DAG.getNode(ISD::TRUNCATE, DL, ReducedVT, N0);
SDValue NewN1 = DAG.getNode(ISD::TRUNCATE, DL, ReducedVT, N1);
- if (VT.getVectorNumElements() >= OpsVT.getVectorNumElements()) {
+ if (NumElts >= OpsVT.getVectorNumElements()) {
// Generate the lower part of mul: pmullw. For MULU8/MULS8, only the
// lower part is needed.
SDValue MulLo = DAG.getNode(ISD::MUL, DL, ReducedVT, NewN0, NewN1);
@@ -31491,7 +31492,7 @@ static SDValue reduceVMULWidth(SDNode *N, SelectionDAG &DAG,
return DAG.getNode((Mode == MULU8) ? ISD::ZERO_EXTEND : ISD::SIGN_EXTEND,
DL, VT, MulLo);
} else {
- MVT ResVT = MVT::getVectorVT(MVT::i32, VT.getVectorNumElements() / 2);
+ 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,
@@ -31500,18 +31501,18 @@ static SDValue reduceVMULWidth(SDNode *N, SelectionDAG &DAG,
// Repack the lower part and higher part result of mul into a wider
// result.
// Generate shuffle functioning as punpcklwd.
- SmallVector<int, 16> ShuffleMask(VT.getVectorNumElements());
- for (unsigned i = 0; i < VT.getVectorNumElements() / 2; i++) {
+ SmallVector<int, 16> ShuffleMask(NumElts);
+ for (unsigned i = 0, e = NumElts/ 2; i < e; i++) {
ShuffleMask[2 * i] = i;
- ShuffleMask[2 * i + 1] = i + VT.getVectorNumElements();
+ ShuffleMask[2 * i + 1] = i + NumElts;
}
SDValue ResLo =
DAG.getVectorShuffle(ReducedVT, DL, MulLo, MulHi, ShuffleMask);
ResLo = DAG.getBitcast(ResVT, ResLo);
// Generate shuffle functioning as punpckhwd.
- for (unsigned i = 0; i < VT.getVectorNumElements() / 2; i++) {
- ShuffleMask[2 * i] = i + VT.getVectorNumElements() / 2;
- ShuffleMask[2 * i + 1] = i + VT.getVectorNumElements() * 3 / 2;
+ for (unsigned i = 0, e = NumElts / 2; i < e; i++) {
+ ShuffleMask[2 * i] = i + NumElts / 2;
+ ShuffleMask[2 * i + 1] = i + NumElts * 3 / 2;
}
SDValue ResHi =
DAG.getVectorShuffle(ReducedVT, DL, MulLo, MulHi, ShuffleMask);
OpenPOWER on IntegriCloud