Skip to content

Commit

Permalink
Auto merge of #135674 - scottmcm:assume-better, r=estebank
Browse files Browse the repository at this point in the history
Update our range `assume`s to the format that LLVM prefers

I found out in llvm/llvm-project#123278 (comment) that the way I started emitting the `assume`s in #109993 was suboptimal, and as seen in that LLVM issue the way we're doing it -- with two `assume`s sometimes -- can at times lead to CVP/SCCP not realize what's happening because one of them turns into a `ne` instead of conveying a range.

So this updates how it's emitted from
```
assume( x >= LOW );
assume( x <= HIGH );
```
or
```
// (for ranges that wrap the range)
assume( (x <= LOW) | (x >= HIGH) );
```
to
```
assume( (x - LOW) <= (HIGH - LOW) );
```
so that we don't need multiple `icmp`s nor multiple `assume`s for a single value, and both wrappping and non-wrapping ranges emit the same shape.

(And we don't bother emitting the subtraction if `LOW` is zero, since that's trivial for us to check too.)
  • Loading branch information
bors committed Jan 22, 2025
2 parents 20e49d5 + a61f3d7 commit 2421d6b
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 2421d6b

Please sign in to comment.