When using -march, wrong tuning flags are selected. E.g., -march=armv4t selects 'tune_flags' for arm600, instead of arm7tdmi (or similar). The error is in arm_override_options(). When "-march" is given, (sel - all_architectures) is calculated. In contrast, "-mcpu" calculates (sel - all_cores). This array index is stored in 'arm_tune' (arm.c:791) In arm.c:909 tune_flags are always taken from all_cores so that the calculated index references the wrong array when using "-march" tune_flags = all_cores[(int)arm_tune].flags;
The -march flag is not supposed to alter the tuning. Use -mtune or -mcpu, as appropriate, if you want to do that.
The problem is that -march=xxx -mtune=yyy doesn't work. The arm_override_option function scans the options in the order -mtune, -march, -mcpu. So when -mtune is given, 'arm_tune' first set by -mtune and then overwritten with the wrong tune settings from -march. I think, this problem was introduced between gcc-3.4.3 and gcc-4.0.0. In 3.4.3 only -mtune sets 'arm_tune' where in 4.0.0 all three flags affect 'arm_tune'.
Ah! I understand now. Sorry, your initial report wasn't clear. Yes, I agree this is incorrect.
This is, of course, a regression from 3.4.x
Subject: Bug 21397 CVSROOT: /cvs/gcc Module name: gcc Changes by: rearnsha@gcc.gnu.org 2005-05-09 14:15:51 Modified files: gcc : ChangeLog gcc/config/arm : arm.c Log message: PR target/21397 * arm.c (ARM_OPT_SET_CPU, ARM_OPT_SET_ARCH, ARM_OPT_SET_TUNE): Define. (arm_override_options): Use them instead of manifest constants. Don't allow -march to override the -mtune setting. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8670&r2=2.8671 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/arm.c.diff?cvsroot=gcc&r1=1.451&r2=1.452
Subject: Bug 21397 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: rearnsha@gcc.gnu.org 2005-05-09 14:53:20 Modified files: gcc : ChangeLog gcc/config/arm : arm.c Log message: PR target/21397 * arm.c (ARM_OPT_SET_CPU, ARM_OPT_SET_ARCH, ARM_OPT_SET_TUNE): Define. (arm_override_options): Use them instead of manifest constants. Don't allow -march to override the -mtune setting. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.232&r2=2.7592.2.233 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/arm.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.430.2.1&r2=1.430.2.2
fixed