Skip to content

Commit e154242

Browse files
amodraAlan Modra
authored andcommitted
[RS6000] Don't pass -many to the assembler
I'd like to remove -many from the options passed by default to the assembler, on the grounds that a gcc bug in instruction selection (eg. emitting a power9 insn for -mcpu=power8) is better found at assembly time than run time. For now, just do this when --enable-checking or gcc is not a release. This patch also emits .machine assembler directives for ELF targets when functions are compiled for different cpus via attributes or pragmas. That's necessary when the initial -m<cpu> option passed to the assembler doesn't enable the superset of all opcodes emitted, as seen by a failure of gcc.target/powerpc/clone2.c without .machine when building gcc for power8. rs6000_machine_from_flags deliberately uses ISA_2_4_MASKS rather than ISA_2_2_MASKS for power5 because "friz" and other similar instructions enabled by gcc with TARGET_FPRND are enabled in gas by "-mpower5". (gas -mpower5 supports power5+ too.) rs6000-cpus.def puts OPTION_MASK_FPRND in ISA_2_4_MASKS, so ISA_2_4_MASKS is the one to use in deciding to pass "-mpower5" to gas. O3-pr70130.c also failed on an earlier version of this patch (when only testing one ISA bit to determine .machine). This is a test for a power7 vector bug, but on power8 hw check_vect_support_and_set_flags passes -mpower8-vector which means the test isn't exercising the original bug exactly. I reckon that is wrong, and similary for other vector testcases that ask for a specific cpu. I've fixed it here by explicitly passing -mno-power8-vector and similar vector options. * config/rs6000/rs6000.h (ASM_OPT_ANY): Define. (ASM_CPU_SPEC): Conditionally add -many. * config/rs6000/rs6000.c (rs6000_machine): New static var. (rs6000_machine_from_flags, emit_asm_machine): New functions.. (rs6000_file_start): ..extracted from here, and modified to test all ISA bits. (rs6000_output_function_prologue): Emit .machine as necessary. * testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c: Don't use power mnemonics. * testsuite/gcc.dg/vect/O3-pr70130.c: Disable default options added by check_vect_support_and_set_flags. * testsuite/gcc.dg/vect/pr48765.c: Likewise. * testsuite/gfortran.dg/vect/pr45714-b.f: Likewise. From-SVN: r271500
1 parent 0acb03a commit e154242

File tree

7 files changed

+78
-33
lines changed

7 files changed

+78
-33
lines changed

gcc/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2019-05-22 Alan Modra <amodra@gmail.com>
2+
3+
* config/rs6000/rs6000.h (ASM_OPT_ANY): Define.
4+
(ASM_CPU_SPEC): Conditionally add -many.
5+
* config/rs6000/rs6000.c (rs6000_machine): New static var.
6+
(rs6000_machine_from_flags, emit_asm_machine): New functions..
7+
(rs6000_file_start): ..extracted from here, and modified to
8+
test all ISA bits.
9+
(rs6000_output_function_prologue): Emit .machine as necessary.
10+
* testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c: Don't use
11+
power mnemonics.
12+
* testsuite/gcc.dg/vect/O3-pr70130.c: Disable default options
13+
added by check_vect_support_and_set_flags.
14+
* testsuite/gcc.dg/vect/pr48765.c: Likewise.
15+
* testsuite/gfortran.dg/vect/pr45714-b.f: Likewise.
16+
117
2019-05-22 Hans-Peter Nilsson <hp@axis.com>
218

319
PR middle-end/90553

gcc/config/rs6000/rs6000.c

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5632,6 +5632,36 @@ rs6000_builtin_md_vectorized_function (tree fndecl, tree type_out,
56325632
/* Default CPU string for rs6000*_file_start functions. */
56335633
static const char *rs6000_default_cpu;
56345634

5635+
#ifdef USING_ELFOS_H
5636+
static const char *rs6000_machine;
5637+
5638+
static const char *
5639+
rs6000_machine_from_flags (void)
5640+
{
5641+
if ((rs6000_isa_flags & (ISA_3_0_MASKS_SERVER & ~ISA_2_7_MASKS_SERVER)) != 0)
5642+
return "power9";
5643+
if ((rs6000_isa_flags & (ISA_2_7_MASKS_SERVER & ~ISA_2_6_MASKS_SERVER)) != 0)
5644+
return "power8";
5645+
if ((rs6000_isa_flags & (ISA_2_6_MASKS_SERVER & ~ISA_2_5_MASKS_SERVER)) != 0)
5646+
return "power7";
5647+
if ((rs6000_isa_flags & (ISA_2_5_MASKS_SERVER & ~ISA_2_4_MASKS)) != 0)
5648+
return "power6";
5649+
if ((rs6000_isa_flags & (ISA_2_4_MASKS & ~ISA_2_1_MASKS)) != 0)
5650+
return "power5";
5651+
if ((rs6000_isa_flags & ISA_2_1_MASKS) != 0)
5652+
return "power4";
5653+
if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) != 0)
5654+
return "ppc64";
5655+
return "ppc";
5656+
}
5657+
5658+
static void
5659+
emit_asm_machine (void)
5660+
{
5661+
fprintf (asm_out_file, "\t.machine %s\n", rs6000_machine);
5662+
}
5663+
#endif
5664+
56355665
/* Do anything needed at the start of the asm file. */
56365666

56375667
static void
@@ -5697,27 +5727,10 @@ rs6000_file_start (void)
56975727
}
56985728

56995729
#ifdef USING_ELFOS_H
5730+
rs6000_machine = rs6000_machine_from_flags ();
57005731
if (!(rs6000_default_cpu && rs6000_default_cpu[0])
57015732
&& !global_options_set.x_rs6000_cpu_index)
5702-
{
5703-
fputs ("\t.machine ", asm_out_file);
5704-
if ((rs6000_isa_flags & OPTION_MASK_MODULO) != 0)
5705-
fputs ("power9\n", asm_out_file);
5706-
else if ((rs6000_isa_flags & OPTION_MASK_DIRECT_MOVE) != 0)
5707-
fputs ("power8\n", asm_out_file);
5708-
else if ((rs6000_isa_flags & OPTION_MASK_POPCNTD) != 0)
5709-
fputs ("power7\n", asm_out_file);
5710-
else if ((rs6000_isa_flags & OPTION_MASK_CMPB) != 0)
5711-
fputs ("power6\n", asm_out_file);
5712-
else if ((rs6000_isa_flags & OPTION_MASK_POPCNTB) != 0)
5713-
fputs ("power5\n", asm_out_file);
5714-
else if ((rs6000_isa_flags & OPTION_MASK_MFCRF) != 0)
5715-
fputs ("power4\n", asm_out_file);
5716-
else if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) != 0)
5717-
fputs ("ppc64\n", asm_out_file);
5718-
else
5719-
fputs ("ppc\n", asm_out_file);
5720-
}
5733+
emit_asm_machine ();
57215734
#endif
57225735

57235736
if (DEFAULT_ABI == ABI_ELFv2)
@@ -27504,7 +27517,17 @@ static void
2750427517
rs6000_output_function_prologue (FILE *file)
2750527518
{
2750627519
if (!cfun->is_thunk)
27507-
rs6000_output_savres_externs (file);
27520+
{
27521+
rs6000_output_savres_externs (file);
27522+
#ifdef USING_ELFOS_H
27523+
const char *curr_machine = rs6000_machine_from_flags ();
27524+
if (rs6000_machine != curr_machine)
27525+
{
27526+
rs6000_machine = curr_machine;
27527+
emit_asm_machine ();
27528+
}
27529+
#endif
27530+
}
2750827531

2750927532
/* ELFv2 ABI r2 setup code and local entry point. This must follow
2751027533
immediately after the global entry point label. */

gcc/config/rs6000/rs6000.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@
7070
#define PPC405_ERRATUM77 0
7171
#endif
7272

73+
#if CHECKING_P
74+
#define ASM_OPT_ANY ""
75+
#else
76+
#define ASM_OPT_ANY " -many"
77+
#endif
78+
7379
/* Common ASM definitions used by ASM_SPEC among the various targets for
7480
handling -mcpu=xxx switches. There is a parallel list in driver-rs6000.c to
7581
provide the default assembler options if the user uses -mcpu=native, so if
@@ -137,8 +143,8 @@
137143
mvsx: -mpower7; \
138144
mpowerpc64: -mppc64;: %(asm_default)}; \
139145
:%eMissing -mcpu option in ASM_CPU_SPEC?\n} \
140-
%{mvsx: -mvsx -maltivec; maltivec: -maltivec} \
141-
-many"
146+
%{mvsx: -mvsx -maltivec; maltivec: -maltivec}" \
147+
ASM_OPT_ANY
142148

143149
#define CPP_DEFAULT_SPEC ""
144150

gcc/testsuite/gcc.dg/vect/O3-pr70130.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* { dg-require-effective-target vsx_hw { target powerpc*-*-* } } */
2-
/* { dg-additional-options "-mcpu=power7" { target powerpc*-*-* } } */
2+
/* { dg-additional-options "-mcpu=power7 -mno-power9-vector -mno-power8-vector" { target powerpc*-*-* } } */
33

44
#include "tree-vect.h"
55

gcc/testsuite/gcc.dg/vect/pr48765.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* { dg-do compile { target { powerpc*-*-* } } } */
22
/* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */
3-
/* { dg-additional-options "-O3 -mcpu=power6" } */
3+
/* { dg-additional-options "-O3 -mcpu=power6 -mno-power9-vector -mno-power8-vector -mno-vsx" } */
44

55
enum reg_class
66
{

gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ __asm__ ("\t.globl\t" #NAME "_asm\n\t" \
4545
#NAME "_asm:\n\t" \
4646
"lis 11,gparms@ha\n\t" \
4747
"la 11,gparms@l(11)\n\t" \
48-
"st 3,0(11)\n\t" \
49-
"st 4,4(11)\n\t" \
50-
"st 5,8(11)\n\t" \
51-
"st 6,12(11)\n\t" \
52-
"st 7,16(11)\n\t" \
53-
"st 8,20(11)\n\t" \
54-
"st 9,24(11)\n\t" \
55-
"st 10,28(11)\n\t" \
48+
"stw 3,0(11)\n\t" \
49+
"stw 4,4(11)\n\t" \
50+
"stw 5,8(11)\n\t" \
51+
"stw 6,12(11)\n\t" \
52+
"stw 7,16(11)\n\t" \
53+
"stw 8,20(11)\n\t" \
54+
"stw 9,24(11)\n\t" \
55+
"stw 10,28(11)\n\t" \
5656
"stfd 1,32(11)\n\t" \
5757
"stfd 2,40(11)\n\t" \
5858
"stfd 3,48(11)\n\t" \

gcc/testsuite/gfortran.dg/vect/pr45714-b.f

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
! { dg-do compile { target powerpc*-*-* } }
2-
! { dg-additional-options "-O3 -mcpu=power7 -ffast-math -mveclibabi=mass" }
2+
! { dg-additional-options "-O3 -mcpu=power7 -mno-power9-vector -mno-power8-vector -ffast-math -mveclibabi=mass" }
33

44
integer index(18),i,j,k,l,ipiv(18),info,ichange,neq,lda,ldb,
55
& nrhs,iplas

0 commit comments

Comments
 (0)