[llvm] [SCEV,LAA] Introduce scoped SCEV, use in LAA computations (WIP). (PR #90742)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Sun May 5 21:57:25 PDT 2024


efriedma-quic wrote:

When I've been thinking about flags in SCEV, I've been mostly considering modifying the flag representation itself: currently, flags have to be valid for the whole function, but we could add another form of flags that are only valid for users of a specific SCEV*. The primary problem with that is that SCEV canonicalization becomes less powerful: you can have two "equal" expressions that don't have the same flags.  To work around that, you'd need some fast way to get from a SCEV with user-flags to the corresponding SCEV without those flags.  Plus, you have two sets of flags, so reasoning about them becomes a bit harder. I think this is all solvable, but it's a pretty large change.

The alternative here is interesting: attach a scope to certain SCEVs, then you can modify their flags however you want, and nothing else ever sees those expressions.

It seems a bit dangerous to me to make the "scope" global per SCEV: scoped SCEVs could accidentally leak into contexts where you don't intend to use them (like the trip counts of loops).  I guess the opposite is also sort of dangerous, though: if you accidentally drop the scope, you can accidentally introduce flags onto unscoped SCEVs.

I'm not sure Loop* pointers reliably live long enough to avoid accidentally reusing a scope; maybe consider just using a counter.

https://github.com/llvm/llvm-project/pull/90742


More information about the llvm-commits mailing list