Hi, PR115688 exposes an inconsistent state in which we have VSX enabled but ALTIVEC disabled. There is one hunk:
if (main_target_opt && !main_target_opt->x_rs6000_altivec_abi) rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC) & ~rs6000_isa_flags_explicit); which disables both VSX and ALTIVEC together only considering them explicitly set or not. For the given case, VSX is explicitly specified, altivec is implicitly enabled as it's part of set ISA_2_6_MASKS_SERVER. When falling into the above hunk, vsx is kept as it's explicitly enabled but altivec gets masked off, it's unexpected. This patch is to consider explicit VSX when masking off ALTIVEC, not mask off it if TARGET_VSX and it's explicitly set. Bootstrapped and regtested on powerpc64-linux-gnu P8/P9 and powerpc64le-linux-gnu P9 and P10. I'm going to push this next week if no objections. BR, Kewen ----- PR target/115688 gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_option_override_internal): Consider explicit VSX when masking off ALTIVEC. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr115688.c: New test. --- gcc/config/rs6000/rs6000.cc | 8 ++++++-- gcc/testsuite/gcc.target/powerpc/pr115688.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr115688.c diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 58553ff66f4..2cbea6ea2d7 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -3933,8 +3933,12 @@ rs6000_option_override_internal (bool global_init_p) not for 32-bit. Don't move this before the above code using ignore_masks, since it can reset the cleared VSX/ALTIVEC flag again. */ if (main_target_opt && !main_target_opt->x_rs6000_altivec_abi) - rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC) - & ~rs6000_isa_flags_explicit); + { + rs6000_isa_flags &= ~(OPTION_MASK_VSX & ~rs6000_isa_flags_explicit); + /* Don't mask off ALTIVEC if it is enabled by an explicit VSX. */ + if (!TARGET_VSX) + rs6000_isa_flags &= ~(OPTION_MASK_ALTIVEC & ~rs6000_isa_flags_explicit); + } if (TARGET_CRYPTO && !TARGET_ALTIVEC) { diff --git a/gcc/testsuite/gcc.target/powerpc/pr115688.c b/gcc/testsuite/gcc.target/powerpc/pr115688.c new file mode 100644 index 00000000000..5222e66ef17 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr115688.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target powerpc*-*-linux* } } */ +/* { dg-options "-mdejagnu-cpu=power5 -O2" } */ + +/* Ignore some error messages on "target attribute or + pragma changes AltiVec ABI". */ +/* { dg-excess-errors "pr115688" { target ilp32 } } */ + +/* Verify there is no ICE under 32 bit env. */ + +__attribute__((target("vsx"))) +int test (void) +{ + return 0; +}