Make algebraic intrinsics into 'const fn' items; Make algebraic functions of 'f16', 'f32', 'f64', and 'f128' into 'const fn' items;
This commit is contained in:
parent
6bc57c6bf7
commit
0296f05ce5
7 changed files with 70 additions and 51 deletions
|
|
@ -391,32 +391,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
this.write_scalar(res, dest)?;
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
| "fadd_algebraic"
|
||||
| "fsub_algebraic"
|
||||
| "fmul_algebraic"
|
||||
| "fdiv_algebraic"
|
||||
| "frem_algebraic"
|
||||
=> {
|
||||
let [a, b] = check_intrinsic_arg_count(args)?;
|
||||
let a = this.read_immediate(a)?;
|
||||
let b = this.read_immediate(b)?;
|
||||
let op = match intrinsic_name {
|
||||
"fadd_algebraic" => mir::BinOp::Add,
|
||||
"fsub_algebraic" => mir::BinOp::Sub,
|
||||
"fmul_algebraic" => mir::BinOp::Mul,
|
||||
"fdiv_algebraic" => mir::BinOp::Div,
|
||||
"frem_algebraic" => mir::BinOp::Rem,
|
||||
_ => bug!(),
|
||||
};
|
||||
let res = this.binary_op(op, &a, &b)?;
|
||||
// `binary_op` already called `generate_nan` if needed.
|
||||
// Apply a relative error of 4ULP to simulate non-deterministic precision loss
|
||||
// due to optimizations.
|
||||
let res = apply_random_float_error_to_imm(this, res, 2 /* log2(4) */)?;
|
||||
this.write_immediate(*res, dest)?;
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
| "fadd_fast"
|
||||
| "fsub_fast"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue