summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2019-09-12 10:21:00 +0000
committerTim Northover <tnorthover@apple.com>2019-09-12 10:21:00 +0000
commit98534843fb4c14ebe8022143cdcfc2a4ea8d2d02 (patch)
tree4455ba6bca082b7a5ff0301b8adb389683202bf1 /llvm
parent719087bbb775d49f6f4c3f923bb3282b66e588ce (diff)
downloadbcm5719-llvm-98534843fb4c14ebe8022143cdcfc2a4ea8d2d02.tar.gz
bcm5719-llvm-98534843fb4c14ebe8022143cdcfc2a4ea8d2d02.zip
CodeGenPrep: add separate hook say when GEPs should be used for sinking. NFCI.
Up to now, we've decided whether to sink address calculations using GEPs or normal arithmetic based on the useAA hook, but there are other reasons GEPs might be preferred. So this patch splits the two questions, with a default implementation falling back to useAA. llvm-svn: 371721
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/CodeGen/TargetSubtargetInfo.h6
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp4
2 files changed, 8 insertions, 2 deletions
diff --git a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
index 263a6bd5a36..b24828152e5 100644
--- a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
@@ -274,6 +274,12 @@ public:
/// scheduling, DAGCombine, etc.).
virtual bool useAA() const;
+ /// \brief Sink addresses into blocks using GEP instructions rather than
+ /// pointer casts and arithmetic.
+ virtual bool addrSinkUsingGEPs() const {
+ return useAA();
+ }
+
/// Enable the use of the early if conversion pass.
virtual bool enableEarlyIfConversion() const { return false; }
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 9a31c082987..aebfa2e1c11 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -4791,8 +4791,8 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
<< " for " << *MemoryInst << "\n");
if (SunkAddr->getType() != Addr->getType())
SunkAddr = Builder.CreatePointerCast(SunkAddr, Addr->getType());
- } else if (AddrSinkUsingGEPs ||
- (!AddrSinkUsingGEPs.getNumOccurrences() && TM && TTI->useAA())) {
+ } else if (AddrSinkUsingGEPs || (!AddrSinkUsingGEPs.getNumOccurrences() &&
+ TM && SubtargetInfo->addrSinkUsingGEPs())) {
// By default, we use the GEP-based method when AA is used later. This
// prevents new inttoptr/ptrtoint pairs from degrading AA capabilities.
LLVM_DEBUG(dbgs() << "CGP: SINKING nonlocal addrmode: " << AddrMode
OpenPOWER on IntegriCloud