Re: [v3 PATCH] Implement N4387 and LWG 2367

2015-06-13 Thread Ville Voutilainen
On 8 June 2015 at 19:01, Ville Voutilainen  wrote:
>> Yes, it should be uglified, thanks.
> Ahem, yes, actually removed since it's there only to be specialized.

Another round! The new patch
- makes sure not to change non-deduced parameters to deduced ones, and adds
tests for that.
- removes the name of the bool non-type template parameter for the 'concepts'.
- introduces shortcuts for making the use of the 'concepts' more readable.
- changes library tag types into non-default-constructible ones.
Without this, we
can run into an ambiguity between the constructor template that takes
(const _T1&, const _T2&)
and the one that takes (allocator_arg_t, Alloc), when the call site
calls it with ({}, somethingelse).
We could avoid that by just not doing that in the library
(experimental string searchers do that),
but it's just daft to allow default-constructing a library tag type. I
have filed an LWG issue to
fix all tag types, but this patch doesn't yet touch nothrow_t and
optional's in_place_t. I expect
to submit follow-up patches for that.

Tested on Linux-PPC64.

2015-06-13  Ville Voutilainen  
Implement N4387, "improving pair and tuple" and
LWG 2367, "pair and tuple are not correctly implemented for
is_constructible with no args". Also make the standard tag types
non-default-constructible. std::nothrow_t not taken care
of yet in that regard, nor std::experimental::optional's
in_place_t.
* include/bits/stl_pair.h (piecewise_construct_t,
piecewise_construct): Make non-default-constructible and adjust.
* include/bits/stl_pair.h (_ConstructiblePair,
_ImplicitlyConvertiblePair, _MoveConstructiblePair,
_ImplicitlyMoveConvertiblePair): New.
* include/bits/stl_pair.h (pair()): Constrain it.
* include/bits/stl_pair.h (pair(const _T1&, const _T2&),
pair(const pair<_U1, _U2>&), pair(_U1&&, const _T2&),
pair(const _T1&, _U2&&), pair(_U1&&, _U2&&),
pair(pair<_U1, _U2>&&)): Make conditionally explicit.
* include/bits/uses_allocator.h (allocator_arg_t,
allocator_arg): Make non-default-constructible and adjust.
* include/std/mutex (defer_lock_t, defer_lock,
try_to_lock_t, try_to_lock, adopt_lock_t, adopt_lock):
Make non-default-constructible and adjust.
* include/std/tuple (_TC, tuple::_TC2, tuple::TCC, tuple::TMC): New.
* include/std/tuple (tuple()): Constrain it.
* include/std/tuple (tuple(const _UElements&...),
tuple(_UElements&&...), tuple(const tuple<_UElements...>&),
tuple(tuple<_UElements...>&&),
tuple(allocator_arg_t, const _Alloc&, const _UElements&...),
tuple(allocator_arg_t, const _Alloc&, _UElements&&...),
tuple(allocator_arg_t, const _Alloc&, const tuple<_UElements...>&),
tuple(allocator_arg_t, const _Alloc&, tuple<_UElements...>&&),
tuple(const pair<_U1, _U2>&),
tuple(pair<_U1, _U2>&&),
tuple(allocator_arg_t, const _Alloc&, const pair<_U1, _U2>&),
tuple(allocator_arg_t, const _Alloc&, pair<_U1, _U2>&&)): Make
conditionally explicit.
* src/c++11/compatibility-thread-c++0x.cc: Adjust.
* testsuite/20_util/pair/cons/explicit_construct.cc: New.
* estsuite/20_util/pair/piecewise.cc: Adjust.
* testsuite/20_util/pair/requirements/dr2367.cc: New.
* testsuite/20_util/tuple/cons/explicit_construct.cc: New.
* testsuite/20_util/tuple/requirements/dr2367.cc: New.


conditional-explicit4.diff.gz
Description: GNU Zip compressed data


[PATCH] Fix comment documenting make_vector_stat

2015-06-13 Thread Patrick Palka
It actually returns a VECTOR_CST not a TREE_VEC.

Committed as obvious.

gcc/ChangeLog:

* tree.c (make_vector_stat): Fix comment to state that the
function returns a VECTOR_CST.
---
 gcc/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree.c b/gcc/tree.c
index be01d0e..6c194a6 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1652,7 +1652,7 @@ cst_and_fits_in_hwi (const_tree x)
   return TREE_INT_CST_NUNITS (x) == 1;
 }
 
-/* Build a newly constructed TREE_VEC node of length LEN.  */
+/* Build a newly constructed VECTOR_CST node of length LEN.  */
 
 tree
 make_vector_stat (unsigned len MEM_STAT_DECL)
-- 
2.4.3.413.ga5fe668



[PATCH OBV] Remove stale commentary in cp/call.c

2015-06-13 Thread Patrick Palka
r76173 removed the function build_method_call() but did not remove the
comment documenting the function.  This patch removes the stale comment.

Committed as obvious.

gcc/cp/ChangeLog:

* call.c: Remove comment documenting the long-deleted
function build_method_call.
---
 gcc/cp/call.c | 31 ---
 1 file changed, 31 deletions(-)

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 2d90ed9..2f0c53a 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -411,37 +411,6 @@ build_call_a (tree function, int n, tree *argarray)
   return function;
 }
 
-/* Build something of the form ptr->method (args)
-   or object.method (args).  This can also build
-   calls to constructors, and find friends.
-
-   Member functions always take their class variable
-   as a pointer.
-
-   INSTANCE is a class instance.
-
-   NAME is the name of the method desired, usually an IDENTIFIER_NODE.
-
-   PARMS help to figure out what that NAME really refers to.
-
-   BASETYPE_PATH, if non-NULL, contains a chain from the type of INSTANCE
-   down to the real instance type to use for access checking.  We need this
-   information to get protected accesses correct.
-
-   FLAGS is the logical disjunction of zero or more LOOKUP_
-   flags.  See cp-tree.h for more info.
-
-   If this is all OK, calls build_function_call with the resolved
-   member function.
-
-   This function must also handle being called to perform
-   initialization, promotion/coercion of arguments, and
-   instantiation of default parameters.
-
-   Note that NAME may refer to an instance variable name.  If
-   `operator()()' is defined for the type of that field, then we return
-   that result.  */
-
 /* New overloading code.  */
 
 typedef struct z_candidate z_candidate;
-- 
2.4.3.413.ga5fe668



[patch, fortran] Warn about constant integer divisions

2015-06-13 Thread Thomas Koenig
Hello world,

the attached patch emits a warning for constant integer division.
While correct according to the standard, I cannot really think
of a legitimate reason why people would want to write 3/5 where
they could have written 0 , so my preference would be to put
this under -Wconversion (like in the attached patch).

However, I am open to discussion on that.  It is easy enough to
change.

Regression-tested.  Opinions?  Comments?  Would somebody rather
have -Wconversion-extra?  OK for trunk?

Regards

Thomas
Index: arith.c
===
--- arith.c	(Revision 224450)
+++ arith.c	(Arbeitskopie)
@@ -733,6 +733,15 @@ gfc_arith_divide (gfc_expr *op1, gfc_expr *op2, gf
 
   mpz_tdiv_q (result->value.integer, op1->value.integer,
 		  op2->value.integer);
+
+  if (warn_conversion)
+	{
+	  char *p;
+	  p = mpz_get_str (NULL, 10, result->value.integer);
+	  gfc_warning_now (OPT_Wconversion, "Integer division simplifies "
+			   "to constant %qs at %L", p, &op1->where);
+	  free (p);
+	}
   break;
 
 case BT_REAL:
! { dg-do compile }
! { dg-options "-Wconversion" }
program main
  print *, 3/5 ! { dg-warning "Integer division simplifies to constant" }
end program main


[PATCH] Handle casts in bound in try_transform_to_exit_first_loop_alt

2015-06-13 Thread Tom de Vries

Hi,

this patch allows try_transform_to_exit_first_loop_alt to succeed when 
handling cases where the expression representing the number of 
iterations contains a cast.


Currently, transform_to_exit_first_loop_alt testcase 
gfortran/parloops-exit-first-loop-alt.f95 will fail.


The nit is _19, which is defined as follows:
...
_20 = _6 + -1;
_19 = (unsigned int) _20;
...
And transform_to_exit_first_loop_alt currently only handles nits with 
defining stmt 'nit = x - 1', for which it finds alt_bound 'x'.


The patch:
- uses try_get_loop_niter to get nit as a nested tree expression
  '(unsigned int) (_6 + -1)'
- strips the outer nops (assuming no change in value)
- uses '(unsigned int)_6' as the alt_bound, and
- gimplifies the expression.

Bootstrapped and reg-tested on x86_64.

OK for trunk?

Thanks,
- Tom
Handle casts in bound in transform_to_exit_first_loop_alt

2015-06-13  Tom de Vries  

	* tree-parloops.c (transform_to_exit_first_loop_alt): Add update_stmt
	for cond_stmt.
	(try_get_loop_niter): Declare forward.
	(try_transform_to_exit_first_loop_alt): Use try_get_loop_niter to get
	updated number of iterations.  Extract alt_bount, and instantiate it.

	* testsuite/libgomp.fortran/parloops-exit-first-loop-alt-2.f95: New test.
	* testsuite/libgomp.fortran/parloops-exit-first-loop-alt.f95: New test.

	* gfortran.dg/parloops-exit-first-loop-alt-2.f95: New test.
	* gfortran.dg/parloops-exit-first-loop-alt.f95: New test.
---
 .../gfortran.dg/parloops-exit-first-loop-alt-2.f95 | 24 +
 .../gfortran.dg/parloops-exit-first-loop-alt.f95   | 25 +
 gcc/tree-parloops.c| 59 +-
 .../parloops-exit-first-loop-alt-2.f95 | 40 +++
 .../parloops-exit-first-loop-alt.f95   | 41 +++
 5 files changed, 164 insertions(+), 25 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/parloops-exit-first-loop-alt-2.f95
 create mode 100644 gcc/testsuite/gfortran.dg/parloops-exit-first-loop-alt.f95
 create mode 100644 libgomp/testsuite/libgomp.fortran/parloops-exit-first-loop-alt-2.f95
 create mode 100644 libgomp/testsuite/libgomp.fortran/parloops-exit-first-loop-alt.f95

diff --git a/gcc/testsuite/gfortran.dg/parloops-exit-first-loop-alt-2.f95 b/gcc/testsuite/gfortran.dg/parloops-exit-first-loop-alt-2.f95
new file mode 100644
index 000..a785bf9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/parloops-exit-first-loop-alt-2.f95
@@ -0,0 +1,24 @@
+! { dg-additional-options "-O2" }
+! { dg-require-effective-target pthread }
+! { dg-additional-options "-ftree-parallelize-loops=2" }
+! { dg-additional-options "-fdump-tree-parloops" }
+
+! Constant bound, vector addition.
+
+subroutine foo()
+  integer, parameter :: n = 1000
+  integer, dimension (0:n-1) :: a, b, c
+  common a, b, c
+  integer:: ii
+
+  do ii = 0, n - 1
+ c(ii) = a(ii) + b(ii) + 25
+  end do
+end subroutine foo
+
+! Three times plus 25:
+! - once in f._loopfn.0
+! - once in the parallel
+! - once in the low iteration count loop
+! Crucially, none for a peeled off last iteration following the parallel.
+! { dg-final { scan-tree-dump-times "(?n) \\+ 25;" 3 "parloops" } }
diff --git a/gcc/testsuite/gfortran.dg/parloops-exit-first-loop-alt.f95 b/gcc/testsuite/gfortran.dg/parloops-exit-first-loop-alt.f95
new file mode 100644
index 000..3873ca2a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/parloops-exit-first-loop-alt.f95
@@ -0,0 +1,25 @@
+! { dg-additional-options "-O2" }
+! { dg-require-effective-target pthread }
+! { dg-additional-options "-ftree-parallelize-loops=2" }
+! { dg-additional-options "-fdump-tree-parloops" }
+
+! Variable bound, vector addition.
+
+subroutine foo(nr)
+  integer, intent(in)   :: nr
+  integer, parameter :: n = 1000
+  integer, dimension (0:n-1) :: a, b, c
+  common a, b, c
+  integer:: ii
+
+  do ii = 0, nr - 1
+ c(ii) = a(ii) + b(ii) + 25
+  end do
+end subroutine foo
+
+! Three times plus 25:
+! - once in f._loopfn.0
+! - once in the parallel
+! - once in the low iteration count loop
+! Crucially, none for a peeled off last iteration following the parallel.
+! { dg-final { scan-tree-dump-times "(?n) \\+ 25;" 3 "parloops" } }
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 3495ac1..6e10901 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1678,6 +1678,7 @@ transform_to_exit_first_loop_alt (struct loop *loop,
 
   /* Set the new loop bound.  */
   gimple_cond_set_rhs (cond_stmt, bound);
+  update_stmt (cond_stmt);
 
   /* Repair the ssa.  */
   vec *v = redirect_edge_var_map_vector (post_inc_edge);
@@ -1755,6 +1756,8 @@ transform_to_exit_first_loop_alt (struct loop *loop,
   calculate_dominance_info (CDI_DOMINATORS);
 }
 
+static bool try_get_loop_niter (loop_p, struct tree_niter_desc *);
+
 /* Tries to moves the exit condition of LOOP to the beginning of its header
without duplication of the loop body.  NIT is the number of iterati

Re: [PATCH] Fix PR66509

2015-06-13 Thread Jack Howarth
On Sat, Jun 13, 2015 at 12:04 AM, Mike Stump  wrote:
> On Jun 12, 2015, at 8:25 PM, Jack Howarth  wrote:
>>   The attached patch revises the tests for the filds and fists
>> mnemonics to use the assembly...
>>
>> filds mem(%rip); fists mem(%rip)
>
>> Okay for gcc trunk?
>
> Fine from a darwin perspective, but I would like an x86 binutils person to 
> weigh in to make sure we aren’t turning off detection on some system that 
> supports the previous version but not the new spelling.
>

Mike,
   As I mentioned in the original PR, if that is a concern, there are
several other instances of the uses of () in detection of assembly
mnemonics in should be revisited as well. Perhaps H.J. can comment on
this issue.
  Jack


Re: [Patch 0/4] PowerPC64 Linux split stack support

2015-06-13 Thread Andreas Schwab
/usr/bin/mkdir -p .; files=`echo ../../../../libgo/go/errors/errors.go | sed -e 
's/[^ ]*\.gox//g'`; /bin/sh ./libtool --tag GO --mode=compile 
/daten/gcc/gcc-20150613/Build/./gcc/gccgo 
-B/daten/gcc/gcc-20150613/Build/./gcc/ -B/usr/powerpc64-linux/bin/ 
-B/usr/powerpc64-linux/lib/ -isystem /usr/powerpc64-linux/include -isystem 
/usr/powerpc64-linux/sys-include  -m32   -O2 -g -I . -c -fgo-pkgpath=`echo 
errors.lo | sed -e 's/.lo$//' -e 's/-go$//'` -o errors.lo $files
libtool: compile:  /daten/gcc/gcc-20150613/Build/./gcc/gccgo 
-B/daten/gcc/gcc-20150613/Build/./gcc/ -B/usr/powerpc64-linux/bin/ 
-B/usr/powerpc64-linux/lib/ -isystem /usr/powerpc64-linux/include -isystem 
/usr/powerpc64-linux/sys-include -m32 -O2 -g -I . -c -fgo-pkgpath=errors 
../../../../libgo/go/errors/errors.go 
go1: error: ‘-fsplit-stack’ currently only supported on PowerPC64 GNU/Linux 
with glibc-2.18 or later
go1: error: ‘-fsplit-stack’ is not supported by this compiler configuration
make[2]: *** [errors.lo] Error 1
make[2]: Leaving directory 
`/daten/gcc/gcc-20150613/Build/powerpc64-linux/32/libgo'
make[1]: *** [all-recursive] Error 1

Andreas.

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


Re: match.pd: Optimize (x & y) ^ (x | y)

2015-06-13 Thread Marc Glisse

On Fri, 12 Jun 2015, Marek Polacek wrote:


fold-const.c traditionally avoided the combinatorial explosion by using
strip_nops.


Yeah.  We can probably special case conditional conversions in code
generation instead of lowering it.  And then go the full way and special
case nop conversions so you can avoid writing the predicate as well.


Without special casing, I currently have:

(match (nopcvt @0)
 (convert? @0)
 (if (tree_nop_conversion_p (type, TREE_TYPE (@0)
(simplify
 (bit_xor:c (convert1? (bit_and@2 (nopcvt @0) (nopcvt @1)))
(convert2? (bit_ior:c (nopcvt @0) (nopcvt @1
 (if (tree_nop_conversion_p (type, TREE_TYPE (@2)))


This could use @0 instead of @2 to save 2 characters.


  (bit_xor (convert @0) (convert @1

which simplifies Jakub's testcase without exploding the size of *-match.c,
but it is still not very satisfying.


Yeah, imagine if we'd have to change every pattern like that :-(.


I am not sure that we will be able to completely avoid it. Nop conversions 
can be ignored in some places, but not everywhere, so we have to be 
explicit about it. We could make a nice short notation, say bit_and# to 
switch whether there is an implicit strip_nops or not, and pick the 
default that applies to most patterns. We would still need a way to access 
the unstripped version of @2 (@#2 maybe?). And we would still need the 
'convert' in the output pattern, unless we teach genmatch to add nop 
conversions in many places, which sounds complicated.


--
Marc Glisse


Re: RFA: Make classify_insn available to the generators

2015-06-13 Thread Eric Botcazou
> gen_expand and gen_split have some fairly complex tests that really just
> repeat what's in classify_insn.  This patch moves classify_insn to rtl.c,
> so that it's available to the generators.  It also adds a generator-specific
> UNKNOWN return code for cases where we need to choose at (GCC) runtime.
> 
> This is preparing for a patch series that I'll post about soon.
> 
> Bootstrapped & regression-tested on x86_64-linux-gnu.  Also tested
> with config-list.mk.  OK for the rtl bits?

Sure.

> The test for whether a barrier is needed seems a little weak: what
> about indirect jumps, jumps with match_operand sources, or jumps in
> PARALLELs?  That for another day though.  At least this patch means
> we'll only have to update one place rather than two.

Agreed.

-- 
Eric Botcazou


Re: match.pd: Three new patterns

2015-06-13 Thread Marc Glisse

They look fine to me.


+/* (x & y) + (x ^ y) -> x | y */


This also works if you replace + with | or ^.


+/* (x | y) - (x ^ y) -> x & y */


For symmetry, you probably also want:
(x | y) - (x & y) -> x ^ y

(they both also work with ^ instead of -)


+/* (x & y) + (x | y) -> x + y */


Again for symmetry, it seems like this comes with
x + y - (x | y) -> x & y
x + y - (x & y) -> x | y
which seem fine when overflow is undefined or wraps, but not if for 
instance it saturates.


--
Marc Glisse


RFA: Make classify_insn available to the generators

2015-06-13 Thread Richard Sandiford
gen_expand and gen_split have some fairly complex tests that really just
repeat what's in classify_insn.  This patch moves classify_insn to rtl.c,
so that it's available to the generators.  It also adds a generator-specific
UNKNOWN return code for cases where we need to choose at (GCC) runtime.

This is preparing for a patch series that I'll post about soon.

Bootstrapped & regression-tested on x86_64-linux-gnu.  Also tested
with config-list.mk.  OK for the rtl bits?

The test for whether a barrier is needed seems a little weak: what
about indirect jumps, jumps with match_operand sources, or jumps in
PARALLELs?  That for another day though.  At least this patch means
we'll only have to update one place rather than two.

Thanks,
Richard


gcc/
* rtl.h (classify_insn): Declare.
* emit-rtl.c (classify_insn): Move to...
* rtl.c: ...here and add generator support.
* gensupport.h (get_emit_function, needs_barrier_p): Declare.
* gensupport.c (get_emit_function, needs_barrier_p): New functions.
* genemit.c (gen_emit_seq): New function.
(gen_expand, gen_split): Use it.

Index: gcc/rtl.h
===
--- gcc/rtl.h   2015-06-13 10:37:47.781963830 +0100
+++ gcc/rtl.h   2015-06-13 10:38:55.640981540 +0100
@@ -2665,6 +2665,7 @@ extern rtvec rtvec_alloc (int);
 extern rtvec shallow_copy_rtvec (rtvec);
 extern bool shared_const_p (const_rtx);
 extern rtx copy_rtx (rtx);
+extern enum rtx_code classify_insn (rtx);
 extern void dump_rtx_statistics (void);
 
 /* In emit-rtl.c */
Index: gcc/emit-rtl.c
===
--- gcc/emit-rtl.c  2015-06-13 10:37:47.781963830 +0100
+++ gcc/emit-rtl.c  2015-06-13 10:38:55.638981628 +0100
@@ -5309,43 +5309,6 @@ set_dst_reg_note (rtx insn, enum reg_not
   return NULL_RTX;
 }
 
-/* Return an indication of which type of insn should have X as a body.
-   The value is CODE_LABEL, INSN, CALL_INSN or JUMP_INSN.  */
-
-static enum rtx_code
-classify_insn (rtx x)
-{
-  if (LABEL_P (x))
-return CODE_LABEL;
-  if (GET_CODE (x) == CALL)
-return CALL_INSN;
-  if (ANY_RETURN_P (x))
-return JUMP_INSN;
-  if (GET_CODE (x) == SET)
-{
-  if (SET_DEST (x) == pc_rtx)
-   return JUMP_INSN;
-  else if (GET_CODE (SET_SRC (x)) == CALL)
-   return CALL_INSN;
-  else
-   return INSN;
-}
-  if (GET_CODE (x) == PARALLEL)
-{
-  int j;
-  for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
-   if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
- return CALL_INSN;
-   else if (GET_CODE (XVECEXP (x, 0, j)) == SET
-&& SET_DEST (XVECEXP (x, 0, j)) == pc_rtx)
- return JUMP_INSN;
-   else if (GET_CODE (XVECEXP (x, 0, j)) == SET
-&& GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == CALL)
- return CALL_INSN;
-}
-  return INSN;
-}
-
 /* Emit the rtl pattern X as an appropriate kind of insn.
If X is a label, it is simply added into the insn chain.  */
 
Index: gcc/rtl.c
===
--- gcc/rtl.c   2015-06-13 10:37:47.781963830 +0100
+++ gcc/rtl.c   2015-06-13 10:38:55.639981584 +0100
@@ -658,6 +658,54 @@ rtx_equal_p (const_rtx x, const_rtx y)
   return 1;
 }
 
+/* Return an indication of which type of insn should have X as a body.
+   In generator files, this can be UNKNOWN if the answer is only known
+   at (GCC) runtime.  Otherwise the value is CODE_LABEL, INSN, CALL_INSN
+   or JUMP_INSN.  */
+
+enum rtx_code
+classify_insn (rtx x)
+{
+  if (LABEL_P (x))
+return CODE_LABEL;
+  if (GET_CODE (x) == CALL)
+return CALL_INSN;
+  if (ANY_RETURN_P (x))
+return JUMP_INSN;
+  if (GET_CODE (x) == SET)
+{
+  if (GET_CODE (SET_DEST (x)) == PC)
+   return JUMP_INSN;
+  else if (GET_CODE (SET_SRC (x)) == CALL)
+   return CALL_INSN;
+  else
+   return INSN;
+}
+  if (GET_CODE (x) == PARALLEL)
+{
+  int j;
+  for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
+   if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
+ return CALL_INSN;
+   else if (GET_CODE (XVECEXP (x, 0, j)) == SET
+&& GET_CODE (SET_DEST (XVECEXP (x, 0, j))) == PC)
+ return JUMP_INSN;
+   else if (GET_CODE (XVECEXP (x, 0, j)) == SET
+&& GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == CALL)
+ return CALL_INSN;
+}
+#ifdef GENERATOR_FILE
+  if (GET_CODE (x) == MATCH_OPERAND
+  || GET_CODE (x) == MATCH_OPERATOR
+  || GET_CODE (x) == MATCH_PARALLEL
+  || GET_CODE (x) == MATCH_OP_DUP
+  || GET_CODE (x) == MATCH_DUP
+  || GET_CODE (x) == PARALLEL)
+return UNKNOWN;
+#endif
+  return INSN;
+}
+
 void
 dump_rtx_statistics (void)
 {
Index: gcc/gensupport.h
===
--- gcc/gensupport.h2015-06-13 10:38:52.370125288 +0100
+++ gcc/gensupport.h2015-06-13 10:38:55.63998158

[committed] Move add_implicit_parallel to gensupport

2015-06-13 Thread Richard Sandiford
Several places in the generators want to convert a define_insn rtvec
into a single rtx.  This patch just puts the routine to do that in
gensupport.c.  The changes to process_one_cond_exec mean that we'll
allocate rtvecs more often, but that's not going to make a noticeable
difference and I think it's better to handle the single- and multi-rtx
forms consistently.

Bootstrapped & regression-tested on x86_64-linux-gnu.  Also tested
with config-list.mk.  Applied.

Richard


gcc/
* gensupport.h (add_implicit_parallel): Declare.
* genrecog.c (add_implicit_parallel): Move to...
* gensupport.c (add_implicit_parallel): ...here.
(process_one_cond_exec): Use it.
* genemit.c (gen_insn): Likewise.

Index: gcc/gensupport.h
===
--- gcc/gensupport.h2015-06-13 10:37:47.844961062 +0100
+++ gcc/gensupport.h2015-06-13 10:38:52.370125288 +0100
@@ -23,6 +23,7 @@ #define GCC_GENSUPPORT_H
 struct obstack;
 extern struct obstack *rtl_obstack;
 
+extern rtx add_implicit_parallel (rtvec);
 extern bool init_rtx_reader_args_cb (int, char **, bool (*)(const char *));
 extern bool init_rtx_reader_args (int, char **);
 extern rtx read_md_rtx (int *, int *);
Index: gcc/genrecog.c
===
--- gcc/genrecog.c  2015-06-13 10:37:47.844961062 +0100
+++ gcc/genrecog.c  2015-06-13 10:38:52.369125332 +0100
@@ -5187,22 +5187,6 @@ print_subroutine_group (output_state *os
   print_subroutine (os, root, 0);
 }
 
-/* Return the rtx pattern specified by the list of rtxes in a
-   define_insn or define_split.  */
-
-static rtx
-add_implicit_parallel (rtvec vec)
-{
-  if (GET_NUM_ELEM (vec) == 1)
-return RTVEC_ELT (vec, 0);
-  else
-{
-  rtx pattern = rtx_alloc (PARALLEL);
-  XVEC (pattern, 0) = vec;
-  return pattern;
-}
-}
-
 /* Return the rtx pattern for the list of rtxes in a define_peephole2.  */
 
 static rtx
Index: gcc/gensupport.c
===
--- gcc/gensupport.c2015-06-13 10:37:47.844961062 +0100
+++ gcc/gensupport.c2015-06-13 10:38:52.370125288 +0100
@@ -143,6 +143,22 @@ gen_rtx_CONST_INT (machine_mode ARG_UNUS
   XWINT (rt, 0) = arg;
   return rt;
 }
+
+/* Return the rtx pattern specified by the list of rtxes in a
+   define_insn or define_split.  */
+
+rtx
+add_implicit_parallel (rtvec vec)
+{
+  if (GET_NUM_ELEM (vec) == 1)
+return RTVEC_ELT (vec, 0);
+  else
+{
+  rtx pattern = rtx_alloc (PARALLEL);
+  XVEC (pattern, 0) = vec;
+  return pattern;
+}
+}
 
 /* Predicate handling.
 
@@ -1703,19 +1719,9 @@ process_one_cond_exec (struct queue_elem
   XSTR (insn, 0) = new_name;
   pattern = rtx_alloc (COND_EXEC);
   XEXP (pattern, 0) = pred;
-  if (XVECLEN (insn, 1) == 1)
-   {
- XEXP (pattern, 1) = XVECEXP (insn, 1, 0);
- XVECEXP (insn, 1, 0) = pattern;
- PUT_NUM_ELEM (XVEC (insn, 1), 1);
-   }
-  else
-   {
- XEXP (pattern, 1) = rtx_alloc (PARALLEL);
- XVEC (XEXP (pattern, 1), 0) = XVEC (insn, 1);
- XVEC (insn, 1) = rtvec_alloc (1);
- XVECEXP (insn, 1, 0) = pattern;
-   }
+  XEXP (pattern, 1) = add_implicit_parallel (XVEC (insn, 1));
+  XVEC (insn, 1) = rtvec_alloc (1);
+  XVECEXP (insn, 1, 0) = pattern;
 
if (XVEC (ce_elem->data, 3) != NULL)
{
@@ -1760,19 +1766,10 @@ process_one_cond_exec (struct queue_elem
   /* Predicate the pattern matched by the split.  */
   pattern = rtx_alloc (COND_EXEC);
   XEXP (pattern, 0) = pred;
-  if (XVECLEN (split, 0) == 1)
-   {
- XEXP (pattern, 1) = XVECEXP (split, 0, 0);
- XVECEXP (split, 0, 0) = pattern;
- PUT_NUM_ELEM (XVEC (split, 0), 1);
-   }
-  else
-   {
- XEXP (pattern, 1) = rtx_alloc (PARALLEL);
- XVEC (XEXP (pattern, 1), 0) = XVEC (split, 0);
- XVEC (split, 0) = rtvec_alloc (1);
- XVECEXP (split, 0, 0) = pattern;
-   }
+  XEXP (pattern, 1) = add_implicit_parallel (XVEC (split, 0));
+  XVEC (split, 0) = rtvec_alloc (1);
+  XVECEXP (split, 0, 0) = pattern;
+
   /* Predicate all of the insns generated by the split.  */
   for (i = 0; i < XVECLEN (split, 2); i++)
{
Index: gcc/genemit.c
===
--- gcc/genemit.c   2015-06-13 10:37:47.844961062 +0100
+++ gcc/genemit.c   2015-06-13 10:38:52.369125332 +0100
@@ -378,27 +378,15 @@ gen_insn (rtx insn, int lineno)
 
   /* Output code to construct and return the rtl for the instruction body.  */
 
-  if (XVECLEN (insn, 1) == 1)
-{
-  printf ("  return ");
-  gen_exp (XVECEXP (insn, 1, 0), DEFINE_INSN, NULL);
-  printf (";\n}\n\n");
-}
-  else
-{
-  char *used = XCNEWVEC (char, stats.num_generator_args);
-
-  printf ("  return gen_rtx_PARALLEL 

[committed] Add parloops-exit-first-loop-alt-4.c

2015-06-13 Thread Tom de Vries

Hi,

this patch adds a new test-case. The existing three 
parloops-exit-first-loop-alt test-cases covered:

- variable bound, vector addition
- constant bound, vector addition
- variable bound, reduction

This patch adds the case 'constant bound, reduction'.

Committed to trunk.

Thanks,
- Tom
Add gcc.dg/parloops-exit-first-loop-alt-4.c

2015-06-13  Tom de Vries  

	* gcc.dg/parloops-exit-first-loop-alt-4.c: New test.

	* testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c: New test.
---
 .../gcc.dg/parloops-exit-first-loop-alt-4.c| 28 ++
 .../libgomp.c/parloops-exit-first-loop-alt-4.c | 33 ++
 2 files changed, 61 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-4.c
 create mode 100644 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c

diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-4.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-4.c
new file mode 100644
index 000..2b8d289
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-4.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target pthread } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */
+
+/* Constant bound, reduction.  */
+
+#define N 4000
+
+unsigned int *a;
+
+unsigned int
+f (void)
+{
+  int i;
+  unsigned int sum = 1;
+
+  for (i = 0; i < N; ++i)
+sum += a[i];
+
+  return sum;
+}
+
+/* Three array accesses:
+   - one in f._loopfn.0
+   - one in the parallel
+   - one in the low iteration count loop
+   Crucially, none for a peeled off last iteration following the parallel.  */
+/* { dg-final { scan-tree-dump-times "(?n)\\\* 4" 3 "parloops" } } */
diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c
new file mode 100644
index 000..1beae3e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2" } */
+
+/* Constant bound, reduction.  */
+
+#define N 4000
+
+unsigned int *a;
+
+unsigned int
+f (void)
+{
+  int i;
+  unsigned int sum = 1;
+
+  for (i = 0; i < N; ++i)
+sum += a[i];
+
+  return sum;
+}
+
+int
+main (void)
+{
+  unsigned int res;
+  unsigned int array[N];
+  int i;
+  for (i = 0; i < N; ++i)
+array[i] = i % 7;
+  a = &array[0];
+  res = f ();
+  return !(res == 11995);
+}
-- 
1.9.1



[committed] Update parloops-exit-first-loop-alt{,-2,-3}.c

2015-06-13 Thread Tom de Vries

Hi,

this patch contains trivial improvements for test-cases 
{libgomp.c,gcc.dg}/parloops-exit-first-loop-alt{,-2,-3}.c.


Committed to trunk.

Thanks,
- Tom
Update parloops-exit-first-loop-alt{,-2,-3}.c

2015-06-13  Tom de Vries  

	* testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c: Add comment.
	* testsuite/libgomp.c/parloops-exit-first-loop-alt.c: Same.
	* testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c: Add comment.
	(N): Define.
	(main): Use N instead of hardcoded constants.

	* gcc.dg/parloops-exit-first-loop-alt-2.c: Add comment.
	(main): Remove superfluous attributes.
	* gcc.dg/parloops-exit-first-loop-alt-3.c: Same.
	* gcc.dg/parloops-exit-first-loop-alt.c: Same.
---
 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c|  6 --
 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c|  4 +++-
 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c  |  4 +++-
 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c |  2 ++
 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c | 10 +++---
 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c   |  2 ++
 6 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c
index 956be9b..24e605a 100644
--- a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c
+++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c
@@ -2,14 +2,16 @@
 /* { dg-require-effective-target pthread } */
 /* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */
 
+/* Constant bound, vector addition.  */
+
 #define N 1000
 
 unsigned int a[N];
 unsigned int b[N];
 unsigned int c[N];
 
-void __attribute__((noclone,noinline))
-f (unsigned int n)
+void
+f (void)
 {
   int i;
 
diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c
index 82b0b1d..b0fde37 100644
--- a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c
+++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c
@@ -2,9 +2,11 @@
 /* { dg-require-effective-target pthread } */
 /* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */
 
+/* Variable bound, reduction.  */
+
 unsigned int *a;
 
-unsigned int __attribute__((noclone,noinline))
+unsigned int
 f (unsigned int n)
 {
   int i;
diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c
index 9be844a..b36f01b 100644
--- a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c
+++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c
@@ -2,13 +2,15 @@
 /* { dg-require-effective-target pthread } */
 /* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */
 
+/* Variable bound, vector addition.  */
+
 #define N 1000
 
 unsigned int a[N];
 unsigned int b[N];
 unsigned int c[N];
 
-void __attribute__((noclone,noinline))
+void
 f (unsigned int n)
 {
   int i;
diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c
index eb5e11f..f20cc99 100644
--- a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c
+++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c
@@ -1,6 +1,8 @@
 /* { dg-do run } */
 /* { dg-options "-O2 -ftree-parallelize-loops=2" } */
 
+/* Constant bound, vector addition.  */
+
 #include 
 #include 
 
diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
index b426b3f..d55589e 100644
--- a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
+++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
@@ -1,6 +1,10 @@
 /* { dg-do run } */
 /* { dg-options "-O2 -ftree-parallelize-loops=2" } */
 
+/* Variable bound, reduction.  */
+
+#define N 4000
+
 unsigned int *a;
 
 unsigned int __attribute__((noclone,noinline))
@@ -19,11 +23,11 @@ int
 main (void)
 {
   unsigned int res;
-  unsigned int array[4000];
+  unsigned int array[N];
   int i;
-  for (i = 0; i < 4000; ++i)
+  for (i = 0; i < N; ++i)
 array[i] = i % 7;
   a = &array[0];
-  res = f (4000);
+  res = f (N);
   return !(res == 11995);
 }
diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c
index d7d4003..f5fd315 100644
--- a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c
+++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c
@@ -1,6 +1,8 @@
 /* { dg-do run } */
 /* { dg-options "-O2 -ftree-parallelize-loops=2" } */
 
+/* Variable bound, vector addition.  */
+
 #include 
 #include 
 
-- 
1.9.1