public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115011] New: [14/15 Regression] Missed optimization: (bool) (f ? 1: t) ==> 1 when bool t = (0 >= f) + x;
@ 2024-05-09 12:59 652023330028 at smail dot nju.edu.cn
  2024-05-09 14:27 ` [Bug tree-optimization/115011] " hjl.tools at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: 652023330028 at smail dot nju.edu.cn @ 2024-05-09 12:59 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-10 12:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-09 12:59 [Bug tree-optimization/115011] New: [14/15 Regression] Missed optimization: (bool) (f ? 1: t) ==> 1 when bool t = (0 >= f) + x; 652023330028 at smail dot nju.edu.cn
2024-05-09 14:27 ` [Bug tree-optimization/115011] " hjl.tools at gmail dot com
2024-05-09 14:28 ` pinskia at gcc dot gnu.org
2024-05-09 14:50 ` pinskia at gcc dot gnu.org
2024-05-09 14:50 ` pinskia at gcc dot gnu.org
2024-05-10 12:27 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).