fabs() intrinsic totally broken in P4, as of 2002-02-11

Jan Hubicka jh@suse.cz
Sun Feb 17 09:05:00 GMT 2002


> I found this out after half an hour spent staring at some code which had
> suddenly broken when compiled with -march=pentium4.
> 
> Consider the program
> 
> #include <math.h>
> #include <stdio.h>
> 
> int main(void)
> {
> double a,b,c;
> double d,e,f;
> scanf("%lf %lf %lf",&a,&b,&c);
> d=fabs(a);e=fabs(b);f=fabs(c);
> printf("%f %f %f %f %f %f\n",a,b,c,d,e,f);
> return 0;
> }

I can't run the SSE binarry here, but after the attached fix I get
seemingly correct assembly.  The same bug has been disussed with Lars
in other email.

Bootstrapped/regtested i686

Sun Feb 17 18:00:34 CET 2002  Jan Hubicka  <jh@suse.cz>

	* regrename.c (kill_set_value): Handle subregs properly.

Index: regrename.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regrename.c,v
retrieving revision 1.42
diff -c -3 -p -r1.42 regrename.c
*** regrename.c	2002/02/13 22:44:12	1.42
--- regrename.c	2002/02/17 17:00:11
*************** kill_set_value (x, set, data)
*** 1186,1195 ****
       void *data;
  {
    struct value_data *vd = data;
!   if (GET_CODE (set) != CLOBBER && REG_P (x))
      {
        kill_value (x, vd);
!       set_value_regno (REGNO (x), GET_MODE (x), vd);
      }
  }
  
--- 1186,1196 ----
       void *data;
  {
    struct value_data *vd = data;
!   if (GET_CODE (set) != CLOBBER)
      {
        kill_value (x, vd);
!       if (REG_P (x))
!         set_value_regno (REGNO (x), GET_MODE (x), vd);
      }
  }
  



More information about the Gcc mailing list