Skip to content

Commit bce802b

Browse files
authored
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 rust-lang/rust#136459; Cc `@tgross35` try-job: test-various
2 parents 783e989 + 83044a8 commit bce802b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/intrinsics/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -145,60 +145,60 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
145145
this.write_scalar(Scalar::from_bool(branch), dest)?;
146146
}
147147

148-
"floorf16" | "ceilf16" | "truncf16" | "roundf16" | "rintf16" => {
148+
"floorf16" | "ceilf16" | "truncf16" | "roundf16" | "round_ties_even_f16" => {
149149
let [f] = check_arg_count(args)?;
150150
let f = this.read_scalar(f)?.to_f16()?;
151151
let mode = match intrinsic_name {
152152
"floorf16" => Round::TowardNegative,
153153
"ceilf16" => Round::TowardPositive,
154154
"truncf16" => Round::TowardZero,
155155
"roundf16" => Round::NearestTiesToAway,
156-
"rintf16" => Round::NearestTiesToEven,
156+
"round_ties_even_f16" => Round::NearestTiesToEven,
157157
_ => bug!(),
158158
};
159159
let res = f.round_to_integral(mode).value;
160160
let res = this.adjust_nan(res, &[f]);
161161
this.write_scalar(res, dest)?;
162162
}
163-
"floorf32" | "ceilf32" | "truncf32" | "roundf32" | "rintf32" => {
163+
"floorf32" | "ceilf32" | "truncf32" | "roundf32" | "round_ties_even_f32" => {
164164
let [f] = check_arg_count(args)?;
165165
let f = this.read_scalar(f)?.to_f32()?;
166166
let mode = match intrinsic_name {
167167
"floorf32" => Round::TowardNegative,
168168
"ceilf32" => Round::TowardPositive,
169169
"truncf32" => Round::TowardZero,
170170
"roundf32" => Round::NearestTiesToAway,
171-
"rintf32" => Round::NearestTiesToEven,
171+
"round_ties_even_f32" => Round::NearestTiesToEven,
172172
_ => bug!(),
173173
};
174174
let res = f.round_to_integral(mode).value;
175175
let res = this.adjust_nan(res, &[f]);
176176
this.write_scalar(res, dest)?;
177177
}
178-
"floorf64" | "ceilf64" | "truncf64" | "roundf64" | "rintf64" => {
178+
"floorf64" | "ceilf64" | "truncf64" | "roundf64" | "round_ties_even_f64" => {
179179
let [f] = check_arg_count(args)?;
180180
let f = this.read_scalar(f)?.to_f64()?;
181181
let mode = match intrinsic_name {
182182
"floorf64" => Round::TowardNegative,
183183
"ceilf64" => Round::TowardPositive,
184184
"truncf64" => Round::TowardZero,
185185
"roundf64" => Round::NearestTiesToAway,
186-
"rintf64" => Round::NearestTiesToEven,
186+
"round_ties_even_f64" => Round::NearestTiesToEven,
187187
_ => bug!(),
188188
};
189189
let res = f.round_to_integral(mode).value;
190190
let res = this.adjust_nan(res, &[f]);
191191
this.write_scalar(res, dest)?;
192192
}
193-
"floorf128" | "ceilf128" | "truncf128" | "roundf128" | "rintf128" => {
193+
"floorf128" | "ceilf128" | "truncf128" | "roundf128" | "round_ties_even_f128" => {
194194
let [f] = check_arg_count(args)?;
195195
let f = this.read_scalar(f)?.to_f128()?;
196196
let mode = match intrinsic_name {
197197
"floorf128" => Round::TowardNegative,
198198
"ceilf128" => Round::TowardPositive,
199199
"truncf128" => Round::TowardZero,
200200
"roundf128" => Round::NearestTiesToAway,
201-
"rintf128" => Round::NearestTiesToEven,
201+
"round_ties_even_f128" => Round::NearestTiesToEven,
202202
_ => bug!(),
203203
};
204204
let res = f.round_to_integral(mode).value;

0 commit comments

Comments
 (0)