Mail Archives: djgpp/1994/12/30/09:57:22
Happy New Year to everybody!
Optimizing a calculation program, I confronted the following problem:
the innermost loop contained a number of floating-point tests (which
were included in an attempt to reduce the number of operations), like
if (X > 0.0) ...; .
Looking at assembler, I found that this comparison is performed as
fldz
fcomp [X]
fnstsw ax
and [dummy var],ah
cmp [another var],ah
je ...
[translated into INTEL notations - E.S.]
This is a VERY inefficient code, and consumes a lot of time in my
program. Other opportunities include, e.g. considering the highest
word of X as signed integer since the sign of a IEEE float is stored
in its highest bit:
cmpb [X+sizeof(X)-sizeof(byte)],0
jl ...
[Equivalent in C should be possible by some ugly type-casting]
Such code is of course purely platform-specific, and ideally should
be generated by the compiler itself.
Before I start playing with non-portable codes, I'd like to ask, if
there is some switch, which will enable generating of such 80x86
specific code? I tried -m486 (which should be in DJGPP by default
anyway) and -O3, without success.
Zhenya.
----
E.Sorokin TU Vienna, IAEE
Tel +43(1)58801 -3703, -3948 Gusshausstr. 27/359-9
Fax +43(1)504 2477 A-1040 Vienna, Austria
- Raw text -