[patch, fortran] Fix PR 69154, inline matmul with WHERE

2016-01-10 Thread Thomas Koenig

Hello world,

the attached patch fixes the regression.  Before this, front-end
optimization would have tried to put a DO loop inside a WHERE construct,
leading to an ICE.

Regression-tested. OK for trunk?

Thomas

2016-01-10  Thomas Koenig  

PR fortran/69154
* frontend-passes.c (in_where):  New variable.
(inline_matmul_assign):  Don't try this if we are within
a WHERE statement.
(gfc_code_walker):  Keep track of in_where.
Index: frontend-passes.c
===
--- frontend-passes.c	(revision 232196)
+++ frontend-passes.c	(working copy)
@@ -78,6 +78,10 @@ static int forall_level;
 
 static bool in_omp_workshare;
 
+/* Keep track of whether we are within a WHERE statement.  */
+
+static bool in_where;
+
 /* Keep track of iterators for array constructors.  */
 
 static int iterator_level;
@@ -2790,6 +2794,9 @@ inline_matmul_assign (gfc_code **c, int *walk_subt
   if (co->op != EXEC_ASSIGN)
 return 0;
 
+  if (in_where)
+return 0;
+
   expr1 = co->expr1;
   expr2 = co->expr2;
   if (expr2->expr_type != EXPR_FUNCTION
@@ -3268,6 +3275,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	  gfc_code *co;
 	  gfc_association_list *alist;
 	  bool saved_in_omp_workshare;
+	  bool saved_in_where;
 
 	  /* There might be statement insertions before the current code,
 	 which must not affect the expression walker.  */
@@ -3274,6 +3282,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 
 	  co = *c;
 	  saved_in_omp_workshare = in_omp_workshare;
+	  saved_in_where = in_where;
 
 	  switch (co->op)
 	{
@@ -3301,6 +3310,10 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	  WALK_SUBEXPR (co->ext.iterator->step);
 	  break;
 
+	case EXEC_WHERE:
+	  in_where = true;
+	  break;
+
 	case EXEC_CALL:
 	case EXEC_ASSIGN_CALL:
 	  for (a = co->ext.actual; a; a = a->next)
@@ -3554,6 +3567,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	doloop_level --;
 
 	  in_omp_workshare = saved_in_omp_workshare;
+	  in_where = saved_in_where;
 	}
 }
   return 0;
! { dg-do compile }
! PR 69154 - inlined matmul used to cause an ICE inside a WHERE.
MODULE m_numeric_tools
 INTEGER, PARAMETER :: dp=8
CONTAINS
subroutine llsfit_svd(xx,yy,sigma,nfuncs,funcs,chisq,par,var,cov,info)
 real(dp),intent(in) :: xx(:),yy(:),sigma(:)
 real(dp),dimension(SIZE(xx)) :: bb,sigm1
 real(dp) :: tmp(nfuncs)
 real(dp),allocatable :: work(:),Vt(:,:),U(:,:),S(:)
 WHERE (S>TOL_*MAXVAL(S))
  tmp=MATMUL(bb,U)/S
 END WHERE
end subroutine llsfit_svd
END MODULE m_numeric_tools


Re: [PATCH] Fix PR68707

2016-01-10 Thread Thomas Schwinge
Hi!

On Fri,  8 Jan 2016 11:30:16 +, Alan Lawrence  wrote:
> Here's an alternative patch, [...]

> +/* { dg-final { scan-tree-dump "note: Built SLP cancelled: can use 
> load/store-lanes" { target { vect_perm && vect_load_lanes } } } } */

For all these, you're missing to provide the "suffix" in the
'scan-tree-dump "note: [...]' directives, which results in:

UNRESOLVED: gcc.dg/vect/slp-perm-1.c -flto -ffat-lto-objects  
scan-tree-dump  target { vect_perm && vect_load_lanes }  "note: Built SLP 
cancelled: can use load/store-lanes"

The target selector doesn't trigger in my x86_64 GNU/Linux testing, but
to get rid of the UNRESOLVEDs, in r232197 I fixed at least the syntax as
follows:

commit 880ed4be84bfc9cec83d7c9718fd4f87a9ca8f39
Author: tschwinge 
Date:   Sun Jan 10 12:12:38 2016 +

Fix scan-tree-dump syntax

gcc/testsuite/
* gcc.dg/vect/slp-perm-1.c: Fix scan-tree-dump syntax.
* gcc.dg/vect/slp-perm-2.c: Likewise.
* gcc.dg/vect/slp-perm-3.c: Likewise.
* gcc.dg/vect/slp-perm-5.c: Likewise.
* gcc.dg/vect/slp-perm-6.c: Likewise.
* gcc.dg/vect/slp-perm-7.c: Likewise.
* gcc.dg/vect/slp-perm-8.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232197 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/testsuite/ChangeLog|   10 ++
 gcc/testsuite/gcc.dg/vect/slp-perm-1.c |2 +-
 gcc/testsuite/gcc.dg/vect/slp-perm-2.c |2 +-
 gcc/testsuite/gcc.dg/vect/slp-perm-3.c |2 +-
 gcc/testsuite/gcc.dg/vect/slp-perm-5.c |2 +-
 gcc/testsuite/gcc.dg/vect/slp-perm-6.c |2 +-
 gcc/testsuite/gcc.dg/vect/slp-perm-7.c |2 +-
 gcc/testsuite/gcc.dg/vect/slp-perm-8.c |2 +-
 8 files changed, 17 insertions(+), 7 deletions(-)

diff --git gcc/testsuite/ChangeLog gcc/testsuite/ChangeLog
index 198f26c..3005c9f 100644
--- gcc/testsuite/ChangeLog
+++ gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2016-01-10  Thomas Schwinge  
+
+   * gcc.dg/vect/slp-perm-1.c: Fix scan-tree-dump syntax.
+   * gcc.dg/vect/slp-perm-2.c: Likewise.
+   * gcc.dg/vect/slp-perm-3.c: Likewise.
+   * gcc.dg/vect/slp-perm-5.c: Likewise.
+   * gcc.dg/vect/slp-perm-6.c: Likewise.
+   * gcc.dg/vect/slp-perm-7.c: Likewise.
+   * gcc.dg/vect/slp-perm-8.c: Likewise.
+
 2016-01-10  Tom de Vries  
 
PR tree-optimization/69039
diff --git gcc/testsuite/gcc.dg/vect/slp-perm-1.c 
gcc/testsuite/gcc.dg/vect/slp-perm-1.c
index 6d0d66f..ee211f2 100644
--- gcc/testsuite/gcc.dg/vect/slp-perm-1.c
+++ gcc/testsuite/gcc.dg/vect/slp-perm-1.c
@@ -60,7 +60,7 @@ int main (int argc, const char* argv[])
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target 
vect_perm } } } */
 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { 
target { vect_perm && {! vect_load_lanes } } } } } */
 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { 
target vect_load_lanes } } } */
-/* { dg-final { scan-tree-dump "note: Built SLP cancelled: can use 
load/store-lanes" { target { vect_perm && vect_load_lanes } } } } */
+/* { dg-final { scan-tree-dump "note: Built SLP cancelled: can use 
load/store-lanes" "vect" { target { vect_perm && vect_load_lanes } } } } */
 /* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } 
} } */
 /* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } 
} } */
 
diff --git gcc/testsuite/gcc.dg/vect/slp-perm-2.c 
gcc/testsuite/gcc.dg/vect/slp-perm-2.c
index 34b413d..4bab348 100644
--- gcc/testsuite/gcc.dg/vect/slp-perm-2.c
+++ gcc/testsuite/gcc.dg/vect/slp-perm-2.c
@@ -56,6 +56,6 @@ int main (int argc, const char* argv[])
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target 
vect_perm } } } */
 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { 
target { vect_perm && {! vect_load_lanes } } } } } */
 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { 
target vect_load_lanes } } } */
-/* { dg-final { scan-tree-dump "note: Built SLP cancelled: can use 
load/store-lanes" { target { vect_perm && vect_load_lanes } } } } */
+/* { dg-final { scan-tree-dump "note: Built SLP cancelled: can use 
load/store-lanes" "vect" { target { vect_perm && vect_load_lanes } } } } */
 /* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } 
} } */
 /* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } 
} } */
diff --git gcc/testsuite/gcc.dg/vect/slp-perm-3.c 
gcc/testsuite/gcc.dg/vect/slp-perm-3.c
index ec13e0f..568e400 100644
--- gcc/testsuite/gcc.dg/vect/slp-perm-3.c
+++ gcc/testsuite/gcc.dg/vect/slp-perm-3.c
@@ -69,7 +69,7 @@ int main (int argc, const char* argv[])
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target 
vect_perm } } } */
 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { 
target { vect_perm && {! vect_load_lanes } } } } } 

[Committed, PR69039] Only allow single exit phi for reduction in try_create_reduction_list

2016-01-10 Thread Tom de Vries

Hi,

Consider this test-case (reduced from ira-color.c):
...
unsigned int b;

unsigned int
fn1 (unsigned int d)
{
  int i;

  for (i = 0; i < 1000; i++)
b |= d;

  return b;
}
...

When compiling with -O2 -ftree-parallelize-loops=2, we run into a segfault.


Before parloops, we have reduction stmt _6 with loop phi prephitmp_11:
...
  :
  pretmp_1 = b;

  :
  # i_13 = PHI 
  # prephitmp_11 = PHI <_6(4), pretmp_1(2)>
  # ivtmp_4 = PHI 
  _6 = d_5(D) | prephitmp_11;
  i_8 = i_13 + 1;
  ivtmp_12 = ivtmp_4 - 1;
  if (ivtmp_12 != 0)
goto ;
  else
goto ;

  :
  goto ;

  :
  # _9 = PHI <_6(3)>
  # b_lsm.4_17 = PHI <_6(3)>
  b = b_lsm.4_17;
  return _9;
...

There are however two corresponding loop exit phis: _9 and b_lsm.4_17.

We only track one exit phi in the keep_res field of struct 
reduction_info, and the segfault is a result of that discrepancy.


The seqfault only happens when using transform_to_exit_first_loop_alt, 
so only trunk needs this fix.



The patch fixes the segfault conservatively by bailing out of 
parallelizing the loop if a reduction has more than one exit phi.


Bootstrapped and reg-tested on x86_64.

Committed to trunk.

Thanks,
- Tom
Only allow single exit phi for reduction in try_create_reduction_list

2016-01-07  Tom de Vries  

	PR tree-optimization/69039
	* tree-parloops.c (try_create_reduction_list): Only allow single exit
	phi for reduction.

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

---
 gcc/testsuite/gcc.dg/autopar/pr69039.c | 15 +++
 gcc/tree-parloops.c|  8 
 2 files changed, 23 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/autopar/pr69039.c b/gcc/testsuite/gcc.dg/autopar/pr69039.c
new file mode 100644
index 000..556f700
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/autopar/pr69039.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2" } */
+
+unsigned int b;
+
+unsigned int
+fn1 (unsigned int d)
+{
+  int i;
+
+  for (i = 0; i < 1000; i++)
+b |= d;
+
+  return b;
+}
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 84f18bd..394aba8 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2595,6 +2595,14 @@ try_create_reduction_list (loop_p loop,
 			 "  FAILED: it is not a part of reduction.\n");
 	  return false;
 	}
+	  if (red->keep_res != NULL)
+	{
+	  if (dump_file && (dump_flags & TDF_DETAILS))
+		fprintf (dump_file,
+			 "  FAILED: reduction has multiple exit phis.\n");
+	  return false;
+	}
+	  red->keep_res = phi;
 	  if (dump_file && (dump_flags & TDF_DETAILS))
 	{
 	  fprintf (dump_file, "reduction phi is  ");


Re: [patch, fortran] Fix PR 69154, inline matmul with WHERE

2016-01-10 Thread Thomas Koenig

Am 10.01.2016 um 12:55 schrieb Thomas Koenig:

Hello world,

the attached patch fixes the regression.  Before this, front-end
optimization would have tried to put a DO loop inside a WHERE construct,
leading to an ICE.


The updated test case demonstrates that matmul inlining is done even
after not doing it inside a WHERE.

OK for trunk with that change?

Thomas

! { dg-do compile }
! { dg-options "-ffrontend-optimize -fdump-tree-original" }
! PR 69154 - inlined matmul used to cause an ICE inside a WHERE.
MODULE m_numeric_tools
 INTEGER, PARAMETER :: dp=8
CONTAINS
subroutine llsfit_svd(xx,yy,sigma,nfuncs,funcs,chisq,par,var,cov,info)
 real(dp),intent(in) :: xx(:),yy(:),sigma(:)
 real(dp),dimension(SIZE(xx)) :: bb,sigm1
 real(dp) :: tmp(nfuncs)
 real(dp),allocatable :: work(:),Vt(:,:),U(:,:),S(:)
 real(dp),dimension(3,3) :: a, b, c
 WHERE (S>TOL_*MAXVAL(S))
  tmp=MATMUL(bb,U)/S
 END WHERE
 call random_number(a)
 call random_number(b)
 c = matmul(a,b)
end subroutine llsfit_svd

END MODULE m_numeric_tools
! { dg-final { scan-tree-dump-times "matmul_r8" 1 "original" } }


Re: [patch, fortran] Fix PR 69154, inline matmul with WHERE

2016-01-10 Thread Paul Richard Thomas
Hi Thomas,

Thanks for changing the testcase to demonstrate that in_where does not
get left as true.

OK for trunk.

That's one regression down!

Thanks for the patch

Paul

On 10 January 2016 at 13:38, Thomas Koenig  wrote:
> Am 10.01.2016 um 12:55 schrieb Thomas Koenig:
>>
>> Hello world,
>>
>> the attached patch fixes the regression.  Before this, front-end
>> optimization would have tried to put a DO loop inside a WHERE construct,
>> leading to an ICE.
>
>
> The updated test case demonstrates that matmul inlining is done even
> after not doing it inside a WHERE.
>
> OK for trunk with that change?
>
> Thomas
>



-- 
The difference between genius and stupidity is; genius has its limits.

Albert Einstein


[Patch, fortran] PR67779 - Strange ordering with strings in extended object

2016-01-10 Thread Paul Richard Thomas
Dear All,

I had already posted a patch for the above, which sets the offset
correctly in the caller to gfc_conv_expr_descriptor. However, I was so
concerned that the latter was not doing the job properly that I
decided to investigate further. The result was that I found a
completely trivial omission in the condition for the calculation of
'base', which meant that the wrong branch was taken and the offset
incorrectly calculated.

Committed as 'obvious' (well... it took a while but is obvious now I
see it!) in revision 232200.

Thanks for the report, Arjen.

Paul


Re: [Patch, fortran] PR67779 - Strange ordering with strings in extended object

2016-01-10 Thread Paul Richard Thomas
Dear All,

The patch applies cleanly to 5-branch and fixes the problem. I will
commit it later on today, at the same time as the first batch of
deferred character fixes unless there are any objections.

Cheers

Paul

On 10 January 2016 at 14:02, Paul Richard Thomas
 wrote:
> Dear All,
>
> I had already posted a patch for the above, which sets the offset
> correctly in the caller to gfc_conv_expr_descriptor. However, I was so
> concerned that the latter was not doing the job properly that I
> decided to investigate further. The result was that I found a
> completely trivial omission in the condition for the calculation of
> 'base', which meant that the wrong branch was taken and the offset
> incorrectly calculated.
>
> Committed as 'obvious' (well... it took a while but is obvious now I
> see it!) in revision 232200.
>
> Thanks for the report, Arjen.
>
> Paul



-- 
The difference between genius and stupidity is; genius has its limits.

Albert Einstein


[gomp4] Merge trunk r232189 (2016-01-09) into gomp-4_0-branch

2016-01-10 Thread Thomas Schwinge
Hi!

Committed to gomp-4_0-branch in r232198:

commit bec521e294ddf37d52860bfa0724a5e6a2bc2225
Merge: 1d481a9 0f8f48d
Author: tschwinge 
Date:   Sun Jan 10 12:27:25 2016 +

svn merge -r 231690:232189 svn+ssh://gcc.gnu.org/svn/gcc/trunk


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@232198 
138bc75d-0d04-0410-961f-82ee72b054a4


Grüße
 Thomas


signature.asc
Description: PGP signature


Correct GCC Internals doc for loop_depth

2016-01-10 Thread Nicklas Bo Jensen
Hi,

In the GCC Internals documentation the loop depth is documented
incorrectly. From git commit 9e3536f4f it is accessed through a
function, not a field.

Please install this patch to reflect this.

Best,
Nicklas


2017-01-10  Nicklas Bo Jensen  

* doc/loop.texi (Loop Analysis and Representation): Document
loop_depth function.

index 8920002..8c7a62f 100644
--- a/gcc/doc/loop.texi
+++ b/gcc/doc/loop.texi
@@ -173,8 +173,6 @@ loop structure (that are kept up-to-date at all times) are:
 loop.
 @item @code{num_nodes}: Number of basic blocks in the loop (including
 the basic blocks of the sub-loops).
-@item @code{depth}: The depth of the loop in the loops tree, i.e., the
-number of super-loops of the loop.
 @item @code{outer}, @code{inner}, @code{next}: The super-loop, the first
 sub-loop, and the sibling of the loop in the loops tree.
 @end itemize
@@ -186,6 +184,8 @@ should not be accessed directly.
 The most important functions to query loop structures are:

 @itemize
+@item @code{loop_depth}: The depth of the loop in the loops tree, i.e., the
+number of super-loops of the loop.
 @item @code{flow_loops_dump}: Dumps the information about loops to a
 file.
 @item @code{verify_loop_structure}: Checks consistency of the loop


[Committed, PR69062] Don't parallelize loops containing phis with addr_exprs

2016-01-10 Thread Tom de Vries

Hi,

when compiling the testcase in the patch (reduced from ira-color.c) with 
-O2 -ftree-parallelize-loops=2, we run into an ICE:

...
prephitmp_39 = PHI <_40(16), &conflicting_regs(7)>
ira-color.c:69:8: internal compiler error: verify_gimple failed
...

The variable conflicting_regs is a local array in the original function, 
and it's the job of eliminate_local_variables to rewrite 
'&conflicting_regs' into a thread function argument relative expression.


However, eliminate_local_variables iterates over the statements of a 
block but ignored the PHIs.



The patch fixes the problem conservatively by bailing out of 
parallelizing loops with a phi with an address expression in a phi argument.


Bootstrapped and reg-tested on x86_64.

Committed to trunk.

Thanks,
- Tom
Don't parallelize loops containing phis with addr_exprs

2016-01-07  Tom de Vries  

	PR tree-optimization/69062
	* tree-parloops.c (loop_has_phi_with_address_arg): New function.
	(parallelize_loops): Don't paralelize loop that has phi with address
	arg.

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

---
 gcc/testsuite/gcc.dg/autopar/pr69062.c | 89 ++
 gcc/tree-parloops.c| 34 +
 2 files changed, 123 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/autopar/pr69062.c b/gcc/testsuite/gcc.dg/autopar/pr69062.c
new file mode 100644
index 000..e039349
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/autopar/pr69062.c
@@ -0,0 +1,89 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2" } */
+
+#include 
+
+typedef unsigned long HARD_REG_ELT_TYPE;
+typedef HARD_REG_ELT_TYPE HARD_REG_SET[1];
+struct target_ira
+{
+  HARD_REG_SET x_ira_prohibited_class_mode_regs[1][1];
+};
+extern struct target_ira *this_target_ira;
+static inline bool
+ira_object_conflict_iter_cond ()
+{
+}
+
+static inline bool
+check_hard_reg_p (int num_objects, int hard_regno,
+		  HARD_REG_SET * conflict_regs, HARD_REG_SET profitable_regs)
+{
+  int j, nwords, nregs;
+  if ((! !
+   (((this_target_ira->
+	  x_ira_prohibited_class_mode_regs)[0][0])[(hard_regno) /
+		   ((unsigned) (8 * 8))] &
+	(((HARD_REG_ELT_TYPE) (1)) <<
+	 ((hard_regno) % ((unsigned) (8 * 8)))
+return false;
+  nwords = num_objects;
+  for (j = 0; j < nregs; j++)
+{
+  int k;
+  int set_to_test_start = 0, set_to_test_end = nwords;
+  if (nregs == nwords)
+	{
+	  if (0)
+	set_to_test_start = nwords - j - 1;
+	  else
+	set_to_test_start = j;
+	}
+  for (k = set_to_test_start; k < set_to_test_end; k++)
+	if ((! !
+	 ((conflict_regs[k])[(hard_regno + j) / ((unsigned) (8 * 8))] &
+	  (((HARD_REG_ELT_TYPE) (1)) <<
+	   ((hard_regno + j) % ((unsigned) (8 * 8)))
+	  break;
+  if (k != set_to_test_end)
+	break;
+}
+  return j == nregs;
+}
+
+void
+improve_allocation (void)
+{
+  int j, k, n, hregno, conflict_hregno, base_cost, class_size, word, nwords;
+  int check, spill_cost, min_cost, nregs, conflict_nregs, r, best;
+  int costs[81];
+  HARD_REG_SET conflicting_regs[2], profitable_hard_regs;
+  int a;
+  for (;;)
+{
+  nwords = a;
+  for (word = 0; word < nwords; word++)
+	{
+	  for (; ira_object_conflict_iter_cond ();)
+	{
+	  for (r = conflict_hregno;
+		   r < conflict_hregno + conflict_nregs; r++)
+		if (check_hard_reg_p
+		(a, r, conflicting_regs, profitable_hard_regs))
+		  costs[r] += spill_cost;
+	}
+	  if (check_hard_reg_p
+	  (a, hregno, conflicting_regs, profitable_hard_regs)
+	  && min_cost > costs[hregno])
+	{
+	  best = hregno;
+	}
+	  for (; ira_object_conflict_iter_cond ();)
+	{
+	  if (best + nregs <= conflict_hregno
+		  || conflict_hregno + conflict_nregs <= best)
+		continue;
+	}
+	}
+}
+}
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 394aba8..5bd9c06 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2640,6 +2640,37 @@ try_create_reduction_list (loop_p loop,
   return true;
 }
 
+/* Return true if LOOP contains phis with ADDR_EXPR in args.  */
+
+static bool
+loop_has_phi_with_address_arg (struct loop *loop)
+{
+  basic_block *bbs = get_loop_body (loop);
+  bool res = false;
+
+  unsigned i, j;
+  gphi_iterator gsi;
+  for (i = 0; i < loop->num_nodes; i++)
+for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
+  {
+	gphi *phi = gsi.phi ();
+	for (j = 0; j < gimple_phi_num_args (phi); j++)
+	  {
+	tree arg = gimple_phi_arg_def (phi, j);
+	if (TREE_CODE (arg) == ADDR_EXPR)
+	  {
+		/* This should be handled by eliminate_local_variables, but that
+		   function currently ignores phis.  */
+		res = true;
+		goto end;
+	  }
+	  }
+  }
+ end:
+  free (bbs);
+  return res;
+}
+
 /* Detect parallel loops and generate parallel code using libgomp
primitives.  Returns true if some loop was parallelized, false
otherwise.  */
@@ -2734,6 +2765,9 @@ parallelize_loops (void)
   if (!try_create_reduction_list (loop, &reduct

[PATCH configure,config.gcc] Fix for PR69153 to allow config.gcc to set target_header_dir

2016-01-10 Thread Peter Bergner
While testing a configure fragment change for an upcoming patch, I noticed
that --with-advance-toolchain=... wasn't correctly setting $target_header_dir
to point to the Advance Toolchain's headers and instead was pointing at
the system headers.  This patch arranges for configure.ac to allow
config.gcc to set $target_header_dir which fixes the problem.

This patch passes bootstrap and regtesting on powerpc64le-linux.
Ok for mainline?

Peter


PR target/69153
* config.gcc: Set target_header_dir for --with-advance-toolchain=.
* configure.ac: Only initialize target_header_dir is it isn't already
initialized from config.gcc.
* configure: Regenerate.

Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 232115)
+++ gcc/config.gcc  (working copy)
@@ -4167,6 +4167,7 @@
-d "/opt/$with_advance_toolchain/bin/." -a \
-d "/opt/$with_advance_toolchain/include/."; then
 
+   target_header_dir=`find /opt/$with_advance_toolchain/ 
-path '*/include/features.h' | sed -e 's#/features.h##'`
tm_file="$tm_file ./advance-toolchain.h"
(at="/opt/$with_advance_toolchain"
 echo "/* Use Advance Toolchain $at */"
Index: gcc/configure.ac
===
--- gcc/configure.ac(revision 232115)
+++ gcc/configure.ac(working copy)
@@ -1401,6 +1401,7 @@
 . ${srcdir}/config.host
 
 target_gtfiles=
+target_header_dir=
 
 # Collect target-machine-specific information.
 . ${srcdir}/config.gcc
@@ -1997,20 +1998,22 @@
 SYSTEM_HEADER_DIR=$build_system_header_dir 
 fi
 
-if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
-  if test "x$with_headers" != x; then
-target_header_dir=$with_headers
-  elif test "x$with_sysroot" = x; then
-target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include"
-  elif test "x$with_build_sysroot" != "x"; then
-target_header_dir="${with_build_sysroot}${native_system_header_dir}"
-  elif test "x$with_sysroot" = xyes; then
-
target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
+if test "x$target_header_dir" == x; then
+  if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
+if test "x$with_headers" != x; then
+  target_header_dir=$with_headers
+elif test "x$with_sysroot" = x; then
+  
target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include"
+elif test "x$with_build_sysroot" != "x"; then
+  target_header_dir="${with_build_sysroot}${native_system_header_dir}"
+elif test "x$with_sysroot" = xyes; then
+  
target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
+else
+  target_header_dir="${with_sysroot}${native_system_header_dir}"
+fi
   else
-target_header_dir="${with_sysroot}${native_system_header_dir}"
+target_header_dir=${native_system_header_dir}
   fi
-else
-  target_header_dir=${native_system_header_dir}
 fi
 
 # If this is a cross-compiler that does not
Index: gcc/configure
===
--- gcc/configure   (revision 232115)
+++ gcc/configure   (working copy)
@@ -11458,6 +11458,7 @@
 . ${srcdir}/config.host
 
 target_gtfiles=
+target_header_dir=
 
 # Collect target-machine-specific information.
 . ${srcdir}/config.gcc
@@ -12215,20 +12216,22 @@
 SYSTEM_HEADER_DIR=$build_system_header_dir
 fi
 
-if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
-  if test "x$with_headers" != x; then
-target_header_dir=$with_headers
-  elif test "x$with_sysroot" = x; then
-target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include"
-  elif test "x$with_build_sysroot" != "x"; then
-target_header_dir="${with_build_sysroot}${native_system_header_dir}"
-  elif test "x$with_sysroot" = xyes; then
-
target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
+if test "x$target_header_dir" == x; then
+  if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
+if test "x$with_headers" != x; then
+  target_header_dir=$with_headers
+elif test "x$with_sysroot" = x; then
+  
target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include"
+elif test "x$with_build_sysroot" != "x"; then
+  target_header_dir="${with_build_sysroot}${native_system_header_dir}"
+elif test "x$with_sysroot" = xyes; then
+  
target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
+else
+  target_header_dir="${with_sysroot}${native_system_header_dir}"
+fi
   else
-target_header_dir="${with_sysroot}${native_system_header_dir}"
+target_header_dir=${native_system_header_dir}

New Chinese (simplified) PO file for 'gcc' (version 5.2.0)

2016-01-10 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 Chinese (simplified) team of translators.  The file is available at:

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

(This file, 'gcc-5.2.0.zh_CN.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: [PATCH configure,config.gcc] Fix for PR69153 to allow config.gcc to set target_header_dir

2016-01-10 Thread Bernd Edlinger
Hi Peter,

> @@ -4167,6 +4167,7 @@
>   -d "/opt/$with_advance_toolchain/bin/." -a \
>   -d "/opt/$with_advance_toolchain/include/."; then
> 
>+  target_header_dir=`find /opt/$with_advance_toolchain/ 
>-path '*/include/features.h' | sed -e 's#/features.h##'`
>   tm_file="$tm_file ./advance-toolchain.h"
>   (at="/opt/$with_advance_toolchain"
>echo "/* Use Advance Toolchain $at */"

why can't you just set native_system_header_dir instead?


Bernd.

[PATCH] Remove snprintf from _(load|store)_mask

2016-01-10 Thread H.J. Lu
This patch removes snprintf from _(load|store)_mask
patterns.  Tested on x86-64.  OK for trunk?

H.J.
---

* config/i386/sse.md (_load_mask): Remove
snprintf.
(_store_mask): Likewise.
---
 gcc/config/i386/sse.md | 52 --
 1 file changed, 16 insertions(+), 36 deletions(-)

diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 757e7bd..88e 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -951,30 +951,20 @@
  (match_operand: 3 "register_operand" "Yk,Yk")))]
   "TARGET_AVX512F"
 {
-  static char buf [64];
-
-  const char *insn_op;
-  const char *sse_suffix;
-  const char *align;
   if (FLOAT_MODE_P (GET_MODE_INNER (mode)))
 {
-  insn_op = "vmov";
-  sse_suffix = "";
+  if (misaligned_operand (operands[1], mode))
+   return "vmovu\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
+  else
+   return "vmova\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
 }
   else
 {
-  insn_op = "vmovdq";
-  sse_suffix = "";
+  if (misaligned_operand (operands[1], mode))
+   return "vmovdqu\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
+  else
+   return "vmovdqa\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
 }
-
-  if (misaligned_operand (operands[1], mode))
-align = "u";
-  else
-align = "a";
-
-  snprintf (buf, sizeof (buf), "%s%s%s\t{%%1, 
%%0%%{%%3%%}%%N2|%%0%%{%%3%%}%%N2, %%1}",
-   insn_op, align, sse_suffix);
-  return buf;
 }
   [(set_attr "type" "ssemov")
(set_attr "prefix" "evex")
@@ -1026,30 +1016,20 @@
  (match_operand: 2 "register_operand" "Yk")))]
   "TARGET_AVX512F"
 {
-  static char buf [64];
-
-  const char *insn_op;
-  const char *sse_suffix;
-  const char *align;
   if (FLOAT_MODE_P (GET_MODE_INNER (mode)))
 {
-  insn_op = "vmov";
-  sse_suffix = "";
+  if (misaligned_operand (operands[0], mode))
+   return "vmovu\t{%1, %0%{%2%}|%0%{%2%}, %1}";
+  else
+   return "vmova\t{%1, %0%{%2%}|%0%{%2%}, %1}";
 }
   else
 {
-  insn_op = "vmovdq";
-  sse_suffix = "";
+  if (misaligned_operand (operands[0], mode))
+   return "vmovdqu\t{%1, %0%{%2%}|%0%{%2%}, %1}";
+  else
+   return "vmovdqa\t{%1, %0%{%2%}|%0%{%2%}, %1}";
 }
-
-  if (misaligned_operand (operands[0], mode))
-align = "u";
-  else
-align = "a";
-
-  snprintf (buf, sizeof (buf), "%s%s%s\t{%%1, %%0%%{%%2%%}|%%0%%{%%2%%}, %%1}",
-   insn_op, align, sse_suffix);
-  return buf;
 }
   [(set_attr "type" "ssemov")
(set_attr "prefix" "evex")
-- 
2.5.0



[PATCH] Remove UNSPEC_LOADU and UNSPEC_STOREU

2016-01-10 Thread H.J. Lu
Since *mov_internal and _(load|store)_mask patterns
can handle unaligned load and store, we can remove UNSPEC_LOADU and
UNSPEC_STOREU.  We use function prototypes with pointer to scalar for
unaligned load/store builtin functions so that memory passed to
*mov_internal is unaligned.

Tested on x86-64.  Is this OK for trunk in stage 3?

H.J.

gcc/

PR target/69201
* config/i386/avx512bwintrin.h (_mm512_mask_loadu_epi16): Pass
const short * to __builtin_ia32_loaddquhi512_mask.
(_mm512_maskz_loadu_epi16): Likewise.
(_mm512_mask_storeu_epi16): Pass short * to
__builtin_ia32_storedquhi512_mask.
(_mm512_mask_loadu_epi8): Pass const char * to
__builtin_ia32_loaddquqi512_mask.
(_mm512_maskz_loadu_epi8): Likewise.
(_mm512_mask_storeu_epi8): Pass char * to
__builtin_ia32_storedquqi512_mask.
* config/i386/avx512fintrin.h (_mm512_loadu_pd): Pass
const double * to __builtin_ia32_loadupd512_mask.
(_mm512_mask_loadu_pd): Likewise.
(_mm512_maskz_loadu_pd): Likewise.
(_mm512_storeu_pd): Pass double * to
__builtin_ia32_storeupd512_mask.
(_mm512_mask_storeu_pd): Likewise.
(_mm512_loadu_ps): Pass const float * to
__builtin_ia32_loadups512_mask.
(_mm512_mask_loadu_ps): Likewise.
(_mm512_maskz_loadu_ps): Likewise.
(_mm512_storeu_ps): Pass float * to
__builtin_ia32_storeups512_mask.
(_mm512_mask_storeu_ps): Likewise.
(_mm512_mask_loadu_epi64): Pass const long long * to
__builtin_ia32_loaddqudi512_mask.
(_mm512_maskz_loadu_epi64): Likewise.
(_mm512_mask_storeu_epi64): Pass long long *
to __builtin_ia32_storedqudi512_mask.
(_mm512_loadu_si512): Pass const int * to
__builtin_ia32_loaddqusi512_mask.
(_mm512_mask_loadu_epi32): Likewise.
(_mm512_maskz_loadu_epi32): Likewise.
(_mm512_storeu_si512): Pass int * to
__builtin_ia32_storedqusi512_mask.
(_mm512_mask_storeu_epi32): Likewise.
* config/i386/avx512vlbwintrin.h (_mm256_mask_storeu_epi8): Pass
char * to __builtin_ia32_storedquqi256_mask.
(_mm_mask_storeu_epi8): Likewise.
(_mm256_mask_loadu_epi16): Pass const short * to
__builtin_ia32_loaddquhi256_mask.
(_mm256_maskz_loadu_epi16): Likewise.
(_mm_mask_loadu_epi16): Pass const short * to
__builtin_ia32_loaddquhi128_mask.
(_mm_maskz_loadu_epi16): Likewise.
(_mm256_mask_loadu_epi8): Pass const char * to
__builtin_ia32_loaddquqi256_mask.
(_mm256_maskz_loadu_epi8): Likewise.
(_mm_mask_loadu_epi8): Pass const char * to
__builtin_ia32_loaddquqi128_mask.
(_mm_maskz_loadu_epi8): Likewise.
(_mm256_mask_storeu_epi16): Pass short * to.
__builtin_ia32_storedquhi256_mask.
(_mm_mask_storeu_epi16): Pass short * to.
__builtin_ia32_storedquhi128_mask.
* config/i386/avx512vlintrin.h (_mm256_mask_loadu_pd): Pass
const double * to __builtin_ia32_loadupd256_mask.
(_mm256_maskz_loadu_pd): Likewise.
(_mm_mask_loadu_pd): Pass onst double * to
__builtin_ia32_loadupd128_mask.
(_mm_maskz_loadu_pd): Likewise.
(_mm256_mask_storeu_pd): Pass double * to
__builtin_ia32_storeupd256_mask.
(_mm_mask_storeu_pd): Pass double * to
__builtin_ia32_storeupd128_mask.
(_mm256_mask_loadu_ps): Pass const float * to
__builtin_ia32_loadups256_mask.
(_mm256_maskz_loadu_ps): Likewise.
(_mm_mask_loadu_ps): Pass const float * to
__builtin_ia32_loadups128_mask.
(_mm_maskz_loadu_ps): Likewise.
(_mm256_mask_storeu_ps): Pass float * to
__builtin_ia32_storeups256_mask.
(_mm_mask_storeu_ps): ass float * to
__builtin_ia32_storeups128_mask.
(_mm256_mask_loadu_epi64): Pass const long long * to
__builtin_ia32_loaddqudi256_mask.
(_mm256_maskz_loadu_epi64): Likewise.
(_mm_mask_loadu_epi64): Pass const long long * to
__builtin_ia32_loaddqudi128_mask.
(_mm_maskz_loadu_epi64): Likewise.
(_mm256_mask_storeu_epi64): Pass long long * to
__builtin_ia32_storedqudi256_mask.
(_mm_mask_storeu_epi64): Pass long long * to
__builtin_ia32_storedqudi128_mask.
(_mm256_mask_loadu_epi32): Pass const int * to
__builtin_ia32_loaddqusi256_mask.
(_mm256_maskz_loadu_epi32): Likewise.
(_mm_mask_loadu_epi32): Pass const int * to
__builtin_ia32_loaddqusi128_mask.
(_mm_maskz_loadu_epi32): Likewise.
(_mm256_mask_storeu_epi32): Pass int * to
__builtin_ia32_storedqusi256_mask.
(_mm_mask_storeu_epi32): Pass int * to
__builtin_ia32_storedqusi128_mask.
* config/i386/i386-builtin-types.def (PCSHORT): New.
(PINT64): Likewise.
(V64QI_FTYPE_PCCHAR_V64QI_U

Re: [PATCH configure,config.gcc] Fix for PR69153 to allow config.gcc to set target_header_dir

2016-01-10 Thread Peter Bergner
On Sun, 2016-01-10 at 19:28 +, Bernd Edlinger wrote:
> Hi Peter,
> 
> > @@ -4167,6 +4167,7 @@
> > -d "/opt/$with_advance_toolchain/bin/." -a \
> > -d "/opt/$with_advance_toolchain/include/.";
> > then
> > 
> > +   target_header_dir=`find
> > /opt/$with_advance_toolchain/ -path '*/include/features.h' | sed -e
> > 's#/features.h##'`
> > tm_file="$tm_file ./advance-toolchain.h"
> > (at="/opt/$with_advance_toolchain"
> >  echo "/* Use Advance Toolchain $at */"
> 
> why can't you just set native_system_header_dir instead?
> 

That won't work on our cross builds using --with-advance-toolchain=...
options, correct?  And don't we really need the native_system_header_dir
to really point at the native system headers for tests against gmp.h etc.?

Peter



[doc, 0/n] improve organization of invoke.texi

2016-01-10 Thread Sandra Loosemore
I am about to start a project to incrementally move chunks of 
invoke.texi around to better organize this very long chapter of the 
manual.  For reference, the current top-level structure looks like this:


@chapter GCC Command Options
@section Option Summary
@section Options Controlling the Kind of Output
@section Compiling C++ Programs
@section Options Controlling C Dialect
@section Options Controlling C++ Dialect
@section Options Controlling Objective-C and Objective-C++ Dialects
@section Options to Control Diagnostic Messages Formatting
@section Options to Request or Suppress Warnings
@section Options for Debugging Your Program or GCC
@section Options That Control Optimization
@section Options Controlling the Preprocessor
@section Passing Options to the Assembler
@section Options for Linking
@section Options for Directory Search
@section Specifying Subprocesses and the Switches to Pass to Them
@section Specifying Target Machine and Compiler Version
@section Hardware Models and Configurations
@section Options for Code Generation Conventions
@section Environment Variables Affecting GCC
@section Using Precompiled Headers

Here's what I'm planning:

1.  Integrate the 1-paragraph section "Specifying Target Machine and 
Compiler Version" into the top-level introduction.  (This paragraph 
essentially just says that the name of the program is "gcc" or 
"-gcc".)


2.  Move "Specifying Subprocesses and the Switches to Pass to Them" 
(which is about spec file details) to the end of the chapter.


3.  Move "Options for Code Generation Conventions" ahead of "Hardware 
Models and Configurations", which is where target-specific options are 
covered -- the idea being to cover all the target-independent options 
before the target-specific ones.


4.  Move "Using Precompiled Headers" to extend.texi.  There's nothing in 
this section about "GCC Command Options" (it's about search paths, 
consistency rules, etc for PCH files.)


5.  Create a new section "Program Instrumentation Options" and 
consolidate all the options relevant to profiling, run-time error 
checking, and related functionality there from the various sections 
where they now reside.  This includes -fvtable-verify, -fsanitize and 
friends, -fcheck-pointer-bounds and friends, stack checking, etc.


6.  Split "Options for Debugging Your Program or GCC" into two separate 
sections, since it seems to me that options for enabling or controlling 
DWARF generation (etc) are of interest to a much different audience than 
all the options for controlling dumps, compiler statistics, etc.


Any complaints about this plan?  Please speak up ASAP if you have other 
suggestions!


-Sandra



Re: [PATCH 2/3] Avoid creating an initializer for a flexible array member

2016-01-10 Thread Patrick Palka
On Sun, Jan 3, 2016 at 3:14 PM, Martin Sebor  wrote:
> On 12/31/2015 08:40 AM, Patrick Palka wrote:
>>
>> If we do create such an initializer, we end up with an error_mark_node
>> during gimplification, because in cp-gimplify.c we pass this
>> VEC_INIT_EXPR of the flexible array member to build_vec_init, for which
>> it spits on an error_mark_node.  This happens in e.g. the test case
>> g++.dg/ext/array1.C.
>>
>> This patch makes it so that we avoid generating an initializer for a
>> flexible array member, thus avoiding to end up with an error_mark_node
>> during gimplification.  The same kind of thing is done ~90 lines down
>> from the code I changed.
>
>
> I don't think this change is correct (or complete).  We could
> decide that the kind of code it's meant to allow should be
> accepted in general but if we did, this change alone would not
> be sufficient.
>
> In the way of background, the existing special treatment for
> flexible array members was added to prevent rejecting cases
> like this one:
>
>   struct A { A (int); };
>   struct B {
>   B ();
>   int n;
>   A a[];
>   };
>
> Since B's ctor above doesn't initialize the flexible array
> member it's well-formed.  Ditto if B's ctor is defined but
> avoids initializing B::a.
>
> The proposed change has the effect of also accepting the
> following modified version of the example above that is
> currently rejected:
>
>   struct A { A (int); };
>   struct B {
>   B (): n (), a () { }
>   int n;
>   A a[];
>   };
>
> In this modified example, B's ctor attempts to default-initialize
> the flexible array member and its elements using their respective
> default ctors even though no such ctor for the latter exists.
>
> Since C++ flexible array members are a GCC extension whose C++
> specific aspects are essentially undocumented it's open to
> discussion whether or not code like this should be accepted.
> Clang rejects it, but one could make the argument that since
> the flexible array member has no elements, default initializing
> it should be allowed even if the same initialization would be
> ill-formed if the array wasn't empty.
>
> If the code should be accepted as written above then it should
> also be accepted if B's ctor were omitted or defaulted. I.e.,
> the following should be treated the same as the above:
>
>   struct A { A (int); };
>   struct B {
>   // ditto with B() = default;
>   int n;
>   A a[];
>   } b;
>
> The patch doesn't handle either of these cases and the code
> is rejected both with and without it.

Good catch.  I had not intended to change the validity of certain uses
of flexible array members with this patch.

So at least for now it seems that we should not avoid building a
VEC_INIT_EXPR of a flexible array member, since calling
build_vec_init_expr is necessary to diagnose some invalid uses of
flexible array members. So, I see three possible solutions to avoid
propagating an error_mark_node to the gimplifier while preserving the
exact behavior of flexible array members:

Continue to unconditionally call_build_vec_init_expr() in
perform_member_init(), and

1. Don't add the resulting VEC_INIT_EXPR to the statement tree if the
array in question has no upper bound (i.e. is a flexible array
member); or
2. Modify build_vec_init() to return an empty statement instead of
returning error_mark_node, if the array to be initialized has no upper
bound (and its initializer is NULL_TREE); or
3. Modify cp_gimplify_expr() to avoid calling build_vec_init() if the
VEC_INIT_EXPR in question is for an array with no upper bound (and its
initializer is NULL_TREE).

Which approach is best? The third one is the most conservative and the
one least likely to cause inadvertent changes in behavior elsewhere, I
think.

(In the end however, this "bug" is mostly harmless, and a patch fixing
it is really only useful in combination with patch #3/3 to avoid a
spurious ICE-on-valid.)


Re: [PATCH] Fix PR c++/69056 (argument pack deduction failure during overload resolution)

2016-01-10 Thread Patrick Palka
On Sun, Dec 27, 2015 at 12:14 PM, Patrick Palka  wrote:
> In try_one_overload(), it should not be a deduction failure if we
> deduced more arguments of an argument pack than were explicitly
> specified (as long as the arguments are otherwise equivalent).
>
> This patch makes try_one_overload() manually check the argument packs,
> to permit such a case.
>
> Bootstrap + regtest in progress on x86_64-pc-linux-gnu, will also test
> against Boost.  Is this OK to commit if testing succeeds?
>
> gcc/cp/ChangeLog:
>
> PR c++/69056
> * pt.c (try_one_overload): Handle comparing argument packs so
> that there is no conflict if we deduced more arguments of an
> argument pack than were explicitly specified.
>
> gcc/testsuite/ChangeLog:
>
> PR c++/69056
> g++.dg/cpp0x/pr69056.C: New test.
> ---
>  gcc/cp/pt.c  | 22 ++
>  gcc/testsuite/g++.dg/cpp0x/pr69056.C | 30 ++
>  2 files changed, 52 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr69056.C
>
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index ff16b7c..e8cf1fa 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -18694,6 +18694,28 @@ try_one_overload (tree tparms,
>template args used in the function parm list with our own
>template parms.  Discard them.  */
> TREE_VEC_ELT (tempargs, i) = NULL_TREE;
> +  else if (oldelt && ARGUMENT_PACK_P (oldelt))
> +   {
> + /* Check that the argument at each index of the deduced argument 
> pack
> +is equivalent to the corresponding explicitly specified argument.
> +We may have deduced more arguments than were explicitly 
> specified,
> +and that's OK.  */
> + gcc_assert (ARGUMENT_PACK_INCOMPLETE_P (oldelt));
> + gcc_assert (ARGUMENT_PACK_ARGS (oldelt)
> + == ARGUMENT_PACK_EXPLICIT_ARGS (oldelt));
> +
> + tree explicit_pack = ARGUMENT_PACK_ARGS (oldelt);
> + tree deduced_pack = ARGUMENT_PACK_ARGS (elt);
> +
> + if (TREE_VEC_LENGTH (deduced_pack)
> + < TREE_VEC_LENGTH (explicit_pack))
> +   return 0;
> +
> + for (int j = 0; j < TREE_VEC_LENGTH (explicit_pack); j++)
> +   if (!template_args_equal (TREE_VEC_ELT (explicit_pack, j),
> + TREE_VEC_ELT (deduced_pack, j)))
> + return 0;
> +   }
>else if (oldelt && !template_args_equal (oldelt, elt))
> return 0;
>  }
> diff --git a/gcc/testsuite/g++.dg/cpp0x/pr69056.C 
> b/gcc/testsuite/g++.dg/cpp0x/pr69056.C
> new file mode 100644
> index 000..ab4e071
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/pr69056.C
> @@ -0,0 +1,30 @@
> +// { dg-do compile { target c++11 } }
> +// PR c++/69056
> +
> +template 
> +void resolver(int (*) (T, Args...));
> +
> +int funcA(int, float) { return 0; }
> +int funcA(double) { return 0; }
> +
> +int funcB(int, float, char) { return 0; }
> +int funcB(int, bool) { return 0; }
> +int funcB(double) { return 0; }
> +
> +int funcC(int) { return 0; }
> +int funcC(double) { return 0; }
> +
> +void
> +foo (void)
> +{
> +  resolver (&funcA); // { dg-error "no match" }
> +  resolver (&funcA);
> +  resolver (&funcA);
> +
> +  resolver (&funcB); // { dg-error "no match" }
> +  resolver (&funcB); // { dg-error "no match" }
> +  resolver (&funcB);
> +
> +  resolver (&funcC);
> +  resolver (&funcC); // { dg-error "no match" }
> +}
> --
> 2.7.0.rc1.98.gacf58d0.dirty
>

Ping.


Re: [PATCH] Fix constexpr evaluation of comparisons involving pointer-to-members

2016-01-10 Thread Patrick Palka
On Mon, Dec 21, 2015 at 6:07 PM, Patrick Palka  wrote:
> We are currently failing to fold equality comparisons involving
> PTRMEM_CSTs since (I think) r229018 thus making this a GCC 6 regression.
> This regression shows up in the boost testsuite.
>
> Fixed in a straightforward way.  OK to commit after bootstrap + regtest?
>
> gcc/cp/ChangeLog:
>
> * constexpr.c (cxx_eval_binary_expression): Expand
> the PTRMEM_CST operands of an equality comparison.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/cpp0x/constexpr-ptrmem5.C: New test.
> ---
>  gcc/cp/constexpr.c |  9 +
>  gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C | 14 ++
>  2 files changed, 23 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C
>
> diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
> index 208f43b..1ad87aa 100644
> --- a/gcc/cp/constexpr.c
> +++ b/gcc/cp/constexpr.c
> @@ -1630,6 +1630,15 @@ cxx_eval_binary_expression (const constexpr_ctx *ctx, 
> tree t,
>location_t loc = EXPR_LOCATION (t);
>enum tree_code code = TREE_CODE (t);
>tree type = TREE_TYPE (t);
> +
> +  if (code == EQ_EXPR || code == NE_EXPR)
> +{
> +  if (TREE_CODE (lhs) == PTRMEM_CST && CONSTANT_CLASS_P (rhs))
> +   lhs = cplus_expand_constant (lhs);
> +  if (TREE_CODE (rhs) == PTRMEM_CST && CONSTANT_CLASS_P (lhs))
> +   rhs = cplus_expand_constant (rhs);
> +}
> +
>r = fold_binary_loc (loc, code, type, lhs, rhs);
>if (r == NULL_TREE)
>  {
> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C 
> b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C
> new file mode 100644
> index 000..e28c917
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C
> @@ -0,0 +1,14 @@
> +// { dg-do compile { target c++11 } }
> +
> +#define SA(x) static_assert ((x), #x)
> +
> +struct X { int a, b; };
> +
> +void
> +foo ()
> +{
> +  SA (&X::a);
> +  SA (&X::a == &X::a);
> +  SA (&X::a != &X::b);
> +  SA ((!&X::b) == 0);
> +}
> --
> 2.7.0.rc0.50.g1470d8f.dirty
>

Ping.


Re: [PATCH 3/3] [RFC] Treat a gimplification failure as an internal error

2016-01-10 Thread Patrick Palka
On Thu, Dec 31, 2015 at 10:40 AM, Patrick Palka  wrote:
> This patch makes it so that a gimplification failure is considered to be
> an internal error under normal circumstances, so that we otherwise avoid
> silently generating wrong code if e.g. a buggy frontend fed us a
> malformed tree.
>
> The rationale for this change is that it's better to abort compilation
> than to silently generate wrong code.  During gimplification we should
> only see e.g. an error_mark_node if the frontend has already issued an
> error.  Otherwise it is likely a bug in frontend.
>
> This patch, for example, turns the PR c++/68948 wrong-code bug into an
> ICE on invalid bug.  During testing it also caught two latent "bugs"
> (patches 1 and 2 in this series).
>
> This series was tested on x86_64-pc-linux-gnu, with 
> --enable-languages=all,ada,go,
> no new regressions.
>
> Does this seem like a reasonable invariant to add to the gimplifier?
>
> gcc/cp/ChangeLog:
>
> * cp-gimplify.c (gimplify_expr_stmt): Don't convert an
> error_mark_node to an empty statement.
>
> gcc/ChangeLog:
>
> * gimplify.c (gimplify_return_expr): Remove a redundant test
> for error_mark_node.
> (gimplify_decl_expr): Return GS_ERROR if an initializer is an
> error_mark_node.
> (gimplify_expr): Treat a gimplification failure as an internal
> error.  Remove now-redundant GIMPLE_CHECKING checking code.
> ---
>  gcc/cp/cp-gimplify.c |  5 +
>  gcc/gimplify.c   | 27 +--
>  2 files changed, 14 insertions(+), 18 deletions(-)
>
> diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
> index 373c9e1..2b0aaaf 100644
> --- a/gcc/cp/cp-gimplify.c
> +++ b/gcc/cp/cp-gimplify.c
> @@ -424,16 +424,13 @@ gimplify_expr_stmt (tree *stmt_p)
>  {
>tree stmt = EXPR_STMT_EXPR (*stmt_p);
>
> -  if (stmt == error_mark_node)
> -stmt = NULL;
> -
>/* Gimplification of a statement expression will nullify the
>   statement if all its side effects are moved to *PRE_P and *POST_P.
>
>   In this case we will not want to emit the gimplified statement.
>   However, we may still want to emit a warning, so we do that before
>   gimplification.  */
> -  if (stmt && warn_unused_value)
> +  if (stmt && stmt != error_mark_node && warn_unused_value)
>  {
>if (!TREE_SIDE_EFFECTS (stmt))
> {
> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
> index bc90401..9a1d723 100644
> --- a/gcc/gimplify.c
> +++ b/gcc/gimplify.c
> @@ -1288,8 +1288,7 @@ gimplify_return_expr (tree stmt, gimple_seq *pre_p)
>  }
>
>if (!ret_expr
> -  || TREE_CODE (ret_expr) == RESULT_DECL
> -  || ret_expr == error_mark_node)
> +  || TREE_CODE (ret_expr) == RESULT_DECL)
>  {
>greturn *ret = gimple_build_return (ret_expr);
>gimple_set_no_warning (ret, TREE_NO_WARNING (stmt));
> @@ -1449,6 +1448,9 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
>  {
>tree init = DECL_INITIAL (decl);
>
> +  if (init == error_mark_node)
> +   return GS_ERROR;
> +
>if (TREE_CODE (DECL_SIZE_UNIT (decl)) != INTEGER_CST
>   || (!TREE_STATIC (decl)
>   && flag_stack_check == GENERIC_STACK_CHECK
> @@ -1464,7 +1466,7 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
>   && DECL_ARTIFICIAL (decl) && DECL_NAME (decl) == NULL_TREE)
> gimple_add_tmp_var (decl);
>
> -  if (init && init != error_mark_node)
> +  if (init)
> {
>   if (!TREE_STATIC (decl))
> {
> @@ -11036,17 +11038,6 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, 
> gimple_seq *post_p,
>  }
>else
>  {
> -#ifdef ENABLE_GIMPLE_CHECKING
> -  if (!(fallback & fb_mayfail))
> -   {
> - fprintf (stderr, "gimplification failed:\n");
> - print_generic_expr (stderr, *expr_p, 0);
> - debug_tree (*expr_p);
> - internal_error ("gimplification failed");
> -   }
> -#endif
> -  gcc_assert (fallback & fb_mayfail);
> -
>/* If this is an asm statement, and the user asked for the
>  impossible, don't die.  Fail and let gimplify_asm_expr
>  issue an error.  */
> @@ -11064,6 +11055,14 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, 
> gimple_seq *post_p,
>  }
>
>   out:
> +  /* If gimplification failed, then either such failure was explicitly 
> permitted
> + (via the FB_MAYFAIL flag) or the frontend fed us a malformed tree, e.g. 
> one
> + containing an ERROR_MARK node -- for which the FE should have already 
> issued an
> + error diagnostic.  Otherwise it is likely that an FE bug was triggered, 
> in
> + which case it is better to abort than to risk silently generating wrong
> + code.  */
> +  if (ret == GS_ERROR)
> +gcc_assert ((fallback & fb_mayfail) || seen_error ());
>input_location = saved_location;
>return ret;
>  }
> --
> 2.7.0.rc3.56.g64157c6.dirty
>

Ping.


Re: [PATCH 1/3] Fix logic bug in Cilk Plus array expansion

2016-01-10 Thread Patrick Palka
On Mon, Jan 4, 2016 at 1:35 PM, Jeff Law  wrote:
> On 01/02/2016 04:26 PM, Patrick Palka wrote:
>>
>> On Sat, Jan 2, 2016 at 3:21 AM, Jakub Jelinek  wrote:
>>>
>>> On Fri, Jan 01, 2016 at 10:06:34PM -0700, Jeff Law wrote:
>
> gcc/cp/ChangeLog:
>
>  * cp-array-notation.c (cp_expand_cond_array_notations): Return
>  error_mark_node only if find_rank failed, not if it was
>  successful.

 Can you use -fdump-tree-original in the testcase and verify there's no
 <<<
 error >>> expressions in the resulting dump file?

 With that change, this is OK.
>>>
>>>
>>> I think the patch is incomplete.  Because, find_rank does not always emit
>>> an error if it returns false, so we again have cases where we can get
>>> error_mark_node in the code without error being emitted.
>>>else if (*rank != current_rank)
>>>  {
>>>/* In this case, find rank is being recursed through a set of
>>>   expression of the form A  B, where A and B both
>>> have
>>>   array notations in them and the rank of A is not equal to
>>> rank of B.
>>>   A simple example of such case is the following: X[:] +
>>> Y[:][:] */
>>>*rank = current_rank;
>>>return false;
>>>  }
>>> and other spots.  E.g.
>>>if (prev_arg && EXPR_HAS_LOCATION (prev_arg))
>>>  error_at (EXPR_LOCATION (prev_arg),
>>>"rank mismatch between %qE and %qE",
>>> prev_arg,
>>>TREE_OPERAND (expr, ii));
>>> looks very suspicious.
>>
>>
>> Hmm, good point. Here's a contrived test case that causes find_rank to
>> return false without emitting an error message thus we again end up
>> with an error_mark_node in the gimplifier:
>>
>> /* { dg-do compile } */
>> /* { dg-options "-fcilkplus" } */
>>
>> void foo() {}
>>
>> #define ALEN 1024
>>
>> int main(int argc, char* argv[])
>> {
>>typedef void (*f) (void *);
>>f b[ALEN], c[ALEN][ALEN];
>>(b[:]) ((void *)c[:][:]);
>>_Cilk_spawn foo();
>>return 0;
>> }
>>
>> But this patch was intended to only fix the testsuite fallout that
>> patch 3 would have otherwise caused, and not to e.g. fix all the bugs
>> with find_rank.
>>
>> (BTW patch 3 also makes this test case trigger an ICE, instead of
>> being silently miscompiled.)
>
> Can you please include this test (xfailed) when you commit patch #1.  I
> think you want the test to scan for error_mark_node in the gimplified dump.

There are four subdirectories under
gcc/testsuite/c-c++-common/cilk-plus -- AN, CK, PS and SE. Into which
directory should this new xfailed test go?

>
> Jeff
>


Re: [PATCH] OpenACC documentation for libgomp

2016-01-10 Thread Sandra Loosemore

On 01/05/2016 08:47 AM, James Norris wrote:

Hi!

I've updated the original patch after some very helpful
comments from Sandra (thank you, thank you).

OK to commit to trunk?


I'm assuming this is now waiting for technical review?  I can give it 
another read-through for tech-writing issues but I don't feel competent 
to approve the content.


-Sandra



Re: [PATCH] arc/gcc: Fix help text for some options.

2016-01-10 Thread Joern Wolfgang Rennecke



On 08/01/16 14:13, Andrew Burgess wrote:

* config/arc/arc.opt (mdiv-rem): Add period to the end.
(mcode-density): Likewise.

Thanks, I have applied this patch.


Re: [PATCH] Remove UNSPEC_LOADU and UNSPEC_STOREU

2016-01-10 Thread Uros Bizjak
On Sun, Jan 10, 2016 at 11:32 PM, H.J. Lu  wrote:
> Since *mov_internal and _(load|store)_mask patterns
> can handle unaligned load and store, we can remove UNSPEC_LOADU and
> UNSPEC_STOREU.  We use function prototypes with pointer to scalar for
> unaligned load/store builtin functions so that memory passed to
> *mov_internal is unaligned.
>
> Tested on x86-64.  Is this OK for trunk in stage 3?

This patch is not appropriate for stage 3.

Uros.

> H.J.
> 
> gcc/
>
> PR target/69201
> * config/i386/avx512bwintrin.h (_mm512_mask_loadu_epi16): Pass
> const short * to __builtin_ia32_loaddquhi512_mask.
> (_mm512_maskz_loadu_epi16): Likewise.
> (_mm512_mask_storeu_epi16): Pass short * to
> __builtin_ia32_storedquhi512_mask.
> (_mm512_mask_loadu_epi8): Pass const char * to
> __builtin_ia32_loaddquqi512_mask.
> (_mm512_maskz_loadu_epi8): Likewise.
> (_mm512_mask_storeu_epi8): Pass char * to
> __builtin_ia32_storedquqi512_mask.
> * config/i386/avx512fintrin.h (_mm512_loadu_pd): Pass
> const double * to __builtin_ia32_loadupd512_mask.
> (_mm512_mask_loadu_pd): Likewise.
> (_mm512_maskz_loadu_pd): Likewise.
> (_mm512_storeu_pd): Pass double * to
> __builtin_ia32_storeupd512_mask.
> (_mm512_mask_storeu_pd): Likewise.
> (_mm512_loadu_ps): Pass const float * to
> __builtin_ia32_loadups512_mask.
> (_mm512_mask_loadu_ps): Likewise.
> (_mm512_maskz_loadu_ps): Likewise.
> (_mm512_storeu_ps): Pass float * to
> __builtin_ia32_storeups512_mask.
> (_mm512_mask_storeu_ps): Likewise.
> (_mm512_mask_loadu_epi64): Pass const long long * to
> __builtin_ia32_loaddqudi512_mask.
> (_mm512_maskz_loadu_epi64): Likewise.
> (_mm512_mask_storeu_epi64): Pass long long *
> to __builtin_ia32_storedqudi512_mask.
> (_mm512_loadu_si512): Pass const int * to
> __builtin_ia32_loaddqusi512_mask.
> (_mm512_mask_loadu_epi32): Likewise.
> (_mm512_maskz_loadu_epi32): Likewise.
> (_mm512_storeu_si512): Pass int * to
> __builtin_ia32_storedqusi512_mask.
> (_mm512_mask_storeu_epi32): Likewise.
> * config/i386/avx512vlbwintrin.h (_mm256_mask_storeu_epi8): Pass
> char * to __builtin_ia32_storedquqi256_mask.
> (_mm_mask_storeu_epi8): Likewise.
> (_mm256_mask_loadu_epi16): Pass const short * to
> __builtin_ia32_loaddquhi256_mask.
> (_mm256_maskz_loadu_epi16): Likewise.
> (_mm_mask_loadu_epi16): Pass const short * to
> __builtin_ia32_loaddquhi128_mask.
> (_mm_maskz_loadu_epi16): Likewise.
> (_mm256_mask_loadu_epi8): Pass const char * to
> __builtin_ia32_loaddquqi256_mask.
> (_mm256_maskz_loadu_epi8): Likewise.
> (_mm_mask_loadu_epi8): Pass const char * to
> __builtin_ia32_loaddquqi128_mask.
> (_mm_maskz_loadu_epi8): Likewise.
> (_mm256_mask_storeu_epi16): Pass short * to.
> __builtin_ia32_storedquhi256_mask.
> (_mm_mask_storeu_epi16): Pass short * to.
> __builtin_ia32_storedquhi128_mask.
> * config/i386/avx512vlintrin.h (_mm256_mask_loadu_pd): Pass
> const double * to __builtin_ia32_loadupd256_mask.
> (_mm256_maskz_loadu_pd): Likewise.
> (_mm_mask_loadu_pd): Pass onst double * to
> __builtin_ia32_loadupd128_mask.
> (_mm_maskz_loadu_pd): Likewise.
> (_mm256_mask_storeu_pd): Pass double * to
> __builtin_ia32_storeupd256_mask.
> (_mm_mask_storeu_pd): Pass double * to
> __builtin_ia32_storeupd128_mask.
> (_mm256_mask_loadu_ps): Pass const float * to
> __builtin_ia32_loadups256_mask.
> (_mm256_maskz_loadu_ps): Likewise.
> (_mm_mask_loadu_ps): Pass const float * to
> __builtin_ia32_loadups128_mask.
> (_mm_maskz_loadu_ps): Likewise.
> (_mm256_mask_storeu_ps): Pass float * to
> __builtin_ia32_storeups256_mask.
> (_mm_mask_storeu_ps): ass float * to
> __builtin_ia32_storeups128_mask.
> (_mm256_mask_loadu_epi64): Pass const long long * to
> __builtin_ia32_loaddqudi256_mask.
> (_mm256_maskz_loadu_epi64): Likewise.
> (_mm_mask_loadu_epi64): Pass const long long * to
> __builtin_ia32_loaddqudi128_mask.
> (_mm_maskz_loadu_epi64): Likewise.
> (_mm256_mask_storeu_epi64): Pass long long * to
> __builtin_ia32_storedqudi256_mask.
> (_mm_mask_storeu_epi64): Pass long long * to
> __builtin_ia32_storedqudi128_mask.
> (_mm256_mask_loadu_epi32): Pass const int * to
> __builtin_ia32_loaddqusi256_mask.
> (_mm256_maskz_loadu_epi32): Likewise.
> (_mm_mask_loadu_epi32): Pass const int * to
> __builtin_ia32_loaddqusi128_mask.
> (_mm_maskz_loadu_epi32): Likewise.
>