public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "crazylht at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-105216-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            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=52778&action=edit
g++ -O2 main.c;./a.out

Regression happens in pass_pre

      while (posib != UINT_FAST32_MAX) {
        // The standard trick for getting the rightmost bit in the mask
        uint_fast32_t bit = ~posib & (posib + 1);
        posib ^= bit; // Eliminate the tried possibility.
        uint_fast32_t new_diagl = (bit << 1) | diagl_shifted;
        uint_fast32_t new_diagr = (bit >> 1) | diagr_shifted;
        bit |= cols[d];
        uint_fast32_t new_posib = (bit | new_diagl | new_diagr);

        if (new_posib != UINT_FAST32_MAX) {
            uint_fast32_t lookahead1 = (bit | (new_diagl << (LOOKAHEAD - 2)) |
(new_diagr >> (LOOKAHEAD - 2)));
            uint_fast32_t lookahead2 = (bit | (new_diagl << (LOOKAHEAD - 1)) |
(new_diagr >> (LOOKAHEAD - 1)));
            uint_fast32_t allowed2 = l_rest > (int8_t)0;

            if(allowed2 && ((lookahead2 == UINT_FAST32_MAX) || (lookahead1 ==
UINT_FAST32_MAX))) {
                continue;
            }


          if(l_rest == (STORE_LEVEL + 1)) {
            start_level4[level4_cnt][0] = bit;   // cols
            start_level4[level4_cnt][1] = new_diagl; // diagl
            start_level4[level4_cnt][2] = 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] = posib;
          d += posib != UINT_FAST32_MAX; // avoid branching with this trick
          posib = new_posib;


          // make values current
          cols[d] = bit;
          diagl[d] = new_diagl;
          diagr[d] = new_diagr;
          rest[d] = l_rest;
          diagl_shifted = new_diagl << 1;
          diagr_shifted = new_diagr >> 1;
        }
      }
      d--;
      posib = posibs[d]; // backtrack ...
    }

For bit |= cols[d]; cols[d] is loop invariant if loop latch from *continue*,
GCC11 catches it, GCC12 not.

             reply	other threads:[~2022-04-11  7:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11  7:57 crazylht at gmail dot com [this message]
2022-04-11  8:12 ` [Bug tree-optimization/105216] " pinskia at gcc dot gnu.org
2022-04-11  8:18 ` rguenth at gcc dot gnu.org
2022-04-11  8:35 ` crazylht at gmail dot com
2022-04-11  8:38 ` rguenth at gcc dot gnu.org
2022-04-11 10:08 ` [Bug tree-optimization/105216] [12 regression] 8% regression for m-queens compared to gcc11 O2 on CLX crazylht at gmail dot com
2022-04-11 10:14 ` crazylht at gmail dot com
2022-04-11 10:24 ` rguenther at suse dot de
2022-04-11 12:07 ` crazylht at gmail dot com
2022-04-11 12:13 ` crazylht at gmail dot com
2022-04-12  3:11 ` crazylht at gmail dot com
2022-04-12  6:15 ` crazylht at gmail dot com
2022-04-26 15:08 ` [Bug tree-optimization/105216] [12 regression] 8% regression for m-queens compared to gcc11 O2 on CLX. since r12-3876-g4a960d548b7d7d94 marxin at gcc dot gnu.org
2022-05-06  8:33 ` [Bug tree-optimization/105216] [12/13 " jakub at gcc dot gnu.org
2022-07-26 12:34 ` rguenth at gcc dot gnu.org
2022-12-31  4:30 ` pinskia at gcc dot gnu.org
2023-01-03  1:01 ` crazylht at gmail dot com
2023-05-08 12:24 ` [Bug tree-optimization/105216] [12/13/14 " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105216-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).