Issue 71280
Summary clang is suboptimal for `(a % b) lt/ge (b-1)` where b is a power of 2
Labels clang
Assignees
Reporter k-arrows
    Example-1 (b=512, "less than")
https://godbolt.org/z/Tdc6onb6e
https://alive2.llvm.org/ce/z/wvSEvC
```cpp
int foo(int a)
{
   return (a % 512) < 511;
}

int bar(int a)
{
   return (a & -2147483137) != 511;
}
```



Example-2 (b=8, "greater than or equal to")
https://godbolt.org/z/cxdveoT1n
https://alive2.llvm.org/ce/z/sm3xs5
```cpp
int baz(int a)
{
   return (a % 8) >= 7;
}

int qux(int a)
{
   return (a & -2147483641) == 7;
}
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to