Go patch committed: Fix inlining method with empty param/receiver

2019-04-24 Thread Ian Lance Taylor
This patch to the Go frontend by Than McIntosh fixes a problem with
Function_declaration::import_function relating to how no-name or
"sink" parameters are handled.  In Gogo::start_function (for the
non-inline case) when parameter bindings are being added, parameters
with empty/sink names are renamed to synthesized "r.%d" / "p.%d" names
so as to avoid collisions.  This same handling needs to be present
when creating the bindings for an inline function that's being
instantiated after being read from export data.  This fixes
https://golang.org/issue/31637.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 270552)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-56fe6a00892252edb4b28f8660ce29a985c48702
+cb6fb7285bac72389bdce7ecfe87f9366022571a
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc   (revision 270552)
+++ gcc/go/gofrontend/gogo.cc   (working copy)
@@ -1832,21 +1832,18 @@ Gogo::start_function(const std::string&
   Variable* this_param = new Variable(receiver->type(), NULL, false,
  true, true, location);
   std::string rname = receiver->name();
-  if (rname.empty() || Gogo::is_sink_name(rname))
-   {
- // We need to give receivers a name since they wind up in
- // DECL_ARGUMENTS.  FIXME.
- static unsigned int count;
- char buf[50];
- snprintf(buf, sizeof buf, "r.%u", count);
- ++count;
- rname = buf;
-   }
+  unsigned rcounter = 0;
+
+  // We need to give a nameless receiver parameter a synthesized name to
+  // avoid having it clash with some other nameless param. FIXME.
+  Gogo::rename_if_empty(, "r", );
+
   block->bindings()->add_variable(rname, NULL, this_param);
 }
 
   const Typed_identifier_list* parameters = type->parameters();
   bool is_varargs = type->is_varargs();
+  unsigned pcounter = 0;
   if (parameters != NULL)
 {
   for (Typed_identifier_list::const_iterator p = parameters->begin();
@@ -1859,16 +1856,11 @@ Gogo::start_function(const std::string&
param->set_is_varargs_parameter();
 
  std::string pname = p->name();
- if (pname.empty() || Gogo::is_sink_name(pname))
-   {
- // We need to give parameters a name since they wind up
- // in DECL_ARGUMENTS.  FIXME.
- static unsigned int count;
- char buf[50];
- snprintf(buf, sizeof buf, "p.%u", count);
- ++count;
- pname = buf;
-   }
+
+  // We need to give each nameless parameter a non-empty name to avoid
+  // having it clash with some other nameless param. FIXME.
+  Gogo::rename_if_empty(, "p", );
+
  block->bindings()->add_variable(pname, NULL, param);
}
 }
@@ -2313,6 +2305,20 @@ Gogo::add_variable(const std::string& na
   return no;
 }
 
+void
+Gogo::rename_if_empty(std::string* pname, const char* tag, unsigned* count)
+{
+  if (pname->empty() || Gogo::is_sink_name(*pname))
+{
+  char buf[50];
+  go_assert(strlen(tag) < 10);
+  snprintf(buf, sizeof buf, "%s.%u", tag, *count);
+  ++(*count);
+  *pname = buf;
+}
+}
+
+
 // Add a sink--a reference to the blank identifier _.
 
 Named_object*
@@ -6904,11 +6910,20 @@ Function_declaration::import_function_bo
   const Typed_identifier* receiver = fntype->receiver();
   Variable* recv_param = new Variable(receiver->type(), NULL, false,
  true, true, start_loc);
-  outer->bindings()->add_variable(receiver->name(), NULL, recv_param);
+
+  std::string rname = receiver->name();
+  unsigned rcounter = 0;
+
+  // We need to give a nameless receiver a name to avoid having it
+  // clash with some other nameless param. FIXME.
+  Gogo::rename_if_empty(, "r", );
+
+  outer->bindings()->add_variable(rname, NULL, recv_param);
 }
 
   const Typed_identifier_list* params = fntype->parameters();
   bool is_varargs = fntype->is_varargs();
+  unsigned pcounter = 0;
   if (params != NULL)
 {
   for (Typed_identifier_list::const_iterator p = params->begin();
@@ -6919,7 +6934,14 @@ Function_declaration::import_function_bo
 start_loc);
  if (is_varargs && p + 1 == params->end())
param->set_is_varargs_parameter();
- outer->bindings()->add_variable(p->name(), NULL, param);
+
+ std::string pname = p->name();
+
+  // We need to give each nameless parameter a non-empty name to avoid
+  // having it clash with some 

Re: [PATCH] Implement LWG 3062, Unnecessary decay_t in is_execution_policy_v

2019-04-24 Thread Jonathan Wakely

On 24/04/19 16:01 -0700, Thomas Rodgers wrote:


should be remove_cvref_t
* include/pstl/execution_defs.h (__enable_if_execution_policy):
   Use std::__remove_cv_ref_t when building with GCC




From cb7bd9a39acacbf81df0d03da8714fa463057cc5 Mon Sep 17 00:00:00 2001
From: Thomas Rodgers 
Date: Wed, 24 Apr 2019 15:53:45 -0700
Subject: [PATCH] Implement LWG 3062, Unnecessary decay_t in
is_execution_policy_v

should be remove_cvref_t
* include/pstl/execution_defs.h (__enable_if_execution_policy):
   Use std::__remove_cv_ref_t when building with GCC.
---
libstdc++-v3/include/pstl/execution_defs.h | 6 ++
1 file changed, 6 insertions(+)

diff --git a/libstdc++-v3/include/pstl/execution_defs.h 
b/libstdc++-v3/include/pstl/execution_defs.h
index 86c7a5a770d..9b9b212b1bd 100644
--- a/libstdc++-v3/include/pstl/execution_defs.h
+++ b/libstdc++-v3/include/pstl/execution_defs.h
@@ -152,9 +152,15 @@ constexpr bool is_execution_policy_v = 
__pstl::execution::is_execution_policy<_T
namespace __internal
{
template 
+#if __GNUC__


Clang and Intel both define that macro, but that doesn't mean
__remove_cvref_t is available. I think you want __GLIBCXX__ to tell
that libstdc++ is in use, or better still:

#if _GLIBCXX_RELEASE >= 9


+using __enable_if_execution_policy =
+typename std::enable_if<__pstl::execution::is_execution_policy>::value,


The typename before std::__remove_cvref_t shouldn't be there.


+_T>::type;
+#else
using __enable_if_execution_policy =
typename std::enable_if<__pstl::execution::is_execution_policy::type>::value,
_T>::type;
+#endif
} // namespace __internal

} // namespace __pstl
--
2.20.1





[PATCH] Implement LWG 3062, Unnecessary decay_t in is_execution_policy_v

2019-04-24 Thread Thomas Rodgers

should be remove_cvref_t
* include/pstl/execution_defs.h (__enable_if_execution_policy):
Use std::__remove_cv_ref_t when building with GCC

>From cb7bd9a39acacbf81df0d03da8714fa463057cc5 Mon Sep 17 00:00:00 2001
From: Thomas Rodgers 
Date: Wed, 24 Apr 2019 15:53:45 -0700
Subject: [PATCH] Implement LWG 3062, Unnecessary decay_t in
 is_execution_policy_v

	should be remove_cvref_t
	* include/pstl/execution_defs.h (__enable_if_execution_policy):
Use std::__remove_cv_ref_t when building with GCC.
---
 libstdc++-v3/include/pstl/execution_defs.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libstdc++-v3/include/pstl/execution_defs.h b/libstdc++-v3/include/pstl/execution_defs.h
index 86c7a5a770d..9b9b212b1bd 100644
--- a/libstdc++-v3/include/pstl/execution_defs.h
+++ b/libstdc++-v3/include/pstl/execution_defs.h
@@ -152,9 +152,15 @@ constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy<_T
 namespace __internal
 {
 template 
+#if __GNUC__
+using __enable_if_execution_policy =
+typename std::enable_if<__pstl::execution::is_execution_policy>::value,
+_T>::type;
+#else
 using __enable_if_execution_policy =
 typename std::enable_if<__pstl::execution::is_execution_policy::type>::value,
 _T>::type;
+#endif
 } // namespace __internal
 
 } // namespace __pstl
-- 
2.20.1



[PATCH, PR d/90086] Fix linker warning and SEGV in core.thread tests

2019-04-24 Thread Iain Buclaw
Hi,

This patch removes the monolithic and cumbersome to maintain
core/threadasm.S, and splitted it into multiple parts, one for each
intended target cpu/os.

Added .type and .size directives for all asm implementations of
fiber_switchContent and callWithStackShell where they were missing,
fixing the last remaining failing test on -m32 that I can reproduce
locally.

Bootstrapped and regression tested on x86_64-linux-gnu with multilibs
-m32, -mx32, and -m64.

Committed to trunk as r270560.

-- 
Iain
---
libphobos/ChangeLog:

2019-04-25  Iain Buclaw  

PR d/90086
* m4/druntime/cpu.m4 (DRUNTIME_CPU_SOURCES): New macro.
* configure.ac: Use it.
* configure: Regenerate.
* libdruntime/Makefile.am: Add new config sources to
DRUNTIME_SOURCES_CONFIGURED.
* libdruntime/Makefile.in: Regenerate.
* libdruntime/config/aarch64/switchcontext.S: New file.
* libdruntime/config/arm/switchcontext.S: New file.
* libdruntime/config/common/threadasm.S: New file.
* libdruntime/config/mingw/switchcontext.S: New file.
* libdruntime/config/mips/switchcontext.S: New file.
* libdruntime/config/powerpc/switchcontext.S: New file.
* libdruntime/config/powerpc64/callwithstack.S: New file.
* libdruntime/config/x86/switchcontext.S: New file.
* libdruntime/core/threadasm.S: Remove.
---
diff --git a/libphobos/configure b/libphobos/configure
index 7c019899c5c..67fe34d7184 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -681,6 +681,18 @@ DRUNTIME_OS_AIX_FALSE
 DRUNTIME_OS_AIX_TRUE
 DRUNTIME_OS_UNIX_FALSE
 DRUNTIME_OS_UNIX_TRUE
+DRUNTIME_CPU_X86_FALSE
+DRUNTIME_CPU_X86_TRUE
+DRUNTIME_CPU_POWERPC64_FALSE
+DRUNTIME_CPU_POWERPC64_TRUE
+DRUNTIME_CPU_POWERPC_FALSE
+DRUNTIME_CPU_POWERPC_TRUE
+DRUNTIME_CPU_MIPS_FALSE
+DRUNTIME_CPU_MIPS_TRUE
+DRUNTIME_CPU_ARM_FALSE
+DRUNTIME_CPU_ARM_TRUE
+DRUNTIME_CPU_AARCH64_FALSE
+DRUNTIME_CPU_AARCH64_TRUE
 DRUNTIME_GC_ENABLE_FALSE
 DRUNTIME_GC_ENABLE_TRUE
 libphobos_srcdir
@@ -11623,7 +11635,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11626 "configure"
+#line 11638 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11729,7 +11741,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11732 "configure"
+#line 11744 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14024,6 +14036,74 @@ fi
 
 
 
+  druntime_target_cpu_parsed=""
+  case "$target_cpu" in
+  aarch64*)
+   druntime_target_cpu_parsed="aarch64"
+   ;;
+  arm*)druntime_target_cpu_parsed="arm"
+   ;;
+  mips*)   druntime_target_cpu_parsed="mips"
+   ;;
+  powerpc) druntime_target_cpu_parsed="powerpc"
+   ;;
+  powerpc64)
+   druntime_target_cpu_parsed="powerpc64"
+   ;;
+  i3456786|x86_64)
+   druntime_target_cpu_parsed="x86"
+   ;;
+  esac
+   if test "$druntime_target_cpu_parsed" = "aarch64"; then
+  DRUNTIME_CPU_AARCH64_TRUE=
+  DRUNTIME_CPU_AARCH64_FALSE='#'
+else
+  DRUNTIME_CPU_AARCH64_TRUE='#'
+  DRUNTIME_CPU_AARCH64_FALSE=
+fi
+
+   if test "$druntime_target_cpu_parsed" = "arm"; then
+  DRUNTIME_CPU_ARM_TRUE=
+  DRUNTIME_CPU_ARM_FALSE='#'
+else
+  DRUNTIME_CPU_ARM_TRUE='#'
+  DRUNTIME_CPU_ARM_FALSE=
+fi
+
+   if test "$druntime_target_cpu_parsed" = "mips"; then
+  DRUNTIME_CPU_MIPS_TRUE=
+  DRUNTIME_CPU_MIPS_FALSE='#'
+else
+  DRUNTIME_CPU_MIPS_TRUE='#'
+  DRUNTIME_CPU_MIPS_FALSE=
+fi
+
+   if test "$druntime_target_cpu_parsed" = "powerpc"; then
+  DRUNTIME_CPU_POWERPC_TRUE=
+  DRUNTIME_CPU_POWERPC_FALSE='#'
+else
+  DRUNTIME_CPU_POWERPC_TRUE='#'
+  DRUNTIME_CPU_POWERPC_FALSE=
+fi
+
+   if test "$druntime_target_cpu_parsed" = "powerpc64"; then
+  DRUNTIME_CPU_POWERPC64_TRUE=
+  DRUNTIME_CPU_POWERPC64_FALSE='#'
+else
+  DRUNTIME_CPU_POWERPC64_TRUE='#'
+  DRUNTIME_CPU_POWERPC64_FALSE=
+fi
+
+   if test "$druntime_target_cpu_parsed" = "x86"; then
+  DRUNTIME_CPU_X86_TRUE=
+  DRUNTIME_CPU_X86_FALSE='#'
+else
+  DRUNTIME_CPU_X86_TRUE='#'
+  DRUNTIME_CPU_X86_FALSE=
+fi
+
+
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for target OS" >&5
 $as_echo_n "checking for target OS... " >&6; }
 if ${druntime_cv_target_os+:} false; then :
@@ -15413,6 +15493,30 @@ if test -z "${DRUNTIME_GC_ENABLE_TRUE}" && test -z "${DRUNTIME_GC_ENABLE_FALSE}"
   as_fn_error $? "conditional \"DRUNTIME_GC_ENABLE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${DRUNTIME_CPU_AARCH64_TRUE}" && test -z "${DRUNTIME_CPU_AARCH64_FALSE}"; then
+  as_fn_error $? "conditional \"DRUNTIME_CPU_AARCH64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${DRUNTIME_CPU_ARM_TRUE}" && test -z 

Re: [PATCH] Document PSTL linker flags

2019-04-24 Thread Jonathan Wakely

On 23/04/19 14:05 -0700, Thomas Rodgers wrote:


Jonathan Wakely writes:


On 23/04/19 09:54 -0700, Thomas Rodgers wrote:


 * doc/xml/manual/using.xml: Add PSTL linker flags to table 3.1.


OK - thanks.


Committed to trunk


I've also committed this update for the C++17 status docs.

commit 7b79761df0445c3adc8de1d19e05585a1f11e29c
Author: Jonathan Wakely 
Date:   Wed Apr 24 23:16:16 2019 +0100

Update C++17 library status tables

* doc/xml/manual/status_cxx2017.xml: Document P0024R2 status.
* doc/html/*: Regenerate.

diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
index bb82e34bba7..73403ef6ba0 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
@@ -633,17 +633,18 @@ Feature-testing recommendations for C++.
 
 
 
-  
+  
The Parallelism TS Should be Standardized	 
   
 	http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0024r2.html;>
 	P0024R2
 	
   
-   No 
+   9.1 
__has_include(execution) ,
 	  __cpp_lib_execution >= 201603 ,
 	  __cpp_lib_parallel_algorithm >= 201603 
+ (requires linking with -ltbb, see Note 3)
   
 
 
@@ -689,7 +690,7 @@ Feature-testing recommendations for C++.
   
7.1 
__cpp_lib_math_special_functions >= 201603 
-	 (see Note 3)
+	 (see Note 4)
   
 
 
@@ -841,7 +842,13 @@ Note 2: This feature is supported in older releases but the
 
 
 
-Note 3: The mathematical special functions are enabled in C++17 mode from
+Note 3: The Parallel Algorithms have an external dependency on Intel TBB 2018
+or later. If the execution
+header is included then -ltbb must be used to link to TBB.
+
+
+
+Note 4: The mathematical special functions are enabled in C++17 mode from
 GCC 7.1 onwards. For GCC 6.x or for C++11/C++14 define
 __STDCPP_WANT_MATH_SPEC_FUNCS__ to a non-zero value
 and test for __STDCPP_MATH_SPEC_FUNCS__ >= 201003L.


Re: [PATCH] Uglify names in pstl/execution_defs.h

2019-04-24 Thread Jonathan Wakely

On 24/04/19 15:00 -0700, Thomas Rodgers wrote:

   Missed in prior uglification passes.

* include/pstl/execution_defs.h:
Uglfiy inline namespace.


s/Uglfiy/Uglify


Uglify ExecPolicy and T template parameters.


The ChangeLog entry should be formatted without that first line break:

* include/pstl/execution_defs.h: Uglify inline namespace.
Uglify ExecPolicy and T template parameters.

OK for trunk like that, thanks.



[PATCH] Uglify names in pstl/execution_defs.h

2019-04-24 Thread Thomas Rodgers
Missed in prior uglification passes.

* include/pstl/execution_defs.h:
Uglfiy inline namespace.
Uglify ExecPolicy and T template parameters.

>From 07d15a71f60d9dec58882f9cfbf80e4b1ed043f3 Mon Sep 17 00:00:00 2001
From: Thomas Rodgers 
Date: Wed, 24 Apr 2019 14:57:26 -0700
Subject: [PATCH] Uglify names in pstl/execution_defs.h

Missed in prior uglification passes.

	* include/pstl/execution_defs.h:
	Uglfiy inline namespace.
	Uglify ExecPolicy and T template parameters.
---
 libstdc++-v3/include/pstl/execution_defs.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libstdc++-v3/include/pstl/execution_defs.h b/libstdc++-v3/include/pstl/execution_defs.h
index 9a4b49bd46a..86c7a5a770d 100644
--- a/libstdc++-v3/include/pstl/execution_defs.h
+++ b/libstdc++-v3/include/pstl/execution_defs.h
@@ -16,7 +16,7 @@ namespace __pstl
 {
 namespace execution
 {
-inline namespace v1
+inline namespace __v1
 {
 
 // 2.4, Sequential execution policy
@@ -117,7 +117,7 @@ constexpr parallel_unsequenced_policy par_unseq{};
 constexpr unsequenced_policy unseq{};
 
 // 2.3, Execution policy type trait
-template 
+template 
 struct is_execution_policy : std::false_type
 {
 };
@@ -142,8 +142,8 @@ struct is_execution_policy<__pstl::execution::unsequenced_policy> : std::true_ty
 };
 
 #if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
-template 
-constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy::value;
+template 
+constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy<_T>::value;
 #endif
 
 } // namespace v1
@@ -151,10 +151,10 @@ constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy
 
 namespace __internal
 {
-template 
+template 
 using __enable_if_execution_policy =
-typename std::enable_if<__pstl::execution::is_execution_policy::type>::value,
-T>::type;
+typename std::enable_if<__pstl::execution::is_execution_policy::type>::value,
+_T>::type;
 } // namespace __internal
 
 } // namespace __pstl
-- 
2.20.1



[PATCH] Make filesystem::path comparison operators hidden friends (LWG 3065)

2019-04-24 Thread Jonathan Wakely

This change revealed two testsuite bugs where some string comparisons
only compiled by converting the strings to filesystem::path objects.

* include/bits/fs_path.h (operator<, operator<=, operator>)
(operator>=, operator==, operator!=): Make hidden friends, as per
LWG 3065.
* testsuite/27_io/filesystem/path/native/string-char8_t.cc: Fix
string type in test.
* testsuite/27_io/filesystem/path/native/string.cc: Likewise.

Tested powerpc64le-linux, committed to trunk.

commit bcfec0ca213b70e81e8291b3344ff47fd8eac012
Author: Jonathan Wakely 
Date:   Wed Apr 24 21:48:17 2019 +0100

Make filesystem::path comparison operators hidden friends (LWG 3065)

This change revealed two testsuite bugs where some string comparisons
only compiled by converting the strings to filesystem::path objects.

* include/bits/fs_path.h (operator<, operator<=, operator>)
(operator>=, operator==, operator!=): Make hidden friends, as per
LWG 3065.
* testsuite/27_io/filesystem/path/native/string-char8_t.cc: Fix
string type in test.
* testsuite/27_io/filesystem/path/native/string.cc: Likewise.

diff --git a/libstdc++-v3/include/bits/fs_path.h 
b/libstdc++-v3/include/bits/fs_path.h
index bf7c65c9cad..3674b4391f8 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -417,6 +417,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
return __is;
   }
 
+// non-member operators
+
+/// Compare paths
+friend bool operator<(const path& __lhs, const path& __rhs) noexcept
+{ return __lhs.compare(__rhs) < 0; }
+
+/// Compare paths
+friend bool operator<=(const path& __lhs, const path& __rhs) noexcept
+{ return !(__rhs < __lhs); }
+
+/// Compare paths
+friend bool operator>(const path& __lhs, const path& __rhs) noexcept
+{ return __rhs < __lhs; }
+
+/// Compare paths
+friend bool operator>=(const path& __lhs, const path& __rhs) noexcept
+{ return !(__lhs < __rhs); }
+
+/// Compare paths
+friend bool operator==(const path& __lhs, const path& __rhs) noexcept
+{ return __lhs.compare(__rhs) == 0; }
+
+/// Compare paths
+friend bool operator!=(const path& __lhs, const path& __rhs) noexcept
+{ return !(__lhs == __rhs); }
+
+/// Append one path to another
+friend path operator/(const path& __lhs, const path& __rhs)
+{
+  path __result(__lhs);
+  __result /= __rhs;
+  return __result;
+}
+
 // Create a basic_string by reading until a null character.
 template,
@@ -578,38 +612,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
   size_t hash_value(const path& __p) noexcept;
 
-  /// Compare paths
-  inline bool operator<(const path& __lhs, const path& __rhs) noexcept
-  { return __lhs.compare(__rhs) < 0; }
-
-  /// Compare paths
-  inline bool operator<=(const path& __lhs, const path& __rhs) noexcept
-  { return !(__rhs < __lhs); }
-
-  /// Compare paths
-  inline bool operator>(const path& __lhs, const path& __rhs) noexcept
-  { return __rhs < __lhs; }
-
-  /// Compare paths
-  inline bool operator>=(const path& __lhs, const path& __rhs) noexcept
-  { return !(__lhs < __rhs); }
-
-  /// Compare paths
-  inline bool operator==(const path& __lhs, const path& __rhs) noexcept
-  { return __lhs.compare(__rhs) == 0; }
-
-  /// Compare paths
-  inline bool operator!=(const path& __lhs, const path& __rhs) noexcept
-  { return !(__lhs == __rhs); }
-
-  /// Append one path to another
-  inline path operator/(const path& __lhs, const path& __rhs)
-  {
-path __result(__lhs);
-__result /= __rhs;
-return __result;
-  }
-
   template
 inline auto
 u8path(_InputIterator __first, _InputIterator __last)
diff --git 
a/libstdc++-v3/testsuite/27_io/filesystem/path/native/string-char8_t.cc 
b/libstdc++-v3/testsuite/27_io/filesystem/path/native/string-char8_t.cc
index 4f187da7804..f5bb1afca5d 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/path/native/string-char8_t.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/path/native/string-char8_t.cc
@@ -46,7 +46,7 @@ test02()
   path p(s);
 
   auto str = p.string();
-  VERIFY( str == u"abc" );
+  VERIFY( str == "abc" );
   VERIFY( str == p.string() );
 
   auto strw = p.string();
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc 
b/libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc
index 5417ab4c011..4d45c7e15df 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc
@@ -46,7 +46,7 @@ test02()
   path p(s);
 
   auto str = p.string();
-  VERIFY( str == u"abc" );
+  VERIFY( str == "abc" );
   VERIFY( str == p.string() );
 
   auto strw = p.string();


C++ PATCH to add test for c++/90236

2019-04-24 Thread Marek Polacek
This valid test started to be accepted with r265789, which removed the
following checks.  I wonder if we want to remove them in gcc 8, or
just leave them in place.  For trunk I'm going to add the new test.

@@ -6985,27 +7071,10 @@ convert_nontype_argument (tree type, tree expr, 
tsubst_flags_t complain)
   itself value-dependent, since what we want here is its address.  */;
   else
{
- if (!DECL_P (expr))
-   {
- if (complain & tf_error)
-   error ("%qE is not a valid template argument for type %qT "
-  "because it is not an object with linkage",
-  expr, type);
- return NULL_TREE;
-   }
-
- /* DR 1155 allows internal linkage in C++11 and up.  */
- linkage_kind linkage = decl_linkage (expr);
- if (linkage < (cxx_dialect >= cxx11 ? lk_internal : lk_external))
-   {
- if (complain & tf_error)
-   error ("%qE is not a valid template argument for type %qT "
-  "because object %qD does not have linkage",
-  expr, type, expr);
- return NULL_TREE;
-   }
-
  expr = build_address (expr);
+
+ if (invalid_tparm_referent_p (type, expr, complain))
+   return NULL_TREE;
}

   if (!same_type_p (type, TREE_TYPE (expr)))

Tested on x86_64-linux, applying to trunk.

2019-04-24  Marek Polacek  

PR c++/90236
* g++.dg/cpp1z/nontype-auto16.C: New test.

diff --git gcc/testsuite/g++.dg/cpp1z/nontype-auto16.C 
gcc/testsuite/g++.dg/cpp1z/nontype-auto16.C
new file mode 100644
index 000..695bb11d780
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1z/nontype-auto16.C
@@ -0,0 +1,13 @@
+// PR c++/90236
+// { dg-do compile { target c++17 } }
+
+struct foo { };
+
+template  void fnc() { } 
+
+void
+test()
+{
+  static constexpr foo a;
+  fnc();
+}


Re: [RFA][tree-optimization/90037] Cleanup const/copies between DOM and erroneous path isolation

2019-04-24 Thread Jeff Law
On 4/24/19 4:44 AM, Richard Biener wrote:
>> Given that we can use the lattice copy propagator by just adding the
>> pass to passes.def whereas using the RPN VN actually requires a little
>> bit of real code (to set up the entry/exits for the relevant SEME
>> regions), I went with the lattice copy propagator.
>>
>> This change adds around .4% instruction executions to my testbed of .i
>> files.  It has no significant impact on the resulting code -- I see
>> different register allocation decisions in a lot of places which seem to
>> primarily result in reversing arguments to comparisons.
> 
> Was there a need to have two copy-prop passes in the early
> DOM/errorneous-path removal where we previously only had
> a single phi-only-prop pass?  Is the testcase fixed also when
> doing copy-prop only a single time?
So if we replace phi-only cprop with the lattice propagator and move the
pass which currently runs before erroneous path isolation so that it
instead runs before erroneous path isolation we're in pretty good shape.

isolate-2.c and isolate-4.c needed twiddling -- they need to look later
in the pipeline for an expected simplification, but the simplification
still occurs and it's not too much later than before.


I've bootstrapped and regression tested on x86_64, but no other targets
at this point.

OK for the trunk now?


Jeff
* Makefile.in (OBJS): Remove tree-ssa-phionlycprop.c
* passes.def: Replace all instance of phi-only cprop with the
lattice propagator.  Move propagation pass from after erroneous
path isolation to before erroneous path isolation.
* tree-ssa-phionlycprop.c: Remove.

* gcc.dg/tree-ssa/20030710-1.c: Update dump file to scan.
* gcc.dg/isolate-2.c: Likewise.
* gcc.dg/isolate-4.c: Likewise.
* gcc.dg/pr19431.c: Accept either ordering of PHI args.



diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index d186d71c91e..5f43d9de00e 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1559,7 +1559,6 @@ OBJS = \
tree-ssa-loop.o \
tree-ssa-math-opts.o \
tree-ssa-operands.o \
-   tree-ssa-phionlycprop.o \
tree-ssa-phiopt.o \
tree-ssa-phiprop.o \
tree-ssa-pre.o \
diff --git a/gcc/passes.def b/gcc/passes.def
index 446a7c48276..bc147cd 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -222,19 +222,13 @@ along with GCC; see the file COPYING3.  If not see
 trying to move or duplicate pass_dominator somewhere earlier.  */
   NEXT_PASS (pass_thread_jumps);
   NEXT_PASS (pass_dominator, true /* may_peel_loop_headers_p */);
-  /* At this point the majority of const/copy propagations
-are exposed.  Go ahead and identify paths that should never
-be executed in a conforming program and isolate those paths.
-
-This will expose more degenerate PHIs in the main path and
-expose more PRE/DOM optimization opportunities.  */
+  /* Threading can leave many const/copy propagations in the IL.
+Clean them up.  Failure to do so well can lead to false
+positives from warnings for erroneous code.  */
+  NEXT_PASS (pass_copy_prop);
+  /* Identify paths that should never be executed in a conforming
+program and isolate those paths.  */
   NEXT_PASS (pass_isolate_erroneous_paths);
-  /* The only const/copy propagation opportunities left after
-DOM and erroneous path isolation should be due to degenerate PHI nodes.
-So rather than run the full propagators, run a specialized pass which
-only examines PHIs to discover const/copy propagation
-opportunities.  */
-  NEXT_PASS (pass_phi_only_cprop);
   NEXT_PASS (pass_dse);
   NEXT_PASS (pass_reassoc, true /* insert_powi_p */);
   NEXT_PASS (pass_dce);
@@ -321,13 +315,10 @@ along with GCC; see the file COPYING3.  If not see
   NEXT_PASS (pass_strlen);
   NEXT_PASS (pass_thread_jumps);
   NEXT_PASS (pass_vrp, false /* warn_array_bounds_p */);
-  /* The only const/copy propagation opportunities left after
-DOM and VRP should be due to degenerate PHI nodes.  So rather than
-run the full propagators, run a specialized pass which
-only examines PHIs to discover const/copy propagation
-opportunities.  */
   NEXT_PASS (pass_warn_restrict);
-  NEXT_PASS (pass_phi_only_cprop);
+  /* Threading can leave many const/copy propagations in the IL.
+Clean them up.  */
+  NEXT_PASS (pass_copy_prop);
   NEXT_PASS (pass_dse);
   NEXT_PASS (pass_cd_dce);
   NEXT_PASS (pass_forwprop);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20030710-1.c 
b/gcc/testsuite/gcc.dg/tree-ssa/20030710-1.c
index 3dd3ba8bc17..529c79b26e3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/20030710-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/20030710-1.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-phicprop1" } */
+/* { dg-options "-O1 

[C++ PATCH] PR c++/90227 - error with template parameter packs.

2019-04-24 Thread Jason Merrill
If require_all_args, we aren't waiting for more args to be deduced later.

Tested x86_64-pc-linux-gnu, applying to trunk.

* pt.c (coerce_template_parms): Do add empty pack when
require_all_args.
---
 gcc/cp/pt.c  |  2 +-
 gcc/testsuite/g++.dg/cpp1y/var-templ62.C | 80 
 gcc/cp/ChangeLog |  6 ++
 3 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/var-templ62.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 5f73fac3e8f..e682b6d51be 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8477,7 +8477,7 @@ coerce_template_parms (tree parms,
arg = NULL_TREE;
 
   if (template_parameter_pack_p (TREE_VALUE (parm))
- && (arg || !(complain & tf_partial))
+ && (arg || require_all_args || !(complain & tf_partial))
  && !(arg && ARGUMENT_PACK_P (arg)))
 {
  /* Some arguments will be placed in the
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ62.C 
b/gcc/testsuite/g++.dg/cpp1y/var-templ62.C
new file mode 100644
index 000..f78ca858ce9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/var-templ62.C
@@ -0,0 +1,80 @@
+// PR c++/90227
+// { dg-do compile { target c++14 } }
+
+template  struct c { static constexpr int d = b; typedef c e; };
+template  using f = a;
+template  using h = c;
+template  using i = c;
+template  struct ab {};
+template  struct k { using e = ab; };
+template  struct ad;
+template  struct ad> { using e = 
ab; };
+template  struct ae;
+template  struct ae> : i {};
+template ::d> struct ag;
+template  struct ag, 0, 0> { using e = ab<>; };
+template 
+struct ag, 0, ah> : k>::e, ah - 
1>::e> {};
+template 
+struct ag, ai, ah> : ag>::e, ai - 1> {};
+template  class> struct aj;
+template  class ak> struct aj, ak> 
{
+  using e = ab::e...>;
+};
+template  struct an;
+struct ao { typedef an<0> ap; };
+template  struct aq {};
+template  struct as;
+template  struct as> { typedef 
aq ap; };
+template  using au = typename as::ap;
+template  using av = aq;
+template  using aw = au;
+struct ay { using e = h::d>; };
+template  class, typename...>
+struct bb : ay::e {};
+struct bd { using e = av<>; };
+struct bg { using e = bd::e; };
+namespace bi {
+enum bj { bk };
+struct bo { enum n { bp }; };
+struct bq { bool br; static const bo::n bs = bo::bp; };
+template  struct bw { using e = bv; };
+template  class bx;
+template 
+struct bx, av> : bo {
+  static const n bs = bv::bs;
+  static const long ca = sizeof bv::br;
+  using cb = int;
+  using cc = ab;
+  using cd = typename ag::e;
+  using ce = typename ag::e;
+  using cf = aw;
+  using cg = typename bw::e;
+  using ch = decltype(cg()(cb(), cd(), ce(), cf()));
+};
+class ck;
+template  struct cl : c {};
+template 
+struct bx> : public bx, 
cl>::e, bg::e> {};
+}
+using bi::bj;
+using bi::ck;
+template  class co {
+  template  co(p) { c(); }
+  static co o;
+};
+namespace bi {
+template  class cp;
+template  using cq = bb;
+template  void cs(cr, f::d, void *> = nullptr);
+}
+using bi::cs;
+struct cu : bi::bq {
+  template 
+  auto operator()(int q, ab, ab, av<>) {
+cs(q);
+  }
+};
+template <>
+co>>
+co>>::o(0);
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3a6dc65dd5e..059a7fd0ea6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-04-24  Jason Merrill  
+
+   PR c++/90227 - error with template parameter packs.
+   * pt.c (coerce_template_parms): Do add empty pack when
+   require_all_args.
+
 2019-04-24  Richard Biener  
 
* call.c (null_ptr_cst_p): Order checks according to expensiveness.

base-commit: b66add0735ce28186c6cc3494c24200b75deeb73
-- 
2.20.1



Re: [PATCH] Check TBB version in tbb-backed effective target check

2019-04-24 Thread Jonathan Wakely

On 24/04/19 11:40 -0700, Thomas Rodgers wrote:


* testsuite/lib/libstdc++.exp (check_effective_target_tbb-backend):
Add check for Thread Building Blocks 2018 or later.




From bd3de7b67f184ed1387b63dc3bda1d12f7ebee04 Mon Sep 17 00:00:00 2001
From: Thomas Rodgers 
Date: Wed, 24 Apr 2019 11:34:14 -0700
Subject: [PATCH] Check TBB version in tbb-backed effective target check

* testsuite/lib/libstdc++.exp (check_effective_target_tbb-backend):
Add check for Thread Building Blocks 2018 or later.
---
libstdc++-v3/testsuite/lib/libstdc++.exp | 42 +---
1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index d0efc90a1ba..c48b4d78bbb 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1607,25 +1607,29 @@ proc check_effective_target_random_device { } {

# Return 1 if tbb parallel backend is available
proc check_effective_target_tbb-backend { } {
-   global cxxflags
-
-   # Set up and preprocess a C++ test program that depends
-   # on tbb
-   set src tbb_backend[pid].cc
-
-   set f [open $src "w"]
-   puts $f "#include "
-   close $f
-   set lines [v3_target_compile $src /dev/null preprocess ""]
-   file delete $src
-
-   if [string match "" $lines] {
-   # No error message, preprocessing succeeded.
-   verbose "check_v3_tbb-backend: `1'" 2
-   return 1
-   }
-   verbose "check_v3_tbb-backend: `0'" 2
-   return 0
+global cxxflags
+
+# Set up and preprocess a C++ test program that depends
+# on tbb
+set src tbb_backend[pid].cc
+
+set f [open $src "w"]
+puts $f "#include "
+puts $f "#if TBB_INTERFACE_VERSION < 1"
+puts $f "#  error Intel(R) Threading Building Blocks 2018 is required; older 
versions are not supported."
+puts $f "#endif"
+close $f
+


This line above has four spaces, but can be just an empty line.

OK for trunk with that tweak, thanks.



[PATCH, PR d/89432] Fix FAIL phobos.exp/core.time on CentOS 5.11, Linux 2.6.18

2019-04-24 Thread Iain Buclaw
Hi,

This patch adds -fversion=Linux_Pre_2639 to the druntime testsuite
compile flags if the linux OS version is older than 2.6.39.  The
second part is from upstream druntime e03164b5, fixing PR d/89432.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r270554.

-- 
Iain
---
libphobos/ChangeLog:

2019-04-24  Iain Buclaw  

PR d/89432
* testsuite/lib/libphobos.exp (check_effective_target_linux_pre_2639):
New proc.
* testsuite/libphobos.druntime/druntime.exp: Add compiler flag
-fversion=Linux_Pre_2639 if target is linux_pre_2639.
* testsuite/libphobos.druntime_shared/druntime_shared.exp: Likewise.

---
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 9fe51fd5ae9..d815647f969 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-513652173d6f02206be3ddaa2b6ed0b191ea4e3d
+e03164b5259a9f116eb91dfa5a18c192fa72e575
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/core/time.d b/libphobos/libdruntime/core/time.d
index 1982122858e..a7640ec1912 100644
--- a/libphobos/libdruntime/core/time.d
+++ b/libphobos/libdruntime/core/time.d
@@ -2539,8 +2539,11 @@ unittest
 
 static bool clockSupported(ClockType c)
 {
-version (Linux_Pre_2639) // skip CLOCK_BOOTTIME on older linux kernels
-return c != ClockType.second && c != ClockType.bootTime;
+// Skip unsupported clocks on older linux kernels, assume that only
+// CLOCK_MONOTONIC and CLOCK_REALTIME exist, as that is the lowest
+// common denominator supported by all versions of Linux pre-2.6.12.
+version (Linux_Pre_2639)
+return c == ClockType.normal || c == ClockType.precise;
 else
 return c != ClockType.second; // second doesn't work with MonoTimeImpl
 
diff --git a/libphobos/testsuite/lib/libphobos.exp b/libphobos/testsuite/lib/libphobos.exp
index d47da178b7e..d3fe75358c8 100644
--- a/libphobos/testsuite/lib/libphobos.exp
+++ b/libphobos/testsuite/lib/libphobos.exp
@@ -261,3 +261,20 @@ proc check_effective_target_libcurl_available { } {
 	int main (void) { return 0; }
 } "-lcurl"]
 }
+
+# Return true if the target is linux version < 2.6.39
+proc check_effective_target_linux_pre_2639 { } {
+if { ![istarget *-*-linux*] } {
+	return 0
+}
+
+if { [check_no_compiler_messages linux_pre_2639 assembly {
+	#include 
+	#if !defined LINUX_VERSION_CODE || LINUX_VERSION_CODE < KERNEL_VERSION(2.6.39)
+	#error Yes, it is.
+	#endif
+}] } {
+	return 0
+}
+return 1
+}
diff --git a/libphobos/testsuite/libphobos.druntime/druntime.exp b/libphobos/testsuite/libphobos.druntime/druntime.exp
index f93562b476b..0f792356500 100644
--- a/libphobos/testsuite/libphobos.druntime/druntime.exp
+++ b/libphobos/testsuite/libphobos.druntime/druntime.exp
@@ -22,13 +22,19 @@ if { ![isnative] || ![is-effective-target static] } {
 # Gather a list of all tests.
 set tests [lsort [filter_libphobos_unittests [find $srcdir/../libdruntime "*.d"]]]
 
+set version_flags ""
+
+if { [is-effective-target linux_pre_2639] } {
+lappend version_flags "-fversion=Linux_Pre_2639"
+}
+
 # Initialize dg.
 dg-init
 
 # Main loop.
 foreach test $tests {
 set libphobos_test_name "$subdir/[dg-trim-dirname $srcdir/../libdruntime $test]"
-dg-runtest $test "" "-fmain -fbuilding-libphobos-tests"
+dg-runtest $test "" "-fmain -fbuilding-libphobos-tests $version_flags"
 set libphobos_test_name ""
 }
 
diff --git a/libphobos/testsuite/libphobos.druntime_shared/druntime_shared.exp b/libphobos/testsuite/libphobos.druntime_shared/druntime_shared.exp
index 77b0402d029..1a067c3177c 100644
--- a/libphobos/testsuite/libphobos.druntime_shared/druntime_shared.exp
+++ b/libphobos/testsuite/libphobos.druntime_shared/druntime_shared.exp
@@ -22,6 +22,12 @@ if { ![isnative] || ![is-effective-target shared] } {
 # Gather a list of all tests.
 set tests [lsort [filter_libphobos_unittests [find $srcdir/../libdruntime "*.d"]]]
 
+set version_flags ""
+
+if { [is-effective-target linux_pre_2639] } {
+lappend version_flags "-fversion=Linux_Pre_2639"
+}
+
 # Initialize dg.
 dg-init
 
@@ -29,7 +35,7 @@ dg-init
 foreach test $tests {
 set libphobos_test_name "$subdir/[dg-trim-dirname $srcdir/../libdruntime $test]"
 dg-runtest $test "-fversion=Shared -shared-libphobos" \
-	"-fmain -fbuilding-libphobos-tests -fno-moduleinfo"
+	"-fmain -fbuilding-libphobos-tests -fno-moduleinfo $version_flags"
 set libphobos_test_name ""
 }
 


[PATCH] Check TBB version in tbb-backed effective target check

2019-04-24 Thread Thomas Rodgers

* testsuite/lib/libstdc++.exp (check_effective_target_tbb-backend):
Add check for Thread Building Blocks 2018 or later.

>From bd3de7b67f184ed1387b63dc3bda1d12f7ebee04 Mon Sep 17 00:00:00 2001
From: Thomas Rodgers 
Date: Wed, 24 Apr 2019 11:34:14 -0700
Subject: [PATCH] Check TBB version in tbb-backed effective target check

	* testsuite/lib/libstdc++.exp (check_effective_target_tbb-backend):
	Add check for Thread Building Blocks 2018 or later.
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 42 +---
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index d0efc90a1ba..c48b4d78bbb 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1607,25 +1607,29 @@ proc check_effective_target_random_device { } {
 
 # Return 1 if tbb parallel backend is available
 proc check_effective_target_tbb-backend { } {
-		global cxxflags
-
-		# Set up and preprocess a C++ test program that depends
-		# on tbb
-		set src tbb_backend[pid].cc
-
-		set f [open $src "w"]
-		puts $f "#include "
-		close $f
-		set lines [v3_target_compile $src /dev/null preprocess ""]
-		file delete $src
-
-		if [string match "" $lines] {
-# No error message, preprocessing succeeded.
-verbose "check_v3_tbb-backend: `1'" 2
-return 1
-		}
-		verbose "check_v3_tbb-backend: `0'" 2
-		return 0
+global cxxflags
+
+# Set up and preprocess a C++ test program that depends
+# on tbb
+set src tbb_backend[pid].cc
+
+set f [open $src "w"]
+puts $f "#include "
+puts $f "#if TBB_INTERFACE_VERSION < 1"
+puts $f "#  error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported."
+puts $f "#endif"
+close $f
+
+set lines [v3_target_compile $src /dev/null preprocess ""]
+file delete $src
+
+if [string match "" $lines] {
+	# No error message, preprocessing succeeded.
+	verbose "check_v3_tbb-backend: `1'" 2
+	return 1
+}
+verbose "check_v3_tbb-backend: `0'" 2
+return 0
 }
 
 set additional_prunes ""
-- 
2.20.1



Re: [RFA][tree-optimization/90037] Cleanup const/copies between DOM and erroneous path isolation

2019-04-24 Thread Jeff Law
On 4/24/19 4:44 AM, Richard Biener wrote:
> On Tue, Apr 23, 2019 at 4:29 PM Jeff Law  wrote:
>>
>>
>> As discussed in the BZ, this patch addresses the false positive warning
>> by cleaning up the const/copy propagations left in the IL between DOM's
>> jump threading and erroneous path isolation.
>>
>> In the past we'd been handling this stuff with phi only cprop.  To make
>> phi only cprop work in this case we'd have to change it to scan
>> statements within some subset of blocks where it had previously only
>> scanned PHIs.
>>
>> I was concerned about the compile-time cost of the additional scanning
>> plus the extra pass.  So I compared that against using the lattice based
>> const/copy propagation as well as against the RPO VN bits.
>>
>> It turns out that the lattice based const/copy propagation does the
>> least amount of work, closely followed by a limited RPO VN.  The
>> improved "phi only" copy propagator being the worst.
> 
> Interesting.
Definitely.  I didn't dig further than what's mentioned in the BZ.

> 
>> Given that we can use the lattice copy propagator by just adding the
>> pass to passes.def whereas using the RPN VN actually requires a little
>> bit of real code (to set up the entry/exits for the relevant SEME
>> regions), I went with the lattice copy propagator.
>>
>> This change adds around .4% instruction executions to my testbed of .i
>> files.  It has no significant impact on the resulting code -- I see
>> different register allocation decisions in a lot of places which seem to
>> primarily result in reversing arguments to comparisons.
> 
> Was there a need to have two copy-prop passes in the early
> DOM/errorneous-path removal where we previously only had
> a single phi-only-prop pass?  Is the testcase fixed also when
> doing copy-prop only a single time?
The testcase is fixed with a single copyprop (lattice or RPO VN) after
DOM but before erroneous path isolation.   I seriously considered just
dropping the copyprop pass after erroneous path isolation.  I'm pretty
sure it'll regress codegen quality, but it may not be too bad.


> 
> Also the late pass you replace should be right after VRP, not
> after warn_restrict (that was a mistake done when adding the
> warn_restrict pass).
Agreed.  But ISTM we should make that an independent change.

> 
> The main reason I dislike this is that it is an unconditional cleanup
> pass run even when we didn't perform any jump threading.  That's
> of course the same case as with the existing phi-only-prop passes
> but would have been my major argument for the SEME VN
> (where at some cut-off of course doing a single whole-function VN
> is cheaper than doing N SEME VNs, and I can even think of doing
> N SEME regions at once in exchange for doing a whole-function
> RPO order compute).
Yea.  We're certainly doing more work in the cases where we didn't
thread anything.  I've always wanted better ways to indicate what
actions a pass did and using that to bypass subsequent passes if they
weren't going to be profitable.




> 
>> FWIW I also considered delaying the erroneous path isolation pass.  I
>> ultimately decided against that.  My recollection is that its location
>> came from the desire to clean up those paths early enough in the
>> pipeline so that other optimizers could do a better job.
>>
>> We could consider an early/late split here.  Essentially we do the
>> optimization early, leaving enough data lying around somewhere for a
>> late pass to look for and issue the warning.  Something like a
>> __builtin_warning that we leave in the IL, then just before expanding to
>> RTL, we scan the IL once and issue the __builtin_warnings.
>>
>> In this specific case the __builtin_warning would be on a path that we
>> eventually would determine was unreachable at compile time and the path
>> would be removed.  I suspect we could do something similar for other
>> warnings coming out of the middle end.
>>
>> Anyway, this has been bootstrapped and regression tested on x86_64,
>> ppc64, i686, sparc64, & ppc64le.  It's also been bootstrapped on alpha,
>> ppc (32 bit), armeb, m68k, riscv64, mipsisa32r4, arm, sh4, & sh4eb.
>> It's also built and regression tested all the *-elf targets in my tester.
>>
>> OK for the trunk, or do we want to defer to gcc-10?
> 
> I like the pass removal and would say OK if you manage with
> a 1:1 replacement (thus get rid of that extra copy-prop between
> DOM and pass_isolate_erroneous_paths).
That's the one we need to fix the regression.  We might be able to drop
the one after erroneous path isolation which would keep us at the 1:1
replacement.  I'll poke at that.

jeff


Re: [aarch64][RFA][rtl-optimization/87763] Fix insv_1 and insv_2 for aarch64

2019-04-24 Thread Jeff Law
On 4/24/19 7:05 AM, Segher Boessenkool wrote:
> Hi Jeff,
> 
> On Mon, Apr 22, 2019 at 09:09:12AM -0600, Jeff Law wrote:
>> First, it re-uses combine's make_field_assignment in the aarch64
>> backend.
> 
> That's not really acceptable.  make_field_assignment depends intimately
> on make_extraction, which is very much combine-specific (and wrong in so
> many ways it's hard to tell).
I think the structure of the pattern and its condition avoid the most
problematic issues.  But yea, it's not ideal.

>> So we don't have to duplicate any of that logic.  I scanned
>> make_field_assignment and its children to make sure it didn't use any
>> data that was only valid during the combine pass, but I could have
>> missed something.  This is one of those cases where encapsulating the
>> pass specific bits in a class really helps avoid problems...  Just
>> saying
> 
> It isn't the data that is the problem.  combine has almost no private
> data.  But the problem is all the hidden assumptions combine makes, and
> for example that it often make **non-canonical** RTL; this is no problem
> in combine, because that code will just not recog() (except of course
> that you then get less well optimised code, in general).  (Often, combine
> makes that RTL canonical later, fwiw).
> 
> But it _is_ a big problem in other contexts: you should not create
> non-canonical RTL.  In your specific case, where you want to run this
> from a splitter, you have to make sure you get only correct, recognised
> patterns for your machine.  make_field_extraction cannot guarantee you
> that.
Even in the case where the form and operands are limited to what's in
the new pattern?  My worry with make_extraction is those cases where it
gets too smart for its own good and returns something even simpler than
extraction.  I'm not sure that can happen in this case or not.

I'm not keen on duplicating the logic from make_field_assignment and
make_extraction.  Though again, given the limited forms we accept it may
not be too bad.

> 
>> Second, it relaxes the main insv pattern to allow an immediate in the
>> operand predicate, but forces it into a register during LRA.  I don't
>> generally like having predicates that are looser than the constraints,
>> but it really helps here.  Basically we want to see the constant field
>> we're going to insert.
> 
> You also have an insn condition that can become invalid by the time the
> pattern is split (the !reload_complted part), which means the pattern
> will then *not* be split, which won't work here (the template is "#").
The pattern is split by the splitting pass before register allocation
and reload.  It's never supposed to exist beyond that splitting pass.
I'm pretty sure we've done this kind of thing regularly in the past.


> 
>> -static int
>> +int
>>  get_pos_from_mask (unsigned HOST_WIDE_INT m, unsigned HOST_WIDE_INT *plen)
> 
> If you want to reuse this, please give it a better name, and move it to
> rtlanal or some header file or similar?
If we go forward, yea, makes sense.

> 
> It may be nicer to make a more machine-specific routine for this, see
> rs6000_is_valid_mask for example.
> 
>> +;; This must be split before register allocation and reloading as
>> +;; we need to verify it's actually an bitfield insertion by
>> +;; examining both immediate operands.  After reload we will lose
>> +;; knowledge of operands[3] constant status.
> 
> I don't understand what this means?  After reload operands[3] is still a
> const_int?
It has to be an integer prior to register allocation.  Otherwise we
can't verify we have a valid field assignment.

The pattern should never exist past the insn splitting pass.  The
comment is obsolete.  It should always be split prior to register
allocation into a field assignment.



> 
>> +(define_insn_and_split ""
> 
> Give this a name?  Starting with * if you don't want a gen_* for it.
Didn't figure it was worth the trouble.  But it's easy enough to do.

> 
>> +  [(set (match_operand:GPI 0 "register_operand" "=r")
>> +(ior:GPI (and:GPI (match_operand:GPI 1 "register_operand" "0")
>> +  (match_operand:GPI 2 "const_int_operand" "n"))
>> + (match_operand:GPI 3 "const_int_operand" "n")))]
>> +  "(!reload_completed
>> +/* make_field_assignment doesn't handle subregs well.  */
>> +&& REG_P (operands[0])
> 
> Another reason to not use make_field_assignment, I'm afraid :-(
Perhaps.  I'd probably want to avoid SUBREGs here regardless :-)


jeff



Re: [PATCH v2] go: disable mvsx and maltivec for aix/ppc

2019-04-24 Thread David Edelsohn
On Tue, Apr 23, 2019 at 4:27 AM CHIGOT, CLEMENT  wrote:
>
> Description:
>   * This patch removes -mvsx and -maltivec for go aix/ppc.
>  These options don't seem compatible with Go stack layout.
>
> Tests:
>   * AIX 7.2:  Configure/Build: SUCCESS
>
> Changelog:
>   * config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Remove OPTION_MASK_VSX
>  and OPTION_MASK_ALTIVEC from rs6000_isa_flags with Go on 32 bits.
>   * config/rs6000/aix72.h (SUBTARGET_OVERRIDE_OPTIONS): Likewise.

I have committed this patch.

Thanks, David


[PATCH] Use __and_v<...> instead of __and_<...>::value

2019-04-24 Thread Jonathan Wakely

Some minor tweaks to C++17 and C++2a components

* include/std/any (any::any(ValueType&&)): Use __and_v.
* include/std/numeric (midpoint(T, T, T), midpoint(T*, T*, T*)):
Likewise.

Tested powerpc64le-linux, committed to trunk.

commit b31d88f0da87ad6d07f012deb51756a5ade7883a
Author: Jonathan Wakely 
Date:   Wed Apr 24 17:06:08 2019 +0100

Use __and_v<...> instead of __and_<...>::value

* include/std/any (any::any(ValueType&&)): Use __and_v.
* include/std/numeric (midpoint(T, T, T), midpoint(T*, T*, T*)):
Likewise.

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 29fe03e2b82..8cbab9b 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -189,9 +189,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 /// Construct with a copy of @p __value as the contained object.
 template ,
  typename _Mgr = _Manager<_Tp>,
-  enable_if_t<__and_,
-__not_>,
-__not_<__is_in_place_type<_Tp>>>::value,
+  enable_if_t<__and_v,
+ __not_>,
+ __not_<__is_in_place_type<_Tp>>>,
  bool> = false>
   any(_ValueType&& __value)
   : _M_manager(&_Mgr::_S_manage)
diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric
index ffd9eae9691..4858ad1aea3 100644
--- a/libstdc++-v3/include/std/numeric
+++ b/libstdc++-v3/include/std/numeric
@@ -162,8 +162,8 @@ namespace __detail
 
 template
 constexpr
-enable_if_t<__and_, is_same, _Tp>,
-  __not_>>::value,
+enable_if_t<__and_v, is_same, _Tp>,
+   __not_>>,
_Tp>
 midpoint(_Tp __a, _Tp __b) noexcept
 {
@@ -192,8 +192,7 @@ template
 
   template
 constexpr
-enable_if_t<__and_, bool_constant>::value,
-   _Tp*>
+enable_if_t<__and_v, bool_constant>, _Tp*>
 midpoint(_Tp* __a, _Tp* __b) noexcept
 {
   return __a > __b ? __b + (__a - __b) / 2 : __a + (__b - __a) / 2;


[PATCH] Finish implementing "Treating Unnecessary decay" (P0777R1)

2019-04-24 Thread Jonathan Wakely

Some more recent-ish changes to the C++ working draft

* include/std/tuple (apply): Use remove_reference_t instead of decay_t
as per P0777R1.
* include/std/type_traits (__result_of_memfun): Use remove_reference
instead of __remove_cvref_t and remove redundant is_same check.
(__inv_unwrap): Use __remove_cvref_t instead of decay_t.

Tested powerpc64le-linux, committed to trunk.

commit 1880e0a8be25f674c281db95e0224121a4a58201
Author: Jonathan Wakely 
Date:   Wed Apr 24 17:03:52 2019 +0100

Finish implementing "Treating Unnecessary decay" (P0777R1)

* include/std/tuple (apply): Use remove_reference_t instead of 
decay_t
as per P0777R1.
* include/std/type_traits (__result_of_memfun): Use remove_reference
instead of __remove_cvref_t and remove redundant is_same check.
(__inv_unwrap): Use __remove_cvref_t instead of decay_t.

diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 0adef1ab384..6c7d91b7987 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -1674,7 +1674,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
   { }
 
-#if __cplusplus > 201402L
+#if __cplusplus >= 201703L
 # define __cpp_lib_apply 201603
 
   template 
@@ -1689,7 +1689,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 constexpr decltype(auto)
 apply(_Fn&& __f, _Tuple&& __t)
 {
-  using _Indices = make_index_sequence>>;
+  using _Indices
+   = make_index_sequence>>;
   return std::__apply_impl(std::forward<_Fn>(__f),
   std::forward<_Tuple>(__t),
   _Indices{});
diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index e0ac5c88dfc..1d14c751cfa 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -2327,10 +2327,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
 {
-  typedef __remove_cvref_t<_Arg> _Argval;
+  typedef typename remove_reference<_Arg>::type _Argval;
   typedef _Res _Class::* _MemPtr;
-  typedef typename conditional<__or_,
-is_base_of<_Class, _Argval>>::value,
+  typedef typename conditional::value,
 __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
 __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
   >::type::type type;
@@ -2341,7 +2340,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   //as the object expression
 
   // Used by result_of, invoke etc. to unwrap a reference_wrapper.
-  template::type>
+  template>
 struct __inv_unwrap
 {
   using type = _Tp;


[PATCH] Fix basic_string_view typedefs and enforce preconditions

2019-04-24 Thread Jonathan Wakely

The basic_string_view::pointer and basic_string_view::reference typedefs
are supposed to refer to the non-const value type.

In previous standards having traits_type::char_type different to
value_type was simply undefined, but in the C++2a draft it's ill-formed,
as changed by P1148R0. For std::basic_string and iostreams we might
want to only enforce this conditionally for __cplusplus > 201703L but
for std::basic_string_view we don't have backwards compatibility
concerns. Also add assertions to verify the _CharT argument is a
"char-like" type (non-array, trivial, standard layout type).

Also remove the non-standard basic_string_view::_M_check and
basic_string_view::_M_limit member functions, replacing them with
non-member functions that will still exist even if basic_string_view is
specialized by the program.

* include/experimental/string_view (basic_string_view::pointer)
(basic_string_view::reference): Fix to refer to non-const value_type.
* include/bits/basic_string.h (basic_string): Use __sv_check and
__sv_limit instead of basic_string_view::_M_check and
basic_string_view::_M_limit.
* include/std/string_view (__sv_check, __sv_limit): New
helper functions to replace basic_string_view::_M_check and
basic_string_view::_M_limit.
(basic_string_view): Add static assertions to enforce ill-formed
requirement for traits_type::char_type from P1148R0, and to enforce
required properties of char-like types.
(basic_string_view::pointer, basic_string_view::reference): Fix to
refer to non-const value_type.
(basic_string_view::operator[], basic_string_view::at)
(basic_string_view::front, basic_string_view::back)
(basic_string_view::data): Use const_reference and const_pointer
typedefs for return types.
(basic_string_view::_M_check, basic_string_view::_M_limit): Remove.
(hash): Fix argument_type typedef.
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/
char/1.cc: Fix expected return type of basic_string_view::data().
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/
wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/
char/1.cc: Likewise.
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/
wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string_view/requirements/traits_neg.cc:
New test.
* testsuite/21_strings/basic_string_view/requirements/typedefs.cc:
Check reference and pointer typedefs.
* testsuite/experimental/string_view/requirements/typedefs.cc:
Likewise.
* testsuite/experimental/string_view/modifiers/remove_prefix/char/1.cc:
Fix expected return type of basic_string_view::data().
* testsuite/experimental/string_view/modifiers/remove_prefix/wchar_t/
1.cc: Likewise.
* testsuite/experimental/string_view/modifiers/remove_suffix/char/1.cc:
Likewise.
* testsuite/experimental/string_view/modifiers/remove_suffix/wchar_t/
1.cc: Likewise.

Tested powerpc64le-linux, committed to trunk.


commit 8550351dc031d50d3a37d8972a9d60227e9160bc
Author: Jonathan Wakely 
Date:   Wed Apr 24 14:04:23 2019 +0100

Fix basic_string_view typedefs and enforce preconditions

The basic_string_view::pointer and basic_string_view::reference typedefs
are supposed to refer to the non-const value type.

In previous standards having traits_type::char_type different to
value_type was simply undefined, but in the C++2a draft it's ill-formed,
as changed by P1148R0. For std::basic_string and iostreams we might
want to only enforce this conditionally for __cplusplus > 201703L but
for std::basic_string_view we don't have backwards compatibility
concerns. Also add assertions to verify the _CharT argument is a
"char-like" type (non-array, trivial, standard layout type).

Also remove the non-standard basic_string_view::_M_check and
basic_string_view::_M_limit member functions, replacing them with
non-member functions that will still exist even if basic_string_view is
specialized by the program.

* include/experimental/string_view (basic_string_view::pointer)
(basic_string_view::reference): Fix to refer to non-const 
value_type.
* include/bits/basic_string.h (basic_string): Use __sv_check and
__sv_limit instead of basic_string_view::_M_check and
basic_string_view::_M_limit.
* include/std/string_view (__sv_check, __sv_limit): New
helper functions to replace basic_string_view::_M_check and
basic_string_view::_M_limit.
(basic_string_view): Add static assertions to enforce ill-formed
requirement for traits_type::char_type from P1148R0, and to enforce

Re: [PATCH] Fix up RTL splitting of asm goto (PR target/90193)

2019-04-24 Thread Eric Botcazou
> 2019-04-24  Jakub Jelinek  
> 
>   PR target/90193
>   * rtl.c (classify_insn): Return JUMP_INSN for asm goto.
>   * emit-rtl.c (try_split): Copy over REG_LABEL_TARGET.
> 
>   * gcc.target/i386/pr90193.c: New test.

OK, thanks.

-- 
Eric Botcazou


[PATCH PR d/88654] Committed skip curl tests if libcurl is not installed on the target.

2019-04-24 Thread Iain Buclaw
Hi,

This patch adds necessary functionality in the libphobos testsuite to
mark druntime and phobos unit-tests to be skipped on matched targets.
Added entries to skip curl tests if libcurl is not installed.

Regression tested on x86_64-linux-gnu on multilibs -m32, -mx32, and
-m64 where curl was not installed.

Committed to trunk as r270545.

-- 
Iain
---
libphobos/ChangeLog:

2019-04-24  Iain Buclaw  

PR d/88654
* testsuite/lib/libphobos.exp (libphobos-dg-test): Check
libphobos_skipped_test_p before running test.
(libphobos-dg-prune): New proc.
(libphobos_init): Set libphobos_skip_tests.
(libphobos_skipped_test_p): New proc.
(check_effective_target_libcurl_available): New proc.
* testsuite/libphobos.phobos/phobos.exp: Skip curl tests if library
not found.
* testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.

---
diff --git a/libphobos/testsuite/lib/libphobos.exp b/libphobos/testsuite/lib/libphobos.exp
index 6d113bc5172..d47da178b7e 100644
--- a/libphobos/testsuite/lib/libphobos.exp
+++ b/libphobos/testsuite/lib/libphobos.exp
@@ -47,8 +47,8 @@ proc libphobos-dg-test { prog do_what extra_tool_flags } {
 set output_file ""
 
 global libphobos_test_name
+upvar name name
 if { $libphobos_test_name != "" } {
-	upvar name name
 	set name $libphobos_test_name
 }
 
@@ -80,11 +80,19 @@ proc libphobos-dg-test { prog do_what extra_tool_flags } {
 	lappend options "additional_flags=$extra_tool_flags"
 }
 
-set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options]
+set unsupported_message [libphobos_skipped_test_p $name]
+if { $unsupported_message != "" } {
+	return [list "::unsupported::$unsupported_message" $output_file]
+}
 
+set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options]
 return [list $comp_output $output_file]
 }
 
+proc libphobos-dg-prune { system text } {
+return $text
+}
+
 #
 # libphobos_init
 #
@@ -120,6 +128,9 @@ proc libphobos_init { args } {
 global libphobos_test_name
 set libphobos_test_name ""
 
+global libphobos_skip_tests
+set libphobos_skip_tests { }
+
 # Default settings.
 set blddir [lookfor_file [get_multilibs] libphobos]
 set flags_file "${blddir}/testsuite/testsuite_flags"
@@ -143,7 +154,7 @@ proc libphobos_init { args } {
 }
 
 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
-set ld_library_path ""
+set ld_library_path "."
 
 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
 if {$gccdir != ""} {
@@ -218,3 +229,35 @@ proc filter_libphobos_unittests { list } {
 }
 return $res
 }
+
+# Skip the unittest (report it as UNSUPPORTED) if the module exists in
+# libphobos_skip_tests and its target list is matched by dg-process-target.
+#
+# The expected format of the libphobos_skip_tests file is:
+# { test { targets } }
+proc libphobos_skipped_test_p { test } {
+global libphobos_skip_tests
+
+set row [lsearch -inline -index 0 $libphobos_skip_tests $test]
+if { $row eq "" } {
+	return ""
+}
+
+if { [llength $row] != 2 } {
+	error "syntax error in libphobos_skip_tests: $row"
+}
+
+set selector [list target [lindex $row 1]]
+if { [dg-process-target-1 $selector] != "S" } {
+	return ""
+}
+
+return "skipped test"
+}
+
+# Return true if the curl library is supported on the target.
+proc check_effective_target_libcurl_available { } {
+return [check_no_compiler_messages libcurl_available executable {
+	int main (void) { return 0; }
+} "-lcurl"]
+}
diff --git a/libphobos/testsuite/libphobos.phobos/phobos.exp b/libphobos/testsuite/libphobos.phobos/phobos.exp
index 8ace023a832..4b731d34cb6 100644
--- a/libphobos/testsuite/libphobos.phobos/phobos.exp
+++ b/libphobos/testsuite/libphobos.phobos/phobos.exp
@@ -22,6 +22,12 @@ if { ![isnative] || ![is-effective-target static] } {
 # Gather a list of all tests.
 set tests [lsort [filter_libphobos_unittests [find $srcdir/../src "*.d"]]]
 
+set libphobos_skip_tests {
+# Skip curl tests if library is not available
+{ libphobos.phobos/etc/c/curl.d { ! libcurl_available } }
+{ libphobos.phobos/std/net/curl.d { ! libcurl_available } }
+}
+
 # Initialize dg.
 dg-init
 
diff --git a/libphobos/testsuite/libphobos.phobos_shared/phobos_shared.exp b/libphobos/testsuite/libphobos.phobos_shared/phobos_shared.exp
index b0510914499..f651abbed78 100644
--- a/libphobos/testsuite/libphobos.phobos_shared/phobos_shared.exp
+++ b/libphobos/testsuite/libphobos.phobos_shared/phobos_shared.exp
@@ -22,6 +22,12 @@ if { ![isnative] || ![is-effective-target shared] } {
 # Gather a list of all tests.
 set tests [lsort [filter_libphobos_unittests [find $srcdir/../src "*.d"]]]
 
+set libphobos_skip_tests {
+# Skip curl tests if library is not available
+{ libphobos.phobos_shared/etc/c/curl.d { ! libcurl_available } }
+{ 

Re: [PATCH v2] go: disable mvsx and maltivec for aix/ppc

2019-04-24 Thread David Edelsohn
On Wed, Apr 24, 2019 at 9:31 AM Ian Lance Taylor  wrote:
>
> On Tue, Apr 23, 2019 at 1:27 AM CHIGOT, CLEMENT  
> wrote:
> >
> > Description:
> >   * This patch removes -mvsx and -maltivec for go aix/ppc.
> >  These options don't seem compatible with Go stack layout.
> >
> > Tests:
> >   * AIX 7.2:  Configure/Build: SUCCESS
> >
> > Changelog:
> >   * config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Remove 
> > OPTION_MASK_VSX
> >  and OPTION_MASK_ALTIVEC from rs6000_isa_flags with Go on 32 bits.
> >   * config/rs6000/aix72.h (SUBTARGET_OVERRIDE_OPTIONS): Likewise.
>
> I still don't understand why there is a problem here.  When using
> gccgo the "Go stack layout" is exactly the same as the C stack layout.
> But this patch is fine with me if it's OK with the AIX maintainers.

There is an underlying problem that Clement has not yet found.  This
is a workaround.

I will test the patch in my build.

Thanks, David


Re: [PATCH v2] go: disable mvsx and maltivec for aix/ppc

2019-04-24 Thread Ian Lance Taylor
On Tue, Apr 23, 2019 at 1:27 AM CHIGOT, CLEMENT  wrote:
>
> Description:
>   * This patch removes -mvsx and -maltivec for go aix/ppc.
>  These options don't seem compatible with Go stack layout.
>
> Tests:
>   * AIX 7.2:  Configure/Build: SUCCESS
>
> Changelog:
>   * config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Remove OPTION_MASK_VSX
>  and OPTION_MASK_ALTIVEC from rs6000_isa_flags with Go on 32 bits.
>   * config/rs6000/aix72.h (SUBTARGET_OVERRIDE_OPTIONS): Likewise.

I still don't understand why there is a problem here.  When using
gccgo the "Go stack layout" is exactly the same as the C stack layout.
But this patch is fine with me if it's OK with the AIX maintainers.

Ian


Re: [PATCH] libiberty: Only declare vasprintf if it was checked for

2019-04-24 Thread Ian Lance Taylor via gcc-patches
On Mon, Apr 22, 2019 at 11:51 PM Michael Forney  wrote:
>
> This matches how the the rest of the libc functions are declared and
> prevents a potential conflict with the system declaration when libiberty.h
> is included from a directory that did not check for vasprintf, but it is
> available. It also corresponds to a similar previous change for asprintf
> (r223589).
>
> 2019-04-22  Michael Forney  
>
> * libiberty.h (vasprintf): Don't declare if HAVE_DECL_VASPRINTF
> is not defined.

This is OK.

Thanks.

Ian


Re: [PATCH, netbsd] Define TARGET_D_CRITSEC_SIZE for D language

2019-04-24 Thread Kamil Rytarowski
On 24.04.2019 13:25, Iain Buclaw wrote:
> On Wed, 24 Apr 2019 at 13:03, Kamil Rytarowski  wrote:
>>
>> On 24.04.2019 03:30, Iain Buclaw wrote:
>>> On Wed, 24 Apr 2019 at 01:56, Kamil Rytarowski  wrote:

 On 24.04.2019 01:13, Iain Buclaw wrote:
>>> https://explore.dgnu.org/z/U29cni
>>>
>>> I'll add special handling for them, but otherwise 48/28 looks like the
>>> reasonable default.
>>>
>>

OK, so please go for this.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] Fix PR90194

2019-04-24 Thread Jakub Jelinek
On Wed, Apr 24, 2019 at 03:11:27PM +0200, Richard Biener wrote:
> 
> While the PR is about an ICE during debug stmt expansion
> it shows a missed optimization ultimatively leading to a
> debug stmt refering to VIEW_CONVERT_EXPR({}) which isn't
> handled.
> 
> The following fixes the missed optimization and thus also
> the ICE by instead producing a debug stmt refering to 0.
> 
> Bootstrap / regtest running on x86_64-unknown-linux-gnu.
> 
> OK for GCC 9?  The ICE would be a checking-only ICE.
> 
> Richard.
> 
> 2019-04-24  Richard Biener  
> 
>   PR middle-end/90194
>   * match.pd: Add pattern to simplify view-conversion of an
>   empty constructor.
> 
>   * g++.dg/torture/pr90194.C: New testcase.

LGTM, thanks.

Jakub


[PATCH] Fix PR90194

2019-04-24 Thread Richard Biener


While the PR is about an ICE during debug stmt expansion
it shows a missed optimization ultimatively leading to a
debug stmt refering to VIEW_CONVERT_EXPR({}) which isn't
handled.

The following fixes the missed optimization and thus also
the ICE by instead producing a debug stmt refering to 0.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

OK for GCC 9?  The ICE would be a checking-only ICE.

Richard.

2019-04-24  Richard Biener  

PR middle-end/90194
* match.pd: Add pattern to simplify view-conversion of an
empty constructor.

* g++.dg/torture/pr90194.C: New testcase.

Index: gcc/match.pd
===
--- gcc/match.pd(revision 270537)
+++ gcc/match.pd(working copy)
@@ -2596,6 +2596,13 @@ (define_operator_list COND_TERNARY
   && TYPE_UNSIGNED (TREE_TYPE (@1)
(view_convert @1)))
 
+/* Simplify a view-converted empty constructor.  */
+(simplify
+  (view_convert CONSTRUCTOR@0)
+  (if (TREE_CODE (@0) != SSA_NAME
+   && CONSTRUCTOR_NELTS (@0) == 0)
+   { build_zero_cst (type); }))
+
 /* Re-association barriers around constants and other re-association
barriers can be removed.  */
 (simplify
Index: gcc/testsuite/g++.dg/torture/pr90194.C
===
--- gcc/testsuite/g++.dg/torture/pr90194.C  (nonexistent)
+++ gcc/testsuite/g++.dg/torture/pr90194.C  (working copy)
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-additional-options "-g" }
+
+struct cb {
+int yr;
+};
+
+void *
+operator new (__SIZE_TYPE__, void *nq)
+{
+  return nq;
+}
+
+void
+af (int xn)
+{
+  new () cb { };
+}


Re: [aarch64][RFA][rtl-optimization/87763] Fix insv_1 and insv_2 for aarch64

2019-04-24 Thread Segher Boessenkool
Hi Jeff,

On Mon, Apr 22, 2019 at 09:09:12AM -0600, Jeff Law wrote:
> First, it re-uses combine's make_field_assignment in the aarch64
> backend.

That's not really acceptable.  make_field_assignment depends intimately
on make_extraction, which is very much combine-specific (and wrong in so
many ways it's hard to tell).

If you now use this in other places than combine, we will *never* be able
to fix it.  It's also shoddy architecture, of course.

> So we don't have to duplicate any of that logic.  I scanned
> make_field_assignment and its children to make sure it didn't use any
> data that was only valid during the combine pass, but I could have
> missed something.  This is one of those cases where encapsulating the
> pass specific bits in a class really helps avoid problems...  Just
> saying

It isn't the data that is the problem.  combine has almost no private
data.  But the problem is all the hidden assumptions combine makes, and
for example that it often make **non-canonical** RTL; this is no problem
in combine, because that code will just not recog() (except of course
that you then get less well optimised code, in general).  (Often, combine
makes that RTL canonical later, fwiw).

But it _is_ a big problem in other contexts: you should not create
non-canonical RTL.  In your specific case, where you want to run this
from a splitter, you have to make sure you get only correct, recognised
patterns for your machine.  make_field_extraction cannot guarantee you
that.

> Second, it relaxes the main insv pattern to allow an immediate in the
> operand predicate, but forces it into a register during LRA.  I don't
> generally like having predicates that are looser than the constraints,
> but it really helps here.  Basically we want to see the constant field
> we're going to insert.

You also have an insn condition that can become invalid by the time the
pattern is split (the !reload_complted part), which means the pattern
will then *not* be split, which won't work here (the template is "#").

> -static int
> +int
>  get_pos_from_mask (unsigned HOST_WIDE_INT m, unsigned HOST_WIDE_INT *plen)

If you want to reuse this, please give it a better name, and move it to
rtlanal or some header file or similar?

It may be nicer to make a more machine-specific routine for this, see
rs6000_is_valid_mask for example.

> +;; This must be split before register allocation and reloading as
> +;; we need to verify it's actually an bitfield insertion by
> +;; examining both immediate operands.  After reload we will lose
> +;; knowledge of operands[3] constant status.

I don't understand what this means?  After reload operands[3] is still a
const_int?

> +(define_insn_and_split ""

Give this a name?  Starting with * if you don't want a gen_* for it.

> +  [(set (match_operand:GPI 0 "register_operand" "=r")
> + (ior:GPI (and:GPI (match_operand:GPI 1 "register_operand" "0")
> +   (match_operand:GPI 2 "const_int_operand" "n"))
> +  (match_operand:GPI 3 "const_int_operand" "n")))]
> +  "(!reload_completed
> +/* make_field_assignment doesn't handle subregs well.  */
> +&& REG_P (operands[0])

Another reason to not use make_field_assignment, I'm afraid :-(


Segher


[PATCH] Fix overflow in fold_const_aggregate_ref_1, PR90213

2019-04-24 Thread Richard Biener


Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2019-04-24  Richard Biener  

PR middle-end/90213
* gimple-fold.c (fold_const_aggregate_ref_1): Do multiplication
by size and BITS_PER_UNIT on poly-wide-ints.

Index: gcc/gimple-fold.c
===
--- gcc/gimple-fold.c   (revision 270537)
+++ gcc/gimple-fold.c   (working copy)
@@ -6983,14 +6983,10 @@ fold_const_aggregate_ref_1 (tree t, tree
= wi::sext (wi::to_poly_offset (idx)
- wi::to_poly_offset (low_bound),
TYPE_PRECISION (TREE_TYPE (idx)));
-
+ woffset *= tree_to_uhwi (unit_size);
+ woffset *= BITS_PER_UNIT;
  if (woffset.to_shwi ())
{
- /* TODO: This code seems wrong, multiply then check
-to see if it fits.  */
- offset *= tree_to_uhwi (unit_size);
- offset *= BITS_PER_UNIT;
-
  base = TREE_OPERAND (t, 0);
  ctor = get_base_constructor (base, , valueize);
  /* Empty constructor.  Always fold to 0.  */


Re: [PATCH] Fix ARM exception handling (PR target/89093)

2019-04-24 Thread Ian Lance Taylor
On Mon, Apr 22, 2019 at 2:14 AM Jakub Jelinek  wrote:
>
> As detailed in the PR, unlike most other targets, on ARM EABI the floating
> point registers are saved lazily, when EH personality routine calls
> __gnu_unwind_frame (usually in the CONTINUE_UNWINDING macro).
> That means the unwinder itself and the personality routines (and whatever
> other functions those call in the path to CONTINUE_UNWINDING) must be
> compiled so that it doesn't use floating point registers.  Calling some
> function that saves those on entry and restores on exit is fine, but calling
> some function which saves those on entry and then calls __gnu_unwind_frame
> and then restores on exit is not fine.
> In 8.x and earlier we were just lucky that the RA when compiling those
> didn't decide to use any of those registers, but starting with the combiner
> hard register changes we are no longer so lucky.
>
> The following patch introduces -mgeneral-regs-only option and
> general-regs-only target attribute for ARM (similarly to how other targets
> like AArch64 and x86), changes the ARM unwinder to be compiled with that
> and changes the personality routines of all languages so that either just
> the personality routine, or whatever other routines called by personality
> routines that call directly or indirectly __gnu_unwind_frame to be compiled
> that way.
>
> Bootstrapped/regtested on armv7hl-linux-gnueabi (and x86_64-linux to make
> sure it compiles on other targets too).
>
> Ok for trunk?
>
> While the libgo changes are included in the patch, I think those need to go
> through go upstream and will likely need some changes if that code can be
> compiled by earlier GCC versions or other compilers.

Thanks.  I've committed the libgo changes.  (Older versions of GCC
have their own copy of libgo, and there are not yet any non-GCC
compilers that use this code and support ARM.)

Ian


Re: Adding noexcept-specification on tuple constructors (LWG 2899)

2019-04-24 Thread Jonathan Wakely

On 24/04/19 11:21 +0100, Nina Dinka Ranns wrote:

New diff attached.


Thanks, this looks great. I think we can apply this as soon as stage 1
begins (which should be Real Soon Now).




Re: [PATCH] PR libstdc++/90220 Fix std::any_cast for function pointers

2019-04-24 Thread Jonathan Wakely

On 24/04/19 10:46 +0100, Jonathan Wakely wrote:

PR libstdc++/90220 (partial)
* include/std/any (any_cast(any*), any_cast(const any*)): Do
not attempt ill-formed static_cast to pointers to non-object types.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
function types.

Tested powerpc64le-linux, committed to trunk.

The PR describes two bugs in any_cast, but I might leave the fix for
the other part until stage 1.


On second thoughts, the fix for the other part seems obviously safe to
commit now as well. I've attached what I've tested. I plan to commit
this later today.

I'm considering backporting these too.

commit a8c2cffdf4cf2dafd95d5648ce74cf2f754f8ef1
Author: Jonathan Wakely 
Date:   Wed Apr 24 11:17:19 2019 +0100

PR libstdc++/90220 Fix std::any_cast for array types

Although the std::any constructors use decay_t to determine the type of
the contained value, std::any_cast should use the un-decayed type (and
so always fail for function and array types that decay to pointers).

Using remove_cv_t is correct, because the condition for std::any_cast
to return non-null is operand.type() == typeid(T) and typeid ignores
top-level cv-qualifiers.

PR libstdc++/90220
* include/std/any (__any_caster): Use remove_cv_t instead of decay_t.
Avoid a runtime check for types that can never be stored in std::any.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
array types.

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 792db27b061..29fe03e2b82 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -506,14 +506,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 void* __any_caster(const any* __any)
 {
-  if constexpr (is_copy_constructible_v>)
+  // any_cast returns non-null if __any->type() == typeid(T) and
+  // typeid(T) ignores cv-qualifiers so remove them:
+  using _Up = remove_cv_t<_Tp>;
+  // The contained value has a decayed type, so if decay_t is not U,
+  // then it's not possible to have a contained value of type U:
+  if constexpr (!is_same_v, _Up>)
+	return nullptr;
+  // Only copy constructible types can be used for contained values:
+  else if constexpr (!is_copy_constructible_v<_Up>)
+	return nullptr;
+  // This check is equivalent to __any->type() == typeid(_Tp)
+  else if (__any->_M_manager == ::_Manager<_Up>::_S_manage)
 	{
-	  if (__any->_M_manager == ::_Manager>::_S_manage)
-	{
-	  any::_Arg __arg;
-	  __any->_M_manager(any::_Op_access, __any, &__arg);
-	  return __arg._M_obj;
-	}
+	  any::_Arg __arg;
+	  __any->_M_manager(any::_Op_access, __any, &__arg);
+	  return __arg._M_obj;
 	}
   return nullptr;
 }
diff --git a/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc b/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc
index c9aeaae3366..b7fbbc5ee95 100644
--- a/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc
+++ b/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc
@@ -154,6 +154,22 @@ void test06()
   }
 }
 
+void test07()
+{
+  int arr[3];
+  any a(arr);
+  VERIFY( a.type() == typeid(int*) );	// contained value is decayed
+
+  int (*p1)[3] = any_cast();
+  VERIFY( a.type() != typeid(int[3]) ); // so any_cast should return nullptr
+  VERIFY( p1 == nullptr );
+  int (*p2)[] = any_cast();
+  VERIFY( a.type() != typeid(int[]) );	// so any_cast should return nullptr
+  VERIFY( p2 == nullptr );
+  const int (*p3)[] = any_cast(::as_const(a));
+  VERIFY( p3 == nullptr );
+}
+
 int main()
 {
   test01();
@@ -162,4 +178,5 @@ int main()
   test04();
   test05();
   test06();
+  test07();
 }


Re: [PATCH, netbsd] Define TARGET_D_CRITSEC_SIZE for D language

2019-04-24 Thread Iain Buclaw
On Wed, 24 Apr 2019 at 13:03, Kamil Rytarowski  wrote:
>
> On 24.04.2019 03:30, Iain Buclaw wrote:
> > On Wed, 24 Apr 2019 at 01:56, Kamil Rytarowski  wrote:
> >>
> >> On 24.04.2019 01:13, Iain Buclaw wrote:
> >>> Hi,
> >>>
> >>> This patch adds missing implementation of TARGET_D_CRITSEC_SIZE, which
> >>> would be noticed when using any bare synchronized statements.
> >>>
> >>> I couldn't see any target-specific alternatives of pthread_mutex_t in
> >>> netbsd headers, so the condition should be right.
> >>>
> >>> OK for trunk?
> >>>
> >>
> >> This patch is wrong.
> >>
> >> sizeof(pthread_mutex_t) depends on CPU.
> >>
> >> Just check that __cpu_simple_lock_nv_t that can be char, int, struct.
> >>
> >
> > Ah, thanks for pointing to that.  I've made a small working example,
> > and it looks like only three have a different size, aarch64, hppa, and
> > hppa64.
> >
> > https://explore.dgnu.org/z/U29cni
> >
> > I'll add special handling for them, but otherwise 48/28 looks like the
> > reasonable default.
> >
>
> I recommend to solve it differently: autodetect the size during
> ./configure. I'm not sure that it is still correct.
>

That would not work when building crosses.

> The sizes can also change over time. There is coming refactoring of
> libpthread(3) in NetBSD that can change sizes of these types, at least
> on some platforms.
>

Maybe explaining the intended use better might help.  This is only for
the following lowering done in the front-end (my upstream):

synchronized { var = 0; }

Loosely converted into equivalent C.

static char __critsec64[48];
_d_criticalenter(& __critsec64);
var = 0;
_d_criticalexit(& __critsec64);

So long as the statically allocated pthread_mutex_t is big enough,
there should be no problems.

-- 
Iain


Re: [PATCH, libphobos] Committed added AArch64 Linux as a supported target.

2019-04-24 Thread Iain Buclaw
On Wed, 24 Apr 2019 at 09:33, Andreas Schwab  wrote:
>
> On Apr 24 2019, Iain Buclaw  wrote:
>
> > This patch adds arch64*-*-linux* as a supported libphobos target,
> > something that has been passing the testsuite for a while now.
> >
> > Committed to trunk as r270524.
>
> That breaks -mabi=ilp32:
>
> /opt/gcc/gcc-20190424/libphobos/libdruntime/core/sys/posix/sys/stat.d:713:13: 
> error: static assert  (104u == 128u) is false
>   713 | static assert(stat_t.sizeof == 128);
>   | ^
> make[8]: *** [Makefile:2047: core/sys/posix/fcntl.lo] Error 1
>

Confirmed, I've sent fix to upstream and committed as r270541.

Tested this on aarch64-linux-gnu, though as I don't have ilp32
libraries on my arm64 phone, I can only see that all modules compile
down to object code.

-- 
Iain
---
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 27dfc5fc1d9..9fe51fd5ae9 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-b43203a134fb5e259ffc1711cc061c6e869b56f6
+513652173d6f02206be3ddaa2b6ed0b191ea4e3d
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d
index ab1fcd7b164..963a241f076 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/stat.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d
@@ -709,10 +709,10 @@ version (CRuntime_Glibc)
 }
 int[2] __unused;
 }
-static if (__USE_FILE_OFFSET64)
+version (D_LP64)
 static assert(stat_t.sizeof == 128);
 else
-static assert(stat_t.sizeof == 128);
+static assert(stat_t.sizeof == 104);
 }
 else version (SPARC64)
 {


Re: [PATCH, netbsd] Define TARGET_D_CRITSEC_SIZE for D language

2019-04-24 Thread Kamil Rytarowski
On 24.04.2019 03:30, Iain Buclaw wrote:
> On Wed, 24 Apr 2019 at 01:56, Kamil Rytarowski  wrote:
>>
>> On 24.04.2019 01:13, Iain Buclaw wrote:
>>> Hi,
>>>
>>> This patch adds missing implementation of TARGET_D_CRITSEC_SIZE, which
>>> would be noticed when using any bare synchronized statements.
>>>
>>> I couldn't see any target-specific alternatives of pthread_mutex_t in
>>> netbsd headers, so the condition should be right.
>>>
>>> OK for trunk?
>>>
>>
>> This patch is wrong.
>>
>> sizeof(pthread_mutex_t) depends on CPU.
>>
>> Just check that __cpu_simple_lock_nv_t that can be char, int, struct.
>>
> 
> Ah, thanks for pointing to that.  I've made a small working example,
> and it looks like only three have a different size, aarch64, hppa, and
> hppa64.
> 
> https://explore.dgnu.org/z/U29cni
> 
> I'll add special handling for them, but otherwise 48/28 looks like the
> reasonable default.
> 

I recommend to solve it differently: autodetect the size during
./configure. I'm not sure that it is still correct.

The sizes can also change over time. There is coming refactoring of
libpthread(3) in NetBSD that can change sizes of these types, at least
on some platforms.



signature.asc
Description: OpenPGP digital signature


Re: [RFA][tree-optimization/90037] Cleanup const/copies between DOM and erroneous path isolation

2019-04-24 Thread Richard Biener
On Tue, Apr 23, 2019 at 4:29 PM Jeff Law  wrote:
>
>
> As discussed in the BZ, this patch addresses the false positive warning
> by cleaning up the const/copy propagations left in the IL between DOM's
> jump threading and erroneous path isolation.
>
> In the past we'd been handling this stuff with phi only cprop.  To make
> phi only cprop work in this case we'd have to change it to scan
> statements within some subset of blocks where it had previously only
> scanned PHIs.
>
> I was concerned about the compile-time cost of the additional scanning
> plus the extra pass.  So I compared that against using the lattice based
> const/copy propagation as well as against the RPO VN bits.
>
> It turns out that the lattice based const/copy propagation does the
> least amount of work, closely followed by a limited RPO VN.  The
> improved "phi only" copy propagator being the worst.

Interesting.

> Given that we can use the lattice copy propagator by just adding the
> pass to passes.def whereas using the RPN VN actually requires a little
> bit of real code (to set up the entry/exits for the relevant SEME
> regions), I went with the lattice copy propagator.
>
> This change adds around .4% instruction executions to my testbed of .i
> files.  It has no significant impact on the resulting code -- I see
> different register allocation decisions in a lot of places which seem to
> primarily result in reversing arguments to comparisons.

Was there a need to have two copy-prop passes in the early
DOM/errorneous-path removal where we previously only had
a single phi-only-prop pass?  Is the testcase fixed also when
doing copy-prop only a single time?

Also the late pass you replace should be right after VRP, not
after warn_restrict (that was a mistake done when adding the
warn_restrict pass).

The main reason I dislike this is that it is an unconditional cleanup
pass run even when we didn't perform any jump threading.  That's
of course the same case as with the existing phi-only-prop passes
but would have been my major argument for the SEME VN
(where at some cut-off of course doing a single whole-function VN
is cheaper than doing N SEME VNs, and I can even think of doing
N SEME regions at once in exchange for doing a whole-function
RPO order compute).

> FWIW I also considered delaying the erroneous path isolation pass.  I
> ultimately decided against that.  My recollection is that its location
> came from the desire to clean up those paths early enough in the
> pipeline so that other optimizers could do a better job.
>
> We could consider an early/late split here.  Essentially we do the
> optimization early, leaving enough data lying around somewhere for a
> late pass to look for and issue the warning.  Something like a
> __builtin_warning that we leave in the IL, then just before expanding to
> RTL, we scan the IL once and issue the __builtin_warnings.
>
> In this specific case the __builtin_warning would be on a path that we
> eventually would determine was unreachable at compile time and the path
> would be removed.  I suspect we could do something similar for other
> warnings coming out of the middle end.
>
> Anyway, this has been bootstrapped and regression tested on x86_64,
> ppc64, i686, sparc64, & ppc64le.  It's also been bootstrapped on alpha,
> ppc (32 bit), armeb, m68k, riscv64, mipsisa32r4, arm, sh4, & sh4eb.
> It's also built and regression tested all the *-elf targets in my tester.
>
> OK for the trunk, or do we want to defer to gcc-10?

I like the pass removal and would say OK if you manage with
a 1:1 replacement (thus get rid of that extra copy-prop between
DOM and pass_isolate_erroneous_paths).

Richard.

>
> Jeff
>
>
>


Re: Add commentary to (SET_)TYPE_VECTOR_SUBPARTS

2019-04-24 Thread Richard Biener
On Tue, Apr 23, 2019 at 10:25 AM Richard Sandiford
 wrote:
>
> This patch explains the encoding used for the precision field in
> TYPE_VECTOR_SUBPARTS when NUM_POLY_INT_COEFFS == 2.  OK to install?

OK.

Richard.

> Richard
>
>
> 2019-04-19  Richard Sandiford  
>
> gcc/
> * tree.h (TYPE_VECTOR_SUBPARTS, SET_TYPE_VECTOR_SUBPARTS): Add
> commentary about the encoding of precision.
>
> Index: gcc/tree.h
> ===
> --- gcc/tree.h  2019-04-23 09:21:46.206208219 +0100
> +++ gcc/tree.h  2019-04-23 09:21:58.898166354 +0100
> @@ -3734,6 +3734,8 @@ TYPE_VECTOR_SUBPARTS (const_tree node)
>unsigned int precision = VECTOR_TYPE_CHECK (node)->type_common.precision;
>if (NUM_POLY_INT_COEFFS == 2)
>  {
> +  /* See the corresponding code in SET_TYPE_VECTOR_SUBPARTS for a
> +description of the encoding.  */
>poly_uint64 res = 0;
>res.coeffs[0] = HOST_WIDE_INT_1U << (precision & 0xff);
>if (precision & 0x100)
> @@ -3756,6 +3758,21 @@ SET_TYPE_VECTOR_SUBPARTS (tree node, pol
>gcc_assert (index >= 0);
>if (NUM_POLY_INT_COEFFS == 2)
>  {
> +  /* We have two coefficients that are each in the range 1 << [0, 63],
> +so supporting all combinations would require 6 bits per coefficient
> +and 12 bits in total.  Since the precision field is only 10 bits
> +in size, we need to be more restrictive than that.
> +
> +At present, coeff[1] is always either 0 (meaning that the number
> +of units is constant) or equal to coeff[0] (meaning that the number
> +of units is N + X * N for some target-dependent zero-based runtime
> +parameter X).  We can therefore encode coeff[1] in a single bit.
> +
> +The most compact encoding would be to use mask 0x3f for coeff[0]
> +and 0x40 for coeff[1], leaving 0x380 unused.  It's possible to
> +get slightly more efficient code on some hosts if we instead
> +treat the shift amount as an independent byte, so here we use
> +0xff for coeff[0] and 0x100 for coeff[1].  */
>unsigned HOST_WIDE_INT coeff1 = subparts.coeffs[1];
>gcc_assert (coeff1 == 0 || coeff1 == coeff0);
>VECTOR_TYPE_CHECK (node)->type_common.precision


Re: Adding noexcept-specification on tuple constructors (LWG 2899)

2019-04-24 Thread Nina Dinka Ranns
On Tue, 23 Apr 2019 at 21:28, Jonathan Wakely  wrote:
>
> On 23/04/19 18:43 +0100, Nina Dinka Ranns wrote:
> >On Thu, 18 Apr 2019 at 21:35, Jonathan Wakely  wrote:
> >>
> >> On 16/04/19 17:59 +0100, Nina Dinka Ranns wrote:
> >> >On Tue, 16 Apr 2019 at 15:18, Jonathan Wakely  wrote:
> >> >>
> >> >> On 16/04/19 14:08 +0100, Nina Dinka Ranns wrote:
> >> >> >Tested on Linux-PPC64
> >> >> >Adding noexcept-specification on tuple constructors (LWG 2899)
> >> >>
> >> >> Thanks, Nina!
> >> >>
> >> >> This looks great, although as I think Ville has explained we won't
> >> >> commit it until the next stage 1, after the GCC 9 release.
> >> >ack
> >> >
> >> >>
> >> >> The changes look good, I just have some mostly-stylistic comments,
> >> >> which are inline below ...
> >> >>
> >> >>
> >> >> >2019-04-13 Nina Dinka Ranns 
> >> >> >
> >> >> >Adding noexcept-specification on tuple constructors (LWG 2899)
> >> >> >* libstdc++-v3/include/std/tuple:
> >> >> >(tuple()): Add noexcept-specification.
> >> >> >(tuple(const _Elements&...)): Likewise
> >> >> >(tuple(_UElements&&...)): Likewise
> >> >> >(tuple(const tuple<_UElements...>&)): Likewise
> >> >> >(tuple(tuple<_UElements...>&&)): Likewise
> >> >> >(tuple(const _T1&, const _T2&)): Likewise
> >> >> >(tuple(_U1&&, _U2&&)): Likewise
> >> >> >(tuple(const tuple<_U1, _U2>&): Likewise
> >> >> >(tuple(tuple<_U1, _U2>&&): Likewise
> >> >> >(tuple(const pair<_U1, _U2>&): Likewise
> >> >> >(tuple(pair<_U1, _U2>&&): Likewise
> >> >> >
> >> >> >
> >> >>
> >> >> There should be no blank lines in the changelog entry here. A single
> >> >> change should be recorded as a single block in the changelog, with no
> >> >> blank lines within it.
> >> >ack. Do you need me to do anything about this or is it for future
> >> >reference only ?
> >>
> >> For future reference. Whoever commits the patch can correct the
> >> changelog.
> >>
> >> >>
> >> >> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc: 
> >> >> > New
> >> >> >* 
> >> >> > libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs2.cc: New
> >> >> >* 
> >> >> > libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs3.cc: New
> >> >> >* 
> >> >> > libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs4.cc: New
> >> >> >* 
> >> >> > libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs5.cc: New
> >> >> >* 
> >> >> > libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs6.cc: New
> >> >>
> >> >> This is a lot of new test files for a small-ish QoI feature. Could
> >> >> they be combined into one file?  Generally we do want one test file
> >> >> per feature, but I think all of these are arguably testing one feature
> >> >> (just on different constructors). The downside of lots of smaller
> >> >> files is that we have to compile+assemble+link+run each one, which
> >> >> adds several fork()s to launch a new process for each step. On some
> >> >> platforms that can be quite slow.
> >> >I can do that, but there may be an issue. See below.
> >> >
> >> >>
> >> >>
> >> >> >@@ -624,6 +634,7 @@
> >> >> >   && (sizeof...(_Elements) >= 1),
> >> >> > bool>::type=true>
> >> >> > constexpr tuple(_UElements&&... __elements)
> >> >> >+
> >> >> >noexcept(__and_...>::value)
> >> >>
> >> >> Can this be __nothrow_constructible<_UElements>() ?
> >> >It should have been that in the first place. Apologies. Fixed.
> >> >
> >> >
> >> >>
> >> >> > : _Inherited(std::forward<_UElements>(__elements)...) { }
> >> >> >
> >> >> >   template >> >> >@@ -635,6 +646,7 @@
> >> >> >   && (sizeof...(_Elements) >= 1),
> >> >> > bool>::type=false>
> >> >> > explicit constexpr tuple(_UElements&&... __elements)
> >> >> >+noexcept(__nothrow_constructible<_UElements&&...>())
> >> >>
> >> >> The && here is redundant, though harmless.
> >> >>
> >> >> is_constructible is exactly equivalent to is_constructible
> >> >> because U means construction from an rvalue of type U and so does U&&.
> >> >>
> >> >> It's fine to leave the && there though.
> >> >I'm happy to go either way. The only reason I used && form is because
> >> >it mimics the wording in the LWG resolution.
> >>
> >> I suspect if STL had reviewed the wording in the resolution he'd have
> >> asked for the && to be removed :-)
> >:) ack. Removed.
> >
> >
> >>
> >>
> >> >> >@@ -966,6 +995,7 @@
> >> >> > && !is_same<__remove_cvref_t<_U1>, 
> >> >> > allocator_arg_t>::value,
> >> >> >   bool>::type = true>
> >> >> > constexpr tuple(_U1&& __a1, _U2&& __a2)
> >> >> >+noexcept(__nothrow_constructible<_U1&&,_U2&&>())
> >> >>
> >> >> There should be a space after the comma here, and all the later
> >> >> additions in the file.
> >> >ack. Fixed
> >> >
> >> >>
> >> >>
> >> >> >Index: libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc
> 

[PATCH] [ARC][COMMITTED] Fix typos.

2019-04-24 Thread Claudiu Zissulescu
From: claziss 

gcc/
-xx-xx  Claudiu Zissulescu  

* config/arc/arc-options.def: Fix typos and spelling mistakes.
* config/arc/arc.c (arc_init): Cleanup warning message.
(arc_override_options): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270540 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog  |  6 ++
 gcc/config/arc/arc-options.def | 12 ++--
 gcc/config/arc/arc.c   | 18 ++
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ba06d65583c..1c70df7ce96 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-04-24  Claudiu Zissulescu  
+
+   * config/arc/arc-options.def: Fix typos and spelling mistakes.
+   * config/arc/arc.c (arc_init): Cleanup warning message.
+   (arc_override_options): Likewise.
+
 2019-04-24  Jakub Jelinek  
 
PR target/90187
diff --git a/gcc/config/arc/arc-options.def b/gcc/config/arc/arc-options.def
index a521b6f9b4e..4b2dcb16e6c 100644
--- a/gcc/config/arc/arc-options.def
+++ b/gcc/config/arc/arc-options.def
@@ -68,9 +68,9 @@ ARC_OPT (FL_SWAP, (1ULL << 7), MASK_SWAP_SET,
"swap")
 ARC_OPT (FL_MUL64,(1ULL << 8), MASK_MUL64_SET,"mul64")
 ARC_OPT (FL_MUL32x16, (1ULL << 9), MASK_MULMAC_32BY16_SET, "mul32x16")
 
-ARC_OPT (FL_EA,  (1ULL << 11), MASK_EA_SET,   "extended 
arithmetics")
-ARC_OPT (FL_SPFP, (1ULL << 12), MASK_SPFP_COMPACT_SET, "single precission 
FPX")
-ARC_OPT (FL_DPFP, (1ULL << 13), MASK_DPFP_COMPACT_SET, "double precission 
FPX")
+ARC_OPT (FL_EA,  (1ULL << 11), MASK_EA_SET,   "extended 
arithmetic")
+ARC_OPT (FL_SPFP, (1ULL << 12), MASK_SPFP_COMPACT_SET, "single precision 
FPX")
+ARC_OPT (FL_DPFP, (1ULL << 13), MASK_DPFP_COMPACT_SET, "double precision 
FPX")
 ARC_OPT (FL_ARGONAUT, (1ULL << 14), MASK_ARGONAUT_SET,"argonaut")
 ARC_OPT (FL_SIMD, (1ULL << 15), MASK_SIMD_SET,"simd")
 
@@ -101,9 +101,9 @@ ARC_OPTX (FL_FPU_FPUD_FMA,  (1ULL << 36), arc_fpu_build, 
FPU_FPUD_FMA,  "mfpu", "
 ARC_OPTX (FL_FPU_FPUD_ALL,  (1ULL << 37), arc_fpu_build, FPU_FPUD_ALL, "mfpu", 
"fpud_all")
 ARC_OPTX (FL_FPX_QUARK,(1ULL << 38), arc_fpu_build, FPX_QK,
"quarkse fp", "N.A.")
 
-ARC_OPT (FL_FPUS,  (0xFULL << 26), 0, "single precission floating point")
-ARC_OPT (FL_FPUDA, (0xFFULL << 26), 0, "double precission fp assist")
-ARC_OPT (FL_FPUD,  (0xF0FULL << 26), 0, "double precission floating point")
+ARC_OPT (FL_FPUS,  (0xFULL << 26), 0, "single precision floating point")
+ARC_OPT (FL_FPUDA, (0xFFULL << 26), 0, "double precision fp assist")
+ARC_OPT (FL_FPUD,  (0xF0FULL << 26), 0, "double precision floating point")
 ARC_OPT (FL_QUARK, (1ULL << 38), 0, "Quark SE fp extension")
 
 /* Local Variables: */
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 1a04f9ef793..2f5753b02fa 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -955,8 +955,7 @@ arc_init (void)
   /* Warn for unimplemented PIC in pre-ARC700 cores, and disable flag_pic.  */
   if (flag_pic && TARGET_ARC600_FAMILY)
 {
-  warning (0,
-  "PIC is not supported for %s.  Generating non-PIC code only",
+  warning (0, "PIC is not supported for %qs",
   arc_cpu_string);
   flag_pic = 0;
 }
@@ -1218,30 +1217,33 @@ arc_override_options (void)
  option is not allowed.  Extra, check options against default
  architecture/cpu flags and throw an warning if we find a
  mismatch.  */
+  /* TRANSLATORS: the DOC/DOC0/DOC1 are strings which shouldn't be
+ translated.  They are like keywords which one can relate with the
+ architectural choices taken for an ARC CPU implementation.  */
 #define ARC_OPTX(NAME, CODE, VAR, VAL, DOC0, DOC1) \
   do { \
 if ((!(arc_selected_cpu->arch_info->flags & CODE)) \
&& (VAR == VAL))\
-  error ("option %s=%s is not available for %s CPU",   \
+  error ("option %<%s=%s%> is not available for %qs CPU",  \
 DOC0, DOC1, arc_selected_cpu->name);   \
 if ((arc_selected_cpu->arch_info->dflags & CODE)   \
&& (VAR != DEFAULT_##VAR)   \
&& (VAR != VAL))\
-  warning (0, "option %s is ignored, the default value %s" \
-  " is considered for %s CPU", DOC0, DOC1, \
+  warning (0, "option %qs is ignored, the default value %qs"   \
+  " is considered for %qs CPU", DOC0, DOC1,\
   arc_selected_cpu->name); \
  } while (0);
 #define ARC_OPT(NAME, CODE, MASK, DOC) \
   do { \
 if ((!(arc_selected_cpu->arch_info->flags & CODE))

[PATCH] PR libstdc++/90220 Fix std::any_cast for function pointers

2019-04-24 Thread Jonathan Wakely

PR libstdc++/90220 (partial)
* include/std/any (any_cast(any*), any_cast(const any*)): Do
not attempt ill-formed static_cast to pointers to non-object types.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
function types.

Tested powerpc64le-linux, committed to trunk.

The PR describes two bugs in any_cast, but I might leave the fix for
the other part until stage 1.

commit 1da13522c390bcb2bf70348656116a4d034aa9a6
Author: Jonathan Wakely 
Date:   Wed Apr 24 10:05:30 2019 +0100

PR libstdc++/90220 Fix std::any_cast for function pointers

PR libstdc++/90220 (partial)
* include/std/any (any_cast(any*), any_cast(const any*)): Do
not attempt ill-formed static_cast to pointers to non-object types.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
function types.

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index b0553dccf22..792db27b061 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -532,16 +532,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 inline const _ValueType* any_cast(const any* __any) noexcept
 {
-  if (__any)
-   return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
+  if constexpr (is_object_v<_ValueType>)
+   if (__any)
+ return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
   return nullptr;
 }
 
   template
 inline _ValueType* any_cast(any* __any) noexcept
 {
-  if (__any)
-   return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
+  if constexpr (is_object_v<_ValueType>)
+   if (__any)
+ return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
   return nullptr;
 }
   // @}
diff --git a/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc 
b/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc
index 8f19dc3ae0b..c9aeaae3366 100644
--- a/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc
+++ b/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc
@@ -20,6 +20,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -121,6 +122,38 @@ void test05()
   VERIFY( p == nullptr );
 }
 
+void test06()
+{
+  // The contained value of a std::any is always an object type,
+  // but std::any_cast does not forbid checking for function types.
+
+  any a(1);
+  void (*p1)() = any_cast();
+  VERIFY( p1 == nullptr );
+  int (*p2)(int) = any_cast();
+  VERIFY( p2 == nullptr );
+  int (*p3)() = any_cast(::as_const(a));
+  VERIFY( p3 == nullptr );
+
+  try {
+any_cast(a);
+VERIFY( false );
+  } catch (const std::bad_any_cast&) {
+  }
+
+  try {
+any_cast(std::move(a));
+VERIFY( false );
+  } catch (const std::bad_any_cast&) {
+  }
+
+  try {
+any_cast(std::as_const(a));
+VERIFY( false );
+  } catch (const std::bad_any_cast&) {
+  }
+}
+
 int main()
 {
   test01();
@@ -128,4 +161,5 @@ int main()
   test03();
   test04();
   test05();
+  test06();
 }


Patch ping (was Re: [PATCH] Don't ignore leading whitespace in AArch64 target attribute/pragma (PR target/89093))

2019-04-24 Thread Jakub Jelinek
Hi!

On Tue, Apr 16, 2019 at 08:32:50PM +0200, Jakub Jelinek wrote:
> 2019-04-16  Jakub Jelinek  
> 
>   PR target/89093
>   * config/aarch64/aarch64.c (aarch64_process_one_target_attr): Don't skip
>   whitespace at the start of target attribute string.
> 
>   * gcc.target/aarch64/pr89093.c: New test.
>   * gcc.target/aarch64/pr63304_1.c: Remove space from target string.

I'd like to ping this patch.
Thanks.

> --- gcc/config/aarch64/aarch64.c.jj   2019-04-11 10:26:22.907293129 +0200
> +++ gcc/config/aarch64/aarch64.c  2019-04-15 19:59:55.784226278 +0200
> @@ -12536,10 +12536,6 @@ aarch64_process_one_target_attr (char *a
>char *str_to_check = (char *) alloca (len + 1);
>strcpy (str_to_check, arg_str);
>  
> -  /* Skip leading whitespace.  */
> -  while (*str_to_check == ' ' || *str_to_check == '\t')
> -str_to_check++;
> -
>/* We have something like __attribute__ ((target ("+fp+nosimd"))).
>   It is easier to detect and handle it explicitly here rather than going
>   through the machinery for the rest of the target attributes in this
> --- gcc/testsuite/gcc.target/aarch64/pr89093.c.jj 2019-04-15 
> 20:02:25.456788897 +0200
> +++ gcc/testsuite/gcc.target/aarch64/pr89093.c2019-04-15 
> 20:02:04.433131260 +0200
> @@ -0,0 +1,7 @@
> +/* PR target/89093 */
> +/* { dg-do compile } */
> +
> +__attribute__((target ("  no-strict-align"))) void f1 (void) {} /* { 
> dg-error "is not valid" } */
> +__attribute__((target (" general-regs-only"))) void f2 (void) {} /* { 
> dg-error "is not valid" } */
> +#pragma GCC target ("general-regs-only") /* { dg-error "is not valid" } 
> */
> +void f3 (void) {}
> --- gcc/testsuite/gcc.target/aarch64/pr63304_1.c.jj   2017-09-13 
> 16:22:19.795513580 +0200
> +++ gcc/testsuite/gcc.target/aarch64/pr63304_1.c  2019-04-15 
> 20:27:17.724847578 +0200
> @@ -1,7 +1,7 @@
>  /* { dg-do assemble } */
>  /* { dg-options "-O1 --save-temps" } */
>  #pragma GCC push_options
> -#pragma GCC target ("+nothing+simd, cmodel=small")
> +#pragma GCC target ("+nothing+simd,cmodel=small")
>  
>  int
>  cal (double a)

Jakub


Re: [PATCH] Fix ix86_expand_sse_fp_minmax (PR target/90187)

2019-04-24 Thread Uros Bizjak
On Wed, Apr 24, 2019 at 9:36 AM Jakub Jelinek  wrote:

> Hi!
>
> ix86_expand_sse_fp_minmax bypasses the expanders and so might end up with
> both if_true and if_false being a MEM, which violates the condition of the
> insn it wants to match.
>
> The following patch makes sure at most one of the operands is a MEM.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2019-04-24  Jakub Jelinek  
>
> PR target/90187
> * config/i386/i386.c (ix86_expand_sse_fp_minmax): Force if_true
> into
> a register if both if_true and if_false are MEMs.
>
> * g++.target/i386/pr90187.C: New test.
>

OK.

Thanks,
Uros.

--- gcc/config/i386/i386.c.jj   2019-04-16 10:40:15.077091789 +0200
> +++ gcc/config/i386/i386.c  2019-04-23 11:42:32.088334896 +0200
> @@ -23712,6 +23712,8 @@ ix86_expand_sse_fp_minmax (rtx dest, enu
>else
>  {
>code = is_min ? SMIN : SMAX;
> +  if (MEM_P (if_true) && MEM_P (if_false))
> +   if_true = force_reg (mode, if_true);
>tmp = gen_rtx_fmt_ee (code, mode, if_true, if_false);
>  }
>
> --- gcc/testsuite/g++.target/i386/pr90187.C.jj  2019-04-23
> 11:42:51.175025002 +0200
> +++ gcc/testsuite/g++.target/i386/pr90187.C 2019-04-23
> 11:41:56.405914260 +0200
> @@ -0,0 +1,15 @@
> +// PR target/90187
> +// { dg-do compile }
> +// { dg-options "-Ofast -ffloat-store" }
> +
> +double a[64];
> +double *foo (void);
> +
> +void
> +bar (int x, const double *y)
> +{
> +  int i;
> +  for (i = 0; i < x; i++)
> +if (y[i] < a[i])
> +  a[i] = y[i];
> +}
>
> Jakub
>


Re: [PATCH, RFC, rs6000] PR80791 Consider doloop in ivopts

2019-04-24 Thread Kewen.Lin
Thanks for catching, Jakub! 

The update listed below, will integrate it with next revision patch.

gcc/ChangeLog

2019-04-24  Kewen Lin  

PR middle-end/80791
* target.def (predict_doloop_p): New hook.
* targhooks.h (default_predict_doloop_p): New declaration.
* targhooks.c (default_predict_doloop_p): New function.
* doc/tm.texi.in (TARGET_PREDICT_DOLOOP_P): New hook.
* doc/tm.texi: Regenerate.
* config/rs6000/rs6000.c (invalid_insn_for_doloop_p): New function.
(costly_iter_for_doloop_p): Likewise.
(rs6000_predict_doloop_p): Likewise.
(TARGET_PREDICT_DOLOOP_P): New macro.
* expr.c (produce_memory_decl_rtl): New function.
(prepare_decl_rtl): Likewise.
* expr.h (produce_memory_decl_rtl): New declaration.
(prepare_decl_rtl): Likewise.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize_loop): Call
predict_doloop_p hook.
(tailor_cmp_uses): New function.
(preserve_ivs_for_use): New function.
(computation_cost): Call refactored prepare_decl_rtl, consider
zero cost iv use.
(dump_use): Dump zero_cost_p field.
(record_use): Init zero_cost_p field.
(produce_memory_decl_rtl): Remove.
(prepare_decl_rtl): Remove.

gcc/testsuite/ChangeLog

2019-04-24  Kewen Lin  

PR middle-end/80791
* gcc.dg/tree-ssa/ivopts-lt.c : Adjust.


on 2019/4/24 下午4:48, Jakub Jelinek wrote:
> On Wed, Apr 24, 2019 at 04:41:01PM +0800, Kewen.Lin wrote:
>> gcc/ChangeLog
> 
> Not a review, just ChangeLog nits.
> 
>> 2019-04-24  Kewen Lin  
>>
>>  PR middle-end/80791
>>  * target.def (predict_doloop_p): New.
>>  * targhooks.h (default_predict_doloop_p): New.
>>  * targhooks.c (default_predict_doloop_p): Likewise.
>>  * doc/tm.texi.in (TARGET_PREDICT_DOLOOP_P): New.
>>  * doc/tm.texi: Regenerate.
>>  * config/rs6000/rs6000.c (invalid_insn_for_doloop_p): New.
>>(costly_iter_for_doloop_p): New.
>>(rs6000_predict_doloop_p): New.
> 
> There should be no leading spaces after the tab on the lines that don't 
> contain
> a filename, so:
>   * config/rs6000/rs6000.c (invalid_insn_for_doloop_p): New.
>   (costly_iter_for_doloop_p): New.
>   (rs6000_predict_doloop_p): New.
> instead (and instead of saying just New. usually we write what kind of
> new thing it is, so New function., New declaration. (or Declare.), New
> macro. (or Define.), New method. etc.
> 
>>  * gcc/expr.c (produce_memory_decl_rtl): New.
> 
> The gcc/ prefixes don't belong into gcc/ChangeLog, the filenames are always
> relative to the ChangeLog file referencing those.
> 
>   Jakub
> 



Re: [RFC] D support for S/390

2019-04-24 Thread Iain Buclaw
On Wed, 24 Apr 2019 at 10:05, Robin Dapp  wrote:
>
> Hi,
>
> the attached patch is against the current HEAD, fixing one additional
> test case.
>

Thanks, this has been committed.

> Parallel testing does not seem to work anymore.  Adding the following
> define for ${PWD_COMMAND} makes it work again.
>
>

Looks OK to me, I guess r270303 would be the introducer of what you're seeing.

This would be the complete patch for that.

libphobos/ChangeLog:

   * testsuite/Makefile.am: Set PWD_COMMAND.
   * testsuite/Makefile.in: Regenerate.

diff --git a/libphobos/testsuite/Makefile.am b/libphobos/testsuite/Makefile.am
index 55b2ba42640..70b105d4014 100644
--- a/libphobos/testsuite/Makefile.am
+++ b/libphobos/testsuite/Makefile.am
@@ -27,6 +27,8 @@ _RUNTEST = $(shell if test -f
$(top_srcdir)/../dejagnu/runtest; then \
 echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
 RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir

+PWD_COMMAND = $${PWDCMD-pwd}
+
 check_p_subno=$(word 2,$(subst _, ,$*))
 check_p_numbers0:=1 2 3 4 5 6 7 8 9
 check_p_numbers1:=0 $(check_p_numbers0)
diff --git a/libphobos/testsuite/Makefile.in b/libphobos/testsuite/Makefile.in
index 26ed875d964..efbd884d7ae 100644
--- a/libphobos/testsuite/Makefile.in
+++ b/libphobos/testsuite/Makefile.in
@@ -289,6 +289,7 @@ _RUNTEST = $(shell if test -f
$(top_srcdir)/../dejagnu/runtest; then \
 echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)

 RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
+PWD_COMMAND = $${PWDCMD-pwd}
 check_p_subno = $(word 2,$(subst _, ,$*))
 check_p_numbers0 := 1 2 3 4 5 6 7 8 9
 check_p_numbers1 := 0 $(check_p_numbers0)


Re: [PATCH] [ARC][COMMITTED] Fix diagnostic messages.

2019-04-24 Thread Claudiu Zissulescu
The DOC/DOC0/DOC1 are like keywords to be placed into the warning
message. They shouldn't be translated as they can referenced directly
in the specific processor architectural options. So, I will use %qs
for them, and fix the other signalized problems.
Thank you

On Wed, Apr 17, 2019 at 2:25 PM Jakub Jelinek  wrote:
>
> On Wed, Apr 17, 2019 at 02:09:33PM +0300, Claudiu Zissulescu wrote:
> >/* Warn for unimplemented PIC in pre-ARC700 cores, and disable flag_pic. 
> >  */
> >if (flag_pic && TARGET_ARC600_FAMILY)
> >  {
> >warning (0,
> > -"PIC is not supported for %s. Generating non-PIC code only..",
> > +"PIC is not supported for %s.  Generating non-PIC code only",
> >  arc_cpu_string);
>
> I believe this is undesirable too.  Either use something like
> "PIC is not supported for %s; generating non-PIC code only"
> or split that into two messages
> if (warning (0, "PIC is not supported for %s", arc_cpu_string))
>   inform (input_location, "generating non-PIC code only");
>
> > @@ -1222,26 +1222,26 @@ arc_override_options (void)
> >do {   \
> >  if ((!(arc_selected_cpu->arch_info->flags & CODE))   \
> >   && (VAR == VAL))\
> > -  error ("Option %s=%s is not available for %s CPU.",\
> > +  error ("option %s=%s is not available for %s CPU", \
> >DOC0, DOC1, arc_selected_cpu->name);   \
>
> I think another complaint in the PR was that it is unclear what
> those DOC0/DOC1/DOC strings stand for, if they are keywords on what
> one writes on the command line or similar (then it should be quoted,
> %qs or %<%s=%s%>), if it is something different, then maybe it is
> not the right thing to construct a translatable sentence from that
> error/warning gmsgid string and one or more words that are inserted
> somewhere into the sentence.  At least for the ARC_OPT the latter seems to
> be the case, given e.g.:
> ARC_OPT (FL_LL64, (1ULL << 5), MASK_LL64,  "double 
> load/store")
> ARC_OPT (FL_BS,   (1ULL << 6), MASK_BARREL_SHIFTER,"barrel shifter")
> Is barrel shifter a keyword, or just random words added into the sentence?
> If the latter, then the translators might want to translate that too, but in
> that case together with the surroundings too.
> ARC_OPT (FL_SPFP, (1ULL << 12), MASK_SPFP_COMPACT_SET, "single precission 
> FPX")
> ARC_OPT (FL_DPFP, (1ULL << 13), MASK_DPFP_COMPACT_SET, "double precission 
> FPX")
> has spelling errors,
> s/precission/precision/g
>
> >  if ((arc_selected_cpu->arch_info->dflags & CODE) \
> >   && (VAR != DEFAULT_##VAR)   \
> >   && (VAR != VAL))\
> > -  warning (0, "Option %s is ignored, the default value %s"   \
> > -" is considered for %s CPU.", DOC0, DOC1,\
> > +  warning (0, "option %s is ignored, the default value %s"   \
> > +" is considered for %s CPU", DOC0, DOC1, \
> >  arc_selected_cpu->name); \
> >   } while (0);
> >  #define ARC_OPT(NAME, CODE, MASK, DOC)   \
> >do {   \
> >  if ((!(arc_selected_cpu->arch_info->flags & CODE))   \
> >   && (target_flags & MASK))   \
> > -  error ("Option %s is not available for %s CPU",\
> > +  error ("option %s is not available for %s CPU",\
> >DOC, arc_selected_cpu->name);  \
> >  if ((arc_selected_cpu->arch_info->dflags & CODE) \
> >   && (target_flags_explicit & MASK)   \
> >   && (!(target_flags & MASK)))\
> > -  warning (0, "Unset option %s is ignored, it is always" \
> > -" enabled for %s CPU.", DOC, \
> > +  warning (0, "unset option %s is ignored, it is always" \
> > +" enabled for %s CPU", DOC,  \
> >  arc_selected_cpu->name); \
> >} while (0);
> >
> > @@ -7268,7 +7268,8 @@ check_if_valid_regno_const (rtx *operands, int opno)
> >  case CONST_INT :
> >return true;
> >  default:
> > - error ("register number must be a compile-time constant. Try giving 
> > higher optimization levels");
> > + error ("register number must be a compile-time constant.  "
> > +"Try giving higher optimization levels");
>
> Similarly to the above case.
>
> Jakub


Re: [PATCH, RFC, rs6000] PR80791 Consider doloop in ivopts

2019-04-24 Thread Jakub Jelinek
On Wed, Apr 24, 2019 at 04:41:01PM +0800, Kewen.Lin wrote:
> gcc/ChangeLog

Not a review, just ChangeLog nits.

> 2019-04-24  Kewen Lin  
> 
>   PR middle-end/80791
>   * target.def (predict_doloop_p): New.
>   * targhooks.h (default_predict_doloop_p): New.
>   * targhooks.c (default_predict_doloop_p): Likewise.
>   * doc/tm.texi.in (TARGET_PREDICT_DOLOOP_P): New.
>   * doc/tm.texi: Regenerate.
>   * config/rs6000/rs6000.c (invalid_insn_for_doloop_p): New.
> (costly_iter_for_doloop_p): New.
> (rs6000_predict_doloop_p): New.

There should be no leading spaces after the tab on the lines that don't contain
a filename, so:
* config/rs6000/rs6000.c (invalid_insn_for_doloop_p): New.
(costly_iter_for_doloop_p): New.
(rs6000_predict_doloop_p): New.
instead (and instead of saying just New. usually we write what kind of
new thing it is, so New function., New declaration. (or Declare.), New
macro. (or Define.), New method. etc.

>   * gcc/expr.c (produce_memory_decl_rtl): New.

The gcc/ prefixes don't belong into gcc/ChangeLog, the filenames are always
relative to the ChangeLog file referencing those.

Jakub


[PATCH, RFC, rs6000] PR80791 Consider doloop in ivopts

2019-04-24 Thread Kewen.Lin
Hi all,

As PR80791 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80791, on
some targets which support low-overhead loop, the related compare
type ivs use is possible to become dead and removed eventually.
However, the current ivopt cost modeling doesn't consider this
possible elimination, it leads suboptimal iv candidate decision.

To make it better, this patch is to introduce one target hook, to
provide target which supports low-overhead loop a way to teach
ivopt to know which compare type iv can be ignored in modeling.

Since the low-overhead loop optimize transformation is based on RTL,
some of those checks are hard to be imitated on gimple, so it's not
possible to predict the current loop will be transformed exactly
in middle-end.  But if we can have most loop predicted precisely,
it would be helpful.  It highly depends on target hook fine tuning.
It's acceptable to have some loops which can be transformed to low-
overhead loop but we don't catch.  But we should try our best to
avoid to predict some loop as low-overhead loop but which isn't.

Bootstrapped and regression testing on powerpc64le.

One failure was found in regression testing, which is:
  gcc.target/powerpc/20050830-1.c

I did some investigation and found: with this patch, one new iv cand
is chosen for exit condition, which is used to rewrite the compare
type use.  Later loop iv analysis in RTL can NOT determine the loop
iteration number is finite, which causes doloop_optimize not transform
the loop.  The check doesn't find the expected pattern.

Still investigating how to solve this failure, like either to enhance
loop iv analysis or to check some special condition and guard in ivopt.
Any suggestions are highly welcomed.

Btw, this is for GCC10.

-

gcc/ChangeLog

2019-04-24  Kewen Lin  

PR middle-end/80791
* target.def (predict_doloop_p): New.
* targhooks.h (default_predict_doloop_p): New.
* targhooks.c (default_predict_doloop_p): Likewise.
* doc/tm.texi.in (TARGET_PREDICT_DOLOOP_P): New.
* doc/tm.texi: Regenerate.
* config/rs6000/rs6000.c (invalid_insn_for_doloop_p): New.
  (costly_iter_for_doloop_p): New.
  (rs6000_predict_doloop_p): New.
* gcc/expr.c (produce_memory_decl_rtl): New.
  (prepare_decl_rtl): New.
* gcc/expr.h (produce_memory_decl_rtl): Declare.
  (prepare_decl_rtl): Declare.
* gcc/tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize_loop): Call
  predict_doloop_p hook.
  (tailor_cmp_uses): New.
  (preserve_ivs_for_use): New.
  (computation_cost): Call refactored prepare_decl_rtl, consider
  zero cost iv use.
  (dump_use): Dump zero_cost_p field.
  (record_use): Init zero_cost_p field.
  (produce_memory_decl_rtl): Remove.
  (prepare_decl_rtl): Remove.

gcc/testsuite/ChangeLog

2019-04-24  Kewen Lin  

PR middle-end/80791
* gcc.dg/tree-ssa/ivopts-lt.c : Adjust.

---
 gcc/config/rs6000/rs6000.c| 174 -
 gcc/doc/tm.texi   |   8 +
 gcc/doc/tm.texi.in|   2 +
 gcc/expr.c|  91 +++
 gcc/expr.h|  16 +-
 gcc/target.def|   9 ++
 gcc/targhooks.c   |  13 ++
 gcc/targhooks.h   |   1 +
 gcc/testsuite/gcc.dg/tree-ssa/ivopts-lt.c |   7 +-
 gcc/tree-ssa-loop-ivopts.c| 247 +++---
 10 files changed, 472 insertions(+), 96 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index a21f4f7..756f914 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -83,6 +83,9 @@
 #include "tree-ssa-propagate.h"
 #include "tree-vrp.h"
 #include "tree-ssanames.h"
+#include "tree-ssa-loop-niter.h"
+#include "tree-cfg.h"
+#include "tree-scalar-evolution.h"
 
 /* This file should be included last.  */
 #include "target-def.h"
@@ -1914,6 +1917,9 @@ static const struct attribute_spec 
rs6000_attribute_table[] =
 #undef TARGET_CAN_USE_DOLOOP_P
 #define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost
 
+#undef TARGET_PREDICT_DOLOOP_P
+#define TARGET_PREDICT_DOLOOP_P rs6000_predict_doloop_p
+
 #undef TARGET_ATOMIC_ASSIGN_EXPAND_FENV
 #define TARGET_ATOMIC_ASSIGN_EXPAND_FENV rs6000_atomic_assign_expand_fenv
 
@@ -39436,7 +39442,173 @@ rs6000_mangle_decl_assembler_name (tree decl, tree id)
   return id;
 }
 
-
+/* Check whether there are some instructions preventing doloop transformation
+   inside loop body, mainly for instructions which are possible to kill CTR.
+
+   Return true if some invalid insn exits, otherwise return false.  */
+
+static bool
+invalid_insn_for_doloop_p (struct loop *loop)
+{
+  basic_block *body = get_loop_body (loop);
+  unsigned num_nodes = loop->num_nodes;
+  gimple_stmt_iterator gsi;
+  

Re: [RFC] D support for S/390

2019-04-24 Thread Robin Dapp
Hi,

the attached patch is against the current HEAD, fixing one additional
test case.

Parallel testing does not seem to work anymore.  Adding the following
define for ${PWD_COMMAND} makes it work again.


diff --git a/libphobos/testsuite/Makefile.in
b/libphobos/testsuite/Makefile.in
index 26ed875d964..ae1cf83615e 100644
--- a/libphobos/testsuite/Makefile.in
+++ b/libphobos/testsuite/Makefile.in
@@ -303,6 +303,7 @@ check_DEJAGNU_libphobos_targets = $(addprefix
check-DEJAGNUlibphobos,$(check_p_s
 AM_MAKEFLAGS = "EXEEXT=$(EXEEXT)"
 CLEANFILES = *.exe *.log *.o *.sum site.exp
 all: all-am
+PWD_COMMAND = $${PWDCMD-pwd}

 .SUFFIXES:
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am
$(am__configure_deps)


Regards
 Robin

--

gcc/d/ChangeLog:

2019-04-24  Robin Dapp  

* typeinfo.cc (create_typeinfo): Set fields with proper length.

gcc/testsuite/ChangeLog:

2019-04-24  Robin Dapp  

* gdc.dg/runnable.d: Add Big Endian handling.
* gdc.dg/simd.d: Likewise.
* gdc.test/runnable/test42.d: Likewise.

libphobos/ChangeLog:

2019-04-24  Robin Dapp  

* configure.tgt: Add S390.
* libdruntime/gcc/sections/elf_shared.d: Add TLS handling for S390.
* testsuite/libphobos.typeinfo/struct-align.d: New test.
diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc
index dac66acdcd4..865fde2c863 100644
--- a/gcc/d/typeinfo.cc
+++ b/gcc/d/typeinfo.cc
@@ -830,7 +830,7 @@ public:
 	flags |= ClassFlags::noPointers;
 
 Lhaspointers:
-	this->layout_field (size_int (flags));
+	this->layout_field (build_integer_cst (flags, d_uint_type));
 
 	/* void *deallocator;  */
 	tree ddtor = (cd->aggDelete)
@@ -886,7 +886,7 @@ public:
 	if (cd->isCOMinterface ())
 	  flags |= ClassFlags::isCOMclass;
 
-	this->layout_field (size_int (flags));
+	this->layout_field (build_integer_cst (flags, d_uint_type));
 
 	/* void *deallocator;
 	   OffsetTypeInfo[] m_offTi;  (not implemented)
@@ -1019,7 +1019,7 @@ public:
 StructFlags::Type m_flags = 0;
 if (ti->hasPointers ())
   m_flags |= StructFlags::hasPointers;
-this->layout_field (size_int (m_flags));
+this->layout_field (build_integer_cst (m_flags, d_uint_type));
 
 /* void function(void*) xdtor;  */
 tree dtor = (sd->dtor) ? build_address (get_symbol_decl (sd->dtor))
@@ -1033,7 +1033,7 @@ public:
   this->layout_field (null_pointer_node);
 
 /* uint m_align;  */
-this->layout_field (size_int (ti->alignsize ()));
+this->layout_field (build_integer_cst (ti->alignsize (), d_uint_type));
 
 if (global.params.is64bit)
   {
@@ -1489,8 +1489,8 @@ create_typeinfo (Type *type, Module *mod)
   array_type_node, array_type_node,
   ptr_type_node, ptr_type_node,
   ptr_type_node, ptr_type_node,
-  size_type_node, ptr_type_node,
-  ptr_type_node, size_type_node,
+  d_uint_type, ptr_type_node,
+  ptr_type_node, d_uint_type,
   ptr_type_node, argtype, argtype, NULL);
 	}
 	  t->vtinfo = TypeInfoStructDeclaration::create (t);
diff --git a/gcc/testsuite/gdc.dg/runnable.d b/gcc/testsuite/gdc.dg/runnable.d
index e36a2585027..fc5fd14c7d9 100644
--- a/gcc/testsuite/gdc.dg/runnable.d
+++ b/gcc/testsuite/gdc.dg/runnable.d
@@ -890,12 +890,18 @@ struct S186
 }
 }
 
+static if (size_t.sizeof == 8)
+ size_t checkval = 0x0202;
+static if (size_t.sizeof == 4)
+ size_t checkval = 0x0202;
+
+
 void check186(in S186 obj, byte fieldB)
 {
 assert(obj.fieldA == 2);
 assert(obj.fieldB == 0);
 assert(obj.fieldC == 0);
-assert(obj._complete == 2);
+assert(obj._complete == checkval);
 assert(fieldB == 0);
 }
 
@@ -907,7 +913,7 @@ void test186a(size_t val)
 assert(obj.fieldA == 2);
 assert(obj.fieldB == 0);
 assert(obj.fieldC == 0);
-assert(obj._complete == 2);
+assert(obj._complete == checkval);
 
 obj = S186(val);
 check186(obj, obj.fieldB);
@@ -915,12 +921,12 @@ void test186a(size_t val)
 assert(obj.fieldA == 2);
 assert(obj.fieldB == 0);
 assert(obj.fieldC == 0);
-assert(obj._complete == 2);
+assert(obj._complete == checkval);
 }
 
 void test186()
 {
-test186a(2);
+test186a(checkval);
 }
 
 /**/
diff --git a/gcc/testsuite/gdc.dg/simd.d b/gcc/testsuite/gdc.dg/simd.d
index 812b36649aa..7d0aa0168c0 100644
--- a/gcc/testsuite/gdc.dg/simd.d
+++ b/gcc/testsuite/gdc.dg/simd.d
@@ -1576,7 +1576,10 @@ ubyte[16] foounsto()
 void testOPvecunsto()
 {
 auto a = foounsto();
-assert(a == [0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65]);
+version(LittleEndian)
+assert(a == [0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65]);
+version(BigEndian)
+assert(a == [65, 64, 0, 0, 65, 64, 0, 0, 65, 64, 0, 0, 65, 64, 0, 0]);
 }
 
 /*/
diff --git a/gcc/testsuite/gdc.test/runnable/test42.d b/gcc/testsuite/gdc.test/runnable/test42.d
index 

Re: [PATCH] FIx up GIMPLE bb removal (PR tree-optimization/90208)

2019-04-24 Thread Richard Biener
On April 24, 2019 10:02:00 AM GMT+02:00, Jakub Jelinek  wrote:
>Hi!
>
>The GIMPLE bb removal code doesn't really remove GIMPLE_LABEL
>stmts referencing FORCED_LABELs (and likewise non-local labels,
>except it turns them into FORCED_LABELs), but instead moves them
>at the start of some other bb.
>
>As can be seen on the testcases, that breaks
>  if (prev_stmt && EH_LANDING_PAD_NR (label) != 0)
>{
>  error ("EH landing pad label ");
>  print_generic_expr (stderr, label);
> fprintf (stderr, " is not first in a sequence of labels in bb %d",
>   bb->index);
>  err = 1;
>}
>checking and in theory could break
>  if (prev_stmt && DECL_NONLOCAL (label))
>{
>  error ("nonlocal label ");
>  print_generic_expr (stderr, label);
> fprintf (stderr, " is not first in a sequence of labels in bb %d",
>   bb->index);
>  err = 1;
>}
>too.  Fixed by moving these FORCED_LABELs after the existing labels
>in the other bb, rather than before those.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK. 

Richard. 

>2019-04-24  Jakub Jelinek  
>
>   PR tree-optimization/90208
>   * tree-cfg.c (remove_bb): Move forced labels from removed bbs
>   after labels of new_bb, not before them.
>
>   * gcc.dg/tsan/pr90208-1.c: New test.
>   * gcc.dg/tsan/pr90208-2.c: New test.
>
>--- gcc/tree-cfg.c.jj  2019-03-14 23:44:27.861560155 +0100
>+++ gcc/tree-cfg.c 2019-04-23 14:40:05.949571172 +0200
>@@ -2265,7 +2265,7 @@ remove_bb (basic_block bb)
> new_bb = single_succ (new_bb);
> gcc_assert (new_bb != bb);
>   }
>-new_gsi = gsi_start_bb (new_bb);
>+new_gsi = gsi_after_labels (new_bb);
> gsi_remove (, false);
> gsi_insert_before (_gsi, stmt, GSI_NEW_STMT);
>   }
>--- gcc/testsuite/gcc.dg/tsan/pr90208-1.c.jj   2019-04-23
>14:48:16.034625947 +0200
>+++ gcc/testsuite/gcc.dg/tsan/pr90208-1.c  2019-04-23 14:48:12.450684051
>+0200
>@@ -0,0 +1,5 @@
>+/* PR tree-optimization/90208 */
>+/* { dg-do compile } */
>+/* { dg-options "-O3 -fexceptions -fsanitize=thread" } */
>+
>+#include "../../gcc.c-torture/compile/pr89280.c"
>--- gcc/testsuite/gcc.dg/tsan/pr90208-2.c.jj   2019-04-23
>14:50:23.850553809 +0200
>+++ gcc/testsuite/gcc.dg/tsan/pr90208-2.c  2019-04-23 14:51:09.819808554
>+0200
>@@ -0,0 +1,20 @@
>+/* PR tree-optimization/90208 */
>+/* { dg-do compile } */
>+/* { dg-options "-O2 -fexceptions -fsanitize=thread" } */
>+
>+void *b[5];
>+void foo (void);
>+
>+void
>+bar (int d)
>+{
>+  while (d)
>+foo ();
>+}
>+
>+void
>+baz (void)
>+{
>+  bar (2);
>+  __builtin_setjmp (b);
>+}
>
>   Jakub



Re: [PATCH] Fix up parloops loop exit PHI handling (PR tree-optimization/90211)

2019-04-24 Thread Richard Biener
On April 24, 2019 9:57:05 AM GMT+02:00, Jakub Jelinek  wrote:
>Hi!
>
>The parloops code when walking over PHI arguments from the loop exit
>edge assumes that the arguments must be SSA_NAMEs, without checking.
>As can be seen on the following testcase, in some cases it can be a
>constant
>as well.  And we don't really need to do anything special in those
>cases,
>the constant can remain even when the loop is parallelized.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK. 

Richard. 

>2019-04-24  Jakub Jelinek  
>
>   PR tree-optimization/90211
>   * tree-parloops.c (try_create_reduction_list): Ignore phi arguments
>   which are not SSA_NAMEs.
>
>   * gcc.dg/autopar/pr90211.c: New test.
>
>--- gcc/tree-parloops.c.jj 2019-02-26 14:13:08.297824084 +0100
>+++ gcc/tree-parloops.c2019-04-23 12:35:13.253037933 +0200
>@@ -2794,7 +2794,7 @@ try_create_reduction_list (loop_p loop,
>   gimple *reduc_phi;
>   tree val = PHI_ARG_DEF_FROM_EDGE (phi, exit);
> 
>-  if (!virtual_operand_p (val))
>+  if (TREE_CODE (val) == SSA_NAME && !virtual_operand_p (val))
>   {
> if (dump_file && (dump_flags & TDF_DETAILS))
>   {
>--- gcc/testsuite/gcc.dg/autopar/pr90211.c.jj  2019-04-23
>12:56:30.426338537 +0200
>+++ gcc/testsuite/gcc.dg/autopar/pr90211.c 2019-04-23
>12:29:12.747882701 +0200
>@@ -0,0 +1,24 @@
>+/* PR tree-optimization/90211 */
>+/* { dg-do compile } */
>+/* { dg-require-effective-target pthread } */
>+/* { dg-options "-O3 -fassociative-math -ftree-parallelize-loops=2
>-fno-signed-zeros -fno-trapping-math -fno-tree-copy-prop" } */
>+
>+double
>+foo (int x)
>+{
>+  double a, b = 0.0;
>+  while (x < 3)
>+{
>+  int c;
>+  a = 0.0;
>+  c = 0;
>+  while (c < x)
>+{
>+  a += 1.0;
>+  ++c;
>+}
>+  b += 1.0;
>+  ++x;
>+}
>+  return a + b;
>+}
>
>   Jakub



[PATCH] FIx up GIMPLE bb removal (PR tree-optimization/90208)

2019-04-24 Thread Jakub Jelinek
Hi!

The GIMPLE bb removal code doesn't really remove GIMPLE_LABEL
stmts referencing FORCED_LABELs (and likewise non-local labels,
except it turns them into FORCED_LABELs), but instead moves them
at the start of some other bb.

As can be seen on the testcases, that breaks
  if (prev_stmt && EH_LANDING_PAD_NR (label) != 0)
{
  error ("EH landing pad label ");
  print_generic_expr (stderr, label);
  fprintf (stderr, " is not first in a sequence of labels in bb %d",
   bb->index);
  err = 1;
}
checking and in theory could break
  if (prev_stmt && DECL_NONLOCAL (label))
{
  error ("nonlocal label ");
  print_generic_expr (stderr, label);
  fprintf (stderr, " is not first in a sequence of labels in bb %d",
   bb->index);
  err = 1;
}
too.  Fixed by moving these FORCED_LABELs after the existing labels
in the other bb, rather than before those.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2019-04-24  Jakub Jelinek  

PR tree-optimization/90208
* tree-cfg.c (remove_bb): Move forced labels from removed bbs
after labels of new_bb, not before them.

* gcc.dg/tsan/pr90208-1.c: New test.
* gcc.dg/tsan/pr90208-2.c: New test.

--- gcc/tree-cfg.c.jj   2019-03-14 23:44:27.861560155 +0100
+++ gcc/tree-cfg.c  2019-04-23 14:40:05.949571172 +0200
@@ -2265,7 +2265,7 @@ remove_bb (basic_block bb)
  new_bb = single_succ (new_bb);
  gcc_assert (new_bb != bb);
}
- new_gsi = gsi_start_bb (new_bb);
+ new_gsi = gsi_after_labels (new_bb);
  gsi_remove (, false);
  gsi_insert_before (_gsi, stmt, GSI_NEW_STMT);
}
--- gcc/testsuite/gcc.dg/tsan/pr90208-1.c.jj2019-04-23 14:48:16.034625947 
+0200
+++ gcc/testsuite/gcc.dg/tsan/pr90208-1.c   2019-04-23 14:48:12.450684051 
+0200
@@ -0,0 +1,5 @@
+/* PR tree-optimization/90208 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fexceptions -fsanitize=thread" } */
+
+#include "../../gcc.c-torture/compile/pr89280.c"
--- gcc/testsuite/gcc.dg/tsan/pr90208-2.c.jj2019-04-23 14:50:23.850553809 
+0200
+++ gcc/testsuite/gcc.dg/tsan/pr90208-2.c   2019-04-23 14:51:09.819808554 
+0200
@@ -0,0 +1,20 @@
+/* PR tree-optimization/90208 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fexceptions -fsanitize=thread" } */
+
+void *b[5];
+void foo (void);
+
+void
+bar (int d)
+{
+  while (d)
+foo ();
+}
+
+void
+baz (void)
+{
+  bar (2);
+  __builtin_setjmp (b);
+}

Jakub


[PATCH] Fix up parloops loop exit PHI handling (PR tree-optimization/90211)

2019-04-24 Thread Jakub Jelinek
Hi!

The parloops code when walking over PHI arguments from the loop exit
edge assumes that the arguments must be SSA_NAMEs, without checking.
As can be seen on the following testcase, in some cases it can be a constant
as well.  And we don't really need to do anything special in those cases,
the constant can remain even when the loop is parallelized.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2019-04-24  Jakub Jelinek  

PR tree-optimization/90211
* tree-parloops.c (try_create_reduction_list): Ignore phi arguments
which are not SSA_NAMEs.

* gcc.dg/autopar/pr90211.c: New test.

--- gcc/tree-parloops.c.jj  2019-02-26 14:13:08.297824084 +0100
+++ gcc/tree-parloops.c 2019-04-23 12:35:13.253037933 +0200
@@ -2794,7 +2794,7 @@ try_create_reduction_list (loop_p loop,
   gimple *reduc_phi;
   tree val = PHI_ARG_DEF_FROM_EDGE (phi, exit);
 
-  if (!virtual_operand_p (val))
+  if (TREE_CODE (val) == SSA_NAME && !virtual_operand_p (val))
{
  if (dump_file && (dump_flags & TDF_DETAILS))
{
--- gcc/testsuite/gcc.dg/autopar/pr90211.c.jj   2019-04-23 12:56:30.426338537 
+0200
+++ gcc/testsuite/gcc.dg/autopar/pr90211.c  2019-04-23 12:29:12.747882701 
+0200
@@ -0,0 +1,24 @@
+/* PR tree-optimization/90211 */
+/* { dg-do compile } */
+/* { dg-require-effective-target pthread } */
+/* { dg-options "-O3 -fassociative-math -ftree-parallelize-loops=2 
-fno-signed-zeros -fno-trapping-math -fno-tree-copy-prop" } */
+
+double
+foo (int x)
+{
+  double a, b = 0.0;
+  while (x < 3)
+{
+  int c;
+  a = 0.0;
+  c = 0;
+  while (c < x)
+{
+  a += 1.0;
+  ++c;
+}
+  b += 1.0;
+  ++x;
+}
+  return a + b;
+}

Jakub


[PATCH] Fix ix86_expand_sse_fp_minmax (PR target/90187)

2019-04-24 Thread Jakub Jelinek
Hi!

ix86_expand_sse_fp_minmax bypasses the expanders and so might end up with
both if_true and if_false being a MEM, which violates the condition of the
insn it wants to match.

The following patch makes sure at most one of the operands is a MEM.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2019-04-24  Jakub Jelinek  

PR target/90187
* config/i386/i386.c (ix86_expand_sse_fp_minmax): Force if_true into
a register if both if_true and if_false are MEMs.

* g++.target/i386/pr90187.C: New test.

--- gcc/config/i386/i386.c.jj   2019-04-16 10:40:15.077091789 +0200
+++ gcc/config/i386/i386.c  2019-04-23 11:42:32.088334896 +0200
@@ -23712,6 +23712,8 @@ ix86_expand_sse_fp_minmax (rtx dest, enu
   else
 {
   code = is_min ? SMIN : SMAX;
+  if (MEM_P (if_true) && MEM_P (if_false))
+   if_true = force_reg (mode, if_true);
   tmp = gen_rtx_fmt_ee (code, mode, if_true, if_false);
 }
 
--- gcc/testsuite/g++.target/i386/pr90187.C.jj  2019-04-23 11:42:51.175025002 
+0200
+++ gcc/testsuite/g++.target/i386/pr90187.C 2019-04-23 11:41:56.405914260 
+0200
@@ -0,0 +1,15 @@
+// PR target/90187
+// { dg-do compile }
+// { dg-options "-Ofast -ffloat-store" }
+
+double a[64];
+double *foo (void);
+
+void
+bar (int x, const double *y)
+{
+  int i;
+  for (i = 0; i < x; i++)
+if (y[i] < a[i])
+  a[i] = y[i];
+}

Jakub


[PATCH] Fix up RTL splitting of asm goto (PR target/90193)

2019-04-24 Thread Jakub Jelinek
Hi!

The i386 backend has a splitter:
(define_split
  [(match_operand 0 "tls_address_pattern")]
  "TARGET_TLS_DIRECT_SEG_REFS"
  [(match_dup 0)]
  "operands[0] = ix86_rewrite_tls_address (operands[0]);")
which just copies the pattern of an insn and adjusts tls references in
there.  Unfortunately it doesn't really work with asm goto, which needs
to be a JUMP_INSN rather than normal INSN.  try_split uses the classify_insn
function to determine the kind of insn it should create and that didn't
have any code to handle asm goto.

The following patch adds that and also copies over the REG_LABEL_TARGET
nodes from the original JUMP_INSN to the replacement JUMP_INSN.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2019-04-24  Jakub Jelinek  

PR target/90193
* rtl.c (classify_insn): Return JUMP_INSN for asm goto.
* emit-rtl.c (try_split): Copy over REG_LABEL_TARGET.

* gcc.target/i386/pr90193.c: New test.

--- gcc/rtl.c.jj2019-01-01 12:37:17.429970488 +0100
+++ gcc/rtl.c   2019-04-22 16:06:08.537256974 +0200
@@ -746,6 +746,8 @@ classify_insn (rtx x)
 return CALL_INSN;
   if (ANY_RETURN_P (x))
 return JUMP_INSN;
+  if (GET_CODE (x) == ASM_OPERANDS && ASM_OPERANDS_LABEL_VEC (x))
+return JUMP_INSN;
   if (GET_CODE (x) == SET)
 {
   if (GET_CODE (SET_DEST (x)) == PC)
@@ -772,6 +774,9 @@ classify_insn (rtx x)
  return CALL_INSN;
   if (has_return_p)
return JUMP_INSN;
+  if (GET_CODE (XVECEXP (x, 0, 0)) == ASM_OPERANDS
+ && ASM_OPERANDS_LABEL_VEC (XVECEXP (x, 0, 0)))
+   return JUMP_INSN;
 }
 #ifdef GENERATOR_FILE
   if (GET_CODE (x) == MATCH_OPERAND
--- gcc/emit-rtl.c.jj   2019-01-10 11:43:14.388377679 +0100
+++ gcc/emit-rtl.c  2019-04-22 16:25:08.698982786 +0200
@@ -3940,6 +3940,7 @@ try_split (rtx pat, rtx_insn *trial, int
  break;
 
case REG_NON_LOCAL_GOTO:
+   case REG_LABEL_TARGET:
  for (insn = insn_last; insn != NULL_RTX; insn = PREV_INSN (insn))
{
  if (JUMP_P (insn))
--- gcc/testsuite/gcc.target/i386/pr90193.c.jj  2019-04-22 16:28:06.554127408 
+0200
+++ gcc/testsuite/gcc.target/i386/pr90193.c 2019-04-22 16:27:45.644463104 
+0200
@@ -0,0 +1,21 @@
+/* PR target/90193 *
+/* { dg-do link } */
+/* { dg-options "-O1" } */
+/* { dg-require-effective-target tls } */
+
+__thread int var;
+
+static int
+foo (void)
+{
+  asm goto ("jmp %l[l]\n\t" : : "m" (var) : : l);
+  return 0;
+l:
+  return 1;
+}
+
+int
+main ()
+{
+  return foo ();
+}

Jakub


Re: [PATCH, libphobos] Committed added AArch64 Linux as a supported target.

2019-04-24 Thread Andreas Schwab
On Apr 24 2019, Iain Buclaw  wrote:

> This patch adds arch64*-*-linux* as a supported libphobos target,
> something that has been passing the testsuite for a while now.
>
> Committed to trunk as r270524.

That breaks -mabi=ilp32:

/opt/gcc/gcc-20190424/libphobos/libdruntime/core/sys/posix/sys/stat.d:713:13: 
error: static assert  (104u == 128u) is false
  713 | static assert(stat_t.sizeof == 128);
  | ^
make[8]: *** [Makefile:2047: core/sys/posix/fcntl.lo] Error 1

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [PATCH] Fix ARM exception handling (PR target/89093)

2019-04-24 Thread Eric Botcazou
> The Ada changes need those guards because the file is compiled by both
> the system compiler and by the newly built compilers; when compiled by
> system compiler, as the FE is built with -fno-exceptions I'd hope the EH
> stuff isn't really used there and at least until GCC 9.1 is released we have
> the issue that the system compiler could be some earlier GCC 9.0.1 snapshot
> which doesn't support general-regs-only.

The Ada front-end does use EH on the host, but only the part written in Ada, 
that's why -fno-exceptions is very likely still OK for the C++ part.

The Ada bits are OK and I guess we don't care about earlier 9.0.1 snapshots.

-- 
Eric Botcazou