This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c/4346: wrong float multiply with Sparc



>Number:         4346
>Category:       c
>Synopsis:       wrong float multiply with Sparc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 18 05:56:03 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Stephan Tassart
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
SunOS 5.7 Generic_106541-16 sun4u sparc SUNW,Ultra-5_10
>Description:
#include <stdio.h>

int main(int argv, char *argc[]) {
  float a1;
  double acc;
  a1 = -1.83351052f;
  acc = a1*a1;
  printf("%.40g\n",acc);
  return 0;
}

/* This code compiles wrong the floating multiplication 
on Sparc. It produces 
	ld	[%fp-20], %f2
	ld	[%fp-20], %f3
	fmuls	%f2, %f3, %f2
	fstod	%f2, %f4

i.e. 
  float32 x float32 -> float32
  cast(float32)     -> float64

Instead of

	ld	[%fp-20], %f2
	ld	[%fp-20], %f3
	fsmuld	%f2, %f3, %f4

i.e.
 float32 x float32 -> float64 


This produces a loss of a precision in the floating
point multiplication. (and because of this loss, same
code compiled on another plateform produces a different
output)
 */


>How-To-Repeat:
compile on sparc the forementionned code with 

gcc -S foo.c -o foo.s 
>Fix:
Dunno
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]