| Issue |
76421
|
| Summary |
[InstCombine] Missed optimisation for checking divisibiliy of square numbers by power of 2
|
| Labels |
llvm:optimizations,
llvm:instcombine,
missed-optimization
|
| Assignees |
|
| Reporter |
Kmeakin
|
$x^2 \mid 2^k \Leftrightarrow x \mid 2^{ \lceil k/2 \rceil }$
```c
#include <stdbool.h>
#include <stdint.h>
#define u32 uint32_t
bool src(u32 x, u32 y) { return (x * x) % (1 << y) == 0; }
bool tgt(u32 x, u32 y) { return x % (1 << ((y + 1) / 2)) == 0; }
```
[godbolt,](https://godbolt.org/z/WK1oW6Mor), [alive](https://alive2.llvm.org/ce/z/q9eGMx)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs