public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/95084] New: code sinking prevents if-conversion
@ 2020-05-12 13:46 rguenth at gcc dot gnu.org
  2022-01-31 15:24 ` [Bug tree-optimization/95084] [11/12 Regression] " rsandifo at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-12 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95084
           Summary: code sinking prevents if-conversion
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

There's a pass ordering issue between the sink pass and tree-if-conv, if
conversion for vectorization.  When sink sinks a possibly trapping operation
to a place that is only conditionally executed if-conversion fails which
results in failed vectorization.  This can be seen with
https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545588.html applied
for gcc.dg/vect/pr56541.c (and it's ifcvt counterpart
gcc.dg/tree-ssa/ifc-pr56541.c).  But I've also seen this in other context.

Here

  iftmp.2_17 = rR_19 < rL_20 ? rR_19 : rL_20;
  iftmp.3_3 = rR_19 < rL_20 ? rL_20 : rR_19;
  if (iftmp.3_3 > 0.0)
    goto <bb 5>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 4> :

  <bb 5> :
  # iftmp.4_14 = PHI <iftmp.2_17(3), 1.5e+2(4)>
  if (iftmp.4_14 > 0.0)

becomes

  iftmp.3_3 = rR_17 < rL_18 ? rL_18 : rR_17;
  if (iftmp.3_3 > 0.0)
    goto <bb 4>; [59.00%]
  else
    goto <bb 9>; [41.00%]

  <bb 9> [local count: 435831803]:
  goto <bb 6>; [100.00%]

  <bb 4> [local count: 627172605]:
  iftmp.2_15 = rR_17 < rL_18 ? rR_17 : rL_18;
  if (iftmp.2_15 > 0.0)

and the now conditionally executed FP comparison can trap.

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

* [Bug tree-optimization/95084] [11/12 Regression] code sinking prevents if-conversion
  2020-05-12 13:46 [Bug tree-optimization/95084] New: code sinking prevents if-conversion rguenth at gcc dot gnu.org
@ 2022-01-31 15:24 ` rsandifo at gcc dot gnu.org
  2022-01-31 21:02 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2022-01-31 15:24 UTC (permalink / raw)
  To: gcc-bugs

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

rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|code sinking prevents       |[11/12 Regression] code
                   |if-conversion               |sinking prevents
                   |                            |if-conversion
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-01-31
             Status|UNCONFIRMED                 |NEW
                 CC|                            |rsandifo at gcc dot gnu.org

--- Comment #1 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Yeah.  I'm seeing this as a GCC 11/12 regression on:

float f(float *x, float *y) {
  float res = 0;
  for (int i = 0; i < 100; ++i) {
    float next = __builtin_sqrtf (y[i]);
    res += x[i] < 100 ? x[i] : next;
  }
  return res;
}

which is cut down from HACCmk.  Previously we could vectorise
the loop for Advanced SIMD at -Ofast, whereas now we require
-Ofast -fno-tree-sink.  (SVE can vectorise it both ways due
to predicated loads.)

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

* [Bug tree-optimization/95084] [11/12 Regression] code sinking prevents if-conversion
  2020-05-12 13:46 [Bug tree-optimization/95084] New: code sinking prevents if-conversion rguenth at gcc dot gnu.org
  2022-01-31 15:24 ` [Bug tree-optimization/95084] [11/12 Regression] " rsandifo at gcc dot gnu.org
@ 2022-01-31 21:02 ` pinskia at gcc dot gnu.org
  2022-02-01  7:31 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-31 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.3
             Blocks|                            |26163


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26163
[Bug 26163] [meta-bug] missed optimization in SPEC (2k17, 2k and 2k6 and 95)

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

* [Bug tree-optimization/95084] [11/12 Regression] code sinking prevents if-conversion
  2020-05-12 13:46 [Bug tree-optimization/95084] New: code sinking prevents if-conversion rguenth at gcc dot gnu.org
  2022-01-31 15:24 ` [Bug tree-optimization/95084] [11/12 Regression] " rsandifo at gcc dot gnu.org
  2022-01-31 21:02 ` pinskia at gcc dot gnu.org
@ 2022-02-01  7:31 ` rguenth at gcc dot gnu.org
  2022-04-21  7:47 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-01  7:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note the issue is older but there are some cases where sink didn't do its job
that have been fixed meanwhile.

For GCC 12 we have an additional (albeit quite late) sinking pass, so one
option might be to tame down early sinking for possibly trapping operations in
loops that look like they could be vectorized (similar how we tame PRE).

I think the only loop pass affected by not sinking might be unswitching which
could get less favorable costs due to the need to duplicate the not sunk stmts.

At least I cannot think of a way to preserve the conditional non-trappingness
on the ref after sinking it.

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

* [Bug tree-optimization/95084] [11/12 Regression] code sinking prevents if-conversion
  2020-05-12 13:46 [Bug tree-optimization/95084] New: code sinking prevents if-conversion rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-02-01  7:31 ` rguenth at gcc dot gnu.org
@ 2022-04-21  7:47 ` rguenth at gcc dot gnu.org
  2022-07-06 21:17 ` [Bug tree-optimization/95084] [11/12/13 " pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21  7:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.3                        |11.4

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.

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

* [Bug tree-optimization/95084] [11/12/13 Regression] code sinking prevents if-conversion
  2020-05-12 13:46 [Bug tree-optimization/95084] New: code sinking prevents if-conversion rguenth at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-04-21  7:47 ` rguenth at gcc dot gnu.org
@ 2022-07-06 21:17 ` pinskia at gcc dot gnu.org
  2023-05-29 10:02 ` [Bug tree-optimization/95084] [11/12/13/14 " jakub at gcc dot gnu.org
  2023-08-04 17:26 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-06 21:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tnfchris at gcc dot gnu.org

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 106217 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/95084] [11/12/13/14 Regression] code sinking prevents if-conversion
  2020-05-12 13:46 [Bug tree-optimization/95084] New: code sinking prevents if-conversion rguenth at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-07-06 21:17 ` [Bug tree-optimization/95084] [11/12/13 " pinskia at gcc dot gnu.org
@ 2023-05-29 10:02 ` jakub at gcc dot gnu.org
  2023-08-04 17:26 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:02 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.4                        |11.5

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.

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

* [Bug tree-optimization/95084] [11/12/13/14 Regression] code sinking prevents if-conversion
  2020-05-12 13:46 [Bug tree-optimization/95084] New: code sinking prevents if-conversion rguenth at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-05-29 10:02 ` [Bug tree-optimization/95084] [11/12/13/14 " jakub at gcc dot gnu.org
@ 2023-08-04 17:26 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-04 17:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This was fixed by the patch which fixed PR 92335 and since that is still open
as a regression like this one I am going to close this one as a dup of bug
92335 and they are exactly the same issue even.

*** This bug has been marked as a duplicate of bug 92335 ***

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

end of thread, other threads:[~2023-08-04 17:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 13:46 [Bug tree-optimization/95084] New: code sinking prevents if-conversion rguenth at gcc dot gnu.org
2022-01-31 15:24 ` [Bug tree-optimization/95084] [11/12 Regression] " rsandifo at gcc dot gnu.org
2022-01-31 21:02 ` pinskia at gcc dot gnu.org
2022-02-01  7:31 ` rguenth at gcc dot gnu.org
2022-04-21  7:47 ` rguenth at gcc dot gnu.org
2022-07-06 21:17 ` [Bug tree-optimization/95084] [11/12/13 " pinskia at gcc dot gnu.org
2023-05-29 10:02 ` [Bug tree-optimization/95084] [11/12/13/14 " jakub at gcc dot gnu.org
2023-08-04 17:26 ` 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).