my kernel does not boot anymore on a ppc970 (powermac g5) due to an illegal instruction caused by gcc 4.5 research showed that the DI bswap64 operation is optimized to ldbrx even on power4, but causes an sigill there. gcc -m64 -c -O2 -mcpu=power4 -mtune=cell gcc/testsuite/gcc.target/powerpc/optimize-bswapdi-3.c ; objdump -d optimize-bswapdi-3.o 0000000000000000 <.swap64_load>: 0: 7c 00 1c 28 .long 0x7c001c28 4: 7c 03 03 78 mr r3,r0 8: 4e 80 00 20 blr while: gcc -m64 -c -O2 -mcpu=power4 gcc/testsuite/gcc.target/powerpc/optimize-bswapdi-3.c ; objdump -d optimize-bswapdi-3.o 0000000000000000 <.swap64_load>: 0: 39 20 00 04 li r9,4 4: 7c 00 1c 2c lwbrx r0,0,r3 8: 7d 69 1c 2c lwbrx r11,r9,r3 c: 79 6a 07 c6 rldicr r10,r11,32,31 10: 7d 4a 03 78 or r10,r10,r0 14: 7d 43 53 78 mr r3,r10 18: 4e 80 00 20 blr -mcpu=power4 -mtune=cell should not start to emit opcodes invalid on power4. I think the bswap64 emitter logic in config/rs6000/rs6000.md is incorrect
This was my fault to some extend; when I added =cell support I asked about if we should emit the cell instructions for -mtune= and the answer was that using -mtune=cell is most likely not going to be used. In fact -mtune=cell most likely produce much slower code on most other processors because of the non use of the dot instructions (and other stuff).
well, the kernel now does easier ... in arch/powerpc/Makefile: ifeq ($(CONFIG_TUNE_CELL),y) KBUILD_CFLAGS += $(call cc-option,-mtune=cell) endif
Confirmed. Adding spu maintainers to CC.
Still happens. rs6000_cpu is set based on the -mtune= setting instead of based on the -mcpu setting. I'll take it.
Author: segher Date: Sat Dec 2 01:23:41 2017 New Revision: 255349 URL: https://gcc.gnu.org/viewcvs?rev=255349&root=gcc&view=rev Log: rs6000: Set rs6000_cpu correctly (PR43871) We set rs6000_cpu based on tune_index, but it should be cpu_index. This patch fixes it. PR target/43871 * config/rs6000/rs6000.c (rs6000_option_override_internal): Set rs6000_cpu based on cpu_index, not tune_index. Modified: trunk/gcc/ChangeLog trunk/gcc/config/rs6000/rs6000.c
Author: segher Date: Mon Dec 4 09:19:27 2017 New Revision: 255376 URL: https://gcc.gnu.org/viewcvs?rev=255376&root=gcc&view=rev Log: PR bootstrap/83265 Revert 2017-12-01 Segher Boessenkool <segher@kernel.crashing.org> PR target/43871 * config/rs6000/rs6000.c (rs6000_option_override_internal): Set rs6000_cpu based on cpu_index, not tune_index. Modified: trunk/gcc/ChangeLog trunk/gcc/config/rs6000/rs6000.c
Author: segher Date: Thu Dec 7 09:36:28 2017 New Revision: 255464 URL: https://gcc.gnu.org/viewcvs?rev=255464&root=gcc&view=rev Log: rs6000: Initialise rs6000_cpu correctly (PR43871) Finally, set rs6000_cpu based not on -mtune=, but only -mcpu= and the defaults. PR target/43871 * config/rs6000/rs6000.c (rs6000_option_override_internal): Set rs6000_cpu to the given -mcpu=, or to the default processor. Modified: trunk/gcc/ChangeLog trunk/gcc/config/rs6000/rs6000.c
I would prefer not to backport this since it is quite involved. Please reopen if you have a good reason to want it on 7 or 6.