1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc __attribute((aligned(16))) float a[128];
4*f4a2713aSLionel Sambuc union {int a[4]; __attribute((aligned(16))) float b[4];} b;
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc // CHECK: @a = {{.*}}zeroinitializer, align 16
7*f4a2713aSLionel Sambuc // CHECK: @b = {{.*}}zeroinitializer, align 16
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc long long int test5[1024];
10*f4a2713aSLionel Sambuc // CHECK-DAG: @test5 = common global [1024 x i64] zeroinitializer, align 8
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc // PR5279 - Reduced alignment on typedef.
13*f4a2713aSLionel Sambuc typedef int myint __attribute__((aligned(1)));
14*f4a2713aSLionel Sambuc 
test1(myint * p)15*f4a2713aSLionel Sambuc void test1(myint *p) {
16*f4a2713aSLionel Sambuc   *p = 0;
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc // CHECK: @test1(
19*f4a2713aSLionel Sambuc // CHECK: store i32 0, i32* {{.*}}, align 1
20*f4a2713aSLionel Sambuc // CHECK: ret void
21*f4a2713aSLionel Sambuc 
test1a(myint * p)22*f4a2713aSLionel Sambuc int test1a(myint *p) {
23*f4a2713aSLionel Sambuc   return *p;
24*f4a2713aSLionel Sambuc }
25*f4a2713aSLionel Sambuc // CHECK: @test1a(
26*f4a2713aSLionel Sambuc // CHECK: load i32* {{.*}}, align 1
27*f4a2713aSLionel Sambuc // CHECK: ret i32
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc // PR5279 - Reduced alignment on typedef.
31*f4a2713aSLionel Sambuc typedef float __attribute__((vector_size(16), aligned(4))) packedfloat4;
32*f4a2713aSLionel Sambuc 
test2(packedfloat4 * p)33*f4a2713aSLionel Sambuc void test2(packedfloat4 *p) {
34*f4a2713aSLionel Sambuc   *p = (packedfloat4) { 3.2f, 2.3f, 0.1f, 0.0f };
35*f4a2713aSLionel Sambuc }
36*f4a2713aSLionel Sambuc // CHECK: @test2(
37*f4a2713aSLionel Sambuc // CHECK: store <4 x float> {{.*}}, align 4
38*f4a2713aSLionel Sambuc // CHECK: ret void
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc 
41*f4a2713aSLionel Sambuc // PR5279 - Reduced alignment on typedef.
42*f4a2713aSLionel Sambuc typedef float __attribute__((ext_vector_type(3), aligned(4))) packedfloat3;
test3(packedfloat3 * p)43*f4a2713aSLionel Sambuc void test3(packedfloat3 *p) {
44*f4a2713aSLionel Sambuc   *p = (packedfloat3) { 3.2f, 2.3f, 0.1f };
45*f4a2713aSLionel Sambuc }
46*f4a2713aSLionel Sambuc // CHECK: @test3(
47*f4a2713aSLionel Sambuc // CHECK: %{{.*}} = bitcast <3 x float>* %{{.*}} to <4 x float>*
48*f4a2713aSLionel Sambuc // CHECK: store <4 x float> {{.*}}, align 4
49*f4a2713aSLionel Sambuc // CHECK: ret void
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc 
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc typedef float __attribute__((vector_size(16), aligned(64))) float4align64;
54*f4a2713aSLionel Sambuc 
55*f4a2713aSLionel Sambuc // rdar://10639962 - Typedef alignment lost in p[]-style dereferencing
test4(float4align64 * p)56*f4a2713aSLionel Sambuc void test4(float4align64 *p) {
57*f4a2713aSLionel Sambuc   p[0] = (float4align64){ 3.2f, 2.3f, 0.1f, 0.0f };
58*f4a2713aSLionel Sambuc }
59*f4a2713aSLionel Sambuc // CHECK: @test4(
60*f4a2713aSLionel Sambuc // CHECK: store <4 x float> {{.*}}, <4 x float>* {{.*}}, align 64
61*f4a2713aSLionel Sambuc 
62