[llvm] [SCEV] Check bitwidth for constant ranges comparison (PR #150364)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 24 13:54:47 PDT 2025


annamthomas wrote:

> Was this triggered by a caller passing mismatching types here that needs updating?

Yep, basically I was adding a fast path downstream to `evaluatePtrAddRecAtMaxBTCWillNotWrap` API which uses `isKnownPredicate` (we have some information on java level loops). I needed to extend both SCEVs to the wider type. Without that, my change crashed here. 

What is not clear to me is that we sometimes convert to wider types before using this API, but at other times we do not. Also, when I tried asserting for SCEV matching types in `isKnownPredicateViaConstantRanges`, there were lit test failures. So, I am not sure what the requirement of the passed-in SCEVs are. 

I don't think we really need to add an assert at the `RangeLHS.getBitWidth() == RangeRHS.getBitWidth() ` because it would anyway crash with the assert within the ConstantRange's utility.





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


More information about the llvm-commits mailing list