Bug 21397 - [4.0/4.1 regression] arm: -march overrides -mtune
Summary: [4.0/4.1 regression] arm: -march overrides -mtune
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Richard Earnshaw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-05 11:01 UTC by trauscher
Modified: 2005-05-09 15:04 UTC (History)
1 user (show)

See Also:
Host: i386-linux
Target: arm-*-elf
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-05-09 11:18:37


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description trauscher 2005-05-05 11:01:03 UTC
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;
Comment 1 Richard Earnshaw 2005-05-08 23:47:40 UTC
The -march flag is not supposed to alter the tuning.  Use -mtune or -mcpu, as
appropriate, if you want to do that.
Comment 2 trauscher 2005-05-09 07:04:36 UTC
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'.
Comment 3 Richard Earnshaw 2005-05-09 11:18:36 UTC
Ah! I understand now.  Sorry, your initial report wasn't clear.  Yes, I agree
this is incorrect.
Comment 4 Richard Earnshaw 2005-05-09 14:04:46 UTC
This is, of course, a regression from 3.4.x

Comment 5 GCC Commits 2005-05-09 14:20:20 UTC
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

Comment 6 GCC Commits 2005-05-09 14:53:33 UTC
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

Comment 7 Richard Earnshaw 2005-05-09 15:04:02 UTC
fixed