home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / arch / 9306 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  2.3 KB

  1. Path: sparky!uunet!mcsun!uknet!gdt!masjpf
  2. From: masjpf@gdr.bath.ac.uk (J P Fitch)
  3. Newsgroups: comp.arch
  4. Subject: SPARC Floating Point Query
  5. Message-ID: <1992Sep9.135913.12073@gdr.bath.ac.uk>
  6. Date: 9 Sep 92 13:59:13 GMT
  7. Organization: School of Mathematics, University of Bath, UK
  8. Lines: 84
  9.  
  10. Can anyone throw any light on the following aspect of the SPARC?
  11.  
  12. We have a trivial C program which calls double divide.  Compiled to
  13. assembler it creates what one might expect.  When we assemble the code
  14. and look with adb we find that the assembler has created an additional
  15. instruction, a fmovs, immediately after that fdivd.  We cannot find
  16. anything in the documentation we have been able to find to explain
  17. why, or what it is trying to avoid.  To make things worse, on an ICL
  18. DRS6000 (SPARC) it does not add this instruction, and seems to work.
  19. When I force it to avoid the extra fmovs (when we are in doubles!) it
  20. seems to work in some contexts but not others.
  21.   So what is the problem?  Below I give the full exhibits.
  22. ==John
  23.  
  24.  
  25.  
  26. The Program
  27. ===========
  28.  
  29. int foo (x,y)double x; double y;{ return x/y;}
  30.  
  31. which when passed through SUN's C compiler generates the assembler
  32.  
  33. LL0:
  34.     .seg    "data"
  35.     .seg    "text"
  36.     .proc 04
  37.     .global    _foo
  38. _foo:
  39.     !#PROLOGUE# 0
  40.     sethi    %hi(LF12),%g1
  41.     add    %g1,%lo(LF12),%g1
  42.     save    %sp,%g1,%sp
  43.     !#PROLOGUE# 1
  44.     st    %i0,[%fp+0x44]
  45.     st    %i1,[%fp+0x48]
  46.     st    %i2,[%fp+0x4c]
  47.     st    %i3,[%fp+0x50]
  48.     ld2    [%fp+0x44],%f0
  49.     ld2    [%fp+0x4c],%f2
  50.     fdivd    %f0,%f2,%f4        <<< Note well
  51.     fdtoi    %f4,%f5
  52.     st    %f5,[%sp+LP12]
  53.     ld    [%sp+LP12],%o0
  54.     b    LE12
  55.     nop
  56. LE12:
  57.     mov    %o0,%i0
  58.     ret
  59.     restore
  60.        LF12 = -72
  61.     LP12 = 64
  62.     LST12 = 72
  63.     LT12 = 72
  64.     .seg    "data"
  65.  
  66.  
  67. The Binary
  68. ==========
  69.  
  70. If I now assemble this and look at the disassemly (with adb) I get
  71.  
  72. foo?i
  73. _foo:        sethi    %hi(0xfffffc00), %g1
  74. _foo+4:        add    %g1, 0x3b8, %g1         ! -0x48
  75. _foo+8:        save    %sp, %g1, %sp
  76. _foo+0xc:    st    %i0, [%fp + 0x44]
  77. _foo+0x10:    st    %i1, [%fp + 0x48]
  78. _foo+0x14:    st    %i2, [%fp + 0x4c]
  79. _foo+0x18:    st    %i3, [%fp + 0x50]
  80. _foo+0x1c:    ld    [%fp + 0x44], %f0
  81. _foo+0x20:    ld    [%fp + 0x48], %f1
  82. _foo+0x24:    ld    [%fp + 0x4c], %f2
  83. _foo+0x28:    ld    [%fp + 0x50], %f3
  84. _foo+0x2c:    fdivd    %f0, %f2, %f4
  85. _foo+0x30:    fmovs    %f4, %f4        <<< Note
  86. _foo+0x34:    fdtoi    %f4, %f5
  87. _foo+0x38:    st    %f5, [%sp + 0x40]
  88. _foo+0x3c:    ld    [%sp + 0x40], %o0
  89. _foo+0x40:    ba    _foo + 0x48
  90. _foo+0x44:    nop
  91. _foo+0x48:    mov    %o0, %i0
  92. _foo+0x4c:    ret
  93. _foo+0x50:    restore
  94.