From 25fe3cc69d3f14d3985aa053ed8962cffcbdc842 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 17 Feb 2024 09:14:45 +0100 Subject: [PATCH 1/3] intrinsics::simd: add missing functions --- library/core/src/intrinsics/simd.rs | 103 ++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index 588891ffa4d5e..9d70b08338284 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -3,6 +3,24 @@ //! In this module, a "vector" is any `repr(simd)` type. extern "platform-intrinsic" { + /// Insert an element into a vector, returning the updated vector. + /// + /// `T` must be a vector with element type `U`. + /// + /// # Safety + /// + /// `idx` must be in-bounds of the vector. + pub fn simd_insert(x: T, idx: u32, val: U) -> T; + + /// Extract an element from a vector. + /// + /// `T` must be a vector with element type `U`. + /// + /// # Safety + /// + /// `idx` must be in-bounds of the vector. + pub fn simd_extract(x: T, idx: u32) -> U; + /// Add two simd vectors elementwise. /// /// `T` must be a vector of integer or floating point primitive types. @@ -317,6 +335,18 @@ extern "platform-intrinsic" { /// Starting with the value `y`, add the elements of `x` and accumulate. pub fn simd_reduce_add_ordered(x: T, y: U) -> U; + /// Add elements within a vector in arbitrary order, and without regard + /// for signed zeros. + /// + /// `T` must be a vector of integer or floating-point primitive types. + /// + /// `U` must be the element type of `T`. + /// + /// # Safety + /// + /// All input elements must be finite (i.e., not NAN and not +/- INF). + pub fn simd_reduce_add_unordered(x: T) -> U; + /// Multiply elements within a vector from left to right. /// /// `T` must be a vector of integer or floating-point primitive types. @@ -326,6 +356,18 @@ extern "platform-intrinsic" { /// Starting with the value `y`, multiply the elements of `x` and accumulate. pub fn simd_reduce_mul_ordered(x: T, y: U) -> U; + /// Multiply elements within a vector in arbitrary order, and without regard + /// for signed zeros. + /// + /// `T` must be a vector of integer or floating-point primitive types. + /// + /// `U` must be the element type of `T`. + /// + /// # Safety + /// + /// All input elements must be finite (i.e., not NAN and not +/- INF). + pub fn simd_reduce_mul_unordered(x: T) -> U; + /// Check if all mask values are true. /// /// `T` must be a vector of integer primitive types. @@ -351,6 +393,19 @@ extern "platform-intrinsic" { /// For floating-point values, uses IEEE-754 `maxNum`. pub fn simd_reduce_max(x: T) -> U; + /// Return the maximum element of a vector. + /// + /// `T` must be a vector of integer or floating-point primitive types. + /// + /// `U` must be the element type of `T`. + /// + /// For floating-point values, uses IEEE-754 `maxNum`. + /// + /// # Safety + /// + /// All input elements must be finite (i.e., not NAN and not +/- INF). + pub fn simd_reduce_max_nanless(x: T) -> U; + /// Return the minimum element of a vector. /// /// `T` must be a vector of integer or floating-point primitive types. @@ -360,6 +415,19 @@ extern "platform-intrinsic" { /// For floating-point values, uses IEEE-754 `minNum`. pub fn simd_reduce_min(x: T) -> U; + /// Return the minimum element of a vector. + /// + /// `T` must be a vector of integer or floating-point primitive types. + /// + /// `U` must be the element type of `T`. + /// + /// For floating-point values, uses IEEE-754 `minNum`. + /// + /// # Safety + /// + /// All input elements must be finite (i.e., not NAN and not +/- INF). + pub fn simd_reduce_min_nanless(x: T) -> U; + /// Logical "and" all elements together. /// /// `T` must be a vector of integer or floating-point primitive types. @@ -518,4 +586,39 @@ extern "platform-intrinsic" { /// /// `T` must be a vector of floats. pub fn simd_fma(x: T, y: T, z: T) -> T; + + // Computes the sine of each element. + /// + /// `T` must be a vector of floats. + pub fn simd_fsin(a: T) -> T; + + // Computes the cosine of each element. + /// + /// `T` must be a vector of floats. + pub fn simd_fcos(a: T) -> T; + + // Computes the exponential function of each element. + /// + /// `T` must be a vector of floats. + pub fn simd_fexp(a: T) -> T; + + // Computes 2 raised to the power of each element. + /// + /// `T` must be a vector of floats. + pub fn simd_fexp2(a: T) -> T; + + // Computes the base 10 logarithm of each element. + /// + /// `T` must be a vector of floats. + pub fn simd_flog10(a: T) -> T; + + // Computes the base 2 logarithm of each element. + /// + /// `T` must be a vector of floats. + pub fn simd_flog2(a: T) -> T; + + // Computes the natural logarithm of each element. + /// + /// `T` must be a vector of floats. + pub fn simd_flog(a: T) -> T; } From 3dc631a61a7333123ece4f21b0d44e43cdff0980 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 18 Feb 2024 23:10:34 +0100 Subject: [PATCH 2/3] make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags --- compiler/rustc_codegen_gcc/src/builder.rs | 4 ++-- compiler/rustc_codegen_gcc/src/intrinsic/simd.rs | 4 ++-- compiler/rustc_codegen_llvm/src/builder.rs | 8 ++++---- compiler/rustc_codegen_llvm/src/intrinsic.rs | 4 ++-- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 1 + compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 15 +++++++++++++++ library/core/src/intrinsics/simd.rs | 16 ++++------------ 7 files changed, 30 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/builder.rs b/compiler/rustc_codegen_gcc/src/builder.rs index 5f1e45383765f..7e2139866f49e 100644 --- a/compiler/rustc_codegen_gcc/src/builder.rs +++ b/compiler/rustc_codegen_gcc/src/builder.rs @@ -1752,7 +1752,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { self.vector_reduce(src, |a, b, context| context.new_binary_op(None, op, a.get_type(), a, b)) } - pub fn vector_reduce_fadd_fast(&mut self, _acc: RValue<'gcc>, _src: RValue<'gcc>) -> RValue<'gcc> { + pub fn vector_reduce_fadd_reassoc(&mut self, _acc: RValue<'gcc>, _src: RValue<'gcc>) -> RValue<'gcc> { unimplemented!(); } @@ -1772,7 +1772,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { unimplemented!(); } - pub fn vector_reduce_fmul_fast(&mut self, _acc: RValue<'gcc>, _src: RValue<'gcc>) -> RValue<'gcc> { + pub fn vector_reduce_fmul_reassoc(&mut self, _acc: RValue<'gcc>, _src: RValue<'gcc>) -> RValue<'gcc> { unimplemented!(); } diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs index 9fa978cd2ef7a..dedd46538589d 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs @@ -989,14 +989,14 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( arith_red!( simd_reduce_add_unordered: BinaryOp::Plus, - vector_reduce_fadd_fast, + vector_reduce_fadd_reassoc, false, add, 0.0 // TODO: Use this argument. ); arith_red!( simd_reduce_mul_unordered: BinaryOp::Mult, - vector_reduce_fmul_fast, + vector_reduce_fmul_reassoc, false, mul, 1.0 diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index cfa266720d2a8..ed73c9f22e767 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -1367,17 +1367,17 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> { pub fn vector_reduce_fmul(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value { unsafe { llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src) } } - pub fn vector_reduce_fadd_algebraic(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value { + pub fn vector_reduce_fadd_reassoc(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value { unsafe { let instr = llvm::LLVMRustBuildVectorReduceFAdd(self.llbuilder, acc, src); - llvm::LLVMRustSetAlgebraicMath(instr); + llvm::LLVMRustSetAllowReassoc(instr); instr } } - pub fn vector_reduce_fmul_algebraic(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value { + pub fn vector_reduce_fmul_reassoc(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value { unsafe { let instr = llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src); - llvm::LLVMRustSetAlgebraicMath(instr); + llvm::LLVMRustSetAllowReassoc(instr); instr } } diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 3b091fca28bcb..b7782410012e2 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -1880,14 +1880,14 @@ fn generic_simd_intrinsic<'ll, 'tcx>( arith_red!(simd_reduce_mul_ordered: vector_reduce_mul, vector_reduce_fmul, true, mul, 1.0); arith_red!( simd_reduce_add_unordered: vector_reduce_add, - vector_reduce_fadd_algebraic, + vector_reduce_fadd_reassoc, false, add, 0.0 ); arith_red!( simd_reduce_mul_unordered: vector_reduce_mul, - vector_reduce_fmul_algebraic, + vector_reduce_fmul_reassoc, false, mul, 1.0 diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index f9eb1da5dc7a4..dbf35e5f49952 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1619,6 +1619,7 @@ extern "C" { pub fn LLVMRustSetFastMath(Instr: &Value); pub fn LLVMRustSetAlgebraicMath(Instr: &Value); + pub fn LLVMRustSetAllowReassoc(Instr: &Value); // Miscellaneous instructions pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &Value; diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 7326f2e8e2a20..664d2adbdc10c 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -418,11 +418,17 @@ extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C, } } +<<<<<<< HEAD // Enable all fast-math flags, including those which will cause floating-point operations // to return poison for some well-defined inputs. This function can only be used to build // unsafe Rust intrinsics. That unsafety does permit additional optimizations, but at the // time of writing, their value is not well-understood relative to those enabled by // LLVMRustSetAlgebraicMath. +||||||| parent of 019019d83e2 (make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags) +// Enable a fast-math flag +======= +// Enable all fast-math flags +>>>>>>> 019019d83e2 (make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags) // // https://llvm.org/docs/LangRef.html#fast-math-flags extern "C" void LLVMRustSetFastMath(LLVMValueRef V) { @@ -450,6 +456,15 @@ extern "C" void LLVMRustSetAlgebraicMath(LLVMValueRef V) { } } +// Enable the reassoc fast-math flag +// +// https://llvm.org/docs/LangRef.html#fast-math-flags +extern "C" void LLVMRustSetAllowReassoc(LLVMValueRef V) { + if (auto I = dyn_cast(unwrap(V))) { + I->setHasAllowReassoc(true); + } +} + extern "C" LLVMValueRef LLVMRustBuildAtomicLoad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Source, const char *Name, LLVMAtomicOrdering Order) { diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index 9d70b08338284..2be0c542f1c41 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -335,16 +335,12 @@ extern "platform-intrinsic" { /// Starting with the value `y`, add the elements of `x` and accumulate. pub fn simd_reduce_add_ordered(x: T, y: U) -> U; - /// Add elements within a vector in arbitrary order, and without regard - /// for signed zeros. + /// Add elements within a vector in arbitrary order. May also be re-associated with + /// unordered additions on the inputs/outputs. /// /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. - /// - /// # Safety - /// - /// All input elements must be finite (i.e., not NAN and not +/- INF). pub fn simd_reduce_add_unordered(x: T) -> U; /// Multiply elements within a vector from left to right. @@ -356,16 +352,12 @@ extern "platform-intrinsic" { /// Starting with the value `y`, multiply the elements of `x` and accumulate. pub fn simd_reduce_mul_ordered(x: T, y: U) -> U; - /// Multiply elements within a vector in arbitrary order, and without regard - /// for signed zeros. + /// Add elements within a vector in arbitrary order. May also be re-associated with + /// unordered additions on the inputs/outputs. /// /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. - /// - /// # Safety - /// - /// All input elements must be finite (i.e., not NAN and not +/- INF). pub fn simd_reduce_mul_unordered(x: T) -> U; /// Check if all mask values are true. From 07b62409478d810b723bf9bf2a471e78c8421d0d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 18 Feb 2024 09:36:36 +0100 Subject: [PATCH 3/3] remove simd_reduce_{min,max}_nanless --- .../src/intrinsics/simd.rs | 4 +-- .../rustc_codegen_gcc/src/intrinsic/simd.rs | 3 --- compiler/rustc_codegen_llvm/src/builder.rs | 16 ------------ compiler/rustc_codegen_llvm/src/intrinsic.rs | 3 --- .../rustc_hir_analysis/src/check/intrinsic.rs | 4 +-- .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 13 +++++----- compiler/rustc_span/src/symbol.rs | 2 -- library/core/src/intrinsics/simd.rs | 26 ------------------- tests/codegen/simd/issue-120720-reduce-nan.rs | 2 +- .../simd/intrinsic/generic-reduction-pass.rs | 6 ----- 10 files changed, 10 insertions(+), 69 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs index ebdc744bcd833..8f662808522b7 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs @@ -743,7 +743,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( simd_reduce(fx, v, None, ret, &|fx, _ty, a, b| fx.bcx.ins().bxor(a, b)); } - sym::simd_reduce_min | sym::simd_reduce_min_nanless => { + sym::simd_reduce_min => { intrinsic_args!(fx, args => (v); intrinsic); if !v.layout().ty.is_simd() { @@ -762,7 +762,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }); } - sym::simd_reduce_max | sym::simd_reduce_max_nanless => { + sym::simd_reduce_max => { intrinsic_args!(fx, args => (v); intrinsic); if !v.layout().ty.is_simd() { diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs index dedd46538589d..d8091724d8647 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs @@ -1041,9 +1041,6 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( minmax_red!(simd_reduce_min: vector_reduce_min, vector_reduce_fmin); minmax_red!(simd_reduce_max: vector_reduce_max, vector_reduce_fmax); - // TODO(sadlerap): revisit these intrinsics to generate more optimal reductions - minmax_red!(simd_reduce_min_nanless: vector_reduce_min, vector_reduce_fmin); - minmax_red!(simd_reduce_max_nanless: vector_reduce_max, vector_reduce_fmax); macro_rules! bitwise_red { ($name:ident : $op:expr, $boolean:expr) => { diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index ed73c9f22e767..8cab2a3f27c1b 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -1406,22 +1406,6 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> { llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ false) } } - pub fn vector_reduce_fmin_fast(&mut self, src: &'ll Value) -> &'ll Value { - unsafe { - let instr = - llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ true); - llvm::LLVMRustSetFastMath(instr); - instr - } - } - pub fn vector_reduce_fmax_fast(&mut self, src: &'ll Value) -> &'ll Value { - unsafe { - let instr = - llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ true); - llvm::LLVMRustSetFastMath(instr); - instr - } - } pub fn vector_reduce_min(&mut self, src: &'ll Value, is_signed: bool) -> &'ll Value { unsafe { llvm::LLVMRustBuildVectorReduceMin(self.llbuilder, src, is_signed) } } diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index b7782410012e2..23e6f054a7c1e 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -1920,9 +1920,6 @@ fn generic_simd_intrinsic<'ll, 'tcx>( minmax_red!(simd_reduce_min: vector_reduce_min, vector_reduce_fmin); minmax_red!(simd_reduce_max: vector_reduce_max, vector_reduce_fmax); - minmax_red!(simd_reduce_min_nanless: vector_reduce_min, vector_reduce_fmin_fast); - minmax_red!(simd_reduce_max_nanless: vector_reduce_max, vector_reduce_fmax_fast); - macro_rules! bitwise_red { ($name:ident : $red:ident, $boolean:expr) => { if name == sym::$name { diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 05fab60fd8dfd..d7277b22c8410 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -606,9 +606,7 @@ pub fn check_platform_intrinsic_type( | sym::simd_reduce_or | sym::simd_reduce_xor | sym::simd_reduce_min - | sym::simd_reduce_max - | sym::simd_reduce_min_nanless - | sym::simd_reduce_max_nanless => (2, 0, vec![param(0)], param(1)), + | sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)), sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)), sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)), _ => { diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 664d2adbdc10c..af2353fbb19c5 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -418,17 +418,11 @@ extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C, } } -<<<<<<< HEAD // Enable all fast-math flags, including those which will cause floating-point operations // to return poison for some well-defined inputs. This function can only be used to build // unsafe Rust intrinsics. That unsafety does permit additional optimizations, but at the // time of writing, their value is not well-understood relative to those enabled by // LLVMRustSetAlgebraicMath. -||||||| parent of 019019d83e2 (make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags) -// Enable a fast-math flag -======= -// Enable all fast-math flags ->>>>>>> 019019d83e2 (make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags) // // https://llvm.org/docs/LangRef.html#fast-math-flags extern "C" void LLVMRustSetFastMath(LLVMValueRef V) { @@ -456,7 +450,12 @@ extern "C" void LLVMRustSetAlgebraicMath(LLVMValueRef V) { } } -// Enable the reassoc fast-math flag +// Enable the reassoc fast-math flag, allowing transformations that pretend +// floating-point addition and multiplication are associative. +// +// Note that this does NOT enable any flags which can cause a floating-point operation on +// well-defined inputs to return poison, and therefore this function can be used to build +// safe Rust intrinsics (such as fadd_algebraic). // // https://llvm.org/docs/LangRef.html#fast-math-flags extern "C" void LLVMRustSetAllowReassoc(LLVMValueRef V) { diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 181ab0d4d56cf..46472a131ff4b 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1553,9 +1553,7 @@ symbols! { simd_reduce_and, simd_reduce_any, simd_reduce_max, - simd_reduce_max_nanless, simd_reduce_min, - simd_reduce_min_nanless, simd_reduce_mul_ordered, simd_reduce_mul_unordered, simd_reduce_or, diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index 2be0c542f1c41..d8a1ad778d752 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -385,19 +385,6 @@ extern "platform-intrinsic" { /// For floating-point values, uses IEEE-754 `maxNum`. pub fn simd_reduce_max(x: T) -> U; - /// Return the maximum element of a vector. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - /// - /// For floating-point values, uses IEEE-754 `maxNum`. - /// - /// # Safety - /// - /// All input elements must be finite (i.e., not NAN and not +/- INF). - pub fn simd_reduce_max_nanless(x: T) -> U; - /// Return the minimum element of a vector. /// /// `T` must be a vector of integer or floating-point primitive types. @@ -407,19 +394,6 @@ extern "platform-intrinsic" { /// For floating-point values, uses IEEE-754 `minNum`. pub fn simd_reduce_min(x: T) -> U; - /// Return the minimum element of a vector. - /// - /// `T` must be a vector of integer or floating-point primitive types. - /// - /// `U` must be the element type of `T`. - /// - /// For floating-point values, uses IEEE-754 `minNum`. - /// - /// # Safety - /// - /// All input elements must be finite (i.e., not NAN and not +/- INF). - pub fn simd_reduce_min_nanless(x: T) -> U; - /// Logical "and" all elements together. /// /// `T` must be a vector of integer or floating-point primitive types. diff --git a/tests/codegen/simd/issue-120720-reduce-nan.rs b/tests/codegen/simd/issue-120720-reduce-nan.rs index 233131aa01c4b..c2ffca4bd8789 100644 --- a/tests/codegen/simd/issue-120720-reduce-nan.rs +++ b/tests/codegen/simd/issue-120720-reduce-nan.rs @@ -12,7 +12,7 @@ use std::arch::x86_64::*; #[no_mangle] #[target_feature(enable = "avx512f")] // Function-level target feature mismatches inhibit inlining pub unsafe fn demo() -> bool { - // CHECK: %0 = tail call reassoc nsz arcp contract double @llvm.vector.reduce.fadd.v8f64( + // CHECK: %0 = tail call reassoc double @llvm.vector.reduce.fadd.v8f64( // CHECK: %_0.i = fcmp uno double %0, 0.000000e+00 // CHECK: ret i1 %_0.i let res = unsafe { diff --git a/tests/ui/simd/intrinsic/generic-reduction-pass.rs b/tests/ui/simd/intrinsic/generic-reduction-pass.rs index 4928ea7bac739..cf4669cd61f5c 100644 --- a/tests/ui/simd/intrinsic/generic-reduction-pass.rs +++ b/tests/ui/simd/intrinsic/generic-reduction-pass.rs @@ -31,8 +31,6 @@ extern "platform-intrinsic" { fn simd_reduce_mul_ordered(x: T, acc: U) -> U; fn simd_reduce_min(x: T) -> U; fn simd_reduce_max(x: T) -> U; - fn simd_reduce_min_nanless(x: T) -> U; - fn simd_reduce_max_nanless(x: T) -> U; fn simd_reduce_and(x: T) -> U; fn simd_reduce_or(x: T) -> U; fn simd_reduce_xor(x: T) -> U; @@ -127,10 +125,6 @@ fn main() { assert_eq!(r, -2_f32); let r: f32 = simd_reduce_max(x); assert_eq!(r, 4_f32); - let r: f32 = simd_reduce_min_nanless(x); - assert_eq!(r, -2_f32); - let r: f32 = simd_reduce_max_nanless(x); - assert_eq!(r, 4_f32); } unsafe {