JF Bastien | 2a0a476 | 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 |
Rafael Espindola | c4d672a | 2013-12-16 19:53:26 +0000 | [diff] [blame] | 8 | // property. |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 9 | |
| 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))); |
| 14 | |
Benjamin Kramer | 06e0dad | 2014-01-11 21:22:35 +0000 | [diff] [blame] | 15 | // CHECK-LABEL: define void @test_cf() |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 16 | void test_cf() { |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 17 | // CHECK: load volatile float, float* getelementptr inbounds ({ float, float }, { float, float }* @cf, i32 0, i32 0), align 4 |
| 18 | // CHECK-NEXT: load volatile float, float* getelementptr inbounds ({ float, float }, { float, float }* @cf, i32 0, i32 1), align 4 |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 19 | (void)(cf); |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 20 | // CHECK-NEXT: [[R:%.*]] = load volatile float, float* getelementptr inbounds ({ float, float }, { float, float }* @cf, i32 0, i32 0), align 4 |
| 21 | // CHECK-NEXT: [[I:%.*]] = load volatile float, float* getelementptr inbounds ({ float, float }, { float, float }* @cf, i32 0, i32 1), align 4 |
| 22 | // CHECK-NEXT: store volatile float [[R]], float* getelementptr inbounds ({ float, float }, { float, float }* @cf, i32 0, i32 0), align 4 |
| 23 | // CHECK-NEXT: store volatile float [[I]], float* getelementptr inbounds ({ float, float }, { float, float }* @cf, i32 0, i32 1), align 4 |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 24 | (void)(cf=cf); |
| 25 | // CHECK-NEXT: ret void |
| 26 | } |
| 27 | |
Benjamin Kramer | 06e0dad | 2014-01-11 21:22:35 +0000 | [diff] [blame] | 28 | // CHECK-LABEL: define void @test_cd() |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 29 | void test_cd() { |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 30 | // CHECK: load volatile double, double* getelementptr inbounds ({ double, double }, { double, double }* @cd, i32 0, i32 0), align 8 |
| 31 | // CHECK-NEXT: load volatile double, double* getelementptr inbounds ({ double, double }, { double, double }* @cd, i32 0, i32 1), align 8 |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 32 | (void)(cd); |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 33 | // CHECK-NEXT: [[R:%.*]] = load volatile double, double* getelementptr inbounds ({ double, double }, { double, double }* @cd, i32 0, i32 0), align 8 |
| 34 | // CHECK-NEXT: [[I:%.*]] = load volatile double, double* getelementptr inbounds ({ double, double }, { double, double }* @cd, i32 0, i32 1), align 8 |
| 35 | // CHECK-NEXT: store volatile double [[R]], double* getelementptr inbounds ({ double, double }, { double, double }* @cd, i32 0, i32 0), align 8 |
| 36 | // CHECK-NEXT: store volatile double [[I]], double* getelementptr inbounds ({ double, double }, { double, double }* @cd, i32 0, i32 1), align 8 |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 37 | (void)(cd=cd); |
| 38 | // CHECK-NEXT: ret void |
| 39 | } |
| 40 | |
Benjamin Kramer | 06e0dad | 2014-01-11 21:22:35 +0000 | [diff] [blame] | 41 | // CHECK-LABEL: define void @test_cf32() |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 42 | void test_cf32() { |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 43 | // CHECK: load volatile float, float* getelementptr inbounds ({ float, float }, { float, float }* @cf32, i32 0, i32 0), align 32 |
| 44 | // CHECK-NEXT: load volatile float, float* getelementptr inbounds ({ float, float }, { float, float }* @cf32, i32 0, i32 1), align 4 |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 45 | (void)(cf32); |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 46 | // CHECK-NEXT: [[R:%.*]] = load volatile float, float* getelementptr inbounds ({ float, float }, { float, float }* @cf32, i32 0, i32 0), align 32 |
| 47 | // CHECK-NEXT: [[I:%.*]] = load volatile float, float* getelementptr inbounds ({ float, float }, { float, float }* @cf32, i32 0, i32 1), align 4 |
| 48 | // CHECK-NEXT: store volatile float [[R]], float* getelementptr inbounds ({ float, float }, { float, float }* @cf32, i32 0, i32 0), align 32 |
| 49 | // CHECK-NEXT: store volatile float [[I]], float* getelementptr inbounds ({ float, float }, { float, float }* @cf32, i32 0, i32 1), align 4 |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 50 | (void)(cf32=cf32); |
| 51 | // CHECK-NEXT: ret void |
| 52 | } |
| 53 | |
Benjamin Kramer | 06e0dad | 2014-01-11 21:22:35 +0000 | [diff] [blame] | 54 | // CHECK-LABEL: define void @test_cd32() |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 55 | void test_cd32() { |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 56 | // CHECK: load volatile double, double* getelementptr inbounds ({ double, double }, { double, double }* @cd32, i32 0, i32 0), align 32 |
| 57 | // CHECK-NEXT: load volatile double, double* getelementptr inbounds ({ double, double }, { double, double }* @cd32, i32 0, i32 1), align 8 |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 58 | (void)(cd32); |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 59 | // CHECK-NEXT: [[R:%.*]] = load volatile double, double* getelementptr inbounds ({ double, double }, { double, double }* @cd32, i32 0, i32 0), align 32 |
| 60 | // CHECK-NEXT: [[I:%.*]] = load volatile double, double* getelementptr inbounds ({ double, double }, { double, double }* @cd32, i32 0, i32 1), align 8 |
| 61 | // CHECK-NEXT: store volatile double [[R]], double* getelementptr inbounds ({ double, double }, { double, double }* @cd32, i32 0, i32 0), align 32 |
| 62 | // CHECK-NEXT: store volatile double [[I]], double* getelementptr inbounds ({ double, double }, { double, double }* @cd32, i32 0, i32 1), align 8 |
JF Bastien | 27dcbb2 | 2013-07-17 05:57:42 +0000 | [diff] [blame] | 63 | (void)(cd32=cd32); |
| 64 | // CHECK-NEXT: ret void |
| 65 | } |