public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
@ 2023-10-25  8:14 crazylht at gmail dot com
  2023-10-25  9:29 ` [Bug tree-optimization/111972] " crazylht at gmail dot com
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: crazylht at gmail dot com @ 2023-10-25  8:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111972
           Summary: [14 regression] missed vectorzation for bool a = j !=
                    1; j = (long int)a;
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

cat test.c

double
foo() {
  long n3 = 3450000, xtra = 7270;
  long i,ix;
  long j;
  double Check;

  /* Section 3, Conditional jumps */
  j = 0;
  {
    for (ix=0; ix<xtra; ix++)
      {
        for(i=0; i<n3; i++)
          {
            if(j==1)       j = 2;
            else           j = 3;
            if(j>2)        j = 0;
            else           j = 1;
            if(j<1)        j = 1;
            else           j = 0;
          }
      }
  }
  Check = Check + (double)j;
  return Check;
}

The different between gcc 13 dump and gcc14 dump is
GCC13 we have

  <bb 3> [local count: 1063004411]:
  # i_16 = PHI <i_13(8), 0(5)>
  # j_18 = PHI <_7(8), j_21(5)>
  # ivtmp_15 = PHI <ivtmp_6(8), 3450000(5)>
  _7 = j_18 ^ 1;
  i_13 = i_16 + 1;
  ivtmp_6 = ivtmp_15 - 1;
  if (ivtmp_6 != 0)
    goto <bb 8>; [99.00%]
  else
    goto <bb 4>; [1.00%]

GCC14 we have

  <bb 3> [local count: 1063004410]:
  # i_17 = PHI <i_13(8), 0(5)>
  # j_19 = PHI <_14(8), j_22(5)>
  # ivtmp_16 = PHI <ivtmp_15(8), 3450000(5)>
  _9 = j_19 != 1;
  _14 = (long int) _9;
  i_13 = i_17 + 1;
  ivtmp_15 = ivtmp_16 - 1;
  if (ivtmp_15 != 0)
    goto <bb 8>; [98.99%]
  else
    goto <bb 4>; [1.01%]

Vectorizer can handle 

  _7 = j_18 ^ 1; 

but not

  _9 = j_19 != 1;
  _14 = (long int) _9;


../test.C:11:18: note:   vect_is_simple_use: operand j_19 != 1, type of def:
internal
../test.C:11:18: note:   mark relevant 2, live 0: _9 = j_19 != 1;
../test.C:11:18: note:   worklist: examine stmt: _9 = j_19 != 1;
../test.C:11:18: note:   vect_is_simple_use: operand j_19 = PHI <_14(8),
j_22(5)>, type of def: unknown
../test.C:11:18: missed:   Unsupported pattern.
../test.C:15:6: missed:   not vectorized: unsupported use in stmt.
../test.C:11:18: missed:  unexpected pattern.


The difference comes from phiopt2.

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

end of thread, other threads:[~2023-12-12  2:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
2023-10-25  9:29 ` [Bug tree-optimization/111972] " crazylht at gmail dot com
2023-10-25 16:46 ` pinskia at gcc dot gnu.org
2023-10-27  3:48 ` pinskia at gcc dot gnu.org
2023-10-27  3:59 ` pinskia at gcc dot gnu.org
2023-10-27  4:01 ` pinskia at gcc dot gnu.org
2023-10-27  5:08 ` crazylht at gmail dot com
2023-10-27  5:17 ` crazylht at gmail dot com
2023-10-27  6:08 ` pinskia at gcc dot gnu.org
2023-10-27  6:11 ` pinskia at gcc dot gnu.org
2023-10-27 12:38 ` rguenth at gcc dot gnu.org
2023-11-14  1:28 ` cvs-commit at gcc dot gnu.org
2023-11-21  1:00 ` liuhongt at gcc dot gnu.org
2023-11-21  1:12 ` pinskia at gcc dot gnu.org
2023-11-21  2:48 ` liuhongt at gcc dot gnu.org
2023-12-02  6:38 ` pinskia at gcc dot gnu.org
2023-12-04 17:31 ` cvs-commit at gcc dot gnu.org
2023-12-10 20:04 ` pinskia at gcc dot gnu.org
2023-12-11 15:56 ` cvs-commit at gcc dot gnu.org
2023-12-11 15:57 ` pinskia at gcc dot gnu.org
2023-12-12  2:58 ` liuhongt 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).