Issue |
91619
|
Summary |
Missed optimization in bounds analysis in unsigned arithmetic that cannot underflow
|
Labels |
new issue
|
Assignees |
|
Reporter |
davidben
|
Clang doesn't seem to be able to optimize the following out:
```
bool f(size_t a, size_t b) {
__builtin_assume(a <= b);
__builtin_assume(b <= PTRDIFF_MAX);
// This can be deleted, because:
// 1. 0 <= a <= b implies that b - a <= b
// 2. b - a <= b <= PTRDIFF_MAX
return b - a <= PTRDIFF_MAX;
}
```
https://godbolt.org/z/vzE7qb7Gb
I ran into this while exploring what combination of `__builtin_assume`s would dispatch some unnecessary assertions in `std::string_view`. (A separate bug while I'll file after this.)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs