public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/54896] New: Some optimization slowness with GCC 4.7.2
@ 2012-10-10 21:28 tammy at Cadence dot COM
  2012-10-10 22:04 ` [Bug c/54896] " steven at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: tammy at Cadence dot COM @ 2012-10-10 21:28 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

             Bug #: 54896
           Summary: Some optimization slowness with GCC 4.7.2
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: tammy@Cadence.COM


We have some code which consist from switch with many cases and non-random
memory writes. Look like there is nothing to optimize at all, but compiling
optimized version takes long time.

Attach is the code to generate source code to reproduce this problem,
generate_bigdata.c.


$ gcc generate_bigdata.c  
$ ./a.out 
  (This step will generate the testcase, BigData.c.)
$ time /gcc-4.7.2/bin/gcc -m32 BigData.c -c -o BigData.o
1.504u 0.077s 0:01.61 97.5%     0+0k 320+10024io 0pf+0w
$ time /gcc-4.7.2/bin/gcc -m32 -O1 BigData.c -c -o BigData.o
50.438u 0.191s 0:50.67 99.9%    0+0k 256+10024io 0pf+0w
$ time /gcc-4.7.2/bin/gcc -m32 -O4 BigData.c -c -o BigData.o
111.710u 3.977s 1:55.73 99.9%   0+0k 1024+9384io 0pf+0w

We tried with gcc44, the optimization takes long also but not as bad as 472.

Sure, code refactoring is best solution and disabling optimization for
particular file is good enough, but will be good idea to improve GCC too.


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

* [Bug c/54896] Some optimization slowness with GCC 4.7.2
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
@ 2012-10-10 22:04 ` steven at gcc dot gnu.org
  2012-10-10 22:09 ` tammy at Cadence dot COM
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: steven at gcc dot gnu.org @ 2012-10-10 22:04 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2012-10-10
                 CC|                            |steven at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Steven Bosscher <steven at gcc dot gnu.org> 2012-10-10 22:04:29 UTC ---
Can you please attach the test case?


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

* [Bug c/54896] Some optimization slowness with GCC 4.7.2
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
  2012-10-10 22:04 ` [Bug c/54896] " steven at gcc dot gnu.org
@ 2012-10-10 22:09 ` tammy at Cadence dot COM
  2012-10-10 22:51 ` [Bug c/54896] [4.7/4.8 Regression] " steven at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: tammy at Cadence dot COM @ 2012-10-10 22:09 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

--- Comment #2 from Tammy Hsu <tammy at Cadence dot COM> 2012-10-10 22:09:04 UTC ---
Created attachment 28416
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28416
This can be used to generate BigData.c


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

* [Bug c/54896] [4.7/4.8 Regression] Some optimization slowness with GCC 4.7.2
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
  2012-10-10 22:04 ` [Bug c/54896] " steven at gcc dot gnu.org
  2012-10-10 22:09 ` tammy at Cadence dot COM
@ 2012-10-10 22:51 ` steven at gcc dot gnu.org
  2012-10-11 14:08 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: steven at gcc dot gnu.org @ 2012-10-10 22:51 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |alias, compile-time-hog
             Status|WAITING                     |NEW
                 CC|                            |rguenth at gcc dot gnu.org
      Known to work|                            |4.3.2, 4.4.0
            Summary|Some optimization slowness  |[4.7/4.8 Regression] Some
                   |with GCC 4.7.2              |optimization slowness with
                   |                            |GCC 4.7.2
      Known to fail|                            |4.7.2, 4.8.0

--- Comment #3 from Steven Bosscher <steven at gcc dot gnu.org> 2012-10-10 22:51:12 UTC ---
Thanks for the test case!

Bug is confirmed with GCC 4.8 (trunk revision 192219).

Problem areas at -O1:
 alias stmt walking    :  31.68 (36%) usr
 tree DSE              :  10.83 (12%) usr
 CSE                   :   9.02 (10%) usr
 reload CSE regs       :  23.17 (26%) usr
 TOTAL                 :  87.99

Problem areas at -O2 are pretty much the same:
 alias stmt walking    :  47.29 (28%) usr
 tree DSE              :  10.84 ( 7%) usr
 CSE                   :   9.12 ( 5%) usr
 CSE 2                 :  34.66 (21%) usr
 reload CSE regs       :  45.37 (27%) usr
 TOTAL                 : 166.12


GCC 4.3.2 has the same problems at the RTL level:
 tree DSE              :  11.60 (17%) usr
 CSE                   :  19.74 (28%) usr
 CSE 2                 :  12.63 (18%) usr
 reload CSE regs       :   8.49 (12%) usr
 TOTAL                 :  69.68


tree-DSE, CSE and reload-CSE are both quadratic in the number of
instructions per basic block, and all basic blocks in this test
case contain O(10^3) instructions.

The alias stmt walking slowness is a regression, but I suspect
there a dup that Rick Biener already knows about...


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

* [Bug c/54896] [4.7/4.8 Regression] Some optimization slowness with GCC 4.7.2
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
                   ` (2 preceding siblings ...)
  2012-10-10 22:51 ` [Bug c/54896] [4.7/4.8 Regression] " steven at gcc dot gnu.org
@ 2012-10-11 14:08 ` rguenth at gcc dot gnu.org
  2012-11-25 15:55 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-10-11 14:08 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> 2012-10-11 14:08:16 UTC ---
(In reply to comment #3)
> Thanks for the test case!
> 
> Bug is confirmed with GCC 4.8 (trunk revision 192219).
> 
> Problem areas at -O1:
>  alias stmt walking    :  31.68 (36%) usr
>  tree DSE              :  10.83 (12%) usr
>  CSE                   :   9.02 (10%) usr
>  reload CSE regs       :  23.17 (26%) usr
>  TOTAL                 :  87.99
> 
> Problem areas at -O2 are pretty much the same:
>  alias stmt walking    :  47.29 (28%) usr
>  tree DSE              :  10.84 ( 7%) usr
>  CSE                   :   9.12 ( 5%) usr
>  CSE 2                 :  34.66 (21%) usr
>  reload CSE regs       :  45.37 (27%) usr
>  TOTAL                 : 166.12
> 
> 
> GCC 4.3.2 has the same problems at the RTL level:
>  tree DSE              :  11.60 (17%) usr
>  CSE                   :  19.74 (28%) usr
>  CSE 2                 :  12.63 (18%) usr
>  reload CSE regs       :   8.49 (12%) usr
>  TOTAL                 :  69.68
> 
> 
> tree-DSE, CSE and reload-CSE are both quadratic in the number of
> instructions per basic block, and all basic blocks in this test
> case contain O(10^3) instructions.

tree-DSE isn't quadratic but linear in the number of instructions
(again with a high factor, up to 256, without a --param).

> The alias stmt walking slowness is a regression, but I suspect
> there a dup that Rick Biener already knows about...

There are (for 4.8) limits in place everywhere to make alias-stmt
walking O(1) (well, with a high constant overhead ;)).

My numbers for 4.7 are, at -O2

 alias stmt walking      :  13.55 (19%) usr
 tree DSE                :   2.60 ( 4%) usr
 CSE                     :   8.79 (13%) usr
 CSE 2                   :  17.52 (25%) usr
 reload CSE regs         :  21.23 (30%) usr

with -m32 reload CSE regs is even worse.


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

* [Bug c/54896] [4.7/4.8 Regression] Some optimization slowness with GCC 4.7.2
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
                   ` (3 preceding siblings ...)
  2012-10-11 14:08 ` rguenth at gcc dot gnu.org
@ 2012-11-25 15:55 ` rguenth at gcc dot gnu.org
  2012-12-03 15:50 ` [Bug middle-end/54896] " rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-11-25 15:55 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.7.3


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

* [Bug middle-end/54896] Some optimization slowness with GCC 4.7.2
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
                   ` (4 preceding siblings ...)
  2012-11-25 15:55 ` rguenth at gcc dot gnu.org
@ 2012-12-03 15:50 ` rguenth at gcc dot gnu.org
  2012-12-03 15:51 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-03 15:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end
             Blocks|                            |47344
            Summary|[4.7/4.8 Regression] Some   |Some optimization slowness
                   |optimization slowness with  |with GCC 4.7.2
                   |GCC 4.7.2                   |

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-03 15:50:06 UTC ---
Generic compile-time regression umbrella.


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

* [Bug middle-end/54896] Some optimization slowness with GCC 4.7.2
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
                   ` (5 preceding siblings ...)
  2012-12-03 15:50 ` [Bug middle-end/54896] " rguenth at gcc dot gnu.org
@ 2012-12-03 15:51 ` rguenth at gcc dot gnu.org
  2013-03-06 11:04 ` [Bug middle-end/54896] optimization slowness on large basic blocks steven at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-03 15:51 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.3                       |---


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

* [Bug middle-end/54896] optimization slowness on large basic blocks
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
                   ` (6 preceding siblings ...)
  2012-12-03 15:51 ` rguenth at gcc dot gnu.org
@ 2013-03-06 11:04 ` steven at gcc dot gnu.org
  2013-03-06 11:12 ` rguenther at suse dot de
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: steven at gcc dot gnu.org @ 2013-03-06 11:04 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Some optimization slowness  |optimization slowness on
                   |with GCC 4.7.2              |large basic blocks
      Known to fail|                            |4.6.0

--- Comment #6 from Steven Bosscher <steven at gcc dot gnu.org> 2013-03-06 11:03:44 UTC ---
(In reply to comment #5)
> Generic compile-time regression umbrella.

Why? This is not an old regression.


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

* [Bug middle-end/54896] optimization slowness on large basic blocks
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
                   ` (7 preceding siblings ...)
  2013-03-06 11:04 ` [Bug middle-end/54896] optimization slowness on large basic blocks steven at gcc dot gnu.org
@ 2013-03-06 11:12 ` rguenther at suse dot de
  2013-03-12 18:24 ` steven at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenther at suse dot de @ 2013-03-06 11:12 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

--- Comment #7 from rguenther at suse dot de <rguenther at suse dot de> 2013-03-06 11:11:28 UTC ---
On Wed, 6 Mar 2013, steven at gcc dot gnu.org wrote:

> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896
> 
> Steven Bosscher <steven at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>             Summary|Some optimization slowness  |optimization slowness on
>                    |with GCC 4.7.2              |large basic blocks
>       Known to fail|                            |4.6.0
> 
> --- Comment #6 from Steven Bosscher <steven at gcc dot gnu.org> 2013-03-06 11:03:44 UTC ---
> (In reply to comment #5)
> > Generic compile-time regression umbrella.
> 
> Why? This is not an old regression.

It's a regression on all maintained branches.


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

* [Bug middle-end/54896] optimization slowness on large basic blocks
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
                   ` (8 preceding siblings ...)
  2013-03-06 11:12 ` rguenther at suse dot de
@ 2013-03-12 18:24 ` steven at gcc dot gnu.org
  2013-03-13  9:53 ` rguenth at gcc dot gnu.org
  2021-12-26  6:38 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: steven at gcc dot gnu.org @ 2013-03-12 18:24 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

--- Comment #8 from Steven Bosscher <steven at gcc dot gnu.org> 2013-03-12 18:23:29 UTC ---
With r196576 on x86_64 (gcc17):

at -O1:
 alias stmt walking      :  30.99 (36%) usr
 reload CSE regs         :  18.94 (22%) usr
 CSE                     :  14.94 (17%) usr
 tree DSE                :   9.32 (11%) usr

at -O2:
 alias stmt walking      :  46.65 (30%) usr
 reload CSE regs         :  37.92 (25%) usr
 CSE 2                   :  29.09 (19%) usr
 CSE                     :  15.02 (10%) usr

at -O3:
 tree slp vectorization  : 129.79 (61%) usr
 alias stmt walking      :  46.52 (22%) usr


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

* [Bug middle-end/54896] optimization slowness on large basic blocks
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
                   ` (9 preceding siblings ...)
  2013-03-12 18:24 ` steven at gcc dot gnu.org
@ 2013-03-13  9:53 ` rguenth at gcc dot gnu.org
  2021-12-26  6:38 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-13  9:53 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54896

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-13 09:53:06 UTC ---
(In reply to comment #8)
> With r196576 on x86_64 (gcc17):
> 
> at -O1:
>  alias stmt walking      :  30.99 (36%) usr
>  reload CSE regs         :  18.94 (22%) usr
>  CSE                     :  14.94 (17%) usr
>  tree DSE                :   9.32 (11%) usr
> 
> at -O2:
>  alias stmt walking      :  46.65 (30%) usr
>  reload CSE regs         :  37.92 (25%) usr
>  CSE 2                   :  29.09 (19%) usr
>  CSE                     :  15.02 (10%) usr
> 
> at -O3:
>  tree slp vectorization  : 129.79 (61%) usr
>  alias stmt walking      :  46.52 (22%) usr

I have patches for the SLP vectorization part, queued for 4.9.


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

* [Bug middle-end/54896] optimization slowness on large basic blocks
  2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
                   ` (10 preceding siblings ...)
  2013-03-13  9:53 ` rguenth at gcc dot gnu.org
@ 2021-12-26  6:38 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-26  6:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note I think -O3 (and now -O2) is much worse recently due to vector SLP taking
a long time too.

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

end of thread, other threads:[~2021-12-26  6:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-10 21:28 [Bug c/54896] New: Some optimization slowness with GCC 4.7.2 tammy at Cadence dot COM
2012-10-10 22:04 ` [Bug c/54896] " steven at gcc dot gnu.org
2012-10-10 22:09 ` tammy at Cadence dot COM
2012-10-10 22:51 ` [Bug c/54896] [4.7/4.8 Regression] " steven at gcc dot gnu.org
2012-10-11 14:08 ` rguenth at gcc dot gnu.org
2012-11-25 15:55 ` rguenth at gcc dot gnu.org
2012-12-03 15:50 ` [Bug middle-end/54896] " rguenth at gcc dot gnu.org
2012-12-03 15:51 ` rguenth at gcc dot gnu.org
2013-03-06 11:04 ` [Bug middle-end/54896] optimization slowness on large basic blocks steven at gcc dot gnu.org
2013-03-06 11:12 ` rguenther at suse dot de
2013-03-12 18:24 ` steven at gcc dot gnu.org
2013-03-13  9:53 ` rguenth at gcc dot gnu.org
2021-12-26  6:38 ` 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).