| Issue |
56479
|
| Summary |
Missing simplification for checking value is sign extended
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
majnemer
|
Consider a sequence like:
```c++
bool src(int x) {
return __builtin_clrsb(x) >= (32 - bits);
}
```
We turn this into:
```llvm
define dso_local zeroext i1 @src(i32 noundef %0) local_unnamed_addr #0 {
%2 = ashr i32 %0, 31
%3 = xor i32 %2, %0
%4 = icmp ult i32 %3, 4
ret i1 %4
}
```
However, it is equivalent to:
```llvm
define dso_local zeroext i1 @tgt(i32 noundef %0) local_unnamed_addr #0 {
%2 = add i32 %0, 4
%3 = icmp ult i32 %2, 8
ret i1 %3
}
```
We get this if we wrote the following C++:
```c++
bool tgt(int x) {
using ty = _BitInt(3);
return int(ty(x)) == x;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs