OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 2:42 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Building GCC with SSE/SSE2 enabled
PostPosted: Wed Aug 25, 2021 7:15 pm 
Offline
Member
Member

Joined: Sun Aug 23, 2020 4:35 pm
Posts: 148
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:
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?


Top
 Profile  
 
 Post subject: Re: Building GCC with SSE/SSE2 enabled
PostPosted: Thu Aug 26, 2021 9:03 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
Is your Linux system 64-bit?

Not all i686 CPUs support SSE2. You could try using --with-arch to specify a different CPU.


Top
 Profile  
 
 Post subject: Re: Building GCC with SSE/SSE2 enabled
PostPosted: Thu Aug 26, 2021 1:19 pm 
Offline
Member
Member

Joined: Sun Aug 23, 2020 4:35 pm
Posts: 148
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?


Top
 Profile  
 
 Post subject: Re: Building GCC with SSE/SSE2 enabled
PostPosted: Thu Aug 26, 2021 1:36 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group