@@ -1713,9 +1713,9 @@ unique_ptr<Instr> ConversionOp::dup(Function &f, const string &suffix) const {
17131713
17141714FpConversionOp::FpConversionOp (Type &type, std::string &&name, Value &val,
17151715 Op op, FpRoundingMode rm, FpExceptionMode ex,
1716- unsigned flags, FastMathFlags fmath )
1716+ unsigned flags)
17171717 : Instr(type, std::move(name)), val(&val), op(op), rm(rm), ex(ex),
1718- flags (flags), fmath(fmath) {
1718+ flags (flags) {
17191719 switch (op) {
17201720 case UIntToFP:
17211721 assert ((flags & NNEG) == flags);
@@ -1724,14 +1724,6 @@ FpConversionOp::FpConversionOp(Type &type, std::string &&name, Value &val,
17241724 assert (flags == 0 );
17251725 break ;
17261726 }
1727- switch (op) {
1728- case FPTrunc:
1729- case FPExt:
1730- break ;
1731- default :
1732- assert (fmath.isNone ());
1733- break ;
1734- }
17351727}
17361728
17371729vector<Value*> FpConversionOp::operands () const {
@@ -1768,8 +1760,6 @@ void FpConversionOp::print(ostream &os) const {
17681760 os << getName () << " = " << str;
17691761 if (flags & NNEG)
17701762 os << " nneg " ;
1771- if (!fmath.isNone ())
1772- os << fmath;
17731763 os << *val << print_type (getType (), " to " , " " );
17741764 if (!rm.isDefault ())
17751765 os << " , rounding=" << rm;
@@ -1779,8 +1769,7 @@ void FpConversionOp::print(ostream &os) const {
17791769
17801770StateValue FpConversionOp::toSMT (State &s) const {
17811771 auto &v = s[*val];
1782- function<StateValue (const expr &, const Type &, const expr &)> fn;
1783- function<StateValue (const StateValue &, const Type &, const Type &)> scalar;
1772+ function<StateValue (const expr &, const Type &, const expr&)> fn;
17841773
17851774 switch (op) {
17861775 case SIntToFP:
@@ -1864,43 +1853,37 @@ StateValue FpConversionOp::toSMT(State &s) const {
18641853 break ;
18651854 case FPExt:
18661855 case FPTrunc:
1867- scalar = [&](const StateValue &sv, const Type &from_type,
1868- const Type &to_type) -> StateValue {
1869- auto fn = [&](auto &v, auto &rm) {
1870- return v.float2Float (to_type.getAsFloatType ()->getDummyFloat (), rm);
1871- };
1872- return fm_poison (s, sv.value , sv.non_poison , fn, from_type, fmath, rm,
1873- false , false , &to_type);
1856+ fn = [](auto &val, auto &to_type, auto &rm) -> StateValue {
1857+ return { val.float2Float (to_type.getAsFloatType ()->getDummyFloat (), rm),
1858+ true };
18741859 };
18751860 break ;
18761861 }
18771862
1878- if (!scalar)
1879- scalar = [&](const StateValue &sv, const Type &from_type,
1880- const Type &to_type) -> StateValue {
1881- auto val = sv.value ;
1863+ auto scalar = [&](const StateValue &sv, const Type &from_type,
1864+ const Type &to_type) -> StateValue {
1865+ auto val = sv.value ;
18821866
1883- if (from_type.isFloatType ()) {
1884- auto ty = from_type.getAsFloatType ();
1885- val = ty->getFloat (val);
1886- }
1867+ if (from_type.isFloatType ()) {
1868+ auto ty = from_type.getAsFloatType ();
1869+ val = ty->getFloat (val);
1870+ }
18871871
1888- function<StateValue (const expr &)> fn_rm = [&](auto &rm) {
1889- return fn (val, to_type, rm);
1890- };
1891- AndExpr np;
1892- np.add (sv.non_poison );
1893-
1894- StateValue ret = to_type.isFloatType () ? round_value (s, rm, np, fn_rm)
1895- : fn (val, to_type, rm.toSMT ());
1896- np.add (std::move (ret.non_poison ));
1897-
1898- return {to_type.isFloatType () ? to_type.getAsFloatType ()->fromFloat (
1899- s, ret.value , from_type,
1900- from_type.isFloatType (), sv.value )
1901- : std::move (ret.value ),
1902- np ()};
1903- };
1872+ function<StateValue (const expr&)> fn_rm
1873+ = [&](auto &rm) { return fn (val, to_type, rm); };
1874+ AndExpr np;
1875+ np.add (sv.non_poison );
1876+
1877+ StateValue ret = to_type.isFloatType () ? round_value (s, rm, np, fn_rm)
1878+ : fn (val, to_type, rm.toSMT ());
1879+ np.add (std::move (ret.non_poison ));
1880+
1881+ return { to_type.isFloatType ()
1882+ ? to_type.getAsFloatType ()
1883+ ->fromFloat (s, ret.value , from_type, from_type.isFloatType (),
1884+ sv.value )
1885+ : std::move (ret.value ), np ()};
1886+ };
19041887
19051888 if (getType ().isVectorType ()) {
19061889 vector<StateValue> vals;
@@ -1948,8 +1931,8 @@ expr FpConversionOp::getTypeConstraints(const Function &f) const {
19481931}
19491932
19501933unique_ptr<Instr> FpConversionOp::dup (Function &f, const string &suffix) const {
1951- return make_unique<FpConversionOp>( getType (), getName () + suffix, *val, op,
1952- rm, ex, flags, fmath );
1934+ return
1935+ make_unique<FpConversionOp>( getType (), getName () + suffix, *val, op, rm );
19531936}
19541937
19551938
0 commit comments