2 /* { dg-options "-O" } */
4 extern void abort (void);
9 __attribute__((aligned(32))) inner_t
; // data type is 32 byte aligned
16 void __attribute__ ((noinline
,weak
))
17 somefunc (int a
, int b
, int c
)
23 __attribute__ ((noinline
,weak
))
31 __attribute__ ((noinline
,weak
))
42 // @p_out is pointing to instance of outer_t, naturally aligned to 4+4 = 8
43 // and not gauranteed be 32 byte aligned.
44 outer_t
*p_out
= some_alloc_1( ); // returns 8 byte aligned ptr
46 // @ptr is pointing to instance of inner_t which is naturally aligned to 32.
47 // It is assigned to p_out->inner which is of type inner_t thus 32 byte
49 // Note that gcc can deduce p_out->inner is 32b aligned, not at runtime,
50 // because it was assigned @ptr, but even at compile time, because it's data
51 // type is naturally 32 byte aligned.
52 inner_t
*ptr
= some_alloc_2(); // returns 32 byte aligned ptr
53 p_out
->inner
= ptr
; // this ptr will also be 32 byte aligned
55 y
= __builtin_arc_aligned(ptr
, 32); // this shd return 1
56 y2
= __builtin_arc_aligned(p_out
->inner
, 32); // this also shd return 1
57 // Although p_out->inner ptr is 32 byte aligned,
58 // it's container &(p_out->inner) need not be.
59 // That is because the hoister has no relation to contents.
60 // p_out is not gauranteed to be 32 byte
61 // aligned, so it's member @inner in p_out need not be.
62 y3
= __builtin_arc_aligned(&(p_out
->inner
), 32);
63 // compiler not sure, so must return 0