https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115275
Bug ID: 115275 Summary: [14/15 Regression] Missed optimization for Dead Code Elimination 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 by Dead Code Elimination, but gcc -O3 missed it. This is a regression from GCC-14.1. https://godbolt.org/z/nc1417ed9 #include<algorithm> unsigned short m, a, b; void fn(unsigned short f) { if( (std::min(std::max(f, a) ? f : 0U, 84991U)) - (std::min(std::max(f, b) ? f : 0U, 84991U)) ) {m=1;} } GCC -O3: fn(unsigned short): movzx eax, WORD PTR a[rip] movzx ecx, WORD PTR b[rip] mov edx, edi cmp di, ax cmovnb eax, edx cmp di, cx cmovnb ecx, edx test ax, ax je .L2 test cx, cx je .L9 .L1: ret .L2: test cx, cx je .L1 cmp dx, ax je .L1 .L10: mov eax, 1 mov WORD PTR m[rip], ax ret .L9: mov eax, edi xor edx, edx cmp dx, ax jne .L10 ret Expected code (GCC-13.2) fn(unsigned short): ret Thank you very much for your time and effort! We look forward to hearing from you.