www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Questions about march/mcpu/mattr and good generic defaults

reply "Mikko Ronkainen" <mikoro iki.fi> writes:
Do -m32/m64 just mean -march=x86/x86-64? Or do they something 
else too?

To create a generic 32-bit program, are these sane choices:

-m32 -mcpu=i686 -mattr=sse2 ?

I see 100% performance increase between sse2 and sse/none. 
Optimizer seems to like quite a lot.

And with 64-bit:

-m64 -mcpu=x86_64 -mattr=avx ?

Not sure about the avx though, doesn't seem to help my program 
anymore than sse2.
Dec 19 2013
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Mikko Ronkainen:

 Do -m32/m64 just mean -march=x86/x86-64?
Right.
 To create a generic 32-bit program, are these sane choices:

 -m32 -mcpu=i686 -mattr=sse2 ?
I think sse2 is active on default on Windows.
 I see 100% performance increase between sse2 and sse/none. 
 Optimizer seems to like quite a lot.
Right, I think LLVM used to produce SSE code before being able to produce the older stack-based FP code. So LLVM likes SSE code a lot. It's the standard. Bye, bearophile
Dec 19 2013
prev sibling parent "David Nadlinger" <code klickverbot.at> writes:
On Thursday, 19 December 2013 at 23:28:50 UTC, Mikko Ronkainen 
wrote:
 Do -m32/m64 just mean -march=x86/x86-64? Or do they something 
 else too?
They generally switch between 32/64 bit subtargets for different processor families, not just x86. But yes, they just set the general target architecture. For the default -mcpu settings this implies on the various operating systems, see: https://github.com/ldc-developers/ldc/blob/master/driver/targetmachine.cpp#L30
 To create a generic 32-bit program, are these sane choices:

 -m32 -mcpu=i686 -mattr=sse2 ?
Depends on what level of backward-compatibility you need. All 64 bit processors support SSE2 (which is why it is enabled by default there).
 And with 64-bit:

 -m64 -mcpu=x86_64 -mattr=avx ?

 Not sure about the avx though, doesn't seem to help my program 
 anymore than sse2.
You definitely can't expect 64 bit machines out in the wild to have AVX yet. For example, the Core i7 in the mid-2010 MacBook Pro I'm typing this message on doesn't support it. On the other hand, if you want to compile your program only for a few machines with similar processors you control, you could also try using -mcpu=native to let LDC auto-detect the available features. David
Dec 23 2013