public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109960] New: [10/11/12/13/14 Regression] missing combining of `(a&1) != 0 || (a&2)!=0` into `(a&3)!=0`
@ 2023-05-25  0:40 pinskia at gcc dot gnu.org
  2023-05-25  0:41 ` [Bug tree-optimization/109960] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-25  0:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109960

            Bug ID: 109960
           Summary: [10/11/12/13/14 Regression] missing combining of
                    `(a&1) != 0 || (a&2)!=0` into `(a&3)!=0`
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take the following C++ code (reduced from stmt_can_terminate_bb_p):
```
static inline bool f1(unsigned *a)
{
        return (*a&1);
}
static inline bool f2(unsigned *a)
{
        return (*a&2);
}

bool f(int c, unsigned *a)
{
  if (c)
    return 0;
  return f2(a) || f1(a) ;
}
```

At -O1 we can produce:
```
        movl    $0, %eax
        testl   %edi, %edi
        jne     .L1
        testb   $3, (%rsi)
        setne   %al
.L1:
        ret
```
But at -O2 we get:
        xorl    %eax, %eax
        testl   %edi, %edi
        jne     .L1
        movl    (%rsi), %edx
        movl    %edx, %eax
        andl    $1, %eax
        andl    $2, %edx
        movl    $1, %edx
        cmovne  %edx, %eax
.L1:
        ret

Which is just so much worse.
This started in GCC 9.

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

end of thread, other threads:[~2024-01-12 13:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25  0:40 [Bug tree-optimization/109960] New: [10/11/12/13/14 Regression] missing combining of `(a&1) != 0 || (a&2)!=0` into `(a&3)!=0` pinskia at gcc dot gnu.org
2023-05-25  0:41 ` [Bug tree-optimization/109960] " pinskia at gcc dot gnu.org
2023-05-25  0:45 ` pinskia at gcc dot gnu.org
2023-05-25  0:58 ` pinskia at gcc dot gnu.org
2023-05-25  2:29 ` pinskia at gcc dot gnu.org
2023-05-25  2:51 ` pinskia at gcc dot gnu.org
2023-05-25  7:59 ` rguenth at gcc dot gnu.org
2023-07-07 10:45 ` [Bug tree-optimization/109960] [11/12/13/14 " rguenth at gcc dot gnu.org
2023-09-16 22:55 ` pinskia at gcc dot gnu.org
2023-09-16 23:04 ` pinskia at gcc dot gnu.org
2023-09-17  1:27 ` pinskia at gcc dot gnu.org
2024-01-12 13:53 ` 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).