Skip to content

Commit

Permalink
fix #995: broken fmin/fmax semantics for -0.0/+0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes committed Dec 25, 2023
1 parent 3dbff83 commit d1dfabb
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions ir/instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,14 +848,11 @@ StateValue FpBinOp::toSMT(State &s) const {
case FMax:
fn = [&](const expr &a, const expr &b, const expr &rm) {
expr ndet = s.getFreshNondetVar("maxminnondet", true);
auto ndz = expr::mkIf(ndet, expr::mkNumber("0", a),
expr::mkNumber("-0", a));

expr z = a.isFPZero() && b.isFPZero();
expr cmp = op == FMin ? a.fole(b) : a.foge(b);
return expr::mkIf(a.isNaN(), b,
expr::mkIf(b.isNaN(), a,
expr::mkIf(z, ndz,
expr::mkIf(a.foeq(b),
expr::mkIf(ndet, a, b),
expr::mkIf(cmp, a, b))));
};
break;
Expand Down

0 comments on commit d1dfabb

Please sign in to comment.