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