Re: [webkit-dev] jit, unordered compare

2009-10-16 Thread Zoltan Herczeg
Hi

fortunately, no, I don't need double branch here. cmpvs reg0, reg0 is a
conditional instruction, which only executes if the v flag is set.

My proposal would be to add a new DoubleCondition called DoubleEqualOrNAN,
or something similar to clarify what we expect from the conditional
branch. Since I feel (and by IEEE as you mentioned) a comparison to NaN
should be false, not true as x86 actually does.

Zoltan

 unfortunately cmf was used by the old fpa (floating point
 accelerator),
 which is replaced by vfp (vector floating point) for some time.
 Perhaps I
 can try a cmpvs reg0, reg0 instruction, which sets zero flag if one
 argument is NaN (since reg0 is always equal to reg0). Otherwise it
 does
 nothing (=nop).

 That should work, but it would require two branches instead of one
 (compare to 0, compare to self).

 I'm sure there must be a way to do an IEEE double comparison on ARM
 with only one branch.

 Geoff


___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] jit, unordered compare

2009-10-12 Thread Geoffrey Garen

Hi Zoltan.

I believe you're talking about this code for op_jfalse:


zeroDouble(fpRegT0);
emitLoadDouble(cond, fpRegT1);
addJump(branchDouble(DoubleEqual, fpRegT0, fpRegT1), target);


and this code for op_jtrue:


zeroDouble(fpRegT0);
emitLoadDouble(cond, fpRegT1);
addJump(branchDouble(DoubleNotEqual, fpRegT0, fpRegT1),  
target);


The goal of this code is to perform a comparison that distinguishes  
{ 0, NaN } from all other doubles. op_jfalse should branch in the case  
of 0 or NaN, and, inversely, op_jtrue should branch in all other cases.


It sounds like the equal / zero condition does not indicate NaN on all  
platforms. Bummer.


I'm not an expert in ARM (or other floating point processors, for that  
matter), so I'm not sure what the best abstraction is for this notion  
of compares to zero as equal or unordered. Since IEEE double  
requires all comparisons to NaN to be implicitly false, I do expect  
that there is some efficient single branch that can do this on ARM.  
From http://www.heyrick.co.uk/assembler/fpops.html#cmf, it looks like  
the CMF instruction should be used to test for equality (ie when a  
BEQ or BNE is used afterwards) or to test for unorderedness (in the V  
flag).


Gavin, do you have any ideas here?

Geoff

On Oct 12, 2009, at 4:05 AM, Zoltan Herczeg wrote:


Hi,

My stougle with USE_JSVALUE32_64 still continues on ARM. In
emit_op_jfalse, there is a comparison here (fpRegT0 contains 0.0):
addJump(branchDouble(DoubleEqual, fpRegT0, fpRegT1), target + 2);

In x86, if either operand is NaN, the zero flag is set by definition
(ucomisd instruction). I have no idea why (NaN == anything is true?).
Unfortunately, ARM does not set the zero flag. What would be a  
portable
way to improve this instruction? (and emit_op_jtrue) Perhaps this  
affects

the possible thumb2 implementation with USE_JSVALUE32_64 as well.

Zoltan


___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] jit, unordered compare

2009-10-12 Thread Zoltan Herczeg
Hi,

unfortunately cmf was used by the old fpa (floating point accelerator),
which is replaced by vfp (vector floating point) for some time. Perhaps I
can try a cmpvs reg0, reg0 instruction, which sets zero flag if one
argument is NaN (since reg0 is always equal to reg0). Otherwise it does
nothing (=nop).

Zoltan

 Hi Zoltan.

 I believe you're talking about this code for op_jfalse:

 zeroDouble(fpRegT0);
 emitLoadDouble(cond, fpRegT1);
 addJump(branchDouble(DoubleEqual, fpRegT0, fpRegT1), target);

 and this code for op_jtrue:

 zeroDouble(fpRegT0);
 emitLoadDouble(cond, fpRegT1);
 addJump(branchDouble(DoubleNotEqual, fpRegT0, fpRegT1),
 target);

 The goal of this code is to perform a comparison that distinguishes
 { 0, NaN } from all other doubles. op_jfalse should branch in the case
 of 0 or NaN, and, inversely, op_jtrue should branch in all other cases.

 It sounds like the equal / zero condition does not indicate NaN on all
 platforms. Bummer.

 I'm not an expert in ARM (or other floating point processors, for that
 matter), so I'm not sure what the best abstraction is for this notion
 of compares to zero as equal or unordered. Since IEEE double
 requires all comparisons to NaN to be implicitly false, I do expect
 that there is some efficient single branch that can do this on ARM.
  From http://www.heyrick.co.uk/assembler/fpops.html#cmf, it looks like
 the CMF instruction should be used to test for equality (ie when a
 BEQ or BNE is used afterwards) or to test for unorderedness (in the V
 flag).

 Gavin, do you have any ideas here?

 Geoff

 On Oct 12, 2009, at 4:05 AM, Zoltan Herczeg wrote:

 Hi,

 My stougle with USE_JSVALUE32_64 still continues on ARM. In
 emit_op_jfalse, there is a comparison here (fpRegT0 contains 0.0):
 addJump(branchDouble(DoubleEqual, fpRegT0, fpRegT1), target + 2);

 In x86, if either operand is NaN, the zero flag is set by definition
 (ucomisd instruction). I have no idea why (NaN == anything is true?).
 Unfortunately, ARM does not set the zero flag. What would be a
 portable
 way to improve this instruction? (and emit_op_jtrue) Perhaps this
 affects
 the possible thumb2 implementation with USE_JSVALUE32_64 as well.

 Zoltan


 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev




___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] jit, unordered compare

2009-10-12 Thread Geoffrey Garen
unfortunately cmf was used by the old fpa (floating point  
accelerator),
which is replaced by vfp (vector floating point) for some time.  
Perhaps I

can try a cmpvs reg0, reg0 instruction, which sets zero flag if one
argument is NaN (since reg0 is always equal to reg0). Otherwise it  
does

nothing (=nop).


That should work, but it would require two branches instead of one  
(compare to 0, compare to self).


I'm sure there must be a way to do an IEEE double comparison on ARM  
with only one branch.


Geoff
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev