[llvm] [SCEV] Increase RewriteMap default size (NFC). (PR #224864)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 20 03:52:02 PDT 2026


https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/224864

>From 3e00d3b33a78deb2d04d591a2072792ee42a8ce2 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Sat, 19 Sep 2026 15:03:11 +0100
Subject: [PATCH] [SCEV] Increase RewriteMap default size (NFC).

The old automatic default of 4 inline buckets meant that in practice we
were frequently hitting the grow path to 64 buckets, causing unnecessary
memory traffic.

SCEVRewriteVisitor is used each time loop guards are applied and the new
default improves compile-time slightly for SCEV-heavy workloads. Geomean improves
by -0.03%, but mafft and lencod see bigger wins:
https://llvm-compile-time-tracker.com/compare.php?from=7c55ad084c8b1503cafa42c60d88bff65919c9fa&to=c1f14fba38c4cd7b282709d8bd9481d28642b2c6&stat=instructions:u

It mostly makes applying loop guards cheaper, making it easier to use in
more places in the future.
---
 llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
index 277f445b93a81..ace050bd2c2c1 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -803,7 +803,7 @@ class SCEVRewriteVisitor : public SCEVVisitor<SC, const SCEV *> {
   // a SCEV is referenced by multiple SCEVs. Without memoization, this
   // visit algorithm would have exponential time complexity in the worst
   // case, causing the compiler to hang on certain tests.
-  SmallDenseMap<const SCEV *, const SCEV *> RewriteResults;
+  SmallDenseMap<const SCEV *, const SCEV *, 16> RewriteResults;
 
 public:
   SCEVRewriteVisitor(ScalarEvolution &SE) : SE(SE) {}



More information about the llvm-commits mailing list