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]

[gfortran] Complex type components


We currently get gimplification failures when taking the real or imaginary 
part of a comples expression. Example:
{
  complex z;
  double r;
  r = __real__ (z*z)
}

The patch below makes the gimplifier mandle these like component references, 
rather than array refs. I'm not sure if this was originally an oversight or 
a deliberate decision - they aren't part of the original SIMPLE grammar.

As a related change it also allow REALPART_EXPR and IMAGPART_EXPR as 
operands of an ADDR_EXPR. Without this &__real__ z would silently gimplify 
to the address of a temporary, not the component of the complex value.

Bootstrapped and regtest in progress. Ok it if passes?

Paul

2003-09-10  Paul Brook  <paul@nowt.org>

	* gimplify.c (gimplify_compound_lval): Treat {REAL|IMAG}PART_EXPR the
	same as COMPONENT_REF.
	* tree-simple.c (is_gimple_addr_expr_arg): Ditto.

diff -urpxCVS clean/tree-ssa/gcc/gimplify.c gcc/gcc/gimplify.c
--- clean/tree-ssa/gcc/gimplify.c
+++ gcc/gcc/gimplify.c
@@ -1454,7 +1454,7 @@ gimplify_compound_lval (tree *expr_p, tr
      Gimplify the base, and then process each of the outer nodes from left
      to right.  */
   gimplify_expr (p, pre_p, post_p, is_gimple_min_lval,
-		 code == COMPONENT_REF ? fb_either : fb_lvalue);
+		 code != ARRAY_REF ? fb_either : fb_lvalue);
 
   for (; VARRAY_ACTIVE_SIZE (stack) > 0; VARRAY_POP (stack))
     {
diff -urpxCVS clean/tree-ssa/gcc/tree-simple.c gcc/gcc/tree-simple.c
--- clean/tree-ssa/gcc/tree-simple.c
+++ gcc/gcc/tree-simple.c
@@ -266,7 +266,9 @@ is_gimple_addr_expr_arg (tree t)
 {
   return (is_gimple_id (t)
 	  || TREE_CODE (t) == ARRAY_REF
-	  || TREE_CODE (t) == COMPONENT_REF);
+	  || TREE_CODE (t) == COMPONENT_REF
+	  || TREE_CODE (t) == REALPART_EXPR
+	  || TREE_CODE (t) == IMAGPART_EXPR);
 }
 
 /*  Return nonzero if T is a constant.  This is one of the few predicates


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