Skip to content

Commit

Permalink
Implement x86 _mm_sqrt_ss vendor intrinsic
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Aug 2, 2024
1 parent 9bad4b6 commit c48b010
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/intrinsics/llvm_x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,23 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
ret.place_lane(fx, 0).write_cvalue(fx, res_lane);
}

"llvm.x86.sse.sqrt.ss" => {
// https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_sqrt_ss&ig_expand=6278
intrinsic_args!(fx, args => (a); intrinsic);

assert_eq!(a.layout(), ret.layout());
let (_, lane_ty) = a.layout().ty.simd_size_and_type(fx.tcx);
assert!(lane_ty.is_floating_point());
let ret_lane_layout = fx.layout_of(lane_ty);

ret.write_cvalue(fx, a);

let lane = a.value_lane(fx, 0).load_scalar(fx);
let res = fx.bcx.ins().sqrt(lane);
let res_lane = CValue::by_val(res, ret_lane_layout);
ret.place_lane(fx, 0).write_cvalue(fx, res_lane);
}

"llvm.x86.sse.sqrt.ps" => {
// https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_sqrt_ps&ig_expand=6245
intrinsic_args!(fx, args => (a); intrinsic);
Expand Down

0 comments on commit c48b010

Please sign in to comment.