[llvm] r201121 - [CodeGenPrepare] Undo changes that happened for the profitability check.

Quentin Colombet qcolombet at apple.com
Mon Feb 10 17:59:02 PST 2014


Author: qcolombet
Date: Mon Feb 10 19:59:02 2014
New Revision: 201121

URL: http://llvm.org/viewvc/llvm-project?rev=201121&view=rev
Log:
[CodeGenPrepare] Undo changes that happened for the profitability check.

The addressing mode matcher checks at some point the profitability of folding an
instruction into the addressing mode. When the instruction to be folded has
several uses, it checks that the instruction can be folded in each use.
To do so, it creates a new matcher for each use and check if the instruction is
in the list of the matched instructions of this new matcher.

The new matchers may promote some instructions and this has to be undone to keep
the state of the original matcher consistent.

A test case will follow.

<rdar://problem/16020230>

Modified:
    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=201121&r1=201120&r2=201121&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Mon Feb 10 19:59:02 2014
@@ -2211,6 +2211,8 @@ IsProfitableToFoldIntoAddressingMode(Ins
     // will tell us if the addressing mode for the memory operation will
     // *actually* cover the shared instruction.
     ExtAddrMode Result;
+    TypePromotionTransaction::ConstRestorationPt LastKnownGood =
+        TPT.getRestorationPoint();
     AddressingModeMatcher Matcher(MatchedAddrModeInsts, TLI, AddressAccessTy,
                                   MemoryInst, Result, InsertedTruncs,
                                   PromotedInsts, TPT);
@@ -2218,6 +2220,11 @@ IsProfitableToFoldIntoAddressingMode(Ins
     bool Success = Matcher.MatchAddr(Address, 0);
     (void)Success; assert(Success && "Couldn't select *anything*?");
 
+    // The match was to check the profitability, the changes made are not
+    // part of the original matcher. Therefore, they should be dropped
+    // otherwise the original matcher will not present the right state.
+    TPT.rollback(LastKnownGood);
+
     // If the match didn't cover I, then it won't be shared by it.
     if (std::find(MatchedAddrModeInsts.begin(), MatchedAddrModeInsts.end(),
                   I) == MatchedAddrModeInsts.end())





More information about the llvm-commits mailing list