PPro patch #3

H.J. Lu hjl@lucon.org
Mon Jun 8 07:11:00 GMT 1998


>   > 
>   > Please get PPro/II reference manual and check out fcomi. You will see
>   > PPro/II cannot handle unordered comparison directly which sets CC in a
>   > way compatible with integer comparison. BTW, Jim may know it since it
>   > is he who disabled fcomi, which hides the bug.
> I don't have a ppro manual here.
> 

I will give it a try. On PPro, there is

	fcomi %st(i),%st

which compares st(0) and %st(i) and sets the status flags ZF, PF and
CF in the EFLAGS register, which is used by conditional move. The
results are

Results		ZF	PF	CF
------------------------------------------------
st(0) > st(i)	0	0	0
st(0) < st(i)	0	0	1
st(0) = st(i)	1	0	0
unordered	1	1	1

For cmove/fcomve, it checks if ZF == 1. Everything works fine with
normal floating pointer number. But if one of st(0)/st(1) is NaN,
ZF, PF and CF will be set to all 1. In that case, cmove/fcomve will
generate incorrect results. Please remember all other conditional move
insns, which don't just check ZF only, work fine.

My solution is

	if compare is equality
	then
	  setne	%al
	  setp	%ax
	  or	%al,%ax
	endif

Now results are
								New
Results		ZF	PF	CF	al	ax    al|ax 	ZF
------------------------------------------------------------------
st(0) > st(i)	0	0	0	1	0	1	0	
st(0) < st(i)	0	0	1	1	0	1	0
st(0) = st(i)	1	0	0	0	0	0	1
unordered	1	1	1	0	1	1	0

so that if one of st(0)/st(1) is NaN, ZF will be 0.  I hope I have
made this clear now.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)



More information about the Gcc-patches mailing list