summaryrefslogtreecommitdiff
path: root/lib/Target/R600/R600ISelLowering.cpp
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2013-07-23 01:48:24 +0000
committerTom Stellard <thomas.stellard@amd.com>2013-07-23 01:48:24 +0000
commit58d3335cb9d2a40bd15c29a12ba045163295190e (patch)
treed28995a1a1aab41ad515eb57064e8386c5ce5fb2 /lib/Target/R600/R600ISelLowering.cpp
parenta7eea0568c16f8e25b9e3ba9b7b73ae506738b63 (diff)
downloadllvm-58d3335cb9d2a40bd15c29a12ba045163295190e.tar.gz
llvm-58d3335cb9d2a40bd15c29a12ba045163295190e.tar.bz2
llvm-58d3335cb9d2a40bd15c29a12ba045163295190e.tar.xz
R600: Move CONST_ADDRESS folding into AMDGPUDAGToDAGISel::Select()
This increases the number of opportunites we have for folding. With the previous implementation we were unable to fold into any instructions other than the first when multiple instructions were selected from a single SDNode. Reviewed-by: Vincent Lejeune <vljn at ovi.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/R600/R600ISelLowering.cpp')
-rw-r--r--lib/Target/R600/R600ISelLowering.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Target/R600/R600ISelLowering.cpp b/lib/Target/R600/R600ISelLowering.cpp
index dd613d56a6..a2bc2c3a9f 100644
--- a/lib/Target/R600/R600ISelLowering.cpp
+++ b/lib/Target/R600/R600ISelLowering.cpp
@@ -1154,6 +1154,30 @@ SDValue R600TargetLowering::LowerLOAD(SDValue Op, SelectionDAG &DAG) const
return DAG.getMergeValues(MergedValues, 2, DL);
}
+ // For most operations returning SDValue() will result int he node being
+ // expanded by the DAG Legalizer. This is not the case for ISD::LOAD, so
+ // we need to manually expand loads that may be legal in some address spaces
+ // and illegal in others. SEXT loads from CONSTANT_BUFFER_0 are supported
+ // for compute shaders, since the data is sign extended when it is uploaded
+ // to the buffer. Howerver SEXT loads from other addresspaces are not
+ // supported, so we need to expand them here.
+ if (LoadNode->getExtensionType() == ISD::SEXTLOAD) {
+ EVT MemVT = LoadNode->getMemoryVT();
+ assert(!MemVT.isVector() && (MemVT == MVT::i16 || MemVT == MVT::i8));
+ SDValue ShiftAmount =
+ DAG.getConstant(VT.getSizeInBits() - MemVT.getSizeInBits(), MVT::i32);
+ SDValue NewLoad = DAG.getExtLoad(ISD::EXTLOAD, DL, VT, Chain, Ptr,
+ LoadNode->getPointerInfo(), MemVT,
+ LoadNode->isVolatile(),
+ LoadNode->isNonTemporal(),
+ LoadNode->getAlignment());
+ SDValue Shl = DAG.getNode(ISD::SHL, DL, VT, NewLoad, ShiftAmount);
+ SDValue Sra = DAG.getNode(ISD::SRA, DL, VT, Shl, ShiftAmount);
+
+ SDValue MergedValues[2] = { Sra, Chain };
+ return DAG.getMergeValues(MergedValues, 2, DL);
+ }
+
if (LoadNode->getAddressSpace() != AMDGPUAS::PRIVATE_ADDRESS) {
return SDValue();
}