4

My C++ application (compiled using g++) needs to work on Pentium-4 (32-bit) and above. However, it's typically used with Core2Duo or better processors.

I'm currently using: -march=pentium4 -mtune=pentium4. But some reading has prompted me to think that -march=pentium4 -mtune=generic might be better.

Can anybody shed some light on this? What are the optimal values for march & mtune options in this case?

Platform: GCC 4.1.2 on RHEL 5.3 (32-bit).

Syam
  • 163
  • 1
  • 8

1 Answers1

5

That would be -march=pentium4 -mtune=core2, as can be seen on the GCC manual.

ninjalj
  • 42,493
  • 9
  • 106
  • 148
  • Why did you select "-march=pentium4 -mtune=core2"? For which version is it the best? The newer gcc (4.6.1) has no problem with instruction scheduling for `arch=core2`. – osgx Jul 21 '11 at 17:00
  • 1
    The OP asked for something that would run on >= Pentium4 and be normally used on core2 – ninjalj Jul 21 '11 at 17:06
  • 1
    i.e. -march=core2 includes instructions not available on Pentium4 and -mtune just controls instruction scheduling. – ninjalj Jul 21 '11 at 17:08
  • But is it any good to have -mtune=core2 when -march=pentium4, since only pentium4 compatible instruction set will be used anyway? – Syam Jul 22 '11 at 15:47
  • 3
    @Syam: `-mtune` changes instruction scheduling (i.e. how to order instructions to get optimal performance). – ninjalj Jul 22 '11 at 15:57