Issue 173691
Summary InstCombine: `umin(clz(x), clz(y)) => clz(x | y)` and `umin(ctz(x), ctz(y)) => ctz(x | y)`
Labels llvm:instcombine, missed-optimization
Assignees
Reporter Kmeakin
    [C++ source](https://godbolt.org/z/E8abbjT7G)
[alive proof](https://alive2.llvm.org/ce/z/mh94_n)

```c++
using u32 = unsigned int;
#define clz __builtin_clzg
#define ctz __builtin_ctzg
#define min(x, y) x < y ? x : y

extern "C" {
u32 src1(u32 x, u32 y) { return min(ctz(x), ctz(y)); }
u32 tgt1(u32 x, u32 y) { return ctz(x | y); }

u32 src2(u32 x, u32 y) { return min(clz(x), clz(y)); }
u32 tgt2(u32 x, u32 y) { return clz(x | y); }
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to