[PATCH] df: Change defs in entry and uses in exit block during separate shrink-wrapping

2016-11-12 Thread Segher Boessenkool
So far all target implementations of the separate shrink-wrapping hooks
use the DF LIVE info to figure out around which basic blocks the non-
volatile registers need to be saved.  This is done by looking at the
IN+GEN+KILL sets of the basic blocks.  However, that doesn't work for
registers that DF says are defined in the entry block, or used in the
exit block.

This patch introduces a shrink_wrap_separate_in_progress variable, and
makes df_get_entry_block_def_set and df_get_exit_block_use_set set the
respective sets to empty if that variable is set to true.  It also
changes the rs6000 port to use IN+GEN+KILL for the LR component.

[  is an older
version of this, using a different (much inferior) approach. ]

Tested on powerpc64-linux {-m32,-m64}.  Is this okay for trunk?


Segher


2016-11-12  Segher Boessenkool  

* config/rs6000/rs6000.c (rs6000_components_for_bb): Mark the LR
component as used also if LR_REGNO is a live input to the bb.
* df-scan.c (df_get_entry_block_def_set): Return immediately after
clearing the set if shrink_wrap_separate_in_progress.
(df_get_exit_block_use_set): Ditto.
* rtl.h (shrink_wrap_separate_in_progress): Declare new variable.
* shrink-wrap.c (shrink_wrap_separate_in_progress): New variable.
(try_shrink_wrapping_separate): Set shrink_wrap_separate_in_progress
and call df_update_entry_block_defs and df_update_exit_block_uses
at the start; clear that variable and call those functions at the end.

---
 gcc/config/rs6000/rs6000.c |  3 ++-
 gcc/df-scan.c  | 16 
 gcc/rtl.h  |  3 +++
 gcc/shrink-wrap.c  | 12 
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 49985f1..8d6b2d5 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -27714,7 +27714,8 @@ rs6000_components_for_bb (basic_block bb)
   bitmap_set_bit (components, regno);
 
   /* LR needs to be saved around a bb if it is killed in that bb.  */
-  if (bitmap_bit_p (gen, LR_REGNO)
+  if (bitmap_bit_p (in, LR_REGNO)
+  || bitmap_bit_p (gen, LR_REGNO)
   || bitmap_bit_p (kill, LR_REGNO))
 bitmap_set_bit (components, 0);
 
diff --git a/gcc/df-scan.c b/gcc/df-scan.c
index 7cfd34b..398842b 100644
--- a/gcc/df-scan.c
+++ b/gcc/df-scan.c
@@ -3506,6 +3506,14 @@ df_get_entry_block_def_set (bitmap entry_block_defs)
 
   bitmap_clear (entry_block_defs);
 
+  /* For separate shrink-wrapping we use LIVE to analyze which basic blocks
+ need a prologue for some component to be executed before that block,
+ and we do not care about any other registers.  Hence, we do not want
+ any register for any component defined in the entry block, and we can
+ just leave all registers undefined.  */
+  if (shrink_wrap_separate_in_progress)
+return;
+
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
 {
   if (global_regs[i])
@@ -3665,6 +3673,14 @@ df_get_exit_block_use_set (bitmap exit_block_uses)
 
   bitmap_clear (exit_block_uses);
 
+  /* For separate shrink-wrapping we use LIVE to analyze which basic blocks
+ need an epilogue for some component to be executed after that block,
+ and we do not care about any other registers.  Hence, we do not want
+ any register for any component seen as used in the exit block, and we
+ can just say no registers at all are used.  */
+  if (shrink_wrap_separate_in_progress)
+return;
+
   /* Stack pointer is always live at the exit.  */
   bitmap_set_bit (exit_block_uses, STACK_POINTER_REGNUM);
 
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 3bb6a22..d1409bc 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -3468,6 +3468,9 @@ extern int lra_in_progress;
 
 #define can_create_pseudo_p() (!reload_in_progress && !reload_completed)
 
+/* Set to true during separate shrink-wrapping.  */
+extern bool shrink_wrap_separate_in_progress;
+
 #ifdef STACK_REGS
 /* Nonzero after end of regstack pass.
Set to 1 or 0 by reg-stack.c.  */
diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
index e480d4d..dd0cae1 100644
--- a/gcc/shrink-wrap.c
+++ b/gcc/shrink-wrap.c
@@ -1764,6 +1764,10 @@ insert_prologue_epilogue_for_components (sbitmap 
components)
   commit_edge_insertions ();
 }
 
+/* Used by DF: if true, the entry block defines no registers, and the exit
+   block uses none.  */
+bool shrink_wrap_separate_in_progress = false;
+
 /* The main entry point to this subpass.  FIRST_BB is where the prologue
would be normally put.  */
 void
@@ -1794,6 +1798,9 @@ try_shrink_wrapping_separate (basic_block first_bb)
 return;
 
   /* We need LIVE info.  */
+  shrink_wrap_separate_in_progress = true;
+  df_update_entry_block_defs ();
+  df_update_exit_block_uses ();
   df_live_add_problem ();
   df_live_set_all_dirty ();
   df_analyze ();
@@ -1859,6 +1866,11 @@ try_shrink_wrapping_separate (basic

Re: [PATCH, RFC] Improve ivopts group costs

2016-11-12 Thread Evgeny Kudryashov

On 2016-11-10 13:30, Bin.Cheng wrote:

Hi,
I see the cost problem with your test now.  When computing an address
type iv_use with a candidate, the computation consists of two parts,
for computation can be represented by addressing mode, it is done in
memory reference; for computation cannot be represented by addressing
mode, it is done outside of memory reference.  The final cost is added
up from the two computation parts.
For address iv_use:
MEM[base + biv << scale + offset]
when it is computed with below candidate on target only supports [base
+ biv << scale] addressing mode:
biv
The computations would be like:
base' = base + offset
MEM[base' + biv << scale]
Both computations has its own cost, the first one is normal RTX cost,
the second one is addressing mode cost.  Final cost is added up from
both parts.

Normally, all these cost should be added up in cost model, but there
should be one exception found in your test: If iv_uses of a group has
exactly the same iv ({base, step}), the first part computation (RTX)
can be shared among all iv_uses, thus the cost should only counted one
time.  That is, we should be able to model such CSE opportunities.
Apparently, we can't CSE the second part computation, of course there
won't be CSE opportunities in address expression anyway.


Hi Bin,
Yes, that is exactly what happens. And this computation might be cheaper 
than initialization and increment of new iv and it would be more 
preferable.



That said, this patch should make difference between cost of RTX
computation and address expression, and only add up RTX cost once if
it can be CSEed.  Well, it might be not trivial to check CSE
opportunities of RTX computation, for example, some iv_uses of the
group are the same, others are not.

Thanks,
bin


Since uses in a given group have the same base and step, they can only 
differ by offsets. Among those, equivalent offsets can be CSE'd. Then, 
perhaps it's possible to use a hash set of unique offsets in this group 
cost estimation loop, and count RTX computation cost only when adding a 
new entry to the set. What do you think about this approach?


While working on this issue, I've found another problem: that costs may 
become negative. That looks unintended, I have filed a new bug: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78332


Thanks,
Evgeny.


Re: [Patch, Fortran, F03] PR 77501: ICE in gfc_match_generic, at fortran/decl.c:9429

2016-11-12 Thread Janus Weil
2016-11-11 19:21 GMT+01:00 Steve Kargl :
> On Fri, Nov 11, 2016 at 02:38:25PM +0100, Janus Weil wrote:
>>
>> 2016-11-11  Janus Weil  
>>
>> PR fortran/77501
>> * decl.c (gfc_match_decl_type_spec): Use gfc_get_tbp_symtree,
>> fix indentation.
>> (gfc_match_generic): Remove an unnecessary assert.
>> Use gfc_get_tbp_symtree to avoid ICE.
>>
>> 2016-11-11  Janus Weil  
>>
>> PR fortran/77501
>> * gfortran.dg/typebound_generic_16.f90: New test.
>
> OK.

Thanks Steve, committed as r242335 (together with the additional
changes to gfc_get_tbp_symtree).

Cheers,
Janus


New Spanish PO file for 'gcc' (version 6.2.0)

2016-11-12 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the Spanish team of translators.  The file is available at:

http://translationproject.org/latest/gcc/es.po

(This file, 'gcc-6.2.0.es.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

http://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

http://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




Re: Fix PR77881: combine improvement

2016-11-12 Thread Segher Boessenkool
Hi Michael,

On Thu, Oct 20, 2016 at 04:20:09PM +0200, Michael Matz wrote:
>   PR missed-optimization/77881
>   * combine.c (simplify_comparison): Remove useless subregs
>   also inside the loop, not just after it.
> 
> testsuite/
>   * gcc.target/i386/pr77881.c: New test.

This isn't checked in yet, do you still want it?

Thanks,


Segher


[PATCH] microMIPS/GCC: Fix PIC call relaxation

2016-11-12 Thread Maciej W. Rozycki
Fix `-mrelax-pic-calls' support for microMIPS code where the relocation 
produced is supposed to be R_MICROMIPS_JALR rather than R_MIPS_JALR.  
The lack of short delay support comes from a missed update to this code 
for microMIPS support and can be relieved as JALRS and JRS instructions 
can be relaxed to BALS and B instructions respectively, so do that as 
well.

By doing so complement commit r196828 ("microMIPS gcc support"), 
, which is the 
original change that introduced microMIPS support, in particular to 
MIPS_CALL, which is where this code previously resided.

Adjust the test suite accordingly, limiting R_MICROMIPS_JALR cases to 
regular MIPS code only, and adding corresponding R_MICROMIPS_JALR cases 
for microMIPS code.

gcc/
* config/mips/mips.c (mips_output_jump): Output R_MICROMIPS_JALR
rather than R_MIPS_JALR relocation in microMIPS code.  Do not
cancel short delay slots in PIC call relaxation.

gcc/testsuite/
* gcc.target/mips/call-1.c (dg-options): Add `-mno-micromips'.
(dg-final): Remove microMIPS JALRS mnemonic matching.
* gcc.target/mips/call-2.c (dg-options): Add `-mno-micromips'.
(dg-final): Remove microMIPS JALRS mnemonic matching.
* gcc.target/mips/call-3.c (dg-options): Add `-mno-micromips'.
(dg-final): Remove microMIPS JALRS mnemonic matching.
* gcc.target/mips/call-4.c (dg-options): Add `-mno-micromips'.
* gcc.target/mips/call-5.c (dg-options): Add `-mno-micromips'.
* gcc.target/mips/call-6.c (dg-options): Add `-mno-micromips'.
* gcc.target/mips/call-1u.c: New test case.
* gcc.target/mips/call-2u.c: New test case.
* gcc.target/mips/call-3u.c: New test case.
* gcc.target/mips/call-4u.c: New test case.
* gcc.target/mips/call-5u.c: New test case.
* gcc.target/mips/call-6u.c: New test case.
---
 NB the use of this feature for microMIPS is limited because short 
encodings of register jump instructions usually do not have their branch 
counterparts and long encodings typically are not used.  However at least 
tail calls can be converted if the jump target is in range, as can calls 
in `-minsn32' code.  Perhaps we could switch to producing `j[al]r[s].32' 
in the `-mrelax-pic-calls' mode like GAS does with the `jal' and `j' 
microMIPS macros in PIC code.

 This change, with commit r235825 reverted (see PR rtl-optimization/78325, 
), has passed 
regression testing with the `mips-mti-linux-gnu' target, using the 
big-endian regular MIPS o32 multilib.

 I think verifying with a microMIPS multilib would be worth doing too, 
however it would take a long time, owing to readily available microMIPS 
hardware being limited in terms of performance; and I am not currently set 
up for simulator testing.  It is a fix for an evident code generation bug 
though and by the nature of the change switching the relocation type only 
and permitting short delay slots with PIC call relaxation any reasonably 
possible fallout would only happen with the assembler and/or linker.  So 
while I do intend to push this through microMIPS testing eventually, it 
will likely take a bit yet (with the bit being weeks to months).

 Let me know if the lack of microMIPS results would be a problem for this 
patch's acceptance.  Otherwise, OK to apply?

  Maciej

gcc-umips-jalr.diff
Index: gcc/gcc/config/mips/mips.c
===
--- gcc.orig/gcc/config/mips/mips.c 2016-11-11 19:55:39.727013997 +
+++ gcc/gcc/config/mips/mips.c  2016-11-11 21:02:20.655335552 +
@@ -13611,12 +13611,9 @@ mips_output_jump (rtx *operands, int tar
s += sprintf (s, ".option\tpic0\n\t");
 
   if (reg_p && mips_get_pic_call_symbol (operands, size_opno))
-   {
- s += sprintf (s, "%%*.reloc\t1f,R_MIPS_JALR,%%%d\n1:\t", size_opno);
- /* Not sure why this shouldn't permit a short delay but it did not
-allow it before so we still don't allow it.  */
- short_delay = "";
-   }
+   s += sprintf (s, "%%*.reloc\t1f,%s,%%%d\n1:\t",
+ TARGET_MICROMIPS ? "R_MICROMIPS_JALR" : "R_MIPS_JALR",
+ size_opno);
   else
s += sprintf (s, "%%*");
 
Index: gcc/gcc/testsuite/gcc.target/mips/call-1.c
===
--- gcc.orig/gcc/testsuite/gcc.target/mips/call-1.c 2016-11-12 
10:09:33.548220788 +
+++ gcc/gcc/testsuite/gcc.target/mips/call-1.c  2016-11-12 10:09:55.004824221 
+
@@ -1,8 +1,8 @@
-/* { dg-options "-mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=32" 
} */
+/* { dg-options "-mno-micromips -mrelax-pic-calls -mshared 
-foptimize-sibling-calls -mabi=32" } */
 /* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } 
} */
-/* { dg-final { 

[PATCH] rs6000: Don't forget to initialize the TOC (PR77957)

2016-11-12 Thread Segher Boessenkool
The code generating traceback tables mistakenly does an early return
if !optional_tbtab, which causes it to miss the code generating the TOC
section.  This only matters if the TOC will be empty since otherwise
the section is created elsewhere.

This patch fixes it.  It will need a backport to 6 as well, and
although I couldn't get it to fail with 5 the code has the same problem
there.

Tested on powerpc64-linux {-m32,-m64}; committing to trunk.

(The patch looks much bigger than it is, it is mostly a reindent).


Segher


2016-11-12  Segher Boessenkool  

PR target/77957
* config/rs6000/rs6000.c (rs6000_output_function_epilogue): Don't
return early if !optional_tbtab.

---
 gcc/config/rs6000/rs6000.c | 77 +++---
 1 file changed, 39 insertions(+), 38 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 03f81a8..bab4dfc 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -30320,53 +30320,54 @@ rs6000_output_function_epilogue (FILE *file,
 seems to set the bit when not optimizing.  */
   fprintf (file, "%d\n", ((float_parms << 1) | (! optimize)));
 
-  if (! optional_tbtab)
-   return;
+  if (optional_tbtab)
+   {
+ /* Optional fields follow.  Some are variable length.  */
 
-  /* Optional fields follow.  Some are variable length.  */
+ /* Parameter types, left adjusted bit fields: 0 fixed, 10 single
+float, 11 double float.  */
+ /* There is an entry for each parameter in a register, in the order
+that they occur in the parameter list.  Any intervening arguments
+on the stack are ignored.  If the list overflows a long (max
+possible length 34 bits) then completely leave off all elements
+that don't fit.  */
+ /* Only emit this long if there was at least one parameter.  */
+ if (fixed_parms || float_parms)
+   fprintf (file, "\t.long %d\n", parm_info);
 
-  /* Parameter types, left adjusted bit fields: 0 fixed, 10 single float,
-11 double float.  */
-  /* There is an entry for each parameter in a register, in the order that
-they occur in the parameter list.  Any intervening arguments on the
-stack are ignored.  If the list overflows a long (max possible length
-34 bits) then completely leave off all elements that don't fit.  */
-  /* Only emit this long if there was at least one parameter.  */
-  if (fixed_parms || float_parms)
-   fprintf (file, "\t.long %d\n", parm_info);
+ /* Offset from start of code to tb table.  */
+ fputs ("\t.long ", file);
+ ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LT");
+ RS6000_OUTPUT_BASENAME (file, fname);
+ putc ('-', file);
+ rs6000_output_function_entry (file, fname);
+ putc ('\n', file);
 
-  /* Offset from start of code to tb table.  */
-  fputs ("\t.long ", file);
-  ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LT");
-  RS6000_OUTPUT_BASENAME (file, fname);
-  putc ('-', file);
-  rs6000_output_function_entry (file, fname);
-  putc ('\n', file);
+ /* Interrupt handler mask.  */
+ /* Omit this long, since we never set the interrupt handler bit
+above.  */
 
-  /* Interrupt handler mask.  */
-  /* Omit this long, since we never set the interrupt handler bit
-above.  */
+ /* Number of CTL (controlled storage) anchors.  */
+ /* Omit this long, since the has_ctl bit is never set above.  */
 
-  /* Number of CTL (controlled storage) anchors.  */
-  /* Omit this long, since the has_ctl bit is never set above.  */
+ /* Displacement into stack of each CTL anchor.  */
+ /* Omit this list of longs, because there are no CTL anchors.  */
 
-  /* Displacement into stack of each CTL anchor.  */
-  /* Omit this list of longs, because there are no CTL anchors.  */
+ /* Length of function name.  */
+ if (*fname == '*')
+   ++fname;
+ fprintf (file, "\t.short %d\n", (int) strlen (fname));
 
-  /* Length of function name.  */
-  if (*fname == '*')
-   ++fname;
-  fprintf (file, "\t.short %d\n", (int) strlen (fname));
+ /* Function name.  */
+ assemble_string (fname, strlen (fname));
 
-  /* Function name.  */
-  assemble_string (fname, strlen (fname));
+ /* Register for alloca automatic storage; this is always reg 31.
+Only emit this if the alloca bit was set above.  */
+ if (frame_pointer_needed)
+   fputs ("\t.byte 31\n", file);
 
-  /* Register for alloca automatic storage; this is always reg 31.
-Only emit this if the alloca bit was set above.  */
-  if (frame_pointer_needed)
-   fputs ("\t.byte 31\n", file);
-
-  fputs ("\t.align 2\n", file);
+ fputs ("\t.align 2\n", file

Re: [PATCH] rs6000: Don't forget to initialize the TOC (PR77957)

2016-11-12 Thread David Edelsohn
On Sat, Nov 12, 2016 at 10:07 AM, Segher Boessenkool
 wrote:
> The code generating traceback tables mistakenly does an early return
> if !optional_tbtab, which causes it to miss the code generating the TOC
> section.  This only matters if the TOC will be empty since otherwise
> the section is created elsewhere.
>
> This patch fixes it.  It will need a backport to 6 as well, and
> although I couldn't get it to fail with 5 the code has the same problem
> there.
>
> Tested on powerpc64-linux {-m32,-m64}; committing to trunk.
>
> (The patch looks much bigger than it is, it is mostly a reindent).
>
>
> Segher
>
>
> 2016-11-12  Segher Boessenkool  
>
> PR target/77957
> * config/rs6000/rs6000.c (rs6000_output_function_epilogue): Don't
> return early if !optional_tbtab.

Okay.

Thanks, David


Re: [Patch 4/5] OpenACC tile clause support, Fortran front-end parts

2016-11-12 Thread Cesar Philippidis
On 11/11/2016 02:34 AM, Jakub Jelinek wrote:
> On Thu, Nov 10, 2016 at 06:46:46PM +0800, Chung-Lin Tang wrote:

And here's the patch.

Cesar

>> 2016-XX-XX  Cesar Philippidis  
>>
>>  fortran/
>>  * openmp.c (resolve_oacc_positive_int_expr): Promote the warning
>>  to an error.
>>  (resolve_oacc_loop_blocks): Use integer zero to represent the '*'
>>  tile argument.
>>  (resolve_omp_clauses): Error on directives containing both tile
>>  and collapse clauses.
>>  * trans-openmp.c (gfc_trans_omp_do): Lower tiled loops like
>>  collapsed loops.
>>
>>
>>  gcc/testsuite/
>>  * gfortran.dg/goacc/loop-2.f95: Change expected tile clause
>> warnings to errors.
>> * gfortran.dg/goacc/loop-5.f95: Likewise.
>> * gfortran.dg/goacc/sie.f95: Likewise.
>> * gfortran.dg/goacc/tile-1.f90: New test.
>> * gfortran.dg/goacc/tile-2.f90: New test
>> * gfortran.dg/goacc/tile-lowering.f95: New test.
> 
> Again, 8 spaces in ChangeLog.  Missing full stop after New test
> 
>> --- fortran/openmp.c (revision 241809)
>> +++ fortran/openmp.c (working copy)
>> @@ -3024,8 +3024,8 @@ resolve_oacc_positive_int_expr (gfc_expr *expr, co
>>resolve_oacc_scalar_int_expr (expr, clause);
>>if (expr->expr_type == EXPR_CONSTANT && expr->ts.type == BT_INTEGER
>>&& mpz_sgn(expr->value.integer) <= 0)
>> -gfc_warning (0, "INTEGER expression of %s clause at %L must be 
>> positive",
>> - clause, &expr->where);
>> +gfc_error ("INTEGER expression of %s clause at %L must be positive",
>> +   clause, &expr->where);
>>  }
> 
> This can't be against current trunk.  The current routine is shared with
> OpenMP and gfc_error is undesirable there.
> 
>> @@ -3859,6 +3859,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_claus
>>  if (omp_clauses->wait_list)
>>for (el = omp_clauses->wait_list; el; el = el->next)
>>  resolve_oacc_scalar_int_expr (el->expr, "WAIT");
>> +  if (omp_clauses->collapse && omp_clauses->tile_list)
>> +gfc_error ("Incompatible use of TILE and COLLAPSE at %L", &code->loc);
> 
> Shouldn't you in that case for error recovery clear collapse (or tile_list)?
> 
>   Jakub
> 

2016-11-11  Cesar Philippidis  
	Thomas Schwinge  

	gcc/cp/
	* cp-tree.h (bind_decls_match): Declare.
	* decl.c (bind_decls_match): New function.
	* parser.c (cp_parser_omp_clause_name): 
	(cp_parser_oacc_shape_clause): New location_t loc argument.  Use it
	to report more accurate diagnostics.
	(cp_parser_oacc_clause_bind): New function.
	(cp_parser_oacc_all_clauses): Handle OpenACC bind and nohost clauses.
	Update calls to c_parser_oacc_{simple,shape}_clause.
	(OACC_ROUTINE_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_{BIND,NOHOST}.
	(cp_parser_oacc_routine): Update diagnostics.
	(cp_parser_late_parsing_oacc_routine): Likewise.
	(cp_finalize_oacc_routine): Likewise.
	* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_{BIND,NOHOST}.


diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 8183775..efd5450 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5772,6 +5772,7 @@ extern void finish_scope			(void);
 extern void push_switch(tree);
 extern void pop_switch(void);
 extern tree make_lambda_name			(void);
+extern int bind_decls_match			(tree, tree);
 extern int decls_match(tree, tree);
 extern tree duplicate_decls			(tree, tree, bool);
 extern tree declare_local_label			(tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 185c98b..7b242781 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1198,6 +1198,138 @@ decls_match (tree newdecl, tree olddecl)
   return types_match;
 }
 
+/* Similiar to decls_match, but only applies to FUNCTION_DECLS.  Functions
+   in separate namespaces may match.
+*/
+
+int
+bind_decls_match (tree newdecl, tree olddecl)
+{
+  int types_match;
+
+  if (newdecl == olddecl)
+return 1;
+
+  if (TREE_CODE (newdecl) != TREE_CODE (olddecl))
+/* If the two DECLs are not even the same kind of thing, we're not
+   interested in their types.  */
+return 0;
+
+  gcc_assert (DECL_P (newdecl));
+  gcc_assert (TREE_CODE (newdecl) == FUNCTION_DECL);
+
+  tree f1 = TREE_TYPE (newdecl);
+  tree f2 = TREE_TYPE (olddecl);
+  tree p1 = TYPE_ARG_TYPES (f1);
+  tree p2 = TYPE_ARG_TYPES (f2);
+  tree r2;
+
+  /* Specializations of different templates are different functions
+ even if they have the same type.  */
+  tree t1 = (DECL_USE_TEMPLATE (newdecl)
+	 ? DECL_TI_TEMPLATE (newdecl)
+	 : NULL_TREE);
+  tree t2 = (DECL_USE_TEMPLATE (olddecl)
+	 ? DECL_TI_TEMPLATE (olddecl)
+	 : NULL_TREE);
+  if (t1 != t2)
+return 0;
+
+  if (CP_DECL_CONTEXT (newdecl) != CP_DECL_CONTEXT (olddecl)
+  && TREE_CODE (CP_DECL_CONTEXT (newdecl)) != NAMESPACE_DECL
+  && TREE_CODE (CP_DECL_CONTEXT (olddecl)) != NAMESPACE_DECL
+  && ! (DECL_EXTERN_C_P (newdecl)
+	&& DECL_EXTERN_C_P (olddecl)))
+return 0;
+
+  /* A new declaration doesn't match a built-in one

Re: [Patch, Fortran, F03] PR 77501: ICE in gfc_match_generic, at fortran/decl.c:9429

2016-11-12 Thread Mikael Morin

Le 11/11/2016 à 19:30, Steve Kargl a écrit :

On Fri, Nov 11, 2016 at 03:05:06PM +0100, Janus Weil wrote:

2016-11-11 14:38 GMT+01:00 Janus Weil :

[Btw, speaking of gfc_get_tbp_symtree: Can anyone tell me by chance
why it is necessary to nullify 'result->n.tb' on a newly-created
symtree?]


Removing the corresponding line does not do any harm to the testsuite,
as I just verified:

Index: gcc/fortran/class.c
===
--- gcc/fortran/class.c(Revision 242066)
+++ gcc/fortran/class.c(Arbeitskopie)
@@ -2970,7 +2970,6 @@ gfc_get_tbp_symtree (gfc_symtree **root, const cha
 {
   result = gfc_new_symtree (root, name);
   gcc_assert (result);
-  result->n.tb = NULL;
 }

   return result;



I think the assert can be removed as well.  gfc_new_symtree
is defined by XCNEW, which is defined in terms of xcalloc,
which is defined in libiberty/xmalloc.c in terms of calloc.
calloc zeros allocated memory.  xcalloc also checks for a
valid allocation, so gcc_assert is redundant.


And you can remove «tbp» from the function name, as there is nothing 
related to typebound procedures any more.


[v3 PATCH] Implement P0504R0 (Revisiting in-place tag types for any/optional/variant).

2016-11-12 Thread Ville Voutilainen
Tested on Linux-x64. We need to get this in before we ship
std::any, std::variant or std::optional.

2016-11-12  Ville Voutilainen  

Implement P0504R0 (Revisiting in-place tag types for
any/optional/variant).
* include/std/any (any(_ValueType&& __value)): Constrain
the __is_in_place_type with the decayed type.
(make_any): Adjust to use the new tag type.
* include/std/utility (in_place_tag): Remove.
(in_place_t): Turn into a non-reference tag type.
(__in_place, __in_place_type, __in_place_index): Remove.
(in_place): Turn into an inline variable of non-reference
tag type.
(in_place<_Tp>): Remove.
(in_place_index<_Idx>): Remove.
(in_place_type_t): New.
(in_place_type): Turn into a variable template of non-reference
type.
(in_place_index_t): New.
(in_place_index): Turn into a variable template of non-reference
type.
* include/std/variant
(_Variant_storage(in_place_index_t<_Np>, _Args&&...)): Adjust to
use the new tag type.
(_Union(in_place_index_t<0>, _Args&&...)): Likewise.
(_Union(in_place_index_t<_Np>, _Args&&...)): Likewise.
(_Variant_base()): Likewise.
(variant(_Tp&&)): Likewise.
(variant(in_place_type_t<_Tp>, _Args&&...)): Likewise.
(variant(in_place_type_t<_Tp>, initializer_list<_Up>,
 _Args&&...)): Likewise.
(variant(in_place_index_t<_Np>, _Args&&...)): Likewise.
(variant(in_place_index_t<_Np>, initializer_list<_Up>,
 _Args&&...)): Likewise
(variant(allocator_arg_t, const _Alloc&)): Likewise.
(variant(allocator_arg_t, const _Alloc&, _Tp&&)): Likewise.
(variant(allocator_arg_t, const _Alloc&, in_place_type_t<_Tp>,
 _Args&&...)): Likewise.
(variant(allocator_arg_t, const _Alloc&, in_place_type_t<_Tp>,
 initializer_list<_Up>, _Args&&...)): Likewise.
(variant(allocator_arg_t, const _Alloc&, in_place_index_t<_Np>,
 _Args&&...)): Likewise.
(variant(allocator_arg_t, const _Alloc&, in_place_index_t<_Np>,
 initializer_list<_Up>, _Args&&...)): Likewise.
(emplace(_Args&&...)): Likewise.
(emplace(initializer_list<_Up>, _Args&&...)): Likewise.
* testsuite/20_util/any/cons/explicit.cc: Likewise.
* testsuite/20_util/any/cons/in_place.cc: Likewise.
* testsuite/20_util/any/requirements.cc: Add tests to
check that any is not constructible from the new in_place_type_t
of any value category.
* testsuite/20_util/variant/compile.cc: Adjust to
use the new tag type.
* testsuite/20_util/variant/run.cc: Likewise.
diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 45a2145..574c18b 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -154,7 +154,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 template ,
  typename _Mgr = _Manager<_Tp>,
   __any_constructible_t<_Tp, _ValueType&&> = true,
- enable_if_t::value, bool> = true>
+ enable_if_t::value, bool> = true>
   any(_ValueType&& __value)
   : _M_manager(&_Mgr::_S_manage)
   {
@@ -166,7 +166,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  typename _Mgr = _Manager<_Tp>,
   enable_if_t<__and_,
 __not_>,
-__not_<__is_in_place_type<_ValueType>>>::value,
+__not_<__is_in_place_type<_Tp>>>::value,
  bool> = false>
   any(_ValueType&& __value)
   : _M_manager(&_Mgr::_S_manage)
@@ -402,14 +402,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template 
 any make_any(_Args&&... __args)
 {
-  return any(in_place<_Tp>, std::forward<_Args>(__args)...);
+  return any(in_place_type<_Tp>, std::forward<_Args>(__args)...);
 }
 
   /// Create an any holding a @c _Tp constructed from @c __il and @c __args.
   template 
 any make_any(initializer_list<_Up> __il, _Args&&... __args)
 {
-  return any(in_place<_Tp>, __il, std::forward<_Args>(__args)...);
+  return any(in_place_type<_Tp>, __il, std::forward<_Args>(__args)...);
 }
 
   /**
diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility
index 6a6659b..faf7316 100644
--- a/libstdc++-v3/include/std/utility
+++ b/libstdc++-v3/include/std/utility
@@ -336,25 +336,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cplusplus > 201402L
 
-  struct in_place_tag {
-in_place_tag() = delete;
+  struct in_place_t {
+explicit in_place_t() = default;
   };
 
-  struct __in_place;
-  template struct __in_place_type;
-  template struct __in_place_index;
-
-  using in_place_t = in_place_tag(&)(__in_place*);
-  template 
-using in_place_type_t = in_place_tag(&)(__in_place_type<_Tp>*);
-  template 
-using in_place_index_t = in_place_tag(&)(__in_place_index<_Idx>*);
-
-  inline in_place_tag in_place(__in_place*) {terminate();}
-  template 
-in_place_tag in_place(__in_place_type<_Tp>*) {terminate();}
-  template 
-in_place_tag in_place(__in_place_

[Patch] Remove variant, variant and variant<>

2016-11-12 Thread Tim Shen
At Issaquah we decided to remove the supports above.

Bootstrapped and tested on x86_64-linux-gnu.

Thanks!


-- 
Regards,
Tim Shen
Index: libstdc++-v3/include/std/variant
===
--- libstdc++-v3/include/std/variant	(revision 242337)
+++ libstdc++-v3/include/std/variant	(working copy)
@@ -136,42 +136,11 @@
 struct __reserved_type_map_impl
 { using type = add_cv_t<__reserved_type_map<_From, _To>>; };
 
-  // Stores a reference alternative as a... well, reference.
-  template
-struct _Reference_storage
-{
-  static_assert(is_reference_v<_Reference>,
-		"BUG: _Reference should be a reference");
-
-  _Reference_storage(_Reference __ref) noexcept : _M_storage(__ref) { }
-
-  operator _Reference() noexcept
-  { return static_cast<_Reference>(_M_storage); }
-
-  _Reference _M_storage;
-};
-
-  // Stores a void alternative, because it is not a regular type.
-  template
-struct _Void_storage { };
-
-  // Map from the alternative type to a non-qualified storage type.
-  template
-struct __storage_type
-{ using type = _Alternative; };
-
+  // This abstraction might be useful for future features,
+  // e.g. boost::recursive_wrapper.
   template
-struct __storage_type<_Alternative,
-			  enable_if_t>>
-{ using type = _Reference_storage<_Alternative>; };
+using __storage = _Alternative;
 
-  template
-struct __storage_type<_Alternative, enable_if_t>>
-{ using type = _Void_storage<_Alternative>; };
-
-  template
-using __storage = typename __storage_type<_Type>::type;
-
   template>
 struct _Uninitialized;
 
@@ -201,37 +170,15 @@
 	  _M_storage;
 };
 
-  // Reverse mapping of __storage_type.
-  template
-struct __alternative_type
-{
-  static_assert(!is_reference_v<_Storage_type>,
-		"BUG: _Storage_type should not be reference");
-  using type = _Storage_type;
-};
-
-  template
-struct __alternative_type<_Reference_storage<_Reference>>
-{ using type = _Reference; };
-
-  template
-struct __alternative_type<_Void_storage<_Void>>
-{ using type = _Void; };
-
   // Given a qualified storage type, return the desired reference.
-  // The qualified storage type is supposed to carry the variant object's
-  // qualifications and reference information, and the designated alternative's
-  // storage type.
-  // Returns the qualification-collapsed alternative references.
-  //
-  // For example, __get_alternative<_Reference_storage&> returns int&.
+  // For example, variant&& stores the int as __storage, and
+  // _Qualified_storage will be __storage&&.
   template
 decltype(auto)
 __get_alternative(void* __ptr)
 {
   using _Storage = decay_t<_Qualified_storage>;
-  using _Alternative = typename __alternative_type<_Storage>::type;
-  return __reserved_type_map<_Qualified_storage, _Alternative>(
+  return __reserved_type_map<_Qualified_storage, _Storage>(
 	*static_cast<_Storage*>(__ptr));
 }
 
@@ -969,6 +916,13 @@
 	variant<_Types...>>
 {
 private:
+  static_assert(sizeof...(_Types) > 0,
+		"variant must have at least one alternative");
+  static_assert(!(std::is_reference_v<_Types> || ...),
+		"variant must have no reference alternative");
+  static_assert(!(std::is_void_v<_Types> || ...),
+		"variant must have no void alternative");
+
   using _Base = __detail::__variant::_Variant_base<_Types...>;
   using _Default_ctor_enabler =
 	_Enable_default_constructor<
@@ -1264,11 +1218,6 @@
 __get_storage(_Vp&& __v);
 };
 
-  // To honor algebraic data type, variant<> should be a bottom type, which
-  // is 0 (as opposed to a void type, which is 1). Use incomplete type to model
-  // bottom type.
-  template<> class variant<>;
-
   template
 variant_alternative_t<_Np, variant<_Types...>>&
 get(variant<_Types...>& __v)
Index: libstdc++-v3/testsuite/20_util/variant/compile.cc
===
--- libstdc++-v3/testsuite/20_util/variant/compile.cc	(revision 242337)
+++ libstdc++-v3/testsuite/20_util/variant/compile.cc	(working copy)
@@ -55,7 +55,6 @@
 {
   static_assert(is_default_constructible_v>, "");
   static_assert(is_default_constructible_v>, "");
-  static_assert(!is_default_constructible_v>, "");
   static_assert(!is_default_constructible_v>, "");
   static_assert(is_default_constructible_v>, "");
 
@@ -124,14 +123,6 @@
   variant a(allocator_arg, alloc);
   static_assert(!is_constructible_v, allocator_arg_t, std::allocator>, "");
   {
-variant b(allocator_arg, alloc, a);
-static_assert(!is_constructible_v, allocator_arg_t, std::allocator, const variant&>, "");
-  }
-  {
-variant b(allocator_arg, alloc, std::move(a));
-static_assert(!is_constructible_v, allocator_arg_t, std::allocator, variant&&>, "");
-  }
-  {
 variant b(allocator_arg, alloc, "a");
 static_assert(!is_constructible_v,

[Patch, Fortran, OOP] PR 66366: ICE on invalid with non-allocatable CLASS variable

2016-11-12 Thread Janus Weil
Hi all,

this patch fixes an ICE on invalid code involving class component
declarations. The ICE is avoided by moving forward the error check
from resolution to parsing stage. For class components this is
possible, because the attributes have to be specified in the same line
(in contrast to class variables, where the attributes can be specified
in multiple statements, so that checking can only be done during
resolution).

Note that this fixes only the original example, but not comment 2
(which is a different issue).

Regtests cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus


2016-11-12  Janus Weil  

PR fortran/66366
* resolve.c (resolve_component): Move check for C437
to ...
* decl.c (build_struct): ... here. Fix indentation.

2016-11-12  Janus Weil  

PR fortran/66366
* gfortran.dg/class_60.f90: New test.
Index: gcc/fortran/decl.c
===
--- gcc/fortran/decl.c  (Revision 242339)
+++ gcc/fortran/decl.c  (Arbeitskopie)
@@ -1866,10 +1866,19 @@ build_struct (const char *name, gfc_charlen *cl, g
}
   else if (current_attr.allocatable == 0)
{
-  gfc_error ("Component at %C must have the POINTER attribute");
+ gfc_error ("Component at %C must have the POINTER attribute");
+ return false;
+   }
+}
+
+  /* F03:C437.  */
+  if (current_ts.type == BT_CLASS
+  && !(current_attr.pointer || current_attr.allocatable))
+{
+  gfc_error ("Component %qs with CLASS at %C must be allocatable "
+ "or pointer", name);
   return false;
 }
-}
 
   if (gfc_current_block ()->attr.pointer && (*as)->rank != 0)
 {
Index: gcc/fortran/resolve.c
===
--- gcc/fortran/resolve.c   (Revision 242339)
+++ gcc/fortran/resolve.c   (Arbeitskopie)
@@ -13587,19 +13587,6 @@ resolve_component (gfc_component *c, gfc_symbol *s
   return false;
 }
 
-  /* C437.  */
-  if (c->ts.type == BT_CLASS && c->attr.flavor != FL_PROCEDURE
-  && (!c->attr.class_ok
-  || !(CLASS_DATA (c)->attr.class_pointer
-   || CLASS_DATA (c)->attr.allocatable)))
-{
-  gfc_error ("Component %qs with CLASS at %L must be allocatable "
- "or pointer", c->name, &c->loc);
-  /* Prevent a recurrence of the error.  */
-  c->ts.type = BT_UNKNOWN;
-  return false;
-}
-
   /* If an allocatable component derived type is of the same type as
  the enclosing derived type, we need a vtable generating so that
  the __deallocate procedure is created.  */
Index: gcc/testsuite/gfortran.dg/class_57.f90
===
--- gcc/testsuite/gfortran.dg/class_57.f90  (Revision 242339)
+++ gcc/testsuite/gfortran.dg/class_57.f90  (Arbeitskopie)
@@ -18,7 +18,7 @@ contains
   function pc(pd)
 type(p) :: pc
 class(d), intent(in), target :: pd
-pc%cc => pd   ! { dg-error "Non-POINTER in pointer association context" }
+pc%cc => pd   ! { dg-error "is not a member of" }
   end function
 
 end
! { dg-do compile }
!
! PR 66366: [OOP] ICE on invalid with non-allocatable CLASS variable
!
! Contributed by Andrew Benson 

module bug

  type :: t1d
   contains
 procedure :: interpolate => interp
  end type t1d

  type :: tff
 class(t1d) :: transfer  ! { dg-error "must be allocatable or pointer" }
  end type tff

contains

  double precision function interp(self)
implicit none
class(t1d), intent(inout) :: self
return
  end function interp

  double precision function fvb(self)
implicit none
class(tff), intent(inout) :: self
fvb=self%transfer%interpolate()  ! { dg-error "is not a member of" }
return
  end function fvb

end module bug


Re: [PATCH] Five patches for std::experimental::filesystem

2016-11-12 Thread Jonathan Wakely

On 10/11/16 17:29 +, Chris Fairles wrote:

"cannot check is file is empty" -> *if


This patch fixes the typo. I haven't looked at the failure yet.

Will commit to trunk shortly.

commit 9882c567342019c9561b44e611af9d42cdf23f3b
Author: Jonathan Wakely 
Date:   Sat Nov 12 20:14:07 2016 +

	* src/filesystem/ops.cc (is_empty): Fix typo in exception message.

diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc
index 8ed0a10..0dcb1b4 100644
--- a/libstdc++-v3/src/filesystem/ops.cc
+++ b/libstdc++-v3/src/filesystem/ops.cc
@@ -1054,7 +1054,7 @@ fs::is_empty(const path& p)
   error_code ec;
   bool e = is_empty(p, ec);
   if (ec)
-_GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot check is file is empty",
+_GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot check if file is empty",
 	 p, ec));
   return e;
 }


Re: [Patch, Fortran, F03] PR 77501: ICE in gfc_match_generic, at fortran/decl.c:9429

2016-11-12 Thread Janus Weil
2016-11-12 20:15 GMT+01:00 Mikael Morin :
 [Btw, speaking of gfc_get_tbp_symtree: Can anyone tell me by chance
 why it is necessary to nullify 'result->n.tb' on a newly-created
 symtree?]
>>>
>>>
>>> Removing the corresponding line does not do any harm to the testsuite,
>>> as I just verified:
>>>
>>> Index: gcc/fortran/class.c
>>> ===
>>> --- gcc/fortran/class.c(Revision 242066)
>>> +++ gcc/fortran/class.c(Arbeitskopie)
>>> @@ -2970,7 +2970,6 @@ gfc_get_tbp_symtree (gfc_symtree **root, const cha
>>>  {
>>>result = gfc_new_symtree (root, name);
>>>gcc_assert (result);
>>> -  result->n.tb = NULL;
>>>  }
>>>
>>>return result;
>>>
>>
>> I think the assert can be removed as well.  gfc_new_symtree
>> is defined by XCNEW, which is defined in terms of xcalloc,
>> which is defined in libiberty/xmalloc.c in terms of calloc.
>> calloc zeros allocated memory.  xcalloc also checks for a
>> valid allocation, so gcc_assert is redundant.
>>
>>
> And you can remove «tbp» from the function name, as there is nothing related
> to typebound procedures any more.

True. Probably one should also move it to symbol.c.

However, one can wonder whether renaming to gfc_get_symtree would not
make the name too similar to gfc_get_sym_tree, which also lives in
symbol.c ...?

Cheers,
Janus


Re: [PATCH] Add std::future_error constructor from future_errc

2016-11-12 Thread Jonathan Wakely

On 12/11/16 02:34 -0500, Tim Song wrote:

On Fri, Nov 11, 2016 at 10:39 PM, Jonathan Wakely  wrote:

making the existing not-required-by-the-standard constructor private.



+  public:
+explicit
+future_error(error_code __ec)
+: logic_error("std::future_error: " + __ec.message()), _M_code(__ec)+{ 
}


That doesn't look private to me...


Whoops, fixed by this patch.

Tested powerpc64le-linux, committed to trunk.


commit 889e7308ad2c7072326698cc76b902d0cb189b6a
Author: Jonathan Wakely 
Date:   Sat Nov 12 18:08:06 2016 +

	* include/std/future (future_error): Fix public typo to private.

diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 4d125e8..cb42830 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 const error_code&
 code() const noexcept { return _M_code; }
 
-  public:
+  private:
 explicit
 future_error(error_code __ec)
 : logic_error("std::future_error: " + __ec.message()), _M_code(__ec)


Re: [Patch, Fortran, OOP] PR 66366: ICE on invalid with non-allocatable CLASS variable

2016-11-12 Thread Steve Kargl
On Sat, Nov 12, 2016 at 09:13:26PM +0100, Janus Weil wrote:
> 
> this patch fixes an ICE on invalid code involving class component
> declarations. The ICE is avoided by moving forward the error check
> from resolution to parsing stage. For class components this is
> possible, because the attributes have to be specified in the same line
> (in contrast to class variables, where the attributes can be specified
> in multiple statements, so that checking can only be done during
> resolution).
> 
> Note that this fixes only the original example, but not comment 2
> (which is a different issue).
> 
> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
> 

Looks good to me.  Thanks.

-- 
Steve


[PATCH], Add PowerPC ISA 3.0 support for xxinsertw, vinserth, and vinsertb instructions

2016-11-12 Thread Michael Meissner
I modified the vec_insert built-in so that it generates the insert word,
half-word, and byte instructions (XXINSERTW, VINSERTH, and VINSERTB) on ISA 3.0
(power9).

I did the usual bootstrap and make check with no regressions.  In addition, I
ran a program on the simulator that verified that the XXINSERTW code works.
Can I install this patch on the trunk?

[gcc]
2016-11-13  Michael Meissner  

* config/rs6000/rs6000.c (rs6000_expand_vector_set): Add support
for using xxinsertw and vinsert{b,h} on ISA 3.0.

* config/rs6000/vsx.md (vsx_extract_): Update comment.
(vsx_set__p9): New insn to generate xxinsertw and
vinsert{b,h} on ISA 3.0.

[gcc/testsuite]
2016-11-13  Michael Meissner  

* gcc.target/powerpc/vec-set-int.c: New test.
* gcc.target/powerpc/vec-set-short.c: Likesie.
* gcc.target/powerpc/vec-set-char.c: Likewise.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  
(svn+ssh://meiss...@gcc.gnu.org/svn/gcc/trunk/gcc/config/rs6000)
(revision 242318)
+++ gcc/config/rs6000/rs6000.c  (.../gcc/config/rs6000) (working copy)
@@ -7095,12 +7095,32 @@ rs6000_expand_vector_set (rtx target, rt
   int width = GET_MODE_SIZE (inner_mode);
   int i;
 
-  if (VECTOR_MEM_VSX_P (mode) && (mode == V2DFmode || mode == V2DImode))
+  if (VECTOR_MEM_VSX_P (mode))
 {
-  rtx (*set_func) (rtx, rtx, rtx, rtx)
-   = ((mode == V2DFmode) ? gen_vsx_set_v2df : gen_vsx_set_v2di);
-  emit_insn (set_func (target, target, val, GEN_INT (elt)));
-  return;
+  rtx (*set_func) (rtx, rtx, rtx, rtx) = (rtx (*) (rtx, rtx, rtx, rtx))0;
+
+  if (mode == V2DFmode)
+   set_func = gen_vsx_set_v2df;
+
+  else if (mode == V2DImode)
+   set_func = gen_vsx_set_v2di;
+
+  else if (TARGET_P9_VECTOR && TARGET_VSX_SMALL_INTEGER
+  && TARGET_UPPER_REGS_DI && TARGET_POWERPC64)
+   {
+ if (mode == V4SImode)
+   set_func = gen_vsx_set_v4si_p9;
+ else if (mode == V8HImode)
+   set_func = gen_vsx_set_v8hi_p9;
+ else if (mode == V16QImode)
+   set_func = gen_vsx_set_v16qi_p9;
+   }
+
+  if (set_func)
+   {
+ emit_insn (set_func (target, target, val, GEN_INT (elt)));
+ return;
+   }
 }
 
   /* Simplify setting single element vectors like V1TImode.  */
Index: gcc/config/rs6000/vsx.md
===
--- gcc/config/rs6000/vsx.md
(svn+ssh://meiss...@gcc.gnu.org/svn/gcc/trunk/gcc/config/rs6000)
(revision 242318)
+++ gcc/config/rs6000/vsx.md(.../gcc/config/rs6000) (working copy)
@@ -2514,9 +2514,9 @@ (define_expand "vec_perm_const"
 FAIL;
 })
 
-;; Extraction of a single element in a small integer vector.  None of the small
-;; types are currently allowed in a vector register, so we extract to a DImode
-;; and either do a direct move or store.
+;; Extraction of a single element in a small integer vector.  Until ISA 3.0,
+;; none of the small types were allowed in a vector register, so we had to
+;; extract to a DImode and either do a direct move or store.
 (define_expand  "vsx_extract_"
   [(parallel [(set (match_operand: 0 "gpc_reg_operand")
   (vec_select:
@@ -2839,6 +2839,31 @@ (define_insn_and_split "*vsx_extract_si_
   DONE;
 })
 
+;; V4SI/V8HI/V16QI set operation on ISA 3.0
+(define_insn "vsx_set__p9"
+  [(set (match_operand:VSX_EXTRACT_I 0 "gpc_reg_operand" "=")
+   (unspec:VSX_EXTRACT_I
+[(match_operand:VSX_EXTRACT_I 1 "gpc_reg_operand" "0")
+ (match_operand: 2 "gpc_reg_operand" "")
+ (match_operand:QI 3 "" "n")]
+UNSPEC_VSX_SET))]
+  "VECTOR_MEM_VSX_P (mode) && TARGET_P9_VECTOR && 
TARGET_VSX_SMALL_INTEGER
+   && TARGET_UPPER_REGS_DI && TARGET_POWERPC64"
+{
+  int ele = INTVAL (operands[3]);
+  int nunits = GET_MODE_NUNITS (mode);
+
+  if (!VECTOR_ELT_ORDER_BIG)
+ele = nunits - 1 - ele;
+
+  operands[3] = GEN_INT (nunits * ele);
+  if (mode == V4SImode)
+return "xxinsertw %x0,%x2,%3";
+  else
+return "vinsert %0,%2,%3";
+}
+  [(set_attr "type" "vecperm")])
+
 ;; Expanders for builtins
 (define_expand "vsx_mergel_"
   [(use (match_operand:VSX_D 0 "vsx_register_operand" ""))
Index: gcc/testsuite/gcc.target/powerpc/vec-set-char.c
===
--- gcc/testsuite/gcc.target/powerpc/vec-set-char.c 
(svn+ssh://meiss...@gcc.gnu.org/svn/gcc/trunk/gcc/testsuite/gcc.target/powerpc) 
(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/vec-set-char.c 
(.../gcc/testsuite/gcc.target/powerpc)  (revision 242346)
@@ -0,0 +1,40 @@
+#include 
+
+/* { dg-do compile { target { powerpc64*-*-* && lp64 } } } */
+/* { dg-skip-if "do not override -mcpu" { p

C++ PATCH for DR 374 (specialization outside of namespace)

2016-11-12 Thread Jason Merrill
In C++11 it's OK to declare a specialization for the first time
outside of the template's namespace, so long as the specialization is
explicitly qualified.  Conversely, C++11 puts the same restrictions on
explicit instantiations, whereas C++98 didn't say anything about where
they needed to go.  So I needed to update a bunch of libstdc++ tests
which didn't conform.

To enforce this for class templates I needed to hook into the parser
at the places where we still know whether or not a
nested-name-specifier was used; for non-class templates we preserve
that information long enough for check_explicit_instantiation to find
it.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 56bc587a8c075200a19b2175aaed648b8e9d88f5
Author: Jason Merrill 
Date:   Fri Nov 11 07:45:01 2016 -0800

DR 374 - specialization in outer namespace

PR c++/56840
* pt.c (check_specialization_namespace): Allow any enclosing
namespace.
(check_unqualified_spec_or_inst): New.
(check_explicit_specialization): Call it.
* parser.c (cp_parser_elaborated_type_specifier)
(cp_parser_class_head): Call it.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 8183775..3e41a33 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6082,6 +6082,7 @@ extern void reset_specialization  (void);
 extern void end_specialization (void);
 extern void begin_explicit_instantiation   (void);
 extern void end_explicit_instantiation (void);
+extern void check_unqualified_spec_or_inst (tree, location_t);
 extern tree check_explicit_specialization  (tree, tree, int, int);
 extern int num_template_headers_for_class  (tree);
 extern void check_template_variable(tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 185c98b..6101504 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7868,8 +7868,7 @@ check_class_member_definition_namespace (tree decl)
  diagnostics.  */
   if (processing_specialization)
 return;
-  /* There are no restrictions on the placement of
- explicit instantiations.  */
+  /* We check this in check_explicit_instantiation_namespace.  */
   if (processing_explicit_instantiation)
 return;
   /* [class.mfct]
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index e574c27..8db6cfd 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3558,7 +3558,7 @@ set_decl_namespace (tree decl, tree scope, bool friendp)
   /* Since decl is a function, old should contain a function decl.  */
   if (!is_overloaded_fn (old))
 goto complain;
-  /* A template can be explicitly specialized in any namespace.  */
+  /* We handle these in check_explicit_instantiation_namespace.  */
   if (processing_explicit_instantiation)
 return;
   if (processing_template_decl || processing_specialization)
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7b95dba..b3b69b3 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -17004,24 +17004,28 @@ cp_parser_elaborated_type_specifier (cp_parser* 
parser,
   globalscope =  cp_parser_global_scope_opt (parser,
 /*current_scope_valid_p=*/false);
   /* Look for the nested-name-specifier.  */
+  tree nested_name_specifier;
   if (tag_type == typename_type && !globalscope)
 {
-  if (!cp_parser_nested_name_specifier (parser,
+  nested_name_specifier
+   = cp_parser_nested_name_specifier (parser,
   /*typename_keyword_p=*/true,
   /*check_dependency_p=*/true,
   /*type_p=*/true,
-   is_declaration))
+  is_declaration);
+  if (!nested_name_specifier)
return error_mark_node;
 }
   else
 /* Even though `typename' is not present, the proposed resolution
to Core Issue 180 says that in `class A::B', `B' should be
considered a type-name, even if `A' is dependent.  */
-cp_parser_nested_name_specifier_opt (parser,
-/*typename_keyword_p=*/true,
-/*check_dependency_p=*/true,
-/*type_p=*/true,
-is_declaration);
+nested_name_specifier
+  = cp_parser_nested_name_specifier_opt (parser,
+/*typename_keyword_p=*/true,
+/*check_dependency_p=*/true,
+/*type_p=*/true,
+is_declaration);
  /* For everything but enumeration types, consider a template-id.
 For an enumeration type, consider only a plain identifier.  */
   if (tag_type != enum_type)
@@ -17069,8 +17073,18 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,

C++ PATCH for _Complex and constexpr

2016-11-12 Thread Jason Merrill
The constexpr code was treating __real/__imag as always producing an
rvalue, which is incorrect.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit b61d1ce84c2e66dde4662dab41ccd99dd360a02f
Author: Jason Merrill 
Date:   Sat Nov 12 10:45:14 2016 -0800

Fix constexpr lvalue use of __real and __imag.

* constexpr.c (potential_constant_expression_1): REALPART_EXPR and
IMAGPART_EXPR can be lvalues.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index f75f0b0..739e902 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5105,6 +5105,8 @@ potential_constant_expression_1 (tree t, bool want_rval, 
bool strict,
 #endif
   return RECUR (t, any);
 
+case REALPART_EXPR:
+case IMAGPART_EXPR:
 case COMPONENT_REF:
 case BIT_FIELD_REF:
 case ARROW_EXPR:
@@ -5276,8 +5278,6 @@ potential_constant_expression_1 (tree t, bool want_rval, 
bool strict,
return true;
   /* fall through.  */
 
-case REALPART_EXPR:
-case IMAGPART_EXPR:
 case CONJ_EXPR:
 case SAVE_EXPR:
 case FIX_TRUNC_EXPR:
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C 
b/gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C
new file mode 100644
index 000..9a9291b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C
@@ -0,0 +1,5 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+static _Complex int i;
+static_assert (&__imag i == &__imag i, "");


C++ PATCH for CWG2233

2016-11-12 Thread Jason Merrill
In Core working group discussions today we were looking at this
testcase, which caused the compiler to ICE because it assumed that
once we had seen one default argument, all following parameters would
have them as well.  This is no longer true now that we allow a
parameter pack to follow default arguments.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 4c59e1a2f90e1aa6f381692e843164ad0543f53b
Author: Jason Merrill 
Date:   Sat Nov 12 14:37:33 2016 -0800

CWG 2233 - default arg and parameter pack

* typeck.c (convert_arguments): Handle default arg followed by none.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 211696c..24ca1b5 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3835,6 +3835,10 @@ convert_arguments (tree typelist, vec 
**values, tree fndecl,
{
  for (; typetail != void_list_node; ++i)
{
+ /* After DR777, with explicit template args we can end up with a
+default argument followed by no default argument.  */
+ if (!TREE_PURPOSE (typetail))
+   break;
  tree parmval
= convert_default_arg (TREE_VALUE (typetail),
   TREE_PURPOSE (typetail),
@@ -3850,9 +3854,10 @@ convert_arguments (tree typelist, vec 
**values, tree fndecl,
break;
}
}
-  else
+
+  if (typetail && typetail != void_list_node)
{
-  if (complain & tf_error)
+ if (complain & tf_error)
error_args_num (input_location, fndecl, /*too_many_p=*/false);
  return -1;
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic169.C 
b/gcc/testsuite/g++.dg/cpp0x/variadic169.C
new file mode 100644
index 000..6858973
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic169.C
@@ -0,0 +1,9 @@
+// DR 2233
+// { dg-do compile { target c++11 } }
+
+template void f(int n = 0, T ...t);
+
+int main()
+{
+  f();// { dg-error "too few arguments" }
+}