public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/107690] [12/13 Regression] vectorization fails for std::ranges::transform due to IR changes
Date: Mon, 14 Nov 2022 20:08:57 +0000	[thread overview]
Message-ID: <bug-107690-4-1r92xNirIP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107690-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.3
            Summary|Regression in               |[12/13 Regression]
                   |ranges::transform           |vectorization fails for
                   |vectorization               |std::ranges::transform due
                   |                            |to IR changes
   Last reconfirmed|                            |2022-11-14
             Blocks|                            |53947
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization,
                   |                            |needs-bisection

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
In GCC 12 before the vectorizer we have:
  <bb 2> [local count: 114863530]:
  _4 = v_2(D) + 64;
  _5 = &v_2(D)->_M_elems;
  if (_4 != _5)
    goto <bb 5>; [89.30%]
  else
    goto <bb 4>; [10.70%]

  <bb 5> [local count: 102576004]:

  <bb 3> [local count: 958878296]:
  # __first1_24 = PHI <_11(6), &u._M_elems(5)>
  # __first2_25 = PHI <_12(6), _5(5)>
  _7 = MEM[(const int &)__first1_24];
  _9 = *__first2_25;
  _10 = _7 + _9;
  *__first1_24 = _10;
  _11 = __first1_24 + 4;
  _12 = __first2_25 + 4;
  _15 = _4 != _12;
  _18 = &MEM <struct array> [(void *)&u + 64B] != _11;
  _16 = _15 & _18;
  if (_16 != 0)
    goto <bb 6>; [89.30%]
  else
    goto <bb 4>; [10.70%]

  <bb 6> [local count: 856302294]:
  goto <bb 3>; [100.00%]


But with GCC 11 we had:

  <bb 2> [local count: 114863530]:
  _2 = &MEM <const int[16]> [(void *)v_3(D) + 64B];
  _5 = &v_3(D)->_M_elems;
  goto <bb 5>; [100.00%]

  <bb 4> [local count: 114863532]:
  <retval> = u;
  return <retval>;

  <bb 6> [local count: 899822495]:

  <bb 5> [local count: 1014686026]:
  # __first1_22 = PHI <_11(6), &u._M_elems(2)>
  # __first2_23 = PHI <_12(6), _5(2)>
  # ivtmp_24 = PHI <ivtmp_13(6), 16(2)>
  _7 = MEM[(const int &)__first1_22];
  _9 = *__first2_23;
  _10 = _7 + _9;
  *__first1_22 = _10;
  _11 = __first1_22 + 4;
  _12 = __first2_23 + 4;
  ivtmp_13 = ivtmp_24 - 1;
  if (ivtmp_13 != 0)
    goto <bb 6>; [93.84%]
  else
    goto <bb 4>; [6.16%]

There is a missing optimization before the vectorizer which is causing the
vectorizer not to know how many iterations the loop is for.

I am tries tracking down which passes the IR changes to make things worse but I
didn't do a good at doing that.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

  parent reply	other threads:[~2022-11-14 20:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 19:53 [Bug rtl-optimization/107690] New: Regression in ranges::transform vectorization Mark_B53 at yahoo dot com
2022-11-14 19:59 ` [Bug rtl-optimization/107690] " pinskia at gcc dot gnu.org
2022-11-14 20:08 ` pinskia at gcc dot gnu.org [this message]
2022-11-16 13:17 ` [Bug tree-optimization/107690] [12/13 Regression] vectorization fails for std::ranges::transform due to IR changes rguenth at gcc dot gnu.org
2022-11-21 10:05 ` [Bug tree-optimization/107690] [12/13 Regression] vectorization fails for std::ranges::transform due to IR changes since r12-3903-g0288527f47cec669 marxin at gcc dot gnu.org
2023-05-08 12:25 ` [Bug tree-optimization/107690] [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-107690-4-1r92xNirIP@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).