https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116751
Bug ID: 116751
Summary: GCC trunk (-O3) doesn't optimize a loop that can be
folded into a constant
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: dccitaliano at gmail dot com
Target Milestone: ---
https://godbolt.org/z/qq1bbdMKn
```
#include <stdint.h>
int64_t patatino() {
int64_t result = 0;
for (int r = 0; r < 7; r++) {
for (int s = 0; s < 10; s++) {
for (int t = 0; t < 10; t++) {
if (t + s + r == 10) {
result += 1;
}
}
}
}
return result;
}
```
Changing the condition from `t + s + r == 10` to `t + s == 10` changes the
generated code into:
```
patatino():
mov eax, 63
ret
```