| 1 |
// RUN: %clang_cc1 -triple s390x-linux-gnu -O1 -emit-llvm %s -o - | FileCheck %s |
| 2 |
// |
| 3 |
// Test that floating point atomic stores and loads do not get casted to/from |
| 4 |
// integer. |
| 5 |
|
| 6 |
#include <stdatomic.h> |
| 7 |
|
| 8 |
_Atomic float Af; |
| 9 |
_Atomic double Ad; |
| 10 |
_Atomic long double Ald; |
| 11 |
|
| 12 |
//// Atomic stores of floating point values. |
| 13 |
void fun0(float Arg) { |
| 14 |
// CHECK-LABEL: @fun0 |
| 15 |
// CHECK: store atomic float %Arg, ptr @Af seq_cst, align 4 |
| 16 |
Af = Arg; |
| 17 |
} |
| 18 |
|
| 19 |
void fun1(double Arg) { |
| 20 |
// CHECK-LABEL: @fun1 |
| 21 |
// CHECK: store atomic double %Arg, ptr @Ad seq_cst, align 8 |
| 22 |
Ad = Arg; |
| 23 |
} |
| 24 |
|
| 25 |
void fun2(long double Arg) { |
| 26 |
// CHECK-LABEL: @fun2 |
| 27 |
// CHECK: store atomic fp128 %Arg, ptr @Ald seq_cst, align 16 |
| 28 |
Ald = Arg; |
| 29 |
} |
| 30 |
|
| 31 |
void fun3(_Atomic float *Dst, float Arg) { |
| 32 |
// CHECK-LABEL: @fun |
| 33 |
// CHECK: store atomic float %Arg, ptr %Dst seq_cst, align 4 |
| 34 |
*Dst = Arg; |
| 35 |
} |
| 36 |
|
| 37 |
void fun4(_Atomic double *Dst, double Arg) { |
| 38 |
// CHECK-LABEL: @fun4 |
| 39 |
// CHECK: store atomic double %Arg, ptr %Dst seq_cst, align 8 |
| 40 |
*Dst = Arg; |
| 41 |
} |
| 42 |
|
| 43 |
void fun5(_Atomic long double *Dst, long double Arg) { |
| 44 |
// CHECK-LABEL: @fun5 |
| 45 |
// CHECK: store atomic fp128 %Arg, ptr %Dst seq_cst, align 16 |
| 46 |
*Dst = Arg; |
| 47 |
} |
| 48 |
|
| 49 |
//// Atomic loads of floating point values. |
| 50 |
float fun6() { |
| 51 |
// CHECK-LABEL: @fun6 |
| 52 |
// CHECK: %atomic-load = load atomic float, ptr @Af seq_cst, align 4 |
| 53 |
return Af; |
| 54 |
} |
| 55 |
|
| 56 |
float fun7() { |
| 57 |
// CHECK-LABEL: @fun7 |
| 58 |
// CHECK: %atomic-load = load atomic double, ptr @Ad seq_cst, align 8 |
| 59 |
return Ad; |
| 60 |
} |
| 61 |
|
| 62 |
float fun8() { |
| 63 |
// CHECK-LABEL: @fun8 |
| 64 |
// CHECK: %atomic-load = load atomic fp128, ptr @Ald seq_cst, align 16 |
| 65 |
return Ald; |
| 66 |
} |
| 67 |
|
| 68 |
float fun9(_Atomic float *Src) { |
| 69 |
// CHECK-LABEL: @fun9 |
| 70 |
// CHECK: %atomic-load = load atomic float, ptr %Src seq_cst, align 4 |
| 71 |
return *Src; |
| 72 |
} |
| 73 |
|
| 74 |
double fun10(_Atomic double *Src) { |
| 75 |
// CHECK-LABEL: @fun10 |
| 76 |
// CHECK: %atomic-load = load atomic double, ptr %Src seq_cst, align 8 |
| 77 |
return *Src; |
| 78 |
} |
| 79 |
|
| 80 |
long double fun11(_Atomic long double *Src) { |
| 81 |
// CHECK-LABEL: @fun11 |
| 82 |
// CHECK: %atomic-load = load atomic fp128, ptr %Src seq_cst, align 16 |
| 83 |
return *Src; |
| 84 |
} |
| 85 |
|
| 86 |
//// Same, but with 'volatile' as well: |
| 87 |
|
| 88 |
_Atomic volatile float Af_vol; |
| 89 |
_Atomic volatile double Ad_vol; |
| 90 |
_Atomic volatile long double Ald_vol; |
| 91 |
|
| 92 |
//// Atomic volatile stores of floating point values. |
| 93 |
void fun0_vol(float Arg) { |
| 94 |
// CHECK-LABEL: @fun0_vol |
| 95 |
// CHECK: store atomic volatile float %Arg, ptr @Af_vol seq_cst, align 4 |
| 96 |
Af_vol = Arg; |
| 97 |
} |
| 98 |
|
| 99 |
void fun1_vol(double Arg) { |
| 100 |
// CHECK-LABEL: @fun1_vol |
| 101 |
// CHECK: store atomic volatile double %Arg, ptr @Ad_vol seq_cst, align 8 |
| 102 |
Ad_vol = Arg; |
| 103 |
} |
| 104 |
|
| 105 |
void fun2_vol(long double Arg) { |
| 106 |
// CHECK-LABEL: @fun2_vol |
| 107 |
// CHECK: store atomic volatile fp128 %Arg, ptr @Ald_vol seq_cst, align 16 |
| 108 |
Ald_vol = Arg; |
| 109 |
} |
| 110 |
|
| 111 |
void fun3_vol(_Atomic volatile float *Dst, float Arg) { |
| 112 |
// CHECK-LABEL: @fun3_vol |
| 113 |
// CHECK: store atomic volatile float %Arg, ptr %Dst seq_cst, align 4 |
| 114 |
*Dst = Arg; |
| 115 |
} |
| 116 |
|
| 117 |
void fun4_vol(_Atomic volatile double *Dst, double Arg) { |
| 118 |
// CHECK-LABEL: @fun4_vol |
| 119 |
// CHECK: store atomic volatile double %Arg, ptr %Dst seq_cst, align 8 |
| 120 |
*Dst = Arg; |
| 121 |
} |
| 122 |
|
| 123 |
void fun5_vol(_Atomic volatile long double *Dst, long double Arg) { |
| 124 |
// CHECK-LABEL: @fun5_vol |
| 125 |
// CHECK: store atomic volatile fp128 %Arg, ptr %Dst seq_cst, align 16 |
| 126 |
*Dst = Arg; |
| 127 |
} |
| 128 |
|
| 129 |
//// Atomic volatile loads of floating point values. |
| 130 |
float fun6_vol() { |
| 131 |
// CHECK-LABEL: @fun6_vol |
| 132 |
// CHECK: %atomic-load = load atomic volatile float, ptr @Af_vol seq_cst, align 4 |
| 133 |
return Af_vol; |
| 134 |
} |
| 135 |
|
| 136 |
float fun7_vol() { |
| 137 |
// CHECK-LABEL: @fun7_vol |
| 138 |
// CHECK: %atomic-load = load atomic volatile double, ptr @Ad_vol seq_cst, align 8 |
| 139 |
return Ad_vol; |
| 140 |
} |
| 141 |
|
| 142 |
float fun8_vol() { |
| 143 |
// CHECK-LABEL: @fun8_vol |
| 144 |
// CHECK: %atomic-load = load atomic volatile fp128, ptr @Ald_vol seq_cst, align 16 |
| 145 |
return Ald_vol; |
| 146 |
} |
| 147 |
|
| 148 |
float fun9_vol(_Atomic volatile float *Src) { |
| 149 |
// CHECK-LABEL: @fun9_vol |
| 150 |
// CHECK: %atomic-load = load atomic volatile float, ptr %Src seq_cst, align 4 |
| 151 |
return *Src; |
| 152 |
} |
| 153 |
|
| 154 |
double fun10_vol(_Atomic volatile double *Src) { |
| 155 |
// CHECK-LABEL: @fun10_vol |
| 156 |
// CHECK: %atomic-load = load atomic volatile double, ptr %Src seq_cst, align 8 |
| 157 |
return *Src; |
| 158 |
} |
| 159 |
|
| 160 |
long double fun11_vol(_Atomic volatile long double *Src) { |
| 161 |
// CHECK-LABEL: @fun11_vol |
| 162 |
// CHECK: %atomic-load = load atomic volatile fp128, ptr %Src seq_cst, align 16 |
| 163 |
return *Src; |
| 164 |
} |