[fpc-pascal] generated assembler
Florian Klaempfl
florian at freepascal.org
Fri Sep 22 10:51:23 CEST 2006
Vincent Snijders wrote:
> Florian Klaempfl schreef:
>>>
>>>
>>> Line 17 generates two assembler instructions. Line 22 generates three
>>> assembler instructions. As far as I can see both high(d) and @d[high(d)]
>>> are constants, because d is a global variable.
>>>
>>> Is it possible that line 22 will generate 2 assembler instructions in
>>> the future? Or is this a limitation of the i386 assembler? Or do I make
>>> a mistake in my reasoning?
>>
>> No, you aren't, however, the problem of this benchmark are the
>> inserted fwaits
>> which are necessary to get fpu exceptions at correct lines. The best
>> would be to
>> introduce a switch which prevents the fwaits.
>
> Aha, that explains why explicit subexpression elimination fails too.
Yes, an fwait patch would help a lot here :) Even more, because C doesn't insert
these fwaits neither.
>
> using comon expression, less calculations:
> distance:=sqrt(sqr(dx)+sqr(dy)+sqr(dz));
> mag := dt / (distance*distance*distance);
> but this is faster:
> distance:=sqrt(sqr(dx)+sqr(dy)+sqr(dz));
> mag := dt /
> (sqrt(sqr(dx)+sqr(dy)+sqr(dz))*(sqr(dx)+sqr(dy)+sqr(dz)));
>
> using comon expression, less calculations:
> b1mag := b1^.mass * mag;
> b2^.vx := b2^.vx + dx * b1mag;
> b2^.vy := b2^.vy + dy * b1mag;
> b2^.vz := b2^.vz + dz * b1mag;
> but this is faster:
> b2^.vx := b2^.vx + dx * b1^.mass * mag;
> b2^.vy := b2^.vy + dy * b1^.mass * mag;
> b2^.vz := b2^.vz + dz * b1^.mass * mag;
>
> Vincent
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list