On Wed, Aug 31, 2022 at 12:00:14PM -0500, Peter Bergner wrote:
> On 8/31/22 11:05 AM, Segher Boessenkool wrote:
> > On Wed, Aug 31, 2022 at 10:48:26AM -0500, Peter Bergner wrote:
> >> Ditto for -msoft-float better disable any -maltivec and -mvsx, etc.
> >
> > Oh? Why should it disable -maltivec? -mvsx makes a little sense on
> > one hand, but totally none on the other either.
>
> VSX has to be disabled, since VSX replies on the FP registers existing.
It doesn't? On a CPU supporting VSX the FP registers are overlaid on
the VSX registers, not the other way around.
GCC says
cc1: warning: '-mvsx' requires hardware floating point
and that's okay with me of course, but it doesn't say why it is
required. Implementation convenience coupled with lack of a use case
is my best guess :-)
OTOH VMX and hard float are completely orthogonal (the VMX FP things do
not even use the fpscr for example).
> As for Altivec, I'm pretty sure there are some inherent dependencies
> there, probably both in hardware and our GCC backend implementation.
> I could be wrong, but my guess is things will fall over the ground
> if as allow -maltivec along with -msoft-float. Does the linux kernel
> only build with -msoft-float assuming it disables altivec and vsx?
> Or does it explicitly always also add -mno-altivec?
No. Instead, it just works!
Try this:
===
typedef float vf __attribute__((vector_size(16)));
vf f(float x)
{
x *= 42;
return (vf){x, x, x, x};
}
===
with -maltivec -msoft-float. It does not use the FPRs, and it does use
the VMX registers and VMX instructions.
> So in linux*.h, we have the following which came from a 2004 commit from Alan:
>
> linux64.h:#define OS_MISSING_POWERPC64 !TARGET_64BIT
That macro returns 1 on OSes that do not properly support -mpowerpc64.
> ...so I think there was no real reason, other than old 64-bit linux kernels
> didn't
> save the upper register state in 32-bit mode binaries.
And it is still not saved in 32-bit user mode (setjmp/longjmp and
getcontext/setcontext). Most bigger programs will fail, and most
smaller programs (including everything in the GCC testsuite) work fine.
But we should not enable -mpowerpc64 on 32-bit Linux by default.
Segher