]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/36093 (__align__ produces incorrect results in certain cases)
authorRichard Guenther <rguenther@suse.de>
Thu, 1 May 2008 11:15:32 +0000 (11:15 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 1 May 2008 11:15:32 +0000 (11:15 +0000)
2008-05-01  Richard Guenther  <rguenther@suse.de>

PR middle-end/36093
Backport from mainline
2007-04-12  Richard Guenther  <rguenther@suse.de>

        * gimplify.c (canonicalize_addr_expr): To be consistent with
        gimplify_compound_lval only set operands two and three of
        ARRAY_REFs if they are not gimple_min_invariant.  This makes
        it never at this place.
        * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.

* gcc.c-torture/execute/pr36093.c: New testcase.

From-SVN: r134849

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr36093.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 0815f0aeb1c7a57e448d157b9799636d1e0b2dcb..f0f12a657e7b7ab661963a028baed5b48328bb00 100644 (file)
@@ -1,3 +1,15 @@
+2008-05-01  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/36093
+       Backport from mainline
+       2007-04-12  Richard Guenther  <rguenther@suse.de>
+
+        * gimplify.c (canonicalize_addr_expr): To be consistent with
+        gimplify_compound_lval only set operands two and three of
+        ARRAY_REFs if they are not gimple_min_invariant.  This makes
+        it never at this place.
+        * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.
+
 2008-04-17  Volker Reichelt  <v.reichelt@netcologne.de>
 
        PR c/35744
index 4acaae2936e2686b3d4b9e96668252e7b36792ba..fa2035bc39c9377f8e8f02d9c2840d66939bd497 100644 (file)
@@ -1600,9 +1600,7 @@ canonicalize_addr_expr (tree *expr_p)
   /* All checks succeeded.  Build a new node to merge the cast.  */
   *expr_p = build4 (ARRAY_REF, dctype, obj_expr,
                    TYPE_MIN_VALUE (TYPE_DOMAIN (datype)),
-                   TYPE_MIN_VALUE (TYPE_DOMAIN (datype)),
-                   size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (dctype),
-                               size_int (TYPE_ALIGN_UNIT (dctype))));
+                   NULL_TREE, NULL_TREE);
   *expr_p = build1 (ADDR_EXPR, ctype, *expr_p);
 }
 
index 372b94b51f6e410c9a704a3a288d0bb91443f4e7..fd3820e0ef4877057fd09e868cd393acb8112b4b 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-01  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/36093
+       * gcc.c-torture/execute/pr36093.c: New testcase.
+
 2008-04-17  Volker Reichelt  <v.reichelt@netcologne.de>
 
        PR c/35744
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr36093.c b/gcc/testsuite/gcc.c-torture/execute/pr36093.c
new file mode 100644 (file)
index 0000000..9549bc3
--- /dev/null
@@ -0,0 +1,28 @@
+extern void abort (void);
+
+typedef struct Bar {
+      char c[129];
+} Bar __attribute__((__aligned__(128)));
+
+typedef struct Foo {
+      Bar bar[4];
+} Foo;
+
+Foo foo[4];
+
+int main()
+{
+   int i, j;
+   Foo *foop = &foo[0];
+
+   for (i=0; i < 4; i++) {
+      Bar *bar = &foop->bar[i];
+      for (j=0; j < 129; j++) {
+         bar->c[j] = 'a' + i;
+      }
+   }
+
+   if (foo[0].bar[3].c[128] != 'd')
+     abort ();
+   return 0;
+}
index f485b02e4cf220b0324fc84641d8d58c1afcfaa8..162191b87751123fdd36ac0104310f306a8ee348 100644 (file)
@@ -1620,9 +1620,7 @@ maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type)
   if (!integer_zerop (elt_offset))
     idx = int_const_binop (PLUS_EXPR, idx, elt_offset, 0);
 
-  return build4 (ARRAY_REF, orig_type, base, idx, min_idx,
-                size_int (tree_low_cst (elt_size, 1)
-                          / (TYPE_ALIGN_UNIT (elt_type))));
+  return build4 (ARRAY_REF, orig_type, base, idx, NULL_TREE, NULL_TREE);
 }