Re: [PATCH,rs6000] PR80108: Fix ICE with cross compiler

2017-04-03 Thread Segher Boessenkool
On Mon, Apr 03, 2017 at 10:56:50AM -0500, Pat Haugen wrote:
> On 03/31/2017 06:28 PM, Kelvin Nilsen wrote:
> > +! { dg-do compile { target { powerpc*-*-* } } }
> > +! { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { 
> > "-mcpu=power9" } }
> 
> Shouldn't it be -mcpu=405 in the exclude string since that's what's
> specified below?
> 
> > +! { dg-require-effective-target powerpc_p9vector_ok }
> > +! { dg-options "-m32 -mcpu=405 -mpower9-minmax -mfloat128-type" }
> 
> -m32 is invalid for LE, so the test should be skipped for powerpc64le.

Or instead of setting -m32, just test for it?


Segher


Re: [PATCH,rs6000] PR80108: Fix ICE with cross compiler

2017-04-03 Thread Pat Haugen
On 03/31/2017 06:28 PM, Kelvin Nilsen wrote:
> +! { dg-do compile { target { powerpc*-*-* } } }
> +! { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { 
> "-mcpu=power9" } }

Shouldn't it be -mcpu=405 in the exclude string since that's what's
specified below?

> +! { dg-require-effective-target powerpc_p9vector_ok }
> +! { dg-options "-m32 -mcpu=405 -mpower9-minmax -mfloat128-type" }

-m32 is invalid for LE, so the test should be skipped for powerpc64le.



[PATCH,rs6000] PR80108: Fix ICE with cross compiler

2017-03-31 Thread Kelvin Nilsen

PR 80108 describes an ICE that occurs on an existing test program when
compiled with a particular combination of target options.  

This patch fixes the compiler to reject that particular combination of
target options since it is not meaningful and duplicates the offending
test case with a dg-options directive to exercise the problematic
command-line options.

This patch has been bootstrapped and tested with no regressions on both
powerpc64-unknown-linux-gnu and powerpc64le-unknown-linux-gnu.  Is
this ok for the trunk?


gcc/ChangeLog:

2017-03-31  Kelvin Nilsen  

PR target/80108
* config/rs6000/rs6000.c (rs6000_option_override_internal):
Enhance special handling given to the TARGET_P9_MINMAX option in
relation to certain other options.

gcc/testsuite/ChangeLog:

2017-03-31  Kelvin Nilsen  

PR target/80108
* gcc.target/powerpc/ppc-fortran/ppc-fortran.exp: New file.
* gcc.target/powerpc/ppc-fortran/pr80108-1.f90: New test.

Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 246573)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -4273,8 +4273,30 @@ rs6000_option_override_internal (bool global_init_
   /* For the newer switches (vsx, dfp, etc.) set some of the older options,
  unless the user explicitly used the -mno- to disable the code.  */
   if (TARGET_P9_VECTOR || TARGET_MODULO || TARGET_P9_DFORM_SCALAR
-  || TARGET_P9_DFORM_VECTOR || TARGET_P9_DFORM_BOTH > 0 || 
TARGET_P9_MINMAX)
+  || TARGET_P9_DFORM_VECTOR || TARGET_P9_DFORM_BOTH > 0)
 rs6000_isa_flags |= (ISA_3_0_MASKS_SERVER & ~rs6000_isa_flags_explicit);
+  else if (TARGET_P9_MINMAX)
+{
+  if (have_cpu)
+   {
+ if (cpu_index == PROCESSOR_POWER9)
+   /* legacy behavior: allow -mcpu-power9 with certain capabilities
+  (eg -mno-vsx) explicitly disabled.  */
+   rs6000_isa_flags |=
+ (ISA_3_0_MASKS_SERVER & ~rs6000_isa_flags_explicit);
+ else
+   error ("Power9 target option is incompatible with -mcpu= for "
+  " less than power9");
+   }
+  else if ((ISA_3_0_MASKS_SERVER & rs6000_isa_flags_explicit)
+  != (ISA_3_0_MASKS_SERVER & rs6000_isa_flags
+  & rs6000_isa_flags_explicit))
+   /* Enforce that none of the ISA_3_0_MASKS_SERVER flags
+  were explicitly cleared.  */
+   error ("-mpower9-minmax incompatible with explicitly disabled options");
+  else
+   rs6000_isa_flags |= ISA_3_0_MASKS_SERVER;
+}
   else if (TARGET_P8_VECTOR || TARGET_DIRECT_MOVE || TARGET_CRYPTO)
 rs6000_isa_flags |= (ISA_2_7_MASKS_SERVER & ~rs6000_isa_flags_explicit);
   else if (TARGET_VSX)
Index: gcc/testsuite/gcc.target/powerpc/ppc-fortran/ppc-fortran.exp
===
--- gcc/testsuite/gcc.target/powerpc/ppc-fortran/ppc-fortran.exp
(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/ppc-fortran/ppc-fortran.exp
(revision 246624)
@@ -0,0 +1,65 @@
+#   Copyright (C) 2004-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# .
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gfortran-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_FFLAGS
+if ![info exists DEFAULT_FFLAGS] then {
+set DEFAULT_FFLAGS " -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+global gfortran_test_path
+global gfortran_aux_module_flags
+set gfortran_test_path $srcdir/$subdir
+set gfortran_aux_module_flags $DEFAULT_FFLAGS
+proc dg-compile-aux-modules { args } {
+global gfortran_test_path
+global gfortran_aux_module_flags
+if { [llength $args] != 2 } {
+   error "dg-set-target-env-var: needs one argument"
+   return
+}
+
+set level [info level]
+if { [info procs dg-save-unknown] != [list] } {
+   rename dg-save-unknown dg-save-unknown-level-$level
+}
+
+dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
+# cleanup-modules is intentionally not invoked here.
+
+if { [info procs dg-save-unknown-level-$level] != [list] } {
+   rename dg-save-unknown-level-$level dg-save-unknown
+}
+}
+
+#