bebbo / gcc

Bebbo's gcc-6-branch for m68k-amigaos
GNU General Public License v2.0
33 stars 11 forks source link

cosf with -mhard-float and -ffast-math #233

Closed BSzili closed 2 months ago

BSzili commented 2 months ago

I had illegal instruction crashes when calling trigonometric functions with fast-math, and it seems like it tries to jump with a positive offset for the MathIEEE* libraries. For example cosf becomes jsr (42,a3) instead of jsr a6@(-0x2a:W), I put a snippet here: http://franke.ms/cex/z/Mde4Y9 Could you look into this please?

bebbo commented 2 months ago

it's the loop optimizer:

(insn 27 26 28 4 (set (reg:SI 14 a6)
        (mem/u:SI (symbol_ref:SI ("MathIeeeSingTransBase")) [0  S4 A16])) 39 {*movsi_m68k}
     (nil))

...
Set in insn 27 is invariant (0), cost 6, depends on 
Decided to move invariant 0 -- gain 6
...

but the register information is not transferred... ... well it does the assignment inside of the loop

r51:SI=[`MathIeeeSingTransBase']

...

39: a6:SI=r51:SI
28: d0:SF=call [a6:SI-0x2a] argc:0

So it's the cprop3 pass that drops the insn and uses r51 directly:

DCE: Deleting insn 39
deleting insn with uid = 39.
BSzili commented 2 months ago

I tried rebuilding after commit 4ad4e84, but unfortunately the snippet above still crashes. I could be completely off-base here, but I see jsr (42,a6) in the output, shouldn't this be jsr (-42,a6)?

BSzili commented 2 months ago

I think this solved the issue, thanks for the help!