IA MCU psABI support: changes to libraries
[gcc.git] / gcc / tree-ssa.c
index 835e3c12458ee335e1b19e3a581242f504624994..cab627daa1534665cdca4c4c6812126942737f12 100644 (file)
@@ -1,5 +1,5 @@
 /* Miscellaneous SSA utility functions.
-   Copyright (C) 2001-2014 Free Software Foundation, Inc.
+   Copyright (C) 2001-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -21,19 +21,17 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
+#include "alias.h"
+#include "symtab.h"
 #include "tree.h"
+#include "fold-const.h"
 #include "stor-layout.h"
 #include "flags.h"
 #include "tm_p.h"
 #include "target.h"
 #include "langhooks.h"
 #include "predict.h"
-#include "vec.h"
-#include "hashtab.h"
-#include "hash-set.h"
-#include "machmode.h"
 #include "hard-reg-set.h"
-#include "input.h"
 #include "function.h"
 #include "dominance.h"
 #include "cfg.h"
@@ -43,7 +41,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "internal-fn.h"
 #include "gimple-fold.h"
 #include "gimple-expr.h"
-#include "is-a.h"
 #include "gimple.h"
 #include "gimplify.h"
 #include "gimple-iterator.h"
@@ -57,7 +54,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-into-ssa.h"
 #include "tree-ssa.h"
 #include "tree-inline.h"
-#include "hash-map.h"
 #include "tree-pass.h"
 #include "diagnostic-core.h"
 #include "cfgloop.h"
@@ -1330,6 +1326,13 @@ non_rewritable_lvalue_p (tree lhs)
   if (DECL_P (lhs))
     return false;
 
+  /* We can re-write REALPART_EXPR and IMAGPART_EXPR sets in
+     a reasonably efficient manner... */
+  if ((TREE_CODE (lhs) == REALPART_EXPR
+       || TREE_CODE (lhs) == IMAGPART_EXPR)
+      && DECL_P (TREE_OPERAND (lhs, 0)))
+    return false;
+
   /* A decl that is wrapped inside a MEM-REF that covers
      it full is also rewritable.
      ???  The following could be relaxed allowing component
@@ -1534,6 +1537,37 @@ execute_update_addresses_taken (void)
                tree rhs, *rhsp = gimple_assign_rhs1_ptr (stmt);
                tree sym;
 
+               /* Rewrite LHS IMAG/REALPART_EXPR similar to
+                  gimplify_modify_expr_complex_part.  */
+               if ((TREE_CODE (lhs) == IMAGPART_EXPR
+                    || TREE_CODE (lhs) == REALPART_EXPR)
+                   && DECL_P (TREE_OPERAND (lhs, 0))
+                   && bitmap_bit_p (suitable_for_renaming,
+                                    DECL_UID (TREE_OPERAND (lhs, 0))))
+                 {
+                   tree other = make_ssa_name (TREE_TYPE (lhs));
+                   tree lrhs = build1 (TREE_CODE (lhs) == IMAGPART_EXPR
+                                       ? REALPART_EXPR : IMAGPART_EXPR,
+                                       TREE_TYPE (other),
+                                       TREE_OPERAND (lhs, 0));
+                   gimple load = gimple_build_assign (other, lrhs);
+                   location_t loc = gimple_location (stmt);
+                   gimple_set_location (load, loc);
+                   gimple_set_vuse (load, gimple_vuse (stmt));
+                   gsi_insert_before (&gsi, load, GSI_SAME_STMT);
+                   gimple_assign_set_lhs (stmt, TREE_OPERAND (lhs, 0));
+                   gimple_assign_set_rhs_with_ops
+                     (&gsi, COMPLEX_EXPR,
+                      TREE_CODE (lhs) == IMAGPART_EXPR
+                      ? other : gimple_assign_rhs1 (stmt),
+                      TREE_CODE (lhs) == IMAGPART_EXPR
+                      ? gimple_assign_rhs1 (stmt) : other, NULL_TREE);
+                   stmt = gsi_stmt (gsi);
+                   unlink_stmt_vdef (stmt);
+                   update_stmt (stmt);
+                   continue;
+                 }
+
                /* We shouldn't have any fancy wrapping of
                   component-refs on the LHS, but look through
                   VIEW_CONVERT_EXPRs as that is easy.  */