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 middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
Date: Wed, 25 Oct 2023 08:14:43 +0000	[thread overview]
Message-ID: <bug-111972-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2023-10-25  8:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25  8:14 crazylht at gmail dot com [this message]
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

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