public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105216] New: [12 regression] 8% regression for m-queens compared to gcc11 O2
@ 2022-04-11  7:57 crazylht at gmail dot com
  2022-04-11  8:12 ` [Bug tree-optimization/105216] " pinskia at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: crazylht at gmail dot com @ 2022-04-11  7:57 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2023-05-08 12:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11  7:57 [Bug tree-optimization/105216] New: [12 regression] 8% regression for m-queens compared to gcc11 O2 crazylht at gmail dot com
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

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).