https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104645
Bug ID: 104645 Summary: [12 Regression] i ? i % 2 : 0 not optimized anymore Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: denis.campredon at gmail dot com Target Milestone: --- Was told to file a new PR for that case : ------------------ int foo(unsigned i) { return i ? i % 2 : 0; } ------------------ With trunk ------------------------ foo(unsigned int): mov eax, edi xor edx, edx and eax, 1 test edi, edi cmove eax, edx ret ----------------------- With 11.2 ----------------------- foo(unsigned int): mov eax, edi and eax, 1 ret ----------------------- According to Jakub Jelinek in PR104639 it started with r12-5358-g32221357007666124409ec3ee0d3a1cf263ebc9e