diff options
author | Toon Moene <toon@moene.indiv.nluug.nl> | 1999-02-27 19:33:05 +0100 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 1999-02-27 11:33:05 -0700 |
commit | 464b5afc755e5b31f87561797e1b62841442f3be (patch) | |
tree | 62e40a9dfebc671dc63090f24a8c96f7ce713663 | |
parent | e52a4527685f3a2159943096bbefb0aa64942b73 (diff) | |
download | gcc-464b5afc755e5b31f87561797e1b62841442f3be.tar.gz |
alias.c (true_dependence): Only apply MEM_IN_STRUCT_P tests when flag_structure_noalias is set.
* alias.c (true_dependence): Only apply MEM_IN_STRUCT_P tests
when flag_structure_noalias is set.
* toplev.c (flag_structure_noalias): New variable.
(f_options): Add -fstructure-noalias.
* flags.h (flag_structure_noalias): Declare.
* invoke.texi: Update documentation.
Co-Authored-By: Jeffrey A Law <law@cygnus.com>
Co-Authored-By: Mark Mitchell <mark@markmitchell.com>
From-SVN: r25483
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/alias.c | 12 | ||||
-rw-r--r-- | gcc/flags.h | 5 | ||||
-rw-r--r-- | gcc/invoke.texi | 12 | ||||
-rw-r--r-- | gcc/toplev.c | 7 |
5 files changed, 44 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e7ecc3e5fea..0f5b4a88416 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +Sat Feb 27 19:29:46 1999 Toon Moene <toon@moene.indiv.nluug.nl> + Mark Mitchell <mark@markmitchell.com> + Jeffrey A Law (law@cygnus.com) + + * alias.c (true_dependence): Only apply MEM_IN_STRUCT_P tests + when flag_structure_noalias is set. + * toplev.c (flag_structure_noalias): New variable. + (f_options): Add -fstructure-noalias. + * flags.h (flag_structure_noalias): Declare. + * invoke.texi: Update documentation. + Sat Feb 27 19:19:36 1999 Jeffrey A Law (law@cygnus.com) * SERVICE: Update from the FSF. diff --git a/gcc/alias.c b/gcc/alias.c index 281e353e101..172b6769f76 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -942,9 +942,15 @@ true_dependence (mem, mem_mode, x, varies) 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; + + /* 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; } diff --git a/gcc/flags.h b/gcc/flags.h index 37c1bd96a91..9fa976bf872 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -291,6 +291,11 @@ extern int flag_fast_math; 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. */ diff --git a/gcc/invoke.texi b/gcc/invoke.texi index 5287f53e4a6..01dd7a88605 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -158,6 +158,7 @@ in the following sections. -fschedule-insns2 -fstrength-reduce -fthread-jumps -funroll-all-loops -funroll-loops -fmove-all-movables -freduce-all-givs -fstrict-aliasing +-fstructure-noalias -O -O0 -O1 -O2 -O3 -Os @end smallexample @@ -2501,6 +2502,17 @@ allowed to alias. For an example, see the C front-end function @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. + +Although this optimization is safe, GCC can occasionally lose track +of which references refer to scalars and which to structures, +leading it to perform unsafe transformations. Release 1.2 of EGCS +will incorporate changes which allow GCC to track the +scalar/structure distinction safely. Thus, the optimization will +always be same, and this option will likely be removed or will have +no effect. @end table @node Preprocessor Options diff --git a/gcc/toplev.c b/gcc/toplev.c index 9b7c50674ad..497359e0e2a 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -554,6 +554,11 @@ static int flag_gcse; 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. */ int flag_rerun_loop_opt; @@ -840,6 +845,8 @@ lang_independent_options f_options[] = "Perform the global common subexpression elimination" }, {"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"}, {"pretend-float", &flag_pretend_float, 1, |