https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115011
Bug ID: 115011 Summary: [14/15 Regression] Missed optimization: (bool) (f ? 1: t) ==> 1 when bool t = (0 >= f) + x; Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: 652023330028 at smail dot nju.edu.cn Target Milestone: --- Hello, we noticed that the code below can be optimized as stated in the title, but gcc -O3 seems to have missed it. Reduced code: https://godbolt.org/z/xE6GEEn7j bool x; bool fn3(unsigned long long int f) { bool t = (0 >= f) + x; return f ? 1: t; } GCC -O3: fn3(unsigned long long): movzx eax, BYTE PTR x[rip] cmp rdi, 1 adc eax, 0 test eax, eax setne al test rdi, rdi setne dl or eax, edx ret Expected code (GCC-13.2): fn3(unsigned long long): mov eax, 1 ret Thank you very much for your time and effort! We look forward to hearing from you.