JF Bastien | c6dabb9 | 2013-07-18 06:11:45 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s |
| 2 | |
| 3 | // Validate that volatile _Complex loads and stores are generated |
| 4 | // properly, including their alignment (even when overaligned). |
| 5 | // |
| 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 |
| 8 | // datalayout. |
| 9 | |
| 10 | // CHECK: target datalayout = "{{.*}}f32:32:32-f64:64:64{{.*}}" |
JF Bastien | ab96e56 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 11 | |
| 12 | volatile _Complex float cf; |
| 13 | volatile _Complex double cd; |
| 14 | volatile _Complex float cf32 __attribute__((aligned(32))); |
| 15 | volatile _Complex double cd32 __attribute__((aligned(32))); |
| 16 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 17 | // CHECK-LABEL-LABEL: define void @test_cf() |
JF Bastien | ab96e56 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 18 | void test_cf() { |
NAKAMURA Takumi | ac13d61 | 2013-07-17 06:39:40 +0000 | [diff] [blame] | 19 | // CHECK: load volatile float* getelementptr inbounds ({ float, float }* @cf, i32 0, i32 0), align 4 |
JF Bastien | ab96e56 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 20 | // CHECK-NEXT: load volatile float* getelementptr inbounds ({ float, float }* @cf, i32 0, i32 1), align 4 |
| 21 | (void)(cf); |
| 22 | // CHECK-NEXT: [[R:%.*]] = load volatile float* getelementptr inbounds ({ float, float }* @cf, i32 0, i32 0), align 4 |
| 23 | // CHECK-NEXT: [[I:%.*]] = load volatile float* getelementptr inbounds ({ float, float }* @cf, i32 0, i32 1), align 4 |
| 24 | // CHECK-NEXT: store volatile float [[R]], float* getelementptr inbounds ({ float, float }* @cf, i32 0, i32 0), align 4 |
| 25 | // CHECK-NEXT: store volatile float [[I]], float* getelementptr inbounds ({ float, float }* @cf, i32 0, i32 1), align 4 |
| 26 | (void)(cf=cf); |
| 27 | // CHECK-NEXT: ret void |
| 28 | } |
| 29 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 30 | // CHECK-LABEL-LABEL: define void @test_cd() |
JF Bastien | ab96e56 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 31 | void test_cd() { |
NAKAMURA Takumi | ac13d61 | 2013-07-17 06:39:40 +0000 | [diff] [blame] | 32 | // CHECK: load volatile double* getelementptr inbounds ({ double, double }* @cd, i32 0, i32 0), align 8 |
JF Bastien | ab96e56 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 33 | // CHECK-NEXT: load volatile double* getelementptr inbounds ({ double, double }* @cd, i32 0, i32 1), align 8 |
| 34 | (void)(cd); |
| 35 | // CHECK-NEXT: [[R:%.*]] = load volatile double* getelementptr inbounds ({ double, double }* @cd, i32 0, i32 0), align 8 |
| 36 | // CHECK-NEXT: [[I:%.*]] = load volatile double* getelementptr inbounds ({ double, double }* @cd, i32 0, i32 1), align 8 |
| 37 | // CHECK-NEXT: store volatile double [[R]], double* getelementptr inbounds ({ double, double }* @cd, i32 0, i32 0), align 8 |
| 38 | // CHECK-NEXT: store volatile double [[I]], double* getelementptr inbounds ({ double, double }* @cd, i32 0, i32 1), align 8 |
| 39 | (void)(cd=cd); |
| 40 | // CHECK-NEXT: ret void |
| 41 | } |
| 42 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 43 | // CHECK-LABEL-LABEL: define void @test_cf32() |
JF Bastien | ab96e56 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 44 | void test_cf32() { |
NAKAMURA Takumi | ac13d61 | 2013-07-17 06:39:40 +0000 | [diff] [blame] | 45 | // CHECK: load volatile float* getelementptr inbounds ({ float, float }* @cf32, i32 0, i32 0), align 32 |
JF Bastien | ab96e56 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 46 | // CHECK-NEXT: load volatile float* getelementptr inbounds ({ float, float }* @cf32, i32 0, i32 1), align 4 |
| 47 | (void)(cf32); |
| 48 | // CHECK-NEXT: [[R:%.*]] = load volatile float* getelementptr inbounds ({ float, float }* @cf32, i32 0, i32 0), align 32 |
| 49 | // CHECK-NEXT: [[I:%.*]] = load volatile float* getelementptr inbounds ({ float, float }* @cf32, i32 0, i32 1), align 4 |
| 50 | // CHECK-NEXT: store volatile float [[R]], float* getelementptr inbounds ({ float, float }* @cf32, i32 0, i32 0), align 32 |
| 51 | // CHECK-NEXT: store volatile float [[I]], float* getelementptr inbounds ({ float, float }* @cf32, i32 0, i32 1), align 4 |
| 52 | (void)(cf32=cf32); |
| 53 | // CHECK-NEXT: ret void |
| 54 | } |
| 55 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 56 | // CHECK-LABEL-LABEL: define void @test_cd32() |
JF Bastien | ab96e56 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 57 | void test_cd32() { |
NAKAMURA Takumi | ac13d61 | 2013-07-17 06:39:40 +0000 | [diff] [blame] | 58 | // CHECK: load volatile double* getelementptr inbounds ({ double, double }* @cd32, i32 0, i32 0), align 32 |
JF Bastien | ab96e56 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 59 | // CHECK-NEXT: load volatile double* getelementptr inbounds ({ double, double }* @cd32, i32 0, i32 1), align 8 |
| 60 | (void)(cd32); |
| 61 | // CHECK-NEXT: [[R:%.*]] = load volatile double* getelementptr inbounds ({ double, double }* @cd32, i32 0, i32 0), align 32 |
| 62 | // CHECK-NEXT: [[I:%.*]] = load volatile double* getelementptr inbounds ({ double, double }* @cd32, i32 0, i32 1), align 8 |
| 63 | // CHECK-NEXT: store volatile double [[R]], double* getelementptr inbounds ({ double, double }* @cd32, i32 0, i32 0), align 32 |
| 64 | // CHECK-NEXT: store volatile double [[I]], double* getelementptr inbounds ({ double, double }* @cd32, i32 0, i32 1), align 8 |
| 65 | (void)(cd32=cd32); |
| 66 | // CHECK-NEXT: ret void |
| 67 | } |