This is the mail archive of the 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]
Other format: [Raw text]

Re: [doc, testsuite, libgfortran] Avoid use of SSE/SSE2/SSE3 on Solaris 8/9 x86

On Fri, 2010-07-09 at 15:22 +0200, Rainer Orth wrote:
> My first attempts to build mainline for Solaris 8/9 x86 have just been
> using the Solaris 8 and 9 assemblers on Solaris 11.  While a couple of
> problems could be sorted out this way, actually bootstrapping found a
> couple of others.  The most pressing one is that before Solaris 9 4/04,
> the Solaris kernel doesn't save and restore SSE and SSE2 registers, so
> any attempt to execute SSE/SSE2 instructions causes the program to
> receive SIGILL, even if the CPU supports the insns:
> Solaris/IA32 should save/restore SSE/SSE2 register set on context switch
> To avoid the problem, I globally default -march to pentiumpro on Solaris
> 8 and 9, not only for Solaris 8 with Sun as as in this patch:
> but there are still two areas that must be fixed because they use
> SSE/SSE2 instructions regardless:
> * libgfortran determines if the CPU is capable of executing SSE
>   instructions at runtime and uses them if so.  This check is not
>   enough and caused all Fortran exectution tests both in
>   gcc/testsuite/gfortran.* and libgomp to fail.
> * Similarly, the SSE/SSE2/SSE3 testcases in use the same
>   technique (cf.{, 2, 3}-check.h), and fail the same way.
> Unfortunately, this problem cannot easily be detected at runtime, as
> would be possible on Solaris 10+ with getisax(2), but we need to set up
> a signal handler, try some instruction, and act accordingly.
> Unfortunately, this is more involved than it may seem at first: you
> cannot simply return from a SIGILL handler after setting some flag
> variable, since the faulting instruction will be executed again, leading
> to an infinite loop.  My solution was inspired by the way GNU libsigsegv
> handles SEGV: they return from the signal handler with setcontext(2).  I
> can do the same here, provided I set set PC to the next instruction
> after the faulting one.  Therefore, I need to know exact insn lengths
> and preferably use insns with side effects that don't hurt.
> The meat of the patch which implements this can be found in
> libgfortran/config/fpu-387.h and  The
> former takes care of libgfortran, the latter of all tests using
> sse-check{, 2, 3}.h.  For the few remaining testcases that hardcode
> -msse or -msse2, I need some new effective-target keywords: sse for the
> ability to compile/assemble sse insns, sse_runtime and sse2_runtime for
> the ability to execute them.
> With this in place, I've been able to reduce testsuite failures from
> ca. 13000 to just a handful.  There will a few unrelated followup
> patches that bring Solaris 8/9 x86 testsuite results practically en par
> with Solaris 10 and 11.
> Bootstrapped without regressions on i386-pc-solaris2.{8, 9, 10, 11},
> both with Sun as and GNU as.
> At the moment, the 4.5 branch is broken on Solaris 8/9 x86, since it
> won't even bootstrap without --with-arch=pentiumpro on Solaris 8 and 9,
> which is a regression from 4.4.  Like this patch
> I'd like to backport the current one to the 4.4 and 4.5 branches after
> some soak time on mainline.
> Ok for mainline now and the 4.4 and 4.5 branches later?

This patch is OK, but please commit it without sse{,2}_runtime changes.

Please prepare another incremental patch that includes sse{,2}_runtime
stuff, we will discuss your approach separatelly.


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