public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/107767] New: GCC has some problems in optimizer of trivial case
@ 2022-11-20 13:00 socketpair at gmail dot com
  2022-11-20 13:02 ` [Bug regression/107767] " socketpair at gmail dot com
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: socketpair at gmail dot com @ 2022-11-20 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107767
           Summary: GCC has some problems in optimizer of trivial case
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: regression
          Assignee: unassigned at gcc dot gnu.org
          Reporter: socketpair at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/rTfTondfP

```
#include <stdint.h>

int firewall(const uint8_t *restrict data) {
    const uint8_t ip_proto = *data;
    const uint16_t dst_port = *((const uint16_t *)data + 32);

    if (ip_proto == 17 && dst_port == 15) return 1;
    if (ip_proto == 17 && dst_port == 23) return 1;
    if (ip_proto == 17 && dst_port == 47) return 1;
    if (ip_proto == 17 && dst_port == 45) return 1;
    if (ip_proto == 17 && dst_port == 42) return 1;
    if (ip_proto == 17 && dst_port == 1) return 1;
    if (ip_proto == 17 && dst_port == 2) return 1;
    if (ip_proto == 17 && dst_port == 3) return 1;

    return 0;
}

int firewall2(const uint8_t *restrict data) {
    const uint16_t dst_port = *((const uint16_t *)data + 32);

    if (dst_port == 15) return 1;
    if (dst_port == 23) return 1;
    if (dst_port == 47) return 1;
    if (dst_port == 45) return 1;
    if (dst_port == 42) return 1;
    if (dst_port == 1) return 1;
    if (dst_port == 2) return 1;
    if (dst_port == 3) return 1;

    return 0;
}
```

Compile with -Os.

Second function IS NOT minimal, obviously. It's a bug. GCC 12.2 does not have
it.

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

end of thread, other threads:[~2023-01-11 12:14 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-20 13:00 [Bug regression/107767] New: GCC has some problems in optimizer of trivial case socketpair at gmail dot com
2022-11-20 13:02 ` [Bug regression/107767] " socketpair at gmail dot com
2022-11-21  8:46 ` marxin at gcc dot gnu.org
2022-11-21 10:33 ` socketpair at gmail dot com
2022-11-21 15:57 ` [Bug tree-optimization/107767] [13 Regression] " pinskia at gcc dot gnu.org
2022-12-02 14:27 ` [Bug tree-optimization/107767] [13 Regression] switch to table conversion happening even though using btq is better marxin at gcc dot gnu.org
2022-12-02 14:54 ` socketpair at gmail dot com
2022-12-02 15:00 ` marxin at gcc dot gnu.org
2022-12-02 15:07 ` marxin at gcc dot gnu.org
2022-12-02 15:15 ` socketpair at gmail dot com
2022-12-02 15:17 ` jakub at gcc dot gnu.org
2022-12-02 15:27 ` rguenth at gcc dot gnu.org
2022-12-02 15:31 ` jakub at gcc dot gnu.org
2022-12-02 15:44 ` jakub at gcc dot gnu.org
2022-12-05 14:49 ` marxin at gcc dot gnu.org
2022-12-21  9:46 ` rguenth at gcc dot gnu.org
2022-12-23 14:05 ` marxin at gcc dot gnu.org
2023-01-04 14:26 ` jakub at gcc dot gnu.org
2023-01-06 12:36 ` marxin at gcc dot gnu.org
2023-01-09 10:02 ` rguenth at gcc dot gnu.org
2023-01-11 12:14 ` cvs-commit at gcc dot gnu.org
2023-01-11 12:14 ` 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).