Apply rounding mode in fp div (#416)

This commit is contained in:
Andrzej Janik
2025-07-17 02:22:59 +02:00
committed by GitHub
parent 95d66df18e
commit 36f0ba9cbb

View File

@ -1921,16 +1921,27 @@ fn get_modes<T: ast::Operand>(inst: &ast::Instruction<T>) -> InstructionModes {
.. ..
}), }),
.. ..
} } => InstructionModes::from_ftz(*type_, *flush_to_zero),
| ast::Instruction::Div { ast::Instruction::Div {
data: data:
ast::DivDetails::Float(ast::DivFloatDetails { ast::DivDetails::Float(ast::DivFloatDetails {
type_, type_,
flush_to_zero, flush_to_zero,
.. kind,
}), }),
.. ..
} => InstructionModes::from_ftz(*type_, *flush_to_zero), } => {
let rounding = match kind {
ast::DivFloatKind::Rounding(rnd) => RoundingMode::from_ast(*rnd),
ast::DivFloatKind::Approx => RoundingMode::NearestEven,
ast::DivFloatKind::ApproxFull => RoundingMode::NearestEven,
};
InstructionModes::new(
*type_,
flush_to_zero.map(DenormalMode::from_ftz),
Some(rounding),
)
}
ast::Instruction::Sin { data, .. } ast::Instruction::Sin { data, .. }
| ast::Instruction::Cos { data, .. } | ast::Instruction::Cos { data, .. }
| ast::Instruction::Lg2 { data, .. } => InstructionModes::from_ftz_f32(data.flush_to_zero), | ast::Instruction::Lg2 { data, .. } => InstructionModes::from_ftz_f32(data.flush_to_zero),