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: SRA changes


On Fri, Jan 16, 2004 at 01:48:16PM -0700, law@redhat.com wrote:
> BTW, these appear to be causing a regression in the fortran testsuite
> (intrinsic_transpose.f90).  Have you tripped over that yet?

This was a problem of not noticing that there was a complex 
comparison, and thus not having put all the pieces back 
together in the right place.  Rather than change SRA, enhance
the complex decomposition code to handle comparisons.


r~


        * tree-complex.c (expand_complex_comparison): New.
        (expand_complex_operations_1): Handle EQ_EXPR and NE_EXPR.

Index: tree-complex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-complex.c,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 tree-complex.c
--- tree-complex.c	14 Jan 2004 09:39:27 -0000	1.1.2.1
+++ tree-complex.c	17 Jan 2004 20:00:27 -0000
@@ -372,13 +372,34 @@ expand_complex_conjugate (block_stmt_ite
   update_complex_assignment (bsi, ar, ri);
 }
 
+/* Expand complex comparison (EQ or NE only).  */
+
+static void
+expand_complex_comparison (block_stmt_iterator *bsi, tree ar, tree ai,
+			   tree br, tree bi, enum tree_code code)
+{
+  tree cr, ci, cc, stmt;
+
+  cr = do_binop (bsi, code, boolean_type_node, ar, br);
+  ci = do_binop (bsi, code, boolean_type_node, ai, bi);
+  cc = do_binop (bsi, (code == EQ_EXPR ? TRUTH_AND_EXPR : TRUTH_OR_EXPR),
+		 boolean_type_node, cr, ci);
+
+  stmt = bsi_stmt (*bsi);
+  modify_stmt (stmt);
+  if (TREE_CODE (stmt) == RETURN_EXPR)
+    stmt = TREE_OPERAND (stmt, 0);
+  TREE_OPERAND (stmt, 1) = convert (TREE_TYPE (TREE_OPERAND (stmt, 1)), cc);
+}
+
 /* Process one statement.  If we identify a complex operation, expand it.  */
 
 static void
 expand_complex_operations_1 (block_stmt_iterator *bsi)
 {
   tree stmt = bsi_stmt (*bsi);
-  tree rhs, type, inner_type, ac, ar, ai, bc, br, bi;
+  tree rhs, type, inner_type;
+  tree ac, ar, ai, bc, br, bi;
   enum tree_code code;
 
   /* All complex operations are in MODIFY_EXPR statements.  */
@@ -393,10 +414,6 @@ expand_complex_operations_1 (block_stmt_
 
   rhs = TREE_OPERAND (stmt, 1);
   type = TREE_TYPE (rhs);
-  if (TREE_CODE (type) != COMPLEX_TYPE)
-    return;
-
-  inner_type = TREE_TYPE (type);
   code = TREE_CODE (rhs);
 
   /* Initial filter for operations we handle.  */
@@ -412,7 +429,18 @@ expand_complex_operations_1 (block_stmt_
     case RDIV_EXPR:
     case NEGATE_EXPR:
     case CONJ_EXPR:
+      if (TREE_CODE (type) != COMPLEX_TYPE)
+	return;
+      inner_type = TREE_TYPE (type);
+      break;
+
+    case EQ_EXPR:
+    case NE_EXPR:
+      inner_type = TREE_TYPE (TREE_OPERAND (rhs, 1));
+      if (TREE_CODE (inner_type) != COMPLEX_TYPE)
+	return;
       break;
+
     default:
       return;
     }
@@ -462,6 +490,11 @@ expand_complex_operations_1 (block_stmt_
 
     case CONJ_EXPR:
       expand_complex_conjugate (bsi, inner_type, ar, ai);
+      break;
+
+    case EQ_EXPR:
+    case NE_EXPR:
+      expand_complex_comparison (bsi, ar, ai, br, bi, code);
       break;
 
     default:


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