fesetenv() does not work on hppa with gcc 4.3, as gcc optimizes out most of the code. This is due to wrong input/output operands/constraints.
Created attachment 2730 [details] Patch to fix the problem.
Aurel, Thanks for doing the work in this case. I appreciate your efforts. @@ -35,7 +35,7 @@ fesetenv (const fenv_t *envp) bufptr = temp.buf; __asm__ ( "fstd,ma %%fr0,8(%1)\n" - : "=m" (temp), "+r" (bufptr) : : "%r0"); + : "=m" (temp) : "r" (bufptr) : "%r0"); This looks correct, and if it prevents the compiler from optimizing away later stores into the union, then that's good. I don't think this is the bug. @@ -56,7 +56,7 @@ fesetenv (const fenv_t *envp) is loaded last and T-Bit is enabled. */ __asm__ ( "fldd,mb -8(%1),%%fr0\n" - : "=m" (temp), "+r" (bufptr) : : "%r0" ); + : : "m" (temp), "r" (bufptr) : "%r0" ); This is probably the real bug, temp should never have been an output. Removing the "=" (write-only) constraint and the "+" read/write constraint was the right thing to do (along with moving them to inputs). What is the results of running the testsuite after this patch?
(In reply to comment #2) > Aurel, > > Thanks for doing the work in this case. I appreciate your efforts. > > @@ -35,7 +35,7 @@ fesetenv (const fenv_t *envp) > bufptr = temp.buf; > __asm__ ( > "fstd,ma %%fr0,8(%1)\n" > - : "=m" (temp), "+r" (bufptr) : : "%r0"); > + : "=m" (temp) : "r" (bufptr) : "%r0"); > > This looks correct, and if it prevents the compiler from optimizing away later > stores into the union, then that's good. I don't think this is the bug. I confirm this change is actually not necessary to get fesetenv() working, but I prefered to do the change, so that it don't break with a future version of gcc. > @@ -56,7 +56,7 @@ fesetenv (const fenv_t *envp) > is loaded last and T-Bit is enabled. */ > __asm__ ( > "fldd,mb -8(%1),%%fr0\n" > - : "=m" (temp), "+r" (bufptr) : : "%r0" ); > + : : "m" (temp), "r" (bufptr) : "%r0" ); > > This is probably the real bug, temp should never have been an output. Removing > the "=" (write-only) constraint and the "+" read/write constraint was the right > thing to do (along with moving them to inputs). > > What is the results of running the testsuite after this patch? Oh, I forget to tell that with this patch test-fenv now passes with gcc-4.3. Otherwise, it does not include any regression.
Subject: Bug 6506 CVSROOT: /cvs/glibc Module name: ports Changes by: carlos@sourceware.org 2008-05-12 12:09:21 Modified files: . : ChangeLog.hppa sysdeps/hppa/fpu: fesetenv.c Log message: 2008-05-12 Aurelien Jarno <aurelien@aurel32.net> [BZ #6506] * sysdeps/hppa/fpu/fesetenv.c: bufptr is always read, temp is read while writing back status word. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/ports/ChangeLog.hppa.diff?cvsroot=glibc&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/ports/sysdeps/hppa/fpu/fesetenv.c.diff?cvsroot=glibc&r1=1.5&r2=1.6
Aurel, Thank for the good work. The patch looks good. I've checked it in. Marking this fixed.