From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A45B63858407; Mon, 11 Apr 2022 07:57:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A45B63858407 From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105216] New: [12 regression] 8% regression for m-queens compared to gcc11 O2 Date: Mon, 11 Apr 2022 07:57:34 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: crazylht 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 attachments.created 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2022 07:57:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105216 Bug ID: 105216 Summary: [12 regression] 8% regression for m-queens compared to gcc11 O2 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- Created attachment 52778 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52778&action=3Dedit g++ -O2 main.c;./a.out Regression happens in pass_pre while (posib !=3D UINT_FAST32_MAX) { // The standard trick for getting the rightmost bit in the mask uint_fast32_t bit =3D ~posib & (posib + 1); posib ^=3D bit; // Eliminate the tried possibility. uint_fast32_t new_diagl =3D (bit << 1) | diagl_shifted; uint_fast32_t new_diagr =3D (bit >> 1) | diagr_shifted; bit |=3D cols[d]; uint_fast32_t new_posib =3D (bit | new_diagl | new_diagr); if (new_posib !=3D UINT_FAST32_MAX) { uint_fast32_t lookahead1 =3D (bit | (new_diagl << (LOOKAHEAD - = 2)) | (new_diagr >> (LOOKAHEAD - 2))); uint_fast32_t lookahead2 =3D (bit | (new_diagl << (LOOKAHEAD - = 1)) | (new_diagr >> (LOOKAHEAD - 1))); uint_fast32_t allowed2 =3D l_rest > (int8_t)0; if(allowed2 && ((lookahead2 =3D=3D UINT_FAST32_MAX) || (lookahe= ad1 =3D=3D UINT_FAST32_MAX))) { continue; } if(l_rest =3D=3D (STORE_LEVEL + 1)) { start_level4[level4_cnt][0] =3D bit; // cols start_level4[level4_cnt][1] =3D new_diagl; // diagl start_level4[level4_cnt][2] =3D new_diagr; // diagr level4_cnt++; continue; } l_rest--; // The next two lines save stack depth + backtrack operations // when we passed the last possibility in a row. // Go lower in the stack, avoid branching by writing above the current // position posibs[d] =3D posib; d +=3D posib !=3D UINT_FAST32_MAX; // avoid branching with this t= rick posib =3D new_posib; // make values current cols[d] =3D bit; diagl[d] =3D new_diagl; diagr[d] =3D new_diagr; rest[d] =3D l_rest; diagl_shifted =3D new_diagl << 1; diagr_shifted =3D new_diagr >> 1; } } d--; posib =3D posibs[d]; // backtrack ... } For bit |=3D cols[d]; cols[d] is loop invariant if loop latch from *continu= e*, GCC11 catches it, GCC12 not.=