Skip to content

Commit 6fc34ff

Browse files
committed
Rollup merge of rust-lang#49231 - gnzlbg:fix_vec_fminmax, r=rkruppe
fix vector fmin/fmax non-fast/fast intrinsics NaN handling This bugs shows up in release mode tests of `stdsimd`: rust-lang/stdarch#391 . The intrinsics are thoroughly tested there for roundoff errors, NaN, and overflow behavior. The problem was that the non-fast intrinsics where specifying `NoNaNs == true`, which meant that they don't support NaNs. This is incorrect, the non-fast intrinsics should handle NaNs properly. Also, the "fast" intrinsics where specifying `NoNaNs == false` which meant that they support NaNs and then fast-math, which probably disables this support. This was not intended either. I've added a comment specifying what the boolean flags do.
2 parents dc47de0 + e0165af commit 6fc34ff

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/librustc_trans/builder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10361036
pub fn vector_reduce_fmin(&self, src: ValueRef) -> ValueRef {
10371037
self.count_insn("vector.reduce.fmin");
10381038
unsafe {
1039-
let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, true);
1039+
let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ false);
10401040
if instr.is_null() {
10411041
bug!("LLVMRustBuildVectorReduceFMin is not available in LLVM version < 5.0");
10421042
}
@@ -1046,7 +1046,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10461046
pub fn vector_reduce_fmax(&self, src: ValueRef) -> ValueRef {
10471047
self.count_insn("vector.reduce.fmax");
10481048
unsafe {
1049-
let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, true);
1049+
let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ false);
10501050
if instr.is_null() {
10511051
bug!("LLVMRustBuildVectorReduceFMax is not available in LLVM version < 5.0");
10521052
}
@@ -1056,7 +1056,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10561056
pub fn vector_reduce_fmin_fast(&self, src: ValueRef) -> ValueRef {
10571057
self.count_insn("vector.reduce.fmin_fast");
10581058
unsafe {
1059-
let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, false);
1059+
let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ true);
10601060
if instr.is_null() {
10611061
bug!("LLVMRustBuildVectorReduceFMin is not available in LLVM version < 5.0");
10621062
}
@@ -1067,7 +1067,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10671067
pub fn vector_reduce_fmax_fast(&self, src: ValueRef) -> ValueRef {
10681068
self.count_insn("vector.reduce.fmax_fast");
10691069
unsafe {
1070-
let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, false);
1070+
let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ true);
10711071
if instr.is_null() {
10721072
bug!("LLVMRustBuildVectorReduceFMax is not available in LLVM version < 5.0");
10731073
}

0 commit comments

Comments
 (0)