Skip to content

Commit 2cb1034

Browse files
committed
change semantics of nsz so it only makes the input sign non-deterministic
Per llvm/llvm-project#180906
1 parent f693d47 commit 2cb1034

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

ir/instr.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ static expr fminimum_fmaximum(State &s, const expr &a, const expr &b,
676676
return expr::mkIf(a.isNaN(), a, expr::mkIf(b.isNaN(), b, e));
677677
}
678678

679-
static expr any_fp_zero(State &s, const expr &v) {
679+
static expr any_fp_zero(State &s, expr v) {
680680
expr is_zero = v.isFPZero();
681681
if (is_zero.isFalse())
682682
return v;
@@ -688,7 +688,7 @@ static expr any_fp_zero(State &s, const expr &v) {
688688
expr a, b;
689689
if (cond.isAnd(a, b) && a.isVar() && a.fn_name().starts_with("anyzero") &&
690690
b.isIsFPZero())
691-
return any_fp_zero(s, val);
691+
return any_fp_zero(s, std::move(val));
692692
}
693693
}
694694

@@ -767,11 +767,11 @@ static StateValue fm_poison(State &s, expr a, const expr &ap, expr b,
767767
auto &fpty = *from_ty.getAsFloatType();
768768

769769
if (fmath.flags & FastMathFlags::NSZ) {
770-
a = any_fp_zero(s, a);
770+
a = any_fp_zero(s, std::move(a));
771771
if (nary >= 2) {
772-
b = any_fp_zero(s, b);
772+
b = any_fp_zero(s, std::move(b));
773773
if (nary == 3)
774-
c = any_fp_zero(s, c);
774+
c = any_fp_zero(s, std::move(c));
775775
}
776776
}
777777

@@ -824,8 +824,6 @@ static StateValue fm_poison(State &s, expr a, const expr &ap, expr b,
824824
val = expr::mkUF("afn", { val }, val);
825825
s.doesApproximation("afn", val);
826826
}
827-
if (!flags_in_only && fmath.flags & FastMathFlags::NSZ)
828-
val = any_fp_zero(s, std::move(val));
829827

830828
if (!bitwise && val.isFloat()) {
831829
val = handle_subnormal(s,

0 commit comments

Comments
 (0)