home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!gdt!masjpf
- From: masjpf@gdr.bath.ac.uk (J P Fitch)
- Newsgroups: comp.arch
- Subject: SPARC Floating Point Query
- Message-ID: <1992Sep9.135913.12073@gdr.bath.ac.uk>
- Date: 9 Sep 92 13:59:13 GMT
- Organization: School of Mathematics, University of Bath, UK
- Lines: 84
-
- Can anyone throw any light on the following aspect of the SPARC?
-
- We have a trivial C program which calls double divide. Compiled to
- assembler it creates what one might expect. When we assemble the code
- and look with adb we find that the assembler has created an additional
- instruction, a fmovs, immediately after that fdivd. We cannot find
- anything in the documentation we have been able to find to explain
- why, or what it is trying to avoid. To make things worse, on an ICL
- DRS6000 (SPARC) it does not add this instruction, and seems to work.
- When I force it to avoid the extra fmovs (when we are in doubles!) it
- seems to work in some contexts but not others.
- So what is the problem? Below I give the full exhibits.
- ==John
-
-
-
- The Program
- ===========
-
- int foo (x,y)double x; double y;{ return x/y;}
-
- which when passed through SUN's C compiler generates the assembler
-
- LL0:
- .seg "data"
- .seg "text"
- .proc 04
- .global _foo
- _foo:
- !#PROLOGUE# 0
- sethi %hi(LF12),%g1
- add %g1,%lo(LF12),%g1
- save %sp,%g1,%sp
- !#PROLOGUE# 1
- st %i0,[%fp+0x44]
- st %i1,[%fp+0x48]
- st %i2,[%fp+0x4c]
- st %i3,[%fp+0x50]
- ld2 [%fp+0x44],%f0
- ld2 [%fp+0x4c],%f2
- fdivd %f0,%f2,%f4 <<< Note well
- fdtoi %f4,%f5
- st %f5,[%sp+LP12]
- ld [%sp+LP12],%o0
- b LE12
- nop
- LE12:
- mov %o0,%i0
- ret
- restore
- LF12 = -72
- LP12 = 64
- LST12 = 72
- LT12 = 72
- .seg "data"
-
-
- The Binary
- ==========
-
- If I now assemble this and look at the disassemly (with adb) I get
-
- foo?i
- _foo: sethi %hi(0xfffffc00), %g1
- _foo+4: add %g1, 0x3b8, %g1 ! -0x48
- _foo+8: save %sp, %g1, %sp
- _foo+0xc: st %i0, [%fp + 0x44]
- _foo+0x10: st %i1, [%fp + 0x48]
- _foo+0x14: st %i2, [%fp + 0x4c]
- _foo+0x18: st %i3, [%fp + 0x50]
- _foo+0x1c: ld [%fp + 0x44], %f0
- _foo+0x20: ld [%fp + 0x48], %f1
- _foo+0x24: ld [%fp + 0x4c], %f2
- _foo+0x28: ld [%fp + 0x50], %f3
- _foo+0x2c: fdivd %f0, %f2, %f4
- _foo+0x30: fmovs %f4, %f4 <<< Note
- _foo+0x34: fdtoi %f4, %f5
- _foo+0x38: st %f5, [%sp + 0x40]
- _foo+0x3c: ld [%sp + 0x40], %o0
- _foo+0x40: ba _foo + 0x48
- _foo+0x44: nop
- _foo+0x48: mov %o0, %i0
- _foo+0x4c: ret
- _foo+0x50: restore
-