<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/123278>123278</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missed optimization between `range` parameter metadata and `assume`s
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
scottmcm
</td>
</tr>
</table>
<pre>
Now that `range` parameter metadata exists (🎉) I'm trying to remove some of our `assume`s that `rustc` outputs which should no longer be necessary.
That works for almost all of our tests in https://github.com/rust-lang/rust/blob/master/tests/codegen/transmute-optimized.rs , but one.
We end up, after optimizations, still getting
```rust
define noundef range(i8 1, 4) i8 @ordering_transmute_onetwothree(i8 noundef returned range(i8 -1, 2) %x) unnamed_addr #2 {
start:
%0 = icmp ne i8 %x, 0
tail call void @llvm.assume(i1 %0)
%1 = icmp ult i8 %x, 4
tail call void @llvm.assume(i1 %1)
ret i8 %x
}
```
That input range is `[-1, 2)` and those assumes are a range `[1, 4)`, so it ought to simplify to just `ret i8 1`, but it doesn't.
Alive2 proof that it would be legal: <https://alive2.llvm.org/ce/z/GucQsJ> -- and legal even without the `range` on the return value.
Maybe this is somehow related to the `x uge 1` being turned into `x ne 0`, and thus it not noticing there's a range? Or maybe it's something about the wrap-around?
SEO: rust transmute range bounds
---
As an aside, I'd love to emit these as `range` [assume operand bundles](https://llvm.org/docs/LangRef.html#assume-operand-bundles) instead of `icmp`s, but AFAICT those don't exist yet, so I'm stuck with the `icmp`s for now 🙁
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVU2P2zYQ_TX0ZaCFRNkr-eCDdzcqUjQN2gboMaDEscSEIg1yaGfz64uh5P24tCiwC8ki53H45s0bFaMZHeJB7B7E7mmjEk0-HOLgieZh3vRePx9-91egSRGI-zIoN6K4L-GsgpqRMMCMpLQiBfjDRIogZCu6Uuw70X4Q7V7IPXwUspmBwrNxI5CH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