In the following code, when compiled with -mhard-float, the single precision floating point to integer conversion instruction is not emitted, instead the software routine for conversion is called.
This has been noted in OR1K's GCC port machine description file, or32.md, but putting it here so too.
Code:
int main(void) { volatile float test = 1234.567f; return (int) test; }
Compiled with:
$ or32-linux-gcc -mhard-float -O2 ftoi.c -o ftoi
Disassembly ( commenting added):
000001d8 <main>: 1d8: 18 60 00 00 l.movhi r3,0x0 1dc: d7 e1 4f fc l.sw 0xfffffffc(r1),r9 1e0: a8 63 3a 88 l.ori r3,r3,0x3a88 ; FP Data loc, see below. 1e4: 9c 21 ff f8 l.addi r1,r1,0xfffffff8 1e8: 84 63 00 00 l.lwz r3,0x0(r3) ; Load FP data 1ec: d4 01 18 00 l.sw 0x0(r1),r3 ; Store same data 1f0: 84 61 00 00 l.lwz r3,0x0(r1) ; Load same data 1f4: 04 00 03 f4 l.jal 11c4 <__fixsfsi> ; Call SW conv. func. 1f8: 15 00 00 00 l.nop 0x0 1fc: 9c 21 00 08 l.addi r1,r1,0x8 200: 85 21 ff fc l.lwz r9,0xfffffffc(r1) 204: 44 00 48 00 l.jr r9 208: 15 00 00 00 l.nop 0x0 ... ... 3a88: 44 9a 52 25 l.jr r10 ; = 1234.5670166015625 decimal
Formatting was ruined. This is highly annoying.
Trying again...
GCC not emitting float-to-integer conversion instructions and is instead always using the software routine.
Example code is:
int main(void) { volatile float test = 1234.567f; return (int) test; }
Compile with:
or32-linux-gcc -mhard-float -O2 ftoi.c -o ftoi
Disassembly I think ruins format so will omit it this time.
See here for disassembly that didn't get all its formating removed.
Fix found in substituting
(define_insn "fixunssfsi2"
for
(define_insn "fix_truncsfsi2"
in the OR32 machine description file.
Appears solved, but will close when it's committed to the repository.