When -mtune is used on AArch64 the -target-cpu is passed the value of the cpu given to -mtune. As well as setting micro-architectural features of the -mtune cpu, this will also add the architectural features such as support for instructions. This can result in the backend using instructions that are supported in the -mtune cpu but not supported in the target architecture. For example use of the v8.1-a LSE extensions with -march=v8.
This change removes the setting of -target-cpu for -mtune, the -mcpu must be used to set -target-cpu. This has the effect of removing all non-hard coded benefits of mtune but it does produce correct output when -mtune cpu with a later architecture than v8 is used. I've kept the hard-coded behaviour of -mtune for some Apple CPU codenames and have added in a call to check the -mtune cpu as there are some tests that depend on it.
Further work will be needed to implement -mtune properly, so that it affects only micro-architectural features.
fixes PR34625