Re: [PATCH] VEC_COND_EXPR: clean up first argument

2020-06-25 Thread Martin Liška

On 6/24/20 4:15 PM, Richard Biener wrote:

On Wed, Jun 24, 2020 at 11:27 AM Martin Liška  wrote:


On 6/24/20 11:09 AM, Richard Biener wrote:

On Wed, Jun 24, 2020 at 10:49 AM Martin Liška  wrote:


On 6/24/20 9:43 AM, Richard Biener wrote:

Hmm, can you instead use simple_dce_from_worklist and simply
record all SSA_NAMEs you end up "forwarding" as possibly dead
in a bitmap?  At least that hashmap traversal looks dangerous
with respect to address-space randomization and gsi_remove
inserting debug stmts and thus eventually allocating debug decls.


Sure, done in the updated patch.


You can simplify the patch by eliding the num_imm_uses checks


Really? How can I be sure that a SSA_NAME is not shared among different
VEC_COND_EXPR statements (or even by some other statements)?


The bitmap DCE does this check for you.


and by using auto_bitmap.


Oh yeah!


  Why is it necessary to update
the veclower pass btw?  Is that just to avoid useless isels
on dead code?


Yes:

_10 = _9 != { 0, 0, 0, 0 };
_11 = *a_16(D);
_12 = *b_17(D);
_13 = _11 + _12;
_14 = VEC_COND_EXPR <_10, _13, { 3.0e+0, 3.0e+0, 3.0e+0, 3.0e+0 }>;

is expanded by vectlower to something like:

_10 = _9 != { 0, 0, 0, 0 };
_11 = *a_16(D);
_12 = *b_17(D);
_67 = BIT_FIELD_REF <_11, 32, 0>;
_68 = BIT_FIELD_REF <_12, 32, 0>;
_69 = _67 + _68;
...
_14 = {_80, _82, _84, _86};
*a_16(D) = _14;

So one needs to remove: _10 = _9 != { 0, 0, 0, 0 };
Note the ICE happens without an optimization level.


Ah, OK.  That makes sense.





You also updated veclower "nicely" but still have the hashmap
walk in isel - you should know when you "merged" a condition
into a cond and set the bit there.


Isn't the same as before as the first argument can be actually shared in between
multiple GIMPLE statements?


As said above the bitmap DCE is built for lazy consumption.


All right, I'm going to push a patch with that changed.

Martin



Richard.


Thanks,
Martin



Richard.


Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin







[PATCH] Fortran : Fill in missing array dimensions using the lower, bound (for review)

2020-06-25 Thread Mark Eggleston
Please find attached a proposed legacy extension to allow dimensions to 
be omitted when referring to an array element.  The declared lower bound 
being used by default.


This feature is known to exist in earlier compilers and is believed to 
be a DEC extension and is definitely supported by flang.  As it is 
non-standard the feature will only be enabled using 
-fdec-add-missing-indexes (and -fdec), a warning will be produced when 
used.  As warnings are commonly regarded as errors in build environments 
-Wno-missing-index has be provided to suppress the warning if needed.


Commit message:

Fortran  : Fill in missing array dimensions using the lower bound

Use -fdec-add-missing-indexes to enable feature. Also enabled by fdec.
A warning that the lower bound is being used for a mission dimension
is output unless suppressed by using -Wno-missing-index.

2020-06-25  Jim MacArthur 
        Mark Eggleston  

gcc/fortran/

    * lang.opt: Add options -Wmissing-index and
    -fdec-add-missing-indexes.
    * options.c (set_dec_flags): Add SET_BITFLAG for new option.
    * resolve.c (compare_spec_to_ref): If the flag is set and
    the number of dimension is less than the rank use the lower
    bound for the missing dimensions.

2020-06-25  Jim MacArthur 
    Mark Eggleston 

gcc/testsuite/

    * gfortran.dg/array_6.f90: New test.
    * gfortran.dg/array_7.f90: New test.
    * gfortran.dg/array_8.f90: New test.
    * gfortran.dg/array_9.f90: New test.

--
https://www.codethink.co.uk/privacy.html

>From 3ab6576ec34dd14cac10a52a1a7e08c176ebc357 Mon Sep 17 00:00:00 2001
From: Mark Eggleston 
Date: Mon, 3 Feb 2020 10:56:36 +
Subject: [PATCH] Fortran  : Fill in missing array dimensions using the lower
 bound

Use -fdec-add-missing-indexes to enable feature. Also enabled by fdec.
A warning that the lower bound is being used for a mission dimension
is output unless suppressed by using -Wno-missing-index.

2020-06-24  Jim MacArthur  
	Mark Eggleston  

gcc/fortran/

	* lang.opt: Add options -Wmissing-index and
	-fdec-add-missing-indexes.
	* options.c (set_dec_flags): Add SET_BITFLAG for new option.
	* resolve.c (compare_spec_to_ref): If the flag is set and
	the number of dimension is less than the rank use the lower
	bound for the missing dimensions.

2020-06-24  Jim MacArthur  
Mark Eggleston  

gcc/testsuite/

	* gfortran.dg/array_6.f90: New test.
* gfortran.dg/array_7.f90: New test.
* gfortran.dg/array_8.f90: New test.
	* gfortran.dg/array_9.f90: New test.
---
 gcc/fortran/invoke.texi   | 40 +++
 gcc/fortran/lang.opt  |  8 +++
 gcc/fortran/options.c |  1 +
 gcc/fortran/resolve.c | 20 ++
 gcc/testsuite/gfortran.dg/array_6.f90 | 24 +
 gcc/testsuite/gfortran.dg/array_7.f90 | 24 +
 gcc/testsuite/gfortran.dg/array_8.f90 | 24 +
 gcc/testsuite/gfortran.dg/array_9.f90 | 24 +
 8 files changed, 151 insertions(+), 14 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/array_6.f90
 create mode 100644 gcc/testsuite/gfortran.dg/array_7.f90
 create mode 100644 gcc/testsuite/gfortran.dg/array_8.f90
 create mode 100644 gcc/testsuite/gfortran.dg/array_9.f90

diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 052d3178244..989011af868 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -118,16 +118,17 @@ by type.  Explanations are in the following sections.
 @xref{Fortran Dialect Options,,Options controlling Fortran dialect}.
 @gccoptlist{-fall-intrinsics -fallow-argument-mismatch -fallow-invalid-boz @gol
 -fbackslash -fcray-pointer -fd-lines-as-code -fd-lines-as-comments @gol
--fdec -fdec-char-conversions -fdec-structure -fdec-intrinsic-ints @gol
--fdec-static -fdec-math -fdec-include -fdec-format-defaults @gol
--fdec-blank-format-item -fdefault-double-8 -fdefault-integer-8 @gol
--fdefault-real-8 -fdefault-real-10 -fdefault-real-16 -fdollar-ok @gol
--ffixed-line-length-@var{n} -ffixed-line-length-none -fpad-source @gol
--ffree-form -ffree-line-length-@var{n} -ffree-line-length-none @gol
--fimplicit-none -finteger-4-integer-8 -fmax-identifier-length @gol
--fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp @gol
--freal-4-real-10 -freal-4-real-16 -freal-4-real-8 -freal-8-real-10 @gol
--freal-8-real-16 -freal-8-real-4 -std=@var{std} -ftest-forall-temp
+-fdec -fdec-add-missing-indexes -fdec-char-conversions -fdec-structure @gol
+-fdec-intrinsic-ints -fdec-static -fdec-math -fdec-include @gol
+-fdec-format-defaults -fdec-blank-format-item -fdefault-double-8 @gol
+-fdefault-integer-8 -fdefault-real-8 -fdefault-real-10 -fdefault-real-16 @gol
+-fdollar-ok -ffixed-line-length-@var{n} -ffixed-line-length-none @gol
+-fpad-source -ffree-form -ffree-line-length-@var{n} @gol
+-ffree-line-length-none -fimplicit-none -finteger-4-integer-8 @gol
+-fmax-identifier-len

Re: Fortran: Fix character-kind=4 substring resolution (PR95837)

2020-06-25 Thread Tobias Burnus

Hi Thomas,

Updated patch – now having submitted the mapping patch,
I can focus on other things, including this patch.

I have now removed the setting of the typespec – and
added an assert to be sure everything is consistent.
At least for the testsuite, it is.

Thanks for insisting on doing it properly. It was clear
that the previous code was wrong – but it was not obvious
whether updating the kind value was ever useful.
However, testing indicates that the expression-type
resolution works and the answer is "never".

Thus, an alternative patch would be to just remove
the e-> ... = ... without adding an assert.

OK – with assert or without?

Tobias

On 6/24/20 10:02 PM, Thomas Koenig wrote:

Hi Tobias,


could you review the second patch instead? I have sent the wrong
patch (early draft) and corrected it half an hour later!


Sorry, I missed that.  Here's the review of the real patch :-)

So, the first part is

+  if (ts)
+e->ts.kind = ts->kind;

Ok, I unerstand that - ts has been set earlier for a component.

But this part

+  else if (e->ts.type != BT_CHARACTER)
+e->ts.kind = gfc_default_character_kind;

I do not quite understand.  How can the type of an expression involving
a substring not be BT_CHARACTER when gfc_resolve_substring_charlen is
called?  Or is it BT_UNKNOWN, and a check for that might be better?
And, if it is indeed BT_UNKNOWN, how do we know it isn't a
CHARACTER(KIND=4)?

Best Regards

Thomas



-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter
Fortran: Fix character-kind=4 substring resolution (PR95837)

gcc/fortran/ChangeLog:

	PR fortran/95837
	* resolve.c (gfc_resolve_substring_charlen): Remove
	bogus ts.kind setting for the expression; add assert.

gcc/testsuite/ChangeLog:

	PR fortran/95837
	* gfortran.dg/char4-subscript.f90: New test.

 gcc/fortran/resolve.c |  7 +--
 gcc/testsuite/gfortran.dg/char4-subscript.f90 | 30 +++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index c53b312f7ed..1d0655dd440 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -5140,8 +5140,11 @@ gfc_resolve_substring_charlen (gfc_expr *e)
 	return;
 }
 
-  e->ts.type = BT_CHARACTER;
-  e->ts.kind = gfc_default_character_kind;
+  gcc_assert (e->ts.type == BT_CHARACTER && (e->ts.kind == 1 || e->ts.kind == 4)
+	  && (!ts || e->ts.kind == ts->kind)
+	  && (ts
+		  || e->expr_type != EXPR_VARIABLE
+		  || e->ts.kind == e->symtree->n.sym->ts.kind));
 
   if (!e->ts.u.cl)
 e->ts.u.cl = gfc_new_charlen (gfc_current_ns, NULL);
diff --git a/gcc/testsuite/gfortran.dg/char4-subscript.f90 b/gcc/testsuite/gfortran.dg/char4-subscript.f90
new file mode 100644
index 000..f1f915c7af9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/char4-subscript.f90
@@ -0,0 +1,30 @@
+! { dg-do run }
+! { dg-additional-options "-fdump-tree-original" }
+!
+! PR fortran/95837
+!
+type t
+  character(len=:, kind=4), pointer :: str2
+end type t
+type(t) :: var
+
+allocate(character(len=5, kind=4) :: var%str2)
+
+var%str2(1:1) = 4_"d"
+var%str2(2:3) = 4_"ef"
+var%str2(4:4) = achar(int(Z'1F600'), kind=4)
+var%str2(5:5) = achar(int(Z'1F608'), kind=4)
+
+if (var%str2(1:3) /= 4_"def") stop 1
+if (ichar(var%str2(4:4)) /= int(Z'1F600')) stop 2
+if (ichar(var%str2(5:5)) /= int(Z'1F608')) stop 2
+
+deallocate(var%str2)
+end
+
+! Note: the last '\x00' is regarded as string terminator, hence, the tailing \0 byte is not in the dump
+
+! { dg-final { scan-tree-dump "  \\(\\*var\\.str2\\)\\\[1\\\]{lb: 1 sz: 4} = .dx00x00.\\\[1\\\]{lb: 1 sz: 4};" "original" } }
+! { dg-final { scan-tree-dump "  __builtin_memmove \\(\\(void \\*\\) &\\(\\*var.str2\\)\\\[2\\\]{lb: 1 sz: 4}, \\(void \\*\\) &.ex00x00x00fx00x00.\\\[1\\\]{lb: 1 sz: 4}, 8\\);" "original" } }
+! { dg-final { scan-tree-dump "  \\(\\*var.str2\\)\\\[4\\\]{lb: 1 sz: 4} = .x00xf6x01.\\\[1\\\]{lb: 1 sz: 4};" "original" } }
+! { dg-final { scan-tree-dump "  \\(\\*var.str2\\)\\\[5\\\]{lb: 1 sz: 4} = .bxf6x01.\\\[1\\\]{lb: 1 sz: 4};" "original" } }


Re: [PATCH] Add TARGET_UPDATE_DECL_ALIGNMENT [PR95237]

2020-06-25 Thread Richard Biener via Gcc-patches
On Thu, Jun 25, 2020 at 2:53 AM Sunil Pandey  wrote:
>
> On Wed, Jun 24, 2020 at 12:30 AM Richard Biener
>  wrote:
> >
> > On Tue, Jun 23, 2020 at 5:31 PM Sunil K Pandey via Gcc-patches
> >  wrote:
> > >
> > > From: Sunil K Pandey 
> > >
> > > Default for this hook is NOP. For x86, in 32 bit mode, this hook
> > > sets alignment of long long on stack to 32 bits if preferred stack
> > > boundary is 32 bits.
> > >
> > >  - This patch fixes
> > > gcc.target/i386/pr69454-2.c
> > > gcc.target/i386/stackalign/longlong-1.c
> > >  - Regression test on x86-64, no new fail introduced.
> >
> > I think the name is badly chosen, TARGET_LOWER_LOCAL_DECL_ALIGNMENT
>
> Yes, I can change the target hook name.
>
> > would be better suited (and then asks for LOCAL_DECL_ALIGNMENT to be
> > renamed to INCREASE_LOCAL_DECL_ALIGNMENT).
>
> It seems like LOCAL_DECL_ALIGNMENT macro documentation is incorrect.
> It increases as well as decreases alignment based on condition(-m32
> -mpreferred-stack-boundary=2)
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95885
>
> >
> > You're calling it from do_type_align which IMHO is dangerous since that's
> > invoked from FIELD_DECL layout as well.  Instead invoke it from
> > layout_decl itself where we do
> >
> >   if (code != FIELD_DECL)
> > /* For non-fields, update the alignment from the type.  */
> > do_type_align (type, decl);
> >
> > and invoke the hook _after_ do_type_align.  Also avoid
> > invoking the hook on globals or hard regs and only
> > invoke it on VAR_DECLs, thus only
> >
> >   if (VAR_P (decl) && !is_global_var (decl) && !DECL_HARD_REGISTER (decl))
>
> It seems like decl property is not fully populated at this point call
> to is_global_var (decl) on global variable return false.
>
> $ cat foo.c
> long long x;
> int main()
> {
> if (__alignof__(x) != 8)
>   __builtin_abort();
> return 0;
> }
>
> Breakpoint 1, layout_decl (decl=0x77ffbb40, known_align=0)
> at /local/skpandey/gccwork/gccwork/gcc/gcc/stor-layout.c:674
> 674 do_type_align (type, decl);
> Missing separate debuginfos, use: dnf debuginfo-install
> gmp-6.1.2-10.fc31.x86_64 isl-0.16.1-9.fc31.x86_64
> libmpc-1.1.0-4.fc31.x86_64 mpfr-3.1.6-5.fc31.x86_64
> zlib-1.2.11-20.fc31.x86_64
> (gdb) call debug_tree(decl)
>   type  size 
> unit-size 
> align:64 warn_if_not_align:0 symtab:0 alias-set -1
> canonical-type 0x7fffea801888 precision:64 min  0x7fffea7e8fd8 -9223372036854775808> max  9223372036854775807>
> pointer_to_this >
> DI foo.c:1:11 size  unit-size
> 
> align:1 warn_if_not_align:0>
>
> (gdb) p is_global_var(decl)
> $1 = false
> (gdb)
>
>
> What about calling hook here
>
>  603 do_type_align (tree type, tree decl)
>  604 {
>  605   if (TYPE_ALIGN (type) > DECL_ALIGN (decl))
>  606 {
>  607   SET_DECL_ALIGN (decl, TYPE_ALIGN (type));
>  608   if (TREE_CODE (decl) == FIELD_DECL)
>  609 DECL_USER_ALIGN (decl) = TYPE_USER_ALIGN (type);
>  610   else
>  611 /* Lower local decl alignment */
>  612 if (VAR_P (decl)
>  613 && !is_global_var (decl)
>  614 && !DECL_HARD_REGISTER (decl)
>  615 && cfun != NULL)
>  616   targetm.lower_local_decl_alignment (decl);
>  617 }

But that doesn't change anything (obviously).  layout_decl
is called quite early, too early it looks like.

Now there doesn't seem to be any other good place where
we are sure to catch the decl before we evaluate things
like __alignof__

void __attribute__((noipa))
foo (__SIZE_TYPE__ align, long long *p)
{
  if ((__SIZE_TYPE__)p & (align-1))
__builtin_abort ();
}
int main()
{
  long long y;
  foo (_Alignof y, &y);
  return 0;
}

Joseph/Jason - do you have a good recommendation
how to deal with targets where natural alignment
is supposed to be lowered for optimization purposes?
(this case is for i?86 to avoid dynamic stack re-alignment
to align long long to 8 bytes with -mpreferred-stack-boundary=2)

I note that for -mincoming-stack-boundary=2 we do perform
dynamic stack re-alignment already.

I can't find a suitable existing target macro/hook for this,
but my gut feeling is that the default alignment should
instead be the lower one and instead the alignment for
globals should be raised as optimization?

Thanks,
Richard.

> >
> > Comments on the hook itself below.
> >
> > > Tested on x86-64.
> > >
> > > gcc/ChangeLog:
> > >
> > > PR target/95237
> > > * config/i386/i386.c (ix86_update_decl_alignment): New
> > > function.
> > > (TARGET_UPDATE_DECL_ALIGNMENT): Define.
> > > * doc/tm.texi: Regenerate.
> > > * doc/tm.texi.in (TARGET_UPDATE_DECL_ALIGNMENT): New hook.
> > > * stor-layout.c (do_type_align): Call target hook to update
> > > decl alignment.
> > > * target.def (update_decl_alignment): New hook.
> > >
> > > gcc/testsuite/ChangeLog:
> > >
> > > PR target/95237
> > > * gcc.target/i386/pr95237-1.c: New t

Re: [PATCH] x96: Remove PTA_CLWB from PTA_ICELAKE_CLIENT

2020-06-25 Thread Uros Bizjak via Gcc-patches
On Wed, Jun 24, 2020 at 6:22 PM H.J. Lu  wrote:
>
> CLWB isn't supported on Ice Lake client.  But Ice Lake server and Tiger
> Lake support it.  Move PTA_CLWB to PTA_ICELAKE_SERVER and PTA_TIGERLAKE.
>
> PR target/95874
> * config/i386/i386.h (PTA_ICELAKE_CLIENT): Remove PTA_CLWB.
> (PTA_ICELAKE_SERVER): Add PTA_CLWB.
> (PTA_TIGERLAKE): Add PTA_CLWB.

OK, also for backports.

Thanks,
Uros.

> ---
>  gcc/config/i386/i386.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
> index e1775ff0b5d..d6b57562a53 100644
> --- a/gcc/config/i386/i386.h
> +++ b/gcc/config/i386/i386.h
> @@ -2475,11 +2475,11 @@ const wide_int_bitmask PTA_CANNONLAKE = PTA_SKYLAKE | 
> PTA_AVX512F
>| PTA_AVX512VBMI | PTA_AVX512IFMA | PTA_SHA;
>  const wide_int_bitmask PTA_ICELAKE_CLIENT = PTA_CANNONLAKE | PTA_AVX512VNNI
>| PTA_GFNI | PTA_VAES | PTA_AVX512VBMI2 | PTA_VPCLMULQDQ | PTA_AVX512BITALG
> -  | PTA_RDPID | PTA_CLWB | PTA_AVX512VPOPCNTDQ;
> +  | PTA_RDPID | PTA_AVX512VPOPCNTDQ;
>  const wide_int_bitmask PTA_ICELAKE_SERVER = PTA_ICELAKE_CLIENT | PTA_PCONFIG
> -  | PTA_WBNOINVD;
> +  | PTA_WBNOINVD | PTA_CLWB;
>  const wide_int_bitmask PTA_TIGERLAKE = PTA_ICELAKE_CLIENT | PTA_MOVDIRI
> -  | PTA_MOVDIR64B | PTA_AVX512VP2INTERSECT;
> +  | PTA_MOVDIR64B | PTA_CLWB | PTA_AVX512VP2INTERSECT;
>  const wide_int_bitmask PTA_KNL = PTA_BROADWELL | PTA_AVX512PF | PTA_AVX512ER
>| PTA_AVX512F | PTA_AVX512CD;
>  const wide_int_bitmask PTA_BONNELL = PTA_CORE2 | PTA_MOVBE;
> --
> 2.26.2
>


Re: [PATCH] libgomp: added simple functions and tests for OMPD

2020-06-25 Thread Jakub Jelinek via Gcc-patches
On Wed, Jun 24, 2020 at 09:22:51PM -0400, y2s1982 wrote:
> +#ifndef LIBGOMPD_H
> +#define LIBGOMPD_H 1
> +
> +#define ompd_str1(x) ompd_str2(x)
> +#define ompd_str2(x) #x

I'd call ompd_str1 (the one that should be actually used)
just ompd_str or ompd_stringify.

> --- /dev/null
> +++ b/libgomp/libgompd.map
> @@ -0,0 +1,49 @@
> +OMPD_5.0 {
> +  global:
> + ompd_dll_locations_valid;

ompd_dll_locations and ompd_dll_locations_valid both need to be exported,
but not from libgompd.so.1 but from libgomp.so.1, so they need to go into
libgomp.map and be defined somewhere in libgomp.so.1, so likely env.c.
Include omp-tools.h and plugin-suffix.h in there and move ompd_dll_locations
definition in there (into the #ifndef LIBGOMP_OFFLOADED_ONLY section)
and for ompd_dll_locations_valid, e.g. make it an alias to
initialize_env or for the time being just an empty function with
__attribute__((noipa)) that initialize_env
calls and I'll help with making it an alias afterwards.

> diff --git a/libgomp/libgompd.s b/libgomp/libgompd.s
> new file mode 100644
> index 000..a648bedf3c7
> --- /dev/null
> +++ b/libgomp/libgompd.s
> @@ -0,0 +1 @@
> + .file   "libgompd.c"

You don't want to check this in.

> diff --git a/libgomp/omp-tools.h b/libgomp/omp-tools.h
> index 394c33e40dd..b6b8c5295a5 100644
> --- a/libgomp/omp-tools.h
> +++ b/libgomp/omp-tools.h
> @@ -101,7 +101,7 @@ typedef struct ompd_device_type_sizes_t {
>  } ompd_device_type_sizes_t;
>  
>  
> -const char **ompd_dll_locations;
> +//const char **ompd_dll_locations;

Extern declaration would be
extern const char **ompd_dll_locations;

> +ompd_rc_t
> +ompd_get_api_version (ompd_word_t *version)
> +{
> +  *version = OMPD_VERSION;
> +  return ompd_rc_ok;
> +}
> +
> +ompd_rc_t
> +ompd_get_version_string (const char **string)
> +{
> +  *string = "GNU OpenMP Runtime implementing OpenMP 5.0" 
> ompd_str2(OMPD_VERSION);

You need a space between 5.0 and the OMPD_VERSION string, so 
5.0 " ompd_stringify (OMPD_VERSION);
and also, the line gets too long, so please write
  *string = "GNU OpenMP Runtime implementing OpenMP 5.0 "
ompd_stringify (OMPD_VERSION);

> +ompd_rc_t
> +ompd_initialize (ompd_word_t api_version, const ompd_callbacks_t *callbacks)
> +{
> +  /* initialized flag */

You don't need to comment everything the function is doing, I think the
comments don't say anything that isn't obvious from it.
Comment only for larger blocks of code where it might not be obvious what
the code is doing and the comment adds added value; comments should be
usually full sentences, starting with capital letter, ending with . and
two spaces after the .
Or one can add function comments (comments before function definition) that
explain what the function does, what are the arguments etc., but in the
case of functions documented in the standard it seems pointless,
the best documentation is the standard.

You don't use the callbacks argument yet, but you will need it later,
so instead of adding an unused attribute to it, just add
  (void) callbacks;
for now to shut up warnings.

Otherwise LGTM.

Jakub



[PATCH] gcov-tool: fix merge operation for summary

2020-06-25 Thread Martin Liška

Hi.

The patch is about broken summary merge when gcov-tool is used.

I've just tested the patch and I'm going to push it to master.
Martin

libgcc/ChangeLog:

* libgcov-driver.c (merge_summary): Remove function as its name
is misleading and doing something different.
(dump_one_gcov): Add ATTRIBUTE_UNUSED for 2 args. Take read summary
in gcov-tool.
* libgcov-util.c (curr_object_summary): Remove.
(read_gcda_file): Remove unused curr_object_summary.
(gcov_merge): Merge summaries.
* libgcov.h: Add summary argument for gcov_info struct.
---
 libgcc/libgcov-driver.c | 26 +++---
 libgcc/libgcov-util.c   | 11 ++-
 libgcc/libgcov.h|  1 +
 3 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index cbfcae96d19..871b87b867b 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -442,19 +442,6 @@ write_one_data (const struct gcov_info *gi_ptr,
   gcov_write_unsigned (0);
 }
 
-/* Helper function for merging summary.  */

-
-static void
-merge_summary (int run_counted, struct gcov_summary *summary,
- gcov_type run_max)
-{
-  if (!run_counted)
-{
-  summary->runs++;
-  summary->sum_max += run_max;
-}
-}
-
 /* Dump the coverage counts for one gcov_info object. We merge with existing
counts when possible, to avoid growing the .da files ad infinitum. We use
this program's checksum to make sure we only accumulate whole program
@@ -464,7 +451,8 @@ merge_summary (int run_counted, struct gcov_summary 
*summary,
 
 static void

 dump_one_gcov (struct gcov_info *gi_ptr, struct gcov_filename *gf,
-  unsigned run_counted, gcov_type run_max)
+  unsigned run_counted ATTRIBUTE_UNUSED,
+  gcov_type run_max ATTRIBUTE_UNUSED)
 {
   struct gcov_summary summary = {};
   int error;
@@ -492,7 +480,15 @@ dump_one_gcov (struct gcov_info *gi_ptr, struct 
gcov_filename *gf,
 
   gcov_rewrite ();
 
-  merge_summary (run_counted, &summary, run_max);

+#if !IN_GCOV_TOOL
+  if (!run_counted)
+{
+  summary.runs++;
+  summary.sum_max += run_max;
+}
+#else
+  summary = gi_ptr->summary;
+#endif
 
   write_one_data (gi_ptr, &summary);

   /* fall through */
diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c
index 224c190ee63..09e34f0a33a 100644
--- a/libgcc/libgcov-util.c
+++ b/libgcc/libgcov-util.c
@@ -80,8 +80,6 @@ static int k_ctrs_mask[GCOV_COUNTERS];
 static struct gcov_ctr_info k_ctrs[GCOV_COUNTERS];
 /* Number of kind of counters that have been seen.  */
 static int k_ctrs_types;
-/* The object summary being processed.  */
-static struct gcov_summary *curr_object_summary;
 
 /* Merge functions for counters.  */

 #define DEF_GCOV_COUNTER(COUNTER, NAME, FN_TYPE) __gcov_merge ## FN_TYPE,
@@ -225,8 +223,7 @@ tag_counters (unsigned tag, unsigned length)
 static void
 tag_summary (unsigned tag ATTRIBUTE_UNUSED, unsigned length ATTRIBUTE_UNUSED)
 {
-  curr_object_summary = (gcov_summary *) xcalloc (sizeof (gcov_summary), 1);
-  gcov_read_summary (curr_object_summary);
+  gcov_read_summary (&curr_gcov_info->summary);
 }
 
 /* This function is called at the end of reading a gcda file.

@@ -300,7 +297,6 @@ read_gcda_file (const char *filename)
   obstack_init (&fn_info);
   num_fn_info = 0;
   curr_fn_info = 0;
-  curr_object_summary = NULL;
   {
 size_t len = strlen (filename) + 1;
 char *str_dup = (char*) xmalloc (len);
@@ -584,6 +580,11 @@ gcov_merge (struct gcov_info *info1, struct gcov_info 
*info2, int w)
   int has_mismatch = 0;
 
   gcc_assert (info2->n_functions == n_functions);

+
+  /* Merge summary.  */
+  info1->summary.runs += info2->summary.runs;
+  info1->summary.sum_max += info2->summary.sum_max;
+
   for (f_ix = 0; f_ix < n_functions; f_ix++)
 {
   unsigned t_ix;
diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h
index ffa9a690af4..81e18950a50 100644
--- a/libgcc/libgcov.h
+++ b/libgcc/libgcov.h
@@ -217,6 +217,7 @@ struct gcov_info
   to function information  */
 #else
   struct gcov_fn_info **functions;
+  struct gcov_summary summary;
 #endif /* !IN_GCOV_TOOL */
 };
 
--

2.27.0



RFA: Remove use of register keyword in libiberty.h

2020-06-25 Thread Nick Clifton via Gcc-patches
Hi Ian, Hi Nick,

  Comping the GOLD linker with Clang has started producing this error
  message:

In file included from gold/archive.cc:29:
include/libiberty.h:646:25: error: 'register' storage class
  specifier is deprecated and incompatible with C++17
  [-Werror,-Wdeprecated-register]

  So I would like to apply the patch below to fix this.  Is this OK ?
  
Cheers
  Nick

include/ChangeLog
2020-06-25  Nick Clifton  

* libiberty.h (bsearch_r): Remove use of the register keyword from
the prototype.

diff --git a/include/libiberty.h b/include/libiberty.h
index 0bb5b81d4a..591e9ac48d 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -643,9 +643,9 @@ extern int pwait (int, int *, int);
 
 /* Like bsearch, but takes and passes on an argument like qsort_r.  */
 
-extern void *bsearch_r (register const void *, const void *,
-   size_t, register size_t,
-   register int (*)(const void *, const void *, void *),
+extern void *bsearch_r (const void *, const void *,
+   size_t, size_t,
+   int (*)(const void *, const void *, void *),
void *);
 
 #if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF

 



RFA: Remove use of register keyword in libiberty.h

2020-06-25 Thread Nick Clifton via Gcc-patches
Hi Ian, Hi Nick,

  Compiling the GOLD linker with Clang has started producing this error
  message:

In file included from gold/archive.cc:29:
include/libiberty.h:646:25: error: 'register' storage class
  specifier is deprecated and incompatible with C++17
  [-Werror,-Wdeprecated-register]

  So I would like to apply the patch below to fix this.  Is this OK ?
  
Cheers
  Nick

include/ChangeLog
2020-06-25  Nick Clifton  

* libiberty.h (bsearch_r): Remove use of the register keyword from
the prototype.

diff --git a/include/libiberty.h b/include/libiberty.h
index 0bb5b81d4a..591e9ac48d 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -643,9 +643,9 @@ extern int pwait (int, int *, int);
 
 /* Like bsearch, but takes and passes on an argument like qsort_r.  */
 
-extern void *bsearch_r (register const void *, const void *,
-   size_t, register size_t,
-   register int (*)(const void *, const void *, void *),
+extern void *bsearch_r (const void *, const void *,
+   size_t, size_t,
+   int (*)(const void *, const void *, void *),
void *);
 
 #if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF

 



[PATCH] tree-optimization/95866 - avoid using scalar ops for vectorized shift

2020-06-25 Thread Richard Biener
This avoids using the original scalar SSA operand when vectorizing
a shift with a vectorized shift operand where we know all vector
components have the same value and thus we can use a vector by
scalar shift.  Using the scalar SSA operand causes a possibly
long chain of scalar computation to be retained so it's better
to simply extract lane zero from the available vectorized shift
operand.

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

2020-06-25  Richard Biener  

PR tree-optimization/95866
* tree-vect-stmts.c (vectorizable_shift): Reject incompatible
vectorized shift operands.  For scalar shifts use lane zero
of a vectorized shift operand.

* gcc.dg/vect/bb-slp-pr95866.c: New testcase.
---
 gcc/testsuite/gcc.dg/vect/bb-slp-pr95866.c | 17 
 gcc/tree-vect-stmts.c  | 30 +++---
 2 files changed, 44 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr95866.c

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr95866.c 
b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95866.c
new file mode 100644
index 000..5de46719101
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95866.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target vect_shift } */
+
+int x[4];
+int j[4];
+void foo()
+{
+  x[0] = (x[0] << j[0]) + j[0];
+  x[1] = (x[1] << j[0]) + j[1];
+  x[2] = (x[2] << j[0]) + j[2];
+  x[3] = (x[3] << j[0]) + j[3];
+}
+
+/* The scalar shift argument should be extracted from the available vector.  */
+/* { dg-final { scan-tree-dump "BIT_FIELD_REF" "slp2" } } */
+/* { dg-final { scan-tree-dump "basic block vectorized" "slp2" } } */
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index de7d77f3872..edd28534cb0 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -5413,6 +5413,15 @@ vectorizable_shift (vec_info *vinfo,
= (!op1_vectype
   || !tree_nop_conversion_p (TREE_TYPE (vectype),
  TREE_TYPE (op1)));
+ if (incompatible_op1_vectype_p
+ && dt[1] == vect_internal_def)
+   {
+ if (dump_enabled_p ())
+   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+"unusable type for last operand in"
+" vector/vector shift/rotate.\n");
+ return false;
+   }
 }
 }
 }
@@ -5457,7 +5466,7 @@ vectorizable_shift (vec_info *vinfo,
 {
   if (slp_node
  && (!vect_maybe_update_slp_op_vectype (slp_op0, vectype)
- || (!scalar_shift_arg
+ || ((!scalar_shift_arg || dt[1] == vect_internal_def)
  && (!incompatible_op1_vectype_p
  || dt[1] == vect_constant_def)
  && !vect_maybe_update_slp_op_vectype
@@ -5499,6 +5508,7 @@ vectorizable_shift (vec_info *vinfo,
 
   if (incompatible_op1_vectype_p && !slp_node)
 {
+  gcc_assert (!scalar_shift_arg && was_scalar_shift_arg);
   op1 = fold_convert (TREE_TYPE (vectype), op1);
   if (dt[1] != vect_constant_def)
op1 = vect_init_vector (vinfo, stmt_info, op1,
@@ -5508,7 +5518,7 @@ vectorizable_shift (vec_info *vinfo,
   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
 
-  if (scalar_shift_arg)
+  if (scalar_shift_arg && dt[1] != vect_internal_def)
 {
   /* Vector shl and shr insn patterns can be defined with scalar
 operand 2 (shift operand).  In this case, use constant or loop
@@ -5533,7 +5543,7 @@ vectorizable_shift (vec_info *vinfo,
vec_oprnds1.quick_push (vec_oprnd1);
}
 }
-  else if (slp_node && incompatible_op1_vectype_p)
+  else if (!scalar_shift_arg && slp_node && incompatible_op1_vectype_p)
 {
   if (was_scalar_shift_arg)
{
@@ -5566,6 +5576,20 @@ vectorizable_shift (vec_info *vinfo,
   FOR_EACH_VEC_ELT (vec_oprnds0, i, vop0)
 {
   vop1 = vec_oprnds1[i];
+  /* For internal defs where we need to use a scalar shift arg
+extract the first lane.  */
+  if (scalar_shift_arg && dt[1] == vect_internal_def)
+   {
+ new_temp = make_ssa_name (TREE_TYPE (TREE_TYPE (vop1)));
+ gassign *new_stmt
+   = gimple_build_assign (new_temp,
+  build3 (BIT_FIELD_REF, TREE_TYPE (new_temp),
+  vop1,
+  TYPE_SIZE (TREE_TYPE (new_temp)),
+  bitsize_zero_node));
+ vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi);
+ vop1 = new_temp;
+   }
   gassign *new_stmt = gimple_build_assign (vec_dest, code, vop0, vop1);
   new_temp = make_ssa_name (vec_dest, new_stmt);
   gimple_assign_set_l

[PATCH] tree-optimization/95839 - allow CTOR vectorization without loads

2020-06-25 Thread Richard Biener
This removes a premature check for enough datarefs in a basic-block
before we consider vectorizing it which leaves basic-blocks with
just vectorizable vector constructors unvectorized.  The check
is effectively done by the following check for store groups
which then also include constructors.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

2020-06-25  Richard Biener  

PR tree-optimization/95839
* tree-vect-slp.c (vect_slp_analyze_bb_1): Remove premature
check on the number of datarefs.

* gcc.dg/vect/bb-slp-pr95839.c: New testcase.
---
 gcc/testsuite/gcc.dg/vect/bb-slp-pr95839.c | 13 +
 gcc/tree-vect-slp.c| 15 +++
 2 files changed, 16 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr95839.c

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr95839.c 
b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95839.c
new file mode 100644
index 000..0bfba01452d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95839.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+/* { dg-additional-options "-w -Wno-psabi" } */
+
+typedef float __attribute__((vector_size(16))) v4f32;
+
+v4f32 f(v4f32 a, v4f32 b)
+{
+  /* Check that we vectorize this CTOR without any loads.  */
+  return (v4f32){a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]};
+}
+
+/* { dg-final { scan-tree-dump "basic block vectorized" "slp2" } } */
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index ca6bedc9cc8..4c2315dcde9 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -3130,15 +3130,6 @@ vect_slp_analyze_bb_1 (bb_vec_info bb_vinfo, int 
n_stmts, bool &fatal)
   return false;
 }
 
-  if (BB_VINFO_DATAREFS (bb_vinfo).length () < 2)
-{
-  if (dump_enabled_p ())
-dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-"not vectorized: not enough data-refs in "
-"basic block.\n");
-  return false;
-}
-
   if (!vect_analyze_data_ref_accesses (bb_vinfo))
 {
  if (dump_enabled_p ())
@@ -3150,9 +3141,9 @@ vect_slp_analyze_bb_1 (bb_vec_info bb_vinfo, int n_stmts, 
bool &fatal)
 
   vect_slp_check_for_constructors (bb_vinfo);
 
-  /* If there are no grouped stores in the region there is no need
- to continue with pattern recog as vect_analyze_slp will fail
- anyway.  */
+  /* If there are no grouped stores and no constructors in the region
+ there is no need to continue with pattern recog as vect_analyze_slp
+ will fail anyway.  */
   if (bb_vinfo->grouped_stores.is_empty ())
 {
   if (dump_enabled_p ())
-- 
2.26.2


Re: [PATCH 3/7] [OpenACC] Don't pass kind array via pointer to goacc_enter_datum

2020-06-25 Thread Thomas Schwinge
Hi Julian!

On 2020-05-22T15:16:06-0700, Julian Brown  wrote:
> Since goacc_enter_datum only maps a single data item now, there is no
> need to pass "kinds" as an array.  Passing as a scalar allows for some
> simplification in the function's callers.

You'd hope (didn't verify) that the compiler can do the same
transformation/optimization.  ;-)

But, au contraire: in my opinion (but please tell if you disagree), we
should instead get (back) to the state where the runtime API and the
pragma variants of the respective OpenACC functionality map to the same
libgomp implementation.

That's what we had a while ago: 'acc_create' calling the same
'goacc_enter_data' as 'GOACC_enter_exit_data' did for OpenACC 'enter
data' with 'create' clause, etc.  You then removed/changed that in
2019-12-20 commit 378da98fcc907d05002bcd3d6ff7951f0cf485e5 "OpenACC
reference count overhaul", reason unknown.

The idea is (a) to match in the libgomp implementation what the OpenACC
specification states ("The 'acc_create' routines are equivalent to the
'enter data' directive with a 'create' clause", etc.), and (b) to reduce
code duplication and thus potential for bugs -- like we've seen in the
case of 'attach'/'detach', where one variant didn't do reference counting
(runtime API variant; correct), and the other variant did (pragma
variant; incorrect).

As it must be able to handle the very same things (and more), my
understanding/expectation is that 'goacc_enter_data_internal' must offer
a superset of 'goacc_enter_datum' functionality, so the latter can just
go away?

And same story for the 'exit data' implementations, of course:
'goacc_exit_datum' vs. 'goacc_exit_data_internal'.


Grüße
 Thomas


>   libgomp/
>   * oacc-mem.c (goacc_enter_datum): Use scalar kind argument instead of
>   kinds array.
>   (acc_create, acc_create_async, acc_copyin, acc_copyin_async): Update
>   calls to goacc_enter_datum.
> ---
>  libgomp/oacc-mem.c | 17 +++--
>  1 file changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
> index fff0d573f59..20d241382a8 100644
> --- a/libgomp/oacc-mem.c
> +++ b/libgomp/oacc-mem.c
> @@ -501,7 +501,8 @@ acc_unmap_data (void *h)
>  /* Enter dynamic mapping for a single datum.  Return the device pointer.  */
>
>  static void *
> -goacc_enter_datum (void **hostaddrs, size_t *sizes, void *kinds, int async)
> +goacc_enter_datum (void **hostaddrs, size_t *sizes, unsigned short kind,
> +int async)
>  {
>void *d;
>splay_tree_key n;
> @@ -560,7 +561,7 @@ goacc_enter_datum (void **hostaddrs, size_t *sizes, void 
> *kinds, int async)
>
>struct target_mem_desc *tgt
>   = gomp_map_vars_async (acc_dev, aq, mapnum, hostaddrs, NULL, sizes,
> -kinds, true, GOMP_MAP_VARS_ENTER_DATA);
> +&kind, true, GOMP_MAP_VARS_ENTER_DATA);
>assert (tgt);
>assert (tgt->list_count == 1);
>n = tgt->list[0].key;
> @@ -584,15 +585,13 @@ goacc_enter_datum (void **hostaddrs, size_t *sizes, 
> void *kinds, int async)
>  void *
>  acc_create (void *h, size_t s)
>  {
> -  unsigned short kinds[1] = { GOMP_MAP_ALLOC };
> -  return goacc_enter_datum (&h, &s, &kinds, acc_async_sync);
> +  return goacc_enter_datum (&h, &s, GOMP_MAP_ALLOC, acc_async_sync);
>  }
>
>  void
>  acc_create_async (void *h, size_t s, int async)
>  {
> -  unsigned short kinds[1] = { GOMP_MAP_ALLOC };
> -  goacc_enter_datum (&h, &s, &kinds, async);
> +  goacc_enter_datum (&h, &s, GOMP_MAP_ALLOC, async);
>  }
>
>  /* acc_present_or_create used to be what acc_create is now.  */
> @@ -617,15 +616,13 @@ acc_pcreate (void *h, size_t s)
>  void *
>  acc_copyin (void *h, size_t s)
>  {
> -  unsigned short kinds[1] = { GOMP_MAP_TO };
> -  return goacc_enter_datum (&h, &s, &kinds, acc_async_sync);
> +  return goacc_enter_datum (&h, &s, GOMP_MAP_TO, acc_async_sync);
>  }
>
>  void
>  acc_copyin_async (void *h, size_t s, int async)
>  {
> -  unsigned short kinds[1] = { GOMP_MAP_TO };
> -  goacc_enter_datum (&h, &s, &kinds, async);
> +  goacc_enter_datum (&h, &s, GOMP_MAP_TO, async);
>  }
>
>  /* acc_present_or_copyin used to be what acc_copyin is now.  */
-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter


Re: RFA: Remove use of register keyword in libiberty.h

2020-06-25 Thread Nick Alcock via Gcc-patches
On 25 Jun 2020, Nick Clifton outgrape:

> Hi Ian, Hi Nick,
>
>   Comping the GOLD linker with Clang has started producing this error
>   message:
>
> In file included from gold/archive.cc:29:
> include/libiberty.h:646:25: error: 'register' storage class
>   specifier is deprecated and incompatible with C++17
>   [-Werror,-Wdeprecated-register]
>
>   So I would like to apply the patch below to fix this.  Is this OK ?

Yes please! This was copied straight from bsearch.c, so you probably
want to change bsearch.c and bsearch_r.c as well (just in case clang
ever finds itself needing to build bsearch_r out of libiberty).


Re: [PATCH 02/13] OpenACC reference count overhaul

2020-06-25 Thread Thomas Schwinge
Hi Julian!

Ping, in particular my question about different 'GOMP_MAP_FORCE_FROM' vs.
'GOMP_MAP_FROM' handling.

(I have not yet looked whether 'GOMP_MAP_ALWAYS_FROM' may be generate
nowadays, given your pending front end/middle end patches.)

On 2020-05-19T17:58:16+0200, I wrote:
> On 2019-12-17T22:02:27-0800, Julian Brown  wrote:
>> --- a/libgomp/oacc-mem.c
>> +++ b/libgomp/oacc-mem.c
>
> (Unhelpful diff trimmed.)
>
>> +/* Unmap variables for OpenACC "exit data", with optional finalization
>> +   (affecting all mappings in this operation).  */
>
>> +static void
>> +goacc_exit_data_internal (struct gomp_device_descr *acc_dev, size_t mapnum,
>> +  void **hostaddrs, size_t *sizes,
>> +  unsigned short *kinds, bool finalize, goacc_aq aq)
>> +{
>> +  gomp_mutex_lock (&acc_dev->lock);
>
>> +  for (size_t i = 0; i < mapnum; ++i)
>>  {
>
>> +  unsigned char kind = kinds[i] & 0xff;
>> +  bool copyfrom = false;
>
>> +  switch (kind)
>
>> +case GOMP_MAP_FROM:
>> +case GOMP_MAP_FORCE_FROM:
>> +case GOMP_MAP_ALWAYS_FROM:
>> +  copyfrom = true;
>> +  /* Fallthrough.  */
>
> What is the case that a 'GOMP_MAP_ALWAYS_FROM' would be generated for
> OpenACC code?  Putting an 'assert' here, it never triggers, given the
> current set of libgomp test cases.  If there is such a case, we should
> add a test case, otherwise, I suggest we do put an 'assert' here (whilst
> leaving in the supposedly correct code, if you'd like), to document that
> this not currently expected, and thus not tested?
>
>> +
>> +case GOMP_MAP_TO_PSET:
>> +case GOMP_MAP_POINTER:
>> +case GOMP_MAP_DELETE:
>> +case GOMP_MAP_RELEASE:
>> +  {
>> +struct splay_tree_key_s cur_node;
>> +cur_node.host_start = (uintptr_t) hostaddrs[i];
>> +cur_node.host_end = cur_node.host_start
>> ++ (kind == GOMP_MAP_POINTER
>> +   ? sizeof (void *) : sizes[i]);
>> +splay_tree_key n
>> +  = splay_tree_lookup (&acc_dev->mem_map, &cur_node);
>> +
>> +if (n == NULL)
>> +  continue;
>> +
>> +if (finalize)
>> +  {
>> +if (n->refcount != REFCOUNT_INFINITY)
>> +  n->refcount -= n->virtual_refcount;
>> +n->virtual_refcount = 0;
>> +  }
>> +
>> +if (n->virtual_refcount > 0)
>> +  {
>> +if (n->refcount != REFCOUNT_INFINITY)
>> +  n->refcount--;
>> +n->virtual_refcount--;
>> +  }
>> +else if (n->refcount > 0 && n->refcount != REFCOUNT_INFINITY)
>> +  n->refcount--;
>> +
>> +if (copyfrom
>> +&& (kind != GOMP_MAP_FROM || n->refcount == 0))
>> +  gomp_copy_dev2host (acc_dev, aq, (void *) cur_node.host_start,
>> +  (void *) (n->tgt->tgt_start + n->tgt_offset
>> ++ cur_node.host_start
>> +- n->host_start),
>> +  cur_node.host_end - cur_node.host_start);
>
> That 'kind != GOMP_MAP_FROM' conditional looks wrong to me.  This should
> instead be 'kind == GOMP_MAP_ALWAYS_FROM'?  Or, get removed, together
> with the 'GOMP_MAP_ALWAYS_FROM' handling above?  But definitely
> 'GOMP_MAP_FORCE_FROM' and 'GOMP_MAP_FROM' need to be handled the same, as
> far as I can tell?
>
>> +
>> +if (n->refcount == 0)
>> +  gomp_remove_var_async (acc_dev, n, aq);
>> +  }
>> +  break;
>> +default:
>> +  gomp_fatal (" goacc_exit_data_internal UNHANDLED kind 0x%.2x",
>> +  kind);
>>  }
>>  }
>>
>>gomp_mutex_unlock (&acc_dev->lock);
>
>>  }


Grüße
 Thomas
-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter


Re: RFA: Remove use of register keyword in libiberty.h

2020-06-25 Thread Nick Clifton via Gcc-patches
Hi Nick, Hi Ian, 
>> In file included from gold/archive.cc:29:
>> include/libiberty.h:646:25: error: 'register' storage class
>>   specifier is deprecated and incompatible with C++17
>>   [-Werror,-Wdeprecated-register]
>>
>>   So I would like to apply the patch below to fix this.  Is this OK ?
> 
> Yes please! This was copied straight from bsearch.c, so you probably
> want to change bsearch.c and bsearch_r.c as well (just in case clang
> ever finds itself needing to build bsearch_r out of libiberty).

OK, here is a revised patch.  Ian - is this OK ?

Cheers
  Nick

include/ChangeLog
2020-06-25  Nick Clifton  

* libiberty.h (bsearch_r): Remove use of the register keyword from
the prototype.

libiberty/ChangeLog
2020-06-25  Nick Clifton  

* bsearch.c (bsearch): Remove use of register keyword.
* bsearch_r.c (bsearch_r): Likewise.
diff --git a/include/libiberty.h b/include/libiberty.h
index 0bb5b81d4ac..591e9ac48d4 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -643,9 +643,9 @@ extern int pwait (int, int *, int);
 
 /* Like bsearch, but takes and passes on an argument like qsort_r.  */
 
-extern void *bsearch_r (register const void *, const void *,
-			size_t, register size_t,
-			register int (*)(const void *, const void *, void *),
+extern void *bsearch_r (const void *, const void *,
+			size_t, size_t,
+			int (*)(const void *, const void *, void *),
 			void *);
 
 #if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
diff --git a/libiberty/bsearch.c b/libiberty/bsearch.c
index 35fad19977c..18158b9591b 100644
--- a/libiberty/bsearch.c
+++ b/libiberty/bsearch.c
@@ -69,13 +69,13 @@ is respectively less than, matching, or greater than the array member.
  * look at item 3.
  */
 void *
-bsearch (register const void *key, const void *base0,
- size_t nmemb, register size_t size,
- register int (*compar)(const void *, const void *))
+bsearch (const void *key, const void *base0,
+ size_t nmemb, size_t size,
+ int (*compar)(const void *, const void *))
 {
-	register const char *base = (const char *) base0;
-	register int lim, cmp;
-	register const void *p;
+	const char *base = (const char *) base0;
+	int lim, cmp;
+	const void *p;
 
 	for (lim = nmemb; lim != 0; lim >>= 1) {
 		p = base + (lim >> 1) * size;
diff --git a/libiberty/bsearch_r.c b/libiberty/bsearch_r.c
index 79ebae9b0be..2a2ca6f5e23 100644
--- a/libiberty/bsearch_r.c
+++ b/libiberty/bsearch_r.c
@@ -70,14 +70,14 @@ is respectively less than, matching, or greater than the array member.
  * look at item 3.
  */
 void *
-bsearch_r (register const void *key, const void *base0,
-	   size_t nmemb, register size_t size,
-	   register int (*compar)(const void *, const void *, void *),
+bsearch_r (const void *key, const void *base0,
+	   size_t nmemb, size_t size,
+	   int (*compar)(const void *, const void *, void *),
 	   void *arg)
 {
-	register const char *base = (const char *) base0;
-	register int lim, cmp;
-	register const void *p;
+	const char *base = (const char *) base0;
+	int lim, cmp;
+	const void *p;
 
 	for (lim = nmemb; lim != 0; lim >>= 1) {
 		p = base + (lim >> 1) * size;


[patch] Take into account range info to optimize range tests

2020-06-25 Thread Eric Botcazou
Hi,

...into bit tests, as done by optimize_range_tests_to_bit_test of the reassoc 
pass.  The patch is aimed at addressing the following two issues:

  1. In order to protect the shift operation from undefinedness, the new bit 
test is guarded with a new test, but this new test uses the range of the bit 
test values, not that of the shift operation so, if the input is in the range 
of the shift operation but not of the bit test values, then the subsequent VRP 
pass cannot eliminate the new test.  Moreover changing the new test to use the 
range of the shift operation, instead of that of the bit test values, in the 
general case would pessimize the cases which are in between.

  2. If the new test can be eliminated, then it becomes profitable to do the 
optimization into a bit test for one fewer comparison in the source code.

Therefore the patch changes optimize_range_tests_to_bit_test to use the range 
info of the input in order to eliminate the new test if possible.

Tested on x86-64/Linux, OK for the mainline?


2020-06-25  Eric Botcazou  

* tree-ssa-reassoc.c (dump_range_entry): New function.
(debug_range_entry): New debug function.
(update_range_test): Invoke dump_range_entry for dumping.
(optimize_range_tests_to_bit_test): Merge the entry test in the bit
test when possible and lower the profitability threshold in this case.


2020-06-25  Eric Botcazou  

* exp_ch4.adb (Expand_Set_Membership): Expand the membership test
using left associativity instead of right associativity.


2020-06-25  Eric Botcazou  

* gnat.dg/opt86_pkg.ads: New helper.
* gnat.dg/opt86a.adb: New test.
* gnat.dg/opt86b.adb: Likewise.
* gnat.dg/opt86c.adb: Likewise.

-- 
Eric Botcazoudiff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 2adebb6f54c..88dcb52349d 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -12879,16 +12879,19 @@ package body Exp_Ch4 is
begin
   Remove_Side_Effects (Lop);
 
-  Alt := Last (Alternatives (N));
+  Alt := First (Alternatives (N));
   Res := Make_Cond (Alt);
+  Next (Alt);
+
+  --  We use left associativity as in the equivalent boolean case. This
+  --  kind of canonicalization helps the optimizer of the code generator.
 
-  Prev (Alt);
   while Present (Alt) loop
  Res :=
Make_Or_Else (Sloc (Alt),
- Left_Opnd  => Make_Cond (Alt),
- Right_Opnd => Res);
- Prev (Alt);
+ Left_Opnd  => Res,
+ Right_Opnd => Make_Cond (Alt));
+ Next (Alt);
   end loop;
 
   Rewrite (N, Res);
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 2e67987f6c6..d06b693ec76 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -2416,6 +2416,32 @@ struct range_entry
   unsigned int idx, next;
 };
 
+void dump_range_entry (FILE *file, struct range_entry *r);
+void debug_range_entry (struct range_entry *r);
+
+/* Dump the range entry R to FILE, skipping its expression if SKIP_EXP.  */
+
+void
+dump_range_entry (FILE *file, struct range_entry *r, bool skip_exp)
+{
+  if (!skip_exp)
+print_generic_expr (file, r->exp);
+  fprintf (file, " %c[", r->in_p ? '+' : '-');
+  print_generic_expr (file, r->low);
+  fputs (", ", file);
+  print_generic_expr (file, r->high);
+  fputc (']', file);
+}
+
+/* Dump the range entry R to STDERR.  */
+
+DEBUG_FUNCTION void
+debug_range_entry (struct range_entry *r)
+{
+  dump_range_entry (stderr, r, false);
+  fputc ('\n', stderr);
+}
+
 /* This is similar to make_range in fold-const.c, but on top of
GIMPLE instead of trees.  If EXP is non-NULL, it should be
an SSA_NAME and STMT argument is ignored, otherwise STMT
@@ -2730,12 +2756,7 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange,
 {
   struct range_entry *r;
   fprintf (dump_file, "Optimizing range tests ");
-  print_generic_expr (dump_file, range->exp);
-  fprintf (dump_file, " %c[", range->in_p ? '+' : '-');
-  print_generic_expr (dump_file, range->low);
-  fprintf (dump_file, ", ");
-  print_generic_expr (dump_file, range->high);
-  fprintf (dump_file, "]");
+  dump_range_entry (dump_file, range, false);
   for (i = 0; i < count; i++)
 	{
 	  if (otherrange)
@@ -2747,15 +2768,13 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange,
 	  && TREE_CODE (r->exp) == SSA_NAME)
 	{
 	  fprintf (dump_file, " and ");
-	  print_generic_expr (dump_file, r->exp);
+	  dump_range_entry (dump_file, r, false);
 	}
 	  else
-	fprintf (dump_file, " and");
-	  fprintf (dump_file, " %c[", r->in_p ? '+' : '-');
-	  print_generic_expr (dump_file, r->low);
-	  fprintf (dump_file, ", ");
-	  print_generic_expr (dump_file, r->high);
-	  fprintf (dump_file, "]");
+	{
+	  fprintf (dump_file, " and");
+	  dump_range_entry (dump_file, r, true);
+	}
 	}

Re: [PATCH PR95700] Use nullptr instead of NULL as a sentinel value

2020-06-25 Thread Ilya Leoshkevich via Gcc-patches
On Wed, 2020-06-24 at 16:16 +0200, Richard Biener wrote:
> On Wed, Jun 24, 2020 at 4:14 PM Jonathan Wakely via Gcc-patches
>  wrote:
> > On 24/06/20 12:31 +0200, Ilya Leoshkevich wrote:
> > > Bootstrapped and regtested on x86_64-redhat-linux, ppc64le-
> > > redhat-linux
> > > and s390x-redhat-linux.
> > > 
> > > Ok for master?
> > > 
> > > ---
> > > 
> > > Bootstrap with musl libc fails with numerous "missing sentinel in
> > > function call" errors.  This is because musl defines NULL as 0L
> > > for C++,
> > > but gcc requires sentinel value to be a pointer or __null.
> > > 
> > > Jonathan Wakely says:
> > > 
> > >To be really safe during stage 1, GCC should not use NULL as a
> > >pointer sentinel in C++ code anyway.
> > > 
> > >The bootstrap compiler could define it to 0 or 0u, neither of
> > > which
> > >is guaranteed to be OK to pass as a varargs sentinel where a
> > > null
> > >pointer is expected.  Any of (void*)0 or (void*)NULL or
> > > nullptr
> > >would be safe.
> > > 
> > > Therefore, fix by replacing NULL sentinels with nullptr.
> > 
> > For some additional context, the C++ standard guarantees that
> > passing
> > nullptr to a varargs function will convert to (void*)0. That has
> > been
> > true since nullptr was added in C++11.
> 
> Is there a diagnostic option that we can turn on so no NULLs will
> creep
> in in such position?   Without that we'll bitrot quickly?

I couldn't find a useful existing warning for this.  The main
difficulty in implementing it, as far as I can see, is that we need to
check preprocessor tokens that were used to generate a function
argument.

Can we somehow compare the source code of a function argument with
"NULL"?  At least diagnostic code should already able to access the
original (non-preprocessed) source code, can the warning code do this
as well?

> 
> Richard.



Re: [PATCH 6/9] [OpenACC] Set bias to zero for explicit attach/detach clauses in C and C++

2020-06-25 Thread Thomas Schwinge
Hi Julian!

On 2020-06-16T15:39:42-0700, Julian Brown  wrote:
> This is a fix for the pointer (or array) size inadvertently being used
> for the bias of attach and detach clauses (PR95270)

Thanks for looking into that one, which had caused my some gray hair.

> for C and C++.

That means, there is no such problem for Fortran?  (I haven't run into
one, just curious.)

> OK?

In principle, yes, for master and releases/gcc-10 branches, but please
incorporate the following items:

>   PR middle-end/95270
>
>   gcc/c/
>   * c-typeck.c (c_finish_omp_clauses): Set OMP_CLAUSE_SIZE (bias) to zero
>   for standalone attach/detach clauses.
>
>   gcc/cp/
>   * semantics.c (finish_omp_clauses): Likewise.
>
>   gcc/testsuite/
>   * c-c++-common/goacc/mdc-1.c: Update expected dump output for zero
>   bias.
> ---
>  gcc/c/c-typeck.c |  8 
>  gcc/cp/semantics.c   |  8 
>  gcc/testsuite/c-c++-common/goacc/mdc-1.c | 14 +++---
>  3 files changed, 23 insertions(+), 7 deletions(-)

> --- a/gcc/c/c-typeck.c
> +++ b/gcc/c/c-typeck.c
> @@ -14533,6 +14533,10 @@ c_finish_omp_clauses (tree clauses, enum 
> c_omp_region_type ort)
>   }
> if (c_oacc_check_attachments (c))
>   remove = true;
> +   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
> +   && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
> +   || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH))
> + OMP_CLAUSE_SIZE (c) = size_zero_node;
> break;
>   }
> if (t == error_mark_node)
> @@ -14546,6 +14550,10 @@ c_finish_omp_clauses (tree clauses, enum 
> c_omp_region_type ort)
> remove = true;
> break;
>   }
> +   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
> +   && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
> +   || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH))
> + OMP_CLAUSE_SIZE (c) = size_zero_node;
> if (TREE_CODE (t) == COMPONENT_REF
> && OMP_CLAUSE_CODE (c) != OMP_CLAUSE__CACHE_)
>   {

I cannot comment if these two code paths are good places (and the only
ones) that need to set 'OMP_CLAUSE_SIZE', so I'll trust you've found the
best/all places.

Does that override an 'OMP_CLAUSE_SIZE' that was set earlier, or
initialize it?  Maybe the latter, given my comment in
: "make sure to skip/invalidate the
'gcc/gimplify.c:gimplify_scan_omp_clauses' handling"?

Plase add some commentary here in the code, instead of just in the
ChangeLog, something like: "initialize here, so that gimplify doesn't
wrongly do so later" (if that's what it is, and in proper language, of
course).

> --- a/gcc/cp/semantics.c
> +++ b/gcc/cp/semantics.c
> @@ -7334,6 +7334,10 @@ finish_omp_clauses (tree clauses, enum 
> c_omp_region_type ort)
>   }
> if (cp_oacc_check_attachments (c))
>   remove = true;
> +   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
> +   && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
> +   || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH))
> + OMP_CLAUSE_SIZE (c) = size_zero_node;
> break;
>   }
> if (t == error_mark_node)
> @@ -7347,6 +7351,10 @@ finish_omp_clauses (tree clauses, enum 
> c_omp_region_type ort)
> remove = true;
> break;
>   }
> +   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
> +   && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
> +   || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH))
> + OMP_CLAUSE_SIZE (c) = size_zero_node;
> if (REFERENCE_REF_P (t)
> && TREE_CODE (TREE_OPERAND (t, 0)) == COMPONENT_REF)
>   {

Likewise.

> --- a/gcc/testsuite/c-c++-common/goacc/mdc-1.c
> +++ b/gcc/testsuite/c-c++-common/goacc/mdc-1.c

Obvious.

In  I also requested size vs. bias be
documented in 'include/gomp-constants.h:enum gomp_map_kind'.

Generally, I'm still somewhat confused by the 'bias' usage in libgomp.
Is it really only used for the *initial* attach, but then (correctly so?)
ignored for any later ones?  Please add some commentary next to the
respective libgomp code.

Please also include an execution test case, like I had included with
, for example the two files I'm attaching.
Ah actually, since the directive variant now no longer fails, please
merge these into one file, with 'test(bool directive)', and two
'test(false)', 'test(true)' calls from 'main'.


Grüße
 Thomas


-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter
#define DIRECTIVE
#include "pr95270_-r.c"
// 

#include 
#include 

int main()
{
  int data;
  int *data_p_dev = (int *) acc_create(&data, s

[PATCH] Always use SLP vector defs to determine insertion place

2020-06-25 Thread Richard Biener
With the last vectorizable_shift patch we can now always use the
SLP vector defs to determine the vectorized stmt insertion place,
paving the way for a "verifier" for pending restructuring and
BB vectorization of reductions and other live stmts.

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

2020-06-25  Richard Biener  

* tree-vect-slp.c (vect_schedule_slp_instance): Always use
vector defs to determine insertion place.
---
 gcc/tree-vect-slp.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index b2792c76ad2..5883ec58c7a 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -4262,13 +4262,6 @@ vect_schedule_slp_instance (vec_info *vinfo,
   else if (SLP_TREE_CHILDREN (node).is_empty ())
 /* This happens for reduction PHIs.  */
 si = gsi_for_stmt (vect_find_last_scalar_stmt_in_slp (node)->stmt);
-  else if (stmt_vec_info first_stmt_info
-= vect_find_last_scalar_stmt_in_slp (node))
-/* ???  Shifts by scalars hit us here again, we end up vectorizing
-   the shift operand but end up using the scalar operand anyway.
-   This needs to be better reflected in the SLP tree.  For now
-   use the last position if available.  */
-si = gsi_for_stmt (first_stmt_info->stmt);
   else
 {
   /* Emit other stmts after the children vectorized defs which is
-- 
2.26.2


Re: [PATCH PR95700] Use nullptr instead of NULL as a sentinel value

2020-06-25 Thread Jonathan Wakely via Gcc-patches

On 25/06/20 13:29 +0200, Ilya Leoshkevich wrote:

On Wed, 2020-06-24 at 16:16 +0200, Richard Biener wrote:

On Wed, Jun 24, 2020 at 4:14 PM Jonathan Wakely via Gcc-patches
 wrote:
> On 24/06/20 12:31 +0200, Ilya Leoshkevich wrote:
> > Bootstrapped and regtested on x86_64-redhat-linux, ppc64le-
> > redhat-linux
> > and s390x-redhat-linux.
> >
> > Ok for master?
> >
> > ---
> >
> > Bootstrap with musl libc fails with numerous "missing sentinel in
> > function call" errors.  This is because musl defines NULL as 0L
> > for C++,
> > but gcc requires sentinel value to be a pointer or __null.
> >
> > Jonathan Wakely says:
> >
> >To be really safe during stage 1, GCC should not use NULL as a
> >pointer sentinel in C++ code anyway.
> >
> >The bootstrap compiler could define it to 0 or 0u, neither of
> > which
> >is guaranteed to be OK to pass as a varargs sentinel where a
> > null
> >pointer is expected.  Any of (void*)0 or (void*)NULL or
> > nullptr
> >would be safe.
> >
> > Therefore, fix by replacing NULL sentinels with nullptr.
>
> For some additional context, the C++ standard guarantees that
> passing
> nullptr to a varargs function will convert to (void*)0. That has
> been
> true since nullptr was added in C++11.

Is there a diagnostic option that we can turn on so no NULLs will
creep
in in such position?   Without that we'll bitrot quickly?


I couldn't find a useful existing warning for this.  The main


Doesn't -Wstrict-null-sentinel do it?

Warn about the use of an uncasted "NULL" as sentinel.  When
compiling only with GCC this is a valid sentinel, as "NULL" is
defined to "__null".  Although it is a null pointer constant
rather than a null pointer, it is guaranteed to be of the same
size as a pointer.  But this use is not portable across different
compilers.


difficulty in implementing it, as far as I can see, is that we need to
check preprocessor tokens that were used to generate a function
argument.


nullptr is not a macro, it's a keyword. A warning that flagged any
sentinel that isn't nullptr wouldn't need to look at preprocessor
tokens.

But I think -Wstrict-null-sentinel is better anyway, isn't it?


Can we somehow compare the source code of a function argument with
"NULL"?  At least diagnostic code should already able to access the
original (non-preprocessed) source code, can the warning code do this
as well?



Richard.






Re: [PATCH] reassoc: Propagate PHI_LOOP_BIAS along single uses

2020-06-25 Thread Richard Biener via Gcc-patches
On Wed, Jun 24, 2020 at 1:31 AM Ilya Leoshkevich via Gcc-patches
 wrote:
>
> Bootstrapped and regtested x86_64-redhat-linux, ppc64le-redhat-linux and
> s390x-redhat-linux.  I also ran SPEC 2006 and 2017 on these platforms,
> and the only measurable regression was 3% in 520.omnetpp_r on ppc, which
> went away after inserting a single nop at the beginning of
> cDynamicExpression::evaluate.
>
> OK for master?

As you might know this is incredibly fragile so I'd prefer if you submit
and push the change to disable PHI biasing in the early pass instance
separately.  At first glance that change looks reasonable (but we'll
watch for fallout).

Comments on the other changes inline

>
> ---
>
> PR tree-optimization/49749 introduced code that shortens dependency
> chains containing loop accumulators by placing them last on operand
> lists of associative operations.
>
> 456.hmmer benchmark on s390 could benefit from this, however, the code
> that needs it modifies loop accumulator before using it, and since only
> so-called loop-carried phis are are treated as loop accumulators, the
> code in the present form doesn't really help.   According to Bill
> Schmidt - the original author - such a conservative approach was chosen
> so as to avoid unnecessarily swapping operands, which might cause
> unpredictable effects.  However, giving special treatment to forms of
> loop accumulators is acceptable.
>
> The definition of loop-carried phi is: it's a single-use phi, which is
> used in the same innermost loop it's defined in, at least one argument
> of which is defined in the same innermost loop as the phi itself.
> Given this, it seems natural to treat single uses of such phis as phis
> themselves.
>
> gcc/ChangeLog:
>
> 2020-05-06  Ilya Leoshkevich  
>
> * passes.def (pass_reassoc): Rename parameter to early_p.
> * tree-ssa-reassoc.c (reassoc_bias_loop_carried_phi_ranks_p):
> New variable.
> (phi_rank): Don't bias loop-carried phi ranks
> before vectorization pass.
> (loop_carried_phi): Remove (superseded by
> operand_rank::biased_p).
> (propagate_rank): Propagate bias along single uses.
> (get_rank): Pass stmt to propagate_rank.
> (execute_reassoc): Add bias_loop_carried_phi_ranks_p parameter.
> (pass_reassoc::pass_reassoc): Add bias_loop_carried_phi_ranks_p
> initializer.
> (pass_reassoc::set_param): Set bias_loop_carried_phi_ranks_p
> value.
> (pass_reassoc::execute): Pass bias_loop_carried_phi_ranks_p to
> execute_reassoc.
> (pass_reassoc::bias_loop_carried_phi_ranks_p): New member.
>
> gcc/testsuite/ChangeLog:
>
> 2020-05-06  Ilya Leoshkevich  
>
> * gcc.target/s390/reassoc-1.c: New test.
> * gcc.target/s390/reassoc-2.c: New test.
> * gcc.target/s390/reassoc-3.c: New test.
> * gcc.target/s390/reassoc.h: New test.
> ---
>  gcc/passes.def|  4 +-
>  gcc/testsuite/gcc.target/s390/reassoc-1.c |  6 ++
>  gcc/testsuite/gcc.target/s390/reassoc-2.c |  7 ++
>  gcc/testsuite/gcc.target/s390/reassoc-3.c |  8 ++
>  gcc/testsuite/gcc.target/s390/reassoc.h   | 22 +
>  gcc/tree-ssa-reassoc.c| 97 ++-
>  6 files changed, 105 insertions(+), 39 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/s390/reassoc-1.c
>  create mode 100644 gcc/testsuite/gcc.target/s390/reassoc-2.c
>  create mode 100644 gcc/testsuite/gcc.target/s390/reassoc-3.c
>  create mode 100644 gcc/testsuite/gcc.target/s390/reassoc.h
>
> diff --git a/gcc/passes.def b/gcc/passes.def
> index 2b1e09fdda3..6864f583f20 100644
> --- a/gcc/passes.def
> +++ b/gcc/passes.def
> @@ -235,7 +235,7 @@ along with GCC; see the file COPYING3.  If not see
>  program and isolate those paths.  */
>NEXT_PASS (pass_isolate_erroneous_paths);
>NEXT_PASS (pass_dse);
> -  NEXT_PASS (pass_reassoc, true /* insert_powi_p */);
> +  NEXT_PASS (pass_reassoc, true /* early_p */);
>NEXT_PASS (pass_dce);
>NEXT_PASS (pass_forwprop);
>NEXT_PASS (pass_phiopt, false /* early_p */);
> @@ -312,7 +312,7 @@ along with GCC; see the file COPYING3.  If not see
>NEXT_PASS (pass_lower_vector_ssa);
>NEXT_PASS (pass_lower_switch);
>NEXT_PASS (pass_cse_reciprocals);
> -  NEXT_PASS (pass_reassoc, false /* insert_powi_p */);
> +  NEXT_PASS (pass_reassoc, false /* early_p */);
>NEXT_PASS (pass_strength_reduction);
>NEXT_PASS (pass_split_paths);
>NEXT_PASS (pass_tracer);
> diff --git a/gcc/testsuite/gcc.target/s390/reassoc-1.c 
> b/gcc/testsuite/gcc.target/s390/reassoc-1.c
> new file mode 100644
> index 000..8343f1cd4b7
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/s390/reassoc-1.c
> @@ -0,0 +1,6 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +#include "reassoc.h"
> +
> +/* { dg-final { scan-assembler 
> {(?n)\n\tl\t(%r\d+),.+(\n.*)*\n\ta\t(\1),.

Re: [PATCH 0/3, v2] rs6000: Add support for Matrix-Multiply Assist (MMA) built-in functions.

2020-06-25 Thread Peter Bergner via Gcc-patches
On 6/24/20 2:37 PM, Segher Boessenkool wrote:
> On Wed, Jun 24, 2020 at 02:28:00PM -0500, Peter Bergner via Gcc-patches wrote:
>> The back ports of the MMA patches/commits was straight forward and I'm
>> currently bootstrapping/regtesting the backports on both powerpc64le-linux
>> and powerpc64-linux.  Is this (including the hunk below) ok for GCC 10
>> release branch assuming the tests come back clean?
> 
> Yes, all are okay for 10 as well (incl. Kelvin's backport).  Thanks!
> 
>> rs6000: Backport u8bit_cint_operand predicate.
> 
> (No dot at the end of the subject please.)

Ok, testing was clean on BE and LE and I made the subject change you requested.
Back port has been pushed to GCC 10.  Thanks!

Peter




Re: [PATCH] libgomp, fortran: Apply if clause to all sub-constructs in combined OpenMP constructs

2020-06-25 Thread Kwok Cheung Yeung

On 24/06/2020 6:29 pm, Tobias Burnus wrote:

Hi Kwok,

the TODO is fixed by the attached patch; I would be happy if you could handle 
this patch,

e.g. together with your patch – or as follow up.

(Lightly tested only, i.e. it fixes the ICE but I did not
do a full testsuite run. But I regard it as obvious.)


Hello

I have committed your patch along with the testcase as 'obvious'. I have 
confirmed that it does not regress the gfortran and libgomp testsuites.


Kwok

commit f530bac8a11da9c85bdd8e58d589747f9825e38d
Author: Kwok Cheung Yeung 
Date:   Thu Jun 25 04:40:53 2020 -0700

fortran: Fix ICE when 'if' clause used with 'target parallel' (PR95869)

2020-06-25  Tobias Burnus  
Kwok Cheung Yeung  

gcc/fortran/

PR fortran/95869
* trans-openmp.c (gfc_trans_omp_target): Use correct scoping block.

gcc/testsuite/

PR fortran/95869
* gfortran.dg/gomp/combined-if.f90 (test_target_parallel): Re-enable.
* gfortran.dg/gomp/pr95869.f90: New.

diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 67b7094..22f8f96 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -5353,7 +5353,7 @@ gfc_trans_omp_target (gfc_code *code)
pushlevel ();
gfc_start_block (&iblock);
tree inner_clauses
- = gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_PARALLEL],
+ = gfc_trans_omp_clauses (&iblock, &clausesa[GFC_OMP_SPLIT_PARALLEL],
   code->loc);
stmt = gfc_trans_omp_code (code->block->next, true);
stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt,
diff --git a/gcc/testsuite/gfortran.dg/gomp/combined-if.f90 
b/gcc/testsuite/gfortran.dg/gomp/combined-if.f90
index 383086c..bf4a9a8 100644
--- a/gcc/testsuite/gfortran.dg/gomp/combined-if.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/combined-if.f90
@@ -18,17 +18,15 @@ contains
 end do
   end subroutine
 
-  ! TODO: This currently fails with an internal compiler error
-  ! (PR 95869)
-  !subroutine test_target_parallel
-  !  do j = 1, N
-  !!$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N))
-  !do i = 1, N
-  !  a(i) = a(i) + 1
-  !end do
-  !!$omp end target parallel
-  !   end do
-  !end subroutine
+  subroutine test_target_parallel
+do j = 1, N
+  !$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N))
+  do i = 1, N
+a(i) = a(i) + 1
+  end do
+  !$omp end target parallel
+ end do
+  end subroutine
 
   subroutine test_target_parallel_loop
 do j = 1, N
@@ -105,6 +103,6 @@ contains
 
 end module
 
-! { dg-final { scan-tree-dump-times "(?n)#pragma omp target.* if\\(" 8 
"omplower" } }
+! { dg-final { scan-tree-dump-times "(?n)#pragma omp target.* if\\(" 9 
"omplower" } }
 ! { dg-final { scan-tree-dump-times "(?n)#pragma omp simd.* if\\(" 7 
"omplower" } }
-! { dg-final { scan-tree-dump-times "(?n)#pragma omp parallel.* if\\(" 5 
"omplower" } }
+! { dg-final { scan-tree-dump-times "(?n)#pragma omp parallel.* if\\(" 6 
"omplower" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr95869.f90 
b/gcc/testsuite/gfortran.dg/gomp/pr95869.f90
new file mode 100644
index 000..daa8d21
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/pr95869.f90
@@ -0,0 +1,18 @@
+! PR fortran/95869
+! { dg-do compile }
+
+program pr95869
+  implicit none
+
+  integer, parameter :: N = 100
+  integer, parameter :: LIMIT = 60
+  integer :: i, j
+  integer, dimension(N) :: a = (/ (i, i = 1,N) /)
+  do j = 1, N
+!$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N))
+do i = 1, N
+  a(i) = a(i) + 1
+end do
+!$omp end target parallel
+end do
+end program


[Patch][Fortran, OpenMP] Fix allocatable-components check (PR67311)

2020-06-25 Thread Tobias Burnus

The test case was giving an ICE as it recursively called itself.
Rather obvious fix.

OK for the trunk?

Tobias

-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter
[Fortran, OpenMP] Fix allocatable-components check (PR67311)

gcc/fortran/ChangeLog:

	PR fortran/67311
	* trans-openmp.c (gfc_has_alloc_comps): Return false also for
	pointers to arrays.

libgomp/ChangeLog:

	PR fortran/67311
	* testsuite/libgomp.fortran/target-map-1.f90: New test.

 gcc/fortran/trans-openmp.c |  5 +++
 libgomp/testsuite/libgomp.fortran/target-map-1.f90 | 41 ++
 2 files changed, 46 insertions(+)

diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 22f8f96a60e..01d82ac11d1 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -330,6 +330,11 @@ gfc_has_alloc_comps (tree type, tree decl)
 	return false;
 }
 
+  if (GFC_DESCRIPTOR_TYPE_P (type)
+  && (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER
+	  || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT))
+return false;
+
   if (GFC_DESCRIPTOR_TYPE_P (type) || GFC_ARRAY_TYPE_P (type))
 type = gfc_get_element_type (type);
 
diff --git a/libgomp/testsuite/libgomp.fortran/target-map-1.f90 b/libgomp/testsuite/libgomp.fortran/target-map-1.f90
new file mode 100644
index 000..6107530d292
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/target-map-1.f90
@@ -0,0 +1,41 @@
+! PR fortran/67311
+
+implicit none
+  TYPE myType
+integer :: A
+TYPE(myType), DIMENSION(:), POINTER :: x
+TYPE(myType), DIMENSION(:), contiguous, POINTER :: y
+integer :: B
+  END TYPE myType
+  call openmp_sub
+contains
+  subroutine openmp_sub
+type(myType) :: argument
+
+!$OMP PARALLEL DEFAULT(NONE) PRIVATE(argument)
+  argument%a = 5
+  argument%b = 7
+  call foo(argument)
+  if (.not.associated(argument%x) .or. size(argument%x) /= 2) stop 2
+  if (argument%a /= 8 .or. argument%b /= 9 &
+  .or. any(argument%x(:)%a /= [2, 3]) &
+  .or. any(argument%x(:)%b /= [9, 1])) stop 3
+  if (.not.associated(argument%y) .or. size(argument%y) /= 3) stop 4
+  if (any(argument%y(:)%a /= [11, 22, 33]) &
+  .or. any(argument%y(:)%b /= [44, 55, 66])) stop 5
+  deallocate (argument%x, argument%y)
+!$OMP END PARALLEL
+  end subroutine openmp_sub
+  subroutine foo(x)
+type(myType), intent(inout) :: x
+!$omp declare target
+if (x%a /= 5 .or. x%b /= 7) stop 1
+x%a = 8; x%b = 9
+allocate (x%x(2))
+x%x(:)%a = [2, 3]
+x%x(:)%b = [9, 1]
+allocate (x%y(3))
+x%y(:)%a = [11, 22, 33]
+x%y(:)%b = [44, 55, 66]
+  end subroutine
+end


Re: Fortran: Fix character-kind=4 substring resolution (PR95837)

2020-06-25 Thread Thomas Koenig via Gcc-patches

Hi Tobias,


OK – with assert or without?


I don't think the assert is needed - if things go wrong there, then
I am quite sure that we will get all sorts of ICEs downstream if
this is not set correctly somewhere after all, and your testing
indicates that it is not.

Besides, I like the elegance of fixing a bug by just removing erroneous
code :-)

So, OK without the assert.

Thanks for the patch!

Best regards

Thomas


Re: [Patch][gcn, nvptx, offloading] mkoffload – handle -fpic/-fPIC

2020-06-25 Thread Thomas Schwinge
Hi Tobias!

On 2020-06-24T15:36:25+0200, Tobias Burnus  wrote:
> [...] who knows
> what users are doing...

Indeed.  ;-)


> On 6/23/20 9:36 PM, Thomas Schwinge wrote:
>> I don't think I can approve, but seems fine if this works (as you've
>> confirmed) -- it's one incremental step forward!

(Noting that nobody spoke up against this.)


>> What about 'gcc/config/i386/intelmic-mkoffload.c'?  I see that one
>> unconditionally passes '-fPIC' to some things -- is that doing the right
>> thing for your case, too?
>
> I have not setup intelmic to test, but it uses -fPIC -share throughout
> and in particular for the sister function to the one to those patched.
> Hence, I expect that it will simply work. – But I wouldn't mind if you
> could test that it indeed does work.

I did now test this manually on a simple example, and yes, it works.
(And, while Intel MIC offloading's emulated mode could be ported to other
targets, it currently isn't, so Intel MIC (emulated) 'mkoffload' only
needs to care about x86_64-pc-linux-gnu, and for that one, its
unconditional '-fPIC' seems to be doing the expected thing.)


Grüße
 Thomas
-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter


[PATCH] coroutines: Generalize promise expressions [PR95519]

2020-06-25 Thread Iain Sandoe
Hi,

The PR points out that the standard does not restrict promise
expressions to methods, but the current implementation does.

The patch factors out the building of a general promise expression,
and then uses it in a fairly mechanical replacement of each case
that we need such an expressions.

This extends the handling for p.xx() expressions to cover the
cases where the promise member is some form callable.

Tests are added for each of the promise expressions.

It's somewhat tortuous to find good uses for this for the
get-return-object and get-return-object-on-allocation-failure
cases, but they are included anyway.

tested on x86_64-darwin, linux, powerpc64-linux,
OK for master / 10.2?
thanks
Iain

gcc/cp/ChangeLog:

PR c++/95519
* coroutines.cc (struct coroutine_info):Add a field
to hold computed p.return_void expressions.
(coro_build_promise_expression): New.
(get_coroutine_return_void_expr): New.
(finish_co_yield_expr): Build the promise expression
using coro_build_promise_expression.
(finish_co_return_stmt): Likewise.
(build_init_or_final_await): Likewise.
(morph_fn_to_coro): Likewise, for several cases.

gcc/testsuite/ChangeLog:

PR c++/95519
* g++.dg/coroutines/torture/pr95519-00-return_void.C: New test.
* g++.dg/coroutines/torture/pr95519-01-initial-suspend.C: New test.
* g++.dg/coroutines/torture/pr95519-02-final_suspend.C: New test.
* g++.dg/coroutines/torture/pr95519-03-return-value.C: New test.
* g++.dg/coroutines/torture/pr95519-04-yield-value.C: New test.
* g++.dg/coroutines/torture/pr95519-05-gro.C: New test.
* g++.dg/coroutines/torture/pr95519-06-grooaf.C: New test.
* g++.dg/coroutines/torture/pr95519-07-unhandled-exception.C: New test.
---
 gcc/cp/coroutines.cc  | 195 ++
 .../torture/pr95519-00-return_void.C  |  63 ++
 .../torture/pr95519-01-initial-suspend.C  |  69 +++
 .../torture/pr95519-02-final_suspend.C|  69 +++
 .../torture/pr95519-03-return-value.C |  80 +++
 .../torture/pr95519-04-yield-value.C  |  84 
 .../coroutines/torture/pr95519-05-gro.C   |  64 ++
 .../coroutines/torture/pr95519-06-grooaf.C|  49 +
 .../torture/pr95519-07-unhandled-exception.C  |  69 +++
 9 files changed, 656 insertions(+), 86 deletions(-)
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-00-return_void.C
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-01-initial-suspend.C
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-02-final_suspend.C
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-03-return-value.C
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-04-yield-value.C
 create mode 100644 gcc/testsuite/g++.dg/coroutines/torture/pr95519-05-gro.C
 create mode 100644 gcc/testsuite/g++.dg/coroutines/torture/pr95519-06-grooaf.C
 create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-07-unhandled-exception.C

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index ba88b992a83..8b8d00e8e0c 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -88,6 +88,7 @@ struct GTY((for_user)) coroutine_info
one that will eventually be allocated in the coroutine
frame.  */
   tree promise_proxy; /* Likewise, a proxy promise instance.  */
+  tree return_void;   /* The expression for p.return_void() if it exists.  */
   location_t first_coro_keyword; /* The location of the keyword that made this
function into a coroutine.  */
   /* Flags to avoid repeated errors for per-function issues.  */
@@ -554,6 +555,67 @@ lookup_promise_method (tree fndecl, tree member_id, 
location_t loc,
   return pm_memb;
 }
 
+/* Build an expression of the form p.method (args) where the p is a promise
+   object for the current coroutine.
+   OBJECT is the promise object instance to use, it may be NULL, in which case
+   we will use the promise_proxy instance for this coroutine.
+   ARGS may be NULL, for empty parm lists.  */
+
+static tree
+coro_build_promise_expression (tree fn, tree promise_obj, tree member_id,
+  location_t loc, vec **args,
+  bool musthave)
+{
+  tree meth = lookup_promise_method (fn, member_id, loc, musthave);
+  if (meth == error_mark_node)
+return error_mark_node;
+
+  /* If we don't find it, and it isn't needed, an empty return is OK.  */
+  if (!meth)
+return NULL_TREE;
+
+  tree promise
+= promise_obj ? promise_obj
+ : get_coroutine_promise_proxy (current_function_decl);
+  tree expr;
+  if (BASELINK_P (meth))
+expr = build_new_method_call (promise, meth, args, NULL_TREE,
+ LOOKUP_NORMAL, NULL, tf_warning_or_error);
+  else
+  

Re: [PATCH] coroutines: Generalize promise expressions [PR95519]

2020-06-25 Thread Nathan Sidwell

On 6/25/20 11:15 AM, Iain Sandoe wrote:

Hi,

The PR points out that the standard does not restrict promise
expressions to methods, but the current implementation does.

The patch factors out the building of a general promise expression,
and then uses it in a fairly mechanical replacement of each case
that we need such an expressions.

This extends the handling for p.xx() expressions to cover the
cases where the promise member is some form callable.

Tests are added for each of the promise expressions.

It's somewhat tortuous to find good uses for this for the
get-return-object and get-return-object-on-allocation-failure
cases, but they are included anyway.

tested on x86_64-darwin, linux, powerpc64-linux,
OK for master / 10.2?
thanks
Iain


ok, thanks



gcc/cp/ChangeLog:

PR c++/95519
* coroutines.cc (struct coroutine_info):Add a field
to hold computed p.return_void expressions.
(coro_build_promise_expression): New.
(get_coroutine_return_void_expr): New.
(finish_co_yield_expr): Build the promise expression
using coro_build_promise_expression.
(finish_co_return_stmt): Likewise.
(build_init_or_final_await): Likewise.
(morph_fn_to_coro): Likewise, for several cases.

gcc/testsuite/ChangeLog:

PR c++/95519
* g++.dg/coroutines/torture/pr95519-00-return_void.C: New test.
* g++.dg/coroutines/torture/pr95519-01-initial-suspend.C: New test.
* g++.dg/coroutines/torture/pr95519-02-final_suspend.C: New test.
* g++.dg/coroutines/torture/pr95519-03-return-value.C: New test.
* g++.dg/coroutines/torture/pr95519-04-yield-value.C: New test.
* g++.dg/coroutines/torture/pr95519-05-gro.C: New test.
* g++.dg/coroutines/torture/pr95519-06-grooaf.C: New test.
* g++.dg/coroutines/torture/pr95519-07-unhandled-exception.C: New test.
---
  gcc/cp/coroutines.cc  | 195 ++
  .../torture/pr95519-00-return_void.C  |  63 ++
  .../torture/pr95519-01-initial-suspend.C  |  69 +++
  .../torture/pr95519-02-final_suspend.C|  69 +++
  .../torture/pr95519-03-return-value.C |  80 +++
  .../torture/pr95519-04-yield-value.C  |  84 
  .../coroutines/torture/pr95519-05-gro.C   |  64 ++
  .../coroutines/torture/pr95519-06-grooaf.C|  49 +
  .../torture/pr95519-07-unhandled-exception.C  |  69 +++
  9 files changed, 656 insertions(+), 86 deletions(-)
  create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-00-return_void.C
  create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-01-initial-suspend.C
  create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-02-final_suspend.C
  create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-03-return-value.C
  create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-04-yield-value.C
  create mode 100644 gcc/testsuite/g++.dg/coroutines/torture/pr95519-05-gro.C
  create mode 100644 gcc/testsuite/g++.dg/coroutines/torture/pr95519-06-grooaf.C
  create mode 100644 
gcc/testsuite/g++.dg/coroutines/torture/pr95519-07-unhandled-exception.C

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index ba88b992a83..8b8d00e8e0c 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -88,6 +88,7 @@ struct GTY((for_user)) coroutine_info
one that will eventually be allocated in the coroutine
frame.  */
tree promise_proxy; /* Likewise, a proxy promise instance.  */
+  tree return_void;   /* The expression for p.return_void() if it exists.  */
location_t first_coro_keyword; /* The location of the keyword that made this
function into a coroutine.  */
/* Flags to avoid repeated errors for per-function issues.  */
@@ -554,6 +555,67 @@ lookup_promise_method (tree fndecl, tree member_id, 
location_t loc,
return pm_memb;
  }
  
+/* Build an expression of the form p.method (args) where the p is a promise

+   object for the current coroutine.
+   OBJECT is the promise object instance to use, it may be NULL, in which case
+   we will use the promise_proxy instance for this coroutine.
+   ARGS may be NULL, for empty parm lists.  */
+
+static tree
+coro_build_promise_expression (tree fn, tree promise_obj, tree member_id,
+  location_t loc, vec **args,
+  bool musthave)
+{
+  tree meth = lookup_promise_method (fn, member_id, loc, musthave);
+  if (meth == error_mark_node)
+return error_mark_node;
+
+  /* If we don't find it, and it isn't needed, an empty return is OK.  */
+  if (!meth)
+return NULL_TREE;
+
+  tree promise
+= promise_obj ? promise_obj
+ : get_coroutine_promise_proxy (current_function_decl);
+  tree expr;
+  if (BASELINK_P (meth))
+expr = build_new_method_call (promise, meth, args, NULL_TREE,
+ 

[committed] d: Fix ICE in uda_attribute_p when looking up unknown attribute

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch fixes an ICE in uda_attribute_p when looking up an unknown
attribute.  The target attribute table is not guaranteed to be set by
all backends.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

PR d/95173
* d-attribs.cc (uda_attribute_p): Don't search target attribute table
if NULL.

gcc/testsuite/ChangeLog:

PR d/95173
* gdc.dg/pr95173.d: New test.
---
 gcc/d/d-attribs.cc |  9 ++---
 gcc/testsuite/gdc.dg/pr95173.d | 10 ++
 2 files changed, 16 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr95173.d

diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc
index 964f59f96f4..f4086c0f0ee 100644
--- a/gcc/d/d-attribs.cc
+++ b/gcc/d/d-attribs.cc
@@ -216,10 +216,13 @@ uda_attribute_p (const char *name)
return true;
 }
 
-  for (const attribute_spec *p = targetm.attribute_table; p->name; p++)
+  if (targetm.attribute_table)
 {
-  if (get_identifier (p->name) == ident)
-   return true;
+  for (const attribute_spec *p = targetm.attribute_table; p->name; p++)
+   {
+ if (get_identifier (p->name) == ident)
+   return true;
+   }
 }
 
   return false;
diff --git a/gcc/testsuite/gdc.dg/pr95173.d b/gcc/testsuite/gdc.dg/pr95173.d
new file mode 100644
index 000..2a4b2ed8232
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr95173.d
@@ -0,0 +1,10 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95173
+// { dg-do compile }
+// { dg-options "-Wattributes" }
+
+import gcc.attribute;
+
+@attribute("foo") // { dg-warning "unknown attribute .foo." }
+void f95173() 
+{
+}
-- 
2.25.1



[committed] d: Don't set DECL_INITIAL if initializer is 'void'.

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch fixes a logic bug in the code-gen for variable declarations.

Declarations initialized with `= void` were being default initialized.
That is not really the intent, and misses the small optimization that
should have been gained from using void initializations.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

* decl.cc (DeclVisitor::visit (VarDeclaration *)): Don't set
DECL_INITIAL if initializer is 'void'.

gcc/testsuite/ChangeLog:

* gdc.dg/init1.d: New test.
---
 gcc/d/decl.cc| 11 ---
 gcc/testsuite/gdc.dg/init1.d |  9 +
 2 files changed, 17 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/init1.d

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index ea6614fb714..77144fe11c8 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -697,13 +697,18 @@ public:
return;
  }
 
-   if (d->_init && !d->_init->isVoidInitializer ())
+   if (d->_init)
  {
-   Expression *e = initializerToExpression (d->_init, d->type);
-   DECL_INITIAL (decl) = build_expr (e, true);
+   /* Use the explicit initializer, this includes `void`.  */
+   if (!d->_init->isVoidInitializer ())
+ {
+   Expression *e = initializerToExpression (d->_init, d->type);
+   DECL_INITIAL (decl) = build_expr (e, true);
+ }
  }
else
  {
+   /* Use default initializer for the type.  */
if (TypeStruct *ts = d->type->isTypeStruct ())
  DECL_INITIAL (decl) = layout_struct_initializer (ts->sym);
else
diff --git a/gcc/testsuite/gdc.dg/init1.d b/gcc/testsuite/gdc.dg/init1.d
new file mode 100644
index 000..679ad15460e
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/init1.d
@@ -0,0 +1,9 @@
+// { dg-do run { target hw } }
+// { dg-options "-fno-druntime" }
+// 'a' should not be default initialized to -1.
+static char a = void;
+
+extern (C) void main()
+{
+assert(a == 0);
+}
-- 
2.25.1



[committed] d: Merge upstream dmd 4be011355.

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch merges the D front-end implementation with upstream dmd
4be011355.  Fixes self-assignment warnings seen when compiling with
clang.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

PR d/95075
* dmd/MERGE: Merge upstream dmd 4be011355.
---
 gcc/d/dmd/MERGE|  2 +-
 gcc/d/dmd/dscope.c | 98 +-
 2 files changed, 55 insertions(+), 45 deletions(-)

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 0d50149a750..7de89351482 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-90450f3ef6ab8551b5f383d8c6190f80034dbf93
+4be011355dd2c5e2e54b99f9369d5faeabca2ca5
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/dscope.c b/gcc/d/dmd/dscope.c
index 32aa965a932..32caf7d2409 100644
--- a/gcc/d/dmd/dscope.c
+++ b/gcc/d/dmd/dscope.c
@@ -291,54 +291,64 @@ unsigned *Scope::saveFieldInit()
 return fi;
 }
 
-static bool mergeFieldInit(unsigned &fieldInit, unsigned fi, bool mustInit)
+/
+ * Merge `b` flow analysis results into `a`.
+ * Params:
+ *  a = the path to merge fi into
+ *  b = the other path
+ * Returns:
+ *  false means either `a` or `b` skips initialization
+ */
+static bool mergeFieldInit(unsigned &a, const unsigned b)
 {
-if (fi != fieldInit)
-{
-// Have any branches returned?
-bool aRet = (fi& CSXreturn) != 0;
-bool bRet = (fieldInit & CSXreturn) != 0;
+if (b == a)
+return true;
 
-// Have any branches halted?
-bool aHalt = (fi& CSXhalt) != 0;
-bool bHalt = (fieldInit & CSXhalt) != 0;
+// Have any branches returned?
+bool aRet = (a & CSXreturn) != 0;
+bool bRet = (b & CSXreturn) != 0;
 
-bool ok;
+// Have any branches halted?
+bool aHalt = (a & CSXhalt) != 0;
+bool bHalt = (b & CSXhalt) != 0;
 
-if (aHalt && bHalt)
-{
-ok = true;
-fieldInit = CSXhalt;
-}
-else if (!aHalt && aRet)
-{
-ok = !mustInit || (fi & CSXthis_ctor);
-fieldInit = fieldInit;
-}
-else if (!bHalt && bRet)
-{
-ok = !mustInit || (fieldInit & CSXthis_ctor);
-fieldInit = fi;
-}
-else if (aHalt)
-{
-ok = !mustInit || (fieldInit & CSXthis_ctor);
-fieldInit = fieldInit;
-}
-else if (bHalt)
-{
-ok = !mustInit || (fi & CSXthis_ctor);
-fieldInit = fi;
-}
-else
-{
-ok = !mustInit || !((fieldInit ^ fi) & CSXthis_ctor);
-fieldInit |= fi;
-}
+if (aHalt && bHalt)
+{
+a = CSXhalt;
+return true;
+}
 
-return ok;
+// The logic here is to prefer the branch that neither halts nor returns.
+bool ok;
+if (!bHalt && bRet)
+{
+// Branch b returns, no merging required.
+ok = (b & CSXthis_ctor);
+}
+else if (!aHalt && aRet)
+{
+// Branch a returns, but b doesn't, b takes precedence.
+ok = (a & CSXthis_ctor);
+a = b;
+}
+else if (bHalt)
+{
+// Branch b halts, no merging required.
+ok = (a & CSXthis_ctor);
+}
+else if (aHalt)
+{
+// Branch a halts, but b doesn't, b takes precedence
+ok = (b & CSXthis_ctor);
+a = b;
+}
+else
+{
+// Neither branch returns nor halts, merge flags
+ok = !((a ^ b) & CSXthis_ctor);
+a |= b;
 }
-return true;
+return ok;
 }
 
 void Scope::mergeFieldInit(Loc loc, unsigned *fies)
@@ -356,9 +366,9 @@ void Scope::mergeFieldInit(Loc loc, unsigned *fies)
 bool mustInit = (v->storage_class & STCnodefaultctor ||
  v->type->needsNested());
 
-if (!::mergeFieldInit(fieldinit[i], fies[i], mustInit))
+if (!::mergeFieldInit(fieldinit[i], fies[i]) && mustInit)
 {
-::error(loc, "one path skips field %s", 
ad->fields[i]->toChars());
+::error(loc, "one path skips field %s", v->toChars());
 }
 }
 }
-- 
2.25.1



[committed] d: Do not implicitly set DECL_DECLARED_INLINE_P on member functions.

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch removes the implicit setting of DECL_DECLARATED_INLINE_P on
member function.

This has been questionable behaviour since it was added, and though it
has no effect on wider discussions around what should be the correct
semantics of pragma(inline) within D modules, doing this tree-level
optimization has mostly zero benefit as cross-module inlining doesn't
happen anyway.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

* decl.cc (get_symbol_decl): Do not implicitly set
DECL_DECLARED_INLINE_P on member functions.
---
 gcc/d/decl.cc | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 77144fe11c8..15eb9a43399 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -1250,13 +1250,6 @@ get_symbol_decl (Declaration *decl)
}
 
   /* Miscellaneous function flags.  */
-  if (fd->isMember2 () || fd->isFuncLiteralDeclaration ())
-   {
- /* See grokmethod in cp/decl.c.  Maybe we shouldn't be setting inline
-flags without reason or proper handling.  */
- DECL_DECLARED_INLINE_P (decl->csym) = 1;
- DECL_NO_INLINE_WARNING_P (decl->csym) = 1;
-   }
 
   /* In [pragma/inline], functions decorated with `pragma(inline)' affects
 whether they are inlined or not.  */
-- 
2.25.1



[committed] d: Merge upstream dmd 5fc1806cd.

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch merges the D front-end implementation with upstream dmd
5fc1806cd.  Backports the OutBuffer interface from upstream dmd master,
removing another difference this and the self-hosted D branch that is
purely refactoring, and doesn't introduce any mechanical changes.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 5fc1806cd.
* d-lang.cc (d_parse_file): Use peekChars to get string representation
of OutBuffer data.
---
 gcc/d/d-lang.cc|   4 +-
 gcc/d/dmd/MERGE|   2 +-
 gcc/d/dmd/dcast.c  |   8 +--
 gcc/d/dmd/dmacro.c |  24 +++
 gcc/d/dmd/dmangle.c|  16 ++---
 gcc/d/dmd/dmodule.c|   6 +-
 gcc/d/dmd/doc.c| 144 ++---
 gcc/d/dmd/dsymbol.h|   2 +-
 gcc/d/dmd/expression.c |   2 +-
 gcc/d/dmd/hdrgen.c |   6 +-
 gcc/d/dmd/json.c   |  32 -
 gcc/d/dmd/lexer.c  |  54 +++---
 gcc/d/dmd/macro.h  |   2 +-
 gcc/d/dmd/mtype.c  |   6 +-
 gcc/d/dmd/root/filename.c  |   6 +-
 gcc/d/dmd/root/outbuffer.c | 118 +++---
 gcc/d/dmd/root/outbuffer.h |  19 +++--
 17 files changed, 224 insertions(+), 227 deletions(-)

diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 24a1125ef8d..e4d0a24c65c 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -1043,7 +1043,7 @@ d_parse_file (void)
  buf.writestring (s);
}
 
- message ("%.*s", (int) buf.offset, (char *) buf.data);
+ message ("%s", buf.peekChars ());
}
 }
 
@@ -1361,7 +1361,7 @@ d_parse_file (void)
  buf.doindent = 1;
 
  moduleToBuffer (&buf, m);
- message ("%.*s", (int) buf.offset, (char *) buf.data);
+ message ("%s", buf.peekChars ());
}
 }
 
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index a13b5c1fae5..0e48f42a0e2 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-4f1046222f3a15a746ad2455e1099ed31e39b554
+5fc1806cd7dd281e944022df2e11ef6b04ee4339
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/dcast.c b/gcc/d/dmd/dcast.c
index ad91a65f6ad..1fc9d936bbd 100644
--- a/gcc/d/dmd/dcast.c
+++ b/gcc/d/dmd/dcast.c
@@ -1758,7 +1758,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *t)
 else
 buffer.writeUTF16(c);
 }
-newlen = buffer.offset / 2;
+newlen = buffer.length() / 2;
 buffer.writeUTF16(0);
 goto L1;
 
@@ -1785,7 +1785,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *t)
 else
 buffer.writeUTF8(c);
 }
-newlen = buffer.offset;
+newlen = buffer.length();
 buffer.writeUTF8(0);
 goto L1;
 
@@ -1812,7 +1812,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *t)
 buffer.writeUTF8(c);
 newlen++;
 }
-newlen = buffer.offset;
+newlen = buffer.length();
 buffer.writeUTF8(0);
 goto L1;
 
@@ -1826,7 +1826,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *t)
 buffer.writeUTF16(c);
 newlen++;
 }
-newlen = buffer.offset / 2;
+newlen = buffer.length() / 2;
 buffer.writeUTF16(0);
 goto L1;
 
diff --git a/gcc/d/dmd/dmacro.c b/gcc/d/dmd/dmacro.c
index a7558b73ef1..07187612616 100644
--- a/gcc/d/dmd/dmacro.c
+++ b/gcc/d/dmd/dmacro.c
@@ -237,14 +237,14 @@ void Macro::expand(OutBuffer *buf, size_t start, size_t 
*pend,
 
 size_t end = *pend;
 assert(start <= end);
-assert(end <= buf->offset);
+assert(end <= buf->length());
 
 /* First pass - replace $0
  */
 arg = memdup(arg, arglen);
 for (size_t u = start; u + 1 < end; )
 {
-utf8_t *p = (utf8_t *)buf->data;   // buf->data is not loop invariant
+utf8_t *p = (utf8_t *)buf->slice().ptr;   // buf->slice().ptr is not 
loop invariant
 
 /* Look for $0, but not $$0, and replace it with arg.
  */
@@ -294,8 +294,8 @@ void Macro::expand(OutBuffer *buf, size_t start, size_t 
*pend,
 {
 // Replace '$1' with '\xFF{arg\xFF}'
 //printf("Replacing '$%c' with '\xFF{%.*s\xFF}'\n", p[u + 1], 
marglen, marg);
-buf->data[u] = 0xFF;
-buf->data[u + 1] = '{';
+buf->slice().ptr[u] = 0xFF;
+buf->slice().ptr[u + 1] = '{';
 buf->insert(u + 

[committed] d: Merge upstream dmd 4f1046222.

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch merges the D front-end implementation with upstream dmd
4f1046222.  Renames OnScopeStatement to ScopeGuardStatement.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 4f1046222.
* toir.cc (IRVisitor::visit (OnScopeGuardStatement *)): Rename to ...
(IRVisitor::visit (ScopeGuardStatement *)): ... this.
---
 gcc/d/dmd/MERGE  |  2 +-
 gcc/d/dmd/blockexit.c|  2 +-
 gcc/d/dmd/clone.c|  2 +-
 gcc/d/dmd/dinterpret.c   |  4 ++--
 gcc/d/dmd/func.c |  2 +-
 gcc/d/dmd/hdrgen.c   |  2 +-
 gcc/d/dmd/parse.c|  2 +-
 gcc/d/dmd/sapply.c   |  2 +-
 gcc/d/dmd/scope.h|  2 +-
 gcc/d/dmd/statement.c| 14 +++---
 gcc/d/dmd/statement.h|  8 
 gcc/d/dmd/statementsem.c |  4 ++--
 gcc/d/dmd/visitor.h  |  4 ++--
 gcc/d/toir.cc|  2 +-
 14 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index d6b2a2a3791..a13b5c1fae5 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-13d67c5757b83a86411e510bd65a6b5167241324
+4f1046222f3a15a746ad2455e1099ed31e39b554
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/blockexit.c b/gcc/d/dmd/blockexit.c
index d4088f5c691..4705862e025 100644
--- a/gcc/d/dmd/blockexit.c
+++ b/gcc/d/dmd/blockexit.c
@@ -435,7 +435,7 @@ int blockExit(Statement *s, FuncDeclaration *func, bool 
mustNotThrow)
 result |= finalresult & ~BEfallthru;
 }
 
-void visit(OnScopeStatement *)
+void visit(ScopeGuardStatement *)
 {
 // At this point, this statement is just an empty placeholder
 result = BEfallthru;
diff --git a/gcc/d/dmd/clone.c b/gcc/d/dmd/clone.c
index a704d1397fe..dd22fb340f5 100644
--- a/gcc/d/dmd/clone.c
+++ b/gcc/d/dmd/clone.c
@@ -914,7 +914,7 @@ FuncDeclaration *buildPostBlit(StructDeclaration *sd, Scope 
*sc)
 
 ex = new CallExp(loc, new IdentifierExp(loc, Id::__ArrayDtor), ex);
 }
-a->push(new OnScopeStatement(loc, TOKon_scope_failure, new 
ExpStatement(loc, ex)));
+a->push(new ScopeGuardStatement(loc, TOKon_scope_failure, new 
ExpStatement(loc, ex)));
 }
 
 // Build our own "postblit" which executes a, but only if needed.
diff --git a/gcc/d/dmd/dinterpret.c b/gcc/d/dmd/dinterpret.c
index ada1d8bc54f..dd1105c03bd 100644
--- a/gcc/d/dmd/dinterpret.c
+++ b/gcc/d/dmd/dinterpret.c
@@ -439,7 +439,7 @@ public:
 ctfeCompile(s->statement);
 }
 
-void visit(OnScopeStatement *)
+void visit(ScopeGuardStatement *)
 {
 // rewritten to try/catch/finally
 assert(0);
@@ -1753,7 +1753,7 @@ public:
 result = new ThrownExceptionExp(s->loc, (ClassReferenceExp *)e);
 }
 
-void visit(OnScopeStatement *)
+void visit(ScopeGuardStatement *)
 {
 assert(0);
 }
diff --git a/gcc/d/dmd/func.c b/gcc/d/dmd/func.c
index 008f09726b4..b6849559bf6 100644
--- a/gcc/d/dmd/func.c
+++ b/gcc/d/dmd/func.c
@@ -194,7 +194,7 @@ public:
 if (s->finalbody)
 visitStmt(s->finalbody);
 }
-void visit(OnScopeStatement *) {  }
+void visit(ScopeGuardStatement *) {  }
 void visit(ThrowStatement *) {  }
 void visit(DebugStatement *s)
 {
diff --git a/gcc/d/dmd/hdrgen.c b/gcc/d/dmd/hdrgen.c
index 11a06a88ce9..33a804fdba1 100644
--- a/gcc/d/dmd/hdrgen.c
+++ b/gcc/d/dmd/hdrgen.c
@@ -618,7 +618,7 @@ public:
 buf->writenl();
 }
 
-void visit(OnScopeStatement *s)
+void visit(ScopeGuardStatement *s)
 {
 buf->writestring(Token::toChars(s->tok));
 buf->writeByte(' ');
diff --git a/gcc/d/dmd/parse.c b/gcc/d/dmd/parse.c
index 4aec7a46e7b..f4cd28ed2fb 100644
--- a/gcc/d/dmd/parse.c
+++ b/gcc/d/dmd/parse.c
@@ -5395,7 +5395,7 @@ Statement *Parser::parseStatement(int flags, const 
utf8_t** endPtr, Loc *pEndloc
 nextToken();
 check(TOKrparen);
 Statement *st = parseStatement(PSscope);
-s = new OnScopeStatement(loc, t, st);
+s = new ScopeGuardStatement(loc, t, st);
 break;
 }
 
diff --git a/gcc/d/dmd/sapply.c b/gcc/d/dmd/sapply.c
index b15d2a8dabf..35e38c151ac 100644
--- a/gcc/d/dmd/sapply.c
+++ b/gcc/d/dmd/sapply.c
@@ -133,7 +133,7 @@ public:
 {
 doCond(s->_body) || doCond(s->finalbody) || applyTo(s);
 }
-void visit(OnScopeStatement *s)
+void visit(ScopeGuardStatement *s)
 {
 doCond(s->statement) || applyTo(s);
 }
diff --git a/gcc/d/dmd/scope.h b/gcc/d/dmd/scope.h
index 7456f7098f6..b22823fb846 100644
--- a/gcc/d/dmd/scope.h
+++ b/gcc/d/dmd/scope.h
@@ -77,7 +77,7 @@ struct Scope
 LabelStatement *slabel; // enclosing labelled statement
 SwitchStatement *sw;// enclosing swi

[committed] d: Merge upstream dmd 90450f3ef.

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch merges the D front-end implementation with upstream dmd
90450f3ef.  Fixes a regression caused by an incomplete backport of
converting the Expression semantic pass to a Visitor.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

PR d/95250
* dmd/MERGE: Merge upstream dmd 90450f3ef.

gcc/testsuite/ChangeLog:

PR d/95250
* gdc.dg/pr95250.d: New test.
---
 gcc/d/dmd/MERGE|  2 +-
 gcc/d/dmd/expressionsem.c  |  1 +
 gcc/testsuite/gdc.dg/pr95250.d | 18 ++
 3 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr95250.d

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 0e48f42a0e2..0d50149a750 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-5fc1806cd7dd281e944022df2e11ef6b04ee4339
+90450f3ef6ab8551b5f383d8c6190f80034dbf93
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c
index e3a5cb36a82..ac6b5bc81f3 100644
--- a/gcc/d/dmd/expressionsem.c
+++ b/gcc/d/dmd/expressionsem.c
@@ -6883,6 +6883,7 @@ public:
 if (Expression *ex = binSemanticProp(exp, sc))
 {
 result = ex;
+return;
 }
 Expression *e = exp->op_overload(sc);
 if (e)
diff --git a/gcc/testsuite/gdc.dg/pr95250.d b/gcc/testsuite/gdc.dg/pr95250.d
new file mode 100644
index 000..c8810c41968
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr95250.d
@@ -0,0 +1,18 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250
+// { dg-do compile }
+
+template Unsigned(T)
+{
+static assert(false, "Type " ~ T.stringof ~
+  " does not have an Unsigned counterpart");
+}
+
+
+void* f95250(T)(T a, T b)
+{
+alias UnsignedVoid = Unsigned!(T);
+return cast(T)(cast(T)(cast(UnsignedVoid)(a-b) / 2));
+}
+
+static assert(is(typeof(f!(void*)(null, null)) == void*));
+// { dg-error "static assert  \(.*\) is false" "" { target *-*-* } .-1 }
-- 
2.25.1



[COMMITTED} m32r: Disable movsicc pattern

2020-06-25 Thread Nick Clifton via Gcc-patches
Hi Guys,

  I am checking in the patch below to fix several failures in the GCC
  testsuite for the M32R target.  The issue is the movsicc pattern which
  is a holdover from when the port from converted from using cc0.  The
  pattern was written as if a previous instruction had set the CC bits,
  whereas in fact it is supposed to move CC bits into a general
  register.

  The patch disables the movsicc pattern, which means that some
  optimizations can be missed, but it does also fix the following
  tests:

> PASS: gcc.c-torture/execute/20040709-1.c   -O2  execution test
> PASS: gcc.c-torture/execute/20040709-1.c   -O3 -fomit-frame-pointer 
> -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> PASS: gcc.c-torture/execute/20040709-1.c   -O3 -g  execution test
> PASS: gcc.c-torture/execute/20040709-1.c   -Os  execution test
> PASS: gcc.c-torture/execute/20040709-1.c   -O2 -flto -fno-use-linker-plugin 
> -flto-partition=none  execution test
> PASS: gcc.c-torture/execute/20040709-1.c   -O2 -flto -fuse-linker-plugin 
> -fno-fat-lto-objects  execution test
> PASS: gcc.c-torture/execute/20040709-2.c   -O2  execution test
> PASS: gcc.c-torture/execute/20040709-2.c   -O3 -fomit-frame-pointer 
> -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> PASS: gcc.c-torture/execute/20040709-2.c   -O3 -g  execution test
> PASS: gcc.c-torture/execute/20040709-2.c   -Os  execution test
> PASS: gcc.c-torture/execute/20040709-2.c   -O2 -flto -fno-use-linker-plugin 
> -flto-partition=none  execution test
> PASS: gcc.c-torture/execute/20040709-2.c   -O2 -flto -fuse-linker-plugin 
> -fno-fat-lto-objects  execution test
> PASS: gcc.c-torture/execute/20040709-3.c   -O2  execution test
> PASS: gcc.c-torture/execute/20040709-3.c   -O3 -g  execution test
> PASS: gcc.c-torture/execute/20040709-3.c   -Os  execution test
> PASS: gcc.c-torture/execute/20040709-3.c   -O2 -flto -fno-use-linker-plugin 
> -flto-partition=none  execution test
> PASS: gcc.c-torture/execute/20040709-3.c   -O2 -flto -fuse-linker-plugin 
> -fno-fat-lto-objects  execution test
> PASS: gcc.dg/strcmpopt_2.c execution test
> PASS: gcc.dg/lto/pr67452 c_lto_pr67452_0.o-c_lto_pr67452_0.o link,  -O2 -flto 
> -fopenmp-simd 

Cheers
  Nick

gcc/ChangeLog
2020-06-25  Nick Clifton  

* config/m32r/m32r.md (movsicc): Disable pattern.

diff --git a/gcc/config/m32r/m32r.md b/gcc/config/m32r/m32r.md
index 823342af1b4..6ecd9ce89ab 100644
--- a/gcc/config/m32r/m32r.md
+++ b/gcc/config/m32r/m32r.md
@@ -2162,6 +2162,12 @@
   ""
   "
 {
+  /* FIXME: This expansion is hold over from a failed conversion of this
+ port away from using cc0.  It still relies upon the last comparison
+ being the one that is now tested.  Disabled for now in order to
+ improve the generation of working code.  */
+  FAIL;
+
   if (! zero_and_one (operands [2], operands [3]))
 FAIL;
 



[committed] d: Move d_signed_type and d_unsigned_type to types.cc

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch moves d_signed_type and d_unsigned_type to types.cc.

These two functions are not tied to the language-specific part of the
front-end in any way.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

* d-lang.cc (d_gimplify_expr_p): Make static.
(d_parse_file): Likewise.
(d_signed_or_unsigned_type): Move to types.cc.
(d_unsigned_type): Likewise.
(d_signed_type): Likewise.
* d-tree.h (d_unsigned_type): Change the location in file.
(d_signed_type): Likewise.
* types.cc (d_signed_or_unsigned_type): Moved from d-lang.cc.
(d_unsigned_type): Likewise.
(d_signed_type): Likewise.
---
 gcc/d/d-lang.cc | 47 ++-
 gcc/d/d-tree.h  |  4 ++--
 gcc/d/types.cc  | 43 +++
 3 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 2c474f8adea..6412c1c204c 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -880,7 +880,7 @@ empty_modify_p (tree type, tree op)
 /* Implements the lang_hooks.gimplify_expr routine for language D.
Do gimplification of D specific expression trees in EXPR_P.  */
 
-int
+static int
 d_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
 gimple_seq *post_p ATTRIBUTE_UNUSED)
 {
@@ -1024,7 +1024,7 @@ d_add_entrypoint_module (Module *entry, Module *root)
 
 /* Implements the lang_hooks.parse_file routine for language D.  */
 
-void
+static void
 d_parse_file (void)
 {
   if (global.params.verbose)
@@ -1507,49 +1507,6 @@ d_type_for_size (unsigned bits, int unsignedp)
   return 0;
 }
 
-/* Return the signed or unsigned version of TYPE, an integral type, the
-   signedness being specified by UNSIGNEDP.  */
-
-static tree
-d_signed_or_unsigned_type (int unsignedp, tree type)
-{
-  if (TYPE_UNSIGNED (type) == (unsigned) unsignedp)
-return type;
-
-  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_cent_type))
-return unsignedp ? d_ucent_type : d_cent_type;
-
-  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_long_type))
-return unsignedp ? d_ulong_type : d_long_type;
-
-  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_int_type))
-return unsignedp ? d_uint_type : d_int_type;
-
-  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_short_type))
-return unsignedp ? d_ushort_type : d_short_type;
-
-  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_byte_type))
-return unsignedp ? d_ubyte_type : d_byte_type;
-
-  return signed_or_unsigned_type_for (unsignedp, type);
-}
-
-/* Return the unsigned version of TYPE, an integral type.  */
-
-tree
-d_unsigned_type (tree type)
-{
-  return d_signed_or_unsigned_type (1, type);
-}
-
-/* Return the signed version of TYPE, an integral type.  */
-
-tree
-d_signed_type (tree type)
-{
-  return d_signed_or_unsigned_type (0, type);
-}
-
 /* Implements the lang_hooks.types.type_promotes_to routine for language D.
All promotions for variable arguments are handled by the D frontend.  */
 
diff --git a/gcc/d/d-tree.h b/gcc/d/d-tree.h
index 4ae38d187d7..b4b832f9ad8 100644
--- a/gcc/d/d-tree.h
+++ b/gcc/d/d-tree.h
@@ -598,8 +598,6 @@ extern d_tree_node_structure_enum d_tree_node_structure 
(lang_tree_node *);
 extern struct lang_type *build_lang_type (Type *);
 extern struct lang_decl *build_lang_decl (Declaration *);
 extern tree d_pushdecl (tree);
-extern tree d_unsigned_type (tree);
-extern tree d_signed_type (tree);
 extern void d_keep (tree);
 
 /* In decl.cc.  */
@@ -672,6 +670,8 @@ extern void add_stmt (tree);
 extern void build_function_body (FuncDeclaration *);
 
 /* In types.cc.  */
+extern tree d_unsigned_type (tree);
+extern tree d_signed_type (tree);
 extern bool valist_array_p (Type *);
 extern bool empty_aggregate_p (tree);
 extern bool same_type_p (Type *, Type *);
diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index b8984a50ff0..0d05e4d82b3 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -42,6 +42,49 @@ along with GCC; see the file COPYING3.  If not see
 #include "d-tree.h"
 
 
+/* Return the signed or unsigned version of TYPE, an integral type, the
+   signedness being specified by UNSIGNEDP.  */
+
+static tree
+d_signed_or_unsigned_type (int unsignedp, tree type)
+{
+  if (TYPE_UNSIGNED (type) == (unsigned) unsignedp)
+return type;
+
+  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_cent_type))
+return unsignedp ? d_ucent_type : d_cent_type;
+
+  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_long_type))
+return unsignedp ? d_ulong_type : d_long_type;
+
+  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_int_type))
+return unsignedp ? d_uint_type : d_int_type;
+
+  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_short_type))
+return unsignedp ? d_ushort_type : d_short_type;
+
+  if (TYPE_PRECISION (type) == TYPE_PRECISION (d_byte_type))
+return unsignedp ? d_ubyte_type : d_byte_type;
+
+  return signed_or_unsigned_type_f

[committed] d: Turn on deprecation warnings by default.

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch makes deprecation warnings the default in gdc, fixing both
the library and any tests that are currently using deprecated styles.
This is the default in the upstream reference compiler, and can reduce
some confusion when comparing warning/error messages of gdc and dmd side
by side.

Merges libphobos with upstream druntime d05ebaad and phobos 021ae0df7.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

* d-lang.cc (d_init_options): Turn on deprecation warnings by default.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime d05ebaad.
* src/MERGE: Merge upstream phobos 021ae0df7.
* testsuite/libphobos.typeinfo/struct-align.d: Remove empty statement.

gcc/testsuite/ChangeLog:

* gdc.dg/asm1.d: Don't use deprecated asm syntax.
* gdc.dg/compilable.d: Add public to selective import.
* gdc.dg/lto/ltotests_0.d: Explicitly catch Throwable.
* gdc.dg/runnable.d: Remove empty statement.
---
 gcc/d/d-lang.cc   | 2 +-
 gcc/testsuite/gdc.dg/asm1.d   | 8 
 gcc/testsuite/gdc.dg/compilable.d | 2 +-
 gcc/testsuite/gdc.dg/lto/ltotests_0.d | 2 +-
 gcc/testsuite/gdc.dg/runnable.d   | 2 +-
 libphobos/libdruntime/MERGE   | 2 +-
 libphobos/libdruntime/rt/util/utf.d   | 4 ++--
 libphobos/src/MERGE   | 2 +-
 libphobos/src/std/range/package.d | 2 +-
 libphobos/testsuite/libphobos.typeinfo/struct-align.d | 2 +-
 10 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 82e24de8cd1..24a1125ef8d 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -306,7 +306,7 @@ d_init_options (unsigned int, cl_decoded_option 
*decoded_options)
   global.params.cplusplus = CppStdRevisionCpp14;
 
   /* Warnings and deprecations are disabled by default.  */
-  global.params.useDeprecated = DIAGNOSTICoff;
+  global.params.useDeprecated = DIAGNOSTICinform;
   global.params.warnings = DIAGNOSTICoff;
 
   global.params.imppath = new Strings ();
diff --git a/gcc/testsuite/gdc.dg/asm1.d b/gcc/testsuite/gdc.dg/asm1.d
index 3fcfd6a58c1..dce36769370 100644
--- a/gcc/testsuite/gdc.dg/asm1.d
+++ b/gcc/testsuite/gdc.dg/asm1.d
@@ -13,8 +13,8 @@ void parse2()
 {
 asm 
 {
-"" : : "g" 1 ? 2 : 3;
-"" : : "g" 1 ? 2 : : 3;
+"" : : "g" (1 ? 2 : 3);
+"" : : "g" (1 ? 2 : :) 3;
 // { dg-error "expression expected, not ':'" "" { target *-*-* } .-1 }
 // { dg-error "expected constant string constraint for operand" "" { 
target *-*-* } .-2 }
 }
@@ -58,7 +58,7 @@ void semantic1()
 void semantic2a(X...)(X expr)
 {
 alias X[0] var1;
-asm { "%0" : "=m" var1; }   // { dg-error "double 'double' is a type, not 
an lvalue" }
+asm { "%0" : "=m" (var1); } // { dg-error "double 'double' is a type, not 
an lvalue" }
 }
 
 void semantic2()
@@ -86,6 +86,6 @@ void semantic4()
 {
 asm
 {
-"%0" : : "m" S4.foo;// { dg-error "template instance 
opDispatch!\"foo\" has no value" }
+"%0" : : "m" (S4.foo);  // { dg-error "template instance 
opDispatch!\"foo\" has no value" }
 }
 }
diff --git a/gcc/testsuite/gdc.dg/compilable.d 
b/gcc/testsuite/gdc.dg/compilable.d
index 92a18756a0e..3f92f9b2957 100644
--- a/gcc/testsuite/gdc.dg/compilable.d
+++ b/gcc/testsuite/gdc.dg/compilable.d
@@ -250,7 +250,7 @@ class C204 : I204
 // https://bugzilla.gdcproject.org/show_bug.cgi?id=241
 
 import imports.gdc241a;
-import imports.gdc241b : S241, C241, E241, N241;
+public import imports.gdc241b : S241, C241, E241, N241;
 
 /**/
 // https://bugzilla.gdcproject.org/show_bug.cgi?id=242
diff --git a/gcc/testsuite/gdc.dg/lto/ltotests_0.d 
b/gcc/testsuite/gdc.dg/lto/ltotests_0.d
index bb18beaa9c8..91737609f10 100644
--- a/gcc/testsuite/gdc.dg/lto/ltotests_0.d
+++ b/gcc/testsuite/gdc.dg/lto/ltotests_0.d
@@ -46,7 +46,7 @@ struct S61b
 {
 try
 other.a();
-catch
+catch (Throwable)
 other.b();
 }
 }
diff --git a/gcc/testsuite/gdc.dg/runnable.d b/gcc/testsuite/gdc.dg/runnable.d
index 7307e09a645..d974bda8c58 100644
--- a/gcc/testsuite/gdc.dg/runnable.d
+++ b/gcc/testsuite/gdc.dg/runnable.d
@@ -243,7 +243,7 @@ void test36b()(char val)
 auto test36c_1()
 {
 int a;
-void c() {};
+void c() {}
 class Result
 {
 int b;
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 5e3bf3b795a..bcde10514ec 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-5cc061a8733731d5b40334c0eb7a927b6d6241ce
+d05ebaad15fbffce6d707c138c84d7b60fcf5ffd
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/d

[committed] d: Remove another dependency on the front-end OutBuffer type.

2020-06-25 Thread Iain Buclaw via Gcc-patches
Hi,

This patch removes another dependency on the front-end OutBuffer type.

As the DMD front-end never frees allocated memory, the glue layer
between the DMD front-end and GCC should generally avoid using DMD types
and interfaces if the purpose is internal only.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

* d-lang.cc (d_parse_file): Replace OutBuffer with obstack.
---
 gcc/d/d-lang.cc | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index e4d0a24c65c..2c474f8adea 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -1032,18 +1032,20 @@ d_parse_file (void)
   message ("binary%s", global.params.argv0.ptr);
   message ("version   %s", global.version.ptr);
 
-  if (global.params.versionids)
+  if (global.versionids)
{
- OutBuffer buf;
- buf.writestring ("predefs  ");
- for (size_t i = 0; i < global.params.versionids->length; i++)
+ obstack buffer;
+ gcc_obstack_init (&buffer);
+ obstack_grow (&buffer, "predefs  ", 9);
+ for (size_t i = 0; i < global.versionids->length; i++)
{
- const char *s = (*global.params.versionids)[i];
- buf.writestring (" ");
- buf.writestring (s);
+ Identifier *id = (*global.versionids)[i];
+ const char *str = id->toChars ();
+ obstack_1grow (&buffer, ' ');
+ obstack_grow (&buffer, str, strlen (str));
}
 
- message ("%s", buf.peekChars ());
+ message ("%s", (char *) obstack_finish (&buffer));
}
 }
 
-- 
2.25.1



Re: [COMMITTED} m32r: Disable movsicc pattern

2020-06-25 Thread Jeff Law via Gcc-patches
On Thu, 2020-06-25 at 16:41 +0100, Nick Clifton via Gcc-patches wrote:
> Hi Guys,
> 
>   I am checking in the patch below to fix several failures in the GCC
>   testsuite for the M32R target.  The issue is the movsicc pattern which
>   is a holdover from when the port from converted from using cc0.  The
>   pattern was written as if a previous instruction had set the CC bits,
>   whereas in fact it is supposed to move CC bits into a general
>   register.
> 
>   The patch disables the movsicc pattern, which means that some
>   optimizations can be missed, but it does also fix the following
>   tests:
> 
> > PASS: gcc.c-torture/execute/20040709-1.c   -O2  execution test
> > PASS: gcc.c-torture/execute/20040709-1.c   -O3 -fomit-frame-pointer 
> > -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> > PASS: gcc.c-torture/execute/20040709-1.c   -O3 -g  execution test
> > PASS: gcc.c-torture/execute/20040709-1.c   -Os  execution test
> > PASS: gcc.c-torture/execute/20040709-1.c   -O2 -flto -fno-use-linker-plugin 
> > -flto-partition=none  execution test
> > PASS: gcc.c-torture/execute/20040709-1.c   -O2 -flto -fuse-linker-plugin 
> > -fno-fat-lto-objects  execution test
> > PASS: gcc.c-torture/execute/20040709-2.c   -O2  execution test
> > PASS: gcc.c-torture/execute/20040709-2.c   -O3 -fomit-frame-pointer 
> > -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
> > PASS: gcc.c-torture/execute/20040709-2.c   -O3 -g  execution test
> > PASS: gcc.c-torture/execute/20040709-2.c   -Os  execution test
> > PASS: gcc.c-torture/execute/20040709-2.c   -O2 -flto -fno-use-linker-plugin 
> > -flto-partition=none  execution test
> > PASS: gcc.c-torture/execute/20040709-2.c   -O2 -flto -fuse-linker-plugin 
> > -fno-fat-lto-objects  execution test
> > PASS: gcc.c-torture/execute/20040709-3.c   -O2  execution test
> > PASS: gcc.c-torture/execute/20040709-3.c   -O3 -g  execution test
> > PASS: gcc.c-torture/execute/20040709-3.c   -Os  execution test
> > PASS: gcc.c-torture/execute/20040709-3.c   -O2 -flto -fno-use-linker-plugin 
> > -flto-partition=none  execution test
> > PASS: gcc.c-torture/execute/20040709-3.c   -O2 -flto -fuse-linker-plugin 
> > -fno-fat-lto-objects  execution test
> > PASS: gcc.dg/strcmpopt_2.c execution test
> > PASS: gcc.dg/lto/pr67452 c_lto_pr67452_0.o-c_lto_pr67452_0.o link,  -O2 
> > -flto -fopenmp-simd 
> 
> Cheers
>   Nick
> 
> gcc/ChangeLog
> 2020-06-25  Nick Clifton  
> 
>   * config/m32r/m32r.md (movsicc): Disable pattern.
Thanks.  You might also need to disable the define_insn since a pass like CE
could possibly construct a movcc insn without using the expander.  That in turn
would then re-open the possibility of the codegen issues we're seeing in those
testcases.

Jeff
> 



PING: Re: Move simplification of statements using ranges into its own class.

2020-06-25 Thread Aldy Hernandez via Gcc-patches
PING

On Thu, Jun 18, 2020, 13:24 Aldy Hernandez  wrote:

> Howdy.
>
> This moves all the simplification code from vr_values into a separate
> class (simplify_using_ranges).  In doing so, we get rid of a bunch of
> dependencies on the internals of vr_values.  The goal is to (a) remove
> unnecessary interdependendcies (b) be able to use this engine with any
> range infrastructure, as all it needs is a method to get the range for
> an SSA name (get_value_range).
>
> I also removed as many dependencies on value_range_equiv as possible,
> preferring value_range.  A few value_range_equiv uses remain, but for
> cases where equivalences are actually used (folding conditionals, etc).
>
> The plan is to use it like this:
>
>simplify_using_ranges simplifier (vr_values_thinggie);
>simplifier.simplify (gsi);
>
> OK?
>
> Aldy
>
>


Re: [PATCH] libgomp: added simple functions and tests for OMPD

2020-06-25 Thread y2s1982 . via Gcc-patches
Hello Jakub,

Thank you for the feedback. I can't believe I made some careless mistakes.
I am also very interested in learning some new techniques mentioned. I had
some questions about them.

On Thu, Jun 25, 2020 at 4:28 AM Jakub Jelinek  wrote:

>
> > --- /dev/null
> > +++ b/libgomp/libgompd.map
> > @@ -0,0 +1,49 @@
> > +OMPD_5.0 {
> > +  global:
> > + ompd_dll_locations_valid;
>
> ompd_dll_locations and ompd_dll_locations_valid both need to be exported,
> but not from libgompd.so.1 but from libgomp.so.1, so they need to go into
> libgomp.map and be defined somewhere in libgomp.so.1, so likely env.c.
>
Ah, so code in env.c gets executed before OMPD gets started?

Include omp-tools.h and plugin-suffix.h in there and move ompd_dll_locations
> definition in there (into the #ifndef LIBGOMP_OFFLOADED_ONLY section)
> and for ompd_dll_locations_valid, e.g. make it an alias to
> initialize_env or for the time being just an empty function with
> __attribute__((noipa)) that initialize_env
> calls and I'll help with making it an alias afterwards.

I got curious about making a function alias and started looking around.
Can it be as simple as #define ompd_dll_location_valid initialize_env?
Or should I use something like ialias_call (fn) fn, defined in libgomp.h?
The latter seems like a wrapper that expands differently depending on the
condition,
and since I wasn't sure what gomp_ialias does, I wasn't sure if that was
the way to go.


>
>
> > diff --git a/libgomp/omp-tools.h b/libgomp/omp-tools.h
> > index 394c33e40dd..b6b8c5295a5 100644
> > --- a/libgomp/omp-tools.h
> > +++ b/libgomp/omp-tools.h
> > @@ -101,7 +101,7 @@ typedef struct ompd_device_type_sizes_t {
> >  } ompd_device_type_sizes_t;
> >
> >
> > -const char **ompd_dll_locations;
> > +//const char **ompd_dll_locations;
>
> Extern declaration would be
> extern const char **ompd_dll_locations;
>
Okay.  I do have an issue:
extern const char **ompd_dll_locations; and const char*
ompd_dll_locations[2]; seems to clash with each other.
At least it was when I had it defined in omp-lib.c.  It stopped giving me
errors when it was moved to env.c.
It seems giving the letter a different name and then assigning the value to
the first seems to work, but I was wondering
if there was a better solution.


>
>
> > +ompd_rc_t
> > +ompd_initialize (ompd_word_t api_version, const ompd_callbacks_t
> *callbacks)
> > +{
> > +  /* initialized flag */
>
> You don't need to comment everything the function is doing, I think the
> comments don't say anything that isn't obvious from it.
> Comment only for larger blocks of code where it might not be obvious what
> the code is doing and the comment adds added value; comments should be
> usually full sentences, starting with capital letter, ending with . and
> two spaces after the .
> Or one can add function comments (comments before function definition) that
> explain what the function does, what are the arguments etc., but in the
> case of functions documented in the standard it seems pointless,
> the best documentation is the standard.
>
> You don't use the callbacks argument yet, but you will need it later,
> so instead of adding an unused attribute to it, just add
>   (void) callbacks;
> for now to shut up warnings.
>
Okay. I will do the same for the api_version argument, too.
For the next patch, I had some questions about this function. It seems I
need to declare an address space
for callbacks. Where does this address space get stored?


>
> Otherwise LGTM.
>
> Jakub
>
> One of the things I wanted to do was create more unit tests.
Should I try making unit tests for the API version functions, focusing on
the formatting of the string?
Would that be something useful for maintaining consistency?

Thank you always for helping me learn more about the project and giving me
great suggestions.

Cheers,

Tony Sim


Re: [PATCH] libgomp: added simple functions and tests for OMPD

2020-06-25 Thread y2s1982 . via Gcc-patches
>
>
> > --- /dev/null
> > +++ b/libgomp/libgompd.map
> > @@ -0,0 +1,49 @@
> > +OMPD_5.0 {
> > +  global:
> > + ompd_dll_locations_valid;
>
> ompd_dll_locations and ompd_dll_locations_valid both need to be exported,
> but not from libgompd.so.1 but from libgomp.so.1, so they need to go into
> libgomp.map and be defined somewhere in libgomp.so.1, so likely env.c.
> Include omp-tools.h and plugin-suffix.h in there and move
> ompd_dll_locations
> definition in there (into the #ifndef LIBGOMP_OFFLOADED_ONLY section)
> and for ompd_dll_locations_valid, e.g. make it an alias to
> initialize_env or for the time being just an empty function with
> __attribute__((noipa)) that initialize_env
> calls and I'll help with making it an alias afterwards.
>

Also, for libgomp.map, which block should I place the ompd_dll_locations
and ompd_dll_locations_valid?
Should I make a new block for OMPD_5.0, or should I place them in one of
existing blocks like GOMP_5.0 or OMP_5.0.1?


Re: [PATCH 2/7] PowerPC tests: Add PLI/PADDI tests.

2020-06-25 Thread Segher Boessenkool
On Mon, Jun 01, 2020 at 03:53:37PM -0400, Michael Meissner wrote:
> Add tests for -mcpu=future that test the generation of PADDI (and PLI which
> becomes PADDI).
> 
> 2020-06-01  Michael Meissner  
> 
>   * gcc.target/powerpc/prefix-add.c: New test.
>   * gcc.target/powerpc/prefix-si-constant.c: New test.
>   * gcc.target/powerpc/prefix-di-constant.c: New test.

This is okay for trunk (with required changes: -mdejagnu-cpu=power10,
and the selector names have changed to be something with power10 instead
of something with future; please retest before commit).

Thanks!


Segher


Re: RFA: Remove use of register keyword in libiberty.h

2020-06-25 Thread Ian Lance Taylor
Nick Clifton  writes:

> Hi Nick, Hi Ian, 
>>> In file included from gold/archive.cc:29:
>>> include/libiberty.h:646:25: error: 'register' storage class
>>>   specifier is deprecated and incompatible with C++17
>>>   [-Werror,-Wdeprecated-register]
>>>
>>>   So I would like to apply the patch below to fix this.  Is this OK ?
>> 
>> Yes please! This was copied straight from bsearch.c, so you probably
>> want to change bsearch.c and bsearch_r.c as well (just in case clang
>> ever finds itself needing to build bsearch_r out of libiberty).
>
> OK, here is a revised patch.  Ian - is this OK ?
>
> Cheers
>   Nick
>
> include/ChangeLog
> 2020-06-25  Nick Clifton  
>
>   * libiberty.h (bsearch_r): Remove use of the register keyword from
>   the prototype.
>
> libiberty/ChangeLog
> 2020-06-25  Nick Clifton  
>
>   * bsearch.c (bsearch): Remove use of register keyword.
>   * bsearch_r.c (bsearch_r): Likewise.

Sure, this is fine.

Thanks.

Ian


Re: [PATCH 3/7] PowerPC tests: Add prefixed vs. DS/DQ instruction tests.

2020-06-25 Thread Segher Boessenkool
On Mon, Jun 01, 2020 at 03:53:38PM -0400, Michael Meissner wrote:
> Add test to make sure prefixed load/store instructions are generated if the
> offset would not fit in the DS/DQ encodings.
> 
> 2020-06-01  Michael Meissner  
> 
>   * gcc.target/powerpc/prefix-ds-dq.c: New test.

Okay for trunk (with changes as 2/7).  Thanks!


Segher


Re: [PATCH 4/7] PowerPC test: Add prefixed no update test

2020-06-25 Thread Segher Boessenkool
On Mon, Jun 01, 2020 at 03:53:39PM -0400, Michael Meissner wrote:
> This test makes sure we do not generate a prefixed instruction with an update
> form.
> 
> 2020-06-01  Michael Meissner  
> 
>   * gcc.target/powerpc/prefix-no-update.c: New test.

Okay like 2 and 3.  Thanks!


Segher


Re: [PATCH 5/7, V2] PowerPC tests: Prefixed insn with large offsets

2020-06-25 Thread Segher Boessenkool
Hi!

On Thu, Jun 04, 2020 at 01:03:51PM -0400, Michael Meissner wrote:
> [PATCH 5/7, V2] PowerPC tests: Prefixed insn with large offsets
> 
> Add tests to make sure for -mcpu=future that prefixed load/store instructions
> are generated if the offset is larger than 16 bits.  The only difference
> is I reworded the comments, based on a suggestion by Will Schmidt.

That is the difference to v1?  Please mark this up clearly -- there are
many examples of how you can do this, on the GCC lists even.

> +/* { dg-final { scan-assembler-times {\mpaddi\M|\mpli|\mpla\M} 3 } } */

Is there are reason you don't have \M on pli, or is that an oversight?

Okay for trunk with that looked at, and the necessary "no future"
changes (and retesting ofc).  Thanks!


Segher


Re: [PATCH 6/7, V2] PowerPC tests: Add PC-relative tests.

2020-06-25 Thread Segher Boessenkool
On Thu, Jun 04, 2020 at 01:05:12PM -0400, Michael Meissner wrote:
> [PATCH 6/7, V2] PowerPC tests: Add PC-relative tests.
> 
> These tests make sure that PC-relative variant is generated for -mcpu=future 
> on
> systems that support PC-relative addressing.  The only difference
> is I reworded the comments, based on a suggestion by Will Schmidt.
> 
> 2020-06-03  Michael Meissner  
> 
>   * gcc.target/powerpc/prefix-pcrel-dd.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-df.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-di.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-hi.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-kf.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-qi.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-sd.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-sf.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-si.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-udi.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-uhi.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-uqi.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-usi.c: New test.
>   * gcc.target/powerpc/prefix-pcrel-v2df.c: New test.
>   * gcc.target/powerpc/prefix-pcrel.h: Include file for new tests.

OKay for trunk like 5.  Thank you!


Segher


Re: [PATCH 7/7] PowerPC test: Add prefixed stack protect test

2020-06-25 Thread Segher Boessenkool
Hi!

On Mon, Jun 01, 2020 at 03:53:42PM -0400, Michael Meissner wrote:
> Test that stack protection generates prefixed stack instructions if you are
> using large stack frame for -mcpu=future.
> 
> 2020-06-01  Michael Meissner  
> 
>   * gcc.target/powerpc/prefix-stack-protect.c: New test.

> +/* { dg-do compile } */
> +/* { dg-require-effective-target powerpc_prefixed_addr } */

Is this test necessary anymore, does -mcpu=power10 not guarantee that?

Okay for trunk with that looked at.  Thanks!


Segher


Re: [PATCH] Treat { 0 } specially for structs with the designated_init attribute.

2020-06-25 Thread Joseph Myers
On Wed, 24 Jun 2020, Asher Gordon via Gcc-patches wrote:

> I see. So perhaps this isn't the best way to go about implementing
> attribute locations. What do you think would be a better way? Perhaps
> using a DECL_MINIMAL for attributes?

In general, too many things in GCC have the static type "tree".

Ideally identifiers wouldn't be "tree" - there are very few places where 
something can, at runtime, be either an identifier or another kind of 
tree, which makes them a good candidate for a different static type.  But 
there are tricky memory allocation issues around identifiers that make 
changing their representation complicated.

Attributes also have the static type "tree".  They're TREE_LISTs, and 
TREE_LIST is used for many different things and is not a particularly 
efficient type.  Unlike identifiers, there's nothing essential that would 
make it hard to change attributes to have a different static type (which 
could have room to store a location - the parsers know the location for 
each token, it's just that in many cases it ends up getting thrown away 
rather than stored in the datastructures they create) - it would just be a 
large, global change requiring testing across many different targets 
(which should definitely not be combined with any change trying to add a 
new feature - the aim would be that such a change to the internal 
representation does not change how GCC behaves at all).  But each bit of 
that large change should be fairly straightforward.  (I'd guess you might 
have a vec.h vector, each of whose elements is a new attribute type, 
rather than using a linked list with the same type for attributes and 
lists thereof.)

There was at least one previous attempt at changing attributes to have a 
different static type (see commit 4b0b31a65819f64bfeea244bfdcd1a1b8fc3c3cc 
on refs/dead/heads/static-tree-branch), but that was so long ago, and so 
much has changed in GCC since then (including regarding the representation 
of attributes, as part of supporting C++11 attributes and distinguishing 
them from attributes using GNU syntax), that it wouldn't be a useful 
starting point for such a change now.  However, the changes made for 
supporting C++11 attributes would probably make such a change *easier* 
than it was then, because more uses of attributes now go through APIs 
relating specifically to attributes rather than generic TREE_LIST APIs.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] libgomp: added simple functions and tests for OMPD

2020-06-25 Thread Jakub Jelinek via Gcc-patches
On Thu, Jun 25, 2020 at 12:17:05PM -0400, y2s1982 . wrote:
> Ah, so code in env.c gets executed before OMPD gets started?

Not all, but initialize_env is the library constructor (has constructor
attribute) and is invoked during the library initialization.
> 
> Include omp-tools.h and plugin-suffix.h in there and move ompd_dll_locations
> > definition in there (into the #ifndef LIBGOMP_OFFLOADED_ONLY section)
> > and for ompd_dll_locations_valid, e.g. make it an alias to
> > initialize_env or for the time being just an empty function with
> > __attribute__((noipa)) that initialize_env
> > calls and I'll help with making it an alias afterwards.
> 
> I got curious about making a function alias and started looking around.
> Can it be as simple as #define ompd_dll_location_valid initialize_env?

No.

> Or should I use something like ialias_call (fn) fn, defined in libgomp.h?
> The latter seems like a wrapper that expands differently depending on the
> condition,
> and since I wasn't sure what gomp_ialias does, I wasn't sure if that was
> the way to go.

You need something like following, because not all targets that support
libgomp do support aliases.  The noipa attribute tells the compiler not to
optimize it away in any way, which will be what is in there for the arches
without aliases.  And for targets that do have them (e.g. Linux), it will
just be an alias to the initialize_env function.

diff --git a/libgomp/env.c b/libgomp/env.c
index c0c4730d47c..4c3b0131629 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -1350,6 +1350,12 @@ handle_omp_display_env (unsigned long stacksize, int 
wait_policy)
   fputs ("OPENMP DISPLAY ENVIRONMENT END\n", stderr);
 }
 
+#ifndef HAVE_ATTRIBUTE_ALIAS
+void __attribute__((noipa))
+ompd_dll_locations_valid (void)
+{
+}
+#endif
 
 static void __attribute__((constructor))
 initialize_env (void)
@@ -1357,6 +1363,10 @@ initialize_env (void)
   unsigned long thread_limit_var, stacksize = GOMP_DEFAULT_STACKSIZE;
   int wait_policy;
 
+#ifndef HAVE_ATTRIBUTE_ALIAS
+  ompd_dll_locations_valid ();
+#endif
+
   /* Do a compile time check that mkomp_h.pl did good job.  */
   omp_check_defines ();
 
@@ -1486,4 +1496,8 @@ initialize_env (void)
 
   goacc_profiling_initialize ();
 }
+#ifdef HAVE_ATTRIBUTE_ALIAS
+strong_alias (initialize_env, ompd_dll_locations_valid)
+#endif
+
 #endif /* LIBGOMP_OFFLOADED_ONLY */

> > > diff --git a/libgomp/omp-tools.h b/libgomp/omp-tools.h
> > > index 394c33e40dd..b6b8c5295a5 100644
> > > --- a/libgomp/omp-tools.h
> > > +++ b/libgomp/omp-tools.h
> > > @@ -101,7 +101,7 @@ typedef struct ompd_device_type_sizes_t {
> > >  } ompd_device_type_sizes_t;
> > >
> > >
> > > -const char **ompd_dll_locations;
> > > +//const char **ompd_dll_locations;
> >
> > Extern declaration would be
> > extern const char **ompd_dll_locations;
> >
> Okay.  I do have an issue:
> extern const char **ompd_dll_locations; and const char*
> ompd_dll_locations[2]; seems to clash with each other.

The former is the type that is mandated by the standard,
so the variable needs to be defined as
const char **ompd_dll_locations.  But, you can just initialize it
to a local variable,
i.e.
static const char *gompd_dll_locations[2] = { ..., NULL };
const char **ompd_dll_locations = gompd_dll_locations;

> Okay. I will do the same for the api_version argument, too.
> For the next patch, I had some questions about this function. It seems I
> need to declare an address space
> for callbacks. Where does this address space get stored?

Look what the OMPToolsInterface ompd-test implementation does.
E.g. when talking about ompd_process_initialize,
ompd_address_space_context_t * is some magic value that the debugger
makes up for talking with the OMPD library, while
ompd_address_space_handle_t * is a structure that is allocated
by OMPD library using the alloc_memory callback and stores whatever
you need to handle that (so at least should remember the
context handle that will need to be passed to the callbacks,
and whatever other info you need (e.g. remember the sizes of the
basic types, etc.).  It will be a private structure for the implementation
(so something to be defined in libgompd.h).

> Should I try making unit tests for the API version functions, focusing on
> the formatting of the string?

No.  You don't have that much time to complete the project, there is a lot
to be still implemented, and ideally we don't want hundreds of OMPD tests,
instead we want fewer of them that will test more functions at once.

Jakub



Re: [PATCH] libgomp: added simple functions and tests for OMPD

2020-06-25 Thread Jakub Jelinek via Gcc-patches
On Thu, Jun 25, 2020 at 12:27:32PM -0400, y2s1982 . via Gcc-patches wrote:
> > > --- /dev/null
> > > +++ b/libgomp/libgompd.map
> > > @@ -0,0 +1,49 @@
> > > +OMPD_5.0 {
> > > +  global:
> > > + ompd_dll_locations_valid;
> >
> > ompd_dll_locations and ompd_dll_locations_valid both need to be exported,
> > but not from libgompd.so.1 but from libgomp.so.1, so they need to go into
> > libgomp.map and be defined somewhere in libgomp.so.1, so likely env.c.
> > Include omp-tools.h and plugin-suffix.h in there and move
> > ompd_dll_locations
> > definition in there (into the #ifndef LIBGOMP_OFFLOADED_ONLY section)
> > and for ompd_dll_locations_valid, e.g. make it an alias to
> > initialize_env or for the time being just an empty function with
> > __attribute__((noipa)) that initialize_env
> > calls and I'll help with making it an alias afterwards.
> >
> 
> Also, for libgomp.map, which block should I place the ompd_dll_locations
> and ompd_dll_locations_valid?

It is not block, but a symbol version what we are talking about, and please
use OMPD_5.0 for those symbols.  The general rule is once a compiler is
released with certain symbols in some symbol version no new symbols are
added to that symbol version, that is why we have OMP_5.0.1 even when there
is no OpenMP 5.0.1 standard, but we have shipped GCC 9/10 with some OMP_5.0
symbols already, so the ones added in 11 had to go into OMP_5.0.1.
And the symbol version name tries to reflect the kind of symbols too,
GOMP_* stands for implementation specific symbols, OMP_* for the OpenMP
standard mandated APIs, and OMPD_* matches that to cover the OMPD symbols.

Jakub



Re: [PATCH] Treat { 0 } specially for structs with the designated_init attribute.

2020-06-25 Thread Joseph Myers
I think both the patches in this discussion (special { 0 } handling and 
the new warning option) generally look good.  I don't see you in the FSF 
copyright assignment list; could you complete 
https://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/Copyright/request-assign.future
 
(unless you're already covered by an employer assignment)?

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] PR fortran/95828 - Buffer overflows with SELECT RANK

2020-06-25 Thread Harald Anlauf
Hi Thomas,

> Thanks for tackling this!  I haven't checked, but you are
> probably setting a new record for bug fixes per second now :-)

I'm trying hard, but I definitely cannot outpace Gerhard.  Any attempt
in this regard seems futile.  |-:

The good thing is that while hunting down things there's some fallout,
sometimes positive, and sometimes negative.. :-o

Harald



Re: [PATCH] Treat { 0 } specially for structs with the designated_init attribute.

2020-06-25 Thread Asher Gordon via Gcc-patches
Joseph Myers  writes:

> I think both the patches in this discussion (special { 0 } handling
> and the new warning option) generally look good.

I also wrote another small patch, which you might have missed since it's
buried in the discussion here:
https://gcc.gnu.org/pipermail/gcc-patches/2020-June/547554.html
(perhaps I should have sent it as its own message).

Here is the patch below, for convenience:
From 6b18a033ece794088ad7a86bfc557c787c7fc4ae Mon Sep 17 00:00:00 2001
From: Asher Gordon 
Date: Mon, 8 Jun 2020 20:59:38 -0400
Subject: [PATCH] Replace free with XDELETE.

gcc/c/ChangeLog:

	* c-typeck.c (free_all_tagged_tu_seen_up_to): Replace free
	with XDELETE.
	(finish_init): Likewise.
	(pop_init_level): Likewise.
---
 gcc/c/c-typeck.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 3be3690c6e2..fa506b6515c 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -1407,7 +1407,7 @@ free_all_tagged_tu_seen_up_to (const struct tagged_tu_seen_cache *tu_til)
   const struct tagged_tu_seen_cache *const tu1
 	= (const struct tagged_tu_seen_cache *) tu;
   tu = tu1->next;
-  free (CONST_CAST (struct tagged_tu_seen_cache *, tu1));
+  XDELETE (CONST_CAST (struct tagged_tu_seen_cache *, tu1));
 }
   tagged_tu_seen_base = tu_til;
 }
@@ -8279,13 +8279,13 @@ finish_init (void)
 {
   struct constructor_stack *q = constructor_stack;
   constructor_stack = q->next;
-  free (q);
+  XDELETE (q);
 }
 
   gcc_assert (!constructor_range_stack);
 
   /* Pop back to the data of the outer initializer (if any).  */
-  free (spelling_base);
+  XDELETE (spelling_base);
 
   constructor_decl = p->decl;
   require_constant_value = p->require_constant_value;
@@ -8298,7 +8298,7 @@ finish_init (void)
   spelling_size = p->spelling_size;
   constructor_top_level = p->top_level;
   initializer_stack = p->next;
-  free (p);
+  XDELETE (p);
 }

 /* Call here when we see the initializer is surrounded by braces.
@@ -8829,7 +8829,7 @@ pop_init_level (location_t loc, int implicit,
   RESTORE_SPELLING_DEPTH (constructor_depth);
 
   constructor_stack = p->next;
-  free (p);
+  XDELETE (p);
 
   if (ret.value == NULL_TREE && constructor_stack == 0)
 ret.value = error_mark_node;
-- 
2.27.0

> I don't see you in the FSF copyright assignment list; could you
> complete
> https://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/Copyright/request-assign.future
> (unless you're already covered by an employer assignment)?

Done.

Thanks,
Asher

-- 
By necessity, by proclivity, and by delight, we all quote.  In fact, it is as
difficult to appropriate the thoughts of others as it is to invent.
-- R. Emerson
-- Quoted from a fortune cookie program
(whose author claims, "Actually, stealing IS easier.")
[to which I reply, "You think it's easy for me to
misconstrue all these misquotations?!?"  Ed.]
   
I prefer to send and receive mail encrypted. Please send me your
public key, and if you do not have my public key, please let me
know. Thanks.

GPG fingerprint: 38F3 975C D173 4037 B397  8095 D4C9 C4FC 5460 8E68


signature.asc
Description: PGP signature


[PATCH] m68k: tag floating-point ABI used

2020-06-25 Thread Pat Bernardi
Tag the floating-point calling convention used on m68k-elf (either hard-float
or soft-float) through the GNU assembler attribute. The use of the tag enables
the linker to ensure linked objects use a consistent floating-point ABI and
allows tools like GDB to infer the ABI used from the ELF file. It is based on
similar work done for PowerPC.

The patch has been tested for m68k-elf and x86-64/Linux. Since tagging is only
enabled when the m68k assembler supports GNU attributes, this patch can be
applied independently from the corresponding binutils patch.

If approved, I'll need a maintainer to commit on my behalf.

Thanks,

Pat Bernardi
AdaCore

---
2020-06-25  Pat Bernardi  

gcc/ChangeLog
* configure.ac: Check m68k assembler supports .gnu_attribute.
* configure: Regenerate.
* config/m68k/linux.h (TARGET_ELF, M68K_LINUX): Define.
* config/m68k/m68kelf.h (TARGET_ELF): Define.
* config/m68k/m68k.c (m68k_elf_file_end): New function.
(TARGET_ASM_FILE_END): Define.
(m68k_passes_float): New static variable.
(m68k_libcall_value, m68k_function_value): set m68k_passes_float if
value is floating point.
(m68k_elf_file_end): New function.

gcc/testsuite/ChangeLog
* gcc.target/m68k/gnuattr1.c: New file.
* gcc.target/m68k/gnuattr2.c: Likewise.

diff --git a/gcc/config/m68k/linux.h b/gcc/config/m68k/linux.h
index 0d18e5ae5ac..2e064ef486d 100644
--- a/gcc/config/m68k/linux.h
+++ b/gcc/config/m68k/linux.h
@@ -18,6 +18,11 @@ You should have received a copy of the GNU General Public 
License
along with GCC; see the file COPYING3.  If not see
.  */

+/* Target is ELF and M68K_LINUX */
+
+#define TARGET_ELF
+#define M68K_LINUX
+
/* Add %(asm_cpu_spec) to a generic definition of ASM_SPEC.  */
#undef ASM_SPEC
#define ASM_SPEC "%(asm_cpu_spec) %(asm_pcrel_spec)"
@@ -226,8 +231,6 @@ along with GCC; see the file COPYING3.  If not see
 : "%d0", "%d2", "%d3");\
}

-#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-
#undef DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(REGNO) (REGNO)

diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index 67b109447b3..f6809386bf2 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -196,7 +196,8 @@ static bool m68k_modes_tieable_p (machine_mode, 
machine_mode);
static machine_mode m68k_promote_function_mode (const_tree, machine_mode,
int *, const_tree, int);
static void m68k_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx [], int);
-
+static void m68k_elf_file_end (void) ATTRIBUTE_UNUSED;
+
/* Initialize the GCC target structure.  */

#if INT_OP_GROUP == INT_OP_DOT_WORD
@@ -360,6 +361,11 @@ static void m68k_asm_final_postscan_insn (FILE *, rtx_insn 
*insn, rtx [], int);
#undef TARGET_ASM_FINAL_POSTSCAN_INSN
#define TARGET_ASM_FINAL_POSTSCAN_INSN m68k_asm_final_postscan_insn

+#ifdef TARGET_ELF
+#undef TARGET_ASM_FILE_END
+#define TARGET_ASM_FILE_END m68k_elf_file_end
+#endif
+
static const struct attribute_spec m68k_attribute_table[] =
{
  /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
@@ -482,6 +488,11 @@ unsigned int m68k_cpu_flags;
/* The set of FL_* flags that apply to the processor to be tuned for.  */
unsigned int m68k_tune_flags;

+#ifdef HAVE_AS_GNU_ATTRIBUTE
+/* Flag whether floating point values have been passed/returned. */
+static bool m68k_passes_float;
+#endif
+
/* Asm templates for calling or jumping to an arbitrary symbolic address,
   or NULL if such calls or jumps are not supported.  The address is held
   in operand 0.  */
@@ -5823,6 +5834,9 @@ m68k_libcall_value (machine_mode mode)
  case E_SFmode:
  case E_DFmode:
  case E_XFmode:
+#ifdef HAVE_AS_GNU_ATTRIBUTE
+m68k_passes_float = true;
+#endif
if (TARGET_68881)
  return gen_rtx_REG (mode, FP0_REG);
break;
@@ -5846,6 +5860,9 @@ m68k_function_value (const_tree valtype, const_tree func 
ATTRIBUTE_UNUSED)
  case E_SFmode:
  case E_DFmode:
  case E_XFmode:
+#ifdef HAVE_AS_GNU_ATTRIBUTE
+m68k_passes_float = true;
+#endif
if (TARGET_68881)
  return gen_rtx_REG (mode, FP0_REG);
break;
@@ -7150,4 +7167,21 @@ m68k_promote_function_mode (const_tree type, 
machine_mode mode,
  return mode;
}

+/* Write out end of ELF file attributes */
+
+static void
+m68k_elf_file_end (void)
+{
+#ifdef HAVE_AS_GNU_ATTRIBUTE
+  /* TARGET_68881 indicates use of hard-float ABI */
+  if (m68k_passes_float)
+  fprintf (asm_out_file, "\t.gnu_attribute 4, %d\n",
+   TARGET_68881 ? 1 : 2);
+#endif
+
+#if defined (M68K_LINUX)
+  file_end_indicate_exec_stack ();
+#endif
+}
+
#include "gt-m68k.h"
diff --git a/gcc/config/m68k/m68kelf.h b/gcc/config/m68k/m68kelf.h
index f10dd326732..849481e9307 100644
--- a/gcc/config/m68k/m68kelf.h
+++ b/gcc/config/m68k/m68kelf.h
@@ -21,6 +21,9 @@ You should have received a copy of the GNU General Public 
License
alo

[PATCH] [9/10/11 Regression] PR fortran/93337 - ICE in gfc_dt_upper_string, at fortran/module.c:441

2020-06-25 Thread Harald Anlauf
This PR is due to a plain NULL pointer that needs to get caught in the right 
place.

Regtested on x86_64-pc-linux-gnu.

OK for master / backports where applicable?

Thanks,
Harald


PR fortran/93337 - ICE in gfc_dt_upper_string, at fortran/module.c:441

When declaring a polymorphic variable that is not a dummy, allocatable or
pointer, an ICE occurred due to a NULL pointer dereference.  Check for
that situation and punt.

gcc/fortran/
PR fortran/93337
* class.c (gfc_find_derived_vtab): Punt if name is not set.

diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 2b760efe8d7..48f81d89a74 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -2277,6 +2277,9 @@ gfc_find_derived_vtab (gfc_symbol *derived)
   if (!derived)
 return NULL;

+  if (!derived->name)
+return NULL;
+
   /* Find the gsymbol for the module of use associated derived types.  */
   if ((derived->attr.use_assoc || derived->attr.used_in_submodule)
&& !derived->attr.vtype && !derived->attr.is_class)
diff --git a/gcc/testsuite/gfortran.dg/pr93337.f90 b/gcc/testsuite/gfortran.dg/pr93337.f90
new file mode 100644
index 000..5cfb9297990
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93337.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! PR fortran/93337 - ICE in gfc_dt_upper_string, at fortran/module.c:441
+
+program p
+  type t
+ character(:), allocatable :: a
+  end type t
+  class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+  x = x ! { dg-error "must not be polymorphic in intrinsic assignment" }
+end


[PATCH] [8/9/10/11 Regression] ICE on invalid with argument list for module procedure

2020-06-25 Thread Harald Anlauf
A simple situation where a NULL pointer dereference occurs during error 
recovery.

Regtested on x86_64-pc-linux-gnu.

OK for master / backports?

Thanks,
Harald


PR fortran/93423 - ICE on invalid with argument list for module procedure

When recovering from an error, a NULL pointer dereference could occur.
Check for that situation and punt.

gcc/fortran/
PR fortran/93423
* resolve.c (resolve_symbol): Avoid NULL pointer dereference.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 6fa34caec54..c9447a24885 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -15901,7 +15901,7 @@ resolve_symbol (gfc_symbol *sym)
   if (formal)
 	{
 	  sym->formal_ns = formal->sym->ns;
-  if (sym->ns != formal->sym->ns)
+	  if (sym->ns != formal->sym->ns && sym->formal_ns)
 	sym->formal_ns->refs++;
 	}
 }
diff --git a/gcc/testsuite/gfortran.dg/pr93423.f90 b/gcc/testsuite/gfortran.dg/pr93423.f90
new file mode 100644
index 000..fed5914daba
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93423.f90
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! PR fortran/93423 - ICE on invalid with argument list for module procedure
+
+module t
+  type :: b
+   contains
+ procedure :: p => bp
+  end type b
+  interface
+ module function bp(s)
+   class(b), intent(inout) :: s
+   integer, pointer :: bp
+ end function
+  end interface
+end module t
+
+submodule (t) ts
+contains
+  module procedure bp(s) ! { dg-error "must be in a generic module interface" }
+  end procedure bp   ! { dg-error "Expecting END SUBMODULE statement" }
+end submodule ts


Re: [PATCH 4/6 ver 3] rs6000, Add vector shift double builtin support

2020-06-25 Thread Segher Boessenkool
Hi!

On Thu, Jun 18, 2020 at 03:20:14PM -0700, Carl Love wrote:
> +;; Map UNSPEC_SLDB to "l" and  UNSPEC_SRDB to "r".
> +(define_int_attr SLDB_LR [(UNSPEC_SLDB "l")
> +   (UNSPEC_SRDB "r")])

Most (all?) other attributes that always result in lower case strings
are written in lower case themselves; at least the part that just is the
possible expansions.  So, "sldb_lr" or "SLDB_lr" please.

> +  else if (icode == CODE_FOR_vsldb_v16qi
> +|| icode == CODE_FOR_vsldb_v8hi
> +|| icode == CODE_FOR_vsldb_v4si
> +|| icode == CODE_FOR_vsldb_v2di
> +|| icode == CODE_FOR_vsrdb_v16qi
> +|| icode == CODE_FOR_vsrdb_v8hi
> +|| icode == CODE_FOR_vsrdb_v4si
> +|| icode == CODE_FOR_vsrdb_v2di)
> +   {
> + /* Check whether the 3rd argument is an integer constant in the range
> + 0 to 7 inclusive.  */
> + STRIP_NOPS (arg2);
> + if (TREE_CODE (arg2) != INTEGER_CST
> +  || !IN_RANGE (TREE_INT_CST_LOW (arg2), 0, 7))
> + {
> +   error ("argument 3 must be in the range 0 to 7");
> +   return CONST0_RTX (tmode);
> + }
> +   }

"must be a constant in the range"... maybe?

Okay for trunk with that considered (and the obvious testsuite changes
from the future->power10 changes).  Thanks!


Segher


Re: [PATCH v2] c++: Fix CTAD for aggregates in template [PR95568]

2020-06-25 Thread Marek Polacek via Gcc-patches
On Wed, Jun 24, 2020 at 03:52:12PM -0400, Jason Merrill via Gcc-patches wrote:
> On 6/23/20 6:58 PM, Marek Polacek wrote:
> > 95568 complains that CTAD for aggregates doesn't work within
> > requires-clause and it turned out that it doesn't work when we try
> > the deduction in a template.  The reason is that maybe_aggr_guide
> > creates a guide that can look like this
> > 
> >template X(decltype (X::x))-> X
> 
> Then that's the bug; there's no reason the guide should be different just
> because we're trying to do the deduction in a template.
> 
> I'm not sure why I used finish_decltype_type there.

Aha.  Here's a v2 using just TREE_TYPE; in the patch I explain why I didn't
go with unlowered_expr_type.  Which is fully expected since
is_bitfield_expr_with_lowered_type doesn't do anything with FIELD_DECLs.

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

-- >8 --
95568 complains that CTAD for aggregates doesn't work within
requires-clause and it turned out that it doesn't work when we try
the deduction in a template.  The reason is that maybe_aggr_guide
creates a guide that can look like this

  template X(decltype (X::x))-> X

where the parameter is a decltype, which is a non-deduced context.  So
the subsequent build_new_function_call fails because unify_one_argument
can't deduce anything from it ([temp.deduct.type]: "If a template
parameter is used only in non-deduced contexts and is not explicitly
specified, template argument deduction fails.")

Those decltypes come from finish_decltype_type.  We can just use
TREE_TYPE instead.  I pondered using unlowered_expr_type, but that
didn't make any difference for the FIELD_DECLs I saw in
class-deduction-aggr6.C.

gcc/cp/ChangeLog:

PR c++/95568
* pt.c (collect_ctor_idx_types): Use TREE_TYPE.

gcc/testsuite/ChangeLog:

PR c++/95568
* g++.dg/cpp2a/class-deduction-aggr5.C: New test.
* g++.dg/cpp2a/class-deduction-aggr6.C: New test.
---
 gcc/cp/pt.c   |  2 +-
 .../g++.dg/cpp2a/class-deduction-aggr5.C  | 20 
 .../g++.dg/cpp2a/class-deduction-aggr6.C  | 32 +++
 3 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr5.C
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr6.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 53a64c3a15e..618bf68b2d6 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -28329,7 +28329,7 @@ collect_ctor_idx_types (tree ctor, tree list, tree elt 
= NULL_TREE)
   tree idx, val; unsigned i;
   FOR_EACH_CONSTRUCTOR_ELT (v, i, idx, val)
 {
-  tree ftype = elt ? elt : finish_decltype_type (idx, true, tf_none);
+  tree ftype = elt ? elt : TREE_TYPE (idx);
   if (BRACE_ENCLOSED_INITIALIZER_P (val)
  && CONSTRUCTOR_NELTS (val)
  /* As in reshape_init_r, a non-aggregate or array-of-dependent-bound
diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr5.C 
b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr5.C
new file mode 100644
index 000..01253f42006
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr5.C
@@ -0,0 +1,20 @@
+// PR c++/95568
+// { dg-do compile { target c++20 } }
+
+template struct X { T x; };
+template struct X2 { T x; U y; };
+template concept Y = requires { X{0}; };
+
+template
+void g()
+{
+  X{0};
+  X2{1, 2.2};
+  Y auto y = X{1};
+}
+
+void
+fn ()
+{
+  g();
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr6.C 
b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr6.C
new file mode 100644
index 000..5332eb93bbe
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr6.C
@@ -0,0 +1,32 @@
+// PR c++/95568
+// { dg-do compile { target c++20 } }
+// CTAD with aggregates containing bit-fields.
+
+template struct same_type;
+template struct same_type {};
+
+enum E { e };
+
+template
+struct X {
+  T a : 5;
+};
+
+template
+void g()
+{
+  auto x = X{ 0 };
+  same_type();
+  auto x2 = X{ E::e };
+  same_type();
+  auto x3 = X{ false };
+  same_type();
+  auto x4 = X{ 0u };
+  same_type();
+}
+
+void
+fn ()
+{
+  g();
+}

base-commit: 77d455ee81ec3a23f8b20259a31ab963716f8e82
-- 
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA



[PATCH] libgomp: added simple functions and tests for OMPD

2020-06-25 Thread y2s1982 via Gcc-patches
From: y2s82 <1997371+y2...@users.noreply.github.com>

This patch adds some unit tests for omp-tools.h header. It also adds some simple
functions variables related to OMPD API versions and dll locations.
It also partially defines the OMPD initialization function.
More OMPD configuration is also added into Makefile.am.

This patch addresses all feedbacks.

2020-06-25  Tony Sim  

libgomp/ChangeLog:

* Makefile.am(toolexeclib_LTLIBRARIES): Add libgompd.la.
(libgompd_la_LDFLAGS, libgompd_la_DEPENDENCIES, libgompd_la_LINK,
libgompd_la_SOURCES, libgompd_version_dep, libgompd_version_script,
libgompd.ver-sun, libgompd.ver, libgompd_version_info): Set.
* Makefile.in: Regenerate.
* config/darwin/plugin-suffix.h (SONAME_SUFFIX): Remove ().
* config/hpux/plugin-suffix.h (SONAME_SUFFIX): Remove ().
* config/posix/plugin-suffix.h (SONAME_SUFFIX): Remove ().
* env.c(ompd_dll_locations_valid): Define with no compiler optimization.
(initialize_env): Call ompd_dll_locations_valid as needed.
(strong_alias): Alias ompd_dll_locations_valid to initialize_env
when possible.
* libgomp.map: Add OMPD_5.0 symbols version.
* omp-tools.h: Declare ompd_dll_locations as an extern.
* testsuite/Makefile.in: Regenerate.
* libgompd.h: New file.
* libgompd.map: New file.
* ompd-lib.c: New file.
* testsuite/libgomp.ompd/header-1.c: New test.
* testsuite/libgomp.ompd/header-order-1.c: New test.
* testsuite/libgomp.ompd/header-order-2.c: New test.
* testsuite/libgomp.ompd/ompd.exp: New test.

---
 libgomp/Makefile.am   | 29 -
 libgomp/Makefile.in   | 39 +++-
 libgomp/config/darwin/plugin-suffix.h |  2 +-
 libgomp/config/hpux/plugin-suffix.h   |  2 +-
 libgomp/config/posix/plugin-suffix.h  |  2 +-
 libgomp/env.c | 21 +++
 libgomp/libgomp.map   |  6 ++
 libgomp/libgompd.h| 37 +++
 libgomp/libgompd.map  | 49 +++
 libgomp/omp-tools.h   |  2 +-
 libgomp/ompd-lib.c| 61 +++
 libgomp/testsuite/Makefile.in |  1 +
 libgomp/testsuite/libgomp.ompd/header-1.c | 10 +++
 .../testsuite/libgomp.ompd/header-order-1.c   | 11 
 .../testsuite/libgomp.ompd/header-order-2.c   | 11 
 libgomp/testsuite/libgomp.ompd/ompd.exp   | 38 
 16 files changed, 312 insertions(+), 9 deletions(-)
 create mode 100644 libgomp/libgompd.h
 create mode 100644 libgomp/libgompd.map
 create mode 100644 libgomp/ompd-lib.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/header-1.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/header-order-1.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/header-order-2.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/ompd.exp

diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
index 4d31f4cef46..e15a838e55c 100644
--- a/libgomp/Makefile.am
+++ b/libgomp/Makefile.am
@@ -20,7 +20,7 @@ AM_CPPFLAGS = $(addprefix -I, $(search_path))
 AM_CFLAGS = $(XCFLAGS)
 AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
 
-toolexeclib_LTLIBRARIES = libgomp.la
+toolexeclib_LTLIBRARIES = libgomp.la libgompd.la
 nodist_toolexeclib_HEADERS = libgomp.spec
 
 if LIBGOMP_BUILD_VERSIONED_SHLIB
@@ -31,14 +31,21 @@ PREPROCESS = $(subst -Wc$(comma), , $(COMPILE)) -E
 libgomp.ver: $(top_srcdir)/libgomp.map
$(EGREP) -v '#(#| |$$)' $< | \
  $(PREPROCESS) -P -include config.h - > $@ || (rm -f $@ ; exit 1)
+libgompd.ver: $(top_srcdir)/libgompd.map
+   $(EGREP) -v '#(#| |$$)' $< | \
+ $(PREPROCESS) -P -include config.h - > $@ || (rm -f $@ ; exit 1)
 
 if LIBGOMP_BUILD_VERSIONED_SHLIB_GNU
 libgomp_version_script = -Wl,--version-script,libgomp.ver
+libgompd_version_script = -Wl,--version-script,libgompd.ver
 libgomp_version_dep = libgomp.ver
+libgompd_version_dep = libgompd.ver
 endif
 if LIBGOMP_BUILD_VERSIONED_SHLIB_SUN
 libgomp_version_script = -Wl,-M,libgomp.ver-sun
+libgompd_version_script = -Wl,-M,libgompd.ver-sun
 libgomp_version_dep = libgomp.ver-sun
+libgompd_version_dep = libgompd.ver-sun
 libgomp.ver-sun : libgomp.ver \
$(top_srcdir)/../contrib/make_sunver.pl \
$(libgomp_la_OBJECTS) $(libgomp_la_LIBADD)
@@ -48,16 +55,32 @@ libgomp.ver-sun : libgomp.ver \
 `echo $(libgomp_la_LIBADD) | \
sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
 > $@ || (rm -f $@ ; exit 1)
+libgompd.ver-sun : libgompd.ver \
+   $(top_srcdir)/../contrib/make_sunver.pl \
+   $(libgompd_la_OBJECTS) $(libgompd_la_LIBADD)
+   perl $(top_srcdir)/../contrib/make_sunver.pl \
+ libgompd.ver \
+ $(libgompd_la_OBJECTS:%.lo=.libs/%.o) \
+`echo $(libgompd_la_LIBADD) 

Re: [PATCH 5/6 ver 3] rs6000, Add vector splat builtin support

2020-06-25 Thread Segher Boessenkool
Hi!

On Thu, Jun 18, 2020 at 03:20:18PM -0700, Carl Love wrote:
>   * config/rs6000/altivec.md (UNSPEC_XXSPLTIW, UNSPEC_XXSPLTID,
>   UNSPEC_XXSPLTI32DX): New.
>   (vxxspltiw_v4si, vxxspltiw_v4sf_inst, vxxspltidp_v2df_inst,
>   vxxsplti32dx_v4si_inst, vxxsplti32dx_v4sf_inst): New define_insn.
>   (vxxspltiw_v4sf, vxxspltidp_v2df, vxxsplti32dx_v4si,
>   vxxsplti32dx_v4sf.): New define_expands.

A whole bunch of these could be done with iterators (but that is then a
future improvement, no need to do it now).

> +(define_expand "xxsplti32dx_v4si"
> +  [(set (match_operand:V4SI 0 "register_operand" "=wa")
> + (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "wa")
> +   (match_operand:QI 2 "u1bit_cint_operand" "n")
> +   (match_operand:SI 3 "s32bit_cint_operand" "n")]
> +  UNSPEC_XXSPLTI32DX))]
> + "TARGET_FUTURE"
> +{
> +  int index = INTVAL (operands[2]);
> +
> +  if (!BYTES_BIG_ENDIAN)
> +index = 1 - index;
> +
> +   /* Instruction uses destination as a source.  Do not overwrite source.  */
> +   emit_move_insn (operands[0], operands[1]);
> +
> +   emit_insn (gen_xxsplti32dx_v4si_inst (operands[0], GEN_INT (index),
> +   operands[3]));
> +   DONE;
> +}
> + [(set_attr "type" "vecsimple")])
> +
> +(define_insn "xxsplti32dx_v4si_inst"
> +  [(set (match_operand:V4SI 0 "register_operand" "+wa")
> + (unspec:V4SI [(match_operand:QI 1 "u1bit_cint_operand" "n")
> +   (match_operand:SI 2 "s32bit_cint_operand" "n")]
> +  UNSPEC_XXSPLTI32DX))]
> +  "TARGET_FUTURE"
> +  "xxsplti32dx %x0,%1,%2"
> +  [(set_attr "type" "vecsimple")])

Hrm.  Can we not just use two operands for that, the second with a "0"
constraint?  Then register allocation will sort it all out (compare to
other instructions with this problem, rl[wd]imi is classical).

> +;; Return 1 if op is a 32-bit constant signed integer
> +(define_predicate "s32bit_cint_operand"
> +  (and (match_code "const_int")
> +   (match_test "(unsigned HOST_WIDE_INT)
> +(0x8000 + UINTVAL (op)) >> 32 == 0")))

You don't need the cast here: UINTVAL returns that type already, and
that cascades to everything else in the expression.

> +;; Return 1 if op is a constant 32-bit floating point value
> +(define_predicate "f32bit_const_operand"
> +  (match_code "const_double")
> +{
> +  if (GET_MODE (op) == SFmode)
> +return 1;
> +
> +  else if ((GET_MODE (op) == DFmode) && ((UINTVAL (op) >> 32) == 0))
> +   {
> +/* Value fits in 32-bits */
> +return 1;
> +}
> +  else
> +/* Not the expected mode.  */
> +return 0;
> +})

I don't think this is the correct test.  What you want to see is if the
number in "op" can be converted to an IEEE single-precision number, and
back again, losslessly.  (And subnormal SP numbers aren't allowed
either, but NaNs and infinities are).


Rest looks fine.  Sorry it took me so long to spot this.


Segher


[committed] c++: Add test for c++/91104

2020-06-25 Thread Marek Polacek via Gcc-patches
Fixed by r271705.

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

gcc/testsuite/ChangeLog:

PR c++/91104
* g++.dg/cpp1y/lambda-generic-variadic21.C: New test.
---
 .../g++.dg/cpp1y/lambda-generic-variadic21.C  | 26 +++
 1 file changed, 26 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic21.C

diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic21.C 
b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic21.C
new file mode 100644
index 000..affb1ffd474
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic21.C
@@ -0,0 +1,26 @@
+// PR c++/91104
+// { dg-do run { target c++14 } }
+
+void
+test (void (*f)(int, int, int))
+{
+  f(1, 2, 3);
+}
+
+void
+check (int a, int b, int c)
+{
+  if (a != 1 || b != 2 || c != 3)
+__builtin_abort ();
+}
+
+int
+main ()
+{
+  test ([](auto... args) {
+check (args...);
+  });
+  test ([](int a, int b, int c) {
+check (a, b, c);
+  });
+}

base-commit: 77d455ee81ec3a23f8b20259a31ab963716f8e82
-- 
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA



[PATCH] rs6000: Add support for __builtin_cpu_is ("power10")

2020-06-25 Thread Peter Bergner via Gcc-patches
rs6000: Add support for __builtin_cpu_is ("power10")

Add support for __builtin_cpu_is ("power10").  Also add documentation for
the recently added "arch_3_1" and "mma" __builtin_cpu_supports arguments.

This passed bootstrap and regtesting with no regressions.  Ok for trunk?

Peter


gcc/
* config/rs6000/rs6000-call.c (cpu_is_info) : New.
: Remove unneeded ','.
* gcc/doc/extend.texi (PowerPC Built-in Functions): Document power10,
arch_3_1 and mma.

gcc/testsuite/
* gcc.target/powerpc/cpu-builtin-1.c: Add tests for power10, arch_3_1
and mma.

diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c
index 3a109fe626f..4bc1e588a2f 100644
--- a/gcc/config/rs6000/rs6000-call.c
+++ b/gcc/config/rs6000/rs6000-call.c
@@ -105,6 +105,7 @@ static const struct
   const char *cpu;
   unsigned int cpuid;
 } cpu_is_info[] = {
+  { "power10",PPC_PLATFORM_POWER10 },
   { "power9", PPC_PLATFORM_POWER9 },
   { "power8", PPC_PLATFORM_POWER8 },
   { "power7", PPC_PLATFORM_POWER7 },
@@ -174,7 +175,7 @@ static const struct
   { "darn",PPC_FEATURE2_DARN,  1 },
   { "scv", PPC_FEATURE2_SCV,   1 },
   { "arch_3_1",PPC_FEATURE2_ARCH_3_1,  1 },
-  { "mma", PPC_FEATURE2_MMA,   1 },
+  { "mma", PPC_FEATURE2_MMA,   1 }
 };
 
 static void altivec_init_builtins (void);
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 95f7192e41e..343fbba8223 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -17123,6 +17123,8 @@ issues a warning.
 The following CPU names can be detected:
 
 @table @samp
+@item power10
+IBM POWER10 Server CPU.
 @item power9
 IBM POWER9 Server CPU.
 @item power8
@@ -17199,6 +17201,8 @@ CPU supports ISA 2.06 (eg, POWER7)
 CPU supports ISA 2.07 (eg, POWER8)
 @item arch_3_00
 CPU supports ISA 3.0 (eg, POWER9)
+@item arch_3_1
+CPU supports ISA 3.1 (eg, POWER10)
 @item archpmu
 CPU supports the set of compatible performance monitoring events.
 @item booke
@@ -17232,6 +17236,8 @@ CPU supports icache snooping capabilities.
 CPU supports 128-bit IEEE binary floating point instructions.
 @item isel
 CPU supports the integer select instruction.
+@item mma
+CPU supports the matrix-multiply assist instructions.
 @item mmu
 CPU has a memory management unit.
 @item notb
diff --git a/gcc/testsuite/gcc.target/powerpc/cpu-builtin-1.c 
b/gcc/testsuite/gcc.target/powerpc/cpu-builtin-1.c
index 960e7fb4f5f..2bcf6f679da 100644
--- a/gcc/testsuite/gcc.target/powerpc/cpu-builtin-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/cpu-builtin-1.c
@@ -24,6 +24,7 @@ use_cpu_is_builtins (unsigned int *p)
   p[12] = __builtin_cpu_is ("ppc440");
   p[13] = __builtin_cpu_is ("ppc405");
   p[14] = __builtin_cpu_is ("ppc-cell-be");
+  p[15] = __builtin_cpu_is ("power10");
 #else
   p[0] = 0;
 #endif
@@ -74,6 +75,8 @@ use_cpu_supports_builtins (unsigned int *p)
   p[38] = __builtin_cpu_supports ("darn");
   p[39] = __builtin_cpu_supports ("scv");
   p[40] = __builtin_cpu_supports ("htm-no-suspend");
+  p[41] = __builtin_cpu_supports ("arch_3_1");
+  p[42] = __builtin_cpu_supports ("mma");
 #else
   p[0] = 0;
 #endif


Re: [PATCH] rs6000: Add support for __builtin_cpu_is ("power10")

2020-06-25 Thread Segher Boessenkool
Hi!

On Thu, Jun 25, 2020 at 06:36:51PM -0500, Peter Bergner wrote:
> rs6000: Add support for __builtin_cpu_is ("power10")
> 
> Add support for __builtin_cpu_is ("power10").  Also add documentation for
> the recently added "arch_3_1" and "mma" __builtin_cpu_supports arguments.

> gcc/
>   * config/rs6000/rs6000-call.c (cpu_is_info) : New.
>   : Remove unneeded ','.

The comma helps making the diff less for future additions (and, makes
merging/refactoring easier, that way).  A trailing comma was not allowed
with older C standards (or just with some implementations?), but it
should be fine with C++11 as we require now.  Is there something I am
missing here?

>   * gcc/doc/extend.texi (PowerPC Built-in Functions): Document power10,
>   arch_3_1 and mma.
> 
> gcc/testsuite/
>   * gcc.target/powerpc/cpu-builtin-1.c: Add tests for power10, arch_3_1
>   and mma.

> @@ -17199,6 +17201,8 @@ CPU supports ISA 2.06 (eg, POWER7)
>  CPU supports ISA 2.07 (eg, POWER8)
>  @item arch_3_00
>  CPU supports ISA 3.0 (eg, POWER9)
> +@item arch_3_1
> +CPU supports ISA 3.1 (eg, POWER10)

Nothing new apparently, but it is spelled "e.g." :-/  Oh well.

Okay for trunk (maybe leave out the comma part).  Thanks!


Segher


Re: [PATCH] rs6000: Add support for __builtin_cpu_is ("power10")

2020-06-25 Thread Peter Bergner via Gcc-patches
On 6/25/20 6:54 PM, Segher Boessenkool wrote:
> Okay for trunk (maybe leave out the comma part).  Thanks!

Ok, I pushed the patch without the ',' change.  Thanks!

Peter