[llvm] 6af94d2 - [cgp] Defer lazy domtree usage to last possible point

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 10:19:52 PST 2021


Author: Philip Reames
Date: 2021-03-04T10:19:45-08:00
New Revision: 6af94d22f7b0f7f5edd84ad9ae96fd801dbf017d

URL: https://github.com/llvm/llvm-project/commit/6af94d22f7b0f7f5edd84ad9ae96fd801dbf017d
DIFF: https://github.com/llvm/llvm-project/commit/6af94d22f7b0f7f5edd84ad9ae96fd801dbf017d.diff

LOG: [cgp] Defer lazy domtree usage to last possible point

This is a compile time optimization for d9e93e8e5. Not sure this matters or not, but why not do it just in case.

This does involve querying TLI with a potentially invalid addressing mode for the using instruction, but since we don't actually pass the using instruction to the TLI callback, that should be fine.

Added: 
    

Modified: 
    llvm/lib/CodeGen/CodeGenPrepare.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 875a0eec2575..f4bf55d773a3 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -3912,12 +3912,15 @@ bool AddressingModeMatcher::matchScaledValue(Value *ScaleReg, int64_t Scale,
       Instruction *IVInc = IVStep->first;
       APInt Step = IVStep->second;
       APInt Offset = Step * AddrMode.Scale;
-      if (Offset.isSignedIntN(64) && getDTFn().dominates(IVInc, MemoryInst)) {
+      if (Offset.isSignedIntN(64)) {
         TestAddrMode.InBounds = false;
         TestAddrMode.ScaledReg = IVInc;
         TestAddrMode.BaseOffs -= Offset.getLimitedValue();
         // If this addressing mode is legal, commit it..
-        if (TLI.isLegalAddressingMode(DL, TestAddrMode, AccessTy, AddrSpace)) {
+        // (Note that we defer the (expensive) domtree base legality check
+        // to the very last possible point.)
+        if (TLI.isLegalAddressingMode(DL, TestAddrMode, AccessTy, AddrSpace) &&
+            getDTFn().dominates(IVInc, MemoryInst)) {
           AddrModeInsts.push_back(cast<Instruction>(IVInc));
           AddrMode = TestAddrMode;
           return true;


        


More information about the llvm-commits mailing list