Use upstream IFMA intrinsics now that they exist.

This commit is contained in:
Henry de Valence 2019-06-04 14:29:33 -07:00
parent 4bbcc28cdc
commit cfa09d859f
3 changed files with 15 additions and 26 deletions

View file

@ -1,13 +1,6 @@
#![cfg_attr(
all(feature = "simd_backend", target_feature = "avx512ifma"),
feature(simd_ffi)
)]
#![cfg_attr(
all(feature = "simd_backend", target_feature = "avx512ifma"),
feature(link_llvm_intrinsics)
)]
#![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))] #![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))]
#![cfg_attr(feature = "nightly", feature(doc_cfg))] #![cfg_attr(feature = "nightly", feature(doc_cfg))]
#![cfg_attr(feature = "simd_backend", feature(stdsimd))]
#![allow(unused_variables)] #![allow(unused_variables)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![allow(dead_code)] #![allow(dead_code)]

View file

@ -14,12 +14,18 @@ use packed_simd::{u64x4, IntoBits};
use backend::serial::u64::field::FieldElement51; use backend::serial::u64::field::FieldElement51;
#[allow(improper_ctypes)] /// A wrapper around `vpmadd52luq` that works on `u64x4`.
extern "C" { #[inline(always)]
#[link_name = "llvm.x86.avx512.vpmadd52l.uq.256"] unsafe fn madd52lo(z: u64x4, x: u64x4, y: u64x4) -> u64x4 {
fn madd52lo(z: u64x4, x: u64x4, y: u64x4) -> u64x4; use core::arch::x86_64::_mm256_madd52lo_epu64;
#[link_name = "llvm.x86.avx512.vpmadd52h.uq.256"] _mm256_madd52lo_epu64(z.into_bits(), x.into_bits(), y.into_bits()).into_bits()
fn madd52hi(z: u64x4, x: u64x4, y: u64x4) -> u64x4; }
/// A wrapper around `vpmadd52huq` that works on `u64x4`.
#[inline(always)]
unsafe fn madd52hi(z: u64x4, x: u64x4, y: u64x4) -> u64x4 {
use core::arch::x86_64::_mm256_madd52hi_epu64;
_mm256_madd52hi_epu64(z.into_bits(), x.into_bits(), y.into_bits()).into_bits()
} }
/// A vector of four field elements in radix 2^51, with unreduced coefficients. /// A vector of four field elements in radix 2^51, with unreduced coefficients.
@ -203,11 +209,7 @@ use subtle::ConditionallySelectable;
impl ConditionallySelectable for F51x4Reduced { impl ConditionallySelectable for F51x4Reduced {
#[inline] #[inline]
fn conditional_select( fn conditional_select(a: &F51x4Reduced, b: &F51x4Reduced, choice: Choice) -> F51x4Reduced {
a: &F51x4Reduced,
b: &F51x4Reduced,
choice: Choice,
) -> F51x4Reduced {
let mask = (-(choice.unwrap_u8() as i64)) as u64; let mask = (-(choice.unwrap_u8() as i64)) as u64;
let mask_vec = u64x4::splat(mask); let mask_vec = u64x4::splat(mask);
F51x4Reduced([ F51x4Reduced([

View file

@ -9,17 +9,11 @@
// - Henry de Valence <hdevalence@hdevalence.ca> // - Henry de Valence <hdevalence@hdevalence.ca>
#![no_std] #![no_std]
#![cfg_attr(
any(
all(feature = "simd_backend", target_feature = "avx512ifma"),
all(feature = "nightly", rustdoc)
),
feature(simd_ffi, link_llvm_intrinsics)
)]
#![cfg_attr(feature = "nightly", feature(test))] #![cfg_attr(feature = "nightly", feature(test))]
#![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))] #![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))]
#![cfg_attr(feature = "nightly", feature(external_doc))] #![cfg_attr(feature = "nightly", feature(external_doc))]
#![cfg_attr(feature = "nightly", feature(doc_cfg))] #![cfg_attr(feature = "nightly", feature(doc_cfg))]
#![cfg_attr(feature = "simd_backend", feature(stdsimd))]
// Refuse to compile if documentation is missing, but only on nightly. // Refuse to compile if documentation is missing, but only on nightly.
// //
// This means that missing docs will still fail CI, but means we can use // This means that missing docs will still fail CI, but means we can use