[llvm] [SCEV] Support ule/sle exit counts via widening (PR #92206)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 21:53:37 PDT 2024


nikic wrote:

> In general, you end up with a sext/zext of some expression which still isn't analyzable... but I guess you end up with a useful result in a lot of cases, as demonstrated by the testcases. Maybe worth explicitly noting that you expect the sign/zero-extension to simplify.

Yes, this will mainly do something useful is the LHS is an addrec with the corresponding nuw or nsw flag, in which case the extension is sunk into the addrec and we get an analyzable condition.

Though based on my testing, I think this change has very little practical impact. Probably non-strict exit conditions that can't be converted to strict ones are pretty rare. I mainly need this to avoid a regression in one PhaseOrdering test for an upcoming change.
 
> My biggest concern here is that we'll somehow end up generating code for a bunch of double-register-width math, which would be relatively expensive to compute. Not sure how likely that is, though.

isHighCostExpansion does cost modelling based on TTI, so I'd expect we would mostly refuse to expand cases where the doubling goes beyond the register size.

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


More information about the llvm-commits mailing list