From a4c6b88b2cc86a004cc23946197b54be718c7756 Mon Sep 17 00:00:00 2001 From: Toon Moene Date: Sat, 27 Feb 1999 18:33:05 +0000 Subject: * 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. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/egcs_1_1_branch@25483 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 11 +++++++++++ gcc/alias.c | 12 +++++++++--- gcc/flags.h | 5 +++++ gcc/invoke.texi | 12 ++++++++++++ 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 + Mark Mitchell + 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, -- cgit v1.2.3