[Bug tree-optimization/112659] New: missed-optimization: if (exp) return exp; else return 0;
goon.pri.low at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Nov 21 21:56:43 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112659
Bug ID: 112659
Summary: missed-optimization: if (exp) return exp; else return
0;
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: goon.pri.low at gmail dot com
Target Milestone: ---
This code here:
int unopt(int v) {
if (v + 8)
return v + 8;
else
return 0;
}
unopt:
xor edx, edx
lea eax, [rdi+8]
cmp edi, -8
cmove eax, edx
ret
Could be optimized to:
int opt(int v) {
return v + 8;
}
opt:
lea eax, [rdi+8]
ret
Note: this happens for all operators, not just addition!
Also, have any suggestions for a better bug name? I am better at spotting
optimizations, not naming them.
More information about the Gcc-bugs
mailing list