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]
Other format: [Raw text]

PR33713: remove -fforce-addr


Hi folks.

I'm picking up this patch that Steven attached to the PR but didn't
submit to the list.  The patch removes support for -fforce-addr.

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

I have added a changelog, incorporated the change suggested by Paolo,
fixed a typo, and tested it on x86_64-linux.  There are no regressions.

Is this OK for mainline?

	PR33713
	* doc/invoke.texi: Remove -fforce-addr documentation.
	* expr.c (emit_move_insn): Remove use of flag_force_addr.
	(expand_expr_real_1): Same.
	(do_tablejump): Same.
	Call memory_address instead of memory_address_noforce.
	* expr.h (memory_address_noforce): Remove prototype.
	* explow.c (memory_address): Remove support for flag_force_addr.
	(validize_mem): Same.
	(memory_address_noforce): Remove.
	* common.opt: Add dummy documentation for -fforce-addr.
	* combine.c (can_combine_p): Remove -fforce-addr comment.
	* config/cris/cris.h: Update CC1_SPEC comment with regards to
	-fforce-addr.
	(OPTIMIZATION_OPTIONS): Remove set of flag_force_addr.
	* config/m68k/m68k.h (PIC_CASE_VECTOR_ADDRESS): Remove comment
	relating to memory_address_noforce.

	* gcc.c-torture/compile/20050802-1.c: Remove.
	* gcc.c-torture/compile/20011113-1.c: Remove.

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 130511)
+++ doc/invoke.texi	(working copy)
@@ -324,7 +324,7 @@ Objective-C and Objective-C++ Dialects}.
 -fcse-skip-blocks -fcx-limited-range -fdata-sections -fdce -fdce @gol
 -fdelayed-branch -fdelete-null-pointer-checks -fdse -fdse @gol
 -fearly-inlining -fexpensive-optimizations -ffast-math @gol
--ffinite-math-only -ffloat-store -fforce-addr -fforward-propagate @gol
+-ffinite-math-only -ffloat-store -fforward-propagate @gol
 -ffunction-sections -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm @gol
 -fgcse-sm -fif-conversion -fif-conversion2 -finline-functions @gol
 -finline-functions-called-once -finline-limit=@var{n} @gol
@@ -5140,11 +5140,6 @@ function calls and pops them all at once
 
 Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
 
-@item -fforce-addr
-@opindex fforce-addr
-Force memory address constants to be copied into registers before
-doing arithmetic on them.
-
 @item -fforward-propagate
 @opindex fforward-propagate
 Perform a forward propagation pass on RTL.  The pass tries to combine two
Index: testsuite/gcc.c-torture/compile/20050802-1.c
===================================================================
--- testsuite/gcc.c-torture/compile/20050802-1.c	(revision 130511)
+++ testsuite/gcc.c-torture/compile/20050802-1.c	(working copy)
@@ -1,10 +0,0 @@
-/* PR 23196 */
-/* { dg-options "-fforce-addr" } */
-
-void foo()
-{
-  char c;
-
-  c |= 1;
-  bar(&c);
-}
Index: testsuite/gcc.dg/20011113-1.c
===================================================================
--- testsuite/gcc.dg/20011113-1.c	(revision 130511)
+++ testsuite/gcc.dg/20011113-1.c	(working copy)
@@ -1,16 +0,0 @@
-/* Copyright (C) 2001  Free Software Foundation.
-   by Hans-Peter Nilsson  <hp@axis.com>  */
-
-/* { dg-do compile } */
-/* { dg-options "-O2 -fforce-addr" } */
-
-const char foo[] = "fum";
-const struct fi
-{
-  const char *const in;
-  const char *const out;
-  const int flags;
-} fie[] = {
-  {"nw", " new", 0},
-  {"dl", foo, 1}
-};
Index: expr.c
===================================================================
--- expr.c	(revision 130511)
+++ expr.c	(working copy)
@@ -3391,16 +3391,12 @@ emit_move_insn (rtx x, rtx y)
   /* If X or Y are memory references, verify that their addresses are valid
      for the machine.  */
   if (MEM_P (x)
-      && ((! memory_address_p (GET_MODE (x), XEXP (x, 0))
-	   && ! push_operand (x, GET_MODE (x)))
-	  || (flag_force_addr
-	      && CONSTANT_ADDRESS_P (XEXP (x, 0)))))
+      && (! memory_address_p (GET_MODE (x), XEXP (x, 0))
+	  && ! push_operand (x, GET_MODE (x))))
     x = validize_mem (x);
 
   if (MEM_P (y)
-      && (! memory_address_p (GET_MODE (y), XEXP (y, 0))
-	  || (flag_force_addr
-	      && CONSTANT_ADDRESS_P (XEXP (y, 0)))))
+      && ! memory_address_p (GET_MODE (y), XEXP (y, 0)))
     y = validize_mem (y);
 
   gcc_assert (mode != BLKmode);
@@ -7294,9 +7290,8 @@ expand_expr_real_1 (tree exp, rtx target
       if (MEM_P (decl_rtl) && REG_P (XEXP (decl_rtl, 0)))
 	temp = validize_mem (decl_rtl);
 
-      /* If DECL_RTL is memory, we are in the normal case and either
-	 the address is not valid or it is not a register and -fforce-addr
-	 is specified, get the address into a register.  */
+      /* If DECL_RTL is memory, we are in the normal case and the
+	 address is not valid, get the address into a register.  */
 
       else if (MEM_P (decl_rtl) && modifier != EXPAND_INITIALIZER)
 	{
@@ -7305,8 +7300,7 @@ expand_expr_real_1 (tree exp, rtx target
 	  decl_rtl = use_anchored_address (decl_rtl);
 	  if (modifier != EXPAND_CONST_ADDRESS
 	      && modifier != EXPAND_SUM
-	      && (!memory_address_p (DECL_MODE (exp), XEXP (decl_rtl, 0))
-		  || (flag_force_addr && !REG_P (XEXP (decl_rtl, 0)))))
+	      && !memory_address_p (DECL_MODE (exp), XEXP (decl_rtl, 0)))
 	    temp = replace_equiv_address (decl_rtl,
 					  copy_rtx (XEXP (decl_rtl, 0)));
 	}
@@ -7428,8 +7422,7 @@ expand_expr_real_1 (tree exp, rtx target
       if (modifier != EXPAND_CONST_ADDRESS
 	  && modifier != EXPAND_INITIALIZER
 	  && modifier != EXPAND_SUM
-	  && (! memory_address_p (mode, XEXP (temp, 0))
-	      || flag_force_addr))
+	  && ! memory_address_p (mode, XEXP (temp, 0)))
 	return replace_equiv_address (temp,
 				      copy_rtx (XEXP (temp, 0)));
       return temp;
@@ -9970,10 +9963,6 @@ do_tablejump (rtx index, enum machine_mo
     index = copy_to_mode_reg (Pmode, index);
 #endif
 
-  /* If flag_force_addr were to affect this address
-     it could interfere with the tricky assumptions made
-     about addresses that contain label-refs,
-     which may be valid only very near the tablejump itself.  */
   /* ??? The only correct use of CASE_VECTOR_MODE is the one inside the
      GET_MODE_SIZE, because this indicates how large insns are.  The other
      uses should all be Pmode, because they are addresses.  This code
@@ -9987,7 +9976,7 @@ do_tablejump (rtx index, enum machine_mo
     index = PIC_CASE_VECTOR_ADDRESS (index);
   else
 #endif
-    index = memory_address_noforce (CASE_VECTOR_MODE, index);
+    index = memory_address (CASE_VECTOR_MODE, index);
   temp = gen_reg_rtx (CASE_VECTOR_MODE);
   vector = gen_const_mem (CASE_VECTOR_MODE, index);
   convert_move (temp, vector, 0);
Index: expr.h
===================================================================
--- expr.h	(revision 130511)
+++ expr.h	(working copy)
@@ -616,9 +616,6 @@ extern rtx eliminate_constant_term (rtx,
    by emitting insns to perform arithmetic if nec.  */
 extern rtx memory_address (enum machine_mode, rtx);
 
-/* Like `memory_address' but pretend `flag_force_addr' is 0.  */
-extern rtx memory_address_noforce (enum machine_mode, rtx);
-
 /* Return a memory reference like MEMREF, but with its mode changed
    to MODE and its address changed to ADDR.
    (VOIDmode means don't change the mode.
Index: explow.c
===================================================================
--- explow.c	(revision 130511)
+++ explow.c	(working copy)
@@ -431,18 +431,21 @@ memory_address (enum machine_mode mode, 
 
       /* At this point, any valid address is accepted.  */
       if (memory_address_p (mode, x))
-	goto win;
+	goto done;
 
       /* If it was valid before but breaking out memory refs invalidated it,
 	 use it the old way.  */
       if (memory_address_p (mode, oldx))
-	goto win2;
+	{
+	  x = oldx;
+	  goto done;
+	}
 
       /* Perform machine-dependent transformations on X
 	 in certain cases.  This is not necessary since the code
 	 below can handle all possible cases, but machine-dependent
 	 transformations can make better code.  */
-      LEGITIMIZE_ADDRESS (x, oldx, mode, win);
+      LEGITIMIZE_ADDRESS (x, oldx, mode, done);
 
       /* PLUS and MULT can appear in special ways
 	 as the result of attempts to make an address usable for indexing.
@@ -482,17 +485,6 @@ memory_address (enum machine_mode mode, 
 	 the register is a valid address.  */
       else
 	x = force_reg (Pmode, x);
-
-      goto done;
-
-    win2:
-      x = oldx;
-    win:
-      if (flag_force_addr && ! cse_not_expected && !REG_P (x))
-	{
-	  x = force_operand (x, NULL_RTX);
-	  x = force_reg (Pmode, x);
-	}
     }
 
  done:
@@ -515,20 +507,6 @@ memory_address (enum machine_mode mode, 
   return x;
 }
 
-/* Like `memory_address' but pretend `flag_force_addr' is 0.  */
-
-rtx
-memory_address_noforce (enum machine_mode mode, rtx x)
-{
-  int ambient_force_addr = flag_force_addr;
-  rtx val;
-
-  flag_force_addr = 0;
-  val = memory_address (mode, x);
-  flag_force_addr = ambient_force_addr;
-  return val;
-}
-
 /* Convert a mem ref into one with a valid memory address.
    Pass through anything else unchanged.  */
 
@@ -538,8 +516,7 @@ validize_mem (rtx ref)
   if (!MEM_P (ref))
     return ref;
   ref = use_anchored_address (ref);
-  if (! (flag_force_addr && CONSTANT_ADDRESS_P (XEXP (ref, 0)))
-      && memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
+  if (memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
     return ref;
 
   /* Don't alter REF itself, since that is probably a stack slot.  */
Index: common.opt
===================================================================
--- common.opt	(revision 130511)
+++ common.opt	(working copy)
@@ -482,11 +482,9 @@ ffloat-store
 Common Report Var(flag_float_store) Optimization
 Don't allocate floats and doubles in extended-precision registers
 
-; Nonzero for -fforce-addr: load memory address into a register before
-; reference to memory.  This makes better cse but slower compilation.
 fforce-addr
-Common Report Var(flag_force_addr) Optimization
-Copy memory address constants into registers before use
+Common
+Does nothing.  Preserved for backward compatibility.
 
 fforward-propagate
 Common Report Var(flag_forward_propagate) Optimization
Index: combine.c
===================================================================
--- combine.c	(revision 130511)
+++ combine.c	(working copy)
@@ -1694,7 +1694,7 @@ can_combine_p (rtx insn, rtx i3, rtx pre
 	 change whether the life span of some REGs crosses calls or not,
 	 and it is a pain to update that information.
 	 Exception: if source is a constant, moving it later can't hurt.
-	 Accept that special case, because it helps -fforce-addr a lot.  */
+	 Accept that as a special case.  */
       || (DF_INSN_LUID (insn) < last_call_luid && ! CONSTANT_P (src)))
     return 0;
 
Index: config/cris/cris.h
===================================================================
--- config/cris/cris.h	(revision 130511)
+++ config/cris/cris.h	(working copy)
@@ -155,11 +155,16 @@ extern int cris_cpu_version;
       %{!fno-function-sections: -ffunction-sections}\
       %{!fno-data-sections: -fdata-sections}}}}"
 
-/* This adds to CC1_SPEC.  When bugs are removed from -fvtable-gc
-   (-fforce-addr causes invalid .vtable_entry asm in tinfo.cc and
-   nothing at all works in GCC 3.0-pre), add this line:
+/* This adds to CC1_SPEC.
+   FIXME: There used to be bugs with -fvtable-gc in combination with
+   -fforce-addr, and the latter was enabled by default for CRIS.  It
+   was suggested, in an old comment here, that the following line should
+   be added here once those bugs would be resolved:
+
    "%{mbest-lib-options:%{!moverride-best-lib-options:\
-   %{!melinux:%{!maout|melf:%{!fno-vtable-gc:-fvtable-gc}}}}}".  */
+   %{!melinux:%{!maout|melf:%{!fno-vtable-gc:-fvtable-gc}}}}}".
+
+   This could be tried agian, now that -fforce-addr has been removed.  */
 #define CC1PLUS_SPEC ""
 
 #ifdef HAVE_AS_NO_MUL_BUG_ABORT_OPTION
@@ -296,19 +301,14 @@ extern int target_flags;
 
 #define OVERRIDE_OPTIONS cris_override_options ()
 
-/* The following gives optimal code for gcc-2.7.2, but *may* be subject
-   to change.  Omitting flag_force_addr gives .1-.7% faster code for gcc
-   *only*, but 1.3% larger code.  On ipps it gives 5.3-10.6% slower
-   code(!) and 0.3% larger code.  For products, images gets .1-1.8%
-   larger.  Do not set strict aliasing from optimization options.  */
+/* FIXME: This once was tuned for gcc-2.7.2, but old flags have gone and
+   new flags have been added.  It may be worthwhile to try and find a new
+   set of optimizations options for cris, e.g. using ACOVEA.  */
 #define OPTIMIZATION_OPTIONS(OPTIMIZE, SIZE)	\
   do						\
     {						\
       if ((OPTIMIZE) >= 2 || (SIZE))		\
-	{					\
-	  flag_force_addr = 1;			\
-	  flag_omit_frame_pointer = 1;		\
-	}					\
+	flag_omit_frame_pointer = 1;		\
     }						\
   while (0)
 
Index: config/m68k/m68k.h
===================================================================
--- config/m68k/m68k.h	(revision 130511)
+++ config/m68k/m68k.h	(working copy)
@@ -755,9 +755,7 @@ __transfer_from_trampoline ()					\
     }									\
   while (0)
 
-/* Don't call memory_address_noforce for the address to fetch
-   the switch offset.  This address is ok as it stands,
-   but memory_address_noforce would alter it.  */
+/* This address is OK as it stands.  */
 #define PIC_CASE_VECTOR_ADDRESS(index) index
 
 /* For the 68000, we handle X+REG by loading X into a register R and


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