llvm / llvm/llvm-project

[IndVars] Wrong code at -O1/2/3

Open
#197,240 0 comments 0 reactions 1 assignee Claimed by @XChy View on GitHub
generated by fuzzer loopoptim miscompilation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer: https://godbolt.org/z/3e9d65W7d
Testcase:
```c
#include
#include
int32_t g4, __chk, g28, g18, g17;
int16_t g7;
_Bool g11;
int main()
{
int32_t v0;
g17 = -78;
_Bool c6;
v0 = g17;
lbl_br5:
switch (v0)
{
case -78: goto lbl_br12;
default: goto lbl_br5;
}
lbl_bf11:
g18 = g4;
c6 = 2 <= g7;
v0 = g18;
switch (v0)
{
case 7: goto lbl_br12;
case 6: goto lbl_br5;
default: goto lbl_sw_def23;
}
lbl_br12:
g28 = 2;
lbl_b14:
g7 = -g28;
g4 = g4 - 106119;
goto lbl_bf11;
lbl_sw_def23:
g28 = 0;
if (c6) goto lbl_b14;
g11 = 0 < g4;
__chk = g4;
printf("checksum=0x%016llx\n", (unsigned long long)__chk);
}
```

The result differs at -O1/2/3, and it bisects to IndVars: https://godbolt.org/z/7Efqnecz8

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.