Re: [PATCH] On x86 allow if-conversion of more than one insn as long as there is at most one cmov (PR tree-optimization/79390)

2017-04-03 Thread Jakub Jelinek
On Sun, Apr 02, 2017 at 08:44:03PM +0200, Uros Bizjak wrote:
> x86 part LGTM.
> 
> Hopefully, this infrastructure will allow us to fix (or it already
> fixes) PR 56309 [1].

I think only allows to.  The target hook has access to the if_info
structure which contains the original basic blocks, their edges,
frequencies, and can inspect both the new sequence as well as the original
basic blocks etc.  I really don't know in detail what the problem with
cmov is (latency, or that it blocks some CPU units, something else?).

In any case, any change will need lots of benchmarking, because apparently
cmov is extremely important to get right (for not well predictable branches
use it, for other not really).  Another question is if say setcc has similar
problem or not.

> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56309

Jakub


Re: [PATCH 2/3] Error message on target attribute on aarch64 target (PR target/79889).

2017-04-03 Thread Martin Liška
Thanks Kyrill for review. I'm pinging the patch.

Martin

On 03/21/2017 10:24 AM, Kyrill Tkachov wrote:
> 
> 
> Hi Martin,
> 
> On 13/03/17 08:25, marxin wrote:
>> gcc/testsuite/ChangeLog:
>>
>> 2017-03-13  Martin Liska  
>>
>> * g++.dg/ext/mv8.C: Add aarch64* targets.
>>
>> gcc/ChangeLog:
>>
>> 2017-03-13  Martin Liska  
>>
>> * config/aarch64/aarch64.c (aarch64_process_target_attr):
>> Show error message instead of an ICE.
> 
> You should mention PR target/79889 in your ChangeLog
>> ---
>>   gcc/config/aarch64/aarch64.c   | 8 ++--
>>   gcc/testsuite/g++.dg/ext/mv8.C | 2 +-
>>   2 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
>> index a069427f576..3107d6b84bf 100644
>> --- a/gcc/config/aarch64/aarch64.c
>> +++ b/gcc/config/aarch64/aarch64.c
>> @@ -9533,8 +9533,12 @@ aarch64_process_target_attr (tree args, const char* 
>> pragma_or_attr)
>>   return true;
>>   }
>> -  /* We expect to find a string to parse.  */
>> -  gcc_assert (TREE_CODE (args) == STRING_CST);
>> +
>> +  if (TREE_CODE (args) != STRING_CST)
>> +{
>> +  error ("attribute % argument not a string");
>> +  return false;
>> +}
>>   
> 
> Looks reasonable to me, but you'll need approval from the folks CC-ed.
> 
> Thanks,
> Kyrill
> 
>> size_t len = strlen (TREE_STRING_POINTER (args));
>> char *str_to_check = (char *) alloca (len + 1);
>> diff --git a/gcc/testsuite/g++.dg/ext/mv8.C b/gcc/testsuite/g++.dg/ext/mv8.C
>> index bbf90b5a328..b49ef84f392 100644
>> --- a/gcc/testsuite/g++.dg/ext/mv8.C
>> +++ b/gcc/testsuite/g++.dg/ext/mv8.C
>> @@ -1,4 +1,4 @@
>> -// { dg-do compile { target i?86-*-* x86_64-*-* powerpc*-*-* } }
>> +// { dg-do compile { target i?86-*-* x86_64-*-* powerpc*-*-* aarch64*-*-* } 
>> }
>>   // { dg-options "" }
>> __attribute__((target (11,12)))
> 



Re: [PATCH] [gcc, testsuite] Don't xfail on s390.

2017-04-03 Thread Dominik Vogt
On Fri, Mar 31, 2017 at 03:37:33PM -0600, Martin Sebor wrote:
> On 03/29/2017 04:23 AM, Dominik Vogt wrote:
> >The attached patch removes the XFAIL in attr-alloc_size-11.c on
> >s390.  (PR 79356).
> >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79356
> >
> >Untested.
> 
> It looks like the only target the test does fail on is x86.
> 
> The attached patch simplifies the test to XFAIL just those.
> It passes with cross-compilers for arm-linux-gnueabi-*-*,
> i386-pc-solaris2.11, powerpc64le-*-*, sparcv9-solaris2.11,
> and s360*-*-*.
> 
> I don't have ready access to an s390 machine.  I assume you
> do.  Does it work for you?

Yes.

> diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-11.c 
> b/gcc/testsuite/gcc.dg/attr-alloc_size-11.c
> index e5f2157..19e8680 100644
> --- a/gcc/testsuite/gcc.dg/attr-alloc_size-11.c
> +++ b/gcc/testsuite/gcc.dg/attr-alloc_size-11.c
> @@ -47,8 +47,8 @@ typedef __SIZE_TYPE__size_t;
> 
>  /* The following tests fail because of missing range information.  The xfail
> exclusions are PR79356.  */
> -TEST (signed char, SCHAR_MIN + 2, ALLOC_MAX);   /* { dg-warning "argument 1 
> range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range 
> info for signed char" { xfail { ! { aarch64*-*-* arm*-*-* ia64-*-* mips*-*-* 
> powerpc*-*-* sparc*-*-* s390x-*-* } } } } */
> -TEST (short, SHRT_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range 
> \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for 
> short" { xfail { ! { aarch64*-*-* arm*-*-* ia64-*-* mips*-*-* powerpc*-*-* 
> sparc*-*-* s390x-*-* } } } } */
> +TEST (signed char, SCHAR_MIN + 2, ALLOC_MAX);   /* { dg-warning "argument 1 
> range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "bug 80086" { 
> xfail { i?86-*-* x86_64-*-* } } } */
> +TEST (short, SHRT_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range 
> \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "bug 80086" { xfail { 
> i?86-*-* x86_64-*-* } } } */
>  TEST (int, INT_MIN + 2, ALLOC_MAX);/* { dg-warning "argument 1 range 
> \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */
>  TEST (int, -3, ALLOC_MAX); /* { dg-warning "argument 1 range 
> \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */
>  TEST (int, -2, ALLOC_MAX); /* { dg-warning "argument 1 range 
> \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany



[Aarch64] Fix stack checking in ILP32 mode

2017-04-03 Thread Eric Botcazou
Hi,

this fixes the ICE that has been introduced by the new implementation of stack 
checking in ILP32 mode, hence a regression present on mainline and 6 branch.
I'd also like to mention that the patch only restores the implementation that 
was originally submitted, i.e. it was probably working out of the box before:
  https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00418.html

Tested on Aarch64/Linux, both LP64 and ILP32, OK for mainline and 6 branch?


2017-04-03  Eric Botcazou  

PR target/78002
* config/aarch64/aarch64.c (aarch64_emit_probe_stack_range): Replace
ptr_mode with Pmode throughout.
 * config/aarch64/aarch64.md (probe_stack_range_Index: config/aarch64/aarch64.c
===
--- config/aarch64/aarch64.c	(revision 246276)
+++ config/aarch64/aarch64.c	(working copy)
@@ -2610,7 +2610,7 @@ aarch64_libgcc_cmp_return_mode (void)
 static void
 aarch64_emit_probe_stack_range (HOST_WIDE_INT first, HOST_WIDE_INT size)
 {
-  rtx reg1 = gen_rtx_REG (ptr_mode, PROBE_STACK_FIRST_REG);
+  rtx reg1 = gen_rtx_REG (Pmode, PROBE_STACK_FIRST_REG);
 
   /* See the same assertion on PROBE_INTERVAL above.  */
   gcc_assert ((first % ARITH_FACTOR) == 0);
@@ -2622,9 +2622,9 @@ aarch64_emit_probe_stack_range (HOST_WID
   const HOST_WIDE_INT base = ROUND_UP (size, ARITH_FACTOR);
 
   emit_set_insn (reg1,
-		 plus_constant (ptr_mode,
+		 plus_constant (Pmode,
 stack_pointer_rtx, -(first + base)));
-  emit_stack_probe (plus_constant (ptr_mode, reg1, base - size));
+  emit_stack_probe (plus_constant (Pmode, reg1, base - size));
 }
 
   /* The run-time loop is made up of 8 insns in the generic case while the
@@ -2634,7 +2634,7 @@ aarch64_emit_probe_stack_range (HOST_WID
   HOST_WIDE_INT i, rem;
 
   emit_set_insn (reg1,
-		 plus_constant (ptr_mode,
+		 plus_constant (Pmode,
 stack_pointer_rtx,
 -(first + PROBE_INTERVAL)));
   emit_stack_probe (reg1);
@@ -2645,7 +2645,7 @@ aarch64_emit_probe_stack_range (HOST_WID
   for (i = 2 * PROBE_INTERVAL; i < size; i += PROBE_INTERVAL)
 	{
 	  emit_set_insn (reg1,
-			 plus_constant (ptr_mode, reg1, -PROBE_INTERVAL));
+			 plus_constant (Pmode, reg1, -PROBE_INTERVAL));
 	  emit_stack_probe (reg1);
 	}
 
@@ -2654,11 +2654,11 @@ aarch64_emit_probe_stack_range (HOST_WID
 	{
 	  const HOST_WIDE_INT base = ROUND_UP (rem, ARITH_FACTOR);
 
-	  emit_set_insn (reg1, plus_constant (ptr_mode, reg1, -base));
-	  emit_stack_probe (plus_constant (ptr_mode, reg1, base - rem));
+	  emit_set_insn (reg1, plus_constant (Pmode, reg1, -base));
+	  emit_stack_probe (plus_constant (Pmode, reg1, base - rem));
 	}
   else
-	emit_stack_probe (plus_constant (ptr_mode, reg1, -rem));
+	emit_stack_probe (plus_constant (Pmode, reg1, -rem));
 }
 
   /* Otherwise, do the same as above, but in a loop.  Note that we must be
@@ -2668,7 +2668,7 @@ aarch64_emit_probe_stack_range (HOST_WID
  equality test for the loop condition.  */
   else
 {
-  rtx reg2 = gen_rtx_REG (ptr_mode, PROBE_STACK_SECOND_REG);
+  rtx reg2 = gen_rtx_REG (Pmode, PROBE_STACK_SECOND_REG);
 
   /* Step 1: round SIZE to the previous multiple of the interval.  */
 
@@ -2679,11 +2679,11 @@ aarch64_emit_probe_stack_range (HOST_WID
 
   /* TEST_ADDR = SP + FIRST.  */
   emit_set_insn (reg1,
-		 plus_constant (ptr_mode, stack_pointer_rtx, -first));
+		 plus_constant (Pmode, stack_pointer_rtx, -first));
 
   /* LAST_ADDR = SP + FIRST + ROUNDED_SIZE.  */
   emit_set_insn (reg2,
-		 plus_constant (ptr_mode, stack_pointer_rtx,
+		 plus_constant (Pmode, stack_pointer_rtx,
 -(first + rounded_size)));
 
 
@@ -2699,10 +2699,7 @@ aarch64_emit_probe_stack_range (HOST_WID
 	 probes at FIRST + N * PROBE_INTERVAL for values of N from 1
 	 until it is equal to ROUNDED_SIZE.  */
 
-  if (ptr_mode == DImode)
-	emit_insn (gen_probe_stack_range_di (reg1, reg1, reg2));
-  else
-	emit_insn (gen_probe_stack_range_si (reg1, reg1, reg2));
+  emit_insn (gen_probe_stack_range (reg1, reg1, reg2));
 
 
   /* Step 4: probe at FIRST + SIZE if we cannot assert at compile-time
@@ -2716,11 +2713,11 @@ aarch64_emit_probe_stack_range (HOST_WID
 	{
 	  const HOST_WIDE_INT base = ROUND_UP (rem, ARITH_FACTOR);
 
-	  emit_set_insn (reg2, plus_constant (ptr_mode, reg2, -base));
-	  emit_stack_probe (plus_constant (ptr_mode, reg2, base - rem));
+	  emit_set_insn (reg2, plus_constant (Pmode, reg2, -base));
+	  emit_stack_probe (plus_constant (Pmode, reg2, base - rem));
 	}
 	  else
-	emit_stack_probe (plus_constant (ptr_mode, reg2, -rem));
+	emit_stack_probe (plus_constant (Pmode, reg2, -rem));
 	}
 }
 
Index: config/aarch64/aarch64.md
===
--- config/aarch64/aarch64.md	(revision 246276)
+++ config/aarch64/aarch64.md	(working copy)
@@ -5412,11 +5412,11 @@

Re: [Aarch64] Enable descriptors for nested functions in Ada

2017-04-03 Thread Andreas Schwab
On Nov 13 2016, Eric Botcazou  wrote:

> Index: config/aarch64/aarch64.c
> ===
> --- config/aarch64/aarch64.c  (revision 242334)
> +++ config/aarch64/aarch64.c  (working copy)
> @@ -14502,6 +14502,10 @@ aarch64_optab_supported_p (int op, machi
>  #undef TARGET_OMIT_STRUCT_RETURN_REG
>  #define TARGET_OMIT_STRUCT_RETURN_REG true
>  
> +/* The architecture reserves bits 0 and 1 so use bit 2 for descriptors.  */
> +#undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS
> +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 4

In which way are the bits reserved?

This does not work for ILP32, because the descriptor address starts off
at address 4 modulo 8, and adding 4 clears the bit.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Re: [PATCH][RFC] Fix P1 PR77498

2017-04-03 Thread Richard Biener
On Fri, 31 Mar 2017, Bin.Cheng wrote:

> On Fri, Mar 31, 2017 at 2:57 PM, Bin.Cheng  wrote:
> > On Fri, Mar 31, 2017 at 11:37 AM, Richard Biener  wrote:
> >> On Fri, 31 Mar 2017, Markus Trippelsdorf wrote:
> >>
> >>> On 2017.03.31 at 11:16 +0200, Richard Biener wrote:
> >>> > On Fri, 31 Mar 2017, Richard Biener wrote:
> >>> >
> >>> > > On Fri, 31 Mar 2017, Rainer Orth wrote:
> >>> > >
> >>> > > > Hi Christophe,
> >>> > > >
> >>> > > > > With this patch, the following testcase now fails on arm* targets:
> >>> > > > > gcc.dg/tree-ssa/pr71347.c scan-tree-dump-not optimized ".* = 
> >>> > > > > MEM.*;"
> >>> > > >
> >>> > > > same on Solaris/SPARC.
> >>> > >
> >>> > > I've reverted r241968 with (patch reverted).  It doesn't include
> >>> > > sparc, so please amend as you see fit.
> >>> >
> >>> > Ah, r241441.  I'll fixup myself then.
> >>>
> >>> It also fails on some X86 configurations:
> >>> https://gcc.gnu.org/ml/gcc-regression/2017-03/msg00237.html
> >>> https://gcc.gnu.org/ml/gcc-regression/2017-03/msg00238.html
> >>
> >> I see.  The test is somewhat strange (well, it's an IVOPTS test).  To
> >> simulate the effect of the PRE changes we could simply enable
> >> -fpredictive-commoning on it.
> >>
> >> Let's ask Bin what the testcase was supposed to test... (the testcase
> >> comment suggests that pcom is applied but it certainly wasn't before
> >> the xfails were removed).
> >
> > It's supposed to test that both loads inside loop can be optimized,
> > X[i-1] by predcom or pre; X[1] by loop invariant.  When the test is
> > added, neither pre nor predcom (not at O2) can do this, but we have
> > another chance that pre + ivopts + dom together can eliminate X[i-1].
> > But this really depends on each pass does the right thing.  That's
> > also why it is added with ivopts change.  Back in time, it was ivopts
> > did "wrong".  Apparently, having a test on different passes is
> > fragile.  I will send a patch adding option "-fpredictive-commoning"
> > because predcom seems the right pass to do that.  Also given we are
> > considering enabling predcom at O2 for GCC 8.
> Here is the patch.  Test result checked on arm-none-eabi.  Is it OK?

Ok.

> Thanks,
> bin
> gcc/testsuite/ChangeLog
> 2017-03-31  Bin Cheng  
> 
> * gcc.dg/tree-ssa/pr71347.c: Add predcom and drop XFAIL.
> 
> Thanks,
> bin
> 

-- 
Richard Biener 
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)


[PATCH] Fix PR80275

2017-04-03 Thread Richard Biener

The following extends split_address_to_core_and_offset to handle
POINTER_PLUS_EXPR to be able to simplify
(unsigned long) &MEM[(void *)&D.15512 + 12B] - (unsigned long) ((const int 
*) &D.15512 + 4) which appears during niter analysis.

We seem to have various copies of similar code but refactoring didn't
seem appropriate at this stage so I went for the minimal fix.

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

Richard.

2017-04-03  Richard Biener  

PR tree-optimization/80275
* fold-const.c (split_address_to_core_and_offset): Handle
POINTER_PLUS_EXPR.

* g++.dg/opt/pr80275.C: New testcase.

Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 246642)
+++ gcc/fold-const.c(working copy)
@@ -14341,6 +14341,24 @@ split_address_to_core_and_offset (tree e
  &volatilep);
   core = build_fold_addr_expr_loc (loc, core);
 }
+  else if (TREE_CODE (exp) == POINTER_PLUS_EXPR)
+{
+  core = TREE_OPERAND (exp, 0);
+  STRIP_NOPS (core);
+  *pbitpos = 0;
+  *poffset = TREE_OPERAND (exp, 1);
+  if (TREE_CODE (*poffset) == INTEGER_CST)
+   {
+ offset_int tem = wi::sext (wi::to_offset (*poffset),
+TYPE_PRECISION (TREE_TYPE (*poffset)));
+ tem <<= LOG2_BITS_PER_UNIT;
+ if (wi::fits_shwi_p (tem))
+   {
+ *pbitpos = tem.to_shwi ();
+ *poffset = NULL_TREE;
+   }
+   }
+}
   else
 {
   core = exp;
Index: gcc/testsuite/g++.dg/opt/pr80275.C
===
--- gcc/testsuite/g++.dg/opt/pr80275.C  (nonexistent)
+++ gcc/testsuite/g++.dg/opt/pr80275.C  (working copy)
@@ -0,0 +1,16 @@
+// { dg-do compile { target c++14 } }
+// { dg-options "-O2 -fdump-tree-optimized" }
+
+#include 
+
+int g()
+{
+  return 1234;
+}
+
+int f2()
+{
+  return std::min({1, g(), 4});
+}
+
+// { dg-final { scan-tree-dump "return 1;" "optimized" } }


Re: [Aarch64] Enable descriptors for nested functions in Ada

2017-04-03 Thread Eric Botcazou
> In which way are the bits reserved?

I don't know, but that's what I was told by the ARM folks.

> This does not work for ILP32, because the descriptor address starts off
> at address 4 modulo 8, and adding 4 clears the bit.

I see, can you try the attached patchlet?

-- 
Eric BotcazouIndex: tree-nested.c
===
--- tree-nested.c	(revision 246276)
+++ tree-nested.c	(working copy)
@@ -496,6 +496,8 @@ static GTY(()) tree descriptor_type;
 static tree
 get_descriptor_type (struct nesting_info *info)
 {
+  /* The base alignment is that of a function.  */
+  const unsigned align = FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY);
   tree t;
 
   if (descriptor_type)
@@ -505,6 +507,9 @@ get_descriptor_type (struct nesting_info
   t = build_array_type (ptr_type_node, t);
   t = build_decl (DECL_SOURCE_LOCATION (info->context),
 		  FIELD_DECL, get_identifier ("__data"), t);
+  if (DECL_ALIGN (t) < align)
+SET_DECL_ALIGN (t, align);
+  DECL_USER_ALIGN (t) = 1;
 
   descriptor_type = make_node (RECORD_TYPE);
   TYPE_NAME (descriptor_type) = get_identifier ("__builtin_descriptor");


Re: Fix ICE with -fauto-profile when walking vdefs

2017-04-03 Thread Richard Biener
On Fri, 31 Mar 2017, Sebastian Pop wrote:

> On Fri, Mar 31, 2017 at 1:50 PM, Richard Biener  wrote:
> > That looks like a workaround rather than the correct fix.  Who sets .MEM? 
> > It should assign the proper def.
> >
> 
> Moving the auto_profile pass above several other passes fixes the problem.
> The minimal change to fix the problem is by disabling these two passes:
> 
> --- a/gcc/passes.def
> +++ b/gcc/passes.def
> @@ -86,14 +86,12 @@ along with GCC; see the file COPYING3.  If not see
>NEXT_PASS (pass_ccp, false /* nonzero_p */);
>/* After CCP we rewrite no longer addressed locals into SSA
>   form if possible.  */
> -  NEXT_PASS (pass_forwprop);
>NEXT_PASS (pass_early_thread_jumps);
>NEXT_PASS (pass_sra_early);
>/* pass_build_ealias is a dummy pass that ensures that we
>   execute TODO_rebuild_alias at this point.  */
>NEXT_PASS (pass_build_ealias);
>NEXT_PASS (pass_fre);
> -  NEXT_PASS (pass_early_vrp);
>NEXT_PASS (pass_merge_phi);
>NEXT_PASS (pass_dse);
>NEXT_PASS (pass_cd_dce);
> 
> It seems to me that early_vrp is the one changing the IR in an inconsistent 
> way.

No, that would have bombed in verify_ssa.


Re: [Aarch64] Enable descriptors for nested functions in Ada

2017-04-03 Thread Andreas Schwab
On Apr 03 2017, Eric Botcazou  wrote:

>> In which way are the bits reserved?
>
> I don't know, but that's what I was told by the ARM folks.
>
>> This does not work for ILP32, because the descriptor address starts off
>> at address 4 modulo 8, and adding 4 clears the bit.
>
> I see, can you try the attached patchlet?

Thanks, that at least fixes tasking.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Re: Fix ICE with -fauto-profile when walking vdefs

2017-04-03 Thread Richard Biener
On Fri, 31 Mar 2017, Sebastian Pop wrote:

> On Fri, Mar 31, 2017 at 12:06 PM, Richard Biener  wrote:
> > That's not a default definition but bogus SSA form.  You have to fix that, 
> > not this symptom.
> >
> 
> Ok.
> It also crashes when adding a call to verifty_ssa
> 
> diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
> index 4b21340c6f0..b834a40af4d 100644
> --- a/gcc/auto-profile.c
> +++ b/gcc/auto-profile.c
> @@ -1589,6 +1590,7 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
>  static void
>  early_inline ()
>  {
> +  verify_ssa (true, true);
>compute_inline_parameters (cgraph_node::get (current_function_decl), true);
>unsigned todo = early_inliner (cfun);
>if (todo & TODO_update_ssa_any)
> 
> The crash is on:
> 
>   gcc_assert (!need_ssa_update_p (cfun));
> 
> and after adding a call to update the SSA, it finishes compilation
> without errors.
> I am testing the following patch:
> 
> * auto-profile.c (early_inline): Call update_ssa.
> 
> --- a/gcc/auto-profile.c
> +++ b/gcc/auto-profile.c
> @@ -1589,6 +1589,8 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
>  static void
>  early_inline ()
>  {
> +  if (need_ssa_update_p (current_function_decl))
> +update_ssa (TODO_update_ssa);
>compute_inline_parameters (cgraph_node::get (current_function_decl), true);
>unsigned todo = early_inliner (cfun);
>if (todo & TODO_update_ssa_any)

Does the following fix it?

Index: gcc/auto-profile.c
===
--- gcc/auto-profile.c  (revision 246642)
+++ gcc/auto-profile.c  (working copy)
@@ -1511,7 +1511,9 @@ afdo_vpt_for_early_inline (stmt_set *pro
 
   if (has_vpt)
 {
-  optimize_inline_calls (current_function_decl);
+  unsigned todo = optimize_inline_calls (current_function_decl);
+  if (todo & TODO_update_ssa_any)
+   update_ssa (TODO_update_ssa);
   return true;
 }
 

afdo really _grossly_ over-does inlining.  And it looks like a total
hack to me.

It iterates PARAM_EARLY_INLINER_MAX_ITERATIONS but early_inliner does
that itself already..


Re: [PATCH] Fix s390 testcase vcond-shift

2017-04-03 Thread Andreas Krebbel
On 03/27/2017 05:03 PM, Robin Dapp wrote:
> this patch fixes the vcond shift testcase that failed since setting
> PARAM_MIN_VECT_LOOP_BOUND in the s390 backend.

Applied. Thanks!

-Andreas-



Re: [PATCH] [gcc, testsuite] Don't xfail on s390.

2017-04-03 Thread Andreas Krebbel
On 03/29/2017 12:23 PM, Dominik Vogt wrote:
> The attached patch removes the XFAIL in attr-alloc_size-11.c on
> s390.  (PR 79356).
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79356

Applied.  Thanks!

-Andreas-



Re: [Aarch64] Enable descriptors for nested functions in Ada

2017-04-03 Thread Eric Botcazou
> Thanks, that at least fixes tasking.

Great, here's what I have installed on the mainline (it only affects the Ada 
compiler) after testing on x86-64/Linux, Aarch64/Linux and SPARC/Solaris.


2017-04-03  Eric Botcazou  

* tree-nested.c (get_descriptor_type): Make sure that the alignment
of descriptors is at least equal to that of functions.

-- 
Eric BotcazouIndex: tree-nested.c
===
--- tree-nested.c	(revision 246276)
+++ tree-nested.c	(working copy)
@@ -496,6 +496,8 @@ static GTY(()) tree descriptor_type;
 static tree
 get_descriptor_type (struct nesting_info *info)
 {
+  /* The base alignment is that of a function.  */
+  const unsigned align = FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY);
   tree t;
 
   if (descriptor_type)
@@ -505,6 +507,8 @@ get_descriptor_type (struct nesting_info
   t = build_array_type (ptr_type_node, t);
   t = build_decl (DECL_SOURCE_LOCATION (info->context),
 		  FIELD_DECL, get_identifier ("__data"), t);
+  SET_DECL_ALIGN (t, MAX (TYPE_ALIGN (ptr_type_node), align));
+  DECL_USER_ALIGN (t) = 1;
 
   descriptor_type = make_node (RECORD_TYPE);
   TYPE_NAME (descriptor_type) = get_identifier ("__builtin_descriptor");


Re: [PATCH] Avoid emitting "sizetype" type names into .debug_info (PR debug/80263)

2017-04-03 Thread Pedro Alves
Hi Jakub,

On 04/01/2017 01:27 PM, Jakub Jelinek wrote:

> 2017-04-01  Jakub Jelinek  
> 
>   PR debug/80263
>   * dwarf2out.c (modified_type_die): Try harder not to emit internal
>   sizetype type into debug info.
> 
>   * gcc.dg/debug/dwarf2/pr80263.c: New test.

Thanks much for the fix.

I've run gdb's testsuite against GCC trunk with this patch,
and found no regressions.

Thanks,
Pedro Alves



Re: [PATCH] Avoid emitting "sizetype" type names into .debug_info (PR debug/80263)

2017-04-03 Thread Pedro Alves
On 04/03/2017 12:11 PM, Pedro Alves wrote:
> Hi Jakub,
> 
> On 04/01/2017 01:27 PM, Jakub Jelinek wrote:
> 
>> 2017-04-01  Jakub Jelinek  
>>
>>  PR debug/80263
>>  * dwarf2out.c (modified_type_die): Try harder not to emit internal
>>  sizetype type into debug info.
>>
>>  * gcc.dg/debug/dwarf2/pr80263.c: New test.
> 
> Thanks much for the fix.
> 
> I've run gdb's testsuite against GCC trunk with this patch,
> and found no regressions.

Oh, and I forgot to mention for the archives that I had
confirmed that the testcase at:

 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80263#c1

starts working correctly with this patch too.

Thanks,
Pedro Alves



[PATCH] ARM: Introduce ARM_DEFAULT_SHORT_ENUMS

2017-04-03 Thread Sebastian Huber
Allow targets to define the default for the short enums option.

gcc/

* config/arm/arm.c: (ARM_DEFAULT_SHORT_ENUMS): Provide default
definition.
* config/arm/rtems.h (ARM_DEFAULT_SHORT_ENUMS) Define.
---
 gcc/config/arm/arm.c   | 6 +-
 gcc/config/arm/rtems.h | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index b24143e..33d3834 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -26547,11 +26547,15 @@ arm_promote_function_mode (const_tree type 
ATTRIBUTE_UNUSED,
 }
 
 /* AAPCS based ABIs use short enums by default.  */
+#ifndef ARM_DEFAULT_SHORT_ENUMS
+#define ARM_DEFAULT_SHORT_ENUMS \
+  (TARGET_AAPCS_BASED && arm_abi != ARM_ABI_AAPCS_LINUX)
+#endif
 
 static bool
 arm_default_short_enums (void)
 {
-  return TARGET_AAPCS_BASED && arm_abi != ARM_ABI_AAPCS_LINUX;
+  return ARM_DEFAULT_SHORT_ENUMS;
 }
 
 
diff --git a/gcc/config/arm/rtems.h b/gcc/config/arm/rtems.h
index 53cd987..b34bbe8 100644
--- a/gcc/config/arm/rtems.h
+++ b/gcc/config/arm/rtems.h
@@ -27,3 +27,5 @@
builtin_assert ("system=rtems");\
TARGET_BPABI_CPP_BUILTINS();\
 } while (0)
+
+#define ARM_DEFAULT_SHORT_ENUMS false
-- 
1.8.4.5



[PATCH] Fix PR80281

2017-04-03 Thread Richard Biener

The following fixes PR80281.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2017-04-03  Richard Biener  

PR middle-end/80281
* match.pd (A + (-B) -> A - B): Make sure to preserve unsigned
arithmetic done for the negate or the plus.
* fold-const.c (split_tree): Make sure to not negate pointers.

* gcc.dg/torture/pr80281.c: New testcase.

Index: gcc/match.pd
===
--- gcc/match.pd(revision 246642)
+++ gcc/match.pd(working copy)
@@ -1153,7 +1153,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
&& tree_nop_conversion_p (type, TREE_TYPE (@1))
&& !TYPE_OVERFLOW_SANITIZED (type))
-   (minus (convert @0) (convert @1
+   (with
+{
+ tree t1 = type;
+ if (INTEGRAL_TYPE_P (type)
+&& TYPE_OVERFLOW_WRAPS (type) != TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
+   t1 = TYPE_OVERFLOW_WRAPS (type) ? type : TREE_TYPE (@1);
+}
+(convert (minus (convert:t1 @0) (convert:t1 @1))
  /* A - (-B) -> A + B */
  (simplify
   (minus (convert1? @0) (convert2? (negate @1)))
Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 246642)
+++ gcc/fold-const.c(working copy)
@@ -831,8 +831,12 @@ split_tree (location_t loc, tree in, tre
   /* Now do any needed negations.  */
   if (neg_litp_p)
*minus_litp = *litp, *litp = 0;
-  if (neg_conp_p)
-   *conp = negate_expr (*conp);
+  if (neg_conp_p && *conp)
+   {
+ /* Convert to TYPE before negating.  */
+ *conp = fold_convert_loc (loc, type, *conp);
+ *conp = negate_expr (*conp);
+   }
   if (neg_var_p && var)
{
  /* Convert to TYPE before negating.  */
@@ -859,7 +863,12 @@ split_tree (location_t loc, tree in, tre
*minus_litp = *litp, *litp = 0;
   else if (*minus_litp)
*litp = *minus_litp, *minus_litp = 0;
-  *conp = negate_expr (*conp);
+  if (*conp)
+   {
+ /* Convert to TYPE before negating.  */
+ *conp = fold_convert_loc (loc, type, *conp);
+ *conp = negate_expr (*conp);
+   }
   if (var)
{
  /* Convert to TYPE before negating.  */
Index: gcc/testsuite/gcc.dg/torture/pr80281.c
===
--- gcc/testsuite/gcc.dg/torture/pr80281.c  (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr80281.c  (working copy)
@@ -0,0 +1,14 @@
+/* { dg-run } */
+/* { dg-require-effective-target int32plus } */
+
+int
+main ()
+{
+  volatile int a = 0;
+  long long b = 2147483648LL;
+  int c = a % 2;
+  int x = ((int) -b + c) % -2147483647;
+  if (x != -1)
+__builtin_abort ();
+  return 0;
+}


Re: C++ PATCH to fix ICE in replace_placeholders_r (PR c++/79937)

2017-04-03 Thread Marek Polacek
Ping.  Any ideas how to move this forward?

On Fri, Mar 24, 2017 at 05:22:00PM +0100, Marek Polacek wrote:
> On Thu, Mar 23, 2017 at 05:09:58PM -0400, Jason Merrill wrote:
> > On Thu, Mar 23, 2017 at 4:34 PM, Marek Polacek  wrote:
> > > On Tue, Mar 14, 2017 at 02:34:30PM -0400, Jason Merrill wrote:
> > >> On Tue, Mar 14, 2017 at 2:33 PM, Jason Merrill  wrote:
> > >> > On Tue, Mar 7, 2017 at 12:10 PM, Marek Polacek  
> > >> > wrote:
> > >> >> In this testcase we have
> > >> >> C c = bar (X{1});
> > >> >> which store_init_value sees as
> > >> >> c = TARGET_EXPR  > >> >> .n=(&)->i}>)>
> > >> >> i.e. we're initializing "c" with a TARGET_EXPR.  We call 
> > >> >> replace_placeholders
> > >> >> that walks the whole tree to substitute the placeholders.  Eventually 
> > >> >> we find
> > >> >> the nested  but that's for another object, 
> > >> >> so we
> > >> >> crash.  Seems that we shouldn't have stepped into the second 
> > >> >> TARGET_EXPR at
> > >> >> all; it has nothing to with "c", it's bar's argument.
> > >> >>
> > >> >> It occurred to me that we shouldn't step into CALL_EXPRs and leave the
> > >> >> placeholders in function arguments to cp_gimplify_init_expr which 
> > >> >> calls
> > >> >> replace_placeholders for constructors.  Not sure if it's enough to 
> > >> >> handle
> > >> >> CALL_EXPRs like this, anything else?
> > >> >
> > >> > Hmm, we might have a DMI containing a call with an argument referring
> > >> > to *this, i.e.
> > >> >
> > >> > struct A
> > >> > {
> > >> >   int i;
> > >> >   int j = frob (this->i);
> > >> > };
> > >> >
> > >> > The TARGET_EXPR seems like a more likely barrier, but even there we
> > >> > could have something like
> > >> >
> > >> > struct A { int i; };
> > >> > struct B
> > >> > {
> > >> >   int i;
> > >> >   A a = A{this->i};
> > >> > };
> > >> >
> > >> > I think we need replace_placeholders to keep a stack of objects, so
> > >> > that when we see a TARGET_EXPR we add it to the stack and therefore
> > >> > can properly replace a PLACEHOLDER_EXPR of its type.
> > >>
> > >> Or actually, avoid replacing such a PLACEHOLDER_EXPR, but rather leave
> > >> it for later when we lower the TARGET_EXPR.
> > >
> > > Sorry, I don't really follow.  I have a patch that puts TARGET_EXPRs on
> > > a stack, but I don't know how that helps.  E.g. with nsdmi-aggr3.C
> > > we have
> > > B b = TARGET_EXPR  > > &>}>
> > > so when we get to that PLACEHOLDER_EXPR, on the stack there's
> > > TARGET_EXPR with type struct A
> > > TARGET_EXPR with type struct B
> > > so the type of the PLACEHOLDER_EXPR doesn't match the type of the current
> > > TARGET_EXPR, but we still want to replace it in this case.
> > >
> > > So -- could you expand a bit on what you had in mind, please?
> > 
> > So then when we see a placeholder, we walk the stack to find the
> > object of the matching type.
> > 
> > But if the object we find was collected from walking through a
> > TARGET_EXPR, we should leave the PLACEHOLDER_EXPR alone, so that it
> > can be replaced later with the actual target of the initialization.
> 
> Unfortunately, I still don't understand; guess I'll have to drop this PR.
> 
> With this we put TARGET_EXPRs on a stack, and then when we find a
> PLACEHOLDER_EXPR we walk the stack to find a TARGET_EXPR of the same type as
> the PLACEHOLDER_EXPR.  There are three simplified examples I've been playing
> with:
> 
>   B b = T_E >}>
> 
>   - here we should replace the P_E; on the stack there are two
> TARGET_EXPRs of types B and A
> 
>   C c = T_E >)>
> 
>   - here we shouldn't replace the P_E; on the stack there are two
> TARGET_EXPRs of types X and C
> 
>   B b = T_E }}>
> 
>   - here we should replace the P_E; on the stack there's one TARGET_EXPR
> of type B
> 
> In each case we find a TARGET_EXPR of the type of the PLACEHOLDER_EXPR, but I
> don't see how to decide which PLACEHOLDER_EXPR we should let slide.  Sorry for
> being dense...
> 
> diff --git gcc/cp/tree.c gcc/cp/tree.c
> index 2757af6..2439a00 100644
> --- gcc/cp/tree.c
> +++ gcc/cp/tree.c
> @@ -2741,8 +2741,12 @@ build_ctor_subob_ref (tree index, tree type, tree obj)
>  
>  struct replace_placeholders_t
>  {
> -  tree obj;  /* The object to be substituted for a PLACEHOLDER_EXPR.  */
> -  bool seen; /* Whether we've encountered a PLACEHOLDER_EXPR.  */
> +  /* The object to be substituted for a PLACEHOLDER_EXPR.  */
> +  tree obj;
> +  /* Whether we've encountered a PLACEHOLDER_EXPR.  */
> +  bool seen;
> +  /* A stack of TARGET_EXPRs we've found ourselves in.  */
> +  vec target_expr_stack;
>  };
>  
>  /* Like substitute_placeholder_in_expr, but handle C++ tree codes and
> @@ -2762,14 +2766,35 @@ replace_placeholders_r (tree* t, int* walk_subtrees, 
> void* data_)
>  
>switch (TREE_CODE (*t))
>  {
> +case TARGET_EXPR:
> +  d->target_expr_stack.safe_push (*t);
> +  cp_walk_tree (&TARGET_EXPR_INITIAL (*t), replace_placeholders_r, data_,
> + NULL);
> +  d->target_expr_stack.pop ();
> +  

Re: [PATCH] Fix PR80281

2017-04-03 Thread Marc Glisse

On Mon, 3 Apr 2017, Richard Biener wrote:


--- gcc/match.pd(revision 246642)
+++ gcc/match.pd(working copy)
@@ -1153,7 +1153,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
   && tree_nop_conversion_p (type, TREE_TYPE (@1))
   && !TYPE_OVERFLOW_SANITIZED (type))
-   (minus (convert @0) (convert @1
+   (with
+{
+ tree t1 = type;
+ if (INTEGRAL_TYPE_P (type)
+&& TYPE_OVERFLOW_WRAPS (type) != TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
+   t1 = TYPE_OVERFLOW_WRAPS (type) ? type : TREE_TYPE (@1);
+}
+(convert (minus (convert:t1 @0) (convert:t1 @1))


Why do we match
(plus:c (convert1? @0) (convert2? (negate @1)))
instead of the simpler
(plus:c @0 (convert? (negate @1)))


 /* A - (-B) -> A + B */


Actually, I believe this transformation has issues as well, it seems 
possible to transform X-INT_MIN into X+INT_MIN if INT_MIN comes as 
(int)(-(unsigned)INT_MIN).


--
Marc Glisse


Re: [PATCH] Fix PR80281

2017-04-03 Thread Richard Biener
On Mon, 3 Apr 2017, Marc Glisse wrote:

> On Mon, 3 Apr 2017, Richard Biener wrote:
> 
> > --- gcc/match.pd(revision 246642)
> > +++ gcc/match.pd(working copy)
> > @@ -1153,7 +1153,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> >   (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
> >&& tree_nop_conversion_p (type, TREE_TYPE (@1))
> >&& !TYPE_OVERFLOW_SANITIZED (type))
> > -   (minus (convert @0) (convert @1
> > +   (with
> > +{
> > + tree t1 = type;
> > + if (INTEGRAL_TYPE_P (type)
> > +&& TYPE_OVERFLOW_WRAPS (type) != TYPE_OVERFLOW_WRAPS (TREE_TYPE
> > (@1)))
> > +   t1 = TYPE_OVERFLOW_WRAPS (type) ? type : TREE_TYPE (@1);
> > +}
> > +(convert (minus (convert:t1 @0) (convert:t1 @1))
> 
> Why do we match
> (plus:c (convert1? @0) (convert2? (negate @1)))
> instead of the simpler
> (plus:c @0 (convert? (negate @1)))

Hmm, historic I believe - matching forwprop code 1:1.  The convert on 
@0 is not needed indeed.

> >  /* A - (-B) -> A + B */
> 
> Actually, I believe this transformation has issues as well, it seems possible
> to transform X-INT_MIN into X+INT_MIN if INT_MIN comes as
> (int)(-(unsigned)INT_MIN).

True.  So the same fix applies to this variant.

I'm re-testing the following variant.

Richard.

2017-04-03  Richard Biener  

PR middle-end/80281
* match.pd (A + (-B) -> A - B): Make sure to preserve unsigned
arithmetic done for the negate or the plus.  Simplify.
(A - (-B) -> A + B): Likewise.
* fold-const.c (split_tree): Make sure to not negate pointers.

* gcc.dg/torture/pr80281.c: New testcase.

Index: gcc/match.pd
===
--- gcc/match.pd(revision 246648)
+++ gcc/match.pd(working copy)
@@ -1148,19 +1148,31 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  /* Contract negates.  */
  /* A + (-B) -> A - B */
  (simplify
-  (plus:c (convert1? @0) (convert2? (negate @1)))
-  /* Apply STRIP_NOPS on @0 and the negate.  */
-  (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
-   && tree_nop_conversion_p (type, TREE_TYPE (@1))
+  (plus:c @0 (convert? (negate @1)))
+  /* Apply STRIP_NOPS on the negate.  */
+  (if (tree_nop_conversion_p (type, TREE_TYPE (@1))
&& !TYPE_OVERFLOW_SANITIZED (type))
-   (minus (convert @0) (convert @1
+   (with
+{
+ tree t1 = type;
+ if (INTEGRAL_TYPE_P (type)
+&& TYPE_OVERFLOW_WRAPS (type) != TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
+   t1 = TYPE_OVERFLOW_WRAPS (type) ? type : TREE_TYPE (@1);
+}
+(convert (minus (convert:t1 @0) (convert:t1 @1))
  /* A - (-B) -> A + B */
  (simplify
-  (minus (convert1? @0) (convert2? (negate @1)))
-  (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
-   && tree_nop_conversion_p (type, TREE_TYPE (@1))
+  (minus @0 (convert? (negate @1)))
+  (if (tree_nop_conversion_p (type, TREE_TYPE (@1))
&& !TYPE_OVERFLOW_SANITIZED (type))
-   (plus (convert @0) (convert @1
+   (with
+{
+ tree t1 = type;
+ if (INTEGRAL_TYPE_P (type)
+&& TYPE_OVERFLOW_WRAPS (type) != TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
+   t1 = TYPE_OVERFLOW_WRAPS (type) ? type : TREE_TYPE (@1);
+}
+(convert (plus (convert:t1 @0) (convert:t1 @1))
  /* -(-A) -> A */
  (simplify
   (negate (convert? (negate @1)))
Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 246648)
+++ gcc/fold-const.c(working copy)
@@ -831,8 +831,12 @@ split_tree (location_t loc, tree in, tre
   /* Now do any needed negations.  */
   if (neg_litp_p)
*minus_litp = *litp, *litp = 0;
-  if (neg_conp_p)
-   *conp = negate_expr (*conp);
+  if (neg_conp_p && *conp)
+   {
+ /* Convert to TYPE before negating.  */
+ *conp = fold_convert_loc (loc, type, *conp);
+ *conp = negate_expr (*conp);
+   }
   if (neg_var_p && var)
{
  /* Convert to TYPE before negating.  */
@@ -859,7 +863,12 @@ split_tree (location_t loc, tree in, tre
*minus_litp = *litp, *litp = 0;
   else if (*minus_litp)
*litp = *minus_litp, *minus_litp = 0;
-  *conp = negate_expr (*conp);
+  if (*conp)
+   {
+ /* Convert to TYPE before negating.  */
+ *conp = fold_convert_loc (loc, type, *conp);
+ *conp = negate_expr (*conp);
+   }
   if (var)
{
  /* Convert to TYPE before negating.  */
Index: gcc/testsuite/gcc.dg/torture/pr80281.c
===
--- gcc/testsuite/gcc.dg/torture/pr80281.c  (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr80281.c  (working copy)
@@ -0,0 +1,14 @@
+/* { dg-run } */
+/* { dg-require-effective-target int32plus } */
+
+int
+main ()
+{
+  volatile int a = 0;
+  long long b = 2147483648LL;
+  int c = a % 2;
+  int x = ((int) -b + c) % -2147483647;
+  if (x != -1)
+__builtin

[RFC]: Fix Ada boostrap failure on S/390 with -mzarch

2017-04-03 Thread Andreas Krebbel
Hi Eric,

I ran into a similiar problem as PR80117 on S/390 starting with your
patch merging the system*.ads files for some biarch plattforms.
Starting with that change GCC does not bootstrap on S/390 when
configured with --with-mode=zarch.

On S/390 UNITS_PER_WORD is:
8 with -m64
4 with -m31
8 with -m31 -mzarch

This has been chosen to support use of 64 bit registers also in 32 bit
code.  Code compiled with -m31 -mzarch is supposed to adhere to the 32
bit ABI.  In order to make that work it was required to prevent
UNITS_PER_WORD from being used in ABI-relevant contexts.  That's why
Ulrich added the TARGET_UNWIND_WORD_MODE in 2008 (for SPU).

More target hooks were needed for UNITS_PER_WORD uses in libgcc:
TARGET_LIBGCC_CMP_RETURN_MODE, and TARGET_LIBGCC_SHIFT_COUNT_MODE.

The use of the UNITS_PER_WORD in the system.ads files looks like
adding another ABI/API-relevant use to me.

Now I could either fix this by reverting that change for S/390
(similiar to what Andreas Schwab did to fix the BZ) or I could just
use the size of the long data type (as we do in the ABI-relevant parts
of the backend as well).  Which one do you prefer?

Bye,

-Andreas-



diff --git a/gcc/ada/system-linux-s390.ads b/gcc/ada/system-linux-s390.ads
index 485a8de..144c46d 100644
--- a/gcc/ada/system-linux-s390.ads
+++ b/gcc/ada/system-linux-s390.ads
@@ -69,7 +69,7 @@ package System is
Null_Address : constant Address;
 
Storage_Unit : constant := 8;
-   Word_Size: constant := Standard'Word_Size;
+   Word_Size: constant := Long_Integer'Size;
Memory_Size  : constant := 2 ** Word_Size;
 
--  Address comparison



Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types

2017-04-03 Thread Peter Bergner
On 4/2/17 1:53 PM, Segher Boessenkool wrote:
> On Sun, Apr 02, 2017 at 09:48:36AM -0500, Peter Bergner wrote:
>> On 4/2/17 2:29 AM, Andreas Schwab wrote:
 +/* { dg-require-effective-target dfp } */
>> [snip]
>>> FAIL: gcc.target/powerpc/pr80246.c (test for excess errors)
>>> Excess errors:
>>> /daten/gcc/gcc-20170401/gcc/testsuite/gcc.target/powerpc/pr80246.c:18:10:
>>>  error: Builtin function __builtin_dxex requires the -mhard-dfp option
>>
>> What configure options are you using?  I would have expected this the
>> dg-require-effective-target to disable this test if you don't have
>> -mhard-dfp.
> 
> This should test hard_dfp instead of dfp.  

Ah, yes, dfp is just support for they DFP types.  I'll make that
change and commit it.



> I also have a fix for the dfp-builtin-1.c problem.

You mean you have a patch to the regex to match both std/stw and ld/lwz?



> Still pondering what to do about the last one, fold-vec-mule-misc.c:
> vsx_ok is pretty useless, or confusingly named at least.

Ummm, how would my patch have affected that FAIL, as it doesn't use
any _Decimal* types, let alone the dxex* or diex* patterns that I
changed?

Peter



Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types

2017-04-03 Thread Peter Bergner
On 4/3/17 9:41 AM, Peter Bergner wrote:
> On 4/2/17 1:53 PM, Segher Boessenkool wrote:
>> I also have a fix for the dfp-builtin-1.c problem.
> 
> You mean you have a patch to the regex to match both std/stw and ld/lwz?

I think we should also add:

  /* { dg-require-effective-target hard_dfp } */

to the dfp-builtin-1.c requirements, since I think someone could do
-mno-hard-dfp while also having VSX enabled.  Ditto for dfp-builtin-2.c.

Peter



Re: [PATCH 4/9] libstdc++ changes for ia16

2017-04-03 Thread Jonathan Wakely

On 01/04/17 17:48 +0100, Andrew Jenner wrote:

* src/c++11/cow-stdexcept.cc (_ITM_RU2): Declare.
(txnal_read_ptr): Allow 16-bit pointers.
* src/c++11/codecvt.cc (read_utf8_code_point): Handle 16-bit int.


OK for Stage 1, thanks.





Re: [PATCH 0/9] New back end ia16: 16-bit Intel x86

2017-04-03 Thread Jeff Law

On 04/01/2017 10:47 AM, Andrew Jenner wrote:

About 10 years ago, Rask Ingemann Lambertsen sent a patch series to add
a 16-bit x86 (i.e. 8088, 8086, 80186 and 80286 CPUs) back end. This work
was never committed. Recently I've been doing some work on this back
end, and today we released a Sourcery CodeBench Lite distribution based
on it (see
https://blogs.mentor.com/embedded/blog/2017/04/01/announcing-sourcery-codebench-lite-for-ia16/
). Given this, I thought it would be a good idea to send these patches
upstream today (though obviously if I commit these it won't be until
we're in Stage 1 and more testing has been done on the middle-end changes).

I have not been able to contact Rask Ingemann Lambertsen, but he does
have a copyright assignment for GCC on file (dated 2006-11-16) so I do
not believe there are any copyright assignment issues that would block
this.
Note that with the trunk in stage4 and a release rapidly approaching, 
it's unlikely that anyone will be looking in depth at this until after 
the release branch is cut.


jeff



Re: [PATCH 7/9] ira-color

2017-04-03 Thread Jeff Law

On 04/01/2017 11:21 AM, Gerald Pfeifer wrote:

On Sat, 1 Apr 2017, Andrew Jenner wrote:

In the course of working with ia16, I found a case where the
sorted_allocnos
array in ira-color.c requires more than ira_allocnos_num entries. The
following patch allows this array to expand when this happens.

2017-04-01  Andrew Jenner  

* ira-color.c (n_sorted_allocnos): New variable.
(improve_allocation): Use it.
(ira_initiate_assign): Initialize it.
(fast_allocation): Likewise.


General improvements/fixes like this you may want to submit independently
of your port and copy the respective maintainers (such as Vladimir for
register allocation who I'm adding now).
Right.  ANd it would be helpful to have more information on how this 
happened.  Otherwise Vlad and the rest of the team have to guess what 
might have happened -- we might guess wrong leading to an incorrect 
conclusion about the correctness of the patch.


Testcases help considerably as well.

jeff



Re: [PATCH 5/9] libstdc++ testsuite changes

2017-04-03 Thread Jonathan Wakely

On 01/04/17 17:48 +0100, Andrew Jenner wrote:

Index: libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc
===
--- libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc   (revision 
475331)
+++ libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc   (revision 
475455)
@@ -18,20 +18,22 @@
// 25.3.2 [lib.alg.nth.element]

// { dg-options "-std=gnu++11" }
+// { dg-require-effective-target stdint_types }

#include 
#include 
#include 
#include 
+#include 

using __gnu_test::test_container;
using __gnu_test::random_access_iterator_wrapper;

-typedef test_container Container;
+typedef test_container 
Container;

void test01()
{
-  std::vector v = {
+  std::vector v = {


We could just use long here, but this is OK too.


207089,
202585,
180067,




Index: libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc
===
--- libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc  
(revision 475331)
+++ libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc  
(revision 475455)
@@ -75,6 +75,6 @@ case_labels(bitmask_type b)
case ~__INT_MAX__:
  break;
}
-  static_assert( sizeof(std::underlying_type_t) == sizeof(int),
+  static_assert( sizeof(std::underlying_type_t) >= sizeof(int),
  "underlying type has same range of values as int");
}


We need to be careful here.

This check is ensuring there is no undefined behaviour in
.

Same for ...


Index: libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc
===
--- libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc  
(revision 475331)
+++ libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc  
(revision 475455)
@@ -51,6 +51,6 @@ case_labels(bitmask_type b)
case ~__INT_MAX__:
  break;
}
-  static_assert( sizeof(std::underlying_type_t) == sizeof(int),
+  static_assert( sizeof(std::underlying_type_t) >= sizeof(int),
  "underlying type has same range of values as int");
}
Index: libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc
===
--- libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc   
(revision 475331)
+++ libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc   
(revision 475455)
@@ -47,6 +47,6 @@ case_labels(bitmask_type b)
case ~__INT_MAX__:
  break;
}
-  static_assert( sizeof(std::underlying_type_t) == sizeof(int),
+  static_assert( sizeof(std::underlying_type_t) >= sizeof(int),
  "underlying type has same range of values as int");
}


If the target uses a larger size for these enumerations then we need
to be sure the code is still correct, not just adjust the tests.

 enum _Ios_Fmtflags 
   { 
 ...

 _S_ios_fmtflags_end = 1L << 16,
 _S_ios_fmtflags_max = __INT_MAX__,
 _S_ios_fmtflags_min = ~__INT_MAX__
   };

 inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
 operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
 { return _Ios_Fmtflags(static_cast(__a) & static_cast(__b)); }

...

 inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
 operator~(_Ios_Fmtflags __a)
 { return _Ios_Fmtflags(~static_cast(__a)); }

I think the operations and casts are still valid if the type is larger
than int. If not, we could replace __INT_MAX__ with __LONG_MAX__ when
defined(__ia16__) and then use long for the static_cast conversions.




Index: libstdc++-v3/testsuite/27_io/basic_stringbuf/setbuf/wchar_t/4.cc
===
--- libstdc++-v3/testsuite/27_io/basic_stringbuf/setbuf/wchar_t/4.cc
(revision 475331)
+++ libstdc++-v3/testsuite/27_io/basic_stringbuf/setbuf/wchar_t/4.cc
(revision 475455)
@@ -19,7 +19,7 @@

// 27.8.1.4 Overridden virtual functions

-// { dg-options "-DMAX_SIZE=4096" { target simulator } }
+// { dg-options "-DMAX_SIZE=4096" { target { simulator || ia16-*-* } } }

#ifndef MAX_SIZE
#define MAX_SIZE (1 << 18)
Index: libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc
===
--- libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc 
(revision 475331)
+++ libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc 
(revision 475455)
@@ -50,7 +50,11 @@ check(wistream& stream, const wstring& s
{
  bool test __attribute__((unused)) = true;

+#ifdef __ia16__
+  static wchar_t buf[1000];
+#else
  static wchar_t buf[100];
+#endif


Hmm, I guess this can't use { target { simulator || ia16-*-* } } to
reduce the MAX_LENGTH instead, because this array would still be too
large for ia16. OK.


  wstring::size_type index = 0, index_new = 0;
  unsigned n = 0;

Index: 
libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc
==

Re: [v3 PATCH] Implement std::is_aggregate.

2017-04-03 Thread Jonathan Wakely

On 02/04/17 15:08 +0300, Ville Voutilainen wrote:

   Implement std::is_aggregate.
   * include/std/type_traits (is_aggregate, is_aggregate_v): New.
   * testsuite/20_util/is_aggregate/requirements/explicit_instantiation.cc:
   New.
   * testsuite/20_util/is_aggregate/requirements/typedefs.cc: Likewise.
   * testsuite/20_util/is_aggregate/value.cc: Likewise.



diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index 6707caa..a5e7048 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -3062,6 +3062,25 @@ template 
#endif
#undef _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP

+#ifdef __has_builtin
+# if !__has_builtin(__is_aggregate)
+// Try not to break non-GNU compilers that don't support the built-in:
+#  define _GLIBCXX_NO_BUILTIN_IS_AGGREGATE 1
+# endif
+#endif
+
+#ifndef _GLIBCXX_NO_BUILTIN_IS_AGGREGATE
+#define __cpp_lib_is_aggregate 201703
+  /// is_aggregate
+  template
+struct is_aggregate
+: bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { };


Blank line here please.


+  /// is_aggregate_v
+  template
+inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
+#endif
+#undef _GLIBCXX_NO_BUILTIN_IS_AGGREGATE
+
#endif // C++17


OK for trunk, thanks.




Re: [v3 PATCH] PR libstdc++/79141

2017-04-03 Thread Jonathan Wakely

On 02/04/17 02:45 +0300, Ville Voutilainen wrote:

   PR libstdc++/79141
   * include/bits/stl_pair.h (__wrap_nonesuch): New.
   (operator=(typename conditional<
   __and_,
   is_copy_assignable<_T2>>::value,
   const pair&, const __wrap_nonesuch&>::type)): Change __nonesuch
   to __wrap_nonesuch.
   (operator=(typename conditional<
   __not_<__and_,
   is_copy_assignable<_T2>>>::value,
   const pair&, const __nonesuch&>::type)): Likewise.
   (operator=(typename conditional<
   __and_,
   is_move_assignable<_T2>>::value,
   pair&&, __wrap_nonesuch&&>::type)): Likewise.
   * testsuite/20_util/pair/79141.cc: New.



diff --git a/libstdc++-v3/include/bits/stl_pair.h 
b/libstdc++-v3/include/bits/stl_pair.h
index 7c7cee2..b746fb4 100644
--- a/libstdc++-v3/include/bits/stl_pair.h
+++ b/libstdc++-v3/include/bits/stl_pair.h
@@ -179,6 +179,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  }
  };

+  struct __wrap_nonesuch : std::__nonesuch {
+explicit __wrap_nonesuch(const __nonesuch&) = delete;
+  };


Could you please add a comment explaining that this is needed to
ensure that functions with parameters of this type are not viable when
an argument of {} is used. Because even with such a comment I'll
probably not understand this by next week.

And I think __explicit_nonesuch or __no_list_init would be a clearer
name. We're not really "wrapping" this, unless I misunderstand.

OK for trunk, I suppose.


This kind of thing is why I want to burn std::pair and std::tuple to
the ground.




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

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

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

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

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



Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types

2017-04-03 Thread Peter Bergner
On 4/2/17 1:53 PM, Segher Boessenkool wrote:
> I also have a fix for the dfp-builtin-1.c problem.

Something like the following maybe?  It seems to work for me.
I think the hard_dfp predicate was added after the dfp-builtin-[12].c
test cases were added, which is maybe why Mike used powerpc_vsx_ok?
Seems like we should switch it to using hard_dfp now.

Peter


Index: dfp-builtin-1.c
===
--- dfp-builtin-1.c (revision 246648)
+++ dfp-builtin-1.c (working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { powerpc*-*-linux* } } } */
-/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-require-effective-target hard_dfp } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { 
"-mcpu=power7" } } */
 /* { dg-options "-mcpu=power7 -O2" } */
 /* { dg-final { scan-assembler-times "ddedpd " 4} } */
@@ -8,8 +8,10 @@
 /* { dg-final { scan-assembler-times "diex "   1} } */
 /* { dg-final { scan-assembler-times "dscli "  2} } */
 /* { dg-final { scan-assembler-times "dscri "  2} } */
-/* { dg-final { scan-assembler-times "std "1} } */
-/* { dg-final { scan-assembler-times "ld " 1} } */
+/* { dg-final { scan-assembler-times "std "1{ target lp64 } } } */
+/* { dg-final { scan-assembler-times "ld " 1{ target lp64 } } } */
+/* { dg-final { scan-assembler-times "stw "2{ target ilp32 } } } */
+/* { dg-final { scan-assembler-times "lwz "2{ target ilp32 } } } */
 /* { dg-final { scan-assembler-times "stfd "   1} } */
 /* { dg-final { scan-assembler-times "lfd "1} } */
 /* { dg-final { scan-assembler-not   "bl __builtin" } } */
Index: dfp-builtin-2.c
===
--- dfp-builtin-2.c (revision 246648)
+++ dfp-builtin-2.c (working copy)
@@ -1,7 +1,6 @@
 /* { dg-do compile { target { powerpc*-*-linux* } } } */
-/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
-/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 /* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-require-effective-target hard_dfp } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { 
"-mcpu=power7" } } */
 /* { dg-options "-mcpu=power7 -O2" } */
 /* { dg-final { scan-assembler-times "ddedpdq " 4} } */




Re: [RFC]: Fix Ada boostrap failure on S/390 with -mzarch

2017-04-03 Thread Eric Botcazou
> On S/390 UNITS_PER_WORD is:
> 8 with -m64
> 4 with -m31
> 8 with -m31 -mzarch
> 
> This has been chosen to support use of 64 bit registers also in 32 bit
> code.  Code compiled with -m31 -mzarch is supposed to adhere to the 32
> bit ABI.  In order to make that work it was required to prevent
> UNITS_PER_WORD from being used in ABI-relevant contexts.  That's why
> Ulrich added the TARGET_UNWIND_WORD_MODE in 2008 (for SPU).

We do that for 32-bit SPARC on Solaris (-mv8plus) but UNITS_PER_WORD is 4.

> Now I could either fix this by reverting that change for S/390
> (similiar to what Andreas Schwab did to fix the BZ) or I could just
> use the size of the long data type (as we do in the ABI-relevant parts
> of the backend as well).  Which one do you prefer?

Having System.Word_Size != Standard'Word_Size is a bit disturbing.  Does it 
work to change only Memory_Size to 2 ** Long_Integer'Size?  This will also 
correct the definition of Address below.

-- 
Eric Botcazou


Re: [v3 PATCH] PR libstdc++/79141

2017-04-03 Thread Jonathan Wakely

On 03/04/17 16:43 +0100, Jonathan Wakely wrote:

On 02/04/17 02:45 +0300, Ville Voutilainen wrote:

  PR libstdc++/79141
  * include/bits/stl_pair.h (__wrap_nonesuch): New.
  (operator=(typename conditional<
  __and_,
  is_copy_assignable<_T2>>::value,
  const pair&, const __wrap_nonesuch&>::type)): Change __nonesuch
  to __wrap_nonesuch.
  (operator=(typename conditional<
  __not_<__and_,
  is_copy_assignable<_T2>>>::value,
  const pair&, const __nonesuch&>::type)): Likewise.
  (operator=(typename conditional<
  __and_,
  is_move_assignable<_T2>>::value,
  pair&&, __wrap_nonesuch&&>::type)): Likewise.
  * testsuite/20_util/pair/79141.cc: New.



diff --git a/libstdc++-v3/include/bits/stl_pair.h 
b/libstdc++-v3/include/bits/stl_pair.h
index 7c7cee2..b746fb4 100644
--- a/libstdc++-v3/include/bits/stl_pair.h
+++ b/libstdc++-v3/include/bits/stl_pair.h
@@ -179,6 +179,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }
 };

+  struct __wrap_nonesuch : std::__nonesuch {
+explicit __wrap_nonesuch(const __nonesuch&) = delete;
+  };


Could you please add a comment explaining that this is needed to
ensure that functions with parameters of this type are not viable when
an argument of {} is used. Because even with such a comment I'll
probably not understand this by next week.

And I think __explicit_nonesuch or __no_list_init would be a clearer
name. We're not really "wrapping" this, unless I misunderstand.

OK for trunk, I suppose.


Oh, and gcc-6-branch.



Re: [PATCH] Bump the default thread stack size on Darwin in libgomp (PR libgomp/79876)

2017-04-03 Thread Jeff Law

On 04/01/2017 06:24 AM, Jakub Jelinek wrote:

Hi!

Apparently Darwin has insane default stack size for pthread_create
unless overridden through pthread_attr_setstacksize - 512kB, compared e.g.
to Linux usual default of around 8MB.  For typical OpenMP uses that is way
too low, so the following patch is an attempt to bump it to 2MB just on
Darwin, and on other targets keep the default.  Everything can be in any
case overridden through {,G}OMP_STACKSIZE env variables.

Bootstrapped/regtested on x86_64-linux and i686-linux, can anyone please test it
on darwin?

2017-04-01  Jakub Jelinek  

PR libgomp/79876
* config/posix/thread-stacksize.h: New file.
* config/darwin/thread-stacksize.h: New file.
* config/nvptx/thread-stacksize.h: New file.
* env.c: Include thread-stacksize.h.
(initialize_env): Initialize stacksize to GOMP_DEFAULT_STACKSIZE
instead of 0.  Call pthread_attr_setstacksize even if
GOMP_DEFAULT_STACKSIZE is non-zero.
I've got a build started, but it's on an ancient macbook pro, so it'll 
take a long time.  Someone else with modern hardware could certainly get 
this done faster :-)


jeff



Re: [PATCH] Bump the default thread stack size on Darwin in libgomp (PR libgomp/79876)

2017-04-03 Thread Jakub Jelinek
On Mon, Apr 03, 2017 at 10:56:13AM -0600, Jeff Law wrote:
> On 04/01/2017 06:24 AM, Jakub Jelinek wrote:
> > Apparently Darwin has insane default stack size for pthread_create
> > unless overridden through pthread_attr_setstacksize - 512kB, compared e.g.
> > to Linux usual default of around 8MB.  For typical OpenMP uses that is way
> > too low, so the following patch is an attempt to bump it to 2MB just on
> > Darwin, and on other targets keep the default.  Everything can be in any
> > case overridden through {,G}OMP_STACKSIZE env variables.
> > 
> > Bootstrapped/regtested on x86_64-linux and i686-linux, can anyone please 
> > test it
> > on darwin?
> > 
> > 2017-04-01  Jakub Jelinek  
> > 
> > PR libgomp/79876
> > * config/posix/thread-stacksize.h: New file.
> > * config/darwin/thread-stacksize.h: New file.
> > * config/nvptx/thread-stacksize.h: New file.
> > * env.c: Include thread-stacksize.h.
> > (initialize_env): Initialize stacksize to GOMP_DEFAULT_STACKSIZE
> > instead of 0.  Call pthread_attr_setstacksize even if
> > GOMP_DEFAULT_STACKSIZE is non-zero.
> I've got a build started, but it's on an ancient macbook pro, so it'll take
> a long time.  Someone else with modern hardware could certainly get this
> done faster :-)

Dominique has already tested it on Darwin 16 and said he'll test on Darwin
10; I'm waiting for those results.

Jakub


Re: [PATCH] simplify-rtx: Fix compare of comparisons (PR60818)

2017-04-03 Thread Jeff Law

On 03/31/2017 03:40 PM, Segher Boessenkool wrote:

The function simplify_binary_operation_1 has code that does
/* Convert (compare (gt (flags) 0) (lt (flags) 0)) to (flags).  */
but this transformation is only valid if "flags" has the same machine
mode as the outer compare.  This fixes it.

Bootstrapped and tested on powerpc64-linux {-m32,-m64} (and tested the
new testcase with {-m32,-m64}{,-misel}).  Is this okay for trunk?


Segher


2017-03-31  Segher Boessenkool  

PR rtl-optimization/60818
* simplify-rtx.c (simplify_binary_operation_1): Do not replace
a compare of comparisons with the thing compared if this results
in a different machine mode.

gcc/testsuite/
PR rtl-optimization/60818
* gcc.c-torture/compile/pr60818.c: New testcase.
Doesn't seem like a regression.  But I can't see how it could possibly 
result in any correctness issues -- the absolute worst would be a 
performance issue and even that seems highly unlikely.


OK for the trunk if you think it's worth fixing for gcc-7.  Else it's 
pre-approved for gcc-8.



jeff



Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types

2017-04-03 Thread Peter Bergner
On 4/3/17 11:04 AM, Peter Bergner wrote:
> On 4/2/17 1:53 PM, Segher Boessenkool wrote:
>> I also have a fix for the dfp-builtin-1.c problem.
> 
> Something like the following maybe?  It seems to work for me.
> I think the hard_dfp predicate was added after the dfp-builtin-[12].c
> test cases were added, which is maybe why Mike used powerpc_vsx_ok?
> Seems like we should switch it to using hard_dfp now.

As we discussed offline, I'll commit the following patch to fix up
the dfp-builtin-1.c failures.  I'll also commit this to the GCC 5 & 6
release branches, since the same issue exists there.

Peter


Index: dfp-builtin-1.c
===
--- dfp-builtin-1.c (revision 246653)
+++ dfp-builtin-1.c (working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { powerpc*-*-linux* } } } */
-/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-require-effective-target hard_dfp } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { 
"-mcpu=power7" } } */
 /* { dg-options "-mcpu=power7 -O2" } */
 /* { dg-final { scan-assembler-times "ddedpd " 4} } */
@@ -8,8 +8,12 @@
 /* { dg-final { scan-assembler-times "diex "   1} } */
 /* { dg-final { scan-assembler-times "dscli "  2} } */
 /* { dg-final { scan-assembler-times "dscri "  2} } */
-/* { dg-final { scan-assembler-times "std "1} } */
-/* { dg-final { scan-assembler-times "ld " 1} } */
+/* { dg-final { scan-assembler-times "std "1{ target lp64 } } } */
+/* { dg-final { scan-assembler-times "ld " 1{ target lp64 } } } */
+/* 32-bit needs a stack frame, and needs two GPR mem insns per _Decimal64.  */
+/* { dg-final { scan-assembler-times "stwu "   2{ target ilp32 } } } */
+/* { dg-final { scan-assembler-times "stw "2{ target ilp32 } } } */
+/* { dg-final { scan-assembler-times "lwz "2{ target ilp32 } } } */
 /* { dg-final { scan-assembler-times "stfd "   1} } */
 /* { dg-final { scan-assembler-times "lfd "1} } */
 /* { dg-final { scan-assembler-not   "bl __builtin" } } */
Index: dfp-builtin-2.c
===
--- dfp-builtin-2.c (revision 246653)
+++ dfp-builtin-2.c (working copy)
@@ -1,7 +1,5 @@
 /* { dg-do compile { target { powerpc*-*-linux* } } } */
-/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
-/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
-/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-require-effective-target hard_dfp } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { 
"-mcpu=power7" } } */
 /* { dg-options "-mcpu=power7 -O2" } */
 /* { dg-final { scan-assembler-times "ddedpdq " 4} } */




Re: [PATCH] Bump the default thread stack size on Darwin in libgomp (PR libgomp/79876)

2017-04-03 Thread Jeff Law

On 04/03/2017 11:00 AM, Jakub Jelinek wrote:

On Mon, Apr 03, 2017 at 10:56:13AM -0600, Jeff Law wrote:

On 04/01/2017 06:24 AM, Jakub Jelinek wrote:

Apparently Darwin has insane default stack size for pthread_create
unless overridden through pthread_attr_setstacksize - 512kB, compared e.g.
to Linux usual default of around 8MB.  For typical OpenMP uses that is way
too low, so the following patch is an attempt to bump it to 2MB just on
Darwin, and on other targets keep the default.  Everything can be in any
case overridden through {,G}OMP_STACKSIZE env variables.

Bootstrapped/regtested on x86_64-linux and i686-linux, can anyone please test it
on darwin?

2017-04-01  Jakub Jelinek  

PR libgomp/79876
* config/posix/thread-stacksize.h: New file.
* config/darwin/thread-stacksize.h: New file.
* config/nvptx/thread-stacksize.h: New file.
* env.c: Include thread-stacksize.h.
(initialize_env): Initialize stacksize to GOMP_DEFAULT_STACKSIZE
instead of 0.  Call pthread_attr_setstacksize even if
GOMP_DEFAULT_STACKSIZE is non-zero.

I've got a build started, but it's on an ancient macbook pro, so it'll take
a long time.  Someone else with modern hardware could certainly get this
done faster :-)


Dominique has already tested it on Darwin 16 and said he'll test on Darwin
10; I'm waiting for those results.

Good.  The thought of waiting on this old box is painful to contemplate.

jeff



[PATCH] Implement P0426R1 "Constexpr for std::char_traits" for C++17 (partial)

2017-04-03 Thread Jonathan Wakely

We can't fully implement this without compiler support (see PR80265)
but this adds _GLIBCXX17_CONSTEXPR where possible.

I've left /* _GLIBCXX17_CONSTEXPR */ comments where we need to add it
once the compiler allows it.

* include/bits/char_traits.h (__gnu_cxx::char_traits): Add
_GLIBCXX14_CONSTEXPR on assign, compare, find, and length.
(std::char_traits, std::char_traits): Add
_GLIBCXX17_CONSTEXPR on assign.
(std::char_traits, std::char_traits): Add
_GLIBCXX17_CONSTEXPR on assign, compare, find, and length.
* testsuite/21_strings/char_traits/requirements/
constexpr_functions_c++17.cc: New test.

Tested powerpc64le-linux, committed to trunk.

commit c7ce2e6d809422aa7440c64f0929492fb88c7634
Author: Jonathan Wakely 
Date:   Fri Mar 31 13:36:43 2017 +0100

Implement P0426R1 "Constexpr for std::char_traits" for C++17 (partial)

* include/bits/char_traits.h (__gnu_cxx::char_traits): Add
_GLIBCXX14_CONSTEXPR on assign, compare, find, and length.
(std::char_traits, std::char_traits): Add
_GLIBCXX17_CONSTEXPR on assign.
(std::char_traits, std::char_traits): Add
_GLIBCXX17_CONSTEXPR on assign, compare, find, and length.
* testsuite/21_strings/char_traits/requirements/
constexpr_functions_c++17.cc: New test.

diff --git a/libstdc++-v3/include/bits/char_traits.h 
b/libstdc++-v3/include/bits/char_traits.h
index bcfc23a..75db5b8 100644
--- a/libstdc++-v3/include/bits/char_traits.h
+++ b/libstdc++-v3/include/bits/char_traits.h
@@ -88,7 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   typedef typename _Char_types<_CharT>::off_typeoff_type;
   typedef typename _Char_types<_CharT>::state_type  state_type;
 
-  static void
+  static _GLIBCXX14_CONSTEXPR void
   assign(char_type& __c1, const char_type& __c2)
   { __c1 = __c2; }
 
@@ -100,13 +100,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   lt(const char_type& __c1, const char_type& __c2)
   { return __c1 < __c2; }
 
-  static int
+  static _GLIBCXX14_CONSTEXPR int
   compare(const char_type* __s1, const char_type* __s2, std::size_t __n);
 
-  static std::size_t
+  static _GLIBCXX14_CONSTEXPR std::size_t
   length(const char_type* __s);
 
-  static const char_type*
+  static _GLIBCXX14_CONSTEXPR const char_type*
   find(const char_type* __s, std::size_t __n, const char_type& __a);
 
   static char_type*
@@ -139,8 +139,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { return !eq_int_type(__c, eof()) ? __c : to_int_type(char_type()); }
 };
 
+// #define __cpp_lib_constexpr_char_traits 201611
+
   template
-int
+_GLIBCXX14_CONSTEXPR int
 char_traits<_CharT>::
 compare(const char_type* __s1, const char_type* __s2, std::size_t __n)
 {
@@ -153,7 +155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }
 
   template
-std::size_t
+_GLIBCXX14_CONSTEXPR std::size_t
 char_traits<_CharT>::
 length(const char_type* __p)
 {
@@ -164,7 +166,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }
 
   template
-const typename char_traits<_CharT>::char_type*
+_GLIBCXX14_CONSTEXPR const typename char_traits<_CharT>::char_type*
 char_traits<_CharT>::
 find(const char_type* __s, std::size_t __n, const char_type& __a)
 {
@@ -238,7 +240,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   typedef streamoff off_type;
   typedef mbstate_t state_type;
 
-  static void
+  static _GLIBCXX17_CONSTEXPR void
   assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
   { __c1 = __c2; }
 
@@ -254,7 +256,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
< static_cast(__c2));
   }
 
-  static int
+  static /* _GLIBCXX17_CONSTEXPR */ int
   compare(const char_type* __s1, const char_type* __s2, size_t __n)
   {
if (__n == 0)
@@ -262,11 +264,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __builtin_memcmp(__s1, __s2, __n);
   }
 
-  static size_t
+  static /* _GLIBCXX17_CONSTEXPR */ size_t
   length(const char_type* __s)
   { return __builtin_strlen(__s); }
 
-  static const char_type*
+  static /* _GLIBCXX17_CONSTEXPR */ const char_type*
   find(const char_type* __s, size_t __n, const char_type& __a)
   {
if (__n == 0)
@@ -333,7 +335,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   typedef wstreampospos_type;
   typedef mbstate_t state_type;
 
-  static void
+  static _GLIBCXX17_CONSTEXPR void
   assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
   { __c1 = __c2; }
 
@@ -345,7 +347,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
   { return __c1 < __c2; }
 
-  static int
+  static /* _GLIBCXX17_CONSTEXPR */ int
   compare(const char_type* __s1, const char_type* __s2, size_t __n)
   {
if (__n == 0)
@@ -353,11 +355

[PATCH] Update C++17 library status table in manual

2017-04-03 Thread Jonathan Wakely

* doc/xml/manual/status_cxx2017.xml: Update C++17 status table.
* doc/xml/manual/appendix_contributing.xml (contrib.organization): Add
directories for debug, parallel and profile headers.
* doc/html/*: Regenerate.

Committed to trunk.

commit 2263ee270e922b504e7d5c1963199d8c10c2cba0
Author: Jonathan Wakely 
Date:   Fri Mar 31 14:04:02 2017 +0100

Update C++17 library status table in manual

* doc/xml/manual/status_cxx2017.xml: Update C++17 status table.
* doc/xml/manual/appendix_contributing.xml (contrib.organization): Add
directories for debug, parallel and profile headers.
* doc/html/*: Regenerate.

diff --git a/libstdc++-v3/doc/xml/manual/appendix_contributing.xml 
b/libstdc++-v3/doc/xml/manual/appendix_contributing.xml
index e967f61..dbc671e 100644
--- a/libstdc++-v3/doc/xml/manual/appendix_contributing.xml
+++ b/libstdc++-v3/doc/xml/manual/appendix_contributing.xml
@@ -285,7 +285,19 @@ It has subdirectories:
   Headers that define extensions to the standard library.  No
   standard header refers to any of them, in theory (there are some
   exceptions).
-  
+
+
+
+
+
+  include/debug,
+  include/parallel, and
+  include/profile
+
+
+  Headers that implement the Debug Mode, Parallel Mode, and Profile Mode
+  extensions.
+
 
 
   
diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml 
b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
index e0e4e8e..7a158b9 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
@@ -471,6 +471,29 @@ Feature-testing recommendations for C++.
 
 
 
+   Adding more constexpr to  
+  
+   http://www.w3.org/1999/xlink"; 
xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0505r0.html";>
+   P0505R0
+   
+  
+   7 
+   ??? 
+
+
+
+  
+   Constexpr for std::char_traits 
+  
+   http://www.w3.org/1999/xlink"; 
xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0426r1.html";>
+   P0426R1
+   
+  
+   7 (partial) 
+   ??? 
+
+
+
Integrating std::string_view and 
std::string 
   
http://www.w3.org/1999/xlink"; 
xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0254r2.pdf";>
@@ -552,6 +575,17 @@ Feature-testing recommendations for C++.
 
 
 
+   Return type of emplace 
+  
+   http://www.w3.org/1999/xlink"; 
xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0084r2.pdf";>
+   P0084R2
+   
+  
+   7 
+   ??? 
+
+
+
Splicing Maps and Sets 
   
http://www.w3.org/1999/xlink"; 
xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0083r3.pdf";>
@@ -718,8 +752,7 @@ Feature-testing recommendations for C++.
 
 
 
-  
- byte type definition
+   byte type definition 
   
http://www.w3.org/1999/xlink"; 
xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0298r3.pdf";>
P0298R3
@@ -729,6 +762,18 @@ Feature-testing recommendations for C++.
??? 
 
 
+
+  
+   Elementary string conversions 
+  
+   http://www.w3.org/1999/xlink"; 
xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0067r5.html";>
+   P0067R5
+   
+  
+   No 
+   ??? 
+
+
 
   
 


[PATCH] Fix comments in libstdc++ header and test

2017-04-03 Thread Jonathan Wakely

* include/bits/ios_base.h: Correct comment.
* testsuite/util/testsuite_hooks.h: Likewise.

Tested powerpc64le-linux, committed to trunk.

commit 9622234eee9d9c61dcfcc8eefa7d5aac0ee44eb4
Author: Jonathan Wakely 
Date:   Mon Apr 3 16:54:40 2017 +0100

Fix comments in libstdc++ header and test

* include/bits/ios_base.h: Correct comment.
* testsuite/util/testsuite_hooks.h: Likewise.

diff --git a/libstdc++-v3/include/bits/ios_base.h 
b/libstdc++-v3/include/bits/ios_base.h
index f1ebfcc..e5a107d 100644
--- a/libstdc++-v3/include/bits/ios_base.h
+++ b/libstdc++-v3/include/bits/ios_base.h
@@ -52,8 +52,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // The following definitions of bitmask types are enums, not ints,
   // as permitted (but not required) in the standard, in order to provide
-  // better type safety in iostream calls.  A side effect is that
-  // expressions involving them are no longer compile-time constants.
+  // better type safety in iostream calls.  A side effect is that in C++98
+  // expressions involving them are not compile-time constants.
   enum _Ios_Fmtflags 
 { 
   _S_boolalpha = 1L << 0,
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h 
b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index 6f064a4..c3b902b 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -247,8 +247,8 @@ namespace __gnu_test
 static unsigned int _M_count;
   };
 
-  // An class of objects that can be used for validating various
-  // behaviours and guarantees of containers and algorithms defined in
+  // A class of objects that can be used for validating various
+  // behaviors and guarantees of containers and algorithms defined in
   // the standard library.
   class copy_tracker
   {


Re: [PATCH] simplify-rtx: Fix compare of comparisons (PR60818)

2017-04-03 Thread Segher Boessenkool
On Mon, Apr 03, 2017 at 11:01:23AM -0600, Jeff Law wrote:
> > PR rtl-optimization/60818
> > * simplify-rtx.c (simplify_binary_operation_1): Do not replace
> > a compare of comparisons with the thing compared if this results
> > in a different machine mode.
> >
> >gcc/testsuite/
> > PR rtl-optimization/60818
> > * gcc.c-torture/compile/pr60818.c: New testcase.
> Doesn't seem like a regression.  But I can't see how it could possibly 
> result in any correctness issues -- the absolute worst would be a 
> performance issue and even that seems highly unlikely.

It ICEs with trunk, it didn't ICE with 6.

The problem is that changing the mode of the CC in the producer, while
not changing the mode in the consumer, is very wrong, and runs into
asserts later on.

> OK for the trunk if you think it's worth fixing for gcc-7.  Else it's 
> pre-approved for gcc-8.

I'll commit it then.  Thanks,


Segher


[PATCH] Uncomment std::reference_wrapper tests that no longer fail

2017-04-03 Thread Jonathan Wakely

I think this started working when I made std::reference_wrapper use
std::__invoke, so we can uncomment the tests.

* testsuite/20_util/reference_wrapper/invoke.cc: Uncomment tests
that no longer fail.

Tested powerpc64le-linux, committed to trunk.


commit fef7c523742f474bb3322bd58b7be27dd088ed7d
Author: Jonathan Wakely 
Date:   Mon Apr 3 16:55:31 2017 +0100

Uncomment std::reference_wrapper tests that no longer fail

* testsuite/20_util/reference_wrapper/invoke.cc: Uncomment tests
that no longer fail.

diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc 
b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
index 8fd5470..c4a4537 100644
--- a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
+++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc
@@ -73,8 +73,7 @@ void test01()
   int (::X::* p_foo_c)(float) const = &::X::foo_c;
   int (::X::* p_foo_v)(float) volatile = &::X::foo_v;
   int (::X::* p_foo_cv)(float) const volatile = &::X::foo_cv;
-  int (::X::* p_foo_varargs)(float, ...) __attribute__((unused))
-= &::X::foo_varargs;
+  int (::X::* p_foo_varargs)(float, ...) = &::X::foo_varargs;
   int ::X::* p_bar = &::X::bar;
 
   const float pi = 3.14;
@@ -96,10 +95,10 @@ void test01()
   VERIFY(ref(p_foo_v)(xp, pi) == 3);
   VERIFY(ref(p_foo_cv)(x, pi) == 3);
   VERIFY(ref(p_foo_cv)(xp, pi) == 3);
-  // VERIFY(ref(p_foo_varargs)(x, pi) == 3);
-  // VERIFY(ref(p_foo_varargs)(xp, pi, 1, 1) == 3);
-  // VERIFY(ref(p_foo_varargs)(x, pi, 1, 1) == 3);
-  // VERIFY(ref(p_foo_varargs)(xp, pi) == 3);
+  VERIFY(ref(p_foo_varargs)(x, pi) == 3);
+  VERIFY(ref(p_foo_varargs)(xp, pi, 1, 1) == 3);
+  VERIFY(ref(p_foo_varargs)(x, pi, 1, 1) == 3);
+  VERIFY(ref(p_foo_varargs)(xp, pi) == 3);
 
   // Member data pointers
   VERIFY(ref(p_bar)(x) == 17);


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

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

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


Segher


[PATCH] Fix typos in comments throughout source tree

2017-04-03 Thread Jonathan Wakely

This fixes lots of typos throughout the tree. Can this be committed to
trunk as obvious?

I've bootstrapped the C and C++ compilers, but not Ada, and of course
not compiled all the target changes in gcc/config/*

Is one big commit OK, or one per-ChangeLog? Or something else?

(Currently I have one commit per ChangeLog, but can easily squash it
to one commit.)

I'm sure there are many more, because this patch comes from an old
branch I found lying around on an old machine. I did this back in
2013 but never committed it:
https://gcc.gnu.org/ml/gcc-patches/2013-07/msg00226.html

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 30daa0d..6d6e3dd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,46 @@
+2017-04-03  Jonathan Wakely  
+
+	* alias.c (base_alias_check): Fix typo in comment.
+	* cgraph.h (class ipa_polymorphic_call_context): Likewise.
+	* cgraphunit.c (symbol_table::compile): Likewise.
+	* collect2.c (maybe_run_lto_and_relink): Likewise.
+	* fold-const.c (fold_truth_andor): Likewise.
+	* genautomata.c (collapse_flag): Likewise.
+	* gengtype.h (struct type::u::s): Likewise.
+	* gensupport.c (has_subst_attribute, add_mnemonic_string): Likewise.
+	* input.c (FORMAT_AMOUNT): Likewise.
+	* ipa-cp.c (class ipcp_lattice, agg_replacements_to_vector)
+	(known_aggs_to_agg_replacement_list): Likewise.
+	* ipa-inline-analysis.c: Likewise.
+	* ipa-inline.h (estimate_edge_time, estimate_edge_hints): Likewise.
+	* ipa-polymorphic-call.c
+	(ipa_polymorphic_call_context::restrict_to_inner_class): Likewise.
+	* loop-unroll.c (analyze_insn_to_expand_var): Likewise.
+	* lra.c (lra_optional_reload_pseudos, lra_subreg_reload_pseudos):
+	Likewise.
+	* modulo-sched.c (apply_reg_moves): Likewise.
+	* omp-expand.c (build_omp_regions_1): Likewise.
+	* trans-mem.c (struct tm_wrapper_hasher): Likewise.
+	* tree-ssa-loop-ivopts.c (may_eliminate_iv): Likewise.
+	* tree-ssa-loop-niter.c (maybe_lower_iteration_bound): Likewise.
+	* tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Likewise.
+	* value-prof.c: Likewise.
+	* var-tracking.c (val_reset): Likewise.
+
+	* config/arm/arm.c (arm_thumb1_mi_thunk): Fix typo in comment.
+	* config/avr/avr-arch.h (avr_arch_info_t): Likewise.
+	* config/avr/avr.c (avr_map_op_t): Likewise.
+	* config/cr16/cr16.h (DATA_ALIGNMENT): Likewise.
+	* config/epiphany/epiphany.c (TARGET_ARG_PARTIAL_BYTES): Likewise.
+	* config/epiphany/epiphany.md (movcc): Likewise.
+	* config/i386/i386.c (legitimize_pe_coff_extern_decl): Likewise.
+	* config/m68k/m68k.c (struct _sched_ib, m68k_sched_variable_issue):
+	Likewise.
+	* config/mips/mips.c (mips_save_restore_reg): Likewise.
+	* config/rx/rx.c (rx_is_restricted_memory_address): Likewise.
+	* config/s390/s390.c (Z10_EARLYLOAD_DISTANCE): Likewise.
+	* config/sh/sh.c (sh_rtx_costs): Likewise.
+
 2017-04-03  Richard Biener  
 
 	PR tree-optimization/80275
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 3efce33..127a181 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,14 @@
+2017-04-03  Jonathan Wakely  
+
+	* doc/gnat_ugn/gnat_and_program_execution.rst: Fix typo.
+	* g-socket.adb (To_Host_Entry): Fix typo in comment.
+	* gnat_ugn.texi: Fix typo.
+	* raise.c (_gnat_builtin_longjmp): Fix capitalization in comment.
+	* s-stposu.adb (Allocate_Any_Controlled): Fix typo in comment.
+	* sem_ch3.adb (Build_Derived_Record_Type): Likewise.
+	* sem_util.adb (Mark_Coextensions): Likewise.
+	* sem_util.ads (Available_Full_View_Of_Component): Likewise.
+
 2017-03-28  Andreas Schwab  
 
 	PR ada/80117
diff --git a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
index b090236..37c077e 100644
--- a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
+++ b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
@@ -3091,7 +3091,7 @@ The three modes are:
 
 Note that these modes apply only to the evaluation of predefined
 arithmetic, membership, and comparison operators for signed integer
-aritmetic.
+arithmetic.
 
 For fixed-point arithmetic, checks can be suppressed. But if checks
 are enabled
diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb
index a8b718a..07931af 100644
--- a/gcc/ada/g-socket.adb
+++ b/gcc/ada/g-socket.adb
@@ -2541,7 +2541,7 @@ package body GNAT.Sockets is
 
--  Hostent_H_Addr (E, ) may return an address that is
--  not correctly aligned for In_Addr, so we need to use
-   --  an intermediate copy operation on a type with an alignemnt
+   --  an intermediate copy operation on a type with an alignment
--  of 1 to recover the value.
 
subtype Addr_Buf_T is C.char_array (1 .. Addr'Size / 8);
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index 421419f..1916d1e 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -22168,7 +22168,7 @@ but overflow is impossible.
 
 Note that these modes apply only to the evaluation of predefined
 arithmetic, membership, and 

Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types

2017-04-03 Thread Peter Bergner
On 4/3/17 12:01 PM, Peter Bergner wrote:
> On 4/3/17 11:04 AM, Peter Bergner wrote:
>> On 4/2/17 1:53 PM, Segher Boessenkool wrote:
>>> I also have a fix for the dfp-builtin-1.c problem.
>>
>> Something like the following maybe?  It seems to work for me.
>> I think the hard_dfp predicate was added after the dfp-builtin-[12].c
>> test cases were added, which is maybe why Mike used powerpc_vsx_ok?
>> Seems like we should switch it to using hard_dfp now.
> 
> As we discussed offline, I'll commit the following patch to fix up
> the dfp-builtin-1.c failures.  I'll also commit this to the GCC 5 & 6
> release branches, since the same issue exists there.

Ok, committed everywhere.  Thanks and sorry about the breakage! :-(

Peter




Re: [PATCH] Fix typos in comments throughout source tree

2017-04-03 Thread Mike Stump
On Apr 3, 2017, at 10:53 AM, Jonathan Wakely  wrote:
> 
> This fixes lots of typos throughout the tree. Can this be committed to
> trunk as obvious?

Yes, it can.  However, I like it when even this patch is reviewed.  I reviewed 
it, looks good.

You missed initialisers -> initializers.

Not sure I like datastructures, should be data structures?

figure out that poth parameters  -> figure out that both parameters


> I've bootstrapped the C and C++ compilers, but not Ada, and of course
> not compiled all the target changes in gcc/config/*
> 
> Is one big commit OK, or one per-ChangeLog? Or something else?

I'd just do one big commit.

Re: [PATCH] Update C++17 library status table in manual

2017-04-03 Thread Jonathan Wakely

On 03/04/17 18:19 +0100, Jonathan Wakely wrote:

* doc/xml/manual/status_cxx2017.xml: Update C++17 status table.
* doc/xml/manual/appendix_contributing.xml (contrib.organization): Add
directories for debug, parallel and profile headers.
* doc/html/*: Regenerate.

Committed to trunk.


Oops, one of these items was already in the table, this removes the
dup.
commit d1785b1741d8bdcf1270056d6ec14eff2dc11683
Author: Jonathan Wakely 
Date:   Mon Apr 3 19:58:02 2017 +0100

Remove duplicated entry in C++17 library status table

	* doc/xml/manual/status_cxx2017.xml: Remove duplicate table entry.
	* doc/html/*: Regenerate.

diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
index 7a158b9..0e35f75 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
@@ -558,7 +558,7 @@ Feature-testing recommendations for C++.
 	
   
7 
-  
+   ??? 
 
 
 
@@ -575,17 +575,6 @@ Feature-testing recommendations for C++.
 
 
 
-   Return type of emplace 
-  
-	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0084r2.pdf";>
-	P0084R2
-	
-  
-   7 
-   ??? 
-
-
-
Splicing Maps and Sets 
   
 	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0083r3.pdf";>


[PR 79905] ICE with vector_type

2017-04-03 Thread Nathan Sidwell

Bill,
can you give this patch a spin please? I've smoke tested it on a ppc64le 
x-compiler, but don't have one to run executables.  regression testing 
on an x86_64-linux system is ok.


The DEPENDENT_TYPE_VALID_P thing is a red herring.

It is the canonical type table's equal function considering most types 
with different TYPE_NAMEs to be different.  Now, you might think that 
only applies to things like RECORD_TYPE, but no,  wchar_t is different 
from plain int, for example.


However, as you can see there's already a get-out for COMPLEX_TYPE, and 
I think the same is needed for VECTOR_TYPE.


Both set_underlying_type and rs6000 set the builtin vector type's 
TYPE_NAME, and so one constructed via applying 
__attribute__((vector_size(16))) will never match.   And it should.


nathan
--
Nathan Sidwell

Index: tree.c
===
--- tree.c	(revision 246647)
+++ tree.c	(working copy)
@@ -7005,10 +7005,11 @@ type_cache_hasher::equal (type_hash *a,
   if (a->hash != b->hash
   || TREE_CODE (a->type) != TREE_CODE (b->type)
   || TREE_TYPE (a->type) != TREE_TYPE (b->type)
-  || !attribute_list_equal (TYPE_ATTRIBUTES (a->type),
- TYPE_ATTRIBUTES (b->type))
   || (TREE_CODE (a->type) != COMPLEX_TYPE
-  && TYPE_NAME (a->type) != TYPE_NAME (b->type)))
+	  && TREE_CODE (a->type) != VECTOR_TYPE
+  && TYPE_NAME (a->type) != TYPE_NAME (b->type))
+  || !attribute_list_equal (TYPE_ATTRIBUTES (a->type),
+TYPE_ATTRIBUTES (b->type)))
 return 0;
 
   /* Be careful about comparing arrays before and after the element type


Re: [PATCH] Fix typos in comments throughout source tree

2017-04-03 Thread Jonathan Wakely

On 03/04/17 11:48 -0700, Mike Stump wrote:

[ dup, I sent the wrong from the wrong email address, you might not see it 
because of that ]


On Apr 3, 2017, at 11:47 AM, Mike Stump  wrote:

On Apr 3, 2017, at 10:53 AM, Jonathan Wakely  wrote:


This fixes lots of typos throughout the tree. Can this be committed to
trunk as obvious?


Yes, it can.  However, I like it when even this patch is reviewed.  I reviewed 
it, looks good.

You missed initialisers -> initializers.


Ah yes, in a couple of places.

I think the original email about these typos only covered words
beginning with the letters A to E, so there are bound to be lots more
typos unfixed :-)



Not sure I like datastructures, should be data structures?


Will do. I also forgot to do something about the "accestor ???" part

  We provide accestor to the inline_summary datastructure and
  basic logic updating the parameters when inlining is performed.

I don't know what that's supposed to say. "access"? "accessors"?



figure out that poth parameters  -> figure out that both parameters


I'll fix that.


I've bootstrapped the C and C++ compilers, but not Ada, and of course
not compiled all the target changes in gcc/config/*

Is one big commit OK, or one per-ChangeLog? Or something else?


I'd just do one big commit.




Will do, thanks.



[PATCH] Fix type of __builtin_update_setjmp_buf

2017-04-03 Thread Andreas Schwab
That builtin actually expects a single pointer argument.

Andreas.

* builtins.def (BUILT_IN_UPDATE_SETJMP_BUF): Fix type.
 
diff --git a/gcc/builtins.def b/gcc/builtins.def
index e383c80145..58d78dbbde 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -884,7 +884,7 @@ DEF_LIB_BUILTIN(BUILT_IN_STRFTIME, "strftime", 
BT_FN_SIZE_STRING_SIZE_CO
 DEF_GCC_BUILTIN(BUILT_IN_TRAP, "trap", BT_FN_VOID, 
ATTR_NORETURN_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN(BUILT_IN_UNREACHABLE, "unreachable", BT_FN_VOID, 
ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN(BUILT_IN_UNWIND_INIT, "unwind_init", BT_FN_VOID, 
ATTR_NULL)
-DEF_GCC_BUILTIN(BUILT_IN_UPDATE_SETJMP_BUF, "update_setjmp_buf", 
BT_FN_VOID_PTR_INT, ATTR_NULL)
+DEF_GCC_BUILTIN(BUILT_IN_UPDATE_SETJMP_BUF, "update_setjmp_buf", 
BT_FN_VOID_PTR, ATTR_NULL)
 DEF_GCC_BUILTIN(BUILT_IN_VA_COPY, "va_copy", 
BT_FN_VOID_VALIST_REF_VALIST_ARG, ATTR_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN(BUILT_IN_VA_END, "va_end", BT_FN_VOID_VALIST_REF, 
ATTR_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN(BUILT_IN_VA_START, "va_start", 
BT_FN_VOID_VALIST_REF_VAR, ATTR_NOTHROW_LEAF_LIST)
-- 
2.12.2

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


[PATCH] Fix MMX/SSE/AVX* shifts by non-immediate scalar (PR target/80286)

2017-04-03 Thread Jakub Jelinek
Hi!

This patch deals just with correctness of vector shifts by scalar
non-immediate.  The manuals say the shift count is bits [0:63] of
the corresponding source operand (XMM reg or memory in some cases),
and if the count is bigger than number of bits - 1 in the vector element,
it is treated as number of bits shift count.
We are modelling it as SImode shift count though, the upper 32 bits
may be random in some cases which causes wrong-code.
Fixed by using DImode that matches what the insns do.

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

Any thoughts on what to do to generate reasonable code when the shift count
comes from memory (e.g. as int variable) or is in the low bits of some XMM
regioster?
First of all, perhaps we could have some combiner (or peephole) pattern that 
would
transform sign-extend from e.g. SI to DI on the shift count into zero-extend
if there are no other uses of the extension result - if the shift count is
negative in SImode (or even QImode), then it is already large number and the
upper 32 bits or more don't really change anything on that.
Then perhaps we could emit pmovzxdq for SSE4.1+ instead of going through
GPRs and back, or for SSE2 pxor on a scratch reg and punpck* to get it zero
extended.  Not sure if we want to add =v / vm alternative to
zero_extendsidi2*, it already has some x but with ?s that prevent the RA
from using it.  So thoughts on that?

2017-04-03  Jakub Jelinek  

PR target/80286
* config/i386/i386.c (ix86_expand_args_builtin): If op has scalar
int mode, convert_modes it to mode as unsigned, otherwise use
lowpart_subreg to mode rather than SImode.
* config/i386/sse.md (ashr3,
ashr3, ashr3, 3):
Use DImode instead of SImode for the shift count operand.
* config/i386/mmx.md (mmx_ashr3, mmx_3):
Likewise.
testsuite/
* gcc.target/i386/avx-pr80286.c: New test.
* gcc.dg/pr80286.c: New test.

--- gcc/config/i386/i386.c.jj   2017-04-03 10:40:22.0 +0200
+++ gcc/config/i386/i386.c  2017-04-03 18:31:39.482367634 +0200
@@ -35582,10 +35582,17 @@ ix86_expand_args_builtin (const struct b
{
  /* SIMD shift insns take either an 8-bit immediate or
 register as count.  But builtin functions take int as
-count.  If count doesn't match, we put it in register.  */
+count.  If count doesn't match, we put it in register.
+The instructions are using 64-bit count, if op is just
+32-bit, zero-extend it, as negative shift counts
+are undefined behavior and zero-extension is more
+efficient.  */
  if (!match)
{
- op = lowpart_subreg (SImode, op, GET_MODE (op));
+ if (SCALAR_INT_MODE_P (GET_MODE (op)))
+   op = convert_modes (mode, GET_MODE (op), op, 1);
+ else
+   op = lowpart_subreg (mode, op, GET_MODE (op));
  if (!insn_p->operand[i + 1].predicate (op, mode))
op = copy_to_reg (op);
}
--- gcc/config/i386/sse.md.jj   2017-04-03 13:43:50.179572564 +0200
+++ gcc/config/i386/sse.md  2017-04-03 18:01:19.713852914 +0200
@@ -10620,7 +10620,7 @@ (define_insn "ashr3<
   [(set (match_operand:VI24_AVX512BW_1 0 "register_operand" "=v,v")
(ashiftrt:VI24_AVX512BW_1
  (match_operand:VI24_AVX512BW_1 1 "nonimmediate_operand" "v,vm")
- (match_operand:SI 2 "nonmemory_operand" "v,N")))]
+ (match_operand:DI 2 "nonmemory_operand" "v,N")))]
   "TARGET_AVX512VL"
   "vpsra\t{%2, %1, %0|%0, %1, %2}"
   [(set_attr "type" "sseishft")
@@ -10634,7 +10634,7 @@ (define_insn "ashr3"
   [(set (match_operand:VI24_AVX2 0 "register_operand" "=x,x")
(ashiftrt:VI24_AVX2
  (match_operand:VI24_AVX2 1 "register_operand" "0,x")
- (match_operand:SI 2 "nonmemory_operand" "xN,xN")))]
+ (match_operand:DI 2 "nonmemory_operand" "xN,xN")))]
   "TARGET_SSE2"
   "@
psra\t{%2, %0|%0, %2}
@@ -10667,7 +10667,7 @@ (define_insn "ashr3"
   [(set (match_operand:VI248_AVX512BW_AVX512VL 0 "register_operand" "=v,v")
(ashiftrt:VI248_AVX512BW_AVX512VL
  (match_operand:VI248_AVX512BW_AVX512VL 1 "nonimmediate_operand" 
"v,vm")
- (match_operand:SI 2 "nonmemory_operand" "v,N")))]
+ (match_operand:DI 2 "nonmemory_operand" "v,N")))]
   "TARGET_AVX512F"
   "vpsra\t{%2, %1, %0|%0, %1, %2}"
   [(set_attr "type" "sseishft")
@@ -10681,7 +10681,7 @@ (define_insn "3 && "
   "@
p\t{%2, %0|%0, %2}
@@ -10700,7 +10700,7 @@ (define_insn "3"
   "@
p\t{%2, %0|%0, %2}
@@ -10720,7 +10720,7 @@ (define_insn "3"
   "vp\t{%2, %1, %0|%0, 
%1, %2}"
   [(set_attr "isa" "avx512f")
--- gcc/config/i386/mmx.md.jj   2017-04-03 13:43:50.119573339 +0200
+++ gcc/config/i386/mmx.md  2017-04-03 18:01:19.708852979 +0200
@@ -930,7 +930,7 @@ (define_insn "mmx_ashr3"
   [(set (match_operand:MMXMODE24 0 "register_operand" "=y")
 (ashiftrt:

Re: [PATCH] Fix profiledbootstrap ada checking failure (PR debug/79255)

2017-04-03 Thread Eric Botcazou
> The following C testcase shows how profiledbootstrap fails with checking
> compiler.  We have a (nested) FUNCTION_DECL inside of BLOCK_VARS of an
> inline function, when it gets inlined, it is moved into
> BLOCK_NONLOCALIZED_VARS.  And, decls_for_scope calls process_scope_var
> with NULL decl and non-NULL origin for all BLOCK_NONLOCALIZED_VARS.
> That is fine for variables, but for FUNCTION_DECLs it can actually
> try to dwarf2out_abstract_function that FUNCTION_DECL, which should be
> really done only when it is inlined (i.e. BLOCK_ABSTRACT_ORIGIN of
> some BLOCK).  The effect is that we actually add DW_AT_inline attribute
> to that DW_TAG_subroutine, and then later when processing it again
> we add DW_AT_low_pc etc. and ICE, because those attributes should not
> appear on DW_AT_inline functions.
> 
> Fixed by handling FUNCTION_DECLs always the same, whether in BLOCK_VARS
> or BLOCK_NONLOCALIZED_VARS.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2017-03-23  Jakub Jelinek  
> 
>   PR debug/79255
>   * dwarf2out.c (decls_for_scope): If BLOCK_NONLOCALIZED_VAR is
>   a FUNCTION_DECL, pass it as decl instead of origin to
>   process_scope_var.

Thanks for working on this, however the patch breaks bootstrap for us in stage 
#2 using a different set of bootstrap options (-gnatpgn -g).  There appears to 
be an endless recursion :

[...]

#27 0x00b7c929 in process_scope_var (stmt=0x742ebf60, 
decl=0x73c01700, origin=0x0, context_die=0x7fffe2ddd870)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24833
#28 0x00b7ca6f in decls_for_scope (stmt=0x742ebf60, 
context_die=0x7fffe2ddd870)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24867
#29 0x00b77e78 in gen_lexical_block_die (stmt=0x742ebf60, 
context_die=0x7fffe2ddd6e0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:23207
#30 0x00b7c638 in gen_block_die (stmt=0x742ebf60, 
context_die=0x7fffe2ddd6e0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24795
#31 0x00b7cb07 in decls_for_scope (stmt=0x742ebde0, 
context_die=0x7fffe2ddd6e0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24881
#32 0x00b78017 in gen_inlined_subroutine_die (stmt=0x742ebde0, 
context_die=0x7fffe2ddd1e0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:23245
#33 0x00b7c623 in gen_block_die (stmt=0x742ebde0, 
context_die=0x7fffe2ddd1e0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24792
#34 0x00b7cb07 in decls_for_scope (stmt=0x7449e000, 
---Type  to continue, or q  to quit---
context_die=0x7fffe2ddd1e0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24881
#35 0x00b7c64d in gen_block_die (stmt=0x7449e000, 
context_die=0x7fffe2ddd1e0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24798
#36 0x00b7cb07 in decls_for_scope (stmt=0x73f7bf00, 
context_die=0x7fffe2ddd1e0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24881
#37 0x00b77e78 in gen_lexical_block_die (stmt=0x73f7bf00, 
context_die=0x7fffe2ddaeb0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:23207
#38 0x00b7c638 in gen_block_die (stmt=0x73f7bf00, 
context_die=0x7fffe2ddaeb0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24795
#39 0x00b7cb07 in decls_for_scope (stmt=0x73bf98a0, 
context_die=0x7fffe2ddaeb0)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24881
#40 0x00b72766 in gen_subprogram_die (decl=0x73c01700, 
context_die=0x7fffe2ddae60)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:22441
#41 0x00b7e034 in gen_decl_die (decl=0x73c01700, origin=0x0, 
ctx=0x0, context_die=0x7fffe2ddae60)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:25289
#42 0x00b7c929 in process_scope_var (stmt=0x742ebf60, 
decl=0x73c01700, origin=0x0, context_die=0x7fffe2ddae60)
at /home/eric/gnat/gnat-head/src/gcc/dwarf2out.c:24833

[...]

We have local modifications in the Ada front-end so I cannot reproduce it with 
the pristine tree either. :-(  I'll try harder tomorrow.

-- 
Eric Botcazou


[Patch C++/80296] Fix broken diagnostic: 'unary_plus_expr' not supported by expression

2017-04-03 Thread Volker Reichelt
The following patch fixes a broken diagnostic:
#'unary_plus_expr' not supported by expression#

The code to handle UNARY_PLUS_EXPR is already in place in
cxx_pretty_printer::unary_expression. However, UNARY_PLUS_EXPR
is not checked in cxx_pretty_printer::expression, so that we
don't call cxx_pretty_printer::unary_expression.
Fixed with the patch below.

Bootstrapped and regtested on x86_64-pc-linux-gnu.

OK for trunk? Or should this wait for stage 1?

Regards,
Volker


2017-04-03  Volker Reichelt  

PR c++/80296
* cxx-pretty-print.c (cxx_pretty_printer::expression): Add
UNARY_PLUS_EXPR case.

Index: gcc/cp/cxx-pretty-print.c
===
--- gcc/cp/cxx-pretty-print.c   (revision 246620)
+++ gcc/cp/cxx-pretty-print.c   (working copy)
@@ -1112,6 +1112,7 @@
 case SIZEOF_EXPR:
 case ALIGNOF_EXPR:
 case NOEXCEPT_EXPR:
+case UNARY_PLUS_EXPR:
   unary_expression (t);
   break;
 
2017-04-03  Volker Reichelt  

PR c++/80296
* g++.dg/cpp0x/alias-decl-80296.C: New test.

Index: gcc/testsuite/g++.dg/cpp0x/alias-decl-80296.C
===
--- gcc/testsuite/g++.dg/cpp0x/alias-decl-80296.C   2017-04-03
+++ gcc/testsuite/g++.dg/cpp0x/alias-decl-80296.C   2017-04-03
@@ -0,0 +1,9 @@
+// { dg-do compile { target c++11 } }
+// { dg-bogus "not supported by" "" { target *-*-* } 0 }
+
+template  struct A {};
+
+template  using B = A<+N...>;
+
+B b; // { dg-error "type/value mismatch" }
+  // { dg-message "expected a constant" "expected" { target *-*-* } 8 }
===



C++ PATCH for sanitizer/79993 (ICE with VLA initialized from string constant)

2017-04-03 Thread Jason Merrill
In this testcase we were giving a STRING_CST a VLA type, which is
nonsensical and leads to the asan crash.  After fixing that the
initialization semantics are still wrong, so this patch corrects that
as well.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 0ada9f9492a4184e638bd8796db5fb68532aae51
Author: Jason Merrill 
Date:   Fri Mar 24 16:37:24 2017 -0400

PR c++/79993 - ICE with VLA initialization

* init.c (finish_length_check): Split out from build_vec_init.
(build_vec_init): Handle STRING_CST.
* typeck2.c (split_nonconstant_init): Handle STRING_CST.
(digest_init_r): Don't give a STRING_CST VLA type.

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 7732795..2015205 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -3884,6 +3884,35 @@ vec_copy_assign_is_trivial (tree inner_elt_type, tree 
init)
   return is_trivially_xible (MODIFY_EXPR, inner_elt_type, fromtype);
 }
 
+/* Subroutine of build_vec_init: Check that the array has at least N
+   elements.  Other parameters are local variables in build_vec_init.  */
+
+void
+finish_length_check (tree atype, tree iterator, tree obase, unsigned n)
+{
+  tree nelts = build_int_cst (ptrdiff_type_node, n - 1);
+  if (TREE_CODE (atype) != ARRAY_TYPE)
+{
+  if (flag_exceptions)
+   {
+ tree c = fold_build2 (LT_EXPR, boolean_type_node, iterator,
+   nelts);
+ c = build3 (COND_EXPR, void_type_node, c,
+ throw_bad_array_new_length (), void_node);
+ finish_expr_stmt (c);
+   }
+  /* Don't check an array new when -fno-exceptions.  */
+}
+  else if (flag_sanitize & SANITIZE_BOUNDS
+  && do_ubsan_in_current_function ())
+{
+  /* Make sure the last element of the initializer is in bounds. */
+  finish_expr_stmt
+   (ubsan_instrument_bounds
+(input_location, obase, &nelts, /*ignore_off_by_one*/false));
+}
+}
+
 /* `build_vec_init' returns tree structure that performs
initialization of a vector of aggregate types.
 
@@ -3932,6 +3961,8 @@ build_vec_init (tree base, tree maxindex, tree init,
   tree obase = base;
   bool xvalue = false;
   bool errors = false;
+  location_t loc = (init ? EXPR_LOC_OR_LOC (init, input_location)
+   : location_of (base));
 
   if (TREE_CODE (atype) == ARRAY_TYPE && TYPE_DOMAIN (atype))
 maxindex = array_type_nelts (atype);
@@ -3963,10 +3994,12 @@ build_vec_init (tree base, tree maxindex, tree init,
}
 }
 
-  /* If we have a braced-init-list, make sure that the array
+  /* If we have a braced-init-list or string constant, make sure that the array
  is big enough for all the initializers.  */
-  bool length_check = (init && TREE_CODE (init) == CONSTRUCTOR
-  && CONSTRUCTOR_NELTS (init) > 0
+  bool length_check = (init
+  && (TREE_CODE (init) == STRING_CST
+  || (TREE_CODE (init) == CONSTRUCTOR
+  && CONSTRUCTOR_NELTS (init) > 0))
   && !TREE_CONSTANT (maxindex));
 
   if (init
@@ -4105,30 +4138,7 @@ build_vec_init (tree base, tree maxindex, tree init,
   from_array = 0;
 
   if (length_check)
-   {
- tree nelts = build_int_cst (ptrdiff_type_node,
- CONSTRUCTOR_NELTS (init) - 1);
- if (TREE_CODE (atype) != ARRAY_TYPE)
-   {
- if (flag_exceptions)
-   {
- tree c = fold_build2 (LT_EXPR, boolean_type_node, iterator,
-   nelts);
- c = build3 (COND_EXPR, void_type_node, c,
- throw_bad_array_new_length (), void_node);
- finish_expr_stmt (c);
-   }
- /* Don't check an array new when -fno-exceptions.  */
-   }
- else if (flag_sanitize & SANITIZE_BOUNDS
-  && do_ubsan_in_current_function ())
-   {
- /* Make sure the last element of the initializer is in bounds. */
- finish_expr_stmt
-   (ubsan_instrument_bounds
-(input_location, obase, &nelts, /*ignore_off_by_one*/false));
-   }
-   }
+   finish_length_check (atype, iterator, obase, CONSTRUCTOR_NELTS (init));
 
   if (try_const)
vec_alloc (const_vec, CONSTRUCTOR_NELTS (init));
@@ -4196,6 +4206,34 @@ build_vec_init (tree base, tree maxindex, tree init,
   /* Any elements without explicit initializers get T{}.  */
   empty_list = true;
 }
+  else if (init && TREE_CODE (init) == STRING_CST)
+{
+  /* Check that the array is at least as long as the string.  */
+  if (length_check)
+   finish_length_check (atype, iterator, obase,
+TREE_STRING_LENGTH (init));
+  tree length = build_int_cst (ptrdiff_type_node,
+  TREE_STRING_LENGTH

Re: [PATCH] Fix typos in comments throughout source tree

2017-04-03 Thread Jonathan Wakely

On 03/04/17 20:06 +0100, Jonathan Wakely wrote:

On 03/04/17 11:48 -0700, Mike Stump wrote:

[ dup, I sent the wrong from the wrong email address, you might not see it 
because of that ]


On Apr 3, 2017, at 11:47 AM, Mike Stump  wrote:

On Apr 3, 2017, at 10:53 AM, Jonathan Wakely  wrote:


This fixes lots of typos throughout the tree. Can this be committed to
trunk as obvious?


Yes, it can.  However, I like it when even this patch is reviewed.  I reviewed 
it, looks good.

You missed initialisers -> initializers.


Ah yes, in a couple of places.

I think the original email about these typos only covered words
beginning with the letters A to E, so there are bound to be lots more
typos unfixed :-)



Not sure I like datastructures, should be data structures?


Will do. I also forgot to do something about the "accestor ???" part

 We provide accestor to the inline_summary datastructure and
 basic logic updating the parameters when inlining is performed.

I don't know what that's supposed to say. "access"? "accessors"?


I went for "access".

Thanks for the review.



figure out that poth parameters  -> figure out that both parameters


I'll fix that.


I've bootstrapped the C and C++ compilers, but not Ada, and of course
not compiled all the target changes in gcc/config/*

Is one big commit OK, or one per-ChangeLog? Or something else?


I'd just do one big commit.




Will do, thanks.



[testsuite] Fix loading wrong DLLs on Windows, merge duplicate target-libpath.exp

2017-04-03 Thread Daniel Santos
We currently have two copies of target-libpath.exp in the tree under
gcc/testsuite/lib and libffi/testsuite/lib.  It was originally pulled
into the libffi project from downstream gcc in 2009
(https://github.com/libffi/libffi/commit/5cbe2058c128e848446ae79fe15ee54260a90559).
Then in 2012, Anthony Green (from libffi) modified it to correct this
Windows problem (thank you!
https://github.com/libffi/libffi/commit/bd78c9c3311244dd5f877c915b0dff91621dd253).
In 2015, this file got pulled from upstream libffi back into gcc, thus
beginning two separate development paths
(https://github.com/gcc-mirror/gcc/commit/89d8a412de548b218cf7c967e65ad98bceb1ed4e).

This patch merges the changes from libffi upstream which correctly solve
the Windows DLL load path problem and removes the duplicate from
libffi/testsuite/lib.  This fixes most of bug #79867, implementing
correct behaviour for set_ld_library_path_env_vars and
restore_ld_library_path_env_vars.  However, there is still incorrect
behaviour in DejaGNU's unix_load that should eventually be adddressed,
although I cannot yet point to a specific failure that it is causing.

gcc/ChangeLog:
2017-04-03  Daniel Santos 

PR testsuite/79867
* testsuite/lib/target-libpath.exp (set_ld_library_path_env_vars,
restore_ld_library_path_env_vars): Merge changes from libffi upstream,
correcting DLL load path problems on Windows.

libffi/ChangeLog:
2017-04-03  Daniel Santos 

PR testsuite/79867
* testsuite/lib/target-libpath.exp: Remove.
* testsuite/Makefile.in: Remove target-libpath.exp.
* testsuite/Makefile.am: Regenerated.

Signed-off-by: Daniel Santos 
---
 gcc/testsuite/lib/target-libpath.exp|  21 +++
 libffi/testsuite/Makefile.am|   2 +-
 libffi/testsuite/Makefile.in|   2 +-
 libffi/testsuite/lib/target-libpath.exp | 283 
 4 files changed, 23 insertions(+), 285 deletions(-)
 delete mode 100644 libffi/testsuite/lib/target-libpath.exp

diff --git a/gcc/testsuite/lib/target-libpath.exp 
b/gcc/testsuite/lib/target-libpath.exp
index 9b3e201ed68..b6d01b31016 100644
--- a/gcc/testsuite/lib/target-libpath.exp
+++ b/gcc/testsuite/lib/target-libpath.exp
@@ -23,6 +23,7 @@ set orig_shlib_path_saved 0
 set orig_ld_library_path_32_saved 0
 set orig_ld_library_path_64_saved 0
 set orig_dyld_library_path_saved 0
+set orig_path_saved 0
 set orig_gcc_exec_prefix_saved 0
 set orig_gcc_exec_prefix_checked 0
 
@@ -55,6 +56,7 @@ proc set_ld_library_path_env_vars { } {
   global orig_ld_library_path_32_saved
   global orig_ld_library_path_64_saved
   global orig_dyld_library_path_saved
+  global orig_path_saved
   global orig_gcc_exec_prefix_saved
   global orig_gcc_exec_prefix_checked
   global orig_ld_library_path
@@ -63,6 +65,7 @@ proc set_ld_library_path_env_vars { } {
   global orig_ld_library_path_32
   global orig_ld_library_path_64
   global orig_dyld_library_path
+  global orig_path
   global orig_gcc_exec_prefix
   global env
 
@@ -110,6 +113,10 @@ proc set_ld_library_path_env_vars { } {
   set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)"
   set orig_dyld_library_path_saved 1
 }
+if [info exists env(PATH)] {
+  set orig_path "$env(PATH)"
+  set orig_path_saved 1
+}
   }
 
   # We need to set ld library path in the environment.  Currently,
@@ -164,6 +171,13 @@ proc set_ld_library_path_env_vars { } {
   } else {
 setenv DYLD_LIBRARY_PATH "$ld_library_path"
   }
+  if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
+if { $orig_path_saved } {
+  setenv PATH "$ld_library_path:$orig_path"
+} else {
+  setenv PATH "$ld_library_path"
+}
+  }
 
   verbose -log "LD_LIBRARY_PATH=[getenv LD_LIBRARY_PATH]"
   verbose -log "LD_RUN_PATH=[getenv LD_RUN_PATH]"
@@ -201,12 +215,14 @@ proc restore_ld_library_path_env_vars { } {
   global orig_ld_library_path_32_saved
   global orig_ld_library_path_64_saved
   global orig_dyld_library_path_saved
+  global orig_path_saved
   global orig_ld_library_path
   global orig_ld_run_path
   global orig_shlib_path
   global orig_ld_library_path_32
   global orig_ld_library_path_64
   global orig_dyld_library_path
+  global orig_path
   global env
 
   restore_gcc_exec_prefix_env_var
@@ -245,6 +261,11 @@ proc restore_ld_library_path_env_vars { } {
   } elseif [info exists env(DYLD_LIBRARY_PATH)] {
 unsetenv DYLD_LIBRARY_PATH
   }
+  if { $orig_path_saved } {
+setenv PATH "$orig_path"
+  } elseif [info exists env(PATH)] {
+unsetenv PATH
+  }
 }
 
 ###
diff --git a/libffi/testsuite/Makefile.am b/libffi/testsuite/Makefile.am
index 209e8976635..b4eb7c2bce9 100644
--- a/libffi/testsuite/Makefile.am
+++ b/libffi/testsuite/Makefile.am
@@ -82,7 +82,7 @@ libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c
\
 libffi.call/cls_6_1_byte.c \
 libffi.call/cls_7_1_byte.c libffi.call/unwindtest.cc   \
 

Re: [PATCH, testsuite] PR79867: Fix loading wrong DLLs on Windows, merge duplicate target-libpath.exp

2017-04-03 Thread Daniel Santos
I forgot to include PATCH and the PR in the subject line, sorry about 
that.  Also, I have run a full bootstrap and testsuite to verify that I 
haven't missed any references to the extraneous copy of 
target-libpath.exp in libffi.




C++ PATCH for -fconcepts regression on alias-decl-42.C

2017-04-03 Thread Jason Merrill
This fixes a crash with -fconcepts on a few testcases.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit cee8cb05c77df3dd3c7d93dd70fb1061823f0e68
Author: Jason Merrill 
Date:   Thu Mar 30 22:04:05 2017 -0400

* semantics.c (finish_template_type): Check CLASSTYPE_TEMPLATE_INFO.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index c572646..0a69500 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3157,6 +3157,7 @@ finish_template_type (tree name, tree args, int 
entering_scope)
   if (flag_concepts
   && entering_scope
   && CLASS_TYPE_P (type)
+  && CLASSTYPE_TEMPLATE_INFO (type)
   && dependent_type_p (type)
   && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (type)))
 type = fixup_template_type (type);
diff --git a/gcc/testsuite/g++.dg/concepts/regress/alias-decl-42.C 
b/gcc/testsuite/g++.dg/concepts/regress/alias-decl-42.C
new file mode 100644
index 000..611a896
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/regress/alias-decl-42.C
@@ -0,0 +1,18 @@
+// PR c++/59200
+// { dg-options "-std=c++1z -fconcepts" }
+
+struct A
+{
+  static constexpr bool value = true;
+};
+
+template
+struct B
+{
+  template
+using C = A;
+};
+
+template
+template
+  const bool B::C::value;  // { dg-error "too many" }


Re: [PATCH] Fix PR80275

2017-04-03 Thread Markus Trippelsdorf
On 2017.04.03 at 11:16 +0200, Richard Biener wrote:
> 
> The following extends split_address_to_core_and_offset to handle
> POINTER_PLUS_EXPR to be able to simplify
> (unsigned long) &MEM[(void *)&D.15512 + 12B] - (unsigned long) ((const int 
> *) &D.15512 + 4) which appears during niter analysis.
> 
> We seem to have various copies of similar code but refactoring didn't
> seem appropriate at this stage so I went for the minimal fix.
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
> 
> Richard.
> 
> 2017-04-03  Richard Biener  
> 
>   PR tree-optimization/80275
>   * fold-const.c (split_address_to_core_and_offset): Handle
>   POINTER_PLUS_EXPR.
> 
>   * g++.dg/opt/pr80275.C: New testcase.
> 
> Index: gcc/fold-const.c
> ===
> --- gcc/fold-const.c  (revision 246642)
> +++ gcc/fold-const.c  (working copy)
> @@ -14341,6 +14341,24 @@ split_address_to_core_and_offset (tree e
> &volatilep);
>core = build_fold_addr_expr_loc (loc, core);
>  }
> +  else if (TREE_CODE (exp) == POINTER_PLUS_EXPR)
> +{
> +  core = TREE_OPERAND (exp, 0);
> +  STRIP_NOPS (core);
> +  *pbitpos = 0;
> +  *poffset = TREE_OPERAND (exp, 1);
> +  if (TREE_CODE (*poffset) == INTEGER_CST)
> + {
> +   offset_int tem = wi::sext (wi::to_offset (*poffset),
> +  TYPE_PRECISION (TREE_TYPE (*poffset)));
> +   tem <<= LOG2_BITS_PER_UNIT;
> +   if (wi::fits_shwi_p (tem))
> + {
> +   *pbitpos = tem.to_shwi ();
> +   *poffset = NULL_TREE;
> + }
> + }
> +}
>else
>  {
>core = exp;
> Index: gcc/testsuite/g++.dg/opt/pr80275.C
> ===
> --- gcc/testsuite/g++.dg/opt/pr80275.C(nonexistent)
> +++ gcc/testsuite/g++.dg/opt/pr80275.C(working copy)
> @@ -0,0 +1,16 @@
> +// { dg-do compile { target c++14 } }
> +// { dg-options "-O2 -fdump-tree-optimized" }
> +
> +#include 
> +
> +int g()
> +{
> +  return 1234;
> +}
> +
> +int f2()
> +{
> +  return std::min({1, g(), 4});
> +}
> +
> +// { dg-final { scan-tree-dump "return 1;" "optimized" } }

The testcase fails with -fpic, e.g.:
https://gcc.gnu.org/ml/gcc-regression/2017-04/msg2.html

So perhaps:

diff --git a/gcc/testsuite/g++.dg/opt/pr80275.C 
b/gcc/testsuite/g++.dg/opt/pr80275.C
index 7296a07fb2dd..7d625f2c7757 100644
--- a/gcc/testsuite/g++.dg/opt/pr80275.C
+++ b/gcc/testsuite/g++.dg/opt/pr80275.C
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++14 } }
+// { dg-do compile { target c++14 && nonpic } }
 // { dg-options "-O2 -fdump-tree-optimized" }
 
 #include 

-- 
Markus


Re: [PATCH] Fix PR80275

2017-04-03 Thread Marc Glisse

On Tue, 4 Apr 2017, Markus Trippelsdorf wrote:


On 2017.04.03 at 11:16 +0200, Richard Biener wrote:


The following extends split_address_to_core_and_offset to handle
POINTER_PLUS_EXPR to be able to simplify
(unsigned long) &MEM[(void *)&D.15512 + 12B] - (unsigned long) ((const int
*) &D.15512 + 4) which appears during niter analysis.

We seem to have various copies of similar code but refactoring didn't
seem appropriate at this stage so I went for the minimal fix.

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

Richard.

2017-04-03  Richard Biener  

PR tree-optimization/80275
* fold-const.c (split_address_to_core_and_offset): Handle
POINTER_PLUS_EXPR.

* g++.dg/opt/pr80275.C: New testcase.

Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 246642)
+++ gcc/fold-const.c(working copy)
@@ -14341,6 +14341,24 @@ split_address_to_core_and_offset (tree e
  &volatilep);
   core = build_fold_addr_expr_loc (loc, core);
 }
+  else if (TREE_CODE (exp) == POINTER_PLUS_EXPR)
+{
+  core = TREE_OPERAND (exp, 0);
+  STRIP_NOPS (core);
+  *pbitpos = 0;
+  *poffset = TREE_OPERAND (exp, 1);
+  if (TREE_CODE (*poffset) == INTEGER_CST)
+   {
+ offset_int tem = wi::sext (wi::to_offset (*poffset),
+TYPE_PRECISION (TREE_TYPE (*poffset)));
+ tem <<= LOG2_BITS_PER_UNIT;
+ if (wi::fits_shwi_p (tem))
+   {
+ *pbitpos = tem.to_shwi ();
+ *poffset = NULL_TREE;
+   }
+   }
+}
   else
 {
   core = exp;
Index: gcc/testsuite/g++.dg/opt/pr80275.C
===
--- gcc/testsuite/g++.dg/opt/pr80275.C  (nonexistent)
+++ gcc/testsuite/g++.dg/opt/pr80275.C  (working copy)
@@ -0,0 +1,16 @@
+// { dg-do compile { target c++14 } }
+// { dg-options "-O2 -fdump-tree-optimized" }
+
+#include 
+
+int g()
+{
+  return 1234;
+}
+
+int f2()
+{
+  return std::min({1, g(), 4});
+}
+
+// { dg-final { scan-tree-dump "return 1;" "optimized" } }


The testcase fails with -fpic, e.g.:
https://gcc.gnu.org/ml/gcc-regression/2017-04/msg2.html

So perhaps:

diff --git a/gcc/testsuite/g++.dg/opt/pr80275.C 
b/gcc/testsuite/g++.dg/opt/pr80275.C
index 7296a07fb2dd..7d625f2c7757 100644
--- a/gcc/testsuite/g++.dg/opt/pr80275.C
+++ b/gcc/testsuite/g++.dg/opt/pr80275.C
@@ -1,4 +1,4 @@
-// { dg-do compile { target c++14 } }
+// { dg-do compile { target c++14 && nonpic } }
// { dg-options "-O2 -fdump-tree-optimized" }

#include 


Making g static should work even with PIC.

--
Marc Glisse


Re: [PATCH] Fix MMX/SSE/AVX* shifts by non-immediate scalar (PR target/80286)

2017-04-03 Thread Uros Bizjak
On Mon, Apr 3, 2017 at 10:34 PM, Jakub Jelinek  wrote:
> Hi!
>
> This patch deals just with correctness of vector shifts by scalar
> non-immediate.  The manuals say the shift count is bits [0:63] of
> the corresponding source operand (XMM reg or memory in some cases),
> and if the count is bigger than number of bits - 1 in the vector element,
> it is treated as number of bits shift count.
> We are modelling it as SImode shift count though, the upper 32 bits
> may be random in some cases which causes wrong-code.
> Fixed by using DImode that matches what the insns do.

IIRC, SImode was choosen to simplify GPR->XMM register moves on 32bit
target. It does look this was wrong choice from the correctness point.

> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> Any thoughts on what to do to generate reasonable code when the shift count
> comes from memory (e.g. as int variable) or is in the low bits of some XMM
> regioster?

The problem with int variable from memory is, that shifts access full
128bits for their count operand, so this is effectively a no-go. If
there is a 128bit count value in memory, we can maybe define shift
pattern with:

(subreg:DI (match_operand:V2DI 2 "general_operand" "xmN,vmN"))

?

> First of all, perhaps we could have some combiner (or peephole) pattern that 
> would
> transform sign-extend from e.g. SI to DI on the shift count into zero-extend
> if there are no other uses of the extension result - if the shift count is
> negative in SImode (or even QImode), then it is already large number and the
> upper 32 bits or more don't really change anything on that.

We can introduce shift patterns with embedded extensions, and split
them to zext + shift. These new patterns can be easily macroized with
any_extend code iterator and SWI124 mode iterator, so we avoid pattern
explosion.

> Then perhaps we could emit pmovzxdq for SSE4.1+ instead of going through
> GPRs and back, or for SSE2 pxor on a scratch reg and punpck* to get it zero
> extended.  Not sure if we want to add =v / vm alternative to
> zero_extendsidi2*, it already has some x but with ?s that prevent the RA
> from using it.  So thoughts on that?

The ? is there to discourage RA from allocating xmm reg (all these
alternatives have * on xmm reg), in effect instructing RA to prefer
GPRs. If the value is already in xmm reg, then I expect ? alternative
will be used. So, yes, v/v alternative as you proposed would be a good
addition to zero_extendsidi alternatives. Please note though that
pmovzxdq operates on a vector value, so memory operands should be
avoided.

>
> 2017-04-03  Jakub Jelinek  
>
> PR target/80286
> * config/i386/i386.c (ix86_expand_args_builtin): If op has scalar
> int mode, convert_modes it to mode as unsigned, otherwise use
> lowpart_subreg to mode rather than SImode.
> * config/i386/sse.md (ashr3,
> ashr3, ashr3, 3):
> Use DImode instead of SImode for the shift count operand.
> * config/i386/mmx.md (mmx_ashr3, mmx_3):
> Likewise.
> testsuite/
> * gcc.target/i386/avx-pr80286.c: New test.
> * gcc.dg/pr80286.c: New test.

OK for trunk and backports.

Thanks,
Uros.

> --- gcc/config/i386/i386.c.jj   2017-04-03 10:40:22.0 +0200
> +++ gcc/config/i386/i386.c  2017-04-03 18:31:39.482367634 +0200
> @@ -35582,10 +35582,17 @@ ix86_expand_args_builtin (const struct b
> {
>   /* SIMD shift insns take either an 8-bit immediate or
>  register as count.  But builtin functions take int as
> -count.  If count doesn't match, we put it in register.  */
> +count.  If count doesn't match, we put it in register.
> +The instructions are using 64-bit count, if op is just
> +32-bit, zero-extend it, as negative shift counts
> +are undefined behavior and zero-extension is more
> +efficient.  */
>   if (!match)
> {
> - op = lowpart_subreg (SImode, op, GET_MODE (op));
> + if (SCALAR_INT_MODE_P (GET_MODE (op)))
> +   op = convert_modes (mode, GET_MODE (op), op, 1);
> + else
> +   op = lowpart_subreg (mode, op, GET_MODE (op));
>   if (!insn_p->operand[i + 1].predicate (op, mode))
> op = copy_to_reg (op);
> }
> --- gcc/config/i386/sse.md.jj   2017-04-03 13:43:50.179572564 +0200
> +++ gcc/config/i386/sse.md  2017-04-03 18:01:19.713852914 +0200
> @@ -10620,7 +10620,7 @@ (define_insn "ashr3<
>[(set (match_operand:VI24_AVX512BW_1 0 "register_operand" "=v,v")
> (ashiftrt:VI24_AVX512BW_1
>   (match_operand:VI24_AVX512BW_1 1 "nonimmediate_operand" "v,vm")
> - (match_operand:SI 2 "nonmemory_operand" "v,N")))]
> + (match_operand:DI 2 "nonmemory_operand" "v,N")))]
>"TARGET_AVX512VL"
>"vpsra\t{%2, %1, %0|%0, %1, 
> %2}"
>[(set_attr "type" "sseishft")
> @@ -10634,7 +10634,7

Re: [PATCH] Fix PR80275

2017-04-03 Thread Richard Biener
On Tue, 4 Apr 2017, Marc Glisse wrote:

> On Tue, 4 Apr 2017, Markus Trippelsdorf wrote:
> 
> > On 2017.04.03 at 11:16 +0200, Richard Biener wrote:
> > > 
> > > The following extends split_address_to_core_and_offset to handle
> > > POINTER_PLUS_EXPR to be able to simplify
> > > (unsigned long) &MEM[(void *)&D.15512 + 12B] - (unsigned long) ((const int
> > > *) &D.15512 + 4) which appears during niter analysis.
> > > 
> > > We seem to have various copies of similar code but refactoring didn't
> > > seem appropriate at this stage so I went for the minimal fix.
> > > 
> > > Bootstrap and regtest running on x86_64-unknown-linux-gnu.
> > > 
> > > Richard.
> > > 
> > > 2017-04-03  Richard Biener  
> > > 
> > >   PR tree-optimization/80275
> > >   * fold-const.c (split_address_to_core_and_offset): Handle
> > >   POINTER_PLUS_EXPR.
> > > 
> > >   * g++.dg/opt/pr80275.C: New testcase.
> > > 
> > > Index: gcc/fold-const.c
> > > ===
> > > --- gcc/fold-const.c  (revision 246642)
> > > +++ gcc/fold-const.c  (working copy)
> > > @@ -14341,6 +14341,24 @@ split_address_to_core_and_offset (tree e
> > > &volatilep);
> > >core = build_fold_addr_expr_loc (loc, core);
> > >  }
> > > +  else if (TREE_CODE (exp) == POINTER_PLUS_EXPR)
> > > +{
> > > +  core = TREE_OPERAND (exp, 0);
> > > +  STRIP_NOPS (core);
> > > +  *pbitpos = 0;
> > > +  *poffset = TREE_OPERAND (exp, 1);
> > > +  if (TREE_CODE (*poffset) == INTEGER_CST)
> > > + {
> > > +   offset_int tem = wi::sext (wi::to_offset (*poffset),
> > > +  TYPE_PRECISION (TREE_TYPE (*poffset)));
> > > +   tem <<= LOG2_BITS_PER_UNIT;
> > > +   if (wi::fits_shwi_p (tem))
> > > + {
> > > +   *pbitpos = tem.to_shwi ();
> > > +   *poffset = NULL_TREE;
> > > + }
> > > + }
> > > +}
> > >else
> > >  {
> > >core = exp;
> > > Index: gcc/testsuite/g++.dg/opt/pr80275.C
> > > ===
> > > --- gcc/testsuite/g++.dg/opt/pr80275.C(nonexistent)
> > > +++ gcc/testsuite/g++.dg/opt/pr80275.C(working copy)
> > > @@ -0,0 +1,16 @@
> > > +// { dg-do compile { target c++14 } }
> > > +// { dg-options "-O2 -fdump-tree-optimized" }
> > > +
> > > +#include 
> > > +
> > > +int g()
> > > +{
> > > +  return 1234;
> > > +}
> > > +
> > > +int f2()
> > > +{
> > > +  return std::min({1, g(), 4});
> > > +}
> > > +
> > > +// { dg-final { scan-tree-dump "return 1;" "optimized" } }
> > 
> > The testcase fails with -fpic, e.g.:
> > https://gcc.gnu.org/ml/gcc-regression/2017-04/msg2.html
> > 
> > So perhaps:
> > 
> > diff --git a/gcc/testsuite/g++.dg/opt/pr80275.C
> > b/gcc/testsuite/g++.dg/opt/pr80275.C
> > index 7296a07fb2dd..7d625f2c7757 100644
> > --- a/gcc/testsuite/g++.dg/opt/pr80275.C
> > +++ b/gcc/testsuite/g++.dg/opt/pr80275.C
> > @@ -1,4 +1,4 @@
> > -// { dg-do compile { target c++14 } }
> > +// { dg-do compile { target c++14 && nonpic } }
> > // { dg-options "-O2 -fdump-tree-optimized" }
> > 
> > #include 
> 
> Making g static should work even with PIC.

Tested on x86_64-unknown-linux-gnu, applied.

Richard.

2017-04-04  Richard Biener  

PR tree-optimization/80275
* g++.dg/opt/pr80275.C: Make g static.

Index: gcc/testsuite/g++.dg/opt/pr80275.C
===
--- gcc/testsuite/g++.dg/opt/pr80275.C  (revision 246670)
+++ gcc/testsuite/g++.dg/opt/pr80275.C  (working copy)
@@ -3,7 +3,7 @@
 
 #include 
 
-int g()
+static int g()
 {
   return 1234;
 }