Skip to content

Commit e4c5298

Browse files
committed
implement exact_div
1 parent ff080a9 commit e4c5298

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/terminator/intrinsic.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,19 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
244244
self.write_primval(dest, result.0, dest_ty)?;
245245
}
246246

247+
"exact_div" => {
248+
// added in https://github.com/rust-lang/rust/pull/49297
249+
250+
// TODO report undefined behavior in cases where
251+
// `a % b != 0` or `b == 0` or `a = ty::min_value() && b == 1`
252+
253+
let ty = instance.substs.type_at(0);
254+
let a = self.value_to_primval(arg_vals[0], ty)?;
255+
let b = self.value_to_primval(arg_vals[1], ty)?;
256+
let result = self.binary_op(mir::BinOp::Div, a, ty, b, ty)?;
257+
self.write_primval(dest, result.0, dest_ty)?;
258+
}
259+
247260
"likely" |
248261
"unlikely" |
249262
"forget" => {}

0 commit comments

Comments
 (0)