]> granicus.if.org Git - llvm/commitdiff
CodeGenPrep: add separate hook say when GEPs should be used for sinking. NFCI.
authorTim Northover <tnorthover@apple.com>
Thu, 12 Sep 2019 10:21:00 +0000 (10:21 +0000)
committerTim Northover <tnorthover@apple.com>
Thu, 12 Sep 2019 10:21:00 +0000 (10:21 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371721 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/TargetSubtargetInfo.h
lib/CodeGen/CodeGenPrepare.cpp

index 263a6bd5a3658e8c60e7bb70e51fe80e793f563b..b24828152e5b970aa6e212437a6c88b45c9be3ad 100644 (file)
@@ -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; }
 
index 9a31c0829873f7acd32476f4c7ab3291319f6cf2..aebfa2e1c110759f294de99ea3f3fa34e4ec8300 100644 (file)
@@ -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