Skip to content

Commit cfa09d8

Browse files
committed
Use upstream IFMA intrinsics now that they exist.
1 parent 4bbcc28 commit cfa09d8

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

build.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
#![cfg_attr(
2-
all(feature = "simd_backend", target_feature = "avx512ifma"),
3-
feature(simd_ffi)
4-
)]
5-
#![cfg_attr(
6-
all(feature = "simd_backend", target_feature = "avx512ifma"),
7-
feature(link_llvm_intrinsics)
8-
)]
91
#![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))]
102
#![cfg_attr(feature = "nightly", feature(doc_cfg))]
3+
#![cfg_attr(feature = "simd_backend", feature(stdsimd))]
114
#![allow(unused_variables)]
125
#![allow(non_snake_case)]
136
#![allow(dead_code)]

src/backend/vector/ifma/field.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ use packed_simd::{u64x4, IntoBits};
1414

1515
use backend::serial::u64::field::FieldElement51;
1616

17-
#[allow(improper_ctypes)]
18-
extern "C" {
19-
#[link_name = "llvm.x86.avx512.vpmadd52l.uq.256"]
20-
fn madd52lo(z: u64x4, x: u64x4, y: u64x4) -> u64x4;
21-
#[link_name = "llvm.x86.avx512.vpmadd52h.uq.256"]
22-
fn madd52hi(z: u64x4, x: u64x4, y: u64x4) -> u64x4;
17+
/// A wrapper around `vpmadd52luq` that works on `u64x4`.
18+
#[inline(always)]
19+
unsafe fn madd52lo(z: u64x4, x: u64x4, y: u64x4) -> u64x4 {
20+
use core::arch::x86_64::_mm256_madd52lo_epu64;
21+
_mm256_madd52lo_epu64(z.into_bits(), x.into_bits(), y.into_bits()).into_bits()
22+
}
23+
24+
/// A wrapper around `vpmadd52huq` that works on `u64x4`.
25+
#[inline(always)]
26+
unsafe fn madd52hi(z: u64x4, x: u64x4, y: u64x4) -> u64x4 {
27+
use core::arch::x86_64::_mm256_madd52hi_epu64;
28+
_mm256_madd52hi_epu64(z.into_bits(), x.into_bits(), y.into_bits()).into_bits()
2329
}
2430

2531
/// A vector of four field elements in radix 2^51, with unreduced coefficients.
@@ -203,11 +209,7 @@ use subtle::ConditionallySelectable;
203209

204210
impl ConditionallySelectable for F51x4Reduced {
205211
#[inline]
206-
fn conditional_select(
207-
a: &F51x4Reduced,
208-
b: &F51x4Reduced,
209-
choice: Choice,
210-
) -> F51x4Reduced {
212+
fn conditional_select(a: &F51x4Reduced, b: &F51x4Reduced, choice: Choice) -> F51x4Reduced {
211213
let mask = (-(choice.unwrap_u8() as i64)) as u64;
212214
let mask_vec = u64x4::splat(mask);
213215
F51x4Reduced([

src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,11 @@
99
// - Henry de Valence <[email protected]>
1010

1111
#![no_std]
12-
#![cfg_attr(
13-
any(
14-
all(feature = "simd_backend", target_feature = "avx512ifma"),
15-
all(feature = "nightly", rustdoc)
16-
),
17-
feature(simd_ffi, link_llvm_intrinsics)
18-
)]
1912
#![cfg_attr(feature = "nightly", feature(test))]
2013
#![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))]
2114
#![cfg_attr(feature = "nightly", feature(external_doc))]
2215
#![cfg_attr(feature = "nightly", feature(doc_cfg))]
16+
#![cfg_attr(feature = "simd_backend", feature(stdsimd))]
2317
// Refuse to compile if documentation is missing, but only on nightly.
2418
//
2519
// This means that missing docs will still fail CI, but means we can use

0 commit comments

Comments
 (0)