public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98365] New: Miss vectoization
@ 2020-12-18  1:13 crazylht at gmail dot com
  2021-01-05  5:09 ` [Bug tree-optimization/98365] Miss vectoization for signed char ifcvt crazylht at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: crazylht at gmail dot com @ 2020-12-18  1:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98365
           Summary: Miss vectoization
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
                CC: hjl.tools at gmail dot com, wwwhhhyyy333 at gmail dot com
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu

cat test.c

int foo (char a[64], char c[64])
{
  int i;
  char cnt=0;
  for (int i = 0;i != 64; i++)
    if (a[i] == c[i])
      cnt++;
  return cnt;
}

with -Ofast -mavx2 gcc failed to vectorize the loop due to 

dump of loop body:
-----------
  # cnt_21 = PHI <cnt_9(7), 0(15)>
  # i_22 = PHI <i_17(7), 0(15)>
  # ivtmp_19 = PHI <ivtmp_18(7), 64(15)>
  _1 = (sizetype) i_22;
  _2 = a_14(D) + _1;
  _3 = *_2;
  _5 = c_15(D) + _1;
  _6 = *_5;
  cnt.1_7 = (unsigned char) cnt_21;
  _8 = cnt.1_7 + 1;
  cnt_16 = (char) _8;
  cnt_9 = _3 == _6 ? cnt_16 : cnt_21;
  i_17 = i_22 + 1;
  ivtmp_18 = ivtmp_19 - 1;
----------

-fopt-info
---------
test.c:5:20: note:   vec_stmt_relevant_p: stmt live but not relevant.
test.c:5:20: note:   mark relevant 1, live 1: cnt_9 = _3 == _6 ? cnt_16 :
cnt_21;
test.c:5:20: note:   init: stmt relevant? i_17 = i_22 + 1;
test.c:5:20: note:   init: stmt relevant? ivtmp_18 = ivtmp_19 - 1;
test.c:5:20: note:   init: stmt relevant? if (ivtmp_18 != 0)
test.c:5:20: note:   worklist: examine stmt: cnt_9 = _3 == _6 ? cnt_16 :
cnt_21;
test.c:5:20: note:   vect_is_simple_use: operand *_2, type of def: internal
test.c:5:20: note:   mark relevant 1, live 0: _3 = *_2;
test.c:5:20: note:   vect_is_simple_use: operand *_5, type of def: internal
test.c:5:20: note:   mark relevant 1, live 0: _6 = *_5;
test.c:5:20: note:   vect_is_simple_use: operand (char) _8, type of def:
internal
test.c:5:20: note:   mark relevant 1, live 0: cnt_16 = (char) _8;
test.c:5:20: note:   vect_is_simple_use: operand cnt_21 = PHI <cnt_9(7),
0(15)>, type of def: unknown
test.c:5:20: missed:   Unsupported pattern.
----------------
Shouldn't cnt_21 = PHI <cnt_9(7), 0(15)>, stmt relevant?


BTW: with extra -fwrapv, gcc successfully vectorized the loop.

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

end of thread, other threads:[~2021-09-17  6:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-18  1:13 [Bug tree-optimization/98365] New: Miss vectoization crazylht at gmail dot com
2021-01-05  5:09 ` [Bug tree-optimization/98365] Miss vectoization for signed char ifcvt crazylht at gmail dot com
2021-01-05  5:40 ` crazylht at gmail dot com
2021-01-05  9:01 ` rguenth at gcc dot gnu.org
2021-01-05  9:57 ` crazylht at gmail dot com
2021-01-05 10:06 ` crazylht at gmail dot com
2021-01-06  9:22 ` crazylht at gmail dot com
2021-06-01  1:59 ` cvs-commit at gcc dot gnu.org
2021-06-01  2:01 ` crazylht at gmail dot com
2021-09-17  6:41 ` pinskia 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).