[Bug tree-optimization/118623] [12/13/14/15 regression] Miscompile with -O2/3 and -O0/1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118623
Richard Biener changed:
What|Removed |Added
Keywords||needs-bisection
Last reconfirmed||2025-01-23
CC||rguenth at gcc dot gnu.org
Priority|P3 |P2
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #5 from Richard Biener ---
Further reduced, not analyzed.
static int c(int f, int g)
{
int e = 1 << f;
if (g & e)
return 0;
return 5;
}
__attribute__((noipa))
void h(int g)
{
if (((c(g - 50, g) + g + g) & 1) == 0)
__builtin_abort ();
}
int main()
{
h(63);
return 0;
}
[Bug tree-optimization/118623] [12/13/14/15 regression] Miscompile with -O2/3 and -O0/1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118623 --- Comment #4 from Andrew Pinski --- Created attachment 60247 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60247&action=edit self testing testcase
[Bug tree-optimization/118623] [12/13/14/15 regression] Miscompile with -O2/3 and -O0/1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118623
--- Comment #3 from Andrew Pinski ---
(In reply to Sam James from comment #2)
> Changing it to:
> ```
> int a, b;
>
> int c(int f, int g) {
> for (int d = 0; d <= 4; d++) {
> int e = 1 << f;
> if (g & e)
> return d;
> }
> return 5;
> }
>
> int h(int f, int g) {
> if ((c(g - 50, g) + g + g) & 1);
> else if (f)
> a = 1;
> return a;
> }
>
> int main() {
> if (h(b + 5, b + 63) != 0)
> __builtin_abort();
> return 0;
> }
> ```
>
> it works at -O3.
Just mark h as noinline.
[Bug tree-optimization/118623] [12/13/14/15 regression] Miscompile with -O2/3 and -O0/1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118623
--- Comment #2 from Sam James ---
Changing it to:
```
int a, b;
int c(int f, int g) {
for (int d = 0; d <= 4; d++) {
int e = 1 << f;
if (g & e)
return d;
}
return 5;
}
int h(int f, int g) {
if ((c(g - 50, g) + g + g) & 1);
else if (f)
a = 1;
return a;
}
int main() {
if (h(b + 5, b + 63) != 0)
__builtin_abort();
return 0;
}
```
it works at -O3.
[Bug tree-optimization/118623] [12/13/14/15 regression] Miscompile with -O2/3 and -O0/1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118623 Sam James changed: What|Removed |Added Component|c |tree-optimization --- Comment #1 from Sam James --- -O2 -fno-tree-pre works
