about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-02-23 14:30:25 -0500
committerGitHub <noreply@github.com>2025-02-23 14:30:25 -0500
commita9e8cfe3f7a3f322f44a207f9dc49a5b03f295db (patch)
tree455344b47f3e38b3077630e9fd6b5c21a884b391
parentbe635722bd4264f0fd0de4cccb9ca4f9f74fafd9 (diff)
parentbeb24b3301e6f9b831f16ddd542930024ffe8239 (diff)
downloadrust-a9e8cfe3f7a3f322f44a207f9dc49a5b03f295db.tar.gz
rust-a9e8cfe3f7a3f322f44a207f9dc49a5b03f295db.zip
Rollup merge of #136543 - RalfJung:round-ties-even, r=tgross35
intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic

LLVM has three intrinsics here that all do the same thing (when used in the default FP environment). There's no reason Rust needs to copy that historically-grown mess -- let's just have one intrinsic and leave it up to the LLVM backend to decide how to lower that.

Suggested by `@hanna-kruppe` in https://github.com/rust-lang/rust/issues/136459; Cc `@tgross35`

try-job: test-various
-rw-r--r--src/intrinsic/mod.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs
index 433868e238a..f8672c07299 100644
--- a/src/intrinsic/mod.rs
+++ b/src/intrinsic/mod.rs
@@ -84,14 +84,11 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
         sym::ceilf64 => "ceil",
         sym::truncf32 => "truncf",
         sym::truncf64 => "trunc",
-        sym::rintf32 => "rintf",
-        sym::rintf64 => "rint",
-        sym::nearbyintf32 => "nearbyintf",
-        sym::nearbyintf64 => "nearbyint",
+        // We match the LLVM backend and lower this to `rint`.
+        sym::round_ties_even_f32 => "rintf",
+        sym::round_ties_even_f64 => "rint",
         sym::roundf32 => "roundf",
         sym::roundf64 => "round",
-        sym::roundevenf32 => "roundevenf",
-        sym::roundevenf64 => "roundeven",
         sym::abort => "abort",
         _ => return None,
     };