This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

New warning patch: Disabling gcse


In gcse.c you find the following code:

    /* Trying to perform global optimizations on flow graphs which have
       a high connectivity will take a long time and is unlikely to be
       particularly useful.

       In normal circumstances a cfg should have about twice has many edges
       as blocks.  But we do not want to punish small functions which have
       a couple switch statements.  So we require a relatively large number
       of basic blocks and the ratio of edges to blocks to be high.  */
    if (n_basic_blocks > 1000 && n_edges / n_basic_blocks >= 20)
      return 0;


I think that this should be accompanied by a warning.  Actually,
this is caused by gcse.c not handling computed goto's correctly;
there should be a computed-goto pseudo-block, with all computed-goto's
having an edge into the block, and all labels whose address is
taken having an edge coming out of this block.  This would reduce the
size of the flow graph from at least $N\times M$, where there are
$N$ computed gotos and $M$ labels, to $N+M$, while giving exactly
the same flow information.  But without this fix, I think there should
be a warning.

So I propose the following patch, which has been bootstrapped on
alphaev6-unknown-linux-gnu with no new testsuite regressions.
With this test, I get the following messages building a development
version of the Gambit-C Scheme system:

_errors.c:5536: warning: Disabling gcse pass; 1112 > 1000 basic blocks and 31 >
20 edges/basic block
_multi.c:9245: warning: Disabling gcse pass; 1697 > 1000 basic blocks and 42 > 20 edges/basic block
_repl.c:12410: warning: Disabling gcse pass; 2698 > 1000 basic blocks and 129 >
20 edges/basic block
_num1.c:13483: warning: Disabling gcse pass; 3781 > 1000 basic blocks and 104 >
20 edges/basic block
_num2.c:19423: warning: Disabling gcse pass; 3494 > 1000 basic blocks and 129 >
20 edges/basic block
_eval.c:21229: warning: Disabling gcse pass; 3890 > 1000 basic blocks and 163 >
20 edges/basic block
_std.c:22625: warning: Disabling gcse pass; 6101 > 1000 basic blocks and 183 > 20 edges/basic block
_utils.c:5923: warning: Disabling gcse pass; 1357 > 1000 basic blocks and 56 > 20 edges/basic block
_source.c:9246: warning: Disabling gcse pass; 1856 > 1000 basic blocks and 94 >
20 edges/basic block
_t-c-1.c:14687: warning: Disabling gcse pass; 3107 > 1000 basic blocks and 157 > 20 edges/basic block
_gvm.c:15037: warning: Disabling gcse pass; 3274 > 1000 basic blocks and 192 > 20 edges/basic block
_ptree2.c:15330: warning: Disabling gcse pass; 3474 > 1000 basic blocks and 240
> 20 edges/basic block
_ptree1.c:19701: warning: Disabling gcse pass; 3918 > 1000 basic blocks and 201
> 20 edges/basic block
_front.c:18847: warning: Disabling gcse pass; 4166 > 1000 basic blocks and 341 > 20 edges/basic block
_t-c-2.c:25727: warning: Disabling gcse pass; 5124 > 1000 basic blocks and 488 > 20 edges/basic block                                                           

So now at least I know where the gcse pass is disabled, and I can
choose alternate compilation strategies for Gambit-C if I like.

Brad Lucier

	* gcse.c (gcse_main): Warn when disabling gcse pass.

===================================================================
RCS file: RCS/gcse.c,v
retrieving revision 1.1
diff -c -r1.1 gcse.c
*** gcse.c	2000/06/24 21:59:24	1.1
--- gcse.c	2000/07/17 21:00:49
***************
*** 687,693 ****
       a couple switch statements.  So we require a relatively large number
       of basic blocks and the ratio of edges to blocks to be high.  */
    if (n_basic_blocks > 1000 && n_edges / n_basic_blocks >= 20)
!     return 0;
  
    /* See what modes support reg/reg copy operations.  */
    if (! can_copy_init_p)
--- 687,697 ----
       a couple switch statements.  So we require a relatively large number
       of basic blocks and the ratio of edges to blocks to be high.  */
    if (n_basic_blocks > 1000 && n_edges / n_basic_blocks >= 20)
!     {
!       warning ("Disabling gcse pass; %d > 1000 basic blocks and %d > 20 edges/basic block",
!                n_basic_blocks, n_edges / n_basic_blocks);
!       return 0;
!     }
  
    /* See what modes support reg/reg copy operations.  */
    if (! can_copy_init_p)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]