]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/45212 (FAIL: gcc.target/alpha/pr24178.c scan-assembler ldl.*,18\\\\()
authorRichard Guenther <rguenther@suse.de>
Mon, 9 Aug 2010 11:43:23 +0000 (11:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 9 Aug 2010 11:43:23 +0000 (11:43 +0000)
2010-08-09  Richard Guenther  <rguenther@suse.de>

PR middle-end/45212
* emit-rtl.c (set_mem_attributes_minus_bitpos): Adjust
alignment from MEM_REF offset only if we took it from the
base object.

* gcc.target/i386/pr24178.c: New testcase.

From-SVN: r163029

gcc/ChangeLog
gcc/emit-rtl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr24178.c [new file with mode: 0644]

index 00d54bc97d67708e97c8ab2ac6100e47f6befd25..ace409d7e7b2a23c2afbba18eb1b30b365d42f4d 100644 (file)
@@ -1,3 +1,10 @@
+2010-08-09  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/45212
+       * emit-rtl.c (set_mem_attributes_minus_bitpos): Adjust
+       alignment from MEM_REF offset only if we took it from the
+       base object.
+
 2010-08-09  Eric Fisher <joefoxreal@gmail.com>
 
        * doc/sourcebuild.texi (vect_int_mult): Remove duplicate entry.
index fe8de9bcdabb4b4793bdbe16e114b3650177657d..91c5d8575e001407e9115102cc77b9a381c12f88 100644 (file)
@@ -1587,29 +1587,31 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
   else if (TREE_CODE (t) == MEM_REF)
     {
       tree op0 = TREE_OPERAND (t, 0);
-      unsigned HOST_WIDE_INT aoff = BITS_PER_UNIT;
-      if (host_integerp (TREE_OPERAND (t, 1), 1))
+      if (TREE_CODE (op0) == ADDR_EXPR
+         && (DECL_P (TREE_OPERAND (op0, 0))
+             || CONSTANT_CLASS_P (TREE_OPERAND (op0, 0))))
        {
-         unsigned HOST_WIDE_INT ioff = TREE_INT_CST_LOW (TREE_OPERAND (t, 1));
-         aoff = (ioff & -ioff) * BITS_PER_UNIT;
-       }
-      if (TREE_CODE (op0) == ADDR_EXPR && DECL_P (TREE_OPERAND (op0, 0)))
-       align = MAX (align, DECL_ALIGN (TREE_OPERAND (op0, 0)));
-      else if (TREE_CODE (op0) == ADDR_EXPR
-              && CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)))
-       {
-         align = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (op0, 0)));
+         if (DECL_P (TREE_OPERAND (op0, 0)))
+           align = DECL_ALIGN (TREE_OPERAND (op0, 0));
+         else if (CONSTANT_CLASS_P (TREE_OPERAND (op0, 0)))
+           {
+             align = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (op0, 0)));
 #ifdef CONSTANT_ALIGNMENT
-         align = CONSTANT_ALIGNMENT (TREE_OPERAND (op0, 0), align);
+             align = CONSTANT_ALIGNMENT (TREE_OPERAND (op0, 0), align);
 #endif
+           }
+         if (TREE_INT_CST_LOW (TREE_OPERAND (t, 1)) != 0)
+           {
+             unsigned HOST_WIDE_INT ioff
+               = TREE_INT_CST_LOW (TREE_OPERAND (t, 1));
+             unsigned HOST_WIDE_INT aoff = (ioff & -ioff) * BITS_PER_UNIT;
+             align = MIN (aoff, align);
+           }
        }
       else
        /* ??? This isn't fully correct, we can't set the alignment from the
           type in all cases.  */
        align = MAX (align, TYPE_ALIGN (type));
-
-      if (!integer_zerop (TREE_OPERAND (t, 1)) && aoff < align)
-       align = aoff;
     }
 
   else if (TREE_CODE (t) == MISALIGNED_INDIRECT_REF)
index 175f10195e77ca76927fbe5fe3fec96c6a680e87..4455729fe4a86444409384191d53995f5e0563d2 100644 (file)
@@ -1,3 +1,12 @@
+2010-08-09  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/45212
+       * emit-rtl.c (set_mem_attributes_minus_bitpos): Adjust
+       alignment from MEM_REF offset only if we took it from the
+       base object.
+
+       * gcc.target/i386/pr24178.c: New testcase.
+
 2010-08-08  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.dg/20030107-1.c: Do not call cleanup-coverage-files.
diff --git a/gcc/testsuite/gcc.target/i386/pr24178.c b/gcc/testsuite/gcc.target/i386/pr24178.c
new file mode 100644 (file)
index 0000000..b1a9208
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-rtl-expand" } */
+
+struct S {
+    int l;
+    unsigned char c;
+};
+unsigned long f(unsigned char *p10) {
+    struct S *p = (struct S *) (p10 + 10);
+    return p->c;
+}
+
+/* The p->c memory access should have alignment of 4 bytes.  */
+
+/* { dg-final { scan-rtl-dump "MEM\[^\\n\]*A32" "expand" } } */
+/* { dg-final { cleanup-rtl-dump "expand" } } */