@@ -118,16 +118,16 @@ DEF_FPU_SEM(FILD, RF80W, T src1) {
118118template <typename T>
119119DEF_FPU_SEM (FLD, RF80W, T src1) {
120120 SetFPUIpOp ();
121- auto val = Float80 ( Read (src1) );
121+ auto val = Read (src1);
122122 state.sw .ie |= IsSignalingNaN (val);
123- state.sw .de = IsDenormal (val);
124- auto res = val;
123+ state.sw .de | = IsDenormal (val);
124+ auto res = Float80 ( val) ;
125125
126126 // Quietize if signaling NaN.
127127 if (state.sw .ie ) {
128- nan64_t res_nan = {Float64 ( res) };
128+ nan80_t res_nan = {res};
129129 res_nan.is_quiet_nan = 1 ;
130- res = Float80 ( res_nan.d ) ;
130+ res = res_nan.d ;
131131 }
132132
133133 PUSH_X87_STACK (res);
@@ -239,10 +239,10 @@ DEF_FPU_SEM(DoFCOS) {
239239 SetFPUIpOp ();
240240 auto st0 = Read (X87_ST0);
241241 state.sw .ie |= IsSignalingNaN (st0) | IsInfinite (st0);
242- state.sw .de = IsDenormal (st0);
242+ state.sw .de | = IsDenormal (st0);
243243 auto res = CheckedFloatUnaryOp (state, FCos80, st0);
244244 if (!IsNaN (res)) {
245- state.sw .pe = IsImprecise (res);
245+ state.sw .pe | = IsImprecise (res);
246246 }
247247 Write (X87_ST0, res);
248248 return memory;
@@ -252,7 +252,7 @@ DEF_FPU_SEM(DoFSIN) {
252252 SetFPUIpOp ();
253253 auto st0 = Read (X87_ST0);
254254 state.sw .ie |= IsSignalingNaN (st0) | IsInfinite (st0);
255- state.sw .de = IsDenormal (st0);
255+ state.sw .de | = IsDenormal (st0);
256256 auto res = CheckedFloatUnaryOp (state, FSin80, st0);
257257 if (!IsNaN (res)) {
258258 state.sw .pe = IsImprecise (res);
@@ -265,7 +265,7 @@ DEF_FPU_SEM(DoFPTAN) {
265265 SetFPUIpOp ();
266266 auto st0 = Read (X87_ST0);
267267 state.sw .ie |= IsSignalingNaN (st0) | IsInfinite (st0);
268- state.sw .de = IsDenormal (st0);
268+ state.sw .de | = IsDenormal (st0);
269269 auto res = CheckedFloatUnaryOp (state, FTan80, st0);
270270 if (!IsNaN (res)) {
271271 state.sw .pe = IsImprecise (res);
@@ -302,7 +302,7 @@ DEF_FPU_SEM(DoFSQRT) {
302302 Write (X87_ST0, st0);
303303 } else {
304304 state.sw .ie |= IsSignalingNaN (st0) | IsNegative (st0);
305- state.sw .de = IsDenormal (st0);
305+ state.sw .de | = IsDenormal (st0);
306306 auto res = CheckedFloatUnaryOp (state, FSqrt80, st0);
307307 if (!IsNaN (res)) {
308308 state.sw .pe = IsImprecise (res);
@@ -316,7 +316,7 @@ DEF_FPU_SEM(DoFSINCOS) {
316316 SetFPUIpOp ();
317317 auto st0 = Read (X87_ST0);
318318 state.sw .ie |= IsSignalingNaN (st0) | IsInfinite (st0);
319- state.sw .de = IsDenormal (st0);
319+ state.sw .de | = IsDenormal (st0);
320320 auto sin_res = CheckedFloatUnaryOp (state, FSin80, st0);
321321 auto cos_res = CheckedFloatUnaryOp (state, FCos80, st0);
322322 if (!IsNaN (sin_res) && !IsNaN (cos_res)) {
@@ -339,7 +339,7 @@ DEF_FPU_SEM(DoF2XM1) {
339339 SetFPUIpOp ();
340340 auto st0 = Read (X87_ST0);
341341 state.sw .ie |= IsSignalingNaN (st0) | IsInfinite (st0);
342- state.sw .de = IsDenormal (st0);
342+ state.sw .de | = IsDenormal (st0);
343343 state.sw .ue = 0 ; // TODO(pag): Not sure.
344344 auto res = FSub (Float80 (Exp2 (st0)), Float80 (1.0 ));
345345 if (!IsNaN (res)) {
@@ -392,6 +392,18 @@ DEF_SEM(DoFWAIT) {
392392
393393DEF_SEM (DoFNCLEX) {
394394 feclearexcept (FE_ALL_EXCEPT);
395+ state.sw .pe = 0 ;
396+ state.sw .ue = 0 ;
397+ state.sw .oe = 0 ;
398+ state.sw .ze = 0 ;
399+ state.sw .de = 0 ;
400+ state.sw .ie = 0 ;
401+
402+ state.sw .c0 = UUndefined8 ();
403+ state.sw .c1 = UUndefined8 ();
404+ state.sw .c2 = UUndefined8 ();
405+ state.sw .c3 = UUndefined8 ();
406+
395407 return memory;
396408}
397409
@@ -998,7 +1010,7 @@ DEF_FPU_SEM(DoFXAM) {
9981010}
9991011
10001012DEF_HELPER (OrderedCompare, native_float80_t src1, native_float80_t src2)->void {
1001- state.sw .de = IsDenormal (src1) | IsDenormal (src2);
1013+ state.sw .de | = IsDenormal (src1) | IsDenormal (src2);
10021014 state.sw .ie = 0 ;
10031015
10041016 if (__builtin_isunordered (src1, src2)) {
@@ -1024,7 +1036,7 @@ DEF_HELPER(OrderedCompare, native_float80_t src1, native_float80_t src2)->void {
10241036}
10251037
10261038DEF_HELPER (UnorderedCompare, native_float80_t src1, native_float80_t src2)->void {
1027- state.sw .de = IsDenormal (src1) | IsDenormal (src2);
1039+ state.sw .de | = IsDenormal (src1) | IsDenormal (src2);
10281040 state.sw .ie = 0 ;
10291041
10301042 if (__builtin_isunordered (src1, src2)) {
@@ -1146,7 +1158,7 @@ DEF_FPU_SEM(DoFCOMPP) {
11461158}
11471159
11481160DEF_HELPER (UnorderedCompareEflags, native_float80_t src1, native_float80_t src2)->void {
1149- state.sw .de = IsDenormal (src1) | IsDenormal (src2);
1161+ state.sw .de | = IsDenormal (src1) | IsDenormal (src2);
11501162 state.sw .ie = 0 ;
11511163
11521164 if (__builtin_isunordered (src1, src2)) {
@@ -1173,7 +1185,7 @@ DEF_HELPER(UnorderedCompareEflags, native_float80_t src1, native_float80_t src2)
11731185}
11741186
11751187DEF_HELPER (OrderedCompareEflags, native_float80_t src1, native_float80_t src2)->void {
1176- state.sw .de = IsDenormal (src1) | IsDenormal (src2);
1188+ state.sw .de | = IsDenormal (src1) | IsDenormal (src2);
11771189 state.sw .ie = 0 ;
11781190
11791191 if (__builtin_isunordered (src1, src2)) {
@@ -1328,7 +1340,7 @@ DEF_FPU_SEM(DoFRNDINT) {
13281340 auto st0 = Read (X87_ST0);
13291341 auto rounded = FRoundUsingMode (st0);
13301342 state.sw .ie |= IsSignalingNaN (st0);
1331- state.sw .de = IsDenormal (st0);
1343+ state.sw .de | = IsDenormal (st0);
13321344 if (!IsNaN (rounded)) {
13331345 state.sw .pe = st0 != rounded;
13341346 }
0 commit comments