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]

[vta] temporary work around for major DF fwprop limitation


The use of DF data structures in fwprop has caused it to miss several
optimizations.  For example, if we have something like:

  (set (reg A) (op (reg B) (reg C)))

and we could fwprop both B and C, the current code will only fwprop
one of them.  The problem is that op will be re-gen()-ed when we
replace B, and therefore the LOC of the use of C present in the DF
structures won't match any more.  This causes the code to refrain from
attempting to fwprop C.  Oops.

This patch does *not* fix this problem.  It just works around it to
avoid codegen changes caused by debug insns that do reference multiple
fwprop-able registers, but that end up not having all fwprop-able
occurrences replaced because of the rtx copying and DF structures
out-of-dateness.  If fwprop succeeds in all active (non-debug)
occurrences of the fwprop-able register, but references in debug insns
remain, the DEF wouldn't die at the expected point, and codegen
differences may arise.

This patch avoids such differences, at the expense, in the location
expressions, of missing rtl simplifications that might be possible and
of wrapping CONST_INTs with CONSTs to give them a mode.

I hope to revert this once fwprop is improved, possibly by myself,
such that it doesn't depend on unchanging LOCs to function.

for  gcc/ChangeLog.vta
from  Alexandre Oliva  <aoliva@redhat.com>

	* fwprop.c (forward_propagate_and_simplify): Update the debug
	insn ref only, not the entire location expression.

Index: gcc/fwprop.c
===================================================================
--- gcc/fwprop.c.orig	2007-10-31 06:05:18.000000000 -0200
+++ gcc/fwprop.c	2007-10-31 16:32:40.000000000 -0200
@@ -832,8 +832,14 @@ forward_propagate_and_simplify (struct d
     }
   else if (!use_set)
     {
-      loc = &INSN_VAR_LOCATION_LOC (use_insn);
+      loc = DF_REF_LOC (use);
       set_reg_equal = false;
+
+      if (GET_MODE (reg) != GET_MODE (src))
+	{
+	  gcc_assert (GET_CODE (src) == CONST_INT);
+	  src = gen_rtx_CONST (GET_MODE (reg), src);
+	}
     }
   else
     {
-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

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