Building GCC with SSE/SSE2 enabled

Programming, for all ages and all languages.
Post Reply
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Building GCC with SSE/SSE2 enabled

Post by foliagecanine »

Hello.
I've recently figured out (or at least I think I've figured out) how to enable SSE/SSE2 in my kernel.
Now in my kernel (which uses a separate compiler than my userspace programs), I've included the -msse and -msse2 flags and it seems to have generated sse instructions since XMM0 is not 0.

However, for my userspace programs, I want SSE/SSE2 optimizations enabled by default (when -O3 is applied).
I've tried building with --enable-sse --enable-float --enable-sse2 but it still shows it not enabled:

Code: Select all

i686-tritium-gcc -Q --help=target | grep sse
  -mno-sse4                             [enabled]
  -msse                                 [disabled]
  -msse2                                [disabled]
  -msse2avx                             [disabled]
  -msse3                                [disabled]
  -msse4                                [disabled]
  -msse4.1                              [disabled]
  -msse4.2                              [disabled]
  -msse4a                               [disabled]
  -msse5
  -msseregparm                          [disabled]
  -mssse3                               [disabled]
  Known assembler dialects (for use with the -masm= option):
    387 387+sse 387,sse both sse sse+387 sse,387
On my linux system's default gcc, it shows -msse and -msse2 as [enabled].
My OS: TritiumOS
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: Building GCC with SSE/SSE2 enabled

Post by Octocontrabass »

Is your Linux system 64-bit?

Not all i686 CPUs support SSE2. You could try using --with-arch to specify a different CPU.
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Re: Building GCC with SSE/SSE2 enabled

Post by foliagecanine »

Octocontrabass wrote:Is your Linux system 64-bit?
Yes. I realize x86_64 processors are required to have at least SSE2 and therefore it is enabled by default.
Octocontrabass wrote:Not all i686 CPUs support SSE2. You could try using --with-arch to specify a different CPU.
But as far as I know, many since the early 2000s do (from googling, SSE2's been around in consumer PCs since 2001). The reason the compiler is i686 as opposed to x86_64 is because my OS is 32-bit.
However, just because it is 32-bit does not mean it shouldn't be able to run on 64-bit hardware (AFAIK, it should).

As for the --with-arch flag, is there a CPU that is x86 32-bit and has SSE2?
My OS: TritiumOS
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: Building GCC with SSE/SSE2 enabled

Post by Octocontrabass »

If you want a CPU that does SSE2 and not much else, choose "pentium4". You'll want to specify "--with-tune" as well.

If you're expecting to run on 64-bit hardware, try "x86-64". As far as I can tell, it's valid for 32-bit targets.

The whole list is here.
Post Reply