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]

[tree-ssa] Fix LHS with BIT_FIELD_REF, take 3


Hello,

this is the updated version of my patch to handle BIT_FIELD_REFs correctly.
BIT_FIELD_REFs on the left side of MODIFY_EXPRs are never produced
(at least in 3.2, 3.5 mainline and 3.5 tree-ssa which were the trees I had
at hand), still I added the check that its operand is not a register.

Diego in the end convinced me that the change to get_expr_operands was
wrong, because my test case did not fail actually. :-/  Sorry, I was
reading

        add_stmt_operand (expr_p, stmt, flags, prev_vops);

as

        add_stmt_operand (&TREE_OPERAND (expr, 0), stmt, flags, prev_vops);

somehow.  I must apologize to Diego for being this kind of
preposterous.  This patch includes the additional consistency check that
he suggested in get_virtual_var.

Bootstrapped/regtested on i686-pc-linux-gnu, all languages except f95, 
ok to apply?

2004-03-24  Paolo Bonzini  <bonzini@gnu.org>

	* tree-alias-common.c (find_func_aliases): Support
	assigning to BIT_FIELD_REFs.
	* tree-cfg.c (verify_expr): Don't allow assign to
	a register with BIT_FIELD_REF.
	* tree-dfa.c (get_virtual_var): Add consistency check on
	the shape of expected VARs.
	(discover_nonconstant_array_refs_r): Go through BIT_FIELD_REFs.
	* tree-simple.c: Document that BIT_FIELD_REFs are valid lvalues.
	* tree-ssa.c (set_is_used): Go through BIT_FIELD_REFs.

2004-03-24  Paolo Bonzini  <bonzini@gnu.org>

	* gcc.dg/tree-ssa/20040324-1.c: New testcase.

Index: tree-alias-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-common.c,v
retrieving revision 1.1.2.53
diff -u -r1.1.2.53 tree-alias-common.c
--- tree-alias-common.c	12 Mar 2004 17:49:52 -0000	1.1.2.53
+++ tree-alias-common.c	25 Mar 2004 10:06:05 -0000
@@ -629,7 +629,8 @@
       else
 	{
 	  /* x.f = y  or x->f = y */
-	  if (TREE_CODE (op0) == COMPONENT_REF 
+	  if ((TREE_CODE (op0) == COMPONENT_REF 
+	       || TREE_CODE (op0) == BIT_FIELD_REF)
 	      && is_gimple_variable (op1))
 	    {
 	      if (rhsAV != NULL)
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.278
diff -u -r1.1.4.278 tree-cfg.c
--- tree-cfg.c	16 Mar 2004 22:31:55 -0000	1.1.4.278
+++ tree-cfg.c	25 Mar 2004 10:06:05 -0000
@@ -2938,6 +2938,16 @@
 	}
       break;
 
+    case MODIFY_EXPR:
+      x = TREE_OPERAND (t, 0);
+      if (TREE_CODE (x) == BIT_FIELD_REF
+	  && is_gimple_reg (TREE_OPERAND (x, 0)))
+	{
+	  error ("GIMPLE register modified with BIT_FIELD_REF");
+	  return *tp;
+	}
+      break;
+
     case ADDR_EXPR:
       x = TREE_OPERAND (t, 0);
       while (TREE_CODE (x) == ARRAY_REF
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.222
diff -u -r1.1.4.222 tree-dfa.c
--- tree-dfa.c	19 Mar 2004 17:51:45 -0000	1.1.4.222
+++ tree-dfa.c	25 Mar 2004 10:06:06 -0000
@@ -990,6 +992,12 @@
       code = TREE_CODE (var);
     }
 
+#ifdef ENABLE_CHECKING
+  if (!SSA_VAR_P (var)
+      || is_gimple_reg (var))
+    abort ();
+#endif
+
   return var;
 }
 
@@ -1222,6 +1230,7 @@
       while ((TREE_CODE (t) == ARRAY_REF
 	      && is_gimple_min_invariant (TREE_OPERAND (t, 1)))
 	     || (TREE_CODE (t) == COMPONENT_REF
+		 || TREE_CODE (t) == BIT_FIELD_REF
 		 || TREE_CODE (t) == REALPART_EXPR
 		 || TREE_CODE (t) == IMAGPART_EXPR))
 	t = TREE_OPERAND (t, 0);
Index: tree-simple.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-simple.c,v
retrieving revision 1.1.4.74
diff -u -r1.1.4.74 tree-simple.c
--- tree-simple.c	12 Mar 2004 04:19:06 -0000	1.1.4.74
+++ tree-simple.c	25 Mar 2004 10:06:08 -0000
@@ -113,8 +113,13 @@
      op1 -> arglist
 
    addr-expr-arg : compref | ID
-   lhs: addr-expr-arg | '*' ID
+   lhs: addr-expr-arg | '*' ID | bitfieldref
    min-lval: ID | '*' ID
+   bitfieldref :
+     BIT_FIELD_REF
+       op0 -> compref | min-lval
+       op1 -> CONST
+       op2 -> CONST
    compref :
      COMPONENT_REF
        op0 -> compref | min-lval
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.216
diff -u -r1.1.4.216 tree-ssa.c
--- tree-ssa.c	19 Mar 2004 02:07:25 -0000	1.1.4.216
+++ tree-ssa.c	25 Mar 2004 10:06:09 -0000
@@ -435,6 +435,7 @@
 	case COMPONENT_REF:
 	case REALPART_EXPR:
 	case IMAGPART_EXPR:
+	case BIT_FIELD_REF:
 	case INDIRECT_REF:
 	  t = TREE_OPERAND (t, 0);
 	  break;


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