From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F26633858D28; Thu, 25 May 2023 00:40:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F26633858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684975213; bh=rmAgIuQiXzYSLOpiBuA0g243z+ul6dOQvedY/Ns78Kw=; h=From:To:Subject:Date:From; b=UqNGF9QabNjJvD7n/lKfvUvdkhZ1NBImu+0ps+Sjx2m+qRN9dgKlOLSmfaNicDfVA 7LkSkpPu2ki3vCNgZ4zZf0LJwsOBvklqjVa2qXEFo/n+zSh02quluBDkJYeUzy1/q1 X9pZkeTP4BkURBYYL1OEBNLsBzv53f57CIAaqvbU= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109960] New: [10/11/12/13/14 Regression] missing combining of `(a&1) != 0 || (a&2)!=0` into `(a&3)!=0` Date: Thu, 25 May 2023 00:40:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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 keywords 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=3D109960 Bug ID: 109960 Summary: [10/11/12/13/14 Regression] missing combining of `(a&1) !=3D 0 || (a&2)!=3D0` into `(a&3)!=3D0` 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.=