From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6F036396D82D; Sun, 20 Nov 2022 13:00:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F036396D82D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668949233; bh=hON6NHqc4sSCQzaGjqCLLyINzRPGDSher246WlKSStY=; h=From:To:Subject:Date:From; b=aeo9hXX8jKhW2q31LqSCLE/FVbhJ9xUpijgJJmzMAwDzYk7YCHLK87lG9S2Kd2D2Y 8wdwmO6LiaZu4PeuSduYko3RM9b+o9r7d5m1hfurNkJrcTXoPl7YPJy258Gwa9DdoN gYtO4KHFpYr+EWjr5XlKn9G64vtapMLvSd+2KQAk= From: "socketpair at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug regression/107767] New: GCC has some problems in optimizer of trivial case Date: Sun, 20 Nov 2022 13:00:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: regression X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: socketpair at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107767 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 int firewall(const uint8_t *restrict data) { const uint8_t ip_proto =3D *data; const uint16_t dst_port =3D *((const uint16_t *)data + 32); if (ip_proto =3D=3D 17 && dst_port =3D=3D 15) return 1; if (ip_proto =3D=3D 17 && dst_port =3D=3D 23) return 1; if (ip_proto =3D=3D 17 && dst_port =3D=3D 47) return 1; if (ip_proto =3D=3D 17 && dst_port =3D=3D 45) return 1; if (ip_proto =3D=3D 17 && dst_port =3D=3D 42) return 1; if (ip_proto =3D=3D 17 && dst_port =3D=3D 1) return 1; if (ip_proto =3D=3D 17 && dst_port =3D=3D 2) return 1; if (ip_proto =3D=3D 17 && dst_port =3D=3D 3) return 1; return 0; } int firewall2(const uint8_t *restrict data) { const uint16_t dst_port =3D *((const uint16_t *)data + 32); if (dst_port =3D=3D 15) return 1; if (dst_port =3D=3D 23) return 1; if (dst_port =3D=3D 47) return 1; if (dst_port =3D=3D 45) return 1; if (dst_port =3D=3D 42) return 1; if (dst_port =3D=3D 1) return 1; if (dst_port =3D=3D 2) return 1; if (dst_port =3D=3D 3) return 1; return 0; } ``` Compile with -Os. Second function IS NOT minimal, obviously. It's a bug. GCC 12.2 does not ha= ve it.=