Re: [PATCH 0/6] Improve -fprefetch-loop-arrays in general and for AArch64 in particular

2017-05-27 Thread Andrew Pinski
On Tue, Feb 28, 2017 at 1:53 AM, Maxim Kuvyrkov
 wrote:
>> On Feb 20, 2017, at 5:38 PM, Kyrill Tkachov  
>> wrote:
>>
>> Hi Maxim,
>>
>> On 30/01/17 11:24, Maxim Kuvyrkov wrote:
>>> This patch series improves -fprefetch-loop-arrays pass through small fixes 
>>> and tweaks, and then enables it for several AArch64 cores.
>>>
>>> My tunings were done on and for Qualcomm hardware, with results varying 
>>> between +0.5-1.9% for SPEC2006 INT and +0.25%-1.0% for SPEC2006 FP at -O3, 
>>> depending on hardware revision.
>>>
>>> This patch series enables restricted -fprefetch-loop-arrays at -O2, which 
>>> also improves SPEC2006 numbers
>>>
>>> Biggest progressions are on 419.mcf and 437.leslie3d, with no serious 
>>> regressions on other benchmarks.
>>>
>>> I'm now investigating making -fprefetch-loop-arrays more aggressive for 
>>> Qualcomm hardware, which improves performance on most benchmarks, but also 
>>> causes big regressions on 454.calculix and 462.libquantum.  If I can fix 
>>> these two regressions, prefetching will give another boost to AArch64.
>>>
>>> Andrew just posted similar prefetching tunings for Cavium's cores, and the 
>>> two patches have trivial conflicts.  I'll post mine as-is, since it address 
>>> one of the comments on Andrew's review (adding a stand-alone struct for 
>>> tuning parameters).
>>>
>>> Andrew, feel free to just copy-paste it to your patch, since it is just a 
>>> mechanical change.
>>>
>>> All patches were bootstrapped and regtested on x86_64-linux-gnu and 
>>> aarch64-linux-gnu.
>>>
>>
>> I've tried these patches out on Cortex-A72 and Cortex-A53, with the tuning 
>> structs entries appropriately
>> modified to enable the changes on those cores.
>> I'm seeing the mcf and leslie3d improvements as well on Cortex-A72 and 
>> Cortex-A53 and no noticeable regressions.
>> I've also verified that the improvements are due to the prefetch 
>> instructions rather than just the unrolling that
>> the pass does.
>> So I'm in favor of enabling this for the cores that benefit from it.
>>
>> Do you plan to get this in for GCC 8?
>
> Hi Kyrill,
>
> My hope was to push them in time for GCC 7, but it seems to late now.  I'll 
> return to these patches at the beginning of Stage 1.

Ping on this patch set as I really want to get in the prefetching side
for ThunderX 1 and 2.  Or should I resubmit my patch set?

Thanks,
Andrew

>
> --
> Maxim Kuvyrkov
> www.linaro.org
>


Re: [PATCH] warn on mem calls modifying objects of non-trivial types (PR 80560)

2017-05-27 Thread Martin Sebor

+/* Return true if class TYPE meets a relaxed definition of
standard-layout.
+   In particular, the requirement that it "has all non-static data
members
+   nd bit-fields in the class and its base classes first declared in the
+   same class" is not considered.  */
+
+static bool
+almost_std_layout_p (tree type, tree *field)


It looks like this will only return false when trivial_type_p will also
return false, so its only real function is setting *field.  Can we
remove it and instead make first_non_public_field recursive?


Sure, that simplifies the diagnostic code as well.  Thanks!



Let's put the !trivial check first.


...

Again, let's put the !trivial check first; then we don't need to check
trivcopy in the !trivassign branch.


...

And here put the trivially-copyable test first, and drop checking
trivcopy in the !trivassign branch.



I found some gaps so I've reworked the checking completely.  I've
also added a check for realloc.  Please see the new patch (sorry
for the churn).


+  else if (!trivial
+   && !VOID_TYPE_P (srctype)
+   && !char_type_p (TYPE_MAIN_VARIANT (srctype))
+   && !same_type_ignoring_top_level_qualifiers_p (desttype,
+  srctype))


How can this ever be true?  If !trivial, we would have already
complained about the type being non-trivially-copyable.


The code has changed but the warning here now fires for cases like
the following (see the test(HasDefault*, ...) overload in the new
test).

  struct S { S (); };

  void f (S *s, const int a[])
  {
memcpy (s, a, sizeof *s);
  }



"array"


Fixed, thanks.




+   "assignment or copy-initialization instead",
+   fndecl, desttype, access, fld, srctype);
+}
+  else if (!zero_init_p (desttype)
+   && !VOID_TYPE_P (srctype)
+   && !char_type_p (TYPE_MAIN_VARIANT (srctype))
+   && !same_type_ignoring_top_level_qualifiers_p (desttype,
+  srctype))
+warnfmt = G_("%qD writing to an object of type %#qT containing "
+ "a pointer-to-member; use assignment or copy-"
+ "initialization instead");


This check seems unnecessary; copying from e.g. an array of
pointer-to-members would be fine.  I think we only want to check
zero_init_p for the bzero case above.


Makes sense.

Martin
PR c++/80560 - warn on undefined memory operations involving non-trivial types

gcc/c-family/ChangeLog:

	PR c++/80560
	* c.opt (-Wclass-memaccess): New option.

gcc/cp/ChangeLog:

	PR c++/80560
	* call.c (first_non_public_field, maybe_warn_class_memaccess): New
	functions.
	(build_cxx_call): Call maybe_warn_class_memaccess.
	* cp-tree.h (locate_ctor, locate_copy_ctor): Declare.
	(locate_copy_assign, has_trivial_assign, has_trivial_copy): Same.
	(has_trivial_dtor): Same.
	* method.c (locate_dtor, locate_copy_ctor): New functions.
	(locate_copy_assign, has_trivial_special_function): Same.
	(has_trivial_assign, has_trivial_copy, has_trivial_default): Same.
	(has_trivial_dtor): Same.

gcc/ChangeLog:

	PR c++/80560
	* dumpfile.c (dump_register): Avoid calling memset to initialize
	a class with a default ctor.
	* gcc.c (struct compiler): Remove const qualification.
	* genattrtab.c (gen_insn_reserv): Replace memset with initialization.
	* hash-table.h: Ditto.
	* ipa-cp.c (allocate_and_init_ipcp_value): Replace memset with
	  assignment.
	* ipa-prop.c (ipa_free_edge_args_substructures): Ditto.
	* omp-low.c (lower_omp_ordered_clauses): Replace memset with
	default ctor.
	* params.h (struct param_info): Make struct members non-const.
	* tree-switch-conversion.c (emit_case_bit_tests): Replace memset
	with default initialization.
	* vec.h (vec_copy_construct, vec_default_construct): New helper
	functions.
	(vec::copy, vec::splice, vec::reserve): Replace memcpy
	with vec_copy_construct.
	(vect::quick_grow_cleared): Replace memset with default ctor.
	(vect::vec_safe_grow_cleared, vec_safe_grow_cleared): Same.
	* doc/invoke.texi (-Wclass-memaccess): Document.

libcpp/ChangeLog:

	PR c++/80560
	* line-map.c (line_maps::~line_maps): Avoid calling htab_delete
	with a null pointer.
	(linemap_init): Avoid calling memset on an object of a non-trivial
	type.

libitm/ChangeLog:

	PR c++/80560
	* beginend.cc (GTM::gtm_thread::rollback): Avoid calling memset
	on an object of a non-trivial type.
	(GTM::gtm_transaction_cp::commit): Use assignment instead of memcpy
	to copy an object.
	* method-ml.cc (orec_iterator::reinit): Avoid -Wclass-memaccess.

gcc/testsuite/ChangeLog:

	PR c++/80560
	* g++.dg/Wclass-memaccess.C: New test.

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 9ad2f6e..f777b8f 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -792,6 +792,10 @@ Wnon-template-friend
 C++ ObjC++ Var(warn_nontemplate_friend) Init(1) Warning
 Warn when non-templatized friend functions are declared within a template.
 
+Wclass-memaccess
+C++ ObjC++ Var(warn_class_memaccess) Warning 

[PATCH] Add header implementation of std::to_string for integers (PR libstdc++/71108)

2017-05-27 Thread Adrian Wielgosik
Currently std::to_string takes a fairly long trip to vs(n/w)printf. The patch
implements int-to-string formatting in header, to improve function performance.

Results of a benchmark on my PC:
to_string(integer) takes 85-107ns per call (depending on result string size),
out of which ~75ns is spent in vsnprintf. The new implementation removes the
overhead, reducing time per call to 12-29ns.

Tested on x64.

As a side note, this is my first patch for libstdc++/GCC, so please try to
forgive any silly mistakes. Regarding requesting copyright assignment, do I
have to contact ass...@gnu.org separately, or is mentioning it here enough?


2017-05-27  Adrian Wielgosik  

PR libstdc++/71108
* libstdc++-v3/include/ext/string_conversions.h:
(__int_to_string, __format_uint): New.
* libstdc++-v3/include/bits/basic_string.h: Use the new function.


 libstdc++-v3/include/bits/basic_string.h  | 44

 libstdc++-v3/include/ext/string_conversions.h | 38
++
 2 files changed, 50 insertions(+), 32 deletions(-)


diff --git a/libstdc++-v3/include/bits/basic_string.h
b/libstdc++-v3/include/bits/basic_string.h
index b6693c440c01..7732b246a962 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -6210,37 +6210,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   // DR 1261.
   inline string
   to_string(int __val)
-  { return __gnu_cxx::__to_xstring(::vsnprintf, 4 * sizeof(int),
-   "%d", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline string
   to_string(unsigned __val)
-  { return __gnu_cxx::__to_xstring(::vsnprintf,
-   4 * sizeof(unsigned),
-   "%u", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline string
   to_string(long __val)
-  { return __gnu_cxx::__to_xstring(::vsnprintf, 4 * sizeof(long),
-   "%ld", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline string
   to_string(unsigned long __val)
-  { return __gnu_cxx::__to_xstring(::vsnprintf,
-   4 * sizeof(unsigned long),
-   "%lu", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline string
   to_string(long long __val)
-  { return __gnu_cxx::__to_xstring(::vsnprintf,
-   4 * sizeof(long long),
-   "%lld", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline string
   to_string(unsigned long long __val)
-  { return __gnu_cxx::__to_xstring(::vsnprintf,
-   4 * sizeof(unsigned long long),
-   "%llu", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline string
   to_string(float __val)
@@ -6313,37 +6303,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   // DR 1261.
   inline wstring
   to_wstring(int __val)
-  { return __gnu_cxx::__to_xstring(::vswprintf, 4 * sizeof(int),
-L"%d", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline wstring
   to_wstring(unsigned __val)
-  { return __gnu_cxx::__to_xstring(::vswprintf,
-4 * sizeof(unsigned),
-L"%u", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline wstring
   to_wstring(long __val)
-  { return __gnu_cxx::__to_xstring(::vswprintf, 4 * sizeof(long),
-L"%ld", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline wstring
   to_wstring(unsigned long __val)
-  { return __gnu_cxx::__to_xstring(::vswprintf,
-4 * sizeof(unsigned long),
-L"%lu", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline wstring
   to_wstring(long long __val)
-  { return __gnu_cxx::__to_xstring(::vswprintf,
-4 * sizeof(long long),
-L"%lld", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline wstring
   to_wstring(unsigned long long __val)
-  { return __gnu_cxx::__to_xstring(::vswprintf,
-4 * sizeof(unsigned long long),
-L"%llu", __val); }
+  { return __gnu_cxx::__int_to_string(__val); }

   inline wstring
   to_wstring(float __val)
diff --git a/libstdc++-v3/include/ext/string_conversions.h
b/libstdc++-v3/include/ext/string_conversions.h
index 89cba61857d4..617a626a7955 100644
--- a/libstdc++-v3/include/ext/string_conversions.h
+++ b/libstdc++-v3/include/ext/string_conversions.h
@@ -93,6 +93,44 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   return __ret;
 }

+  template
+_CharT*
+__format_uint(_CharT *__end, _T __value)
+{
+  do
+  {
+*--__end = '0' + __value % 10;
+__value /= 10;
+  } while(__value);
+
+  return __end;
+}
+
+  template
+_String
+__int_to_string(_T __value)
+{
+  using _UT = typename std::make_unsigned<_T>::type;
+  using _CharT = typename _String::value_type;
+  constexpr std::size_t __n = 4 * sizeof(_T);
+
+  _UT __absolute;
+  bool __negative = __value < 0;
+  if (__negative)
+__absolute = -static_cast<_UT>(__value);
+  else
+__absolute = static_cast<_UT>(__value);
+
+  _CharT __s[__n];
+  _CharT* __end = __s + __n;
+  _CharT* __start = 

[Patch, fortran] PR35339 Optimize implied do loops in io statements

2017-05-27 Thread Nicolas Koenig

Hello everyone,

attached is a patch to simplify implied do loops in io statements by 
replacing them with their respective array slices. For example "WRITE 
(*,*) (a(i), i=1,4,2)" becomes "WRITE (*,*) a(1:4:2)".


Ok for trunk?

Nicolas

Regression tested for x85_64-pc-linux-gnu.

Changelog:
2017-05-27  Nicolas Koenig  

PR fortran/35339
* frontend-passes.c (traverse_io_block): New function.
(simplify_io_impl_do): New function.
(optimize_namespace): Invoke gfc_code_walker with
simplify_io_impl_do.

2017-05-27  Nicolas Koenig  

PR fortran/35339
* gfortran.dg/implied_do_io_1.f90: New Test.

Index: frontend-passes.c
===
--- frontend-passes.c	(revision 248539)
+++ frontend-passes.c	(working copy)
@@ -1060,6 +1060,258 @@ convert_elseif (gfc_code **c, int *walk_subtrees A
   return 0;
 }
 
+#define swap(x, y) (x) ^= (y), (y) ^= (x), (x) ^= (y);
+
+struct do_stack
+{
+  struct do_stack *prev;
+  gfc_iterator *iter;
+  gfc_code *code;
+} *stack_top;
+
+/* Recursivly traverse the block of a WRITE or READ statement, and, can it be
+   optimized, do so. It optimizes it by replacing do loops with their analog
+   array slices. For example:
+   
+ write (*,*) (a(i), i=1,4)
+ 
+   is replaced with
+ 
+ write (*,*) a(1:4:1) .  */
+
+static bool 
+traverse_io_block(gfc_code *code, bool *has_reached, gfc_code *prev)
+{
+  gfc_code *curr; 
+  gfc_expr *new_e, *expr, *start;
+  gfc_ref *ref;
+  struct do_stack ds_push;
+  int i, future_rank = 0;
+  gfc_iterator *iters[GFC_MAX_DIMENSIONS];
+
+  /* Find the first transfer/do statement.  */
+  for (curr = code; curr; curr = curr->next)
+{
+  if (curr->op == EXEC_DO || curr->op == EXEC_TRANSFER)
+break;
+}
+
+  /* Ensure it is the only transfer/do statement because cases like
+   
+   write (*,*) (a(i), b(i), i=1,4)
+
+ cannot be optimized.  */
+
+  if (!curr || curr->next)
+return false;
+
+  if (curr->op == EXEC_DO)
+{
+  if (curr->ext.iterator->var->ref)
+return false;
+  ds_push.prev = stack_top;
+  ds_push.iter = curr->ext.iterator;
+  ds_push.code = curr;
+  stack_top = _push;
+  if (traverse_io_block(curr->block->next, has_reached, prev))
+{
+	  if (curr != stack_top->code && !*has_reached)
+	{
+  curr->block->next = NULL;
+  gfc_free_statements(curr);
+	}
+	  else
+	*has_reached = true;
+	  return true;
+}
+  return false;
+}
+
+  gcc_assert(curr->op == EXEC_TRANSFER);
+
+  if (curr->expr1->symtree->n.sym->attr.allocatable)
+return false;
+
+  ref = curr->expr1->ref;
+  if (!ref || ref->type != REF_ARRAY || ref->u.ar.codimen != 0)
+return false;
+
+  /* Find the iterators belonging to each variable and check conditions.  */
+  for (i = 0; i < ref->u.ar.dimen; i++)
+{
+  if (!ref->u.ar.start[i] || ref->u.ar.start[i]->ref
+  || ref->u.ar.dimen_type[i] != DIMEN_ELEMENT)
+return false;
+  
+  start = ref->u.ar.start[i];
+  gfc_simplify_expr(start, 0);
+  switch (start->expr_type)
+{
+	case EXPR_VARIABLE:
+
+	  /* write (*,*) (a(i), i=a%b,1) not handled yet.  */
+	  if (start->ref)
+	return false;
+
+	  /*  Check for (a(k), i=1,4) or ((a(j, i), i=1,4), j=1,4).  */
+	  if (!stack_top || !stack_top->iter 
+	 || stack_top->iter->var->symtree != start->symtree)
+	iters[i] = NULL; 
+	  else
+	{
+  iters[i] = stack_top->iter;
+	  stack_top = stack_top->prev;
+	  future_rank++;
+	}
+	  break;
+case EXPR_CONSTANT:
+	  iters[i] = NULL;
+	  break;
+	case EXPR_OP:
+  switch (start->value.op.op)
+	{
+	case INTRINSIC_PLUS:
+	case INTRINSIC_TIMES:
+	  if (start->value.op.op1->expr_type != EXPR_VARIABLE)
+	std::swap(start->value.op.op1, start->value.op.op2);
+	__attribute__((fallthrough));
+	case INTRINSIC_MINUS:
+	  if ((start->value.op.op1->expr_type!= EXPR_VARIABLE 
+	&& start->value.op.op2->expr_type != EXPR_CONSTANT)
+	  || start->value.op.op1->ref)
+	return false;
+  if (!stack_top || !stack_top->iter 
+	 || stack_top->iter->var->symtree 
+		!= start->value.op.op1->symtree)
+	return false;
+	  iters[i] = stack_top->iter; 
+	  stack_top = stack_top->prev;
+	  break;
+	default:
+	  return false;
+	}
+	future_rank++;
+	  break;
+	default:
+	  return false;
+}
+}
+
+  /* Create new expr.  */
+  new_e = gfc_copy_expr(curr->expr1);
+  new_e->expr_type = EXPR_VARIABLE;
+  new_e->rank = future_rank; 
+  if (curr->expr1->shape)
+{
+  new_e->shape = gfc_get_shape(new_e->rank);
+}
+
+  /* Assign new starts, ends and strides if necessary.  */
+  for (i = 0; i < ref->u.ar.dimen; i++)
+{
+  if (!iters[i])
+

Re: regression for microblaze architecture

2017-05-27 Thread Michael Eager

From https://gcc.gnu.org/ml/gcc/2017-05/msg00221.html:

On 05/27/2017 09:09 AM, Michael Eager wrote:

On 05/27/2017 01:51 AM, Waldemar Brodkorb wrote:

Hi,

Buildroot and OpenADK have samples to create a Linux system to be
bootup in Qemu system emulation for microblaze architecture.

With gcc 6.3 and 7.1 the samples are not working anymore,
because the Linux system userland does not boot.
Qemu 2.9.0:
Kernel panic - not syncing: Attempted to kill init!
exitcode=0x000b
(with glibc, musl and uClibc-ng toolchains)

I bisected gcc source code and found the bad commit:
6dcad60c0ef48af584395a40feeb256fb82986a8

When reverting the change, gcc 6.3 and 7.1 produces working
Linux rootfs again.

What can we do about it?


I will revert this commit in GCC.


Reverted on GCC mainline: Committed revision 248540.

--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


[PATCH] fix PR ada/80888

2017-05-27 Thread Simon Wright
The GNAT reference manual says in 11.6 Wide_Text_IO
,

  "The default encoding method for the standard files, and for opened
  files for which no WCEM parameter is given in the FORM string matches
  the wide character encoding specified for the main program (the
  default being brackets encoding if no coding method was specified with
  -gnatW)."

This is not true; the default is brackets encoding regardless of the
coding method specified with -gnatW.

The attached patch (to 7.1.0) corrects this. Tested on
x86_84-apple-darwin15 by rebuilding the library (cd gcc; make gnatlib
gnatlib-shared) and make -j4 check-ada,

=== acats Summary ===
# of expected passes2320
# of unexpected failures0
/Volumes/Miscellaneous/tmp/gcc-7.1.0/gcc/testsuite/ada/acats/run_all.sh 
completed at Fri 26 May 2017 15:44:52 BST

=== gnat Summary ===

# of expected passes2569
# of expected failures  24
# of unsupported tests  7
/Volumes/Miscellaneous/tmp/gcc-7.1.0-build/gcc/gnatmake version 7.1.0

gcc/ada/Changelog:

2017-05-27 Simon Wright 

PR ada/80888
* a-textio.adb (Set_WCEM): default the file's wide character encoding
  method to Default_WCEM, not WCEM_Brackets.
* a-witeio.adb: likewise.
* a-ztexio.adb: likewise.



wcem-fix.diff
Description: Binary data


Re: MinGW compilation warnings in libiberty's waitpid.c

2017-05-27 Thread Iain Buclaw
On 26 May 2017 at 18:30, Joel Brobecker  wrote:
>> Thanks.  Is the environ thing also fixed?
>>
>> Joel/Pedro, how should I go about making sure these changes are in the
>> GDB copy of libiberty?
>
> Normally, I'd expect someone pushing to GCC's libibert to also
> update our repo accordingly. However, it's easy to forget so,
> if you notice a change that was not propagated to us, we just
> cherry-pick those changes so as to make sure our copy is up
> to date with GCC's. We also see the occasional "resync libiberty"
> commits which act as a failsafe, but I don't think we should wait
> for one of those.
>

This has been on my todo-list for a little while, as re-syncing is
something I normally do after pushing D language support updates into
libiberty.  However I decided to give it a wait until I got all
pending patches in, the last of which I'm just pushing in now.

Regards,
Iain.


Re: Default std::vector default and move constructor

2017-05-27 Thread Jonathan Wakely

On 26/05/17 23:13 +0200, François Dumont wrote:

On 25/05/2017 18:28, Jonathan Wakely wrote:

On 15/05/17 19:57 +0200, François Dumont wrote:

Hi

  Following what I have started on RbTree here is a patch to 
default implementation of default and move constructors on 
std::vector.


  As in _Rb_tree_impl the default allocator is not value 
initialized anymore. We could add a small helper type arround the 
allocator to do this value initialization per default. Should I do 
so ?


It's required to be value-initialized, so if your patch changes that
then it's a problem.

Did we decide it's OK to do that for RB-trees? Did we actually discuss
that part of the r243379 changes?


I remember a message pointing this issue but after the commit AFAIR. I 
thought it was from Tim but I can't find it on the archive.


What is the rational of this requirement ? I started working on a type 
to do the allocator value initialization if there is no default 
constructor but it seems quite complicated to do so. It is quite sad 
that we can't fully benefit from this nice C++11 feature just because 
of this requirement. If there is any initialization needed it doesn't 
sound complicated to provide a default constructor.


The standard says that the default constructor is:

 vector() : vector(Allocator()) { }

That value-initializes the allocator. If the allocator type behaves
differently for value-init and default-init (e.g. it has data members
that are left uninitialized by default-init) then the difference
matters. If you change the code so it only does default-init of the
allocator then you will introduce an observable difference.

I don't see any requirement that a DefaultConstructible allocator
cannot leave members uninitialized, so that means the standard
requires default construction of vector to value-init the
allocator. Not default-init.

Here's an allocator that behaves differently if value-initialized or
default-initialized:

template
struct Alloc {
 using value_type = T;
 Alloc() = default;
 template
   Alloc(const Alloc& a) : mem(a.mem) { }
 T* allocate(std::size_t n) {
   if (mem)
 throw 1;
   return std::allocator().allocate(n);
 }
 void deallocate(T* p, std::size_t n) {
   std::allocator().deallocate(p, n);
 }

 int mem;
};

template
bool operator==(const Alloc& t, const Alloc& u)
{ return t.mem == u.mem; }

template
bool operator!=(const Alloc& t, const Alloc& u)
{ return !(t == u); }


MAINTAINERS update

2017-05-27 Thread Bernd Schmidt
I am no longer working for Red Hat, so I've updated my email address. 
Also, I don't expect to be around very much in the near future, so I've 
removed myself as maintainer for some areas.



Bernd
Index: ChangeLog
===
--- ChangeLog	(revision 248535)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2017-05-27  Bernd Schmidt  
+
+	* MAINTAINERS: Update my email address, and remove myself as
+	maintainer in some areas.
+
 2017-05-25  Eric Gallager  
 
 	* MAINTAINERS: Add self to Write After Approval
Index: MAINTAINERS
===
--- MAINTAINERS	(revision 248535)
+++ MAINTAINERS	(working copy)
@@ -30,7 +30,7 @@ Michael Meissner
 David S. Miller	
 Joseph Myers	
-Bernd Schmidt	
+Bernd Schmidt	
 Ian Lance Taylor
 Jim Wilson	
 
@@ -48,9 +48,7 @@ arm port		Nick Clifton		
 arm port		Ramana Radhakrishnan	
 avr port		Denis Chertykov		
-bfin port		Bernd Schmidt		
 bfin port		Jie Zhang		
-c6x port		Bernd Schmidt		
 cris port		Hans-Peter Nilsson	
 epiphany port		Joern Rennecke		
 fr30 port		Nick Clifton		
@@ -85,7 +83,6 @@ nds32 port		Chung-Ju Wu		
 nios2 port		Chung-Lin Tang		
 nios2 port		Sandra Loosemore	
-nvptx port		Bernd Schmidt		
 pdp11 port		Paul Koning		
 picochip port		Daniel Towner		
 riscv port		Kito Cheng		
@@ -231,7 +228,6 @@ tree browser/unparser	Sebastian Pop		
 profile feedback	Jan Hubicka		
 reload			Ulrich Weigand		
-reload			Bernd Schmidt		
 dfp.c, related		Ben Elliston		
 RTL optimizers		Eric Botcazou		
 instruction combiner	Segher Boessenkool	


Re: Web page for binaries

2017-05-27 Thread Gerald Pfeifer
On Sat, 27 May 2017, FX wrote:
> Does the website get rebuilt automatically, or does it need to be 
> triggered?

All automagically :-), and in the case of documents created from 
.texi (such as /onlinedocs or /install) this happens once a day, 
cf. gcc/maintainer-scripts/crontab line 2.

Gerald


Re: Web page for binaries

2017-05-27 Thread FX
> Just omit the slashes at the ends of the two URLs please.  (If you 
> paste them into Firefox, say, you'll notice they end up getting stripped.  
> I don't have the RFC handy right now, but for domain names without 
> directories the / hasn't been necessary for fifteen or so years.)

Done.

Does the website get rebuilt automatically, or does it need to be triggered?

FX


Re: Allow some NOP conversions in (X+CST1)+CST2 in match.pd

2017-05-27 Thread Marc Glisse

On Sat, 27 May 2017, Jakub Jelinek wrote:


After discussions in PR80887, I've reverted the match.pd part and xfailed
the test, because it breaks bootstrap and will take a while to resolve
properly.


Thank you.

--
Marc Glisse


Re: Allow some NOP conversions in (X+CST1)+CST2 in match.pd

2017-05-27 Thread Jakub Jelinek
On Sun, May 21, 2017 at 09:22:56PM +0200, Marc Glisse wrote:
> generalizing a bit one transformation, to avoid a regression with another
> patch I am working on. Handling conversions always gets messy :-( It would
> have been easier to stick to scalars and wide_int, but since the existing
> transformation handles vectors, I didn't want to regress.
> 
> Bootstrap+testsuite on powerpc64le-unknown-linux-gnu.
> 
> 2017-05-22  Marc Glisse  
> 
> gcc/
>   * match.pd ((A +- CST1) +- CST2): Allow some conversions.
>   * tree.c (drop_tree_overflow): Handle COMPLEX_CST and VECTOR_CST.
> 
> gcc/testsuite/
>   * gcc.dg/tree-ssa/addadd.c: New file.

After discussions in PR80887, I've reverted the match.pd part and xfailed
the test, because it breaks bootstrap and will take a while to resolve
properly.

2017-05-27  Jakub Jelinek  

PR bootstrap/80887
Revert:
2017-05-25  Marc Glisse  

* match.pd ((A +- CST1) +- CST2): Allow some conversions.

* gcc.dg/tree-ssa/addadd.c: Xfail all scan-tree-dump*.

--- gcc/match.pd(revision 248448)
+++ gcc/match.pd(revision 248447)
@@ -1299,39 +1299,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   /* (A +- CST1) +- CST2 -> A + CST3  */
   (for outer_op (plus minus)
(for inner_op (plus minus)
-   neg_inner_op (minus plus)
 (simplify
- (outer_op (convert? (inner_op @0 CONSTANT_CLASS_P@1)) CONSTANT_CLASS_P@2)
- (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
-  /* If one of the types wraps, use that one.  */
-  (if (!ANY_INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_WRAPS (type))
-   (if (outer_op == PLUS_EXPR)
-   (plus (convert @0) (inner_op @2 (convert @1)))
-   (minus (convert @0) (neg_inner_op @2 (convert @1
-   (if (!ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
-   || TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0)))
-   (if (outer_op == PLUS_EXPR)
-(convert (plus @0 (inner_op (convert @2) @1)))
-(convert (minus @0 (neg_inner_op (convert @2) @1
-   /* If the constant operation overflows we cannot do the transform
-  directly as we would introduce undefined overflow, for example
-  with (a - 1) + INT_MIN.  */
-   (if (types_match (type, @0))
-(with { tree cst = const_binop (outer_op == inner_op
-? PLUS_EXPR : MINUS_EXPR,
-type, @1, @2); }
- (if (cst && !TREE_OVERFLOW (cst))
-  (inner_op @0 { cst; } )
-  /* X+INT_MAX+1 is X-INT_MIN.  */
-  (if (INTEGRAL_TYPE_P (type) && cst
-   && wi::eq_p (cst, wi::min_value (type)))
-   (neg_inner_op @0 { wide_int_to_tree (type, cst); })
-   /* Last resort, use some unsigned type.  */
-   (with { tree utype = unsigned_type_for (type); }
-(convert (inner_op
-  (convert:utype @0)
-  (convert:utype
-   { drop_tree_overflow (cst); }))
+ (outer_op (inner_op @0 CONSTANT_CLASS_P@1) CONSTANT_CLASS_P@2)
+ /* If the constant operation overflows we cannot do the transform
+   as we would introduce undefined overflow, for example
+   with (a - 1) + INT_MIN.  */
+ (with { tree cst = const_binop (outer_op == inner_op
+? PLUS_EXPR : MINUS_EXPR, type, @1, @2); }
+  (if (cst && !TREE_OVERFLOW (cst))
+   (inner_op @0 { cst; } ))
 
   /* (CST1 - A) +- CST2 -> CST3 - A  */
   (for outer_op (plus minus)
--- gcc/testsuite/gcc.dg/tree-ssa/addadd.c  (revision 248532)
+++ gcc/testsuite/gcc.dg/tree-ssa/addadd.c  (working copy)
@@ -29,6 +29,6 @@ void j(S*x){
   *x += __INT_MAX__;
 }
 
-/* { dg-final { scan-tree-dump-times " \\+ 24;" 2 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "\\(unsigned int\\)" 2 "optimized" } } */
-/* { dg-final { scan-tree-dump-not "2147483647" "optimized" } } */
+/* { dg-final { scan-tree-dump-times " \\+ 24;" 2 "optimized" { xfail *-*-* } 
} } */
+/* { dg-final { scan-tree-dump-times "\\(unsigned int\\)" 2 "optimized" { 
xfail *-*-* }  } } */
+/* { dg-final { scan-tree-dump-not "2147483647" "optimized" { xfail *-*-* }  } 
} */


Jakub