@@ -170,6 +170,65 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
170170 }
171171 }
172172
173+ "llvm.x86.sse.add.ss" => {
174+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_add_ss&ig_expand=171
175+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
176+
177+ assert_eq ! ( a. layout( ) , b. layout( ) ) ;
178+ assert_eq ! ( a. layout( ) , ret. layout( ) ) ;
179+ let layout = a. layout ( ) ;
180+
181+ let ( _, lane_ty) = layout. ty . simd_size_and_type ( fx. tcx ) ;
182+ assert ! ( lane_ty. is_floating_point( ) ) ;
183+ let ret_lane_layout = fx. layout_of ( lane_ty) ;
184+
185+ ret. write_cvalue ( fx, a) ;
186+
187+ let a_lane = a. value_lane ( fx, 0 ) . load_scalar ( fx) ;
188+ let b_lane = b. value_lane ( fx, 0 ) . load_scalar ( fx) ;
189+
190+ let res = fx. bcx . ins ( ) . fadd ( a_lane, b_lane) ;
191+
192+ let res_lane = CValue :: by_val ( res, ret_lane_layout) ;
193+ ret. place_lane ( fx, 0 ) . write_cvalue ( fx, res_lane) ;
194+ }
195+
196+ "llvm.x86.sse.sqrt.ps" => {
197+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_sqrt_ps&ig_expand=6245
198+ intrinsic_args ! ( fx, args => ( a) ; intrinsic) ;
199+
200+ // FIXME use vector instructions when possible
201+ simd_for_each_lane ( fx, a, ret, & |fx, _lane_ty, _res_lane_ty, lane| {
202+ fx. bcx . ins ( ) . sqrt ( lane)
203+ } ) ;
204+ }
205+
206+ "llvm.x86.sse.max.ps" => {
207+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_max_ps&ig_expand=4357
208+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
209+
210+ simd_pair_for_each_lane (
211+ fx,
212+ a,
213+ b,
214+ ret,
215+ & |fx, _lane_ty, _res_lane_ty, a_lane, b_lane| fx. bcx . ins ( ) . fmax ( a_lane, b_lane) ,
216+ ) ;
217+ }
218+
219+ "llvm.x86.sse.min.ps" => {
220+ // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_min_ps&ig_expand=4489
221+ intrinsic_args ! ( fx, args => ( a, b) ; intrinsic) ;
222+
223+ simd_pair_for_each_lane (
224+ fx,
225+ a,
226+ b,
227+ ret,
228+ & |fx, _lane_ty, _res_lane_ty, a_lane, b_lane| fx. bcx . ins ( ) . fmin ( a_lane, b_lane) ,
229+ ) ;
230+ }
231+
173232 "llvm.x86.sse.cmp.ps" | "llvm.x86.sse2.cmp.pd" => {
174233 let ( x, y, kind) = match args {
175234 [ x, y, kind] => ( x, y, kind) ,
0 commit comments