Hi,

Since bug 30255 has been declared as never going to be fixed, I've been
enjoying going through half a million lines of code looking for places where I
have to declare things long double to keep gcc from arbitrarily rounding down
intermediate results.  The problem now is that I have come across a case where
the exact opposite occurs: If I declare a variable long double, gcc inserts a
round to double before computing the square root, where it does not if I
declare it double.  I will upload the file seperately, but here's the section
of code:

   for (i=0; i < N; i++) t0 += X[i]*X[i];
   t0 = sqrt(t0);

When compiled with t0 declared as double, no spills are performed by gcc, and
80-bit accuracy is maintained throughout the computation (critical to avoid
overflow).  When declared as long double, however, the following code is
inserted:
        fstpl   16(%rsp)
        fldl    16(%rsp)
        fld     %st(0)
        fsqrt
So, a long double is rounded to double by gcc, even though there is no store in
the algorithm.  Any idea what is going on, and is there anything to be done?  I
will post the short file seperately.  You can gen both assemblies to see the
difference with
   gcc -O -mfpmath=387 -S nrm2.c  # gen double declaration
   gcc -O -mfpmath=387 -DLD_ -S nrm2.c # gen long double variant

Thanks,
Clint


-- 
           Summary: long double declaration rounds to double instead
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: whaley at cs dot utsa dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30599

Reply via email to