Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the minimum target CPU architecture for the various versions of Visual Studio?

What is the minimum target processor architecture (indicated with _M_IX86 predefined macros) supported by every version of Visual Studio 2008, 2010 and 2012?

For example, MSVS 2012 supports only Pentium Pro and higher.

like image 415
Artem Romanov Avatar asked Feb 13 '23 03:02

Artem Romanov


1 Answers

The classic switch for this was /G. Your available options differed for different versions of the compiler (with newer versions dropping older options, albeit continuing to accept them for compatibility reasons). Here's what you got:

  • /G3 built code that was optimized for 386 processors (_M_IX86 was set to 300)
  • /G4 for the 486 processor (_M_IX86 was set to 400)
  • /G5 built code that was optimized for the Pentium (_M_IX86 was set to 500)
  • /G6 built code that was optimized for the Pentium Pro, II, and III (_M_IX86 was set to 600)
  • /G7 built code that was optimized for the Pentium 4 or AMD Athlon (_M_IX86 was set to 700)

  • /GB specified either "blend" mode or the lowest common denominator that was reasonable when that version of the compiler was released. This was the default option if no other was specified.

And of course, it bears explicit mention that setting this option to optimize for a newer processor architecture did not prevent your code from running on an older processor architecture. It just wasn't optimized for that architecture and might run more slowly.

However, if you look up this compiler option in a current version of the documentation, you'll see no mention of any of this. All you see is something about Itanium processors (which we'll put aside). That's because the compiler shipping with VC++ 2005 dropped the /G3/G7 compiler options altogether:

[The] /G3, /G4, /G5, /G6, /G7, and /GB compiler options have been removed. The compiler now uses a "blended model" that attempts to create the best output file for all architectures.

So, although many of us remember it well from VC++ 6, this code generation setting was a historical curiosity only even as far back as VC++ 2008. Therefore I'm not sure where you get the impression that VS 2012 supports only the Pentium Pro. I can't find mention of that anywhere in the official documentation or elsewhere online. The limiting factor for version 2012 of the compiler is not the processor architecture but the OS version. If you've patched the compiler, libraries, and all the other accoutrements to support targeting Windows XP, then you will be able to run your application on an original Pentium-233, onto which you've masochistically shoe-horned Windows XP.

The purpose of the _M_IX86 macro is really just an indicator that you're targeting the Intel IA-32 processor family—more commonly known as good old 32-bit x86—in contrast to one of the other supported target architectures, like _M_AMD64 for 64-bit x86. You should just treat it as a defined/undefined value now.

Yes, the old table of values for _M_IX86 still appears in the latest version of the preprocessor documentation, but it is utterly obsolete. You'll note that other obsolete symbols appear there as well, such as _M_PPC: what was the last version of MSVC++ that shipped with a PowerPC compiler? 4.2?


But that is only part of the story. There are still other compiler options that govern code generation with respect to target architectures.

For example, the /arch switch. From the latest version of the documentation, you have the following options:

  • /arch:IA32 which essentially sets the lowest common denominator, using x87 for floating point
  • /arch:SSE which turns on SSE instructions
  • /arch:SSE2 which turns on SSE2 instructions (and is the default for x86)
  • /arch:AVX which turns on Intel Advanced Vector Extensions
  • /arch:AVX2 which turns on Intel Advanced Vector Extensions 2

    If you read the Remarks section, you'll also see that these options can imply more than just the specified instruction set. For example, since all processors that support SSE instructions also support the CMOV instruction, the CMOV instruction will be generated when /arch:SSE or higher is specified. The CMOV instruction has nothing to do with SSE; in fact, SSE was introduced with the Pentium III while CMOV was introduced way back with the Pentium Pro. But it's guaranteed to be supported on any architectures that support SSE.

The other relevant option is controlled by the /favor switch. This was new starting with VC++ 2008, and was presumably the replacement for the old /G3/G7 options. As the documentation says:

  • /favor:blend is the default and produces code with no unique optimizations
  • /favor:INTEL64 generates code specific for Intel's implementation of x86-64
  • /favor:AMD64 generates code specific for AMD's implementation of x86-64
  • /favor:ATOM generates code specific for Intel's Atom processor
like image 63
Cody Gray Avatar answered May 02 '23 13:05

Cody Gray