Re: [PATCH] [RFA] [PR tree-optmization/69740] Schedule loop fixups when needed

2016-02-25 Thread Jeff Law

On 02/25/2016 03:00 AM, Richard Biener wrote:


So I fail to see how only successor edges are relevant.  Isn't the important
case to catch whether we remove an edge marked EDGE_IRREDUCIBLE_LOOP?
Even if the BB persists we might have exposed a new loop here.

Note that it is not safe to look at {BB,EDGE}_IRREDUCIBLE_LOOP if the loop
state does not have LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS set
(the flags may be stale or missing).  So it might be that we can't rely on
non-loop passes modifying the CFG to handle this optimistically.

Thus, how about (my main point) moving this to remove_edge instead, like
Yea.  That works.  The !loops_state_satisfies_p check will almost 
certainly cause us to trigger loop cleanups more often, but I think it's 
the right/safe thing to do to catch cases where we haven't go the 
IRREDUCIBLE_LOOP flags set.



Bootstrapped and regression tested on x86_64-linux-gnu.  OK for the trunk?

Thanks,
Jeff

PR tree-optimization/69740
* cfghooks.c (remove_edge): Request loop fixups if we delete
an edge that might turn an irreducible loop into a natural
loop.

PR tree-optimization/69740
* gcc.c-torture/compile/pr69740-1.c: New test.
* gcc.c-torture/compile/pr69740-2.c: New test.

diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index bbb1017..f80e455 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -408,7 +408,14 @@ void
 remove_edge (edge e)
 {
   if (current_loops != NULL)
-rescan_loop_exit (e, false, true);
+{
+  rescan_loop_exit (e, false, true);
+
+  if (!loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)
+ || (e->flags & EDGE_IRREDUCIBLE_LOOP)
+ || (e->dest->flags & BB_IRREDUCIBLE_LOOP))
+   loops_state_set (LOOPS_NEED_FIXUP);
+}
 
   /* This is probably not needed, but it doesn't hurt.  */
   /* FIXME: This should be called via a remove_edge hook.  */
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr69740-1.c 
b/gcc/testsuite/gcc.c-torture/compile/pr69740-1.c
new file mode 100644
index 000..ac867d8
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr69740-1.c
@@ -0,0 +1,12 @@
+char a;
+short b;
+void fn1() {
+  if (b)
+;
+  else {
+int c[1] = {0};
+  l1:;
+  }
+  if (a)
+goto l1;
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr69740-2.c 
b/gcc/testsuite/gcc.c-torture/compile/pr69740-2.c
new file mode 100644
index 000..a89c9a0
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr69740-2.c
@@ -0,0 +1,19 @@
+inline int foo(int *p1, int p2) {
+  int z = *p1;
+  while (z > p2)
+p2 = 2;
+  return z;
+}
+int main() {
+  int i;
+  for (;;) {
+int j, k;
+i = foo(, 7);
+if (k)
+  j = i;
+else
+  k = j;
+if (2 != j)
+  __builtin_abort();
+  }
+}


[PATCH, rs6000] Fixing PR 67145

2016-02-25 Thread Richard Henderson

It's the simplify-rtx.c portion of the patch that fixes the i686 regression.

In the PR, Alan raises some good points, but I don't believe that we can 
address those for gcc6.  A new rtl reassoc optimization that takes loop 
invariance into account will have to wait.


But we do need to take care of the rs6000 ice that results, and that's the bulk 
of the patch -- allowing CA to be sorted to any register of the plus chain.


Some notes:

ca_operand doesn't work as written, since CA_REGNO is not an available 
register, and thus doesn't satisfy register_operand.


Is there any particular reason that subf<>3_carry_in_m1 was written with minus 
rather than plus like all of the other patterns?



Tested on ppc64le-linux.


r~
* simplify-rtx.c (simplify_plus_minus): If only PLUS of REG,
rematerialize the canonical chain.

* config/rs6000/predicates.md (ca_operand): Use match_code.
(gpc_ca_reg_operand): New.
* config/rs6000/rs6000.md (add3_carry_in): Expand by hand.
(subf3_carry_in): Likewise.
(*add3_carry_in_reg): Rename from *add3_carry_in_internal;
accept CA at any register position, exactly once.
(*add3_carry_in_0): Similarly.
(*add3_carry_in_m1): Similarly.
(*subf3_carry_in_reg): Similarly.
(*subf3_carry_in_0): Rename with leading *.
(*subf3_carry_in_m1): Rename with leading *; use the same
plus/plus/not form as subf3_carry_in_reg.

diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index 072291e..98937bd 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -116,7 +116,7 @@
 
 ;; Return 1 if op is the carry register.
 (define_predicate "ca_operand"
-  (match_operand 0 "register_operand")
+  (match_code "reg,subreg")
 {
   if (GET_CODE (op) == SUBREG)
 op = SUBREG_REG (op);
@@ -230,6 +230,10 @@
   return INT_REGNO_P (REGNO (op)) || FP_REGNO_P (REGNO (op));
 })
 
+(define_predicate "gpc_ca_reg_operand"
+  (ior (match_operand 0 "gpc_reg_operand")
+   (match_operand 0 "ca_operand")))
+
 ;; Return 1 if op is a general purpose register.  Unlike gpc_reg_operand, don't
 ;; allow floating point or vector registers.
 (define_predicate "int_reg_operand"
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 0299a00..b300727 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -1770,50 +1770,65 @@
 (define_expand "add3_carry_in"
   [(parallel [
  (set (match_operand:GPR 0 "gpc_reg_operand")
- (plus:GPR (plus:GPR (match_operand:GPR 1 "gpc_reg_operand")
- (match_operand:GPR 2 "adde_operand"))
-   (reg:GPR CA_REGNO)))
+ (plus:GPR
+   (plus:GPR
+ (reg:GPR CA_REGNO)
+  (match_operand:GPR 1 "gpc_reg_operand"))
+   (match_operand:GPR 2 "adde_operand")))
  (clobber (reg:GPR CA_REGNO))])]
   ""
 {
-  if (operands[2] == const0_rtx)
-{
-  emit_insn (gen_add3_carry_in_0 (operands[0], operands[1]));
-  DONE;
-}
-  if (operands[2] == constm1_rtx)
-{
-  emit_insn (gen_add3_carry_in_m1 (operands[0], operands[1]));
-  DONE;
-}
+  rtx ca = gen_rtx_REG (mode, CA_REGNO);
+  rtx x, y;
+
+  x = gen_rtx_PLUS (mode, ca, operands[1]);
+  if (operands[2] != const0_rtx)
+x = gen_rtx_PLUS (mode, x, operands[2]);
+  x = gen_rtx_SET (operands[0], x);
+  y = gen_rtx_CLOBBER (VOIDmode, ca);
+
+  emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, x, y)));
+  DONE;
 })
 
-(define_insn "*add3_carry_in_internal"
-  [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
-   (plus:GPR (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
-   (match_operand:GPR 2 "gpc_reg_operand" "r"))
- (reg:GPR CA_REGNO)))
+(define_insn "*add3_carry_in_reg"
+  [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,r")
+   (plus:GPR
+ (plus:GPR
+   (match_operand:GPR 1 "gpc_ca_reg_operand" "z,r,r")
+   (match_operand:GPR 2 "gpc_ca_reg_operand" "r,z,r"))
+ (match_operand:GPR 3 "gpc_ca_reg_operand"   "r,r,z")))
(clobber (reg:GPR CA_REGNO))]
-  ""
-  "adde %0,%1,%2"
+  "ca_operand (operands[1], mode)
+   + ca_operand (operands[2], mode)
+   + ca_operand (operands[3], mode) == 1"
+  "@
+   adde %0,%2,%3
+   adde %0,%1,%3
+   adde %0,%1,%2"
   [(set_attr "type" "add")])
 
-(define_insn "add3_carry_in_0"
+(define_insn "*add3_carry_in_0"
   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
-   (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
- (reg:GPR CA_REGNO)))
+   (plus:GPR
+ (match_operand:GPR 1 "gpc_ca_reg_operand" "%r")
+ (match_operand:GPR 2 "gpc_ca_reg_operand" "z")))
(clobber (reg:GPR CA_REGNO))]
-  ""
+  "ca_operand (operands[1], mode)
+   + ca_operand (operands[2], mode) == 1"
   "addze %0,%1"
   [(set_attr "type" "add")])
 
-(define_insn "add3_carry_in_m1"
+(define_insn 

C++ PATCH for c++/69889 (ICE with lambda conversion)

2016-02-25 Thread Jason Merrill
Here, we were crashing because the artificial thunk returned by the 
lambda conversion operator was dereferencing an invisible reference 
parameter instead of passing it through.  I needed to fix 
cp_genericize_r to avoid that like it already does for virtual function 
thunks.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 3180adca839ba43c21834ef6cb6af7bbc8eda478
Author: Jason Merrill 
Date:   Thu Feb 25 21:40:09 2016 -0500

	PR c++/69889

	* cp-tree.h (AGGR_INIT_FROM_THUNK_P): New.
	* tree.c (build_aggr_init_expr): Set it.
	* semantics.c (simplify_aggr_init_expr): Check it.
	* cp-gimplify.c (cp_genericize_r): Don't walk into
	a call/aggr_init from a thunk.

diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index a77b242..6af3760 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1021,10 +1021,16 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
   && omp_var_to_track (stmt))
 omp_cxx_notice_variable (wtd->omp_ctx, stmt);
 
-  if (is_invisiref_parm (stmt)
-  /* Don't dereference parms in a thunk, pass the references through. */
-  && !(DECL_THUNK_P (current_function_decl)
-	   && TREE_CODE (stmt) == PARM_DECL))
+  /* Don't dereference parms in a thunk, pass the references through. */
+  if ((TREE_CODE (stmt) == CALL_EXPR && CALL_FROM_THUNK_P (stmt))
+  || (TREE_CODE (stmt) == AGGR_INIT_EXPR && AGGR_INIT_FROM_THUNK_P (stmt)))
+{
+  *walk_subtrees = 0;
+  return NULL;
+}
+
+  /* Otherwise, do dereference invisible reference parms.  */
+  if (is_invisiref_parm (stmt))
 {
   *stmt_p = convert_from_reference (stmt);
   *walk_subtrees = 0;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 88c6367..b1dc23c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3409,6 +3409,11 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 #define AGGR_INIT_ZERO_FIRST(NODE) \
   TREE_LANG_FLAG_2 (AGGR_INIT_EXPR_CHECK (NODE))
 
+/* Nonzero means that the call is the jump from a thunk to the
+   thunked-to function.  */
+#define AGGR_INIT_FROM_THUNK_P(NODE) \
+  (AGGR_INIT_EXPR_CHECK (NODE)->base.protected_flag)
+
 /* AGGR_INIT_EXPR accessors.  These are equivalent to the CALL_EXPR
accessors, except for AGGR_INIT_EXPR_SLOT (which takes the place of
CALL_EXPR_STATIC_CHAIN).  */
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index fad233a..fd83c46 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -4067,6 +4067,7 @@ simplify_aggr_init_expr (tree *tp)
 AGGR_INIT_EXPR_ARGP (aggr_init_expr));
   TREE_NOTHROW (call_expr) = TREE_NOTHROW (aggr_init_expr);
   CALL_EXPR_LIST_INIT_P (call_expr) = CALL_EXPR_LIST_INIT_P (aggr_init_expr);
+  CALL_FROM_THUNK_P (call_expr) = AGGR_INIT_FROM_THUNK_P (aggr_init_expr);
 
   if (style == ctor)
 {
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index ac38ce3..9e29a42 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -464,18 +464,25 @@ build_aggr_init_expr (tree type, tree init)
 {
   slot = build_local_temp (type);
 
-  if (TREE_CODE(init) == CALL_EXPR)
-	rval = build_aggr_init_array (void_type_node, fn, slot,
-  call_expr_nargs (init),
-  CALL_EXPR_ARGP (init));
+  if (TREE_CODE (init) == CALL_EXPR)
+	{
+	  rval = build_aggr_init_array (void_type_node, fn, slot,
+	call_expr_nargs (init),
+	CALL_EXPR_ARGP (init));
+	  AGGR_INIT_FROM_THUNK_P (rval)
+	= CALL_FROM_THUNK_P (init);
+	}
   else
-	rval = build_aggr_init_array (void_type_node, fn, slot,
-  aggr_init_expr_nargs (init),
-  AGGR_INIT_EXPR_ARGP (init));
+	{
+	  rval = build_aggr_init_array (void_type_node, fn, slot,
+	aggr_init_expr_nargs (init),
+	AGGR_INIT_EXPR_ARGP (init));
+	  AGGR_INIT_FROM_THUNK_P (rval)
+	= AGGR_INIT_FROM_THUNK_P (init);
+	}
   TREE_SIDE_EFFECTS (rval) = 1;
   AGGR_INIT_VIA_CTOR_P (rval) = is_ctor;
   TREE_NOTHROW (rval) = TREE_NOTHROW (init);
-  CALL_EXPR_LIST_INIT_P (rval) = CALL_EXPR_LIST_INIT_P (init);
 }
   else
 rval = init;
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv10.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv10.C
new file mode 100644
index 000..8e806c8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv10.C
@@ -0,0 +1,34 @@
+// PR c++/69889
+// { dg-do compile { target c++11 } }
+
+template  struct Tag {
+  static void fp() { f()(0); }
+  static F f() {}
+};
+
+struct Dispatch {
+  template  Dispatch(F&&) : f(Tag::fp) {}
+  void (*f)();
+};
+
+struct Empty { Empty(Empty&&); };
+
+struct Value {
+  Value();
+  template  Value(U);
+  void call(Dispatch);
+  Empty e;
+};
+
+struct EmptyValue {
+  EmptyValue(EmptyValue&&);
+  EmptyValue();
+};
+
+struct User {
+  User() {
+Value().call([](Value) { return EmptyValue(); });
+  }
+};
+
+User user;


[PATCH] add more style checks to check_GNU_style.sh

2016-02-25 Thread Martin Sebor

Recently I had the opportunity to learn about a number of rather
subtle style conventions sometimes enforced during code reviews
(though not inconsistently followed in GCC code).  To help find
these kinds of problems before a patch is submitted and cut down
on the subsequent back-and-forth, I've added checks for some of
these conventions to the check_GNU_style.sh script.  In addition,
since the script tends to produce lots of noise for things that
can't be fixed in tests like lines in excess of 80 characters
caused by dg-error directives, I tweaked it to suppress these.

To verify that the new checkers don't add too much noise I ran
the patched script on the last 1000 commits, both with and without
testsuite changes (all without libstdc++).  The results are below.
It's telling that over a quarter of all commits violate even the
limited subset of the GNU coding guidelines the script checks for.

  script w/o tests  w/tests
  baseline  258   434
  patched   282   466

FWIW, to make the script more usable (e.g., to check the rules
appropriate for each file type, including documentation), it
will need to be considerably enhanced.  I think most of it can
be done in AWK (already used by the script), and I might try
to tackle that at some point in the future.

Martin
contrib/ChangeLog:
2016-02-25  Martin Sebor  

	* check_GNU_style.sh: Add a new global variable.
	Add checks for trailing operators and spaces before left brackets.
	Tightened up a check for a trailing left curly brace.
	(g, ag, vg): Use color.
	(col): Don't complain about excessively long lines with DejaGnu
	directives.

Index: contrib/check_GNU_style.sh
===
--- contrib/check_GNU_style.sh	(revision 233722)
+++ contrib/check_GNU_style.sh	(working copy)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 # Checks some of the GNU style formatting rules in a set of patches.
-# Copyright (C) 2010, 2012  Free Software Foundation, Inc.
+# Copyright (C) 2010, 2012, 2016  Free Software Foundation, Inc.
 # Contributed by Sebastian Pop 
 
 # This program is free software; you can redistribute it and/or modify
@@ -15,8 +15,11 @@
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+# along with this program; if not, see the file COPYING3.  If not,
+# see .
+
+# Set to empty in the environment to override.
+: ${color:---color=always}
 
 usage() {
 cat < "$tmp" && found=true
 
 if $found; then
@@ -117,8 +120,8 @@ ag (){
 
 local found=false
 cat $inp \
-	| egrep --color=always -- "$arg1" \
-	| egrep --color=always -- "$arg2" \
+	| egrep $color -- "$arg1" \
+	| egrep $color -- "$arg2" \
 	> "$tmp" && found=true
 
 if $found; then
@@ -136,7 +139,7 @@ vg (){
 local found=false
 cat $inp \
 	| egrep -v -- "$varg" \
-	| egrep --color=always -- "$arg" \
+	| egrep $color -- "$arg" \
 	> "$tmp" && found=true
 
 if $found; then
@@ -171,10 +174,11 @@ col (){
 	# Expand tabs to spaces according to tab positions.
 	# Keep long lines, make short lines empty.  Print the part past 80 chars
 	# in red.
+# Don't complain about dg-xxx directives in tests.
 	cat "$tmp" \
 	| sed 's/^[0-9]*:+//' \
 	| expand \
-	| awk '{ \
+	| awk '$0 !~ /{[[:space:]]*dg-(error|warning|message)[[:space:]]/ { \
 		 if (length($0) > 80) \
 		   printf "%s\033[1;31m%s\033[0m\n", \
 			  substr($0,1,80), \
@@ -201,6 +205,7 @@ col (){
 done
 }
 
+
 col 'Lines should not exceed 80 characters.'
 
 g 'Blocks of 8 spaces should be replaced with tabs.' \
@@ -221,13 +226,20 @@ g 'Dot, space, space, end of comment.' \
 g 'Sentences should end with a dot.  Dot, space, space, end of the comment.' \
 '[[:alnum:]][[:blank:]]*\*/'
 
-vg 'There should be exactly one space between function name and parentheses.' \
+vg 'There should be exactly one space between function name and parenthesis.' \
 '\#define' \
 '[[:alnum:]]([[:blank:]]{2,})?\('
 
-g 'There should be no space before closing parentheses.' \
+g 'There should be no space before a left square bracket.' \
+   '[[:alnum:]][[:blank:]]+\['
+
+g 'There should be no space before closing parenthesis.' \
 '[[:graph:]][[:blank:]]+\)'
 
-ag 'Braces should be on a separate line.' \
-'\{' \
-'if[[:blank:]]\(|while[[:blank:]]\(|switch[[:blank:]]\('
+# This will give false positives for C99 compound literals.
+g 'Braces should be on a separate line.' \
+'(\)|else)[[:blank:]]*{'
+
+# Does this apply to definition of aggregate objects?
+g 'Trailing operator.' \
+  '(([^a-zA-Z_]\*)|([-%<=&|^?])|([^*]/)|([^:][+]))$'


[RFC][PATCH][PR63586] Convert x+x+x+x into 4*x

2016-02-25 Thread kugan



Hi,

This is an attempt to fix missed optimization: x+x+x+x -> 4*x as 
reported in PR63586.


Regression tested and bootstrapped on x86-64-linux-gnu with no new 
regressions.


Is this OK for next stage1?

Thanks,
Kugan


gcc/testsuite/ChangeLog:

2016-02-26  Kugan Vivekanandarajah  

PR middle-end/63586
* gcc.dg/tree-ssa/reassoc-14.c: Fix multiply count.

gcc/ChangeLog:

2016-02-26  Kugan Vivekanandarajah  

PR middle-end/63586
* tree-ssa-reassoc.c (transform_add_to_multiply): New.
(reassociate_bb): Call transform_add_to_multiply.


diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-14.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-14.c
index 62802d1..16ebc86 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-14.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-14.c
@@ -19,6 +19,7 @@ unsigned int test2 (unsigned int x, unsigned int y, unsigned 
int z,
   return tmp1 + tmp2 + tmp3;
 }
 
-/* There should be one multiplication left in test1 and three in test2.  */
+/* There should be two multiplication left in test1 (inculding one generated
+   when converting addition to multiplication) and three in test2.  */
 
-/* { dg-final { scan-tree-dump-times "\\\*" 4 "reassoc1" } } */
+/* { dg-final { scan-tree-dump-times "\\\*" 5 "reassoc1" } } */
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index dfd0da1..2454b9d 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -1698,6 +1698,61 @@ eliminate_redundant_comparison (enum tree_code opcode,
   return false;
 }
 
+/* Recursively transoform repeated addition of same values into multiply with
+   constant.  */
+static void
+transform_add_to_multiply (gimple_stmt_iterator *gsi, gimple *stmt, 
vec *ops)
+{
+  operand_entry *oe;
+  tree op = NULL_TREE;
+  int i, start = -1, end = 0, count = 0;
+
+  /* Look for repeated operands.  */
+  FOR_EACH_VEC_ELT (*ops, i, oe)
+{
+  if (start == -1)
+   {
+ count = 1;
+ op = oe->op;
+ start = i;
+   }
+  else if (operand_equal_p (oe->op, op, 0))
+   {
+ count++;
+ end = i;
+   }
+  else if (count == 1)
+   {
+ count = 1;
+ op = oe->op;
+ start = i;
+   }
+  else
+   break;
+}
+
+  if (count > 1)
+{
+  /* Convert repeated operand addition to multiplication.  */
+  for (i = end; i >= start; --i)
+   ops->unordered_remove (i);
+  tree tmp = make_temp_ssa_name (TREE_TYPE (op), NULL, "reassocmul");
+  gassign *mul_stmt = gimple_build_assign (tmp, MULT_EXPR,
+  op, build_int_cst 
(TREE_TYPE(op), count));
+  gimple_set_location (mul_stmt, gimple_location (stmt));
+  gimple_set_uid (mul_stmt, gimple_uid (stmt));
+  gsi_insert_before (gsi, mul_stmt, GSI_SAME_STMT);
+  oe = operand_entry_pool.allocate ();
+  oe->op = tmp;
+  oe->rank = get_rank (op) * count;
+  oe->id = 0;
+  oe->count = 1;
+  ops->safe_push (oe);
+  transform_add_to_multiply (gsi, stmt, ops);
+}
+}
+
+
 /* Perform various identities and other optimizations on the list of
operand entries, stored in OPS.  The tree code for the binary
operation between all the operands is OPCODE.  */
@@ -4854,6 +4909,12 @@ reassociate_bb (basic_block bb)
  && flag_unsafe_math_optimizations)
powi_result = attempt_builtin_powi (stmt, );
 
+ if (rhs_code == PLUS_EXPR)
+   {
+ transform_add_to_multiply (, stmt, );
+ ops.qsort (sort_by_operand_rank);
+   }
+
  /* If the operand vector is now empty, all operands were 
 consumed by the __builtin_powi optimization.  */
  if (ops.length () == 0)


[RFC][PATCH][PR40921] Convert x + (-y * z * z) into x - y * z * z

2016-02-25 Thread kugan



Hi,

This is an attempt to fix missed optimization: x + (-y * z * z) => x - y 
* z * z as reported in PR40921.


Regression tested and bootstrapped on x86-64-linux-gnu with no new 
regressions.


Is this OK for next stage1?

Thanks,
Kugan


gcc/ChangeLog:

2016-02-26  Kugan Vivekanandarajah  

PR middle-end/40921
* tree-ssa-reassoc.c (propagate_neg_to_sub_or_add): New.
(reassociate_bb): Call propagate_neg_to_sub_or_add.


gcc/testsuite/ChangeLog:

2016-02-26  Kugan Vivekanandarajah  

PR middle-end/40921
* gcc.dg/tree-ssa/pr40921.c: New test.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr40921.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr40921.c
index e69de29..6a3529b 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr40921.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr40921.c
@@ -0,0 +1,11 @@
+
+/* PR middle-end/40921.  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-reassoc1 -fno-rounding-math" } */
+
+double foo (double x, double y, double z)
+{
+return x + (-y * z*z);
+}
+
+/* { dg-final { scan-tree-dump-times "= -" 0 "reassoc1" } } */
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index e54700e..f99635b 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -4784,6 +4784,78 @@ transform_stmt_to_multiply (gimple_stmt_iterator *gsi, 
gimple *stmt,
 }
 }
 
+/* Propagate NEGATE_EXPR to MINUS_EXPR/PLUS_EXPR when the neageted
+   expression is multiplied and used in MINUS_EXPR/PLUS_EXPR.  */
+static void
+propagate_neg_to_sub_or_add (gimple_stmt_iterator *gsi, gimple *stmt)
+{
+  tree lhs = gimple_assign_lhs (stmt);
+  tree rhs1, rhs2, mult_lhs;
+  gimple *use_stmt;
+  gimple *use_stmt2;
+  use_operand_p use;
+  enum tree_code code;
+  gassign *g;
+
+  /* Note that -frounding-math should disable the proposed
+ optimization.  */
+  if (flag_rounding_math)
+return;
+
+  if (!single_imm_use (lhs, , _stmt))
+return;
+
+  if (!is_gimple_assign (use_stmt))
+return;
+
+  code = gimple_assign_rhs_code (use_stmt);
+  if (code != MULT_EXPR)
+return;
+  mult_lhs = gimple_assign_lhs (use_stmt);
+  while (code == MULT_EXPR)
+{
+  if (!single_imm_use (mult_lhs, , _stmt2))
+   break;
+  if (!is_gimple_assign (use_stmt2))
+   break;
+  code = gimple_assign_rhs_code (use_stmt2);
+  mult_lhs = gimple_assign_lhs (use_stmt2);
+  use_stmt = use_stmt2;
+}
+
+  if (code != PLUS_EXPR
+  && code != MINUS_EXPR)
+return;
+
+  lhs = gimple_assign_lhs (use_stmt);
+  rhs1 = gimple_assign_rhs1 (use_stmt);
+  rhs2 = gimple_assign_rhs2 (use_stmt);
+
+  if (rhs1 == USE_FROM_PTR (use))
+{
+  if (code == MINUS_EXPR)
+   return;
+  std::swap (rhs1, rhs2);
+  code = MINUS_EXPR;
+}
+  else
+{
+  if (code == PLUS_EXPR)
+   code = MINUS_EXPR;
+  else
+   code = PLUS_EXPR;
+}
+
+  g = gimple_build_assign (lhs, code, rhs1, rhs2);
+  gimple_stmt_iterator gsi2 = gsi_for_stmt (use_stmt);
+  gsi_replace (, g, true);
+
+  lhs = gimple_assign_lhs (stmt);
+  rhs1 = gimple_assign_rhs1 (stmt);
+  g = gimple_build_assign (lhs, SSA_NAME, rhs1);
+  gsi_replace (gsi, g, true);
+}
+
 /* Reassociate expressions in basic block BB and its post-dominator as
children.
 
@@ -4809,6 +4881,11 @@ reassociate_bb (basic_block bb)
{
  tree lhs, rhs1, rhs2;
  enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
+ if (rhs_code == NEGATE_EXPR)
+   {
+ propagate_neg_to_sub_or_add (, stmt);
+ continue;
+   }
 
  /* If this is not a gimple binary expression, there is
 nothing for us to do with it.  */
@@ -4884,6 +4961,7 @@ reassociate_bb (basic_block bb)
  if (rhs_code == MULT_EXPR)
attempt_builtin_copysign ();
 
+
  if (reassoc_insert_powi_p
  && rhs_code == MULT_EXPR
  && flag_unsafe_math_optimizations)


Re: [PATCH] hurd: align -p and -pg behavior on Linux

2016-02-25 Thread Samuel Thibault
Samuel Thibault, on Thu 25 Feb 2016 00:18:21 +0100, wrote:
> Thomas Schwinge, on Wed 24 Feb 2016 23:46:36 +0100, wrote:
> > I guess getting -D_REENTRANT for -pthread won't do us any harm?
> 
> It won't.

(Actually we've been using this in Debian for a long time).

Samuel


[PATCH][SPARC] sparc: switch -fasynchronous-unwind-tables on by default.

2016-02-25 Thread Jose E. Marchesi
In sparc systems glibc uses libgcc's unwinder to implement the
backtrace(3) function, defaulting to a simple non-dwarf unwinder if
libgcc_s doesn't provide a working _Unwind_Backtrace.

However, libgcc's unwinder uses .eh_frame instead of .frame_debug, and
.eh_frame is fully populated only if applications are built with
-fexceptions or -fasynchronous-unwind-tables.

This patch changes GCC to assume -fasynchronous-unwind-tables by default
in sparcv9 and sparc64, like other ports (notably x86) do.

Tested in both sparcv9-*-* and sparc64-*-* targets.

   * common/config/sparc/sparc-common.c (sparc_option_init_struct):
 New function.
 (TARGET_OPTION_INIT_STRUCT): Defined.
---
 gcc/ChangeLog  |  6 ++
 gcc/common/config/sparc/sparc-common.c | 10 ++
 2 files changed, 16 insertions(+)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3a13f5f..ba7befe 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-02-25  Jose E. Marchesi  
+
+   * common/config/sparc/sparc-common.c (sparc_option_init_struct):
+   New function.
+   (TARGET_OPTION_INIT_STRUCT): Defined.
+
 2016-02-25  Richard Biener  
 
PR tree-optimization/48795
diff --git a/gcc/common/config/sparc/sparc-common.c 
b/gcc/common/config/sparc/sparc-common.c
index 3958b7e..1c5bc06 100644
--- a/gcc/common/config/sparc/sparc-common.c
+++ b/gcc/common/config/sparc/sparc-common.c
@@ -24,6 +24,14 @@ along with GCC; see the file COPYING3.  If not see
 #include "common/common-target.h"
 #include "common/common-target-def.h"
 
+/* Implement TARGET_OPTION_INIT_STRUCT.  */
+
+static void
+sparc_option_init_struct (struct gcc_options *opts)
+{
+  opts->x_flag_asynchronous_unwind_tables = 2;
+}
+
 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE.  */
 static const struct default_options sparc_option_optimization_table[] =
   {
@@ -31,6 +39,8 @@ static const struct default_options 
sparc_option_optimization_table[] =
 { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
+#undef TARGET_OPTION_INIT_STRUCT
+#define TARGET_OPTION_INIT_STRUCT sparc_option_init_struct
 #undef TARGET_DEFAULT_TARGET_FLAGS
 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
 #undef TARGET_OPTION_OPTIMIZATION_TABLE
-- 
2.3.4



Re: [PATCH] Fix DW_OP_GNU_implicit_pointer referring to DW_TAG_dwarf_procedure (PR debug/69947)

2016-02-25 Thread Jakub Jelinek
On Thu, Feb 25, 2016 at 05:46:40PM +0100, Jakub Jelinek wrote:
> On Thu, Feb 25, 2016 at 04:53:58PM +0100, Pierre-Marie de Rodat wrote:
> > I introduced a DW_OP_call* traversal for this:
> > 
> >   * prune_unused_types_mark traverses attributes using
> > prune_unused_types_walk_attribs;
> > 
> >   * …_walk_attribs walks location descriptions and location lists using
> > …_walk_loc_descr
> > 
> >   * …_walk_loc_descr marks DWARF procedures referenced by DW_OP_call*
> > operations.
> 
> Ah, I've been looking for something that would set die_perennial_p, but
> actually you just set die_mark later on instead for those.
> So IMHO the right fix is just handle all the ops that could directly or
> indirectly contain references to other DIEs, rather than just handling
> the 3 you have there.
> 
> Going to bootstrap/regtest this on x86_64-linux and i686-linux now.
> 
> Is this ok for trunk if it passes testing?

Successfully bootstrapped/regtested on x86_64-linux and i686-linux.

> 2016-02-25  Jakub Jelinek  
> 
>   PR debug/69947
>   * dwarf2out.c (prune_unused_types_walk_loc_descr): Handle
>   all other ops that have dw_val_class_die_ref operands,
>   and DW_OP_GNU_entry_value.
> 
>   * gcc.dg/guality/pr69947.c: New test.

Jakub


[PATCH 2/3] Add x86_64-*-rtems* target

2016-02-25 Thread Joel Sherrill
* gcc/config.gcc, libgcc/config.host: Add x86_64-*-rtems*.
* gcc/config/i386/rtems-64.h: New file.
---
 gcc/config.gcc |  3 +++
 gcc/config/i386/rtems-64.h | 30 ++
 libgcc/config.host |  2 +-
 3 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 gcc/config/i386/rtems-64.h

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 3b280e0..4cc6438 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1421,6 +1421,9 @@ i[34567]86-*-elf*)
 x86_64-*-elf*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h 
newlib-stdint.h i386/i386elf.h i386/x86-64.h"
;;
+x86_64-*-rtems*)
+   tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h 
newlib-stdint.h i386/i386elf.h i386/x86-64.h i386/rtems-64.h"
+   ;;
 i[34567]86-*-rdos*)
 tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h 
newlib-stdint.h i386/i386elf.h i386/rdos.h"
 ;;
diff --git a/gcc/config/i386/rtems-64.h b/gcc/config/i386/rtems-64.h
new file mode 100644
index 000..b087d44
--- /dev/null
+++ b/gcc/config/i386/rtems-64.h
@@ -0,0 +1,30 @@
+/* Definitions for rtems targeting an x86_64
+   Copyright (C) 2016 Free Software Foundation, Inc.
+   Contributed by Joel Sherrill (j...@oarcorp.com).
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+/* Specify predefined symbols in preprocessor.  */
+
+#define TARGET_OS_CPP_BUILTINS()   \
+  do   \
+{  \
+   builtin_define ("__rtems__");   \
+   builtin_define ("__USE_INIT_FINI__");   \
+   builtin_assert ("system=rtems");\
+}  \
+  while (0)
diff --git a/libgcc/config.host b/libgcc/config.host
index 1f85c46..b61a579 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -577,7 +577,7 @@ i[34567]86-*-elfiamcu)
 i[34567]86-*-elf*)
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
;;
-x86_64-*-elf*)
+x86_64-*-elf* | x86_64-*-rtems*)
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
;;
 i[34567]86-*-dragonfly*)
-- 
1.8.3.1



[PATCH 1/3] Add aarch64-*-rtems* target

2016-02-25 Thread Joel Sherrill
* gcc/config.gcc, libgcc/config.host: Add aarch64-*-rtems*.
* gcc/config/aarch64/rtems.h: New file.
---
 gcc/config.gcc | 11 +--
 gcc/config/aarch64/rtems.h | 28 
 libgcc/config.host |  2 +-
 3 files changed, 38 insertions(+), 3 deletions(-)
 create mode 100644 gcc/config/aarch64/rtems.h

diff --git a/gcc/config.gcc b/gcc/config.gcc
index e26742e..3b280e0 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -906,11 +906,18 @@ case ${target} in
 esac
 
 case ${target} in
-aarch64*-*-elf)
+aarch64*-*-elf | aarch64*-*-rtems*)
tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-elf-raw.h"
tmake_file="${tmake_file} aarch64/t-aarch64"
-   use_gcc_stdint=wrap
+   case $target in
+   aarch64-*-elf*)
+   use_gcc_stdint=wrap
+   ;;
+   aarch64-*-rtems*)
+   tm_file="${tm_file} rtems.h aarch64/rtems.h"
+   ;;
+   esac
case $target in
aarch64_be-*)
tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
diff --git a/gcc/config/aarch64/rtems.h b/gcc/config/aarch64/rtems.h
new file mode 100644
index 000..a166034
--- /dev/null
+++ b/gcc/config/aarch64/rtems.h
@@ -0,0 +1,28 @@
+/* Definitions for RTEMS based AARCH64 system.
+   Copyright (C) 2016 Free Software Foundation, Inc.
+ 
+   This file is part of GCC.
+ 
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+ 
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+ 
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   .  */
+
+#define HAS_INIT_SECTION
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS()   \
+do {   \
+   builtin_define ("__rtems__");   \
+   builtin_define ("__USE_INIT_FINI__");   \
+   builtin_assert ("system=rtems");\
+} while (0)
diff --git a/libgcc/config.host b/libgcc/config.host
index ef7dfd0..1f85c46 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -327,7 +327,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 esac
 
 case ${host} in
-aarch64*-*-elf)
+aarch64*-*-elf | aarch64*-*-rtems*)
extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o"
extra_parts="$extra_parts crtfastmath.o"
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
-- 
1.8.3.1



[PATCH 3/3] contrib/config-list.mk: Add aarch64-rtems and x86_64-rtems

2016-02-25 Thread Joel Sherrill
* contrib/config-list.mk: Add aarch64-rtems and x86_64-rtems
---
 contrib/config-list.mk | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/contrib/config-list.mk b/contrib/config-list.mk
index 0f15464..6a83a84 100644
--- a/contrib/config-list.mk
+++ b/contrib/config-list.mk
@@ -11,7 +11,7 @@ TEST=all-gcc
 # nohup nice make -j25 -l36 -f ../gcc/contrib/config-list.mk > make.out 2>&1 &
 #
 # v850e1-elf is rejected by config.sub
-LIST = aarch64-elf aarch64-linux-gnu \
+LIST = aarch64-elf aarch64-linux-gnu aarch64-rtems \
   alpha-linux-gnu alpha-freebsd6 alpha-netbsd alpha-openbsd \
   alpha64-dec-vms alpha-dec-vms am33_2.0-linux \
   arc-elf32OPT-with-cpu=arc600 arc-elf32OPT-with-cpu=arc700 \
@@ -76,7 +76,8 @@ LIST = aarch64-elf aarch64-linux-gnu \
   x86_64-pc-linux-gnuOPT-with-fpmath=avx \
   x86_64-elfOPT-with-fpmath=sse x86_64-freebsd6 x86_64-netbsd \
   x86_64-knetbsd-gnuOPT-enable-obsolete x86_64-w64-mingw32 \
-  x86_64-mingw32OPT-enable-sjlj-exceptions=yes xstormy16-elf xtensa-elf \
+  x86_64-mingw32OPT-enable-sjlj-exceptions=yes x86_64-rtems \
+  xstormy16-elf xtensa-elf \
   xtensa-linux \
   i686-interix3OPT-enable-obsolete
 
-- 
1.8.3.1



Re: [PATCH] libffi testsuite: Use split to ensure valid tcl list

2016-02-25 Thread Thomas Schwinge
Hi!

On Thu, 25 Feb 2016 11:45:06 -0800, Mike Stump  wrote:
> On Feb 25, 2016, at 11:10 AM, Thomas Schwinge  wrote:
> > +set lines [libffi_target_compile $src /dev/null assembly “"]
> 
> Does this work on a dos box, or windows or other random non-posix systems?

I don't know, and can't easily test.  However, I had seen the same
pattern be used elsewhere, for example:

$ git grep dev/null -- libstdc++-v3/testsuite/lib/
libstdc++-v3/testsuite/lib/libstdc++.exp:   set lines 
[v3_target_compile $src /dev/null executable ""]
[several more]

..., so assumed that to be OK.

Now that I'm reading [dejagnu]/target.exp:default_target_compile, I see
that for "[is_remote host]", it *always* passes "-o a.out" and then
"remote_upload host a.out $destfile", so "/dev/null" never escapes from
the system that DejaGnu/runtest is running on, which is always a POSIX
system as far as I know.

Otherwise, we could easily switch all these to a temporary output file,
which is then deleted right away...


Grüße
 Thomas


Re: [patch, libstdc++] In debug mode, diagnose empty initializer_list in min/max/minmax

2016-02-25 Thread Eelis van der Weegen

On 2016-02-23 23:39, Jonathan Wakely wrote:

On 23/02/16 22:03 +0100, Eelis wrote:

The std::min, std::max, and std::minmax overloads that take a 
std::initializer_list all require that the list is not empty. The attached 
patch adds debug mode checks for this.


Nice, thanks for the patch.


Hi Jonathan,

Thanks for the review! Updated patch attached.

I couldn't find precedent in the libstdc++ testsuite of tests that test 
__glibcxx_assert assertions, so I put these under {min,max,minmax}/assert/, 
analogous to {min,max,minmax}/debug/. Is that ok?


Otherwise this looks good, but will have to wait until after the GCC 6 release 
now.


No hurry at all. :)

Cheers,

Eelis
Index: libstdc++-v3/include/debug/formatter.h
===
--- libstdc++-v3/include/debug/formatter.h	(revision 233636)
+++ libstdc++-v3/include/debug/formatter.h	(working copy)
@@ -127,7 +127,8 @@
 // others
 __msg_equal_allocs,
 __msg_insert_range_from_self,
-__msg_irreflexive_ordering
+__msg_irreflexive_ordering,
+__msg_empty_init_list
   };
 
   class _Error_formatter
Index: libstdc++-v3/src/c++11/debug.cc
===
--- libstdc++-v3/src/c++11/debug.cc	(revision 233636)
+++ libstdc++-v3/src/c++11/debug.cc	(working copy)
@@ -188,7 +188,8 @@
 "allocators must be equal",
 "attempt to insert with an iterator range [%1.name;, %2.name;) from this"
 " container",
-"comparison doesn't meet irreflexive requirements, assert(!(a < a))"
+"comparison doesn't meet irreflexive requirements, assert(!(a < a))",
+"%1;(): empty initializer_list"
   };
 
   void
Index: libstdc++-v3/include/debug/macros.h
===
--- libstdc++-v3/include/debug/macros.h	(revision 233636)
+++ libstdc++-v3/include/debug/macros.h	(working copy)
@@ -69,6 +69,12 @@
 		  ._M_iterator(_First, #_First)			\
 		  ._M_iterator(_Last, #_Last))
 
+// Verify that the initializer_list is non-empty.
+#define __glibcxx_check_non_empty_init_list(_List)			\
+_GLIBCXX_DEBUG_VERIFY(_List.size() != 0,\
+		  _M_message(__gnu_debug::__msg_empty_init_list)	\
+		  ._M_string(__func__))
+
 /** Verify that we can insert into *this with the iterator _Position.
  *  Insertion into a container at a specific position requires that
  *  the iterator be nonsingular, either dereferenceable or past-the-end,
Index: libstdc++-v3/include/debug/debug.h
===
--- libstdc++-v3/include/debug/debug.h	(revision 233636)
+++ libstdc++-v3/include/debug/debug.h	(working copy)
@@ -87,9 +87,13 @@
 // Verify that the container is nonempty
 # define __glibcxx_requires_nonempty() \
   __glibcxx_assert(! this->empty())
+// Verify that the initializer_list is non-empty.
+# define __glibcxx_requires_non_empty_init_list(_List) \
+  __glibcxx_assert(_List.size() != 0)
 #else
 # define __glibcxx_requires_non_empty_range(_First,_Last)
 # define __glibcxx_requires_nonempty()
+# define __glibcxx_requires_non_empty_init_list(_List)
 #endif
 
 #else
@@ -99,6 +103,8 @@
 # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
 # define __glibcxx_requires_valid_range(_First,_Last)	\
   __glibcxx_check_valid_range(_First,_Last)
+# define __glibcxx_requires_non_empty_init_list(_List)	\
+  __glibcxx_check_non_empty_init_list(_List)
 # define __glibcxx_requires_non_empty_range(_First,_Last)	\
   __glibcxx_check_non_empty_range(_First,_Last)
 # define __glibcxx_requires_sorted(_First,_Last)	\
Index: libstdc++-v3/include/bits/stl_algo.h
===
--- libstdc++-v3/include/bits/stl_algo.h	(revision 233636)
+++ libstdc++-v3/include/bits/stl_algo.h	(working copy)
@@ -3452,25 +3452,37 @@
 _GLIBCXX14_CONSTEXPR
 inline _Tp
 min(initializer_list<_Tp> __l)
-{ return *std::min_element(__l.begin(), __l.end()); }
+{
+  __glibcxx_requires_non_empty_init_list(__l);
+  return *std::min_element(__l.begin(), __l.end());
+}
 
   template
 _GLIBCXX14_CONSTEXPR
 inline _Tp
 min(initializer_list<_Tp> __l, _Compare __comp)
-{ return *std::min_element(__l.begin(), __l.end(), __comp); }
+{
+  __glibcxx_requires_non_empty_init_list(__l);
+  return *std::min_element(__l.begin(), __l.end(), __comp);
+}
 
   template
 _GLIBCXX14_CONSTEXPR
 inline _Tp
 max(initializer_list<_Tp> __l)
-{ return *std::max_element(__l.begin(), __l.end()); }
+{
+  __glibcxx_requires_non_empty_init_list(__l);
+  return *std::max_element(__l.begin(), __l.end());
+}
 
   template
 _GLIBCXX14_CONSTEXPR
 inline _Tp
 max(initializer_list<_Tp> __l, _Compare __comp)
-{ return *std::max_element(__l.begin(), __l.end(), __comp); }
+{
+  __glibcxx_requires_non_empty_init_list(__l);
+  return 

Re: [PATCH] libffi testsuite: Use split to ensure valid tcl list

2016-02-25 Thread Mike Stump
On Feb 25, 2016, at 11:10 AM, Thomas Schwinge  wrote:
> +set lines [libffi_target_compile $src /dev/null assembly “"]

Does this work on a dos box, or windows or other random non-posix systems?


Re: [PATCH] libffi testsuite: Use split to ensure valid tcl list

2016-02-25 Thread Thomas Schwinge
Hi!

Already had noticed something odd here months ago; now finally looked
into it...

On Sat, 28 Mar 2015 13:59:30 -0400, John David Anglin  
wrote:
> The attached change fixes tcl errors that occur running the complex.exp and 
> go.exp test sets.
> See: .
> 
> Tested on hppa2.0w-hp-hpux11.11.  Okay for trunk?

(Got approved, and installed as r221765.)

> 2015-03-28  John David Anglin  
> 
>   PR libffi/65567
>   * testsuite/lib/libffi.exp (libffi_feature_test): Use split to ensure
>   lindex is applied to a list.
> 
> Index: testsuite/lib/libffi.exp
> ===
> --- testsuite/lib/libffi.exp  (revision 221591)
> +++ testsuite/lib/libffi.exp  (working copy)
> @@ -238,7 +239,7 @@
>  set lines [libffi_target_compile $src "" "preprocess" ""]
>  file delete $src
>  
> -set last [lindex $lines end]
> +set last [lindex [split $lines] end]
>  return [regexp -- "xyzzy" $last]
>  }

On my several systems, this has the effect that any user of
libffi_feature_test has their test results regress from PASS to
UNSUPPORTED.  Apparently the regexp xyzzy matching doesn't work as
intended.  If I revert your patch, it's OK for me -- but still not for
you, I suppose.  ;-)

How about the followinginstead?  It's conceptually simpler (and similar
to what other such tests are doing), works for me -- but can you also
please test this?

--- libffi/testsuite/lib/libffi.exp
+++ libffi/testsuite/lib/libffi.exp
@@ -227,20 +227,21 @@ proc libffi_target_compile { source dest type options } {
 
 # TEST should be a preprocessor condition.  Returns true if it holds.
 proc libffi_feature_test { test } {
-set src "ffitest.c"
+set src "ffitest[pid].c"
 
 set f [open $src "w"]
 puts $f "#include "
 puts $f $test
-puts $f "xyzzy"
+puts $f "/* OK */"
+puts $f "#else"
+puts $f "# error Failed $test"
 puts $f "#endif"
 close $f
 
-set lines [libffi_target_compile $src "" "preprocess" ""]
+set lines [libffi_target_compile $src /dev/null assembly ""]
 file delete $src
 
-set last [lindex [split $lines] end]
-return [regexp -- "xyzzy" $last]
+return [string match "" $lines]
 }
 
 # Utility routines.


Grüße
 Thomas


signature.asc
Description: PGP signature


Re: [PATCH] Do not gather mem stats in run_exit_handles (PR middle-end/69919)

2016-02-25 Thread David Malcolm
On Thu, 2016-02-25 at 12:07 +0100, Martin Liška wrote:
> Hello.
> 
> As discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69919#c3
> , following patch
> guards usage of memory statistics infrastructure after a
> mem_alloc_description is already
> destructed.
> 
> Patch can lto-bootstrap on x86_64-linux-gnu with --enable-gather
> -detailed-mem-stats and
> survives bootstrap with --enable-gather-detailed-mem-stats
> on x86_64-linux-gnu with.
> 
> Ready to be installed?
> Martin
> 
> gcc/ChangeLog:
> 
> 2016-02-25  Martin Liska  
> 
>   PR middle-end/69919
>   * alloc-pool.c (after_memory_report): New variable.
>   * alloc-pool.h (base_pool_allocator ::release): Do not use
>   the infrastructure if after_memory_report.
>   * toplev.c (toplev::main): Mark after memory report.
> ---
>  gcc/alloc-pool.c | 1 +
>  gcc/alloc-pool.h | 5 -
>  gcc/toplev.c | 3 +++
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c
> index ae5e232..43d06f6 100644
> --- a/gcc/alloc-pool.c
> +++ b/gcc/alloc-pool.c
> @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
>  
>  ALLOC_POOL_ID_TYPE last_id;
>  mem_alloc_description pool_allocator_usage;
> +bool after_memory_report = false;
>  
>  /* Output per-alloc_pool memory usage statistics.  */
>  void
> diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
> index 8ccf089..3ead101 100644
> --- a/gcc/alloc-pool.h
> +++ b/gcc/alloc-pool.h
> @@ -25,6 +25,9 @@ along with GCC; see the file COPYING3.  If not see
>  
>  extern void dump_alloc_pool_statistics (void);
>  
> +/* Flag indicates whether memory statistics are gathered any longer.
>   */
> +extern bool after_memory_report;
> +
>  typedef unsigned long ALLOC_POOL_ID_TYPE;
>  
>  /* Last used ID.  */
> @@ -306,7 +309,7 @@ base_pool_allocator ::release ()
>TBlockAllocator::release (block);
>  }
>  
> -  if (GATHER_STATISTICS)
> +  if (GATHER_STATISTICS && !after_memory_report)
>  {
>pool_allocator_usage.release_instance_overhead
>   (this, (m_elts_allocated - m_elts_free) * m_elt_size);
> diff --git a/gcc/toplev.c b/gcc/toplev.c
> index 28c115d..c480bfc 100644
> --- a/gcc/toplev.c
> +++ b/gcc/toplev.c
> @@ -2107,6 +2107,9 @@ toplev::main (int argc, char **argv)
>  
>finalize_plugins ();
>location_adhoc_data_fini (line_table);
> +
> +  after_memory_report = true;
> +
>if (seen_error () || werrorcount)
>  return (FATAL_EXIT_CODE);

Was this tested with "jit" in --enable-languages?   I ask because
toplev::main can be run repeatedly by libgccjit, and it looks like
nothing can reset after_memory_report.  (Though I don't typically build
with --enable-gather-detailed-mem-stats, and the jit docs don't mention
it).


Re: [PATCH] Add -funknown-commons to work around PR/69368 (and others) in SPEC2006

2016-02-25 Thread Alan Lawrence
On 22/02/16 12:03, Jakub Jelinek wrote:
> (f) A global command-line option, which we check alongside DECL_COMMON and
> further tests (basically, we want only DECL_COMMON decls that either have
> ARRAY_TYPE, or some other aggregate type with flexible array member or some
> other trailing array in the struct), and use the resulting predicate in
> places where we optimize based on DECL_SIZE{,_UNIT} of the decl - if that
> predicate returns true, we assume the DECL_SIZE is
> "variable"/"unlimited"/whatever.
> The two spots known to me that would need to use this new predicate would
> be:
> tree.c (array_at_struct_end_p):
[...]
> tree-dfa.c (get_ref_base_and_extent):
[...]

Close enough to what I meant by (a)/(b), but never mind that, and I hadn't
looked at where the change for aggressive loop opts needed to be. However...
Well you are essentially writing the patch for me at this point (so, thanks!),
 but here's a patch that puts that under a global -funknown-commons flag.
Testcase as before.

Bootstrapped (with flag overridden to true) on x86_64 and aarch64, check-gcc,
check-fortran, and tested 416.gamess on AArch64, where this patch enables
running *without* the -fno-aggressive-loop-opts previously required.

In the gcc testsuite, these fail with the option turned on:
gcc.dg/pr53265.c  (test for warnings, line 137)
gcc.dg/pr53265.c  (test for warnings, line 138)
gcc.dg/pr64277.c scan-tree-dump cunroll ... (*2)
gcc.dg/tree-ssa/cunroll-{1,2,3,4,9,10,11}.c scan-tree-dump 
cunroll/cunrolli/ivcanon (various)
gcc.dg/tree-ssa/loop-38.c scan-tree-dump cunrolli "Loop 1 iterates at most 11 
times"
...which all appear harmless.

Thomas Koenig suggests (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69368#c80)
that this be combined with some flag fiddling and warnings in the Fortran
front-end; this patch doesn't do that, as I'm not very familiar with the
frontends, but that can follow in a separate patch. (Thomas?)

OK for trunk?

Cheers, Alan

gcc/ChangeLog:

DATE  Alan Lawrence  
  Jakub Jelinek  

* common.opt (funknown-commons, flag_unknown_commons): New.
* tree.c (array_at_struct_end_p): Do not limit to size of decl for
DECL_COMMONS if flag_unknown_commons is set.
* tree-dfa.c (get_ref_base_and_extent): Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/unknown_commons.f: New.
---
 gcc/common.opt  |  4 
 gcc/testsuite/gfortran.dg/unknown_commons.f | 20 
 gcc/tree-dfa.c  | 15 ++-
 gcc/tree.c  |  6 --
 4 files changed, 42 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/unknown_commons.f

diff --git a/gcc/common.opt b/gcc/common.opt
index 520fa9c..b5b1282 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2455,6 +2455,10 @@ funit-at-a-time
 Common Report Var(flag_unit_at_a_time) Init(1)
 Compile whole compilation unit at a time.
 
+funknown-commons
+Common Var(flag_unknown_commons)
+Assume common declarations may be overridden with unknown larger sizes
+
 funroll-loops
 Common Report Var(flag_unroll_loops) Optimization
 Perform loop unrolling when iteration count is known.
diff --git a/gcc/testsuite/gfortran.dg/unknown_commons.f 
b/gcc/testsuite/gfortran.dg/unknown_commons.f
new file mode 100644
index 000..97e3ce3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/unknown_commons.f
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! { dg-options "-O3 -funknown-commons -fdump-tree-dom2-details" }
+
+! Test for PR69368: a single-element array in a common block, which will be
+! overridden with a larger size at link time (contrary to language spec).
+! Dominator opts considers accesses to differently-computed elements of X as
+! equivalent, unless -funknown-commons is passed in.
+  SUBROUTINE FOO
+  IMPLICIT DOUBLE PRECISION (X)
+  INTEGER J
+  COMMON /MYCOMMON / X(1)
+  DO 10 J=1,1024
+ X(J+1)=X(J+7)
+  10  CONTINUE
+  RETURN
+  END
+! { dg-final { scan-tree-dump-not "FIND" "dom2" } }
+! We should retain both a read and write of mycommon.x.
+! { dg-final { scan-tree-dump-times "  _\[0-9\]+ = 
mycommon\\.x\\\[_\[0-9\]+\\\];" 1 "dom2" } }
+! { dg-final { scan-tree-dump-times "  mycommon\\.x\\\[_\[0-9\]+\\\] = 
_\[0-9\]+;" 1 "dom2" } }
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index 0e98056..017e98e 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -612,9 +612,22 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
 
   if (DECL_P (exp))
 {
+  if (flag_unknown_commons
+ && TREE_CODE (exp) == VAR_DECL && DECL_COMMON (exp))
+   {
+ tree sz_tree = TYPE_SIZE (TREE_TYPE (exp));
+ /* If size is unknown, or we have read to the end, assume there
+may be more to the structure than we are told.  */
+ if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
+ || (seen_variable_array_ref
+ 

Re: [PATCH 1/4] Replace ENABLE_CHECKING macro with flag_checking in HSA

2016-02-25 Thread Martin Jambor
On Wed, Feb 24, 2016 at 02:59:11PM +0100, Martin Liska wrote:
> gcc/ChangeLog:
> 
> 2016-02-24  Martin Liska  
> 
>   * hsa-gen.c (generate_hsa): Replace ENABLE_CHECKING macro
>   with flag_checking.
>   * hsa-regalloc.c (linear_scan_regalloc): Likewise.


OK, thanks,

Martin


Re: [PATCH 3/9] S/390: Get rid of Y constraint in rotate patterns.

2016-02-25 Thread Ulrich Weigand
Andreas Krebbel wrote:

>   * config/s390/predicates.md (const_int_6bitset_operand): New
> predicates.
>   * config/s390/s390.md: Include subst.md.
>   ("rotl3"): New expander.
>   ("rotl3", "*rotl3_and"): Merge insn definitions into
>   ...
>   ("*rotl3"): New insn definition.
>   * config/s390/subst.md: New file.

This already looks much nicer (and shorter) :-)

In fact, I'm now wondering whether it couldn't be even shorter.  Would it
be possible to use instead of:

(define_insn "*rotl3"
  [(set (match_operand:GPR 0 "register_operand" "=d,d")
(rotate:GPR (match_operand:GPR 1 "register_operand"  "d,d")
(match_operand:SI  2 "nonmemory_operand" "a,n")))]
  "TARGET_CPU_ZARCH"
  "@
   rll\t%0,%1,(%2)
   rll\t%0,%1,%Y2"
  [(set_attr "op_type"  "RSE")
   (set_attr "atype""reg")
   (set_attr "enabled"  "*,")
   (set_attr "z10prop"  "z10_super_E1")])

simply something like:

(define_insn "*rotl3"
  [(set (match_operand:GPR 0 "register_operand" "=d")
(rotate:GPR (match_operand:GPR 1 "register_operand"  "d")
(match_operand:SI  2 "nonmemory_operand" "an")))]
  "TARGET_CPU_ZARCH"
  "rll\t%0,%1,
  [(set_attr "op_type"  "RSE")
   (set_attr "atype""reg")
   (set_attr "z10prop"  "z10_super_E1")])


where addr_style_op_ops is defined like:

(define_subst_attr "addr_style_op_ops" "addr_style_op_subst" "%Y2" "%Y3(%2)")

and we don't need addr_style_op_enabled any more?   %Y would continue
to emit both simple constants and register operands (and full address
operands e.g. for setmem) as before.


> +(define_subst "masked_op_subst"
> +  [(set (match_operand:DSI 0 ""   "")
> +(SUBST:DSI (match_operand:DSI 1 "" "")
> +(match_operand:SI  2 "" "")))]
> +  ""
> +  [(set (match_dup 0)
> +(SUBST:DSI (match_dup 1)
> +(and:SI (match_dup 2)
> +(match_operand:SI 3 "const_int_6bitset_operand" 
> ""])

Do we need a constraint letter here?

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  ulrich.weig...@de.ibm.com



[PATCH] Fix DW_OP_GNU_implicit_pointer referring to DW_TAG_dwarf_procedure (PR debug/69947)

2016-02-25 Thread Jakub Jelinek
On Thu, Feb 25, 2016 at 04:53:58PM +0100, Pierre-Marie de Rodat wrote:
> I introduced a DW_OP_call* traversal for this:
> 
>   * prune_unused_types_mark traverses attributes using
> prune_unused_types_walk_attribs;
> 
>   * …_walk_attribs walks location descriptions and location lists using
> …_walk_loc_descr
> 
>   * …_walk_loc_descr marks DWARF procedures referenced by DW_OP_call*
> operations.

Ah, I've been looking for something that would set die_perennial_p, but
actually you just set die_mark later on instead for those.
So IMHO the right fix is just handle all the ops that could directly or
indirectly contain references to other DIEs, rather than just handling
the 3 you have there.

Going to bootstrap/regtest this on x86_64-linux and i686-linux now.

Is this ok for trunk if it passes testing?

2016-02-25  Jakub Jelinek  

PR debug/69947
* dwarf2out.c (prune_unused_types_walk_loc_descr): Handle
all other ops that have dw_val_class_die_ref operands,
and DW_OP_GNU_entry_value.

* gcc.dg/guality/pr69947.c: New test.

--- gcc/dwarf2out.c.jj  2016-02-25 17:04:11.465781368 +0100
+++ gcc/dwarf2out.c 2016-02-25 17:41:26.785371399 +0100
@@ -25641,11 +25641,29 @@ prune_unused_types_walk_loc_descr (dw_lo
   for (; loc != NULL; loc = loc->dw_loc_next)
 switch (loc->dw_loc_opc)
   {
+  case DW_OP_GNU_implicit_pointer:
+  case DW_OP_GNU_convert:
+  case DW_OP_GNU_reinterpret:
+   if (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref)
+ prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, 1);
+   break;
   case DW_OP_call2:
   case DW_OP_call4:
   case DW_OP_call_ref:
+  case DW_OP_GNU_const_type:
+  case DW_OP_GNU_parameter_ref:
+   gcc_assert (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref);
prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, 1);
break;
+  case DW_OP_GNU_regval_type:
+  case DW_OP_GNU_deref_type:
+   gcc_assert (loc->dw_loc_oprnd2.val_class == dw_val_class_die_ref);
+   prune_unused_types_mark (loc->dw_loc_oprnd2.v.val_die_ref.die, 1);
+   break;
+  case DW_OP_GNU_entry_value:
+   gcc_assert (loc->dw_loc_oprnd1.val_class == dw_val_class_loc);
+   prune_unused_types_walk_loc_descr (loc->dw_loc_oprnd1.v.val_loc);
+   break;
   default:
break;
   }
--- gcc/testsuite/gcc.dg/guality/pr69947.c.jj   2016-02-25 17:22:13.729098931 
+0100
+++ gcc/testsuite/gcc.dg/guality/pr69947.c  2016-02-25 17:22:13.729098931 
+0100
@@ -0,0 +1,22 @@
+/* PR debug/69947 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+#include "../nop.h"
+
+static const char *c = "foobar";
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+  static const char a[] = "abcdefg";
+  const char *b = a;   /* { dg-final { gdb-test 14 "c\[2\]" "'o'" } } 
*/
+  asm (NOP : : : "memory");/* { dg-final { gdb-test 14 "b\[4\]" "'e'" } } 
*/
+}
+
+int
+main ()
+{
+  foo ();
+  return 0;
+}


Jakub


Re: [PATCH] [RFA] [PR tree-optmization/69740] Schedule loop fixups when needed

2016-02-25 Thread Jeff Law

On 02/25/2016 03:00 AM, Richard Biener wrote:


+  /* Look at BB's successors, if any are marked as BB_IRREDUCIBLE_LOOP,
then
+ removing BB (and its outgoing edges) may make the loop a natural
+ loop.  In which case we need to schedule loop fixups.  */
+  if (current_loops)
+for (edge_iterator ei = ei_start (bb->succs); !ei_end_p (ei); ei_next
())
+  if (ei_edge (ei)->dest->flags & BB_IRREDUCIBLE_LOOP)
+   loops_state_set (LOOPS_NEED_FIXUP);


So I fail to see how only successor edges are relevant.  Isn't the important
case to catch whether we remove an edge marked EDGE_IRREDUCIBLE_LOOP?
Even if the BB persists we might have exposed a new loop here.

Yea, let me give that a spin.



Note that it is not safe to look at {BB,EDGE}_IRREDUCIBLE_LOOP if the loop
state does not have LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS set
(the flags may be stale or missing).  So it might be that we can't rely on
non-loop passes modifying the CFG to handle this optimistically.
I was concerned about this as well.   The problem case would be if we 
have an irreducible loop with nodes not marked.  In that case we could 
fail to ask for loop fixups leading to failure again.  The other cases 
shouldn't cause failures, but can cause us to spend time fixing up loops 
which perhaps we didn't need to.


Anyway, I'll have a closer look at that too.



Jeff




Re: [PATCHES, PING*5] Enhance standard DWARF for Ada

2016-02-25 Thread Pierre-Marie de Rodat

On 02/25/2016 04:51 PM, Jakub Jelinek wrote:

Do you have some short Ada testcase where the DW_OP_call4 referring to
DW_TAG_dwarf_procedure is supposed to be emitted?  I believe you must be
getting there the .Ldebug_info0+0 invalid reference in the DW_OP_call4
operand.


Sure! Here’s one:

$ gcc -S -g -fgnat-encodings=minimal -dA foo.adb && grep DW_OP_call4 foo.s
foo.s:313:  .byte   0x99# DW_OP_call4


--
Pierre-Marie de Rodat
procedure Foo is

   type Record_Type (N : Natural) is record
  S1 : String (1 .. N);
  S2 : String (1 .. N);
   end record;

   procedure Process (R : Record_Type) is
   begin
  null;
   end Process;

   R : Record_Type (4) := (4, "abcd", "efgh");

begin
   Process (R);
end Foo;


Re: [PATCHES, PING*5] Enhance standard DWARF for Ada

2016-02-25 Thread Pierre-Marie de Rodat

On 02/25/2016 10:48 AM, Jakub Jelinek wrote:

The first one just fixes what I mainly care about, the committed patch
assumed that DW_TAG_dwarf_procedure is always only created for the Ada
variable sized structures or whatever it was meant for, which is not the
case, and thus if we emit DW_TAG_dwarf_procedure for some other reason,
it would be pruned as unused even when it is actually used (and result in
a DIE reference to the compilation unit header, which is always invalid).


This first patch looks good to me, as a good enough and simple fix.


But, looking at the points where you use DW_TAG_dwarf_procedure for the Ada
things, I can't see how it can actually work at all, though there is no
testsuite coverage, so it is hard to find out for real.
The thing is, current code sets die_perennial_p on type DIEs and their
parents, but nothing else.  In particular, type DIEs are identified by
being returned from lookup_type_die, thus earlier passed to
equate_type_number_to_die.  I don't see that this would ever be the case
of DW_TAG_dwarf_procedure though, I see the return of
function_to_dwarf_procedure being used as dw_loc_oprnd1.v.val_die_ref.die
of a DW_OP_call4 that is somewhere used in some location description that is
perhaps used somewhere in some type DIE computation.


I introduced a DW_OP_call* traversal for this:

  * prune_unused_types_mark traverses attributes using
prune_unused_types_walk_attribs;

  * …_walk_attribs walks location descriptions and location lists using
…_walk_loc_descr

  * …_walk_loc_descr marks DWARF procedures referenced by DW_OP_call*
operations.

So all DWARF procedures referenced this way are not supposed to be 
pruned (I checked: no problem for the Ada types I tested). As you 
noticed, I did not realize that there were other DWARF procedure 
producers, hence the assumption that this was enought to mark all DWARF 
procs.



So IMHO the second patch
makes more sense, and if you (for GCC 7?) want to prune really unused
DW_TAG_dwarf_procedure, you need to add code that will really walk all of
the debuginfo, rather than just type DIEs themselves, and look if location
descriptions (in .debug_info or .debug_loc) reference those
DW_TAG_dwarf_procedure and mark the DW_TAG_dwarf_procedure.


I just had a look: the prune_unused_type_mark pass already reaches the 
DW_OP_GNU_implicit_pointer operation, it’s just that 
prune_unused_types_walk_loc_descr does not know about this kind of 
operation. I think the attached patch is a more general fix for that. 
What do you think?


(bootstrapped and regtested on x86_64-linux)

--
Pierre-Marie de Rodat
>From 671199e8a7da326e54e081b5c368f93428455e98 Mon Sep 17 00:00:00 2001
From: Pierre-Marie de Rodat 
Date: Thu, 25 Feb 2016 11:37:22 +0100
Subject: [PATCH] DWARF: fix debug info for implicit pointers to string
 constants

2016-02-25  Pierre-Marie de Rodat  

PR debug/69947
* dwarf2out.c (prune_unused_types_walk_loc_descr): Recurse on
  all dw_val_class_die_ref operands, not just the ones for
  DW_OP_call* operations.

2016-02-25  Jakub Jelinek  

PR debug/69947
* gcc.dg/guality/pr69947.c: New test.
---
 gcc/dwarf2out.c| 16 +++-
 gcc/testsuite/gcc.dg/guality/pr69947.c | 22 ++
 2 files changed, 29 insertions(+), 9 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/guality/pr69947.c

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 97e192b..37ccd3a 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -25639,16 +25639,14 @@ static void
 prune_unused_types_walk_loc_descr (dw_loc_descr_ref loc)
 {
   for (; loc != NULL; loc = loc->dw_loc_next)
-switch (loc->dw_loc_opc)
-  {
-  case DW_OP_call2:
-  case DW_OP_call4:
-  case DW_OP_call_ref:
+{
+  if (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref
+	  && !loc->dw_loc_oprnd1.v.val_die_ref.external)
 	prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, 1);
-	break;
-  default:
-	break;
-  }
+  if (loc->dw_loc_oprnd2.val_class == dw_val_class_die_ref
+	  && !loc->dw_loc_oprnd2.v.val_die_ref.external)
+	prune_unused_types_mark (loc->dw_loc_oprnd2.v.val_die_ref.die, 1);
+}
 }
 
 /* Given DIE that we're marking as used, find any other dies
diff --git a/gcc/testsuite/gcc.dg/guality/pr69947.c b/gcc/testsuite/gcc.dg/guality/pr69947.c
new file mode 100644
index 000..6280ed5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/guality/pr69947.c
@@ -0,0 +1,22 @@
+/* PR debug/69947 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+#include "../nop.h"
+
+static const char *c = "foobar";
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+  static const char a[] = "abcdefg";
+  const char *b = a;		/* { dg-final { gdb-test 14 "c\[2\]" "'o'" } } */
+  asm (NOP : : : "memory");	/* { dg-final { gdb-test 14 "b\[4\]" "'e'" } } */
+}
+
+int
+main ()
+{
+  foo ();
+  return 0;
+}
-- 

Re: [PATCH] powerpc: Handle DImode rotatert implemented with rlwinm (PR69946)

2016-02-25 Thread David Edelsohn
On Wed, Feb 24, 2016 at 5:57 PM, Segher Boessenkool
 wrote:
> Some DImode rotate-right-and-mask can be implemented best with a rlwinm
> instruction: those that could be a lshiftrt instead of a rotatert, while
> the mask is not right-aligned.  Why the rotate in the testcase is not
> optimised to a plain shift is another question, but we need to handle
> it here anyway.  We compute the shift amount for a 64-bit rotate.  This
> is 32 too high in this case; if we print using %h that is masked out (and
> this doesn't silently let through invalid instructions, everything is
> checked by rs6000_is_valid_shift_mask which is much more thorough).
>
> Built and tested on powerpc64-linux, -m32,-m64 and -mlra,-mno-lra.  Also
> tested the new test on powerpc64le-linux (where the test is skipped).
> Is this okay for trunk?
>
>
> Segher
>
>
> 2016-02-24  Segher Boessenkool  
>
> PR target/69946
> * config/rs6000/rs6000.c (rs6000_insn_for_shift_mask): Print rlwinm
> shift amount using %h.
>
> gcc/testsuite/
> * pr69946.c: New file.

Okay.

Please add a short comment explaining why rs6000_insn_for_shift_mask
doesn't need to match the logic in rs6000_is_valid_shift_mask
converting rotates to simple shifts.

Thanks, David


Re: [PATCHES, PING*5] Enhance standard DWARF for Ada

2016-02-25 Thread Jakub Jelinek
On Thu, Feb 25, 2016 at 11:35:07AM +0100, Pierre-Marie de Rodat wrote:
> On 02/25/2016 10:48 AM, Jakub Jelinek wrote:
> >Unfortunately, this broke the DW_OP_GNU_implicit_pointer support, on vast
> >majority of binaries and libraries gcc now emits invalid DWARF (which both
> >gdb and dwz complain about and dwz refuses to optimize because of that).
> 
> Arg, sorry about this!
> 
> >I'm attaching two possible patches, so far untested.
> 
> Thanks, I’m having a look as we speak.
> 
> >So, Pierre-Marie, can I ask you to run whatever Ada debug info testsuite
> >you have with the second patch?  And for GCC 7 really please consider adding
> >gnat.dg/guality/ and fill it with tests.
> 
> Testing in progress…
> 
> I have a tiny Python/pyelftools-based testsuite that checks the DIE patterns
> GCC emits for several Ada types. I really wish I could somehow integrate
> them to the GCC testsuite, but right now I don’t know how I could do similar
> things, there.

Do you have some short Ada testcase where the DW_OP_call4 referring to
DW_TAG_dwarf_procedure is supposed to be emitted?  I believe you must be
getting there the .Ldebug_info0+0 invalid reference in the DW_OP_call4
operand.

Jakub


[PATCH 1/4] Replace ENABLE_CHECKING macro with flag_checking in HSA

2016-02-25 Thread marxin
gcc/ChangeLog:

2016-02-24  Martin Liska  

* hsa-gen.c (generate_hsa): Replace ENABLE_CHECKING macro
with flag_checking.
* hsa-regalloc.c (linear_scan_regalloc): Likewise.
---
 gcc/hsa-gen.c  | 25 +
 gcc/hsa-regalloc.c |  7 +++
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
index 28e8b6f..8e2144c 100644
--- a/gcc/hsa-gen.c
+++ b/gcc/hsa-gen.c
@@ -6091,21 +6091,22 @@ generate_hsa (bool kernel)
 s->m_gridified_kernel_p);
 }
 
-#ifdef ENABLE_CHECKING
-  for (unsigned i = 0; i < hsa_cfun->m_ssa_map.length (); i++)
-if (hsa_cfun->m_ssa_map[i])
-  hsa_cfun->m_ssa_map[i]->verify_ssa ();
-
-  basic_block bb;
-  FOR_EACH_BB_FN (bb, cfun)
+  if (flag_checking)
 {
-  hsa_bb *hbb = hsa_bb_for_bb (bb);
+  for (unsigned i = 0; i < hsa_cfun->m_ssa_map.length (); i++)
+   if (hsa_cfun->m_ssa_map[i])
+ hsa_cfun->m_ssa_map[i]->verify_ssa ();
 
-  for (hsa_insn_basic *insn = hbb->m_first_insn; insn; insn = insn->m_next)
-   insn->verify ();
-}
+  basic_block bb;
+  FOR_EACH_BB_FN (bb, cfun)
+   {
+ hsa_bb *hbb = hsa_bb_for_bb (bb);
 
-#endif
+ for (hsa_insn_basic *insn = hbb->m_first_insn; insn;
+  insn = insn->m_next)
+   insn->verify ();
+   }
+}
 
   hsa_regalloc ();
   hsa_brig_emit_function ();
diff --git a/gcc/hsa-regalloc.c b/gcc/hsa-regalloc.c
index f8e83ecf..9437132 100644
--- a/gcc/hsa-regalloc.c
+++ b/gcc/hsa-regalloc.c
@@ -580,10 +580,9 @@ linear_scan_regalloc (struct m_reg_class_desc *classes)
   /* Sort all intervals by increasing start point.  */
   gcc_assert (ind2reg.length () == (size_t) hsa_cfun->m_reg_count);
 
-#ifdef ENABLE_CHECKING
-  for (unsigned i = 0; i < ind2reg.length (); i++)
-gcc_assert (ind2reg[i]);
-#endif
+  if (flag_checking)
+for (unsigned i = 0; i < ind2reg.length (); i++)
+  gcc_assert (ind2reg[i]);
 
   ind2reg.qsort (cmp_begin);
   for (i = 0; i < 4; i++)
-- 
2.7.0




[PATCH 0/4] Replace remaining ENABLE_CHECKING macros

2016-02-25 Thread marxin
Hello

Following series removes remaining usage of ENABLE_CHECKING macro, where
the last patch eventually poisons the macro.

The series has been tested in common and survives regbootstrap on
x86_64-linux-gnu with default options (and Ada enabled)
and --enable-checking=none.

Ready for trunk?
Martin

marxin (4):
  Replace ENABLE_CHECKING macro with flag_checking in HSA
  Replace ENABLE_CHECKING macro with flag_checking in GNAT
  Replace ENABLE_CHECKING with CHECKING_P in dwarf2out
  Poison ENABLE_CHECKING macro

 gcc/ada/gcc-interface/utils.c | 12 +++-
 gcc/dwarf2out.c   |  6 +++---
 gcc/dwarf2out.h   |  2 +-
 gcc/hsa-gen.c | 25 +
 gcc/hsa-regalloc.c|  7 +++
 gcc/system.h  |  4 
 6 files changed, 31 insertions(+), 25 deletions(-)

-- 
2.7.0



[PATCH 3/4] Replace ENABLE_CHECKING with CHECKING_P in dwarf2out

2016-02-25 Thread marxin
gcc/ChangeLog:

2016-02-25  Martin Liska  

* dwarf2out.c (new_loc_descr): Replace ENABLE_CHECKING with
CHECKING_P.
(resolve_args_picking_1): Likewise.
* dwarf2out.h (struct GTY): Likewise.
---
 gcc/dwarf2out.c | 6 +++---
 gcc/dwarf2out.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 97e192b..a8c21d8 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -1325,7 +1325,7 @@ new_loc_descr (enum dwarf_location_atom op, unsigned 
HOST_WIDE_INT oprnd1,
   dw_loc_descr_ref descr = ggc_cleared_alloc ();
 
   descr->dw_loc_opc = op;
-#if ENABLE_CHECKING
+#if CHECKING_P
   descr->dw_loc_frame_offset = -1;
 #endif
   descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
@@ -15369,14 +15369,14 @@ resolve_args_picking_1 (dw_loc_descr_ref loc, 
unsigned initial_frame_offset,
   /* If we already met this node, there is nothing to compute anymore.  */
   if (visited.add (l))
{
-#if ENABLE_CHECKING
+#if CHECKING_P
  /* Make sure that the stack size is consistent wherever the execution
 flow comes from.  */
  gcc_assert ((unsigned) l->dw_loc_frame_offset == frame_offset_);
 #endif
  break;
}
-#if ENABLE_CHECKING
+#if CHECKING_P
   l->dw_loc_frame_offset = frame_offset_;
 #endif
 
diff --git a/gcc/dwarf2out.h b/gcc/dwarf2out.h
index a96ac38..91b3d6b 100644
--- a/gcc/dwarf2out.h
+++ b/gcc/dwarf2out.h
@@ -239,7 +239,7 @@ struct GTY((chain_next ("%h.dw_loc_next"))) 
dw_loc_descr_node {
  frame offset.  */
   unsigned int frame_offset_rel : 1;
   int dw_loc_addr;
-#if ENABLE_CHECKING
+#if CHECKING_P
   /* When translating a function into a DWARF procedure, contains the frame
  offset *before* evaluating this operation.  It is -1 when not yet
  initialized.  */
-- 
2.7.0




[PATCH 4/4] Poison ENABLE_CHECKING macro

2016-02-25 Thread marxin
gcc/ChangeLog:

2016-02-25  Martin Liska  

* system.h: Poison ENABLE_CHECKING macro.
---
 gcc/system.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/system.h b/gcc/system.h
index 445073c..cb54541 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1014,6 +1014,10 @@ extern void fancy_abort (const char *, int, const char 
*) ATTRIBUTE_NORETURN;
 #undef rindex
  #pragma GCC poison bcopy bzero bcmp rindex
 
+/* Poison ENABLE_CHECKING macro that should be replaced with
+   'if (flag_checking)', or with CHECKING_P macro.  */
+#pragma GCC poison ENABLE_CHECKING
+
 #endif /* GCC >= 3.0 */
 
 /* This macro allows casting away const-ness to pass -Wcast-qual
-- 
2.7.0



[PATCH 2/4] Replace ENABLE_CHECKING macro with flag_checking in GNAT

2016-02-25 Thread marxin
gcc/ada/ChangeLog:

2016-02-24  Martin Liska  

* gcc-interface/utils.c (set_reverse_storage_order_on_pad_type):
Replace ENABLE_CHECKING macro with flag_checking.
---
 gcc/ada/gcc-interface/utils.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index ff21e7b..4f81f1d 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -1486,11 +1486,13 @@ set_reverse_storage_order_on_pad_type (tree type)
 {
   tree field, canonical_pad_type;
 
-#ifdef ENABLE_CHECKING
-  /* If the inner type is not scalar then the function does nothing.  */
-  tree inner_type = TREE_TYPE (TYPE_FIELDS (type));
-  gcc_assert (!AGGREGATE_TYPE_P (inner_type) && !VECTOR_TYPE_P (inner_type));
-#endif
+  if (flag_checking)
+{
+  /* If the inner type is not scalar then the function does nothing.  */
+  tree inner_type = TREE_TYPE (TYPE_FIELDS (type));
+  gcc_assert (!AGGREGATE_TYPE_P (inner_type)
+ && !VECTOR_TYPE_P (inner_type));
+}
 
   /* This is required for the canonicalization.  */
   gcc_assert (TREE_CONSTANT (TYPE_SIZE (type)));
-- 
2.7.0




Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)

2016-02-25 Thread Jakub Jelinek
On Sat, Feb 20, 2016 at 06:38:05AM +, Bernd Edlinger wrote:
> Hi,
> 
> as almost expected r233572 needs to be back-ported to gcc-5 and gcc-4.9
> branches in order to be built by gcc-6.  It applies cleanly to both
> branches.  But unfortunately PR 69881 prevents boot-strapping gcc-4.9
> in the moment.
> 
> Boot-strap and regression-test of gcc-5 on x86_64-pc-linux-gnu.
> OK for gcc-5 and gcc-4.9 when PR 69881 is resolved?

Ok for 5/4.9.

> 2016-02-20  Bernd Edlinger  
> 
>   Backported from mainline
>   2016-02-19  Jakub Jelinek  
>   Bernd Edlinger  
> 
>   * Make-lang.in: Invoke gperf with -L C++.
>   * cfns.gperf: Remove prototypes for hash and libc_name_p
>   inlines.
>   * cfns.h: Regenerated.
>   * except.c (nothrow_libfn_p): Adjust.

Jakub


Re: C++ PATCH for c++/69842 (wrong error with generic lambda)

2016-02-25 Thread Jason Merrill

On 02/17/2016 03:44 PM, Jason Merrill wrote:

The problem here was that the call from the stub returned by the
conversion function to the op() was changing an xvalue to an lvalue,
leading to a parameter of the wrong type in the op().


...and now, handling variadic templates as well.

Tested x86_64-pc-linux-gnu, applying to trunk.


commit 7788d30617c68e660a73288a0c8adbe7d2d0a714
Author: Jason Merrill 
Date:   Thu Feb 25 09:56:42 2016 -0500

	PR c++/69842
	* method.c (forward_parm): Handle parameter packs.
	* lambda.c (maybe_add_lambda_conv_op): Use it for them.

diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 296c6f7..cdc11fe 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cgraph.h"
 #include "tree-iterator.h"
 #include "toplev.h"
+#include "gimplify.h"
 
 /* Constructor for a lambda expression.  */
 
@@ -952,23 +953,18 @@ maybe_add_lambda_conv_op (tree type)
 
 	if (generic_lambda_p)
 	  {
-	if (DECL_PACK_P (tgt))
-	  {
-		tree a = make_pack_expansion (tgt);
-		if (decltype_call)
-		  CALL_EXPR_ARG (decltype_call, ix) = copy_node (a);
-		PACK_EXPANSION_LOCAL_P (a) = true;
-		CALL_EXPR_ARG (call, ix) = a;
-	  }
-	else
-	  {
-		++processing_template_decl;
-		tree a = forward_parm (tgt);
-		--processing_template_decl;
-		CALL_EXPR_ARG (call, ix) = a;
-		if (decltype_call)
-		  CALL_EXPR_ARG (decltype_call, ix) = copy_node (a);
-	  }
+	++processing_template_decl;
+	tree a = forward_parm (tgt);
+	--processing_template_decl;
+
+	CALL_EXPR_ARG (call, ix) = a;
+	if (decltype_call)
+	  CALL_EXPR_ARG (decltype_call, ix) = unshare_expr (a);
+
+	if (PACK_EXPANSION_P (a))
+	  /* Set this after unsharing so it's not in decltype_call.  */
+	  PACK_EXPANSION_LOCAL_P (a) = true;
+
 	++ix;
 	  }
 	else
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index f455b32..0235e6a 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -481,9 +481,12 @@ tree
 forward_parm (tree parm)
 {
   tree exp = convert_from_reference (parm);
-  if (TREE_CODE (TREE_TYPE (parm)) != REFERENCE_TYPE
-  || TYPE_REF_IS_RVALUE (TREE_TYPE (parm)))
-exp = move (exp);
+  tree type = TREE_TYPE (parm);
+  if (DECL_PACK_P (parm))
+type = PACK_EXPANSION_PATTERN (type);
+  exp = build_static_cast (type, exp, tf_warning_or_error);
+  if (DECL_PACK_P (parm))
+exp = make_pack_expansion (exp);
   return exp;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic4.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic4.C
new file mode 100644
index 000..0b65f56
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic4.C
@@ -0,0 +1,20 @@
+// PR c++/69842
+// { dg-do compile { target c++14 } }
+
+template  struct assert_same;
+template  struct assert_same {};
+
+template
+void sink(T &&)
+{
+  assert_same a;
+}
+
+int main()
+{
+  auto const g([](auto &&...  _var) {
+  sink(static_cast(_var)...);
+});
+
+  g(0);
+}


Re: [WWWDocs] Deprecate support for non-thumb ARM devices

2016-02-25 Thread Stefan Ring
On Thu, Feb 25, 2016 at 3:15 PM, David Brown  wrote:
> 

Great link, thanks!


Re: [Fortran, Patch] (Coarrays) Wrong events size

2016-02-25 Thread Alessandro Fanfarillo
* PING *

2016-02-20 18:25 GMT+01:00 Alessandro Fanfarillo :
> Dear all,
>
> currently, the compiler doesn't pass the right size to the
> registration routine of OpenCoarrays for event variables:
>
> size.15 = 0;
>
> ev.data = (void * restrict) _gfortran_caf_register (MAX_EXPR  1>, 6, , 0B, 0B, 0);
>
> The attached patch solves the problem.
>
> I don't understand the following block in trans-types.c:
>
>   if (flag_coarray != GFC_FCOARRAY_LIB
>   && derived->from_intmod == INTMOD_ISO_FORTRAN_ENV
>   && derived->intmod_sym_id == ISOFORTRAN_EVENT_TYPE)
> return gfc_get_int_type (gfc_default_integer_kind);
>
> Why should an event variable be different from a lock variable when
> LIBCAF_SINGLE is used?
>
> The patch has been built and regtested on x86_64-pc-linux-gnu.
>
> Ok for trunk and gcc-5-branch?


Re: [WWWDocs] Deprecate support for non-thumb ARM devices

2016-02-25 Thread Stefan Ring
On Thu, Feb 25, 2016 at 3:15 PM, David Brown  wrote:
> The "t" is thumb, "e" means "DSP-like extensions", and I suspect the "l"
> is a misprint for "j", meaning the Jazelle (Java) acceleration instructions.

I doubt that as "armv5tejl" is also quite common.


Re: [PATCH] Do not gather mem stats in run_exit_handles (PR middle-end/69919)

2016-02-25 Thread Richard Biener
On Thu, Feb 25, 2016 at 12:07 PM, Martin Liška  wrote:
> Hello.
>
> As discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69919#c3, 
> following patch
> guards usage of memory statistics infrastructure after a 
> mem_alloc_description is already
> destructed.
>
> Patch can lto-bootstrap on x86_64-linux-gnu with 
> --enable-gather-detailed-mem-stats and
> survives bootstrap with --enable-gather-detailed-mem-stats on 
> x86_64-linux-gnu with.
>
> Ready to be installed?

Ok.

Richard.

> Martin
>
> gcc/ChangeLog:
>
> 2016-02-25  Martin Liska  
>
> PR middle-end/69919
> * alloc-pool.c (after_memory_report): New variable.
> * alloc-pool.h (base_pool_allocator ::release): Do not use
> the infrastructure if after_memory_report.
> * toplev.c (toplev::main): Mark after memory report.
> ---
>  gcc/alloc-pool.c | 1 +
>  gcc/alloc-pool.h | 5 -
>  gcc/toplev.c | 3 +++
>  3 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c
> index ae5e232..43d06f6 100644
> --- a/gcc/alloc-pool.c
> +++ b/gcc/alloc-pool.c
> @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
>
>  ALLOC_POOL_ID_TYPE last_id;
>  mem_alloc_description pool_allocator_usage;
> +bool after_memory_report = false;
>
>  /* Output per-alloc_pool memory usage statistics.  */
>  void
> diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
> index 8ccf089..3ead101 100644
> --- a/gcc/alloc-pool.h
> +++ b/gcc/alloc-pool.h
> @@ -25,6 +25,9 @@ along with GCC; see the file COPYING3.  If not see
>
>  extern void dump_alloc_pool_statistics (void);
>
> +/* Flag indicates whether memory statistics are gathered any longer.  */
> +extern bool after_memory_report;
> +
>  typedef unsigned long ALLOC_POOL_ID_TYPE;
>
>  /* Last used ID.  */
> @@ -306,7 +309,7 @@ base_pool_allocator ::release ()
>TBlockAllocator::release (block);
>  }
>
> -  if (GATHER_STATISTICS)
> +  if (GATHER_STATISTICS && !after_memory_report)
>  {
>pool_allocator_usage.release_instance_overhead
> (this, (m_elts_allocated - m_elts_free) * m_elt_size);
> diff --git a/gcc/toplev.c b/gcc/toplev.c
> index 28c115d..c480bfc 100644
> --- a/gcc/toplev.c
> +++ b/gcc/toplev.c
> @@ -2107,6 +2107,9 @@ toplev::main (int argc, char **argv)
>
>finalize_plugins ();
>location_adhoc_data_fini (line_table);
> +
> +  after_memory_report = true;
> +
>if (seen_error () || werrorcount)
>  return (FATAL_EXIT_CODE);
>
> --
> 2.7.0
>


Re: [WWWDocs] Deprecate support for non-thumb ARM devices

2016-02-25 Thread Richard Earnshaw (lists)
On 25/02/16 14:15, David Brown wrote:
> On 25/02/16 14:32, Stefan Ring wrote:
>> On Thu, Feb 25, 2016 at 10:20 AM, Richard Earnshaw (lists)
>>  wrote:
>>> The point is to permit the compiler to use interworking compatible
>>> sequences of code when generating ARM code, not to force users to use
>>> Thumb code.  The necessary instruction (BX) is available in armv5 and
>>> armv5e, even though Thumb is not supported in those architecture variants.
>>>
>>> It might be worth deprecating v5 and v5e at some point in the future: to
>>> the best of my knowledge no v5 class device without Thumb has ever
>>> existed - but it's not a decision that needs to be related to this proposal.
>>
>> Slightly off topic, but related: What does the "e" stand for? Also,
>> what does "l" stand for in armv5tel, which is what I usually get --
>> little endian?
> 
> 
> 
> 
> 
> The "t" is thumb, 
Correct.

"e" means "DSP-like extensions",
Correct.  But there were other bits as well.

 and I suspect the "l"
> is a misprint for "j", meaning the Jazelle (Java) acceleration instructions.

No.  As I said earlier, it's nothing to do with the architecture, but
means the system is running little-endian.

R.



Re: [WWWDocs] Deprecate support for non-thumb ARM devices

2016-02-25 Thread David Brown
On 25/02/16 14:32, Stefan Ring wrote:
> On Thu, Feb 25, 2016 at 10:20 AM, Richard Earnshaw (lists)
>  wrote:
>> The point is to permit the compiler to use interworking compatible
>> sequences of code when generating ARM code, not to force users to use
>> Thumb code.  The necessary instruction (BX) is available in armv5 and
>> armv5e, even though Thumb is not supported in those architecture variants.
>>
>> It might be worth deprecating v5 and v5e at some point in the future: to
>> the best of my knowledge no v5 class device without Thumb has ever
>> existed - but it's not a decision that needs to be related to this proposal.
> 
> Slightly off topic, but related: What does the "e" stand for? Also,
> what does "l" stand for in armv5tel, which is what I usually get --
> little endian?





The "t" is thumb, "e" means "DSP-like extensions", and I suspect the "l"
is a misprint for "j", meaning the Jazelle (Java) acceleration instructions.

> 
> I have no idea if there is an authoritative source for these host
> specifications and cannot find any. config.guess seems to just rely on
> uname -m.
> 



C++ PATCH for c++/67364 (constexpr vs. empty class)

2016-02-25 Thread Jason Merrill
We don't bother evaluating a store to an empty class member, and we 
shouldn't complain about accesses either.


Tested x86_64-pc-linux-gnu, applying to trunk and 5.
commit fd0e8f3776afa35340bcd3c555280012aa82f645
Author: Jason Merrill 
Date:   Wed Feb 24 17:14:41 2016 -0500

	PR c++/67364
	* constexpr.c (cxx_eval_component_reference): Don't complain about
	unevaluated empty classes.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index d3b04b1..8d9168c 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1983,7 +1983,8 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
   return t;
 }
 
-  if (CONSTRUCTOR_NO_IMPLICIT_ZERO (whole))
+  if (CONSTRUCTOR_NO_IMPLICIT_ZERO (whole)
+  && !is_empty_class (TREE_TYPE (part)))
 {
   /* 'whole' is part of the aggregate initializer we're currently
 	 building; if there's no initializer for this member yet, that's an
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty10.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty10.C
new file mode 100644
index 000..694ed3d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty10.C
@@ -0,0 +1,17 @@
+// PR c++/67364
+// { dg-do compile { target c++11 } }
+
+template 
+struct element : Xn {
+  constexpr element() : Xn() { }
+};
+
+template 
+struct closure {
+  element member;
+  constexpr closure() { }
+};
+
+struct empty { };
+constexpr closure tup{};
+constexpr empty first = tup.member;


C++ PATCH for c++/68049 (ICE with may_alias)

2016-02-25 Thread Jason Merrill
strip_typedefs was failing to strip the typedef in this case, because 
TYPE_MAIN_VARIANT doesn't strip attributes, which were applied after 
applying the typedef name.  Fixed by explicitly using DECL_ORIGINAL_TYPE.


Tested x86_64-pc-linux-gnu, applying to trunk and 5.
commit bd94683bb095be2533c7cdae930e9fb987a22dbf
Author: Jason Merrill 
Date:   Wed Feb 24 16:46:09 2016 -0500

	PR c++/68049
	* tree.c (strip_typedefs): Use DECL_ORIGINAL_TYPE.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 0f7287a..ac38ce3 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1447,7 +1447,15 @@ strip_typedefs (tree t, bool *remove_attributes)
 }
 
   if (!result)
-  result = TYPE_MAIN_VARIANT (t);
+{
+  if (typedef_variant_p (t))
+	/* Explicitly get the underlying type, as TYPE_MAIN_VARIANT doesn't
+	   strip typedefs with attributes.  */
+	result = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (TYPE_NAME (t)));
+  else
+	result = TYPE_MAIN_VARIANT (t);
+}
+  gcc_assert (!typedef_variant_p (result));
   if (TYPE_USER_ALIGN (t) != TYPE_USER_ALIGN (result)
   || TYPE_ALIGN (t) != TYPE_ALIGN (result))
 {
diff --git a/gcc/testsuite/g++.dg/ext/attribute-may-alias-3.C b/gcc/testsuite/g++.dg/ext/attribute-may-alias-3.C
new file mode 100644
index 000..ba6091b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/attribute-may-alias-3.C
@@ -0,0 +1,22 @@
+// PR c++/68049
+// { dg-do compile { target c++11 } }
+
+template  struct Bar
+{
+using type = T;
+};
+template  struct Foo
+{
+typedef typename Bar::type alias_type [[gnu::may_alias]];
+
+alias_type operator()() { return {}; }
+};
+
+template  void print(T) {}
+
+int main()
+{
+print(Foo()());
+print(0);
+return 0;
+}


Re: [WWWDocs] Deprecate support for non-thumb ARM devices

2016-02-25 Thread Richard Earnshaw (lists)
On 25/02/16 13:32, Stefan Ring wrote:
> On Thu, Feb 25, 2016 at 10:20 AM, Richard Earnshaw (lists)
>  wrote:
>> The point is to permit the compiler to use interworking compatible
>> sequences of code when generating ARM code, not to force users to use
>> Thumb code.  The necessary instruction (BX) is available in armv5 and
>> armv5e, even though Thumb is not supported in those architecture variants.
>>
>> It might be worth deprecating v5 and v5e at some point in the future: to
>> the best of my knowledge no v5 class device without Thumb has ever
>> existed - but it's not a decision that needs to be related to this proposal.
> 
> Slightly off topic, but related: What does the "e" stand for? Also,
> what does "l" stand for in armv5tel, which is what I usually get --
> little endian?

The 'e' represented some extensions to the original v5 ISA (you can make
your own mind up as to what the 'e' stands for).

The 'l' isn't anything to do with the architecture per-se.  It simply
means in the Linux context a little-endian device, as opposed to a
'b'ig-endian device.  Most ARM based systems are little-endian so you'll
see that far more often than 'b'.


> I have no idea if there is an authoritative source for these host
> specifications and cannot find any. config.guess seems to just rely on
> uname -m.
> 

For the AArch32 it's extremely ad-hoc.  There's a bit more sanity in the
AArch64 world, but it relies on people following some conventions and
not just creating anarchy.

R.


Re: [WWWDocs] Deprecate support for non-thumb ARM devices

2016-02-25 Thread Stefan Ring
On Thu, Feb 25, 2016 at 10:20 AM, Richard Earnshaw (lists)
 wrote:
> The point is to permit the compiler to use interworking compatible
> sequences of code when generating ARM code, not to force users to use
> Thumb code.  The necessary instruction (BX) is available in armv5 and
> armv5e, even though Thumb is not supported in those architecture variants.
>
> It might be worth deprecating v5 and v5e at some point in the future: to
> the best of my knowledge no v5 class device without Thumb has ever
> existed - but it's not a decision that needs to be related to this proposal.

Slightly off topic, but related: What does the "e" stand for? Also,
what does "l" stand for in armv5tel, which is what I usually get --
little endian?

I have no idea if there is an authoritative source for these host
specifications and cannot find any. config.guess seems to just rely on
uname -m.


[PATCH] Fix PR48795

2016-02-25 Thread Richard Biener

The following fixes a bogus Warray-bound warning by consolidating some
(slightly bogus) duplicate code in tree-vrp.c

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2016-02-25  Richard Biener  

PR tree-optimization/48795
* tree-vrp.c (check_array_ref): Use array_at_struct_end_p.

* gcc.dg/Warray-bounds-18.c: New testcase.

Index: gcc/tree-vrp.c
===
*** gcc/tree-vrp.c  (revision 233693)
--- gcc/tree-vrp.c  (working copy)
*** check_array_ref (location_t location, tr
*** 6450,6456 
value_range *vr = NULL;
tree low_sub, up_sub;
tree low_bound, up_bound, up_bound_p1;
-   tree base;
  
if (TREE_NO_WARNING (ref))
  return;
--- 6450,6455 
*** check_array_ref (location_t location, tr
*** 6465,6491 
  
/* Accesses to trailing arrays via pointers may access storage
   beyond the types array bounds.  */
!   base = get_base_address (ref);
!   if ((warn_array_bounds < 2)
!   && base && TREE_CODE (base) == MEM_REF)
! {
!   tree cref, next = NULL_TREE;
! 
!   if (TREE_CODE (TREE_OPERAND (ref, 0)) != COMPONENT_REF)
!   return;
! 
!   cref = TREE_OPERAND (ref, 0);
!   if (TREE_CODE (TREE_TYPE (TREE_OPERAND (cref, 0))) == RECORD_TYPE)
!   for (next = DECL_CHAIN (TREE_OPERAND (cref, 1));
!next && TREE_CODE (next) != FIELD_DECL;
!next = DECL_CHAIN (next))
! ;
! 
!   /* If this is the last field in a struct type or a field in a
!union type do not warn.  */
!   if (!next)
!   return;
! }
  
low_bound = array_ref_low_bound (ref);
up_bound_p1 = int_const_binop (PLUS_EXPR, up_bound,
--- 6464,6472 
  
/* Accesses to trailing arrays via pointers may access storage
   beyond the types array bounds.  */
!   if (warn_array_bounds < 2
!   && array_at_struct_end_p (ref))
! return;
  
low_bound = array_ref_low_bound (ref);
up_bound_p1 = int_const_binop (PLUS_EXPR, up_bound,
Index: gcc/testsuite/gcc.dg/Warray-bounds-18.c
===
*** gcc/testsuite/gcc.dg/Warray-bounds-18.c (revision 0)
--- gcc/testsuite/gcc.dg/Warray-bounds-18.c (working copy)
***
*** 0 
--- 1,25 
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -Warray-bounds" } */
+ 
+ typedef struct
+ {
+   int len;
+   char data[1];
+ } rec;
+ 
+ int
+ p(rec *r, int len);
+ 
+ int
+ f (char prm1, char prm2)
+ {
+   char buf[10];
+ 
+   rec *r1 = (rec *)
+ 
+   r1->len = 10;
+   r1->data[0] = prm1;
+   r1->data[1] = prm2; /* { dg-bogus "above array bounds" } */
+ 
+   return p(r1, r1->len);
+ }


[testsuite, c++] Require init_priority support for g++.dg/ext/attr-constructor1.C

2016-02-25 Thread Rainer Orth
The new g++.dg/ext/attr-constructor1.C FAILs on Solaris 10 and 11:

FAIL: g++.dg/ext/attr-constructor1.C  -std=c++11  (test for errors, line 5)
FAIL: g++.dg/ext/attr-constructor1.C  -std=c++11 (test for excess errors)
FAIL: g++.dg/ext/attr-constructor1.C  -std=c++14  (test for errors, line 5)
FAIL: g++.dg/ext/attr-constructor1.C  -std=c++14 (test for excess errors)

Excess errors:
/vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/ext/attr-constructor1.C:5:50: 
error: constructor priorities are not supported

Fixed as follows, tested with the appropriate runtest invocation on
i386-pc-solaris2.11 (which lacks constructor priority support),
i386-pc-solaris2.12 (which has it) and x86_64-pc-linux-gnu, installed on
mainline.

Rainer


2016-02-25  Rainer Orth  

* g++.dg/ext/attr-constructor1.C: Require init_priority support.

# HG changeset patch
# Parent  91ba3e75fb07900f8f953f4387f6a0f12031d1a6
Require init_priority support for g++.dg/ext/attr-constructor1.C

diff --git a/gcc/testsuite/g++.dg/ext/attr-constructor1.C b/gcc/testsuite/g++.dg/ext/attr-constructor1.C
--- a/gcc/testsuite/g++.dg/ext/attr-constructor1.C
+++ b/gcc/testsuite/g++.dg/ext/attr-constructor1.C
@@ -1,5 +1,5 @@
 // PR c++/59281
-// { dg-do compile { target c++11 } }
+// { dg-do compile { target { c++11 && init_priority } } }
 
 enum class E : int { prio = 666 };
 void f (int) __attribute__((constructor(E::prio))); // { dg-error "integer" }

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCHES, PING*5] Enhance standard DWARF for Ada

2016-02-25 Thread Eric Botcazou
> I agree that catching this in scan-assembler test is hard, but guality test
> would catch this.  It is true that some guality tests (mostly the ones that
> test behaviour of optimized code, which differs a lot between different
> architectures) have known FAILs (or known XFAILs), because the target,
> compilation options and gdb version matrix is too large to catch all cases.

IMO the guality testsuite is not really appropriate for debug info issues, 
it's too brittle, has a low signal-over-noise ratio and nobody really cares 
about it.  And, given that most people already don't care about the regular 
gnat.dg testsuite, I think that literally nobody will about gnat.dg/guality.

Given that only AdaCore's folks work on Ada debug info issues in practice and 
that they run the GDB testsuite, I don't see any real need for it.

-- 
Eric Botcazou


[wwwdocs] Update -Wnonnull description

2016-02-25 Thread Marek Polacek
Now that -Wnonnull-comare has been split out of -Wnonnull, we should also
update the porting_to text.  Is this sufficient?

Index: porting_to.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-6/porting_to.html,v
retrieving revision 1.15
diff -u -r1.15 porting_to.html
--- porting_to.html 23 Feb 2016 10:13:29 -  1.15
+++ porting_to.html 25 Feb 2016 12:17:00 -
@@ -388,12 +388,12 @@
 the indentation of the source was fixed instead.
 
 
-Enhanced -Wnonnull
+-Wnonnull-compare
 
-The -Wnonnull warning has been improved so that it also warns
-about comparing parameters declared as nonnull with
-NULL.  For example, the compiler will warn about the
-following code:
+A new warning -Wnonnull-compare was added to -Wall.
+It warns about comparing parameters declared as nonnull with
+NULL.  For example, the compiler will now warn about the following
+code:
 
 
 

Marek


Re: [wwwdocs] Describe behavior of -flifetime-dse in class constructors

2016-02-25 Thread Martin Liška
On 02/19/2016 05:52 AM, Jan Hubicka wrote:
> Hi,
> thank you for working this out and writting summary. I think in a shorter 
> form this would make
> excellent entry for changes.html, too.  We tell about the new feature and 
> warn users about fallout
> that is always good.

Good idea.

That's a suggestion for changes.html.

Ready to be installed?
Martin
Index: htdocs/gcc-6/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-6/changes.html,v
retrieving revision 1.62
diff --unified -r1.62 changes.html
--- htdocs/gcc-6/changes.html	24 Feb 2016 09:36:06 -	1.62
+++ htdocs/gcc-6/changes.html	25 Feb 2016 11:21:42 -
@@ -230,6 +230,10 @@
 The default mode has been changed to -std=gnu++14.
 C++ Concepts are now supported when compiling with
 -std=gnu++1z or -std=c++1z.
+-flifetime-dse is more
+aggressive in dead-store elimination in situations where
+a memory store to a location precedes a constructor to the
+memory location.
   
 
 Runtime Library (libstdc++)


[PATCH] Do not gather mem stats in run_exit_handles (PR middle-end/69919)

2016-02-25 Thread Martin Liška
Hello.

As discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69919#c3, 
following patch
guards usage of memory statistics infrastructure after a mem_alloc_description 
is already
destructed.

Patch can lto-bootstrap on x86_64-linux-gnu with 
--enable-gather-detailed-mem-stats and
survives bootstrap with --enable-gather-detailed-mem-stats on 
x86_64-linux-gnu with.

Ready to be installed?
Martin

gcc/ChangeLog:

2016-02-25  Martin Liska  

PR middle-end/69919
* alloc-pool.c (after_memory_report): New variable.
* alloc-pool.h (base_pool_allocator ::release): Do not use
the infrastructure if after_memory_report.
* toplev.c (toplev::main): Mark after memory report.
---
 gcc/alloc-pool.c | 1 +
 gcc/alloc-pool.h | 5 -
 gcc/toplev.c | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c
index ae5e232..43d06f6 100644
--- a/gcc/alloc-pool.c
+++ b/gcc/alloc-pool.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 
 ALLOC_POOL_ID_TYPE last_id;
 mem_alloc_description pool_allocator_usage;
+bool after_memory_report = false;
 
 /* Output per-alloc_pool memory usage statistics.  */
 void
diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 8ccf089..3ead101 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -25,6 +25,9 @@ along with GCC; see the file COPYING3.  If not see
 
 extern void dump_alloc_pool_statistics (void);
 
+/* Flag indicates whether memory statistics are gathered any longer.  */
+extern bool after_memory_report;
+
 typedef unsigned long ALLOC_POOL_ID_TYPE;
 
 /* Last used ID.  */
@@ -306,7 +309,7 @@ base_pool_allocator ::release ()
   TBlockAllocator::release (block);
 }
 
-  if (GATHER_STATISTICS)
+  if (GATHER_STATISTICS && !after_memory_report)
 {
   pool_allocator_usage.release_instance_overhead
(this, (m_elts_allocated - m_elts_free) * m_elt_size);
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 28c115d..c480bfc 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2107,6 +2107,9 @@ toplev::main (int argc, char **argv)
 
   finalize_plugins ();
   location_adhoc_data_fini (line_table);
+
+  after_memory_report = true;
+
   if (seen_error () || werrorcount)
 return (FATAL_EXIT_CODE);
 
-- 
2.7.0



[PATCH][AArch64] Set TREE_TARGET_GLOBALS in aarch64_set_current_function when new tree is the default node to recalculate optab availability

2016-02-25 Thread Kyrill Tkachov

Hi all,

Seems like aarch64 is suffering from something similar to PR 69245 as well.
If a target pragma sets the target state to the same as the 
target_option_default_node
the node is just a pointer to target_option_default_node rather than a distinct 
identical
node. So we must still restore the target globals even when setting to 
target_option_default_node
in order to force the midend to recompute the availability of various optabs.

If we don't do it, we can get in a problem like in the testcase where the 
isa_flags are all
set correctly, but the optab HAVE_* predicates have not been recomputed.

There is also a related issue present when popping/resetting target pragmas for 
which
I'll send out a patch separately.

Bootstrapped and tested on aarch64.

Ok for trunk?
Thanks,
Kyrill


2016-02-25  Kyrylo Tkachov  

PR target/69245
* config/aarch64/aarch64.c (aarch64_set_current_function): Save/restore
target globals when switching to target_option_default_node.

2016-02-25  Kyrylo Tkachov  

PR target/69245
* gcc.target/aarch64/pr69245_1.c: New test.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 2e69e345545e591d1de76c2d175aac476e6e1107..07590bd43ca81e182ab1e2ba9596cf6881173729 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -8593,7 +8593,7 @@ aarch64_set_current_function (tree fndecl)
   if (old_tree == new_tree)
 	;
 
-  else if (new_tree && new_tree != target_option_default_node)
+  else if (new_tree)
 	{
 	  cl_target_option_restore (_options,
 TREE_TARGET_OPTION (new_tree));
diff --git a/gcc/testsuite/gcc.target/aarch64/pr69245_1.c b/gcc/testsuite/gcc.target/aarch64/pr69245_1.c
new file mode 100644
index ..dcc542b2a8686f1b323433624d4df65ca9e96b36
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr69245_1.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=armv8-a+fp -fomit-frame-pointer" } */
+
+#pragma GCC target "arch=armv8-a+nofp"
+long a;
+static void
+fn1 ()
+{
+}
+
+#pragma GCC target "arch=armv8-a+fp"
+float
+fn2 (float a)
+{
+  return a + 2.0;
+}
+
+/* { dg-final { scan-assembler-not "__addsf3" } } */


Re: [PATCH][AArch64] Remove an unused reload hook.

2016-02-25 Thread Yvan Roux
Hi,

On 26 January 2015 at 18:01, Matthew Wahab  wrote:
> Hello,
>
> The LEGITIMIZE_RELOAD_ADDRESS macro is only needed for reload. Since the
> Aarch64 backend no longer supports reload, this macro is not needed and this
> patch removes it.
>
> Tested aarch64-none-linux-gnu with gcc-check. No new failures.
>
> Ok for trunk?
> Matthew
>
> gcc/
> 2015-01-26  Matthew Wahab  
>
> * config/aarch64/aarch64.h (LEGITIMIZE_RELOAD_ADDRESS): Remove.
> * config/aarch64/arch64-protos.h
> (aarch64_legitimize_reload_address): Remove.
> * config/aarch64/aarch64.c (aarch64_legitimize_reload_address):
> Remove.

It seems that this old patch was forgotten, I guess that it'll have to
wait for GCC 7 now, but I think it's a good thing top cleanup the
reload specific hooks and constructions (I've another patch on for
that under on-going).

Cheers,
Yvan


Re: [PATCHES, PING*5] Enhance standard DWARF for Ada

2016-02-25 Thread Jakub Jelinek
On Thu, Feb 25, 2016 at 11:35:07AM +0100, Pierre-Marie de Rodat wrote:
> As I said at the end of a message in another thread
> (https://gcc.gnu.org/ml/gcc-patches/2016-01/msg01078.html), I always feel
> uncomfortable writing brittle dg-scan testcases, hence the current lack of
> testcases for those DWARF changes.

I agree that catching this in scan-assembler test is hard, but guality test
would catch this.  It is true that some guality tests (mostly the ones that
test behaviour of optimized code, which differs a lot between different
architectures) have known FAILs (or known XFAILs), because the target,
compilation options and gdb version matrix is too large to catch all cases.
But, if one just looks at test_summary output before/after a change,
one can detect regressions and fix them.  Perhaps in some cases you could
just limit to -O0 guality if it is something you want to just check if
the debug info is represented properly and don't need to test
-fvar-tracking-assignments etc. handling - you can just dg-skip-if the tests
except for -O0 etc.
Similarly, it shouldn't be hard to add tcl function to check for gdb
version, and limit some tests only to a particular version of gdb or newer.

Jakub


Re: [PATCHES, PING*5] Enhance standard DWARF for Ada

2016-02-25 Thread Pierre-Marie de Rodat

On 02/25/2016 10:48 AM, Jakub Jelinek wrote:

Unfortunately, this broke the DW_OP_GNU_implicit_pointer support, on vast
majority of binaries and libraries gcc now emits invalid DWARF (which both
gdb and dwz complain about and dwz refuses to optimize because of that).


Arg, sorry about this!


I'm attaching two possible patches, so far untested.


Thanks, I’m having a look as we speak.


So, Pierre-Marie, can I ask you to run whatever Ada debug info testsuite
you have with the second patch?  And for GCC 7 really please consider adding
gnat.dg/guality/ and fill it with tests.


Testing in progress…

I have a tiny Python/pyelftools-based testsuite that checks the DIE 
patterns GCC emits for several Ada types. I really wish I could somehow 
integrate them to the GCC testsuite, but right now I don’t know how I 
could do similar things, there.


As I said at the end of a message in another thread 
(https://gcc.gnu.org/ml/gcc-patches/2016-01/msg01078.html), I always 
feel uncomfortable writing brittle dg-scan testcases, hence the current 
lack of testcases for those DWARF changes.


--
Pierre-Marie de Rodat


Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences

2016-02-25 Thread Pierre-Marie de Rodat

On 02/25/2016 11:15 AM, Martin Liška wrote:

Sure. Just working on that.


Great, thank you!

--
Pierre-Marie de Rodat


Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences

2016-02-25 Thread Martin Liška
On 02/25/2016 11:14 AM, Pierre-Marie de Rodat wrote:
> Understood. Martin, as the ENABLE_CHECKING refactoring is not comitted yet, 
> could you do the substitution ENABLE_CHECKING → CHECKING_P for these 
> dwarf2out.* occurences as part of it?

Sure. Just working on that.

Martin


Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences

2016-02-25 Thread Pierre-Marie de Rodat

On 02/25/2016 10:24 AM, Richard Biener wrote:

So what about removing the field (in struct dw_loc_descr_node) and replacing
the visited hash set with a frame_offset hash map (in resolve_args_picking)?
This hash map would remember the information we currently store in the
field.


Sounds reasonable.


Thanks. I will prepare the patch and submit it for GCC 7, then.


Technically it's GCC 7 material.  Can you either change the ENABLE_CHECKING
use to CHECKING_P for GCC 6 or remove the guarded code/fields?


Understood. Martin, as the ENABLE_CHECKING refactoring is not comitted 
yet, could you do the substitution ENABLE_CHECKING → CHECKING_P for 
these dwarf2out.* occurences as part of it?


--
Pierre-Marie de Rodat


Re: [wwwdocs] Describe behavior of -flifetime-dse in class constructors

2016-02-25 Thread Markus Trippelsdorf
On 2016.02.25 at 11:07 +0100, Markus Trippelsdorf wrote:
> On 2016.02.25 at 11:01 +0100, Martin Liška wrote:
> > On 02/17/2016 04:01 PM, Martin Liška wrote:
> > > On 02/17/2016 03:23 PM, Jakub Jelinek wrote:
> > >> "has been" looks weird.  I'd say that the C++ compiler is now more
> > >> aggressive...
> > >>
> > I've been thinking if the suggested patch makes sense any longer after
> > the following patch was applied:
> > https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01651.html ?
> 
> It still makes sense, just replace -fno-lifetime-dse with
> -fno-lifetime-dse=1.

Err, I mean -flifetime-dse=1 of course.

-- 
Markus


Re: [wwwdocs] Describe behavior of -flifetime-dse in class constructors

2016-02-25 Thread Markus Trippelsdorf
On 2016.02.25 at 11:01 +0100, Martin Liška wrote:
> On 02/17/2016 04:01 PM, Martin Liška wrote:
> > On 02/17/2016 03:23 PM, Jakub Jelinek wrote:
> >> "has been" looks weird.  I'd say that the C++ compiler is now more
> >> aggressive...
> >>
> I've been thinking if the suggested patch makes sense any longer after
> the following patch was applied:
> https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01651.html ?

It still makes sense, just replace -fno-lifetime-dse with
-fno-lifetime-dse=1.

-- 
Markus


Re: [wwwdocs] Describe behavior of -flifetime-dse in class constructors

2016-02-25 Thread Martin Liška
On 02/17/2016 04:01 PM, Martin Liška wrote:
> On 02/17/2016 03:23 PM, Jakub Jelinek wrote:
>> "has been" looks weird.  I'd say that the C++ compiler is now more
>> aggressive...
>>
>>  Jakub
> 
> Sending v3.
> 
> M.
> 

Hi.

I've been thinking if the suggested patch makes sense any longer after the 
following patch was applied:
https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01651.html ?

Martin



Re: [PATCH] [RFA] [PR tree-optmization/69740] Schedule loop fixups when needed

2016-02-25 Thread Richard Biener
On Thu, Feb 25, 2016 at 7:18 AM, Jeff Law  wrote:
>
> PR69740 shows two instances where one or more transformations ultimately
> lead to the removal of a basic block.
>
> In both cases, removal of the basic block removes a path into an irreducible
> region and turns the irreducible region into a natural loop.
>
> When that occurs we need to be requesting loops to be fixed up.
>
> My first patch was to handle this is was in tree-ssa-dce.c and that fixed
> the initial problem report.  As I was cobbling the patch together, I
> pondered putting the changes into delete_basic_block because that would
> capture other instances of this problem.
>
> When I looked at the second instance, it came via a completely different
> path (tail merging).  Again it was a case where we called delete_basic_block
> which in turn changed an irreducible region into a natural loop.  So I
> tossed my original patch and put the test into delete_basic_block as you see
> here.
>
> Bootstrapped and regression tested on x86_64-linux-gnu.  OK for the trunk
> and the gcc-5 branch after a suitable soak time?
>
>
>
> Jeff
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 913abc8..42e5b4f 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,10 @@
> +2016-02-24  Jeff Law  
> +
> +   PR tree-optimization/69740
> +   * cfghooks.c (delete_basic_block): Request loop fixups if we delete
> +   a block with an outgoing edge to a block marked as being in anx
> +   irreducible region.
> +
>  2016-02-24  Jason Merrill  
>
> * common.opt (flifetime-dse): Add -flifetime-dse=1.
> diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
> index bbb1017..4d31aa9 100644
> --- a/gcc/cfghooks.c
> +++ b/gcc/cfghooks.c
> @@ -574,6 +574,14 @@ delete_basic_block (basic_block bb)
>if (!cfg_hooks->delete_basic_block)
>  internal_error ("%s does not support delete_basic_block",
> cfg_hooks->name);
>
> +  /* Look at BB's successors, if any are marked as BB_IRREDUCIBLE_LOOP,
> then
> + removing BB (and its outgoing edges) may make the loop a natural
> + loop.  In which case we need to schedule loop fixups.  */
> +  if (current_loops)
> +for (edge_iterator ei = ei_start (bb->succs); !ei_end_p (ei); ei_next
> ())
> +  if (ei_edge (ei)->dest->flags & BB_IRREDUCIBLE_LOOP)
> +   loops_state_set (LOOPS_NEED_FIXUP);

So I fail to see how only successor edges are relevant.  Isn't the important
case to catch whether we remove an edge marked EDGE_IRREDUCIBLE_LOOP?
Even if the BB persists we might have exposed a new loop here.

Note that it is not safe to look at {BB,EDGE}_IRREDUCIBLE_LOOP if the loop
state does not have LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS set
(the flags may be stale or missing).  So it might be that we can't rely on
non-loop passes modifying the CFG to handle this optimistically.

Thus, how about (my main point) moving this to remove_edge instead, like

Index: gcc/cfghooks.c
===
--- gcc/cfghooks.c  (revision 233693)
+++ gcc/cfghooks.c  (working copy)
@@ -408,7 +408,15 @@ void
 remove_edge (edge e)
 {
   if (current_loops != NULL)
-rescan_loop_exit (e, false, true);
+{
+  rescan_loop_exit (e, false, true);
+  /* If we remove an edge that is part of an irreducible region
+ or we remove an entry into an irreducible region we may expose
+new natural loops.  */
+  if (e->flags & EDGE_IRREDUCIBLE_LOOP
+ || e->dest->flags & BB_IRREDUCIBLE_LOOP)
+   loops_state_set (LOOPS_NEED_FIXUP);
+}

   /* This is probably not needed, but it doesn't hurt.  */
   /* FIXME: This should be called via a remove_edge hook.  */

that then handles delete_basic_block via its call to remove all
incoming/outgoing edges.

As for the comment above it may need to be conservatively

   if (! loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)
  || checks above)

That looks like a more complete fix (and it avoids an extra loop over
all edges).

(the edge flag check might be redundant given it's only set if both
src and dest are
BB_IRREDUCIBLE_LOOP).

Richard.

>cfg_hooks->delete_basic_block (bb);
>
>if (current_loops != NULL)
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index 311232f..b0df819 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,9 @@
> +2016-02-04  Jeff Law  
> +
> +   PR tree-optimization/69740
> +   * gcc.c-torture/compile/pr69740-1.c: New test.
> +   * gcc.c-torture/compile/pr69740-2.c: New test.
> +
>  2016-02-24  Martin Sebor  
>
> PR c++/69912
> diff --git a/gcc/testsuite/gcc.c-torture/compile/pr69740-1.c
> b/gcc/testsuite/gcc.c-torture/compile/pr69740-1.c
> new file mode 100644
> index 000..ac867d8
> --- /dev/null
> +++ b/gcc/testsuite/gcc.c-torture/compile/pr69740-1.c
> @@ -0,0 +1,12 @@
> +char a;
> +short b;
> 

Re: [patch] libstdc++/69945 Add __gnu_cxx::__freeres hook

2016-02-25 Thread Jonathan Wakely

On 25/02/16 10:36 +0100, Richard Biener wrote:

On Wed, Feb 24, 2016 at 7:35 PM, Jonathan Wakely  wrote:

This adds a new function to libsupc++ which will free the memory still
in use by the pool used for allocating exceptions when malloc fails.

This is similar to glibc's __libc_freeres, which valgrind (and other
tools?) use to tell glibc to deallocate everything before exiting.

I initially called it __gnu_cxx::__free_eh_pool() but I figured we
might have other memory in use at some later date, and we wouldn't
want valgrind to have to start calling a second function, nor make a
function called __free_eh_pool() actually free other things.

I intentionally *didn't* lock the pool's mutex before freeing it,
because this should never be called in a context where multiple
threads are still active and accessing the pool.

Thoughts?

Is the new test a good idea, or will exposing it like that in the
testsuite just give users the idea that they can/should be doing the
same themselves?


The goal is to lookup the function via dlsym and only call it before
glibcs freeres (which will probably make free() in-operatable?)


Yes, I believe so (Mark? Ivo?)

Another way to test it would be to use dg-final to run gdb in the
global's destructor and try to call the function from GDB.



[ Aside: should the actual pool be created with placement-new to
[ ensure it doesn't ever get destroyed?
[
[   alignas(pool) unsigned char poolbuf[sizeof(pool)];
[   pool& emergency_pool = *::new(poolbuf) pool;


Hmm, for pedantic correctness yes I guess.  But it hasn't any destructor,
it's global (so no CLOBBER / memory re-use issue) and so the destruction
won't do anything.  Of course it might simply save a global dtor (does it
even register one?  I don't see one).


It was the CLOBBER that I was thinking about, but I agree we don't
(currently) do that for trivial destructors.


There is still the missing feature of allowing to size the emergency
pool using an environment variable (properly securely implemented, of course).


Yes.


Re: [ARM] Add support for overflow add, sub, and neg operations

2016-02-25 Thread Kyrill Tkachov

Hi Michael,

On 24/02/16 23:02, Michael Collison wrote:

This patch adds support for builtin overflow of add, subtract and negate. This 
patch is targeted for gcc 7 stage 1. It was tested with no regressions in arm 
and thumb modes on the following targets:

arm-non-linux-gnueabi
arm-non-linux-gnuabihf
armeb-none-linux-gnuabihf
arm-non-eabi



I'll have a deeper look once we're closer to GCC 7 development.
I've got a few comments in the meantime.


2016-02-24 Michael Collison  

* config/arm/arm-modes.def: Add new condition code mode CC_V
to represent the overflow bit.
* config/arm/arm.c (maybe_get_arm_condition_code):
Add support for CC_Vmode.
* config/arm/arm.md (addv4, add3_compareV,
addsi3_compareV_upper): New patterns to support signed
builtin overflow add operations.
(uaddv4, add3_compareC, addsi3_compareV_upper):
New patterns to support unsigned builtin add overflow operations.
(subv4, sub3_compare1): New patterns to support signed
builtin overflow subtract operations,
(usubv4): New patterns to support unsigned builtin subtract
overflow operations.
(negvsi3, negvdi3, negdi2_compre, negsi2_carryin_compare): New patterns
to support builtin overflow negate operations.




Can you please summarise what sequences are generated for these operations, and 
how
they are better than the default fallback sequences.
Also, we'd need tests for each of these overflow operations, since these are 
pretty complex
patterns that are being added.

Also, you may want to consider splitting this into a patch series, each adding 
a single
overflow operation, together with its tests. That way it will be easier to keep 
track of
which pattern applies to which use case and they can go in independently of 
each other.

+(define_expand "uaddv4"
+  [(match_operand:SIDI 0 "register_operand")
+   (match_operand:SIDI 1 "register_operand")
+   (match_operand:SIDI 2 "register_operand")
+   (match_operand 3 "")]
+  "TARGET_ARM"
+{
+  emit_insn (gen_add3_compareC (operands[0], operands[1], operands[2]));
+
+  rtx x;
+  x = gen_rtx_NE (VOIDmode, gen_rtx_REG (CC_Cmode, CC_REGNUM), const0_rtx);
+  x = gen_rtx_IF_THEN_ELSE (VOIDmode, x,
+   gen_rtx_LABEL_REF (VOIDmode, operands[3]),
+   pc_rtx);
+  emit_jump_insn (gen_rtx_SET (pc_rtx, x));
+  DONE;
+})
+

I notice this and many other patterns in this patch are guarded on TARGET_ARM. 
Is there any reason why they
should be restricted to arm state and not be TARGET_32BIT ?

Thanks,
Kyrill


Re: [PATCHES, PING*5] Enhance standard DWARF for Ada

2016-02-25 Thread Jakub Jelinek
On Wed, Dec 16, 2015 at 09:53:37AM +0100, Pierre-Marie de Rodat wrote:
> On 12/11/2015 09:25 PM, Jason Merrill wrote:
> >Hmm, can we generate the DWARF procedures during finalize_size_functions
> >to avoid the need for preserve_body?
> 
> Good idea, thank you! Here’s the updated patch (bootstrapped and regtested
> on x86_64-linux, as usual).

Unfortunately, this broke the DW_OP_GNU_implicit_pointer support, on vast
majority of binaries and libraries gcc now emits invalid DWARF (which both
gdb and dwz complain about and dwz refuses to optimize because of that).

I'm attaching two possible patches, so far untested.

The first one just fixes what I mainly care about, the committed patch
assumed that DW_TAG_dwarf_procedure is always only created for the Ada
variable sized structures or whatever it was meant for, which is not the
case, and thus if we emit DW_TAG_dwarf_procedure for some other reason,
it would be pruned as unused even when it is actually used (and result in
a DIE reference to the compilation unit header, which is always invalid).

But, looking at the points where you use DW_TAG_dwarf_procedure for the Ada
things, I can't see how it can actually work at all, though there is no
testsuite coverage, so it is hard to find out for real.
The thing is, current code sets die_perennial_p on type DIEs and their
parents, but nothing else.  In particular, type DIEs are identified by
being returned from lookup_type_die, thus earlier passed to
equate_type_number_to_die.  I don't see that this would ever be the case
of DW_TAG_dwarf_procedure though, I see the return of
function_to_dwarf_procedure being used as dw_loc_oprnd1.v.val_die_ref.die
of a DW_OP_call4 that is somewhere used in some location description that is
perhaps used somewhere in some type DIE computation.
Thus, I'm afraid for Ada variable sized structures you get the same problem,
you might IMHO DW_OP_call4 .Ldebug_info0 + 0 because the
DW_TAG_dwarf_procedure will be pruned as "unused".  So IMHO the second patch
makes more sense, and if you (for GCC 7?) want to prune really unused
DW_TAG_dwarf_procedure, you need to add code that will really walk all of
the debuginfo, rather than just type DIEs themselves, and look if location
descriptions (in .debug_info or .debug_loc) reference those
DW_TAG_dwarf_procedure and mark the DW_TAG_dwarf_procedure.

So, Pierre-Marie, can I ask you to run whatever Ada debug info testsuite
you have with the second patch?  And for GCC 7 really please consider adding
gnat.dg/guality/ and fill it with tests.

Jakub
2016-02-25  Jakub Jelinek  

PR debug/69947
* dwarf2out.c (string_cst_pool_decl): Set die_perennial_p on
the DW_TAG_dwarf_procedure DIE.

* gcc.dg/guality/pr69947.c: New test.

--- gcc/dwarf2out.c.jj  2016-02-24 23:03:32.0 +0100
+++ gcc/dwarf2out.c 2016-02-25 10:08:46.688716691 +0100
@@ -26288,6 +26288,7 @@ string_cst_pool_decl (tree t)
   l->dw_loc_oprnd2.v.val_vec.elt_size = 1;
   l->dw_loc_oprnd2.v.val_vec.array = array;
   add_AT_loc (ref, DW_AT_location, l);
+  ref->die_perennial_p = 1;
   equate_decl_number_to_die (decl, ref);
 }
   return rtl;
--- gcc/testsuite/gcc.dg/guality/pr69947.c.jj   2016-02-25 10:00:25.503608176 
+0100
+++ gcc/testsuite/gcc.dg/guality/pr69947.c  2016-02-25 10:05:20.446552599 
+0100
@@ -0,0 +1,22 @@
+/* PR debug/69947 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+#include "../nop.h"
+
+static const char *c = "foobar";
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+  static const char a[] = "abcdefg";
+  const char *b = a;   /* { dg-final { gdb-test 14 "c\[2\]" "'o'" } } 
*/
+  asm (NOP : : : "memory");/* { dg-final { gdb-test 14 "b\[4\]" "'e'" } } 
*/
+}
+
+int
+main ()
+{
+  foo ();
+  return 0;
+}
2016-02-25  Jakub Jelinek  

PR debug/69947
* dwarf2out.c (prune_unused_types_walk): Don't prune
DW_TAG_dwarf_procedure.

* gcc.dg/guality/pr69947.c: New test.

--- gcc/dwarf2out.c.jj  2016-02-24 23:03:32.0 +0100
+++ gcc/dwarf2out.c 2016-02-25 10:08:46.688716691 +0100
@@ -25853,11 +25853,6 @@ prune_unused_types_walk (dw_die_ref die)
 case DW_TAG_file_type:
   /* Type nodes are useful only when other DIEs reference them --- don't
 mark them.  */
-  /* FALLTHROUGH */
-
-case DW_TAG_dwarf_procedure:
-  /* Likewise for DWARF procedures.  */
-
   if (die->die_perennial_p)
break;
 
--- gcc/testsuite/gcc.dg/guality/pr69947.c.jj   2016-02-25 10:00:25.503608176 
+0100
+++ gcc/testsuite/gcc.dg/guality/pr69947.c  2016-02-25 10:05:20.446552599 
+0100
@@ -0,0 +1,22 @@
+/* PR debug/69947 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+#include "../nop.h"
+
+static const char *c = "foobar";
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+  static const char a[] = "abcdefg";
+  const char *b = a;   /* { dg-final { gdb-test 14 "c\[2\]" "'o'" } } 

Re: [patch] libstdc++/69945 Add __gnu_cxx::__freeres hook

2016-02-25 Thread Richard Biener
On Wed, Feb 24, 2016 at 7:35 PM, Jonathan Wakely  wrote:
> This adds a new function to libsupc++ which will free the memory still
> in use by the pool used for allocating exceptions when malloc fails.
>
> This is similar to glibc's __libc_freeres, which valgrind (and other
> tools?) use to tell glibc to deallocate everything before exiting.
>
> I initially called it __gnu_cxx::__free_eh_pool() but I figured we
> might have other memory in use at some later date, and we wouldn't
> want valgrind to have to start calling a second function, nor make a
> function called __free_eh_pool() actually free other things.
>
> I intentionally *didn't* lock the pool's mutex before freeing it,
> because this should never be called in a context where multiple
> threads are still active and accessing the pool.
>
> Thoughts?
>
> Is the new test a good idea, or will exposing it like that in the
> testsuite just give users the idea that they can/should be doing the
> same themselves?

The goal is to lookup the function via dlsym and only call it before
glibcs freeres (which will probably make free() in-operatable?)

>
> [ Aside: should the actual pool be created with placement-new to
> [ ensure it doesn't ever get destroyed?
> [
> [   alignas(pool) unsigned char poolbuf[sizeof(pool)];
> [   pool& emergency_pool = *::new(poolbuf) pool;

Hmm, for pedantic correctness yes I guess.  But it hasn't any destructor,
it's global (so no CLOBBER / memory re-use issue) and so the destruction
won't do anything.  Of course it might simply save a global dtor (does it
even register one?  I don't see one).

There is still the missing feature of allowing to size the emergency
pool using an environment variable (properly securely implemented, of course).

Richard.

>
>


[PATCH][AArch64] PR target/69613: Return zero TARGET_SHIFT_TRUNCATION_MASK when SHIFT_COUNT_TRUNCATED is false

2016-02-25 Thread Kyrill Tkachov

Hi all,

In this wrong-code PR we get bad code when synthesising a TImode right shift
by variable amount using DImode shifts during expand.

The expand_double_word_shift function expands two paths: one where the
variable amount is greater than GET_MODE_BITSIZE (DImode) (word_mode for 
aarch64) at runtime
and one where it's less than that, and performs a conditional select between 
the two in the end.

The second path is the one that goes wrong here.
The algorithm it uses for calculating a TImode shift when the variable shift 
amount is <64 is:


  --DImode-   --DImode- --DImode-   --DImode-
{ |__ target-hi ___| |___ target-lo ___| } = { |___ source-hi ___| |___ source-lo 
___| } >> var_amnt

1) carry = source-hi << 1
2) tmp = ~var_amnt // either that or BITS_PER_WORD - 1 - var_amnt depending on 
shift_truncation_mask
3) carry = carry << tmp // net effect is that carry is source-hi shifted left 
by BITS_PER_WORD - var_amnt
4) target-lo = source-lo >>u var_amnt //unsigned shift.
5) target-lo = target-lo | carry
6) target-hi = source-hi >> var_amnt

where the two DImode words source-hi and source-lo are the two words of the 
source TImode value
and var_amnt is the register holding the variable shift amount. This is 
performed by the
expand_subword_shift function in optabs.c.

Step 2) is valid only if the target truncates the shift amount by the width of 
the type its shifting,
that is SHIFT_COUNT_TRUNCATED is true and TARGET_SHIFT_TRUNCATION_MASK is 63 in 
this case.

Step 3) is the one that goes wrong.  On aarch64 a left shift is usually 
implemented using the LSL
instruction but we also have alternatives that can use the SIMD registers and 
the USHL instruction.
In this case we end up using the USHL instruction. However, although the USHL 
instruction does
a DImode shift, it doesn't truncate the shift amount by 64, but rather by 255. 
Furthermore, the
shift amount is interpreted as a 2's complement signed integer and if it's 
negative performs
a right shift.  This is in contrast with the normal LSL instruction which just 
performs an
unsigned shift by an amount truncated by 64.

Now, on aarch64 SHIFT_COUNT_TRUNCATED is defined as !TARGET_SIMD, so we don't 
assume shift
amounts are truncated unless we know we can only ever use the LSL instructions 
for variable
shifts.

However, we still return 63 as the TARGET_SHIFT_TRUNCATION_MASK for DImode, so 
expand_subword_shift
assumes that since the mask is non-zero it's a valid shift truncation mask.
The documentation for TARGET_SHIFT_TRUNCATION_MASK says:
" The default implementation of this function returns
  @code{GET_MODE_BITSIZE (@var{mode}) - 1} if @code{SHIFT_COUNT_TRUNCATED}
  and 0 otherwise."

So since for TARGET_SIMD we cannot guarantee that all shifts truncate their 
amount, we should be
returning 0 in TARGET_SHIFT_TRUNCATION_MASK when SHIFT_COUNT_TRUNCATED is false.
This is what the patch does, and with it step 2) becomes:
2) tmp = BITS_PER_WORD - 1 - var_amnt
which behaves correctly on aarch64.

Unfortunately, the testcase from the PR has very recently gone latent on trunk 
because it
depends on register allocation picking a particular alternative from the 
*aarch64_ashl_sisd_or_int_3
pattern in aarch64.md. I tried to do some inline asm tricks to get it to force 
the correct constraints
but was unsuccessful. Nevertheless I've included the testcase in the patch. I 
suppose it's better than nothing.

Bootstrapped and tested on aarch64.

Ok for trunk?

Thanks,
Kyrill


2016-02-25  Kyrylo Tkachov  

PR target/69613
* config/aarch64/aarch64.c (aarch64_shift_truncation_mask):
Return 0 if !SHIFT_COUNT_TRUNCATED

2016-02-25  Kyrylo Tkachov  

PR target/69613
* gcc.dg/torture/pr69613.c: New test.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index d0d15b4feee70a5ca6af8dd16c7667cbcd844dbf..2e69e345545e591d1de76c2d175aac476e6e1107 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -11171,7 +11171,8 @@ static unsigned HOST_WIDE_INT
 aarch64_shift_truncation_mask (machine_mode mode)
 {
   return
-(aarch64_vector_mode_supported_p (mode)
+(!SHIFT_COUNT_TRUNCATED
+ || aarch64_vector_mode_supported_p (mode)
  || aarch64_vect_struct_mode_p (mode)) ? 0 : (GET_MODE_BITSIZE (mode) - 1);
 }
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr69613.c b/gcc/testsuite/gcc.dg/torture/pr69613.c
new file mode 100644
index ..44f2b0cc91ac4b12c4d255b608f95bc8bf016923
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr69613.c
@@ -0,0 +1,40 @@
+/* PR target/69613.  */
+/* { dg-do run { target int128 } } */
+/* { dg-additional-options "-mavx" { target { i?86-*-* x86_64-*-* } } } */
+
+typedef unsigned short u16;
+typedef unsigned short v32u16 __attribute__ ((vector_size (32)));
+typedef unsigned int u32;
+typedef unsigned int v32u32 __attribute__ ((vector_size (32)));
+typedef 

Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences

2016-02-25 Thread Richard Biener
On Wed, Feb 24, 2016 at 3:16 PM, Martin Liška  wrote:
> On 02/23/2016 04:21 PM, Richard Biener wrote:
>> On Wed, Nov 4, 2015 at 4:03 PM, Mikhail Maltsev  wrote:
>>> On 11/03/2015 02:35 AM, Jeff Law wrote:
 This is good fore the trunk too.  Please install.

 Thanks!

 jeff
>>>
>>> Committed as r229758.
>>
>>> grep ENABLE_CHECKING *.[ch]
>> dwarf2out.c:#if ENABLE_CHECKING
>> dwarf2out.c:#if ENABLE_CHECKING
>> dwarf2out.c:#if ENABLE_CHECKING
>> dwarf2out.h:#if ENABLE_CHECKING
>
> Hi Richi.
>
> Removal in dwarf2out.c is not possible due to assignment (and read) of
> a struct member that is conditional in dwarf2out.h:
>
> struct GTY((chain_next ("%h.dw_loc_next"))) dw_loc_descr_node {
> ...
> #if ENABLE_CHECKING
>   /* When translating a function into a DWARF procedure, contains the frame
>  offset *before* evaluating this operation.  It is -1 when not yet
>  initialized.  */
>   int dw_loc_frame_offset;
> #endif
> };
>
>
>> hsa-gen.c:#ifdef ENABLE_CHECKING
>> hsa-regalloc.c:#ifdef ENABLE_CHECKING
>>> grep ENABLE_CHECKING ada/gcc-interface/*.[ch]
>> ada/gcc-interface/utils.c:#ifdef ENABLE_CHECKING
>
> I've just prepared patches for remaining files., btw. is it an acceptable 
> stage4 material?

I think so - we should then poison ENABLE_CHECKING in system.h

Richard.

> Thanks,
> Martin
>
>>
>>
>>> --
>>> Regards,
>>> Mikhail Maltsev
>


Re: [PATCH 10/9] ENABLE_CHECKING refactoring: remove remaining occurrences

2016-02-25 Thread Richard Biener
On Wed, Feb 24, 2016 at 4:43 PM, Pierre-Marie de Rodat
 wrote:
> On 02/24/2016 03:53 PM, Martin Liška wrote:
>>
>> On 02/24/2016 03:27 PM, Michael Matz wrote:
>>>
>>> But nothing can set ENABLE_CHECKING anymore (the macro is meanwhile
>>> called
>>> CHECKING_P), so all that code is dead anyway.  So either the new macro
>>> should be used or that code should be removed.
>>
>>
>> Good point, well the change is quite recent (12-2015). I'm adding
>> the author of the code to make a decision about it.
>
>
> Thanks for the heads up! That’s kind of funny: the check associated with
> this dw_loc_frame_offset field revealed a bug to us (at AdaCore) very
> recently, so I think we should keep it in one form or another.
>
> This field takes one int slot in the dw_loc_descr_node structure, so I guess
> not having it in release mode is important (that’s what Jason said in
> ). Here’s what I
> think:
>
>   * This field is used only in the resolve_args_picking graph traversal
> for a consistency check in already visited nodes.
>
>   * resolve_args_picking has a hash set to remember the already visited
> nodes.
>
>   * The consistency check itself has almost no runtime cost: we’re
> doing the graph traversal in release mode anyway.
>
> So what about removing the field (in struct dw_loc_descr_node) and replacing
> the visited hash set with a frame_offset hash map (in resolve_args_picking)?
> This hash map would remember the information we currently store in the
> field.

Sounds reasonable.

> This is a little change, but I can take care of this if you want. I’m a
> little bit desynchronized with the development pace these days: would this
> be for stage 4 or GCC 7?

Technically it's GCC 7 material.  Can you either change the ENABLE_CHECKING
use to CHECKING_P for GCC 6 or remove the guarded code/fields?

Thanks,
Richard.

> --
> Pierre-Marie de Rodat


Re: [WWWDocs] Deprecate support for non-thumb ARM devices

2016-02-25 Thread Richard Earnshaw (lists)
On 24/02/16 17:38, Joseph Myers wrote:
> On Wed, 24 Feb 2016, Richard Earnshaw (lists) wrote:
> 
>> After discussion with the ARM port maintainers we have decided that now
>> is probably the right time to deprecate support for versions of the ARM
>> Architecture prior to ARMv4t.  This will allow us to clean up some of
> 
> Should this include -march=armv5 and -march=armv5e (the theoretical 
> no-Thumb versions of v5, which may never have had any corresponding 
> processors)?
> 

It's a fair question, but the answer is no, this isn't necessary.

The point is to permit the compiler to use interworking compatible
sequences of code when generating ARM code, not to force users to use
Thumb code.  The necessary instruction (BX) is available in armv5 and
armv5e, even though Thumb is not supported in those architecture variants.

It might be worth deprecating v5 and v5e at some point in the future: to
the best of my knowledge no v5 class device without Thumb has ever
existed - but it's not a decision that needs to be related to this proposal.

R.


Re: [PATCH PR69052]Check if loop inv can be propagated into mem ref with additional addr expr canonicalization

2016-02-25 Thread Bin.Cheng
On Thu, Feb 25, 2016 at 6:39 AM, Jeff Law  wrote:
> On 02/22/2016 02:22 AM, Bin.Cheng wrote:
>
>>> My only question is why didn't you use FOR_EACH_SUBRTX_VRA from
>>> rtl-iter.h
>>> to walk the RTX expressions in collect_address_parts and
>>> canonicalize_address_mult?
>>
>> Hi Jeff,
>> Nothing special, just I haven't used this before, also
>> canonicalize_address_mult is alphabetically copied from fwprop.c.  One
>> question is when rewriting SHIFT to MULT, we need to modify rtl
>> expression in place, does FOR_EACH_SUBRTX iterator support this?  If
>> yes, what is the behavior for modified sub-expression?
>
> Hmm.  The question of semantics when we change the underlying
> sub-expressions is an interesting one.
>
> While I think we're OK in practice using the iterators, I think that's more
> of an accident than by design -- if MULT/ASHIFT had a different underlying
> RTL structure then I'm much less sure using the iterators would be safe.
Hi Jeff,
Yes, I thought about this too and finally decided to skip sub rtxes in
modified MULT/ASHIFT expressions.  I think this will make the patch
with FOR_EACH_SUBRTX iterator safe.  Although it doesn't dive into
MULT/ASHIFT while the original one does, I don't think there is such
case in practice, after all we can't handle such complicated address
expression either.
>
> Let's go with your original patch that didn't use the iterators.  Sorry for
> making you do the additional work/testing to build the iterator version.
Not even a problem.
> But after pondering the issue you raised, I think your original patch is
> safer.
So in conclusion, I think both versions should be safe, the iterator
one is definitely cleaner.  It is your call which version I should
apply.

Thanks,
bin
>
>
> jeff