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]

Re: [VTA, PR41679] mode mismatch in var-tracking


On Nov 22, 2009, Alexandre Oliva <aoliva@redhat.com> wrote:

> On Nov 19, 2009, Alexandre Oliva <aoliva@redhat.com> wrote:

>> This patch does not address the issue of cond_exec stores, that has not
>> been taken into account in var-tracking, although support for it is
>> right there in cselib.

> But *this* patch (to be applied on top of the other) does.

> (This patch also removes some excess indirection, which I did to make
> sure the pointer values didn't really matter; it looked like they might.
> I guess I might split this part out, but if you want to just look at the
> new parts, search for COND_EXEC.)

> I'm considering just dropping the if_then_else expressions, binding the
> newly-generated value to the register and leaving it at that.  cselib
> will still remember the if_then_else equivalence anyway.

Dropping the if_then_else from the var-tracking tables (but not from
cselib) is most definitely the right thing to do, to parallel the way we
handle all other expressions that are not straight REGs and MEMs.

So I split out the removal of the excess indirection, and implemented
the change above in the second patch below.

Are these 3 patches (counting the original one upthread, URL below) ok
to install, if they pass yet another round of regstrapping on
ia64-linux-gnu?

http://gcc.gnu.org/ml/gcc-patches/2009-11/msg00992.html

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

	PR debug/41679
	* var-tracking.c (use_type): Remove indirection from loc.
	(count_uses): Dereference incoming loc early.
	(add_uses): Dereference incoming loc early.

Index: gcc/var-tracking.c
===================================================================
--- gcc/var-tracking.c.orig	2009-11-23 03:58:14.000000000 -0200
+++ gcc/var-tracking.c	2009-11-23 04:02:12.000000000 -0200
@@ -4375,19 +4375,19 @@ replace_expr_with_values (rtx loc)
    MO_CLOBBER if no micro operation is to be generated.  */
 
 static enum micro_operation_type
-use_type (rtx *loc, struct count_use_info *cui, enum machine_mode *modep)
+use_type (rtx loc, struct count_use_info *cui, enum machine_mode *modep)
 {
   tree expr;
   cselib_val *val;
 
   if (cui && cui->sets)
     {
-      if (GET_CODE (*loc) == VAR_LOCATION)
+      if (GET_CODE (loc) == VAR_LOCATION)
 	{
-	  if (track_expr_p (PAT_VAR_LOCATION_DECL (*loc), false))
+	  if (track_expr_p (PAT_VAR_LOCATION_DECL (loc), false))
 	    {
-	      rtx ploc = PAT_VAR_LOCATION_LOC (*loc);
-	      cselib_val *val = cselib_lookup (ploc, GET_MODE (*loc), 1);
+	      rtx ploc = PAT_VAR_LOCATION_LOC (loc);
+	      cselib_val *val = cselib_lookup (ploc, GET_MODE (loc), 1);
 
 	      /* ??? flag_float_store and volatile mems are never
 		 given values, but we could in theory use them for
@@ -4399,15 +4399,15 @@ use_type (rtx *loc, struct count_use_inf
 	    return MO_CLOBBER;
 	}
 
-      if ((REG_P (*loc) || MEM_P (*loc))
-	  && (val = find_use_val (*loc, GET_MODE (*loc), cui)))
+      if ((REG_P (loc) || MEM_P (loc))
+	  && (val = find_use_val (loc, GET_MODE (loc), cui)))
 	{
 	  if (modep)
-	    *modep = GET_MODE (*loc);
+	    *modep = GET_MODE (loc);
 	  if (cui->store_p)
 	    {
-	      if (REG_P (*loc)
-		  || cselib_lookup (XEXP (*loc, 0), GET_MODE (*loc), 0))
+	      if (REG_P (loc)
+		  || cselib_lookup (XEXP (loc, 0), GET_MODE (loc), 0))
 		return MO_VAL_SET;
 	    }
 	  else if (!cselib_preserved_value_p (val))
@@ -4415,31 +4415,31 @@ use_type (rtx *loc, struct count_use_inf
 	}
     }
 
-  if (REG_P (*loc))
+  if (REG_P (loc))
     {
-      gcc_assert (REGNO (*loc) < FIRST_PSEUDO_REGISTER);
+      gcc_assert (REGNO (loc) < FIRST_PSEUDO_REGISTER);
 
-      expr = REG_EXPR (*loc);
+      expr = REG_EXPR (loc);
 
       if (!expr)
 	return MO_USE_NO_VAR;
       else if (target_for_debug_bind (var_debug_decl (expr)))
 	return MO_CLOBBER;
-      else if (track_loc_p (*loc, expr, REG_OFFSET (*loc),
+      else if (track_loc_p (loc, expr, REG_OFFSET (loc),
 			    false, modep, NULL))
 	return MO_USE;
       else
 	return MO_USE_NO_VAR;
     }
-  else if (MEM_P (*loc))
+  else if (MEM_P (loc))
     {
-      expr = MEM_EXPR (*loc);
+      expr = MEM_EXPR (loc);
 
       if (!expr)
 	return MO_CLOBBER;
       else if (target_for_debug_bind (var_debug_decl (expr)))
 	return MO_CLOBBER;
-      else if (track_loc_p (*loc, expr, INT_MEM_OFFSET (*loc),
+      else if (track_loc_p (loc, expr, INT_MEM_OFFSET (loc),
 			    false, modep, NULL))
 	return MO_USE;
       else
@@ -4467,37 +4467,38 @@ log_op_type (rtx x, basic_block bb, rtx 
    INSN is instruction which the LOC is part of.  */
 
 static int
-count_uses (rtx *loc, void *cuip)
+count_uses (rtx *ploc, void *cuip)
 {
+  rtx loc = *ploc;
   struct count_use_info *cui = (struct count_use_info *) cuip;
   enum micro_operation_type mopt = use_type (loc, cui, NULL);
 
   if (mopt != MO_CLOBBER)
     {
       cselib_val *val;
-      enum machine_mode mode = GET_MODE (*loc);
+      enum machine_mode mode = GET_MODE (loc);
 
       VTI (cui->bb)->n_mos++;
 
       if (dump_file && (dump_flags & TDF_DETAILS))
-	log_op_type (*loc, cui->bb, cui->insn, mopt, dump_file);
+	log_op_type (loc, cui->bb, cui->insn, mopt, dump_file);
 
       switch (mopt)
 	{
 	case MO_VAL_LOC:
-	  loc = &PAT_VAR_LOCATION_LOC (*loc);
-	  if (VAR_LOC_UNKNOWN_P (*loc))
+	  loc = PAT_VAR_LOCATION_LOC (loc);
+	  if (VAR_LOC_UNKNOWN_P (loc))
 	    break;
 	  /* Fall through.  */
 
 	case MO_VAL_USE:
 	case MO_VAL_SET:
-	  if (MEM_P (*loc)
-	      && !REG_P (XEXP (*loc, 0)) && !MEM_P (XEXP (*loc, 0)))
+	  if (MEM_P (loc)
+	      && !REG_P (XEXP (loc, 0)) && !MEM_P (XEXP (loc, 0)))
 	    {
 	      enum machine_mode address_mode
-		= targetm.addr_space.address_mode (MEM_ADDR_SPACE (*loc));
-	      val = cselib_lookup (XEXP (*loc, 0), address_mode, false);
+		= targetm.addr_space.address_mode (MEM_ADDR_SPACE (loc));
+	      val = cselib_lookup (XEXP (loc, 0), address_mode, false);
 
 	      if (val && !cselib_preserved_value_p (val))
 		{
@@ -4506,7 +4507,7 @@ count_uses (rtx *loc, void *cuip)
 		}
 	    }
 
-	  val = find_use_val (*loc, mode, cui);
+	  val = find_use_val (loc, mode, cui);
 	  if (val)
 	    cselib_preserve_value (val);
 	  else
@@ -4590,8 +4591,9 @@ count_with_sets (rtx insn, struct cselib
    to VTI (bb)->mos.  INSN is instruction which the LOC is part of.  */
 
 static int
-add_uses (rtx *loc, void *data)
+add_uses (rtx *ploc, void *data)
 {
+  rtx loc = *ploc;
   enum machine_mode mode = VOIDmode;
   struct count_use_info *cui = (struct count_use_info *)data;
   enum micro_operation_type type = use_type (loc, cui, &mode);
@@ -4602,12 +4604,12 @@ add_uses (rtx *loc, void *data)
       micro_operation *mo = VTI (bb)->mos + VTI (bb)->n_mos++;
 
       mo->type = type;
-      mo->u.loc = type == MO_USE ? var_lowpart (mode, *loc) : *loc;
+      mo->u.loc = type == MO_USE ? var_lowpart (mode, loc) : loc;
       mo->insn = cui->insn;
 
       if (type == MO_VAL_LOC)
 	{
-	  rtx oloc = *loc;
+	  rtx oloc = loc;
 	  rtx vloc = PAT_VAR_LOCATION_LOC (oloc);
 	  cselib_val *val;
 
@@ -4655,7 +4657,7 @@ add_uses (rtx *loc, void *data)
 
 	      oloc = gen_rtx_CONCAT (mode, val->val_rtx, oloc);
 
-	      type2 = use_type (&vloc, 0, &mode2);
+	      type2 = use_type (vloc, 0, &mode2);
 
 	      gcc_assert (type2 == MO_USE || type2 == MO_USE_NO_VAR
 			  || type2 == MO_CLOBBER);
@@ -4679,8 +4681,8 @@ add_uses (rtx *loc, void *data)
 	{
 	  enum machine_mode mode2 = VOIDmode;
 	  enum micro_operation_type type2;
-	  cselib_val *val = find_use_val (*loc, GET_MODE (*loc), cui);
-	  rtx vloc, oloc = *loc, nloc;
+	  cselib_val *val = find_use_val (loc, GET_MODE (loc), cui);
+	  rtx vloc, oloc = loc, nloc;
 
 	  gcc_assert (cui->sets);
 
@@ -4718,7 +4720,7 @@ add_uses (rtx *loc, void *data)
 		      || type2 == MO_CLOBBER);
 
 	  if (type2 == MO_USE)
-	    vloc = var_lowpart (mode2, *loc);
+	    vloc = var_lowpart (mode2, loc);
 	  else
 	    vloc = oloc;
 
@@ -4732,7 +4734,7 @@ add_uses (rtx *loc, void *data)
 
 	  */
 
-	  nloc = replace_expr_with_values (*loc);
+	  nloc = replace_expr_with_values (loc);
 	  if (!nloc)
 	    nloc = oloc;
 
@@ -4781,7 +4783,7 @@ add_stores (rtx loc, const_rtx expr, voi
   basic_block bb = cui->bb;
   micro_operation *mo;
   rtx oloc = loc, nloc, src = NULL;
-  enum micro_operation_type type = use_type (&loc, cui, &mode);
+  enum micro_operation_type type = use_type (loc, cui, &mode);
   bool track_p = false;
   cselib_val *v;
   bool resolve, preserve;
@@ -4796,7 +4798,7 @@ add_stores (rtx loc, const_rtx expr, voi
       mo = VTI (bb)->mos + VTI (bb)->n_mos++;
 
       if ((GET_CODE (expr) == CLOBBER && type != MO_VAL_SET)
-	  || !(track_p = use_type (&loc, NULL, &mode2) == MO_USE)
+	  || !(track_p = use_type (loc, NULL, &mode2) == MO_USE)
 	  || GET_CODE (expr) == CLOBBER)
 	{
 	  mo->type = MO_CLOBBER;
@@ -4829,7 +4831,7 @@ add_stores (rtx loc, const_rtx expr, voi
       mo->insn = cui->insn;
     }
   else if (MEM_P (loc)
-	   && ((track_p = use_type (&loc, NULL, &mode2) == MO_USE)
+	   && ((track_p = use_type (loc, NULL, &mode2) == MO_USE)
 	       || cui->sets))
     {
       mo = VTI (bb)->mos + VTI (bb)->n_mos++;
for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR debug/41679
	* var-tracking.c (count_uses): Count MO_VAL_USE of original
	MO_VAL_SET value for COND_EXEC.
	(add_stores): Handle conditional stores.

Index: gcc/var-tracking.c
===================================================================
--- gcc/var-tracking.c.orig	2009-11-23 04:05:12.000000000 -0200
+++ gcc/var-tracking.c	2009-11-23 04:05:59.000000000 -0200
@@ -4509,7 +4509,28 @@ count_uses (rtx *ploc, void *cuip)
 
 	  val = find_use_val (loc, mode, cui);
 	  if (val)
-	    cselib_preserve_value (val);
+	    {
+	      if (mopt == MO_VAL_SET
+		  && GET_CODE (PATTERN (cui->insn)) == COND_EXEC
+		  && (REG_P (loc)
+		      || (MEM_P (loc)
+			  && (use_type (loc, NULL, NULL) == MO_USE
+			      || cui->sets))))
+		{
+		  cselib_val *oval = cselib_lookup (loc, GET_MODE (loc), 0);
+
+		  gcc_assert (oval != val);
+		  gcc_assert (REG_P (loc) || MEM_P (loc));
+
+		  if (!cselib_preserved_value_p (oval))
+		    {
+		      VTI (cui->bb)->n_mos++;
+		      cselib_preserve_value (oval);
+		    }
+		}
+
+	      cselib_preserve_value (val);
+	    }
 	  else
 	    gcc_assert (mopt == MO_VAL_LOC);
 
@@ -4905,7 +4926,32 @@ add_stores (rtx loc, const_rtx expr, voi
   if (nloc)
     oloc = nloc;
 
-  if (resolve && GET_CODE (mo->u.loc) == SET)
+  if (GET_CODE (PATTERN (cui->insn)) == COND_EXEC)
+    {
+      cselib_val *oval = cselib_lookup (oloc, GET_MODE (oloc), 0);
+
+      gcc_assert (oval != v);
+      gcc_assert (REG_P (oloc) || MEM_P (oloc));
+
+      if (!cselib_preserved_value_p (oval))
+	{
+	  micro_operation *nmo = VTI (bb)->mos + VTI (bb)->n_mos++;
+
+	  cselib_preserve_value (oval);
+
+	  nmo->type = MO_VAL_USE;
+	  nmo->u.loc = gen_rtx_CONCAT (mode, oval->val_rtx, oloc);
+	  VAL_NEEDS_RESOLUTION (nmo->u.loc) = 1;
+	  nmo->insn = mo->insn;
+
+	  if (dump_file && (dump_flags & TDF_DETAILS))
+	    log_op_type (nmo->u.loc, cui->bb, cui->insn,
+			 nmo->type, dump_file);
+	}
+
+      resolve = false;
+    }
+  else if (resolve && GET_CODE (mo->u.loc) == SET)
     {
       nloc = replace_expr_with_values (SET_SRC (expr));
 
-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

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