PATCH for structure / varying address & scalar problem in egcs-1.1.x.

Toon Moene toon@moene.indiv.nluug.nl
Sat Feb 27 12:03:00 GMT 1999


Hi,

Given that the aliasing problem for structure / varying array references
vs. fixed scalars isn't solved for egcs 1.1.x, here's my set of patches
to a recent CVS'd egcs_1_1_branch snapshot (bootstrapped on
i686-pc-linux-gnu):

*** alias.c.orig        Sat Feb 27 15:40:20 1999
--- alias.c     Sat Feb 27 20:34:04 1999
*************** true_dependence (mem, mem_mode, x, varie
*** 943,949 ****
       If either memory reference is a variable structure the other is a
       fixed scalar and there is no aliasing.  */
!   if ((MEM_IN_STRUCT_P (mem) && varies (mem_addr))
!       || (MEM_IN_STRUCT_P (x) && varies (x_addr)))
!     return 0;
  
    return 1;
--- 943,953 ----
       If either memory reference is a variable structure the other is a
       fixed scalar and there is no aliasing.  */
! 
!   /* Disabled by default for egcs 1.1.x as alias analysis isn't good
!      enough yet to discover all cases where this doesn't apply.  */
!   if (flag_structure_noalias)
!     if ((MEM_IN_STRUCT_P (mem) && varies (mem_addr))
!         || (MEM_IN_STRUCT_P (x) && varies (x_addr)))
!       return 0;
  
    return 1;
*** flags.h.orig        Sat Feb 27 15:34:21 1999
--- flags.h     Sat Feb 27 15:37:06 1999
*************** extern int flag_fast_math;
*** 292,295 ****
--- 292,300 ----
  extern int flag_rerun_loop_opt;
  
+ /* Nonzero means to assume that a structure or an array reference at
+    a varying address cannot alias a scalar at a fixed address. */
+ 
+ extern int flag_structure_noalias;
+ 
  /* Nonzero means make functions that look like good inline candidates
     go inline.  */
*** invoke.texi.orig    Sat Feb 27 16:42:38 1999
--- invoke.texi Sat Feb 27 16:47:37 1999
*************** in the following sections.
*** 159,162 ****
--- 159,163 ----
  -funroll-all-loops  -funroll-loops
  -fmove-all-movables  -freduce-all-givs -fstrict-aliasing
+ -fstructure-noalias
  -O  -O0  -O1  -O2  -O3 -Os
  @end smallexample
*************** allowed to alias.  For an example, see t
*** 2501,2504 ****
--- 2502,2512 ----
  @code{c_get_alias_set}.
  @end ifset
+ 
+ @item -fstructure-noalias
+ Allows the compiler to assume that structure / varying array
references
+ do not alias fixed scalars.  This option is not enabled by default, as
it
+ is a work around for a shortcoming in alias analysis in egcs version
1.1.x.
+ This option will be removed in egcs version 1.2.x, as this problem has
+ been solved in that version of the compiler.
  
  @end table
*** toplev.c.orig       Sat Feb 27 15:37:14 1999
--- toplev.c    Sat Feb 27 20:39:11 1999
*************** static int flag_gcse;
*** 555,558 ****
--- 555,563 ----
  static int flag_rerun_cse_after_loop;
  
+ /* Nonzero means to assume that a structure or an array reference at
+    a varying address cannot alias a scalar at a fixed address. */
+ 
+ int flag_structure_noalias = 0;
+ 
  /* Nonzero means to run loop optimizations twice.  */
  
*************** lang_independent_options f_options[] =
*** 841,844 ****
--- 846,851 ----
    {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
     "Run CSE pass after loop optimisations"},
+   {"structure-noalias", &flag_structure_noalias, 1,
+    "Assume structure / array reference and fixed scalar cannot
alias"},
    {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
     "Run the loop optimiser twice"},

Note that this is a temporary work-around - it isn't meant to be for
eternity (nevertheless, it should better be correct as it is now !).

Cheers,

-- 
Toon Moene (toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: fortran@gnu.org; egcs: egcs-bugs@cygnus.com


More information about the Gcc-patches mailing list