Re: [PATCH] s390x: Fix popcounthi2_z196 expander [PR93533]

2020-02-02 Thread Andreas Krebbel
On 2/1/20 9:41 PM, Jakub Jelinek wrote:
> Hi!
> 
> The following testcase started to ICE when .POPCOUNT matching has been added
> to match.pd; we had __builtin_popcount*, but nothing would use the
> popcounthi2 expander before.
> 
> The problem is that the popcounthi2_z196 expander doesn't emit valid RTL:
> error: unrecognizable insn:
> (insn 138 137 139 27 (set (reg:SI 190)
> (ashift:SI (reg:HI 95 [ _105 ])
> (const_int 8 [0x8]))) -1
>  (nil))
> during RTL pass: vregs
> The following patch is an attempt to fix that, furthermore I've tried to
> slightly simplify it as well, it makes no sense to me to perform
> (x + (x << 8)) >> 8 when we need to either zero extend or mask the result
> at the end in order to avoid bits from above HImode to affect it, when we
> can do
> (x + (x >> 8)) & 0xff (or zero extension).
> 
> Bootstrapped/regtested on s390x-linux, ok for trunk?
Ok. Thanks for the fix!

Andreas

> 
> 2020-02-01  Jakub jelinek  
> 
>   PR target/93533
>   * config/s390/s390.md (popcounthi2_z196): Fix up expander to emit
>   valid RTL to sum up the lowest and second lowest bytes of the popcnt
>   result.
> 
> --- gcc/config/s390/s390.md.jj2020-01-12 11:54:36.412413424 +0100
> +++ gcc/config/s390/s390.md   2020-02-01 13:34:21.671431689 +0100
> @@ -11670,21 +11670,28 @@ (define_expand "popcountsi2"
>  })
>  
>  (define_expand "popcounthi2_z196"
> -  [; popcnt op0, op1
> -   (parallel [(set (match_operand:HI 0 "register_operand" "")
> +  [; popcnt op2, op1
> +   (parallel [(set (match_dup 2)
>  (unspec:HI [(match_operand:HI 1 "register_operand")]
> UNSPEC_POPCNT))
> (clobber (reg:CC CC_REGNUM))])
> -   ; sllk op2, op0, 8
> -   (set (match_dup 2)
> - (ashift:SI (match_dup 0) (const_int 8)))
> -   ; ar op0, op2
> -   (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
> +   ; lr op3, op2
> +   (set (match_dup 3) (subreg:SI (match_dup 2) 0))
> +   ; srl op4, op3, 8
> +   (set (match_dup 4) (lshiftrt:SI (match_dup 3) (const_int 8)))
> +   ; ar op3, op4
> +   (parallel [(set (match_dup 3) (plus:SI (match_dup 3) (match_dup 4)))
> (clobber (reg:CC CC_REGNUM))])
> -   ; srl op0, op0, 8
> -   (set (match_dup 0) (lshiftrt:HI (match_dup 0) (const_int 8)))]
> +   ; llgc op0, op3
> +   (parallel [(set (match_operand:HI 0 "register_operand" "")
> +(and:HI (subreg:HI (match_dup 3) 2) (const_int 255)))
> +   (clobber (reg:CC CC_REGNUM))])]
>"TARGET_Z196"
> -  "operands[2] = gen_reg_rtx (SImode);")
> +{
> +  operands[2] = gen_reg_rtx (HImode);
> +  operands[3] = gen_reg_rtx (SImode);
> +  operands[4] = gen_reg_rtx (SImode);
> +})
>  
>  (define_expand "popcounthi2"
>[(set (match_dup 2)
> --- gcc/testsuite/gcc.c-torture/compile/pr93533.c.jj  2020-02-01 
> 13:44:16.296681108 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr93533.c 2020-02-01 
> 13:43:52.034038073 +0100
> @@ -0,0 +1,9 @@
> +/* PR target/93533 */
> +
> +unsigned
> +foo (unsigned short a)
> +{
> +  a = a - (a >> 1 & 21845);
> +  a = (a & 13107) + (a >> 2 & 13107);
> +  return (unsigned short) ((a + (a >> 4) & 3855) * 257) >> 8;
> +}
> --- gcc/testsuite/gcc.target/s390/pr93533.c.jj2020-02-01 
> 13:45:41.433428499 +0100
> +++ gcc/testsuite/gcc.target/s390/pr93533.c   2020-02-01 13:45:32.984552824 
> +0100
> @@ -0,0 +1,5 @@
> +/* PR target/93533 */
> +/* { dg-do compile } */
> +/* { dg-options "-march=z196 -O2" } */
> +
> +#include "../../gcc.c-torture/compile/pr93533.c"
> 
>   Jakub
> 



[PATCH Coroutines]Insert the default return_void call at correct position

2020-02-02 Thread bin.cheng
Hi,

Exception in coroutine is not correctly handled because the default
return_void call is now inserted before the finish suspend point,
rather than at the end of the original coroutine body.  This patch
fixes the issue by generating following code:
  co_await promise.initial_suspend();
  try {
// The original coroutine body

promise.return_void(); // The default return_void call.
  } catch (...) {
promise.unhandled_exception();
  }
  final_suspend:
  // ...

Bootstrap and test on x86_64.  Is it OK?

Thanks,
bin

gcc/cp
2020-02-03  Bin Cheng  

* coroutines.cc (build_actor_fn): Factor out code inserting the
default return_void call to...
(morph_fn_to_coro): ...here, also hoist local var declarations.

gcc/testsuite
2020-02-03  Bin Cheng  

* g++.dg/coroutines/torture/co-ret-15-default-return_void.C: New.

0001-Insert-default-return_void-at-the-end-of-coroutine-b.patch
Description: Binary data


Re: [PATCH Coroutines v1] Handle type deduction of auto and decltype(auto) with indirect_ref expression

2020-02-02 Thread JunMa

在 2020/2/3 上午9:03, JunMa 写道:

在 2020/1/28 上午12:01, Nathan Sidwell 写道:

On 1/21/20 6:21 AM, JunMa wrote:

Hi
When test gcc with cppcoro, I find case like:

   int& awaitable::await_resume()
   auto x1 = co_await awaitable;
   decltype(auto) x2 = co_await awaitable;

Based on standard, typeof(x1) should be int, typeof(x2) is int&.
However, we get both x1 and x2 as int, this because we donot
consider indirect_ref which wrap await_resume call expression
(convert_from_reference), and it is invoked into type deduction
of auto and decltype(auto).

This patch wrap co_await expression with indirect_ref which should be
same with await_resume expression, and it sink await_resume expression
to real call_expr when replace co_await expression. it fix type 
deduction

of auto and decltype(auto) in coroutine.

Bootstrap and test on X86_64, is it OK?


+  /* Wrap co_await_expr.  */
+  if (TREE_CODE (awrs_call) == INDIRECT_REF)
+    await_expr = build1_loc (loc, INDIRECT_REF, TREE_TYPE (awrs_call),
+ await_expr);

I think all you want here is:
  await_expr = convert_from_reference (await_expr);


Thanks, I'll update it.

Regards
JunMa

Hi nathan,
Here is the update.

Regards
JunMa

gcc/cp
2020-02-03  Jun Ma 

 * coroutines.cc (build_co_await): Call convert_from_reference
 to wrap co_await_expr with indirect_ref which avoid
 reference/non-reference type confusion.

 (co_await_expander):  Sink to call_expr if await_resume
 is wrapped by indirect_ref.

gcc/testsuite
2020-02-03  Jun Ma 

 * g++.dg/coroutines/co-await-14-return-ref-to-auto.C: New test.




Regards
JunMa

gcc/cp
2020-01-21  Jun Ma 

 * coroutines.cc (build_co_await): Wrap co_await with
 indirect_ref when needed.
 (co_await_expander):  Sink to call_expr if await_resume
 is wrapped by indirect_ref.

gcc/testsuite
2020-01-21  Jun Ma 

 * g++.dg/coroutines/co-await-14-return-ref-to-auto.C: Add 
label.





---
 gcc/cp/coroutines.cc  | 12 +++--
 .../torture/co-await-14-return-ref-to-auto.C  | 45 +++
 2 files changed, 54 insertions(+), 3 deletions(-)
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/co-await-14-return-ref-to-auto.C

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 62d92d9fc98..e7a150d257f 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -749,9 +749,12 @@ build_co_await (location_t loc, tree a, suspend_point_kind 
suspend_kind)
   TREE_VEC_ELT (awaiter_calls, 1) = awsp_call; /* await_suspend().  */
   TREE_VEC_ELT (awaiter_calls, 2) = awrs_call; /* await_resume().  */
 
-  return build5_loc (loc, CO_AWAIT_EXPR, TREE_TYPE (awrs_call), a,
-e_proxy, o, awaiter_calls,
-build_int_cst (integer_type_node, (int) suspend_kind));
+  tree await_expr = build5_loc (loc, CO_AWAIT_EXPR,
+   TREE_TYPE (TREE_TYPE (awrs_func)),
+   a, e_proxy, o, awaiter_calls,
+   build_int_cst (integer_type_node,
+  (int) suspend_kind));
+  return convert_from_reference (await_expr);
 }
 
 tree
@@ -1512,6 +1515,9 @@ co_await_expander (tree *stmt, int * /*do_subtree*/, void 
*d)
   /* This will produce the value (if one is provided) from the co_await
  expression.  */
   tree resume_call = TREE_VEC_ELT (awaiter_calls, 2); /* await_resume().  */
+  if (TREE_CODE (resume_call) == INDIRECT_REF)
+/* Sink to await_resume call_expr.  */
+resume_call = TREE_OPERAND (resume_call, 0);
   switch (stmt_code)
 {
 default: /* not likely to work .. but... */
diff --git 
a/gcc/testsuite/g++.dg/coroutines/torture/co-await-14-return-ref-to-auto.C 
b/gcc/testsuite/g++.dg/coroutines/torture/co-await-14-return-ref-to-auto.C
new file mode 100644
index 000..0a7c035ef2a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/torture/co-await-14-return-ref-to-auto.C
@@ -0,0 +1,45 @@
+//  { dg-do run }
+
+/* The simplest valued co_await we can do.  */
+
+#include "../coro.h"
+
+// boiler-plate for tests of codegen
+#include "../coro1-ret-int-yield-int.h"
+
+
+coro1
+f ()
+{
+  int t1 = 5;
+  int t2 = 5;
+  auto gX = co_await coro1::suspend_always_intrefprt{t1};
+  if (gX != t1)
+ abort();
+  decltype(auto) gX1 = co_await coro1::suspend_always_intrefprt{t2};
+  if ( != )
+ abort();
+  co_return t1 + 10;
+}
+
+int main ()
+{
+  PRINT ("main: create coro1");
+  struct coro1 f_coro = f ();
+  if (f_coro.handle.done())
+{
+  PRINT ("main: we should not be 'done' [1]");
+  abort ();
+}
+  PRINT ("main: resuming [1] initial suspend");
+  while (!f_coro.handle.done())
+f_coro.handle.resume();
+  /* we should now have returned with the co_return (15) */
+  if (!f_coro.handle.done())
+{
+  PRINT ("main: we should be 'done' ");
+  abort ();
+}
+  puts ("main: done");
+  return 0;
+}
-- 

Ping* [PATCH V2] Generalized value pass-through for self-recursive function (ipa/pr93203)

2020-02-02 Thread Feng Xue OS
Thanks,
Feng


From: Feng Xue OS 
Sent: Saturday, January 25, 2020 9:50 PM
To: mjam...@suse.cz; Jan Hubicka; gcc-patches@gcc.gnu.org
Subject: [PATCH V2] Generalized value pass-through for self-recursive function 
(ipa/pr93203)

Made some changes.

Feng


From: Feng Xue OS
Sent: Saturday, January 25, 2020 5:54 PM
To: mjam...@suse.cz; Jan Hubicka; gcc-patches@gcc.gnu.org
Subject: [PATCH] Generalized value pass-through for self-recursive function 
(ipa/pr93203)

Besides simple pass-through (aggregate) jump function, arithmetic (aggregate)
jump function could also bring same (aggregate) value as parameter passed-in
for self-feeding recursive call.  For example,

  f1 (int i)/*  normal jump function */
 {
f1 (i & 1);
 }

Suppose i is 0, recursive propagation via (i & 1) also gets 0, which
can be seen as a simple pass-through of i.

  f2 (int *p)  /* aggregate jump function */
 {
int t = *p & 1;
f2 ();
 }
Likewise, if *p is 0, (*p & 1) is also 0, and  is an aggregate simple
pass-through of p.

This patch is to support these two kinds of value pass-through.
Bootstrapped/regtested on x86_64-linux and aarch64-linux.

Feng

---
2020-01-25  Feng Xue  

PR ipa/93203
* ipa-cp.c (ipcp_lattice::add_value): Add source with same call
edge but different source value.
(adjust_callers_for_value_intersection): New function.
(gather_edges_for_value): Adjust order of callers to let a
non-self-recursive caller be the first element.
(self_recursive_pass_through_p): Add a new parameter simple, and
check generalized self-recursive pass-through jump function.
(self_recursive_agg_pass_through_p): Likewise.
(find_more_scalar_values_for_callers_subset): Compute value from
pass-through jump function for self-recursive.
(intersect_with_plats): Remove code of itersection with unknown
place holder value.
(intersect_with_agg_replacements): Likewise.
(intersect_aggregates_with_edge): Deduce with from pass-through
jump function for self-recursive.
(decide_whether_version_node): Remove dead callers and adjust
order to let a non-self-recursive caller be the first element.

From 74aef0cd2f40ff828a4b2abcbbdbbf4b1aea1fcf Mon Sep 17 00:00:00 2001
From: Feng Xue 
Date: Tue, 21 Jan 2020 20:53:38 +0800
Subject: [PATCH] Generalized value pass-through for self-recusive function

---
 gcc/ipa-cp.c   | 195 ++---
 gcc/testsuite/g++.dg/ipa/pr93203.C |  95 ++
 gcc/testsuite/gcc.dg/ipa/ipcp-1.c  |   2 +-
 3 files changed, 216 insertions(+), 76 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr93203.C

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 17da1d8e8a7..64d23a34292 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -1850,7 +1850,7 @@ ipcp_lattice::add_value (valtype newval, cgraph_edge *cs,
 	  {
 	ipcp_value_source *s;
 	for (s = val->sources; s; s = s->next)
-	  if (s->cs == cs)
+	  if (s->cs == cs && s->val == src_val)
 		break;
 	if (s)
 	  return false;
@@ -4207,6 +4207,33 @@ get_info_about_necessary_edges (ipcp_value *val, cgraph_node *dest,
   return hot;
 }
 
+/* Given a NODE, and a set of its CALLERS, try to adjust order of the callers
+   to let a non-self-recursive caller be the first element.  Thus, we can
+   simplify intersecting operations on values that arrive from all of these
+   callers, especially when there exists self-recursive call.  Return true if
+   this kind of adjustment is possible.  */
+
+static bool
+adjust_callers_for_value_intersection (vec callers,
+   cgraph_node *node)
+{
+  for (unsigned i = 0; i < callers.length (); i++)
+{
+  cgraph_edge *cs = callers[i];
+
+  if (cs->caller != node)
+	{
+	  if (i > 0)
+	{
+	  callers[i] = callers[0];
+	  callers[0] = cs;
+	}
+	  return true;
+	}
+}
+  return false;
+}
+
 /* Return a vector of incoming edges that do bring value VAL to node DEST.  It
is assumed their number is known and equal to CALLER_COUNT.  */
 
@@ -4230,6 +4257,9 @@ gather_edges_for_value (ipcp_value *val, cgraph_node *dest,
 	}
 }
 
+  if (caller_count > 1)
+adjust_callers_for_value_intersection (ret, dest);
+
   return ret;
 }
 
@@ -4241,7 +4271,6 @@ get_replacement_map (class ipa_node_params *info, tree value, int parm_num)
 {
   struct ipa_replace_map *replace_map;
 
-
   replace_map = ggc_alloc ();
   if (dump_file)
 {
@@ -4592,36 +4621,40 @@ create_specialized_node (struct cgraph_node *node,
 }
 
 /* Return true, if JFUNC, which describes a i-th parameter of call CS, is a
-   simple no-operation pass-through function to itself.  */
+   pass-through function to itself.  When SIMPLE is true, further check if
+   JFUNC is a simple no-operation pass-through.  */
 
 

Re: [PATCH Coroutines] Handle type deduction of auto and decltype(auto) with indirect_ref expression

2020-02-02 Thread JunMa

在 2020/1/28 上午12:01, Nathan Sidwell 写道:

On 1/21/20 6:21 AM, JunMa wrote:

Hi
When test gcc with cppcoro, I find case like:

   int& awaitable::await_resume()
   auto x1 = co_await awaitable;
   decltype(auto) x2 = co_await awaitable;

Based on standard, typeof(x1) should be int, typeof(x2) is int&.
However, we get both x1 and x2 as int, this because we donot
consider indirect_ref which wrap await_resume call expression
(convert_from_reference), and it is invoked into type deduction
of auto and decltype(auto).

This patch wrap co_await expression with indirect_ref which should be
same with await_resume expression, and it sink await_resume expression
to real call_expr when replace co_await expression. it fix type 
deduction

of auto and decltype(auto) in coroutine.

Bootstrap and test on X86_64, is it OK?


+  /* Wrap co_await_expr.  */
+  if (TREE_CODE (awrs_call) == INDIRECT_REF)
+    await_expr = build1_loc (loc, INDIRECT_REF, TREE_TYPE (awrs_call),
+ await_expr);

I think all you want here is:
  await_expr = convert_from_reference (await_expr);


Thanks, I'll update it.

Regards
JunMa


Regards
JunMa

gcc/cp
2020-01-21  Jun Ma 

 * coroutines.cc (build_co_await): Wrap co_await with
 indirect_ref when needed.
 (co_await_expander):  Sink to call_expr if await_resume
 is wrapped by indirect_ref.

gcc/testsuite
2020-01-21  Jun Ma 

 * g++.dg/coroutines/co-await-14-return-ref-to-auto.C: Add 
label.







Re: [wwwdocs] Mention powerpc*-*-*spe* deprecation in gcc-8/changes.html

2020-02-02 Thread Gerald Pfeifer
On Wed, 18 Apr 2018, Jakub Jelinek wrote:
> The following patch mentions the deprecation of powerpc*spe*.

I know it's a little, ahem, late, but I applied this follow-up
patch to avoid a link with the text "here".  (More specific text
is generally recommended by user design guidelines.)

Gerald


commit 1eed7f705ad5153ac835cf6433ce07538e400fa8
Author: Gerald Pfeifer 
Date:   Sun Feb 2 23:48:17 2020 +0100

Make a "here" link text more specific.

diff --git a/htdocs/gcc-8/changes.html b/htdocs/gcc-8/changes.html
index ddc7e824..636552ab 100644
--- a/htdocs/gcc-8/changes.html
+++ b/htdocs/gcc-8/changes.html
@@ -42,8 +42,8 @@ You may also want to check out our
   
   Support for the powerpc*-*-*spe* target ports which have
 been recently unmaintained and untested in GCC has been declared
-obsolete in GCC 8 as announced
-https://gcc.gnu.org/ml/gcc/2018-04/msg00102.html;>here.
+obsolete in GCC 8 as
+https://gcc.gnu.org/ml/gcc/2018-04/msg00102.html;>announced.
 Unless there is activity to revive them, the
 next release of GCC will have their sources permanently
 removed.


Re: [PATCH] c++: Fix ICE on invalid alignas in a template [PR93530]

2020-02-02 Thread Jason Merrill

On 1/31/20 8:06 PM, Marek Polacek wrote:

This fixes an ICE taking place in cp_default_conversion because we got
a SCOPE_REF that doesn't have a type and so checking
INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (exp)) will crash.
This happens since the recent Joseph's change in decl_attributes whereby
we don't skip C++11 attributes on types.

[dcl.align] is clear that alignas applied to a function is ill-formed.
That should be fixed, and we have PR90847 for that.  But I think a more
appropriate fix at this stage would be the following: in a template we
want to splice dependent attributes and save them for later, and by
doing so avoid this crash.

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


OK.



PR c++/93530 - ICE on invalid alignas in a template.
* decl.c (grokdeclarator): Call cplus_decl_attributes instead of
decl_attributes.



* g++.dg/cpp0x/alignas18.C: New test.
---
  gcc/cp/decl.c  | 2 +-
  gcc/testsuite/g++.dg/cpp0x/alignas18.C | 8 
  2 files changed, 9 insertions(+), 1 deletion(-)
  create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas18.C

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6ad558eef9e..576cbd8643a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -12300,7 +12300,7 @@ grokdeclarator (const cp_declarator *declarator,
  
  		 The optional attribute-specifier-seq appertains to

 the function type.  */
- decl_attributes (, attrs, 0);
+ cplus_decl_attributes (, attrs, 0);
  
  	if (raises)

  type = build_exception_variant (type, raises);
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas18.C 
b/gcc/testsuite/g++.dg/cpp0x/alignas18.C
new file mode 100644
index 000..820bdd2d7ca
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alignas18.C
@@ -0,0 +1,8 @@
+// PR c++/93530 - ICE on invalid alignas in a template.
+// { dg-do compile { target c++11 } }
+
+template  struct S {
+  using U = S;
+  // FIXME: This is ill-formed; see PR90847.
+  void fn() alignas(U::X);
+};

base-commit: 2a07345c4f8dabc286fc470e76c53473e5bc3eb7





[committed] testsuite,Darwin,PPC: Adjust darwin-abi-12.c for common section use.

2020-02-02 Thread Iain Sandoe
Hi,

Another in the series of amendments following the switch to 
default to no-common.

Tested on powerpc-darwin9,
applied to master,
thanks
Iain

--

This test explicitly tests for code generation that expects a
common section.

gcc/testsuite/ChangeLog:

2020-02-02  Iain Sandoe  

* gcc.target/powerpc/darwin-abi-12.c: Add '-fcommon' to the
options.

---
 gcc/testsuite/ChangeLog  | 5 +
 gcc/testsuite/gcc.target/powerpc/darwin-abi-12.c | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 779f1fbb457..05620402c8a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-02  Iain Sandoe  
+
+   * gcc.target/powerpc/darwin-abi-12.c: Add '-fcommon' to the
+   options.
+
 2020-02-02  Vladimir Makarov  
 
PR rtl-optimization/91333
diff --git a/gcc/testsuite/gcc.target/powerpc/darwin-abi-12.c 
b/gcc/testsuite/gcc.target/powerpc/darwin-abi-12.c
index 5f5764368c1..e77969c2635 100644
--- a/gcc/testsuite/gcc.target/powerpc/darwin-abi-12.c
+++ b/gcc/testsuite/gcc.target/powerpc/darwin-abi-12.c
@@ -1,4 +1,6 @@
 /* { dg-do compile { target powerpc*-*-darwin* } } */
+/* This test explicitly checks for output that expects common.  */
+/* { dg-additional-options "-fcommon" { target powerpc*-*-darwin* } } */
 /* { dg-final { scan-assembler ".comm\[\t \]_x,12,2" } } */
 /* { dg-final { scan-assembler-not ".space 7" } } */
 /* PR 23071 */
-- 
2.24.1




One more patch for PR91333

2020-02-02 Thread Vladimir Makarov

  The previous patch for

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91333

resulted in aarch64 testsuite failures.

The following patch solves some of the failures and modified the PR test 
as the generated code changed.


The patch was successfully bootstrapped on x86-64 and benchmarked on 
SPEC2000.



commit 897a73086b2d63a5a6ae79f4276422272eca534d (HEAD -> master, origin/master, origin/HEAD)
Author: Vladimir N. Makarov 
Date:   Sun Feb 2 11:23:25 2020 -0500

One more fix for PR 91333 - suboptimal register allocation for inline asm

2020-02-02  Vladimir Makarov  

PR rtl-optimization/91333
* ira-color.c (struct allocno_color_data): Add member
hard_reg_prefs.
(init_allocno_threads): Set the member up.
(bucket_allocno_compare_func): Add compare hard reg
prefs.

2020-02-02  Vladimir Makarov  

PR rtl-optimization/91333
* gcc.target/i386/pr91333.c: Add vmovsd to regexp.  Set up count
to 3.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b2031eea3fb..3c0f1176ead 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2020-02-02  Vladimir Makarov  
+
+	PR rtl-optimization/91333
+	* ira-color.c (struct allocno_color_data): Add member
+	hard_reg_prefs.
+	(init_allocno_threads): Set the member up.
+	(bucket_allocno_compare_func): Add compare hard reg
+	prefs.
+
 2020-01-31  Sandra Loosemore  
 
 	nios2: Support for GOT-relative DW_EH_PE_datarel encoding.
diff --git a/gcc/ira-color.c b/gcc/ira-color.c
index 51c4afd6391..444cb1e8279 100644
--- a/gcc/ira-color.c
+++ b/gcc/ira-color.c
@@ -151,6 +151,8 @@ struct allocno_color_data
   ira_allocno_t next_thread_allocno;
   /* All thread frequency.  Defined only for first thread allocno.  */
   int thread_freq;
+  /* Sum of frequencies of hard register preferences of the allocno.  */
+  int hard_reg_prefs;
 };
 
 /* See above.  */
@@ -2173,6 +2175,7 @@ init_allocno_threads (void)
   ira_allocno_t a;
   unsigned int j;
   bitmap_iterator bi;
+  ira_pref_t pref;
 
   EXECUTE_IF_SET_IN_BITMAP (consideration_allocno_bitmap, 0, j, bi)
 {
@@ -2181,6 +2184,9 @@ init_allocno_threads (void)
   ALLOCNO_COLOR_DATA (a)->first_thread_allocno
 	= ALLOCNO_COLOR_DATA (a)->next_thread_allocno = a;
   ALLOCNO_COLOR_DATA (a)->thread_freq = ALLOCNO_FREQ (a);
+  ALLOCNO_COLOR_DATA (a)->hard_reg_prefs = 0;
+  for (pref = ALLOCNO_PREFS (a); pref != NULL; pref = pref->next_pref)
+	ALLOCNO_COLOR_DATA (a)->hard_reg_prefs += pref->freq;
 }
 }
 
@@ -2251,6 +2257,11 @@ bucket_allocno_compare_func (const void *v1p, const void *v2p)
   ira_allocno_t t2 = ALLOCNO_COLOR_DATA (a2)->first_thread_allocno;
   int cl1 = ALLOCNO_CLASS (a1), cl2 = ALLOCNO_CLASS (a2);
 
+  /* Push allocnos with minimal hard_reg_prefs first.  */
+  pref1 = ALLOCNO_COLOR_DATA (a1)->hard_reg_prefs;
+  pref2 = ALLOCNO_COLOR_DATA (a2)->hard_reg_prefs;
+  if ((diff = pref1 - pref2) != 0)
+return diff;
   /* Push allocnos with minimal conflict_allocno_hard_prefs first.  */
   pref1 = ALLOCNO_COLOR_DATA (a1)->conflict_allocno_hard_prefs;
   pref2 = ALLOCNO_COLOR_DATA (a2)->conflict_allocno_hard_prefs;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5902ab6bb85..779f1fbb457 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2020-02-02  Vladimir Makarov  
+
+	PR rtl-optimization/91333
+	* gcc.target/i386/pr91333.c: Add vmovsd to regexp.  Set up count
+	to 3.
+
 2020-01-31  Sandra Loosemore  
 
 	nios2: Support for GOT-relative DW_EH_PE_datarel encoding.
diff --git a/gcc/testsuite/gcc.target/i386/pr91333.c b/gcc/testsuite/gcc.target/i386/pr91333.c
index 41fc328698e..269491202ae 100644
--- a/gcc/testsuite/gcc.target/i386/pr91333.c
+++ b/gcc/testsuite/gcc.target/i386/pr91333.c
@@ -1,6 +1,6 @@
 /* { dg-do compile { target x86_64-*-* } } */
 /* { dg-options "-O2 -mavx" } */
-/* { dg-final { scan-assembler-times "vmovapd" 2 } } */
+/* { dg-final { scan-assembler-times "vmovapd|vmovsd" 3 } } */
 
 static inline double g (double x){
   asm volatile ("" : "+x" (x));


Re: [PATCH] Add --with-diagnostics-urls configuration option and GCC_URLS/TERM_URLS env var

2020-02-02 Thread Bernd Edlinger
On 2/2/20 1:28 AM, Sandra Loosemore wrote:
> On 2/1/20 8:43 AM, Bernd Edlinger wrote:
> 
>> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
>> index 6ffafac..1d3fec5 100644
>> --- a/gcc/doc/install.texi
>> +++ b/gcc/doc/install.texi
>> @@ -2097,9 +2097,18 @@ option (if not used explicitly on the command line).  
>> @var{choice}
>>  can be one of @samp{never}, @samp{auto}, @samp{always}, and 
>> @samp{auto-if-env}
>>  where @samp{auto} is the default.  @samp{auto-if-env} means that
>>  @option{-fdiagnostics-color=auto} will be the default if @code{GCC_COLORS}
>> -is present and non-empty in the environment, and
>> +is present and non-empty in the environment of the compiler, and
>>  @option{-fdiagnostics-color=never} otherwise.
>>  
>> +@item --with-diagnostics-urls=@var{choice}
>> +Tells GCC to use @var{choice} as the default for 
>> @option{-fdiagnostics-urls=}
>> +option (if not used explicitly on the command line).  @var{choice}
>> +can be one of @samp{never}, @samp{auto}, @samp{always}, and 
>> @samp{auto-if-env}
>> +where @samp{auto} is the default.  @samp{auto-if-env} means that
>> +@option{-fdiagnostics-urls=auto} will be the default if @env{GCC_URLS}
>> +or @env{TERM_URLS} is present and non-empty in the environment of the
>> +compiler, and @option{-fdiagnostics-urls=never} otherwise.
>> +
> 
> It would be good to rewrite both of the above paragraphs to get rid of the 
> future tense and put them in the active voice, like
> 
> @samp{auto-if-env} makes ... the default if ...
> 

done.

> Also @code{GCC_COLORS} ought to be @env{GCC_COLORS}, no?
> 

right.

>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>> index b8ba8a3..59306bc 100644
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -4032,14 +4032,41 @@ arguments in the C++ frontend.
>>  @item -fdiagnostics-urls[=@var{WHEN}]
>>  @opindex fdiagnostics-urls
>>  @cindex urls
>> +@vindex GCC_URLS @r{environment variable}
>> +@vindex TERM_URLS @r{environment variable}
>>  Use escape sequences to embed URLs in diagnostics.  For example, when
>>  @option{-fdiagnostics-show-option} emits text showing the command-line
>>  option controlling a diagnostic, embed a URL for documentation of that
>>  option.
>>  
>>  @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
>> -The default is @samp{auto}, which means to use URL escape sequences only
>> -when the standard error is a terminal.
>> +@samp{auto} means to use URL escape sequences only when the standard error
>> +is a terminal, and @env{TERM} is not set to "dumb".
> 
> We should avoid literal quotes in the manual instead of proper markup. Maybe 
> @samp{dumb}?  Or is this trying to express something other than a literal 
> string?
> 

okay, in this case, maybe it gets clearer when I write:

"standard error is a terminal, and when not executing in an emacs shell."

I moved the "dumb" to a comment in the C-function doing that detection
now, and consider it an implementation detail for the emacs detection.


>> +
>> +The default depends on how the compiler has been configured.
>> +It can be any of the above @var{WHEN} options.
>> +
>> +GCC can also be configured (via the
>> +@option{--with-diagnostics-urls=auto-if-env} configure-time option)
>> +so that the default is affected by environment variables.
>> +Under such a configuration, GCC defaults to using @samp{auto}
>> +if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
>> +present and non-empty in the environment of the compiler, or @samp{never}
>> +if neither are.
>> +
>> +However, even with @option{-fdiagnostics-urls=always} the behavior will be
> 
> s/will be/is/, unless this is something that hasn't been implemented yet.  :-S
> 

okay, thanks.

>> +dependent on those environment variables:
>> +If @env{GCC_URLS} set to empty or "no", do not embed URLs in diagnostics.
> 
> s/set/is set/ ??
> 

yes.

> And please avoid literal quotes in the text here too.
> 

done.

>> +If set to "st", URLs use ST escape sequences.
>> +If set to "bel", the default, URLs use BEL escape sequences.
> 
> I have no idea what ST and BEL escape sequences are
> 

those are the acronyms of certain escape sequences, I added an explanation.

>> +Any other non-empty value enables the feature.
>> +If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
>> +
>> +At this time GCC tries to detect also a few terminals that are known to
>> +not implement the URL feature, and have an installed basis where the URL
> 
> What is "an installed basis"?
> 

I meant that old versions are still installed on a lot of places,
and we do not want to break them.
I re-worded that paragraph, to be hopefully clearer now.

>> +escapes are likely to mis-behave, i.e. print garbage on the screen.
> 
> s/mis-behave/misbehave/
> 

done.

>> +That list is currently xfce4-terminal and tmux and mingw, this can be
>> +overridden with the @option{-fdiagnostics-urls=always}.
> 
> Are those things literal strings for something?  How do you use that 

Re: libgo patch committed: Update to Go1.14beta1

2020-02-02 Thread Andreas Schwab
I'm getting these errors on aarch64 with -mabi=ilp32:

../../../../libgo/go/runtime/mpagealloc.go:226:38: error: shift count overflow
  226 |  chunks [1 << pallocChunksL1Bits]*[1 << pallocChunksL2Bits]pallocData
  |  ^
../../../../libgo/go/runtime/mgcscavenge.go:487:15: error: shift count overflow
  487 |l2 := (*[1 << 
pallocChunksL2Bits]pallocData)(atomic.Loadp(unsafe.Pointer([i.l1()])))
  |   ^
../../../../libgo/go/runtime/mpagealloc.go:138:22: error: shift count overflow
  138 |   return uint(i) & (1<> pallocChunksL1Shift
  | ^
../../../../libgo/go/runtime/mpagealloc_64bit.go:34:2: error: integer constant 
overflow
   34 |  summaryL0Bits,
  |  ^

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [Patch] [OpenMP] Add missing parameters to omp_lib documentation (PR fortran/93541)

2020-02-02 Thread Thomas Koenig

Hi Tobias,


OK? – And for which branches?


OK for all branches (assuming you checked with "make pdf" and
"make dvi").

Thanks for doing this - our documentation is not always quite
up to date...

Regards

Thomas


[Patch] [OpenMP] Add missing parameters to omp_lib documentation (PR fortran/93541)

2020-02-02 Thread Tobias Burnus
I recently stumbled over the intrinsic module documentation and wondered 
whether it was complete. Answer: It wasn't. Cf. 
https://gcc.gnu.org/onlinedocs/gfortran/OpenMP-Modules-OMP_005fLIB-and-OMP_005fLIB_005fKINDS.html


Pause was added 8th Nov 2018 → GCC 9. The lock hint already 2015-10-13. 
Hence, the patch "as is" applies also to GCC 9 while for GCC 8, one has 
to remove the "pause" bit before applying.


OK? – And for which branches?

Tobias

	PR fortran/93541
	* intrinisic.texi (OpenMP Modules OMP_LIB and OMP_LIB_KINDS):
	Add undocumented parameters from omp_lib.f90.in.

diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 823cb9cef30..842c88b2eba 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -15307,13 +15307,16 @@ below.
 For details refer to the actual
 @uref{http://www.openmp.org/wp-content/uploads/openmp-4.5.pdf,
 OpenMP Application Program Interface v4.5}.
+And for the @code{pause}-related constants to the OpenMP 5.0 specification.
 
 @code{OMP_LIB_KINDS} provides the following scalar default-integer
 named constants:
 
 @table @asis
 @item @code{omp_lock_kind}
+@item @code{omp_lock_hint_kind}
 @item @code{omp_nest_lock_kind}
+@item @code{omp_pause_resource_kind}
 @item @code{omp_proc_bind_kind}
 @item @code{omp_sched_kind}
 @end table
@@ -15344,6 +15347,24 @@ kind @code{omp_proc_bind_kind}:
 @item @code{omp_proc_bind_spread}
 @end table
 
+The following scalar integer named constants are of the
+kind @code{omp_lock_hint_kind}:
+
+@table @asis
+@item @code{omp_lock_hint_none}
+@item @code{omp_lock_hint_uncontended}
+@item @code{omp_lock_hint_contended}
+@item @code{omp_lock_hint_nonspeculative}
+@item @code{omp_lock_hint_speculative}
+@end table
+
+And the following two scalar integer named constants are of the
+kind @code{omp_pause_resource_kind}:
+
+@table @asis
+@item @code{omp_pause_soft}
+@item @code{omp_pause_hard}
+@end table
 
 
 @node OpenACC Module OPENACC


Re: [PATCH] Add --with-diagnostics-urls configuration option and GCC_URLS/TERM_URLS env var

2020-02-02 Thread Bernd Edlinger
On 2/2/20 12:05 AM, Segher Boessenkool wrote:
> On Sat, Feb 01, 2020 at 05:21:30PM +, Bernd Edlinger wrote:
>> On 2/1/20 6:12 PM, Jakub Jelinek wrote:
>>> On Sat, Feb 01, 2020 at 03:43:20PM +, Bernd Edlinger wrote:
 I seem to remember him saying that he always has to configure with
 --with-diagnostics-color=never, and the URLs are on top of that.
 But there was no configure option for that, which, given his explanation,
 made immediately sense to me.

 In the case of the xfce terminal, the color thing was always working fine,
 but beginning with last october, the warnings look just terrible.

 If that assumption turns out to be wrong, we can easily move that check 
 from
 the auto_color to the auto_url code, or add more terminals which are
 of that kind.
>>>
>>> For me colors work just fine in screen, it really depends on which
>>> terminals one is attaching the screen from.
>>> URLs don't work, but show up exactly as if they were disabled, no visual nor
>>> accoustic problems with those (and work fine in gnome-terminal which is
>>> recent).
>>> That said, my TERM is actually screen.xterm-256color rather than just screen
>>> (and xterm-256color in gnome-terminal).
>>
>> Okay, thanks.  That is a strong indication that there is no need
>> to interfere with screen, which proves that any auto-disabling should
>> have a very specific terminal detection logic.
> 
> Jakub says that he tested with a recent gnome-terminal.  That works, of
> course.  Mnay other terminals will not, and switching what terminal is
> attached to your screen session will not work well either, as far as I
> can tell.
> 

I understood his statement, that the URLs are stripped from the data
stream by screen and are no longer visible, even if the terminal would
support them i.e. you connect from a gnome-terminal.
But work fine when the compiler runs natively in a gnome-terminal.

Or does screen pass the URL escapes thru to any terminal wether or not
the produce garbage?


Bernd.