Mail Archives: djgpp/2000/04/14/13:56:03
Alexei A. Frounze <alex DOT fru AT mtu-net DOT ru> wrote:
> __asm__ __volatile__ ("
> fmull (%0)"
> :
> : "g" (&variable)
> );
[...]
> But with use of the ``"g" ()'' thing I can't know what will the
> optimizer do. So, I can't know where I should put those parentheses and
> where I should not.
Exactly. The problem is that with the AT&T assembly syntax used by gas
and gcc, it may well be impossible to use the "g" constraint for any
input/output operand. Please do keep in mind that gcc is a
multiplatform compiler, and that you're rather deep inside its guts,
here, so some things that were put into it for other platforms may not
make sense at all, on an Intel one.
> Of course I can use the ``"r" ()'' instead, but this
> means I work instead of the optimizer, but do I have to do *its* job?
No. You just write your code, in whatever way you like. Then you let
GCC do its job, by telling it how you did yours, as correctly as
possible. I.e. if you decided to use a register for that operand,
write
fmull (%0)
and tell GCC to use a register, by the "r" constraint. If, OTOH, you
decide you want to address memory directly, you can write
fmull %0
and tell GCC to use direct memory reference ("m" that is, I think).
GCC doesn't read the assembly you wrote, as I already pointed out, so
it cannot modify it according to its choice, in the way you think it
should.
> I think no. It must figure out what to do itself and it must not generate
> faulty source code. *Optimizing* doesn't mean *adding bugs*.
It doesn't add a bug, here. The bug's still in your code, as your
assembly operation is not as flexible as the your use of the "g"
constraint claims it is.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -