[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / PowerPC / builtins-ppc-fpconstrained.c
blob6fc70ed74cc43023e338e7576193ee778fae1015
1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
3 // RUN: -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-UNCONSTRAINED %s
4 // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
5 // RUN: -ffp-exception-behavior=strict -emit-llvm %s -o - | FileCheck \
6 // RUN: --check-prefix=CHECK-CONSTRAINED -vv %s
7 // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
8 // RUN: -S -o - %s | \
9 // RUN: FileCheck --check-prefix=CHECK-ASM --check-prefix=NOT-FIXME-CHECK %s
10 // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
11 // RUN: -S -ffp-exception-behavior=strict \
12 // RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \
13 // RUN: --check-prefix=FIXME-CHECK %s
14 // RUN: %clang_cc1 -triple powerpcspe -S -ffp-exception-behavior=strict \
15 // RUN: -target-feature +spe -fexperimental-strict-floating-point -emit-llvm \
16 // RUN: %s -o - | FileCheck --check-prefix=CHECK-CONSTRAINED %s
18 typedef __attribute__((vector_size(4 * sizeof(float)))) float vec_float;
19 typedef __attribute__((vector_size(2 * sizeof(double)))) double vec_double;
21 volatile vec_double vd;
22 volatile vec_float vf;
24 void test_float(void) {
25 vf = __builtin_vsx_xvsqrtsp(vf);
26 // CHECK-LABEL: try-xvsqrtsp
27 // CHECK-UNCONSTRAINED: @llvm.sqrt.v4f32(<4 x float> %{{.*}})
28 // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
29 // CHECK-ASM: xvsqrtsp
31 vd = __builtin_vsx_xvsqrtdp(vd);
32 // CHECK-LABEL: try-xvsqrtdp
33 // CHECK-UNCONSTRAINED: @llvm.sqrt.v2f64(<2 x double> %{{.*}})
34 // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
35 // CHECK-ASM: xvsqrtdp
37 vf = __builtin_vsx_xvrspim(vf);
38 // CHECK-LABEL: try-xvrspim
39 // CHECK-UNCONSTRAINED: @llvm.floor.v4f32(<4 x float> %{{.*}})
40 // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
41 // CHECK-ASM: xvrspim
43 vd = __builtin_vsx_xvrdpim(vd);
44 // CHECK-LABEL: try-xvrdpim
45 // CHECK-UNCONSTRAINED: @llvm.floor.v2f64(<2 x double> %{{.*}})
46 // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
47 // CHECK-ASM: xvrdpim
49 vf = __builtin_vsx_xvrspi(vf);
50 // CHECK-LABEL: try-xvrspi
51 // CHECK-UNCONSTRAINED: @llvm.round.v4f32(<4 x float> %{{.*}})
52 // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
53 // CHECK-ASM: xvrspi
55 vd = __builtin_vsx_xvrdpi(vd);
56 // CHECK-LABEL: try-xvrdpi
57 // CHECK-UNCONSTRAINED: @llvm.round.v2f64(<2 x double> %{{.*}})
58 // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
59 // CHECK-ASM: xvrdpi
61 vf = __builtin_vsx_xvrspic(vf);
62 // CHECK-LABEL: try-xvrspic
63 // CHECK-UNCONSTRAINED: @llvm.rint.v4f32(<4 x float> %{{.*}})
64 // CHECK-CONSTRAINED: @llvm.experimental.constrained.rint.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
65 // CHECK-ASM: xvrspic
67 vd = __builtin_vsx_xvrdpic(vd);
68 // CHECK-LABEL: try-xvrdpic
69 // CHECK-UNCONSTRAINED: @llvm.rint.v2f64(<2 x double> %{{.*}})
70 // CHECK-CONSTRAINED: @llvm.experimental.constrained.rint.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
71 // CHECK-ASM: xvrdpic
73 vf = __builtin_vsx_xvrspip(vf);
74 // CHECK-LABEL: try-xvrspip
75 // CHECK-UNCONSTRAINED: @llvm.ceil.v4f32(<4 x float> %{{.*}})
76 // CHECK-CONSTRAINED: @llvm.experimental.constrained.ceil.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
77 // CHECK-ASM: xvrspip
79 vd = __builtin_vsx_xvrdpip(vd);
80 // CHECK-LABEL: try-xvrdpip
81 // CHECK-UNCONSTRAINED: @llvm.ceil.v2f64(<2 x double> %{{.*}})
82 // CHECK-CONSTRAINED: @llvm.experimental.constrained.ceil.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
83 // CHECK-ASM: xvrdpip
85 vf = __builtin_vsx_xvrspiz(vf);
86 // CHECK-LABEL: try-xvrspiz
87 // CHECK-UNCONSTRAINED: @llvm.trunc.v4f32(<4 x float> %{{.*}})
88 // CHECK-CONSTRAINED: @llvm.experimental.constrained.trunc.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
89 // CHECK-ASM: xvrspiz
91 vd = __builtin_vsx_xvrdpiz(vd);
92 // CHECK-LABEL: try-xvrdpiz
93 // CHECK-UNCONSTRAINED: @llvm.trunc.v2f64(<2 x double> %{{.*}})
94 // CHECK-CONSTRAINED: @llvm.experimental.constrained.trunc.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
95 // CHECK-ASM: xvrdpiz
97 vf = __builtin_vsx_xvmaddasp(vf, vf, vf);
98 // CHECK-LABEL: try-xvmaddasp
99 // CHECK-UNCONSTRAINED: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
100 // CHECK-CONSTRAINED: @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
101 // CHECK-ASM: xvmaddasp
103 vd = __builtin_vsx_xvmaddadp(vd, vd, vd);
104 // CHECK-LABEL: try-xvmaddadp
105 // CHECK-UNCONSTRAINED: @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
106 // CHECK-CONSTRAINED: @llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
107 // CHECK-ASM: xvmaddadp
109 vf = __builtin_vsx_xvnmaddasp(vf, vf, vf);
110 // CHECK-LABEL: try-xvnmaddasp
111 // CHECK-UNCONSTRAINED: [[RESULT:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
112 // CHECK-UNCONSTRAINED: fneg <4 x float> [[RESULT]]
113 // CHECK-CONSTRAINED: [[RESULT:%[^ ]+]] = call <4 x float> @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
114 // CHECK-CONSTRAINED: fneg <4 x float> [[RESULT]]
115 // NOT-FIXME-CHECK: xvnmaddasp
116 // FIXME-CHECK: xvmaddasp
117 // FIXME-CHECK: xvnegsp
119 vd = __builtin_vsx_xvnmaddadp(vd, vd, vd);
120 // CHECK-LABEL: try-xvnmaddadp
121 // CHECK-UNCONSTRAINED: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
122 // CHECK-UNCONSTRAINED: fneg <2 x double> [[RESULT]]
123 // CHECK-CONSTRAINED: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
124 // CHECK-CONSTRAINED: fneg <2 x double> [[RESULT]]
125 // CHECK-ASM: xvnmaddadp
127 vf = __builtin_vsx_xvmsubasp(vf, vf, vf);
128 // CHECK-LABEL: try-xvmsubasp
129 // CHECK-UNCONSTRAINED: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
130 // CHECK-UNCONSTRAINED: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> [[RESULT]])
131 // CHECK-CONSTRAINED: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
132 // CHECK-CONSTRAINED: @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> [[RESULT]], metadata !"round.tonearest", metadata !"fpexcept.strict")
133 // CHECK-ASM: xvmsubasp
135 vd = __builtin_vsx_xvmsubadp(vd, vd, vd);
136 // CHECK-LABEL: try-xvmsubadp
137 // CHECK-UNCONSTRAINED: [[RESULT:%[^ ]+]] = fneg <2 x double> %{{.*}}
138 // CHECK-UNCONSTRAINED: @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> [[RESULT]])
139 // CHECK-CONSTRAINED: [[RESULT:%[^ ]+]] = fneg <2 x double> %{{.*}}
140 // CHECK-CONSTRAINED: @llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> [[RESULT]], metadata !"round.tonearest", metadata !"fpexcept.strict")
141 // CHECK-ASM: xvmsubadp
143 vf = __builtin_vsx_xvnmsubasp(vf, vf, vf);
144 // CHECK-LABEL: try-xvnmsubasp
145 // CHECK-UNCONSTRAINED: call <4 x float> @llvm.ppc.fnmsub.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
146 // CHECK-CONSTRAINED: [[RESULT0:%[^ ]+]] = fneg <4 x float> %{{.*}}
147 // CHECK-CONSTRAINED: [[RESULT1:%[^ ]+]] = call <4 x float> @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> [[RESULT0]], metadata !"round.tonearest", metadata !"fpexcept.strict")
148 // CHECK-CONSTRAINED: fneg <4 x float> [[RESULT1]]
149 // CHECK-ASM: xvnmsubasp
151 vd = __builtin_vsx_xvnmsubadp(vd, vd, vd);
152 // CHECK-LABEL: try-xvnmsubadp
153 // CHECK-UNCONSTRAINED: call <2 x double> @llvm.ppc.fnmsub.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
154 // CHECK-CONSTRAINED: [[RESULT0:%[^ ]+]] = fneg <2 x double> %{{.*}}
155 // CHECK-CONSTRAINED: [[RESULT1:%[^ ]+]] = call <2 x double> @llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> [[RESULT0]], metadata !"round.tonearest", metadata !"fpexcept.strict")
156 // CHECK-CONSTRAINED: fneg <2 x double> [[RESULT1]]
157 // CHECK-ASM: xvnmsubadp