aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2021-03-04 10:18:10 -0800
committerPhilip Reames <listmail@philipreames.com>2021-03-04 10:19:45 -0800
commit6af94d22f7b0f7f5edd84ad9ae96fd801dbf017d (patch)
tree0c96641d953a44e378931d2a703bc384d9572233 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parentda1e37a8b06b921ac8f742245bb4d2a6ecd8b9e1 (diff)
downloadllvm-6af94d22f7b0f7f5edd84ad9ae96fd801dbf017d.zip
llvm-6af94d22f7b0f7f5edd84ad9ae96fd801dbf017d.tar.gz
llvm-6af94d22f7b0f7f5edd84ad9ae96fd801dbf017d.tar.bz2
[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.
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 875a0ee..f4bf55d 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;