Fix PR53937

Submitted by Richard Guenther on July 13, 2012, 9:16 a.m.

Details

Message ID alpine.LNX.2.00.1207131114410.17088@jbgna.fhfr.qr
State New
Headers show

Commit Message

Richard Guenther July 13, 2012, 9:16 a.m.
We fail to handle constant addresses in get_pointer_alignment_1
so we use too pessimistic alignment when accessing a packed
structure via such a pointer.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2012-07-13  Richard Guenther  <rguenther@suse.de>

	PR middle-end/53937
	* builtins.c (get_pointer_alignment_1): Handle constant
	pointers.

Patch hide | download patch | download mbox

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 189451)
+++ gcc/builtins.c	(working copy)
@@ -536,6 +536,13 @@  get_pointer_alignment_1 (tree exp, unsig
 	  return false;
 	}
     }
+  else if (TREE_CODE (exp) == INTEGER_CST)
+    {
+      *alignp = BIGGEST_ALIGNMENT;
+      *bitposp = ((TREE_INT_CST_LOW (exp) * BITS_PER_UNIT)
+		  & (BIGGEST_ALIGNMENT - 1));
+      return true;
+    }
 
   *bitposp = 0;
   *alignp = BITS_PER_UNIT;