summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-11-21 22:49:15 +0000
committerJustin Lebar <jlebar@google.com>2016-11-21 22:49:15 +0000
commit3e50a5be8f5259bc256f39830e72525dd9f90626 (patch)
treeb99385ff21dbca7fb6474649ed54e31953b3cb28 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent838c7f5a85a96f642fea0e2167c92e32682222b6 (diff)
downloadbcm5719-llvm-3e50a5be8f5259bc256f39830e72525dd9f90626.tar.gz
bcm5719-llvm-3e50a5be8f5259bc256f39830e72525dd9f90626.zip
[CodeGenPrepare] Don't sink non-cheap addrspacecasts.
Summary: Previously, CGP would unconditionally sink addrspacecast instructions, even going so far as to sink them into a loop. Now we check that the cast is "cheap", as defined by TLI. We introduce a new "is-cheap" function to TLI rather than using isNopAddrSpaceCast because some GPU platforms want the ability to ask for non-nop casts to be sunk. Reviewers: arsenm, tra Subscribers: jholewinski, wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D26923 llvm-svn: 287591
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 87ad3075873..68f090ccee2 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -927,6 +927,14 @@ static bool SinkCast(CastInst *CI) {
///
static bool OptimizeNoopCopyExpression(CastInst *CI, const TargetLowering &TLI,
const DataLayout &DL) {
+ // Sink only "cheap" (or nop) address-space casts. This is a weaker condition
+ // than sinking only nop casts, but is helpful on some platforms.
+ if (auto *ASC = dyn_cast<AddrSpaceCastInst>(CI)) {
+ if (!TLI.isCheapAddrSpaceCast(ASC->getSrcAddressSpace(),
+ ASC->getDestAddressSpace()))
+ return false;
+ }
+
// If this is a noop copy,
EVT SrcVT = TLI.getValueType(DL, CI->getOperand(0)->getType());
EVT DstVT = TLI.getValueType(DL, CI->getType());
OpenPOWER on IntegriCloud