Should ghc -msse imply gcc -msse

Hi all, You can turn on e.g. SSE 4.1 by passing -msse4.2 to ghc. This doesn't currently imply that we compile any C code with -msse4.2 turned on, so if someone really want to use SSE4.2, they have to do: ghc -msse4,2 -optc-msse4.2 Do we want to change this so it's enough to pass -msse4.2 to ghc? -- Johan

On 11 January 2013 06:10, Johan Tibell
Hi all,
You can turn on e.g. SSE 4.1 by passing -msse4.2 to ghc. This doesn't currently imply that we compile any C code with -msse4.2 turned on, so if someone really want to use SSE4.2, they have to do:
ghc -msse4,2 -optc-msse4.2
Do we want to change this so it's enough to pass -msse4.2 to ghc?
+1, I'd expect the flag to affect all compiled code (I'd be passing -msse4.2 to make it go faster). If anyone really wanted the C code to be compiled without (perhaps for debugging the code generator), they could run something like: ghc -msse4,2 -optc-no-msse4.2 Conrad.

Hi all, I forgot I once raised this on the GHC bug tracker: http://hackage.haskell.org/trac/ghc/ticket/7025 Here's what Simon M had to say back then: "The right thing is to put -msse in the cc-options field of your .cabal file, if that's what you want. I'm distinctly uneasy about having -msse magically pass through to gcc. * There are many flags that we do not pass through to gcc, so having one that we do pass through could be confusing (and lead to lots more requests for more flags to be passed through) * What if there is a variant of -msse that gcc supports but we don't? Wouldn't we have to keep them in sync? I'm going to close this as wontfix, but please feel free to reopen and disagree."

On Thu, Jan 17, 2013 at 12:01 PM, Johan Tibell
I forgot I once raised this on the GHC bug tracker: http://hackage.haskell.org/trac/ghc/ticket/7025
Here's what Simon M had to say back then:
"The right thing is to put -msse in the cc-options field of your .cabal file, if that's what you want.
I'm distinctly uneasy about having -msse magically pass through to gcc.
* There are many flags that we do not pass through to gcc, so having one that we do pass through could be confusing (and lead to lots more requests for more flags to be passed through)
* What if there is a variant of -msse that gcc supports but we don't? Wouldn't we have to keep them in sync?
I'm going to close this as wontfix, but please feel free to reopen and disagree."
One problem with having the user set cc-options in addition to passing -msse to GHC, is that the user might not realize that he/she needs to do this. This is bad if you use -fllvm, as your -msse will essentially just be ignored as the LLVM primitives we use in the LLVM backend (e.g. for popcnt) won't convert to SSE instructions. Even worse, LLVM doesn't support a -msse flag, instead you need to use -mattr=+sse, so the user needs to be aware of this difference and change his/her flags depending on if we use the native backend or the LLVM backend. -- Johan

On 17/01/13 20:06, Johan Tibell wrote:
On Thu, Jan 17, 2013 at 12:01 PM, Johan Tibell
wrote: I forgot I once raised this on the GHC bug tracker: http://hackage.haskell.org/trac/ghc/ticket/7025
Here's what Simon M had to say back then:
"The right thing is to put -msse in the cc-options field of your .cabal file, if that's what you want.
I'm distinctly uneasy about having -msse magically pass through to gcc.
* There are many flags that we do not pass through to gcc, so having one that we do pass through could be confusing (and lead to lots more requests for more flags to be passed through)
* What if there is a variant of -msse that gcc supports but we don't? Wouldn't we have to keep them in sync?
I'm going to close this as wontfix, but please feel free to reopen and disagree."
One problem with having the user set cc-options in addition to passing -msse to GHC, is that the user might not realize that he/she needs to do this. This is bad if you use -fllvm, as your -msse will essentially just be ignored as the LLVM primitives we use in the LLVM backend (e.g. for popcnt) won't convert to SSE instructions.
Even worse, LLVM doesn't support a -msse flag, instead you need to use -mattr=+sse, so the user needs to be aware of this difference and change his/her flags depending on if we use the native backend or the LLVM backend.
If the intended meaning of -msse is Use SSE instructions in Haskell compilations then of course we should pass -mattr=+sse to LLVM, because it is the backend for Haskell compilations. But we should not pass it to gcc, unless we're using the C backend. If instead the intended meaning of -msse is Use SSE instructions in all compilations then we should pass it to gcc too. This just feels a bit too magical to me, and since we have a way to say exactly what you want, I'm not sure it's necessary. Cheers, Simon

On Thu, Jan 17, 2013 at 12:29 PM, Simon Marlow
If the intended meaning of -msse is
Use SSE instructions in Haskell compilations
then of course we should pass -mattr=+sse to LLVM, because it is the backend for Haskell compilations. But we should not pass it to gcc, unless we're using the C backend.
Lets do at least this then. -- Johan
participants (3)
-
Conrad Parker
-
Johan Tibell
-
Simon Marlow