diff options
author | Farhana Aleen <farhana.aleen@gmail.com> | 2018-05-01 21:41:12 +0000 |
---|---|---|
committer | Farhana Aleen <farhana.aleen@gmail.com> | 2018-05-01 21:41:12 +0000 |
commit | e2dfe8a8539bd457f517eaa3bb859c0f9ff21b31 (patch) | |
tree | 52ed315879d5b65321fa62e40f23b7c2350f4682 /llvm/lib/Target | |
parent | 8d693602a1b990f0e44af9fd34c7e7ea3eca91b3 (diff) | |
download | bcm5719-llvm-e2dfe8a8539bd457f517eaa3bb859c0f9ff21b31.tar.gz bcm5719-llvm-e2dfe8a8539bd457f517eaa3bb859c0f9ff21b31.zip |
[AMDGPU] Support horizontal vectorization.
Author: FarhanaAleen
Reviewed By: rampitec, arsenm
Subscribers: llvm-commits, AMDGPU
Differential Revision: https://reviews.llvm.org/D46213
llvm-svn: 331313
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h | 4 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 24 |
3 files changed, 43 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp index bf560a94b31..d9bee122ce7 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp @@ -468,6 +468,21 @@ unsigned AMDGPUTTIImpl::getCFInstrCost(unsigned Opcode) { } } +int AMDGPUTTIImpl::getArithmeticReductionCost(unsigned Opcode, Type *Ty, + bool IsPairwise) { + EVT OrigTy = TLI->getValueType(DL, Ty); + + // Computes cost on targets that have packed math instructions(which support + // 16-bit types only). + if (IsPairwise || + !ST->hasVOP3PInsts() || + OrigTy.getScalarSizeInBits() != 16) + return BaseT::getArithmeticReductionCost(Opcode, Ty, IsPairwise); + + std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Ty); + return LT.first * getFullRateInstrCost(); +} + int AMDGPUTTIImpl::getVectorInstrCost(unsigned Opcode, Type *ValTy, unsigned Index) { switch (Opcode) { diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h index a112757173d..744093d038f 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h @@ -172,6 +172,10 @@ public: const Function *Callee) const; unsigned getInliningThresholdMultiplier() { return 9; } + + int getArithmeticReductionCost(unsigned Opcode, + Type *Ty, + bool IsPairwise); }; } // end namespace llvm diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index 4186e221ede..1ed6dd963fa 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -6616,6 +6616,30 @@ SDValue SITargetLowering::performExtractVectorEltCombine( return DAG.getNode(Vec.getOpcode(), SL, EltVT, Elt); } + // ScalarRes = EXTRACT_VECTOR_ELT ((vector-BINOP Vec1, Vec2), Idx) + // => + // Vec1Elt = EXTRACT_VECTOR_ELT(Vec1, Idx) + // Vec2Elt = EXTRACT_VECTOR_ELT(Vec2, Idx) + // ScalarRes = scalar-BINOP Vec1Elt, Vec2Elt + if (Vec.hasOneUse()) { + SDLoc SL(N); + EVT EltVT = N->getValueType(0); + SDValue Idx = N->getOperand(1); + unsigned Opc = Vec.getOpcode(); + + switch(Opc) { + default: + return SDValue(); + // TODO: Support other binary operations. + case ISD::FADD: + case ISD::ADD: + return DAG.getNode(Opc, SL, EltVT, + DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, EltVT, + Vec.getOperand(0), Idx), + DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, EltVT, + Vec.getOperand(1), Idx)); + } + } return SDValue(); } |