218 lines · c
1// REQUIRES: powerpc-registered-target2// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s3// RUN: %clang_cc1 -target-feature +float128 -DTEST_F128 -triple \4// RUN: powerpc64le-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s \5// RUN: --check-prefix CHECK-F1286 7float crealf(_Complex float);8double creal(_Complex double);9long double creall(_Complex long double);10#ifdef TEST_F12811__float128 crealf128(_Complex __float128);12__float128 foo_f128(_Complex __float128 x) {13 return crealf128(x);14}15// CHECK-F128: define{{.*}} fp128 @foo_f128(fp128 noundef {{[%A-Za-z0-9.]+}}, fp128 noundef {{[%A-Za-z0-9.]+}})16#endif17 18float foo_float(_Complex float x) {19 return crealf(x);20}21 22// CHECK: define{{.*}} float @foo_float(float noundef {{[%A-Za-z0-9.]+}}, float noundef {{[%A-Za-z0-9.]+}}) [[NUW:#[0-9]+]] {23 24double foo_double(_Complex double x) {25 return creal(x);26}27 28// CHECK: define{{.*}} double @foo_double(double noundef {{[%A-Za-z0-9.]+}}, double noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {29 30long double foo_long_double(_Complex long double x) {31 return creall(x);32}33 34// CHECK: define{{.*}} ppc_fp128 @foo_long_double(ppc_fp128 noundef {{[%A-Za-z0-9.]+}}, ppc_fp128 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {35 36__ibm128 foo_ibm128(_Complex __ibm128 x) {37 // We don't have a suffix for explicit __ibm128 type yet. Use *l instead.38 return creall(x);39}40 41// CHECK: define{{.*}} ppc_fp128 @foo_ibm128(ppc_fp128 noundef {{[%A-Za-z0-9.]+}}, ppc_fp128 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {42 43int foo_int(_Complex int x) {44 return __real__ x;45}46 47// CHECK: define{{.*}} signext i32 @foo_int(i32 noundef {{[%A-Za-z0-9.]+}}, i32 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {48 49short foo_short(_Complex short x) {50 return __real__ x;51}52 53// CHECK: define{{.*}} signext i16 @foo_short(i16 noundef {{[%A-Za-z0-9.]+}}, i16 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {54 55signed char foo_char(_Complex signed char x) {56 return __real__ x;57}58 59// CHECK: define{{.*}} signext i8 @foo_char(i8 noundef {{[%A-Za-z0-9.]+}}, i8 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {60 61long foo_long(_Complex long x) {62 return __real__ x;63}64 65// CHECK: define{{.*}} i64 @foo_long(i64 noundef {{[%A-Za-z0-9.]+}}, i64 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {66 67long long foo_long_long(_Complex long long x) {68 return __real__ x;69}70 71// CHECK: define{{.*}} i64 @foo_long_long(i64 noundef {{[%A-Za-z0-9.]+}}, i64 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {72 73void bar_float(void) {74 foo_float(2.0f - 2.5fi);75}76 77// CHECK: define{{.*}} void @bar_float() [[NUW]] {78// CHECK: %[[VAR1:[A-Za-z0-9.]+]] = alloca { float, float }, align 479// CHECK: %[[VAR2:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { float, float }, ptr %[[VAR1]], i32 0, i32 080// CHECK: %[[VAR3:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { float, float }, ptr %[[VAR1]], i32 0, i32 181// CHECK: store float 2.000000e+00, ptr %[[VAR2]]82// CHECK: store float -2.500000e+00, ptr %[[VAR3]]83// CHECK: %[[VAR4:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { float, float }, ptr %[[VAR1]], i32 0, i32 084// CHECK: %[[VAR5:[A-Za-z0-9.]+]] = load float, ptr %[[VAR4]], align 485// CHECK: %[[VAR6:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { float, float }, ptr %[[VAR1]], i32 0, i32 186// CHECK: %[[VAR7:[A-Za-z0-9.]+]] = load float, ptr %[[VAR6]], align 487// CHECK: %{{[A-Za-z0-9.]+}} = call float @foo_float(float noundef %[[VAR5]], float noundef %[[VAR7]])88 89void bar_double(void) {90 foo_double(2.0 - 2.5i);91}92 93// CHECK: define{{.*}} void @bar_double() [[NUW]] {94// CHECK: %[[VAR11:[A-Za-z0-9.]+]] = alloca { double, double }, align 895// CHECK: %[[VAR12:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { double, double }, ptr %[[VAR11]], i32 0, i32 096// CHECK: %[[VAR13:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { double, double }, ptr %[[VAR11]], i32 0, i32 197// CHECK: store double 2.000000e+00, ptr %[[VAR12]]98// CHECK: store double -2.500000e+00, ptr %[[VAR13]]99// CHECK: %[[VAR14:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { double, double }, ptr %[[VAR11]], i32 0, i32 0100// CHECK: %[[VAR15:[A-Za-z0-9.]+]] = load double, ptr %[[VAR14]], align 8101// CHECK: %[[VAR16:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { double, double }, ptr %[[VAR11]], i32 0, i32 1102// CHECK: %[[VAR17:[A-Za-z0-9.]+]] = load double, ptr %[[VAR16]], align 8103// CHECK: %{{[A-Za-z0-9.]+}} = call double @foo_double(double noundef %[[VAR15]], double noundef %[[VAR17]])104 105void bar_long_double(void) {106 foo_long_double(2.0L - 2.5Li);107}108 109// CHECK: define{{.*}} void @bar_long_double() [[NUW]] {110// CHECK: %[[VAR21:[A-Za-z0-9.]+]] = alloca { ppc_fp128, ppc_fp128 }, align 16111// CHECK: %[[VAR22:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 0112// CHECK: %[[VAR23:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 1113// CHECK: store ppc_fp128 0xM40000000000000000000000000000000, ptr %[[VAR22]]114// CHECK: store ppc_fp128 0xMC0040000000000008000000000000000, ptr %[[VAR23]]115// CHECK: %[[VAR24:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 0116// CHECK: %[[VAR25:[A-Za-z0-9.]+]] = load ppc_fp128, ptr %[[VAR24]], align 16117// CHECK: %[[VAR26:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 1118// CHECK: %[[VAR27:[A-Za-z0-9.]+]] = load ppc_fp128, ptr %[[VAR26]], align 16119// CHECK: %{{[A-Za-z0-9.]+}} = call ppc_fp128 @foo_long_double(ppc_fp128 noundef %[[VAR25]], ppc_fp128 noundef %[[VAR27]])120 121void bar_ibm128(void) {122 foo_ibm128(2.0L - 2.5Li);123}124 125// CHECK: define{{.*}} void @bar_ibm128() [[NUW]] {126// CHECK: %[[VAR21:[A-Za-z0-9.]+]] = alloca { ppc_fp128, ppc_fp128 }, align 16127// CHECK: %[[VAR22:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 0128// CHECK: %[[VAR23:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 1129// CHECK: store ppc_fp128 0xM40000000000000000000000000000000, ptr %[[VAR22]]130// CHECK: store ppc_fp128 0xMC0040000000000008000000000000000, ptr %[[VAR23]]131// CHECK: %[[VAR24:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 0132// CHECK: %[[VAR25:[A-Za-z0-9.]+]] = load ppc_fp128, ptr %[[VAR24]], align 16133// CHECK: %[[VAR26:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 1134// CHECK: %[[VAR27:[A-Za-z0-9.]+]] = load ppc_fp128, ptr %[[VAR26]], align 16135// CHECK: %{{[A-Za-z0-9.]+}} = call ppc_fp128 @foo_ibm128(ppc_fp128 noundef %[[VAR25]], ppc_fp128 noundef %[[VAR27]])136 137void bar_int(void) {138 foo_int(2 - 3i);139}140 141// CHECK: define{{.*}} void @bar_int() [[NUW]] {142// CHECK: %[[VAR31:[A-Za-z0-9.]+]] = alloca { i32, i32 }, align 4143// CHECK: %[[VAR32:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[VAR31]], i32 0, i32 0144// CHECK: %[[VAR33:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[VAR31]], i32 0, i32 1145// CHECK: store i32 2, ptr %[[VAR32]]146// CHECK: store i32 -3, ptr %[[VAR33]]147// CHECK: %[[VAR34:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[VAR31]], i32 0, i32 0148// CHECK: %[[VAR35:[A-Za-z0-9.]+]] = load i32, ptr %[[VAR34]], align 4149// CHECK: %[[VAR36:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[VAR31]], i32 0, i32 1150// CHECK: %[[VAR37:[A-Za-z0-9.]+]] = load i32, ptr %[[VAR36]], align 4151// CHECK: %{{[A-Za-z0-9.]+}} = call signext i32 @foo_int(i32 noundef %[[VAR35]], i32 noundef %[[VAR37]])152 153void bar_short(void) {154 foo_short(2 - 3i);155}156 157// CHECK: define{{.*}} void @bar_short() [[NUW]] {158// CHECK: %[[VAR41:[A-Za-z0-9.]+]] = alloca { i16, i16 }, align 2159// CHECK: %[[VAR42:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i16, i16 }, ptr %[[VAR41]], i32 0, i32 0160// CHECK: %[[VAR43:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i16, i16 }, ptr %[[VAR41]], i32 0, i32 1161// CHECK: store i16 2, ptr %[[VAR42]]162// CHECK: store i16 -3, ptr %[[VAR43]]163// CHECK: %[[VAR44:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i16, i16 }, ptr %[[VAR41]], i32 0, i32 0164// CHECK: %[[VAR45:[A-Za-z0-9.]+]] = load i16, ptr %[[VAR44]], align 2165// CHECK: %[[VAR46:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i16, i16 }, ptr %[[VAR41]], i32 0, i32 1166// CHECK: %[[VAR47:[A-Za-z0-9.]+]] = load i16, ptr %[[VAR46]], align 2167// CHECK: %{{[A-Za-z0-9.]+}} = call signext i16 @foo_short(i16 noundef %[[VAR45]], i16 noundef %[[VAR47]])168 169void bar_char(void) {170 foo_char(2 - 3i);171}172 173// CHECK: define{{.*}} void @bar_char() [[NUW]] {174// CHECK: %[[VAR51:[A-Za-z0-9.]+]] = alloca { i8, i8 }, align 1175// CHECK: %[[VAR52:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i8, i8 }, ptr %[[VAR51]], i32 0, i32 0176// CHECK: %[[VAR53:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i8, i8 }, ptr %[[VAR51]], i32 0, i32 1177// CHECK: store i8 2, ptr %[[VAR52]]178// CHECK: store i8 -3, ptr %[[VAR53]]179// CHECK: %[[VAR54:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i8, i8 }, ptr %[[VAR51]], i32 0, i32 0180// CHECK: %[[VAR55:[A-Za-z0-9.]+]] = load i8, ptr %[[VAR54]], align 1181// CHECK: %[[VAR56:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i8, i8 }, ptr %[[VAR51]], i32 0, i32 1182// CHECK: %[[VAR57:[A-Za-z0-9.]+]] = load i8, ptr %[[VAR56]], align 1183// CHECK: %{{[A-Za-z0-9.]+}} = call signext i8 @foo_char(i8 noundef %[[VAR55]], i8 noundef %[[VAR57]])184 185void bar_long(void) {186 foo_long(2L - 3Li);187}188 189// CHECK: define{{.*}} void @bar_long() [[NUW]] {190// CHECK: %[[VAR61:[A-Za-z0-9.]+]] = alloca { i64, i64 }, align 8191// CHECK: %[[VAR62:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[VAR61]], i32 0, i32 0192// CHECK: %[[VAR63:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[VAR61]], i32 0, i32 1193// CHECK: store i64 2, ptr %[[VAR62]]194// CHECK: store i64 -3, ptr %[[VAR63]]195// CHECK: %[[VAR64:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[VAR61]], i32 0, i32 0196// CHECK: %[[VAR65:[A-Za-z0-9.]+]] = load i64, ptr %[[VAR64]], align 8197// CHECK: %[[VAR66:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[VAR61]], i32 0, i32 1198// CHECK: %[[VAR67:[A-Za-z0-9.]+]] = load i64, ptr %[[VAR66]], align 8199// CHECK: %{{[A-Za-z0-9.]+}} = call i64 @foo_long(i64 noundef %[[VAR65]], i64 noundef %[[VAR67]])200 201void bar_long_long(void) {202 foo_long_long(2LL - 3LLi);203}204 205// CHECK: define{{.*}} void @bar_long_long() [[NUW]] {206// CHECK: %[[VAR71:[A-Za-z0-9.]+]] = alloca { i64, i64 }, align 8207// CHECK: %[[VAR72:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[VAR71]], i32 0, i32 0208// CHECK: %[[VAR73:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[VAR71]], i32 0, i32 1209// CHECK: store i64 2, ptr %[[VAR72]]210// CHECK: store i64 -3, ptr %[[VAR73]]211// CHECK: %[[VAR74:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[VAR71]], i32 0, i32 0212// CHECK: %[[VAR75:[A-Za-z0-9.]+]] = load i64, ptr %[[VAR74]], align 8213// CHECK: %[[VAR76:[A-Za-z0-9.]+]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[VAR71]], i32 0, i32 1214// CHECK: %[[VAR77:[A-Za-z0-9.]+]] = load i64, ptr %[[VAR76]], align 8215// CHECK: %{{[A-Za-z0-9.]+}} = call i64 @foo_long_long(i64 noundef %[[VAR75]], i64 noundef %[[VAR77]])216 217// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }218