re PR tree-optimization/49094 (ARM aligned(1) attribute is sometimes dropped)
authorMartin Jambor <mjambor@suse.cz>
Thu, 30 Jun 2011 13:24:19 +0000 (15:24 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 30 Jun 2011 13:24:19 +0000 (15:24 +0200)
2011-06-30  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/49094
* tree-sra.c (tree_non_mode_aligned_mem_p): New function.
(build_accesses_from_assign): Use it.

* testsuite/gcc.dg/tree-ssa/pr49094.c: New test.

From-SVN: r175703

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr49094.c [new file with mode: 0644]
gcc/tree-sra.c

index cf9bfa218dad3ca52894dc6f08977d0dbf034569..17f1cd8681a6f137fe534d3603afead90ac6b371 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-30  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/49094
+       * tree-sra.c (tree_non_mode_aligned_mem_p): New function.
+       (build_accesses_from_assign): Use it.
+
 2011-06-30  Jakub Jelinek  <jakub@redhat.com>
 
        * tree-ssa-structalias.c (find_func_aliases_for_builtin_call): Fix
index d2e9ee678755d614243cfc8f2bee3af8cafcad31..ead74b9055a14be1d79d37fdd0cdb6bf7fab748c 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-30  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/49094
+       * gcc.dg/tree-ssa/pr49094.c: New test.
+
 2011-06-30  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/49540
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr49094.c b/gcc/testsuite/gcc.dg/tree-ssa/pr49094.c
new file mode 100644 (file)
index 0000000..5e565f7
--- /dev/null
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-O" } */
+
+struct in_addr {
+       unsigned int s_addr;
+};
+
+struct ip {
+       unsigned char ip_p;
+       unsigned short ip_sum;
+       struct  in_addr ip_src,ip_dst;
+} __attribute__ ((aligned(1), packed));
+
+struct ip ip_fw_fwd_addr;
+
+int test_alignment( char *m )
+{
+  struct ip *ip = (struct ip *) m;
+  struct in_addr pkt_dst;
+  pkt_dst = ip->ip_dst ;
+  if( pkt_dst.s_addr == 0 )
+    return 1;
+  else
+    return 0;
+}
+
+int __attribute__ ((noinline, noclone))
+intermediary (char *p)
+{
+  return test_alignment (p);
+}
+
+int
+main (int argc, char *argv[])
+{
+  ip_fw_fwd_addr.ip_dst.s_addr = 1;
+  return intermediary ((void *) &ip_fw_fwd_addr);
+}
index 45ebd93698d37c15420bc1f9ea943818a54840a4..e45ff8a027268c41f1f9cc5216da06fcf30ef82e 100644 (file)
@@ -1050,6 +1050,26 @@ disqualify_ops_if_throwing_stmt (gimple stmt, tree lhs, tree rhs)
   return false;
 }
 
+/* Return true iff type of EXP is not sufficiently aligned.  */
+
+static bool
+tree_non_mode_aligned_mem_p (tree exp)
+{
+  enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
+  unsigned int align;
+
+  if (TREE_CODE (exp) == SSA_NAME
+      || mode == BLKmode
+      || !STRICT_ALIGNMENT)
+    return false;
+
+  align = get_object_alignment (exp, BIGGEST_ALIGNMENT);
+  if (GET_MODE_ALIGNMENT (mode) > align)
+    return true;
+
+  return false;
+}
+
 /* Scan expressions occuring in STMT, create access structures for all accesses
    to candidates for scalarization and remove those candidates which occur in
    statements or expressions that prevent them from being split apart.  Return
@@ -1074,7 +1094,10 @@ build_accesses_from_assign (gimple stmt)
   lacc = build_access_from_expr_1 (lhs, stmt, true);
 
   if (lacc)
-    lacc->grp_assignment_write = 1;
+    {
+      lacc->grp_assignment_write = 1;
+      lacc->grp_unscalarizable_region |= tree_non_mode_aligned_mem_p (rhs);
+    }
 
   if (racc)
     {
@@ -1082,6 +1105,7 @@ build_accesses_from_assign (gimple stmt)
       if (should_scalarize_away_bitmap && !gimple_has_volatile_ops (stmt)
          && !is_gimple_reg_type (racc->type))
        bitmap_set_bit (should_scalarize_away_bitmap, DECL_UID (racc->base));
+      racc->grp_unscalarizable_region |= tree_non_mode_aligned_mem_p (lhs);
     }
 
   if (lacc && racc