This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix PR middle-end/44843

As diagnosed by Richard G, there is a wrong assumption in the code handling 
MEM_REF in set_mem_attributes_minus_bitpos.  This replaces it with a much 
less wrong assumption, as suggested by Richard.

Tested on SPARC/Solaris and SPARC64/Solaris, applied on the mainline.

2010-07-08  Eric Botcazou  <>

	PR middle-end/44843
	* emit-rtl.c (set_mem_attributes_minus_bitpos): Do not rely on the
	pointed-to type of the offset in a MEM_REF to compute the alignment.

2010-07-08  Mikael Pettersson  <>

	* gcc.c-torture/execute/20100708-1.c: New test.

Eric Botcazou
Index: emit-rtl.c
--- emit-rtl.c	(revision 161961)
+++ emit-rtl.c	(working copy)
@@ -1634,10 +1634,9 @@ set_mem_attributes_minus_bitpos (rtx ref
-	/* This technically isn't correct.  We can't really derive
-	   alignment information from types.  */
-	align = MAX (align,
+	/* ??? 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;
/* PR middle-end/44843 */
/* Verify that we don't use the alignment of struct S for inner accesses.  */

struct S
  double for_alignment;
  struct { int x, y, z; } a[16];

void f(struct S *s) __attribute__((noinline));

void f(struct S *s)
  unsigned int i;

  for (i = 0; i < 16; ++i)
      s->a[i].x = 0;
      s->a[i].y = 0;
      s->a[i].z = 0;

int main (void)
  struct S s;
  f (&s);
  return 0;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]