public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/107690] New: Regression in ranges::transform vectorization
@ 2022-11-14 19:53 Mark_B53 at yahoo dot com
  2022-11-14 19:59 ` [Bug rtl-optimization/107690] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Mark_B53 at yahoo dot com @ 2022-11-14 19:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107690
           Summary: Regression in ranges::transform vectorization
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Mark_B53 at yahoo dot com
  Target Milestone: ---

GCC 11.3 vectorizes the following code.  GCC 12.2 fails to vectorize.

#include <algorithm>
#include <array>
#include <ranges>

std::array<int, 16> foo(std::array<int, 16> u, std::array<int, 16> const &v)
{
    std::ranges::transform(u, v, u.begin(), std::plus<int>());
    return u;
}

https://godbolt.org/z/KnhdPs6G3

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

* [Bug rtl-optimization/107690] Regression in ranges::transform vectorization
  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 ` pinskia at gcc dot gnu.org
  2022-11-14 20:08 ` [Bug rtl-optimization/107690] [12/13 Regression] vectorization fails for std::ranges::transform due to IR changes pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-14 19:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-std=c++20 -O3

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

* [Bug rtl-optimization/107690] [12/13 Regression] vectorization fails for std::ranges::transform due to IR changes
  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
  2022-11-16 13:17 ` [Bug tree-optimization/107690] " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-14 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

* [Bug tree-optimization/107690] [12/13 Regression] vectorization fails for std::ranges::transform due to IR changes
  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 ` [Bug rtl-optimization/107690] [12/13 Regression] vectorization fails for std::ranges::transform due to IR changes pinskia at gcc dot gnu.org
@ 2022-11-16 13:17 ` 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
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-11-16 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org
           Priority|P3                          |P2

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

* [Bug tree-optimization/107690] [12/13 Regression] vectorization fails for std::ranges::transform due to IR changes since r12-3903-g0288527f47cec669
  2022-11-14 19:53 [Bug rtl-optimization/107690] New: Regression in ranges::transform vectorization Mark_B53 at yahoo dot com
                   ` (2 preceding siblings ...)
  2022-11-16 13:17 ` [Bug tree-optimization/107690] " rguenth at gcc dot gnu.org
@ 2022-11-21 10:05 ` marxin at gcc dot gnu.org
  2023-05-08 12:25 ` [Bug tree-optimization/107690] [12/13/14 " rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-11-21 10:05 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12/13 Regression]          |[12/13 Regression]
                   |vectorization fails for     |vectorization fails for
                   |std::ranges::transform due  |std::ranges::transform due
                   |to IR changes               |to IR changes since
                   |                            |r12-3903-g0288527f47cec669
           Keywords|needs-bisection             |
                 CC|                            |aldyh at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-3903-g0288527f47cec669.

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

* [Bug tree-optimization/107690] [12/13/14 Regression] vectorization fails for std::ranges::transform due to IR changes since r12-3903-g0288527f47cec669
  2022-11-14 19:53 [Bug rtl-optimization/107690] New: Regression in ranges::transform vectorization Mark_B53 at yahoo dot com
                   ` (3 preceding siblings ...)
  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 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-08 12:25 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.3                        |12.4

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 12.3 is being released, retargeting bugs to GCC 12.4.

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [Bug rtl-optimization/107690] [12/13 Regression] vectorization fails for std::ranges::transform due to IR changes pinskia at gcc dot gnu.org
2022-11-16 13:17 ` [Bug tree-optimization/107690] " 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

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