[llvm] [SCEV] Preserve divisibility info when creating UMax/SMax expressions. (PR #160012)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 24 10:49:10 PDT 2025


fhahn wrote:

> > Yep, I can try to see if this would also trigger in practice at construction, but we would still need the guard-specific logic w/o the != 0 check
> 
> Your wording here triggered a thought. When phrased like this, this sounds _a lot_ like SCEV construction under an assumption (or predicate) that x != 0. We have a bunch of logic of this variety in PredicatedScalarEvolution, and our assumption handling already, is there a possibility for code sharing here?
> 
> (This may not be worth the work to actually do immediately. Not a blocking comment by any means.)

Thanks, I need to think about this a bit more. With both PredicatedScalarEvolution  and loop guards we rewrite SCEV expressions given extra information (runtime predicates and information from guards respectively), but currently there does't seem much overlap in the types of expressions we rewrite, with PSE mostly focused on extends and forced AddRecs.

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


More information about the llvm-commits mailing list