1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
3 // Validate that volatile _Complex loads and stores are generated
4 // properly, including their alignment (even when overaligned).
6 // This test assumes that floats are 32-bit aligned and doubles are
7 // 64-bit aligned, and uses x86-64 as a target that should have this
10 volatile _Complex
float cf
;
11 volatile _Complex
double cd
;
12 volatile _Complex
float cf32
__attribute__((aligned(32)));
13 volatile _Complex
double cd32
__attribute__((aligned(32)));
15 // CHECK-LABEL: define{{.*}} void @test_cf()
17 // CHECK: load volatile float, ptr @cf, align 4
18 // CHECK-NEXT: load volatile float, ptr getelementptr inbounds nuw ({ float, float }, ptr @cf, i32 0, i32 1), align 4
20 // CHECK-NEXT: [[R:%.*]] = load volatile float, ptr @cf, align 4
21 // CHECK-NEXT: [[I:%.*]] = load volatile float, ptr getelementptr inbounds nuw ({ float, float }, ptr @cf, i32 0, i32 1), align 4
22 // CHECK-NEXT: store volatile float [[R]], ptr @cf, align 4
23 // CHECK-NEXT: store volatile float [[I]], ptr getelementptr inbounds nuw ({ float, float }, ptr @cf, i32 0, i32 1), align 4
25 // CHECK-NEXT: ret void
28 // CHECK-LABEL: define{{.*}} void @test_cd()
30 // CHECK: load volatile double, ptr @cd, align 8
31 // CHECK-NEXT: load volatile double, ptr getelementptr inbounds nuw ({ double, double }, ptr @cd, i32 0, i32 1), align 8
33 // CHECK-NEXT: [[R:%.*]] = load volatile double, ptr @cd, align 8
34 // CHECK-NEXT: [[I:%.*]] = load volatile double, ptr getelementptr inbounds nuw ({ double, double }, ptr @cd, i32 0, i32 1), align 8
35 // CHECK-NEXT: store volatile double [[R]], ptr @cd, align 8
36 // CHECK-NEXT: store volatile double [[I]], ptr getelementptr inbounds nuw ({ double, double }, ptr @cd, i32 0, i32 1), align 8
38 // CHECK-NEXT: ret void
41 // CHECK-LABEL: define{{.*}} void @test_cf32()
42 void test_cf32(void) {
43 // CHECK: load volatile float, ptr @cf32, align 32
44 // CHECK-NEXT: load volatile float, ptr getelementptr inbounds nuw ({ float, float }, ptr @cf32, i32 0, i32 1), align 4
46 // CHECK-NEXT: [[R:%.*]] = load volatile float, ptr @cf32, align 32
47 // CHECK-NEXT: [[I:%.*]] = load volatile float, ptr getelementptr inbounds nuw ({ float, float }, ptr @cf32, i32 0, i32 1), align 4
48 // CHECK-NEXT: store volatile float [[R]], ptr @cf32, align 32
49 // CHECK-NEXT: store volatile float [[I]], ptr getelementptr inbounds nuw ({ float, float }, ptr @cf32, i32 0, i32 1), align 4
51 // CHECK-NEXT: ret void
54 // CHECK-LABEL: define{{.*}} void @test_cd32()
55 void test_cd32(void) {
56 // CHECK: load volatile double, ptr @cd32, align 32
57 // CHECK-NEXT: load volatile double, ptr getelementptr inbounds nuw ({ double, double }, ptr @cd32, i32 0, i32 1), align 8
59 // CHECK-NEXT: [[R:%.*]] = load volatile double, ptr @cd32, align 32
60 // CHECK-NEXT: [[I:%.*]] = load volatile double, ptr getelementptr inbounds nuw ({ double, double }, ptr @cd32, i32 0, i32 1), align 8
61 // CHECK-NEXT: store volatile double [[R]], ptr @cd32, align 32
62 // CHECK-NEXT: store volatile double [[I]], ptr getelementptr inbounds nuw ({ double, double }, ptr @cd32, i32 0, i32 1), align 8
64 // CHECK-NEXT: ret void