Another f77 bug, and an apparent fix
chris at umcp-cs.UUCP
chris at umcp-cs.UUCP
Thu Nov 3 21:00:14 AEST 1983
Bug:
f77 crashes with "no table entry for op REG".
Repeat-By:
Try compiling this program:
program bug
f1=bt*.5*(1./e-e*exp(-2.*x))
end
If you get that error during the compilation, you have the bug.
Fix:
Not sure that this is correct, but: change the entry in
../src/cmd/pcc/table.c, around line 750, which reads
ASG OPFLOAT, INAREG|INTAREG|FOREFF|FORCC,
SAREG|AWD, TFLOAT,
SAREG|AWD, TDOUBLE,
NAREG, RLEFT|RESC1|RESCC,
" cvtfd AL,A1\n OD2 AR,A1\n cvtdf A1,AL\n",
to
ASG OPFLOAT, INAREG|INTAREG|FOREFF|FORCC,
SAREG|AWD, TFLOAT,
SAREG|AWD, TDOUBLE,
2*NTEMP, RLEFT|RESC1|RESCC,
" cvtfd AL,A1\n OD2 AR,A1\n cvtdf A1,AL\n",
(You might search for "cvtfd"; there aren't many.)
From one night's hacking, it appears that NAREG says that
the operation needs a temporary register for its results.
The only thing is that the operation needs *two* temporary
registers. When the code generator goes to compute the
ASG OPFLOAT, in the particular example above, it finds that
there are no temporary registers (register pairs that is)
available. It then tries to use the default rewrite rule
for ASG OP operations, and ends up trying to simplify a
register (!). It can't, so it gives up in disgust. With
the 2*NTEMP, it knows to reserve the space it needs (and
in this program winds up using stack space).
This fix would also apply to the C compiler, except that
the C compiler always does things in double precision and
never needs to convert floats to doubles for intermediate
results (at least it doesn't need to at this level).
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci
UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris.umcp-cs at CSNet-Relay
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list