From: Taylor R Campbell Date: Sat, 22 Feb 2014 22:28:39 +0000 (+0000) Subject: On i386, avoid FCOM[P] and FTST in favour of FUCOM[P]. X-Git-Tag: release-9.2.0~45 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=521ffb3;p=mit-scheme.git On i386, avoid FCOM[P] and FTST in favour of FUCOM[P]. The FCOM[P] and FTST instructions trap even on quiet NaN; the FUCOM[P] instructions don't. --- diff --git a/src/compiler/machines/i386/rulflo.scm b/src/compiler/machines/i386/rulflo.scm index 5dc0ab630..ace08312e 100644 --- a/src/compiler/machines/i386/rulflo.scm +++ b/src/compiler/machines/i386/rulflo.scm @@ -657,14 +657,14 @@ USA. (st2 (flonum-source! source2))) (cond ((zero? st1) (flonum-branch! predicate - (LAP (FCOM (ST 0) (ST ,st2))))) + (LAP (FUCOM (ST 0) (ST ,st2))))) ((zero? st2) (flonum-branch! (commute-flonum-predicate predicate) - (LAP (FCOM (ST 0) (ST ,st1))))) + (LAP (FUCOM (ST 0) (ST ,st1))))) (else (flonum-branch! predicate (LAP (FLD (ST ,st1)) - (FCOMP (ST 0) (ST ,(1+ st2))))))))) + (FUCOMP (ST 0) (ST ,(1+ st2))))))))) (define-rule predicate (FLONUM-PRED-2-ARGS (? predicate) @@ -692,18 +692,15 @@ USA. (define (flonum-compare-zero predicate source) (let ((sti (flonum-source! source))) - (if (zero? sti) - (flonum-branch! predicate - (LAP (FTST))) - (flonum-branch! (commute-flonum-predicate predicate) - (LAP (FLDZ) - (FCOMP (ST 0) (ST ,(1+ sti)))))))) + (flonum-branch! (commute-flonum-predicate predicate) + (LAP (FLDZ) + (FUCOMP (ST 0) (ST ,(1+ sti))))))) (define (flonum-compare-one predicate source) (let ((sti (flonum-source! source))) (flonum-branch! (commute-flonum-predicate predicate) (LAP (FLD1) - (FCOMP (ST 0) (ST ,(1+ sti))))))) + (FUCOMP (ST 0) (ST ,(1+ sti))))))) (define (commute-flonum-predicate pred) (case pred diff --git a/src/microcode/cmpauxmd/i386.m4 b/src/microcode/cmpauxmd/i386.m4 index a779873c5..33cf5476c 100644 --- a/src/microcode/cmpauxmd/i386.m4 +++ b/src/microcode/cmpauxmd/i386.m4 @@ -984,7 +984,8 @@ define_hook_label(generic_$1) jne asm_generic_$1_fail OP(and,l) TW(rmask,REG(edx)) OP(fld,l) DOF(4,REG(edx)) - ftst + fldz + fucomp ST(1) fstsw REG(ax) fstp ST(0) sahf @@ -1088,7 +1089,8 @@ asm_generic_divide_flo_flo: OP(mov,l) TW(REG(ebx),REG(ecx)) OP(and,l) TW(rmask,REG(ecx)) OP(fld,l) DOF(4,REG(ecx)) # fldd - ftst + fldz + fucomp ST(1) fstsw REG(ax) sahf je asm_generic_divide_by_zero