| Issue |
61671
|
| Summary |
Transform 31 - CTLZ into CTLZ ^ 31 on x86
|
| Labels |
backend:X86,
missed-optimization
|
| Assignees |
|
| Reporter |
kazutakahirata
|
Compile:
```
// -march=skylake -std=c++20 -O2 -S
#include <bit>
unsigned log2_floor_std(unsigned i) {
return std::bit_width(i) - 1;
}
```
I get:
```
define dso_local noundef i32 @_Z14log2_floor_stdj(i32 noundef %i) local_unnamed_addr #0 {
entry:
%0 = tail call i32 @llvm.ctlz.i32(i32 %i, i1 false), !range !5
%sub = sub nsw i32 31, %0
ret i32 %sub
}
```
```
f3 0f bd cf lzcnt %edi,%ecx
b8 1f 00 00 00 mov $0x1f,%eax
29 c8 sub %ecx,%eax
```
We could generate:
```
f3 0f bd c7 lzcnt %edi,%eax
83 f0 1f xor $0x1f,%eax
```
This issue is inspired by https://github.com/llvm/llvm-project/issues/57312.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs