diff options
| author | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2018-01-26 21:54:56 +0000 |
|---|---|---|
| committer | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2018-01-26 21:54:56 +0000 |
| commit | 90ca4e8b0c2785b03f5a7c29277bab6fd77fc195 (patch) | |
| tree | 027444fef3e154a5e3b8fa55da79d7dc4906bb5f /llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp | |
| parent | 643b2b9e26321859f1e9f7fa9912efebfa7560ba (diff) | |
| download | bcm5719-llvm-90ca4e8b0c2785b03f5a7c29277bab6fd77fc195.tar.gz bcm5719-llvm-90ca4e8b0c2785b03f5a7c29277bab6fd77fc195.zip | |
[Hexagon] Generate constant splats instead of loads from constant pool
llvm-svn: 323568
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp')
| -rw-r--r-- | llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp index 2e20f080b83..89fecfceeb3 100644 --- a/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp +++ b/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp @@ -151,22 +151,6 @@ HexagonTargetLowering::buildHvxVectorReg(ArrayRef<SDValue> Values, unsigned ElemWidth = ElemTy.getSizeInBits(); unsigned HwLen = Subtarget.getVectorLength(); - // TODO: Recognize constant splats. - SmallVector<ConstantInt*, 128> Consts(VecLen); - bool AllConst = getBuildVectorConstInts(Values, VecTy, DAG, Consts); - if (AllConst) { - if (llvm::all_of(Consts, [](ConstantInt *CI) { return CI->isZero(); })) - return getZero(dl, VecTy, DAG); - - ArrayRef<Constant*> Tmp((Constant**)Consts.begin(), - (Constant**)Consts.end()); - Constant *CV = ConstantVector::get(Tmp); - unsigned Align = HwLen; - SDValue CP = LowerConstantPool(DAG.getConstantPool(CV, VecTy, Align), DAG); - return DAG.getLoad(VecTy, dl, DAG.getEntryNode(), CP, - MachinePointerInfo::getConstantPool(MF), Align); - } - unsigned ElemSize = ElemWidth / 8; assert(ElemSize*VecLen == HwLen); SmallVector<SDValue,32> Words; @@ -196,7 +180,26 @@ HexagonTargetLowering::buildHvxVectorReg(ArrayRef<SDValue> Values, } if (IsSplat) { assert(SplatV.getNode()); - return DAG.getNode(HexagonISD::VSPLAT, dl, VecTy, SplatV); + auto *IdxN = dyn_cast<ConstantSDNode>(SplatV.getNode()); + if (IdxN && IdxN->isNullValue()) + return getZero(dl, VecTy, DAG); + MVT WordTy = MVT::getVectorVT(MVT::i32, HwLen/4); + SDValue SV = DAG.getNode(HexagonISD::VSPLAT, dl, WordTy, SplatV); + return DAG.getBitcast(VecTy, SV); + } + + // Delay recognizing constant vectors until here, so that we can generate + // a vsplat. + SmallVector<ConstantInt*, 128> Consts(VecLen); + bool AllConst = getBuildVectorConstInts(Values, VecTy, DAG, Consts); + if (AllConst) { + ArrayRef<Constant*> Tmp((Constant**)Consts.begin(), + (Constant**)Consts.end()); + Constant *CV = ConstantVector::get(Tmp); + unsigned Align = HwLen; + SDValue CP = LowerConstantPool(DAG.getConstantPool(CV, VecTy, Align), DAG); + return DAG.getLoad(VecTy, dl, DAG.getEntryNode(), CP, + MachinePointerInfo::getConstantPool(MF), Align); } // Construct two halves in parallel, then or them together. |

