re PR tree-optimization/25680 (Store CCP does not understand REALPART_EXPR < COMPLEX_...
authorAndrew Pinski <pinskia@physics.uc.edu>
Sat, 18 Feb 2006 21:09:35 +0000 (21:09 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sat, 18 Feb 2006 21:09:35 +0000 (13:09 -0800)
2006-02-18  Andrew Pinski  <pinskia@physics.uc.edu>

        PR tree-opt/25680
        * tree-ssa-ccp.c (ccp_fold): Handle store CCP of REALPART_EXPR and
        IMAGPART_EXPR.
2006-02-18  Andrew Pinski  <pinskia@physics.uc.edu>

        PR tree-opt/25680
        * testsuite/gcc.dg/tree-ssa/complex-3.c: New test.

From-SVN: r111251

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/complex-3.c
gcc/tree-ssa-ccp.c

index f2ccbca6139e839d2eb59d2c6645d1b1e886f313..851936294ca50c455b4c996a3ec43891d8d1a9be 100644 (file)
@@ -1,3 +1,9 @@
+2006-02-18  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR tree-opt/25680
+       * tree-ssa-ccp.c (ccp_fold): Handle store CCP of REALPART_EXPR and
+       IMAGPART_EXPR.
+
 2006-02-18  Diego Novillo  <dnovillo@redhat.com>
 
        * tree-flow.h (struct var_ann_d): Rename field is_alias_tag to
index df5cb4c6c90e913cb333e30f5066dfb461e1bb4a..f705bddb63996b4e43f9f5fe1dc973309e5e61e7 100644 (file)
@@ -1,3 +1,8 @@
+2006-02-18  Andrew Pinski  <pinskia@physics.uc.edu>
+
+        PR tree-opt/25680
+        * testsuite/gcc.dg/tree-ssa/complex-3.c: New test.
+
 2006-02-18  Andrew Pinski  <pinskia@physics.uc.edu>
 
        * gcc.dg/tree-ssa/20031106-1.c: Fix the final scan of the
index 5f4b110c6f85be34dd4f73a55315a63475f1af68..a3544955f7016b3d7fdd44df124934c49a5d3c1c 100644 (file)
@@ -1,3 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+int g(_Complex int*);
+int f(void)
+{
+  _Complex int t = 0;
+  int i, j;
+ __real__ t += 2;
+ __imag__ t += 2;
+  return g(&t);
+}
+
+/* { dg-final { scan-tree-dump-times "__complex__" 0 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
 /* { dg-do compile } */
 /* { dg-options "-O -fdump-tree-optimized" } */
 
index 4513f977cd0ff1de8d14ff972d136ecdc74c89d5..ec70c36d6d37d743674a7db5c791790f6fde84c9 100644 (file)
@@ -855,11 +855,19 @@ ccp_fold (tree stmt)
       /* If the RHS is a memory load, see if the VUSEs associated with
         it are a valid constant for that memory load.  */
       prop_value_t *val = get_value_loaded_by (stmt, const_val);
-      if (val && val->mem_ref
-         && operand_equal_p (val->mem_ref, rhs, 0))
-       return val->value;
-      else
-       return NULL_TREE;
+      if (val && val->mem_ref)
+       {
+         if (operand_equal_p (val->mem_ref, rhs, 0))
+           return val->value;
+
+         /* If RHS is extracting REALPART_EXPR or IMAGPART_EXPR of a
+            complex type with a known constant value, return it.  */
+         if ((TREE_CODE (rhs) == REALPART_EXPR
+              || TREE_CODE (rhs) == IMAGPART_EXPR)
+             && operand_equal_p (val->mem_ref, TREE_OPERAND (rhs, 0), 0))
+           return fold_build1 (TREE_CODE (rhs), TREE_TYPE (rhs), val->value);
+       }
+      return NULL_TREE;
     }
 
   /* Unary operators.  Note that we know the single operand must