Skip to content

Commit 5d10f31

Browse files
committed
Add a condition on what the maximum of locations there are in a function for RLE to optimize
RLE is an iterative data flow. Functions with too many locations may take a long time for the data flow to converge. Once we move to a genset and killset for RLE. we should be able to lessen the condition a bit more. I have observed no difference in # of redundant loads eliminated on the stdlib (currently we eliminate 3862 redundant loads).
1 parent fd368f0 commit 5d10f31

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/SILOptimizer/Transforms/RedundantLoadElimination.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ static bool isForwardableEdge(SILBasicBlock *BB) {
158158
//===----------------------------------------------------------------------===//
159159
namespace {
160160

161+
// If there are too many locations in the function, we give up.
162+
constexpr unsigned MaxLSLocationLimit = 2048;
163+
161164
/// forward declaration.
162165
class RLEContext;
163166
/// State of the load store in one basic block which allows for forwarding from
@@ -931,6 +934,10 @@ bool RLEContext::gatherValues(SILBasicBlock *BB, LSLocation &L,
931934
}
932935

933936
bool RLEContext::run() {
937+
// Data flow may take too long to converge.
938+
if (LSLocationVault.size() > MaxLSLocationLimit)
939+
return false;
940+
934941
// Process basic blocks in RPO. After the data flow converges, run last
935942
// iteration and perform load forwarding.
936943
bool LastIteration = false;

0 commit comments

Comments
 (0)