public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model
@ 2024-06-18  7:19 sjames at gcc dot gnu.org
  2024-06-18  7:20 ` [Bug ipa/115533] " sjames at gcc dot gnu.org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-18  7:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115533
           Summary: [12/13/14/15 regression] flac miscompiled with -O3
                    -march=znver2 -fipa-pta -fno-vect-cost-model
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
            Blocks: 68331
  Target Milestone: ---

Created attachment 58458
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58458&action=edit
replaygain_analysis.i

Hit this when building flac with -O3 -march=znver2 -fipa-pta
-fno-vect-cost-model.

I don't yet have a reduced runtime testcase, working on it though.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68331
[Bug 68331] [meta-bug] fipa-pta issues

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
@ 2024-06-18  7:20 ` sjames at gcc dot gnu.org
  2024-06-18  7:22 ` sjames at gcc dot gnu.org
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-18  7:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
* Adding optimize("O2") or O0 to ReallocateWindowBuffer fixes it (it's a
realloc wrapper)
* We go wrong in analyzeResult and return a bogus result

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
  2024-06-18  7:20 ` [Bug ipa/115533] " sjames at gcc dot gnu.org
@ 2024-06-18  7:22 ` sjames at gcc dot gnu.org
  2024-06-18  7:24 ` sjames at gcc dot gnu.org
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-18  7:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 58459
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58459&action=edit
replaygain_analysis-bad.c.o.xz

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
  2024-06-18  7:20 ` [Bug ipa/115533] " sjames at gcc dot gnu.org
  2024-06-18  7:22 ` sjames at gcc dot gnu.org
@ 2024-06-18  7:24 ` sjames at gcc dot gnu.org
  2024-06-18  7:25 ` sjames at gcc dot gnu.org
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-18  7:24 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #58459|0                           |1
        is obsolete|                            |

--- Comment #3 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 58460
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58460&action=edit
replaygain_analysis-bad.c.o.xz

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-06-18  7:24 ` sjames at gcc dot gnu.org
@ 2024-06-18  7:25 ` sjames at gcc dot gnu.org
  2024-06-18 10:27 ` rguenth at gcc dot gnu.org
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-18  7:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 58461
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58461&action=edit
replaygain_analysis-good.c.o.xz

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-06-18  7:25 ` sjames at gcc dot gnu.org
@ 2024-06-18 10:27 ` rguenth at gcc dot gnu.org
  2024-06-20  9:15 ` rguenth at gcc dot gnu.org
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-18 10:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org
            Version|unknown                     |15.0
   Target Milestone|---                         |12.4

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
I wonder if it's the badly tested interaction between IPA opts and IPA PTA,
I assume -O2 -ftree-vectorize instead of -O3 isn't enough to reproduce?

I don't think that GCC 11 working means anything - IPA PTA doesn't get
much changes, so it's likely just now actually doing sth meaningful (bad)
with IPA PTA info.

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-06-18 10:27 ` rguenth at gcc dot gnu.org
@ 2024-06-20  9:15 ` rguenth at gcc dot gnu.org
  2024-06-20 15:33 ` sjames at gcc dot gnu.org
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-20  9:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-06-20  9:15 ` rguenth at gcc dot gnu.org
@ 2024-06-20 15:33 ` sjames at gcc dot gnu.org
  2024-06-20 15:33 ` sjames at gcc dot gnu.org
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-20 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 58471
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58471&action=edit
test.c

Attached a first cut of a reduction, I still have more to do though.

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-06-20 15:33 ` sjames at gcc dot gnu.org
@ 2024-06-20 15:33 ` sjames at gcc dot gnu.org
  2024-06-20 21:47 ` [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75 sjames at gcc dot gnu.org
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-20 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #5)
> I wonder if it's the badly tested interaction between IPA opts and IPA PTA,
> I assume -O2 -ftree-vectorize instead of -O3 isn't enough to reproduce?
> 

It isn't, surprisingly. It was also really sensitive to vectorisation -- for a
while, novector on one loop was enough, but it stopped being after reduction.
We'll see..

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2024-06-20 15:33 ` sjames at gcc dot gnu.org
@ 2024-06-20 21:47 ` sjames at gcc dot gnu.org
  2024-06-21 16:50 ` sjames at gcc dot gnu.org
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-20 21:47 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |
            Summary|[12/13/14/15 regression]    |[12/13/14/15 regression]
                   |flac miscompiled with -O3   |flac miscompiled with -O3
                   |-march=znver2 -fipa-pta     |-march=znver2 -fipa-pta
                   |-fno-vect-cost-model        |-fno-vect-cost-model since
                   |                            |r12-3893-g6390c5047adb75

--- Comment #9 from Sam James <sjames at gcc dot gnu.org> ---
r12-3893-g6390c5047adb75

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2024-06-20 21:47 ` [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75 sjames at gcc dot gnu.org
@ 2024-06-21 16:50 ` sjames at gcc dot gnu.org
  2024-06-21 16:54 ` sjames at gcc dot gnu.org
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-21 16:50 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #58471|0                           |1
        is obsolete|                            |

--- Comment #10 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 58479
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58479&action=edit
test.c

Another checkpoint

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2024-06-21 16:50 ` sjames at gcc dot gnu.org
@ 2024-06-21 16:54 ` sjames at gcc dot gnu.org
  2024-06-21 17:03 ` sjames at gcc dot gnu.org
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-21 16:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Sam James from comment #10)
> Created attachment 58479 [details]
> test.c
> 
> Another checkpoint

Ugh, lout became uninitialised. I'll try again.

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2024-06-21 16:54 ` sjames at gcc dot gnu.org
@ 2024-06-21 17:03 ` sjames at gcc dot gnu.org
  2024-06-21 19:08 ` sjames at gcc dot gnu.org
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-21 17:03 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #58479|0                           |1
        is obsolete|                            |

--- Comment #12 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 58480
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58480&action=edit
test.c

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (11 preceding siblings ...)
  2024-06-21 17:03 ` sjames at gcc dot gnu.org
@ 2024-06-21 19:08 ` sjames at gcc dot gnu.org
  2024-06-21 19:10 ` sjames at gcc dot gnu.org
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-21 19:08 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #58480|0                           |1
        is obsolete|                            |

--- Comment #13 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 58481
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58481&action=edit
test.c

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (12 preceding siblings ...)
  2024-06-21 19:08 ` sjames at gcc dot gnu.org
@ 2024-06-21 19:10 ` sjames at gcc dot gnu.org
  2024-06-21 20:16 ` sjames at gcc dot gnu.org
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-21 19:10 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

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

--- Comment #14 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Sam James from comment #13)
> Created attachment 58481 [details]
> test.c

If I do:
```
-       if(k == 715635309.750000)
+
+       if(k != 715635440.437500)
                __builtin_abort();
```

it starts to fail with gcc-11 -O0, which makes me worried I'm misunderstanding
some FP issue here.

$ gcc-15 test.c -o test -O3 -march=znver2 -fno-vect-cost-model -fipa-pta -o
test && ./test
Aborted (core dumped)

pinskia, could you take a look? I don't think I can do much more without hints
at least

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (13 preceding siblings ...)
  2024-06-21 19:10 ` sjames at gcc dot gnu.org
@ 2024-06-21 20:16 ` sjames at gcc dot gnu.org
  2024-06-21 20:51 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-21 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #58481|0                           |1
        is obsolete|                            |

--- Comment #15 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 58484
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58484&action=edit
test.c

iains & pinskia helped, now using fabs(...) < e (error is large though because
of all the accumulated multiplication error terms..)

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (14 preceding siblings ...)
  2024-06-21 20:16 ` sjames at gcc dot gnu.org
@ 2024-06-21 20:51 ` pinskia at gcc dot gnu.org
  2024-06-23  2:20 ` sjames at gcc dot gnu.org
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-21 20:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-06-21

--- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So I am not sure if the reduced testcase is an issue.
You get the "bad" value if you use  -ffp-contract=off too or -O0.

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (15 preceding siblings ...)
  2024-06-21 20:51 ` pinskia at gcc dot gnu.org
@ 2024-06-23  2:20 ` sjames at gcc dot gnu.org
  2024-06-24  7:12 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-23  2:20 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #58484|0                           |1
        is obsolete|                            |

--- Comment #17 from Sam James <sjames at gcc dot gnu.org> ---
Created attachment 58492
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58492&action=edit
test.c

This seems to be the best I can get out of it.

The original (upstream) code passes with -ffp-contract=off, so if this is
invalid, no feelings will be hurt.

I'm going to keep looking for other IPA miscompilations when I have spare
cycles.

This reduced testcase passes with gcc 11 with -O3 -march=znver2
-fno-vect-cost-model -fipa-pta -ffp-contract=fast, but fails with 12+ with the
same options. The relationship with the vectoriser here makes it hard to
understand (in addition to my inexperience with FP so far).

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (16 preceding siblings ...)
  2024-06-23  2:20 ` sjames at gcc dot gnu.org
@ 2024-06-24  7:12 ` rguenth at gcc dot gnu.org
  2024-06-24 12:06 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-24  7:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from Richard Biener <rguenth at gcc dot gnu.org> ---
With -fipa-pta we add

+t.c:28:24: optimized: loop with 5 iterations completely unrolled (header
execution count 43151276)
+t.c:30:16: optimized: loop turned into non-loop; it never loops
...
-t.c:28:24: optimized: loop with 4 iterations completely unrolled (header
execution count 107374186)
+t.c:36:11: optimized: basic block part vectorized using 32 byte vectors
+t.c:36:11: optimized: basic block part vectorized using 8 byte vectors

the testcase still breaks when adding -fdisable-tree-cunroll
-fno-tree-loop-vectorize, then the only change is

+t.c:36:11: optimized: basic block part vectorized using 16 byte vectors
+t.c:36:11: optimized: basic block part vectorized using 8 byte vectors

when failing we have

t.c:36:11: missed:   can't determine dependence between *_65 and *ad_68
t.c:36:11: note:  removing SLP instance operations starting from: *_65 = _66;

w/o IPA PTA we have

  # PT = nonlocal escaped null
  _65 = a.6_13 + _64;
  # PT = nonlocal escaped
  ad_68 = ad_205 + 4;

with IPA PTA

  # PT = null { D.4063 D.4066 } (nonlocal, escaped, escaped heap)
  _65 = a.6_13 + _64;
  # PT = { D.4062 D.4065 } (nonlocal, escaped, escaped heap)
  ad_68 = ad_205 + 4;

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (17 preceding siblings ...)
  2024-06-24  7:12 ` rguenth at gcc dot gnu.org
@ 2024-06-24 12:06 ` rguenth at gcc dot gnu.org
  2024-06-24 19:15 ` amonakov at gcc dot gnu.org
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-24 12:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note I can't exactly see something wrong.  -ffp-contract=fast triggers
BB vectorization in 'ac', placing __restrict on 'ae' like

void ac(float *ad, float * __restrict ae, size_t t, float *a, float *b, size_t
af,  
        uint32_t) {
...

no longer requires -fipa-pta to reproduce the issue.  I _think_ this
__restrict is OK (allocation is unnecessarily obfuscated in the test).

Alex fixed -ffp-contract=on but =fast is still default it seems.

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (18 preceding siblings ...)
  2024-06-24 12:06 ` rguenth at gcc dot gnu.org
@ 2024-06-24 19:15 ` amonakov at gcc dot gnu.org
  2024-06-24 19:32 ` sjames at gcc dot gnu.org
  2024-06-24 20:44 ` amonakov at gcc dot gnu.org
  21 siblings, 0 replies; 23+ messages in thread
From: amonakov at gcc dot gnu.org @ 2024-06-24 19:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Sam, can you provide more context? It seems there is no downstream bugreport?
How does the alleged miscompilation manifest?

Note that effects of interplay of fp-contract=fast and vectorization can be
pretty epic, like the completely wrong strong green tint of blur filter in
RawTherapee (see screenshot at
https://github.com/Beep6581/RawTherapee/issues/6384 which was minimized and
reported as our PR 106902).

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (19 preceding siblings ...)
  2024-06-24 19:15 ` amonakov at gcc dot gnu.org
@ 2024-06-24 19:32 ` sjames at gcc dot gnu.org
  2024-06-24 20:44 ` amonakov at gcc dot gnu.org
  21 siblings, 0 replies; 23+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-24 19:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #21 from Sam James <sjames at gcc dot gnu.org> ---
It fell out when building media-libs/flac's tests after I threw in -fipa-pta in
a test container for a single run where I check trunk for regressions.

Building flac itself, I can reproduce it with:
```
export CFLAGS="-O3 -ggdb3 -march=znver2 -fipa-pta -fno-vect-cost-model"
export CXXFLAGS="-O3 -ggdb3 -march=znver2 -fipa-pta -fno-vect-cost-model"
export LDFLAGS="-Wl,-O1"
cmake -B build-bad -DINSTALL_MANPAGES=OFF -DCMAKE_BUILD_TYPE=Debug
-DBUILD_SHARED_LIBS=ON
make -C build-bad
ctest --test-dir build-bad -R generate_streams
ctest --test-dir build-bad --tests-information -o -R replaygain
--output-on-failure
```

(*BUILD_TYPE and *SHARED_LIBS can be emitted if desired - was just there for
debugging while I went as wanted assertions, and you can just run make -C
build-bad and then make -C build-bad check).

It fails like:
```
[...]
replaygain.flac: 64.820000 1.000000 64.820000 1.000000
CPU info (x86-64):
  CMOV ....... Y
  MMX ........ Y
  SSE ........ Y
  SSE2 ....... Y
  SSE3 ....... Y
  SSSE3 ...... Y
  SSE41 ...... Y
  SSE42 ...... Y
  AVX ........ Y
  FMA ........ Y
  AVX2 ....... Y
  BMI2 ....... Y
  AVX OS sup . Y
CPU info (x86-64):
  CMOV ....... Y
  MMX ........ Y
  SSE ........ Y
  SSE2 ....... Y
  SSE3 ....... Y
  SSSE3 ...... Y
  SSE41 ...... Y
  SSE42 ...... Y
  AVX ........ Y
  FMA ........ Y
  AVX2 ....... Y
  BMI2 ....... Y
  AVX OS sup . Y
ERROR, Expected -12.73 db instead of comment[1]: REPLAYGAIN_TRACK_GAIN=+64.82
dB


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.09 sec

The following tests FAILED:
          7 - replaygain (Failed)
Errors while running CTest
```

(Will check out your link now, thanks!)

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

* [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75
  2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (20 preceding siblings ...)
  2024-06-24 19:32 ` sjames at gcc dot gnu.org
@ 2024-06-24 20:44 ` amonakov at gcc dot gnu.org
  21 siblings, 0 replies; 23+ messages in thread
From: amonakov at gcc dot gnu.org @ 2024-06-24 20:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #22 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Similar to the RawTherapee issue, SLP opportunities are created by predcom, so
either -fno-predictive-commoning or -fno-tree-slp-vectorize avoids numerical
runaway on the small testcase.

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

end of thread, other threads:[~2024-06-24 20:44 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-18  7:19 [Bug ipa/115533] New: [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model sjames at gcc dot gnu.org
2024-06-18  7:20 ` [Bug ipa/115533] " sjames at gcc dot gnu.org
2024-06-18  7:22 ` sjames at gcc dot gnu.org
2024-06-18  7:24 ` sjames at gcc dot gnu.org
2024-06-18  7:25 ` sjames at gcc dot gnu.org
2024-06-18 10:27 ` rguenth at gcc dot gnu.org
2024-06-20  9:15 ` rguenth at gcc dot gnu.org
2024-06-20 15:33 ` sjames at gcc dot gnu.org
2024-06-20 15:33 ` sjames at gcc dot gnu.org
2024-06-20 21:47 ` [Bug ipa/115533] [12/13/14/15 regression] flac miscompiled with -O3 -march=znver2 -fipa-pta -fno-vect-cost-model since r12-3893-g6390c5047adb75 sjames at gcc dot gnu.org
2024-06-21 16:50 ` sjames at gcc dot gnu.org
2024-06-21 16:54 ` sjames at gcc dot gnu.org
2024-06-21 17:03 ` sjames at gcc dot gnu.org
2024-06-21 19:08 ` sjames at gcc dot gnu.org
2024-06-21 19:10 ` sjames at gcc dot gnu.org
2024-06-21 20:16 ` sjames at gcc dot gnu.org
2024-06-21 20:51 ` pinskia at gcc dot gnu.org
2024-06-23  2:20 ` sjames at gcc dot gnu.org
2024-06-24  7:12 ` rguenth at gcc dot gnu.org
2024-06-24 12:06 ` rguenth at gcc dot gnu.org
2024-06-24 19:15 ` amonakov at gcc dot gnu.org
2024-06-24 19:32 ` sjames at gcc dot gnu.org
2024-06-24 20:44 ` amonakov 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).