Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable.

2016-02-23 Thread Jakub Jelinek
On Tue, Feb 23, 2016 at 08:55:40AM +0100, Mark Wielaard wrote:
> On Mon, 2016-02-22 at 19:20 -0800, H.J. Lu wrote:
> > It caused:
> > 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69911
> 
> Apologies. Apparently main_input_filename can be NULL. I am not entirely
> sure when that happens. Or how I failed to see that test failure. I
> think I didn't have java enabled, causing libffi to be skipped.
> 
> I am testing this patch that skips the test in that case:

Are you sure that is the problem?
I think it doesn't hurt to check for non-NULL main_input_filename, perhaps
some non-c-family languages might not set it, and this is in generic code,
but at least on the gcc.target/i386/iamcu/test_passing_structs.c testcase and 
on one
randomly selected libffi testcase I see the ICE from completely different
reason - what is NULL is DECL_SOURCE_FILE (decl).

decl is e.g.
 
unit size 
align 8 symtab 0 alias set 6 canonical type 0x718865e8
fields 
QI file 
/usr/src/gcc/gcc/testsuite/gcc.target/i386/iamcu/test_passing_structs.c line 
133 col 8
size 
unit size 
align 8 offset_align 32
offset 
bit offset  context 
 chain > 
context 
chain >
readonly addressable static ignored in-constant-pool BLK file (null) line 0 
col 0 size  unit size 
align 32 initial >

We are not really going to warn about this anyway, e.g. because
it is DECL_ARTIFICIAL, but that is checked only in a much later
condition.  So, I think you should check also for NULL DECL_SOURCE_FILE
(and treat it as possibly in a header).  Unfortunately
DECL_SOURCE_FILE involves a function call, so you might want to cache
it in some automatic variable.
&& (warn_unused_const_variable == 2
|| (main_input_filename != NULL
&& (decl_file = DECL_SOURCE_FILE (decl)) != NULL
&& filename_cmp (main_input_filename,
 decl_file) == 0

Jakub


Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable.

2016-02-23 Thread Mark Wielaard
On Tue, 2016-02-23 at 09:26 +0100, Jakub Jelinek wrote:
> On Tue, Feb 23, 2016 at 08:55:40AM +0100, Mark Wielaard wrote:
> > On Mon, 2016-02-22 at 19:20 -0800, H.J. Lu wrote:
> > > It caused:
> > > 
> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69911
> > 
> > Apologies. Apparently main_input_filename can be NULL. I am not entirely
> > sure when that happens. Or how I failed to see that test failure. I
> > think I didn't have java enabled, causing libffi to be skipped.
> > 
> > I am testing this patch that skips the test in that case:
> 
> Are you sure that is the problem?

No :) I was still bootstrapping. I did see it didn't solve the issue but
hadn't understood why yet...

> I think it doesn't hurt to check for non-NULL main_input_filename, perhaps
> some non-c-family languages might not set it, and this is in generic code,
> but at least on the gcc.target/i386/iamcu/test_passing_structs.c testcase and 
> on one
> randomly selected libffi testcase I see the ICE from completely different
> reason - what is NULL is DECL_SOURCE_FILE (decl).

Thanks, that makes more sense than my first hypothesis.

> We are not really going to warn about this anyway, e.g. because
> it is DECL_ARTIFICIAL, but that is checked only in a much later
> condition.  So, I think you should check also for NULL DECL_SOURCE_FILE
> (and treat it as possibly in a header).  Unfortunately
> DECL_SOURCE_FILE involves a function call, so you might want to cache
> it in some automatic variable.
>   && (warn_unused_const_variable == 2
>   || (main_input_filename != NULL
>   && (decl_file = DECL_SOURCE_FILE (decl)) != NULL
>   && filename_cmp (main_input_filename,
>decl_file) == 0

That looks right. Now testing:

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 49f6c25..e9e1aab 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2016-02-23  Mark Wielaard  
+   Jakub Jelinek  
+
+   PR c/69911
+   * cgraphunit.c (check_global_declaration): Check main_input_filename
+   and DECL_SOURCE_FILE are not NULL.
+
 2016-02-20  Mark Wielaard  
 
PR c/28901
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 27a073a..8b3fddc 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -917,6 +917,7 @@ walk_polymorphic_call_targets (hash_set 
*reachable_call_targets,
 static void
 check_global_declaration (symtab_node *snode)
 {
+  const char *decl_file;
   tree decl = snode->decl;
 
   /* Warn about any function declared static but not defined.  We don't
@@ -944,8 +945,10 @@ check_global_declaration (symtab_node *snode)
|| (((warn_unused_variable && ! TREE_READONLY (decl))
|| (warn_unused_const_variable > 0 && TREE_READONLY (decl)
&& (warn_unused_const_variable == 2
-   || filename_cmp (main_input_filename,
-DECL_SOURCE_FILE (decl)) == 0)))
+   || (main_input_filename != NULL
+   && (decl_file = DECL_SOURCE_FILE (decl)) != NULL
+   && filename_cmp (main_input_filename,
+decl_file) == 0
   && TREE_CODE (decl) == VAR_DECL))
   && ! DECL_IN_SYSTEM_HEADER (decl)
   && ! snode->referred_to_p (/*include_self=*/false)



Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable.

2016-02-23 Thread Jakub Jelinek
On Tue, Feb 23, 2016 at 09:53:57AM +0100, Mark Wielaard wrote:
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,10 @@
> +2016-02-23  Mark Wielaard  
> + Jakub Jelinek  
> +
> + PR c/69911
> + * cgraphunit.c (check_global_declaration): Check main_input_filename
> + and DECL_SOURCE_FILE are not NULL.
> +
>  2016-02-20  Mark Wielaard  

This is ok for trunk if it passes testing.  Thanks.

> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> index 27a073a..8b3fddc 100644
> --- a/gcc/cgraphunit.c
> +++ b/gcc/cgraphunit.c
> @@ -917,6 +917,7 @@ walk_polymorphic_call_targets (hash_set 
> *reachable_call_targets,
>  static void
>  check_global_declaration (symtab_node *snode)
>  {
> +  const char *decl_file;
>tree decl = snode->decl;
>  
>/* Warn about any function declared static but not defined.  We don't
> @@ -944,8 +945,10 @@ check_global_declaration (symtab_node *snode)
> || (((warn_unused_variable && ! TREE_READONLY (decl))
>   || (warn_unused_const_variable > 0 && TREE_READONLY (decl)
>   && (warn_unused_const_variable == 2
> - || filename_cmp (main_input_filename,
> -  DECL_SOURCE_FILE (decl)) == 0)))
> + || (main_input_filename != NULL
> + && (decl_file = DECL_SOURCE_FILE (decl)) != NULL
> + && filename_cmp (main_input_filename,
> +  decl_file) == 0
>  && TREE_CODE (decl) == VAR_DECL))
>&& ! DECL_IN_SYSTEM_HEADER (decl)
>&& ! snode->referred_to_p (/*include_self=*/false)

Jakub


RE: [MIPS r5900] libgcc floating point fixes

2016-02-23 Thread Matthew Fortune
Woon yung Liu  wries
> Bump! Sorry, but could I please get an answer? I'm willing to update the 
> patch without
> credit, if necessary.

Hi WY,

Apologies for exceptionally slow response.

The patch you referenced is mostly OK but I would like to get the MIPS16 check
changed to a configure time check for MIPS16 support rather than checking for
r5900. I.e. I think we should have GCC raise an error for -march=r5900 -mips16
and then a configure time check using just -mips16 would fail. That can then
be used to choose whether to build the mips16 code instead of this:

+   if test x$with_arch != xr5900; then
+   tmake_file="$tmake_file mips/t-mips16"
+   fi

This change should also make it possible to have mips.exp simply skip the mips16
tests for r5900 without having to tell it explicitly about r5900.

Thanks,
Matthew

> The patch is working for the R5900 hard-fp mode. I've also used the same, 
> patched copy of
> GCC, to build the toolchain for the IOP (MIPS R3000A, 32-bit MIPS I with no 
> FPU) and it
> also builds correctly.
> 
> If I should be writing to someone else specifically, could someone please 
> tell me who I
> should be writing to instead?
> 
> 
> Thanks and regards,
> -W Y
> 
> 
> 
> On Tuesday, January 26, 2016 5:41 PM, Woon yung Liu  wrote:
> Hi,
> 
> I refer to the previous message by Juergen, regarding his patch to libgcc.
> https://gcc.gnu.org/ml/gcc-patches/2014-08/msg01725.html
> 
> As of now, libgcc (of GCC v5.3.0) still has the problem of building support 
> for both soft
> and hard floats, when there is no support for hard floats by the R5900 (and 
> hence
> resulting in the generation of recursive functions like extendsfdf2).
> 
> That patch doesn't seem to have been committed. I would very much like to 
> help to see it
> get committed because GCC's support for the R5900 is currently not suitable 
> for
> PlayStation 2 development; software-floating point emulation is severely 
> detrimental to
> performance.
> What else needs to be done first, before it can be accepted?
> 
> Thanks and regards,
> -W Y


Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)

2016-02-23 Thread Jonathan Wakely

On 23/02/16 07:15 +, Bernd Edlinger wrote:

as described in the PR 69881 it happens quite often that cstddef is
called with __need_size_t because we still support gmp-4.3.2 which
is installed by contrib/download_prerequisites.  This causes a kind
of undefined behavior.  It is just by chance that this does not cause
the gcc-6 boot-strap to fail, but it causes gcc-4.9 bootstrap to fail
when the gcc-6 version of cstddef is around.  So it looks like a
regression, because the new cstddef is more fragile than before.


Is it? cstddef hasn't been changed since 2013-06-11. cstdarg hasn't
been changed since 2011-01-30.

What made them more fragile?


Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable.

2016-02-23 Thread Manuel López-Ibáñez

On 23/02/16 08:56, Jakub Jelinek wrote:

On Tue, Feb 23, 2016@09:53:57AM +0100, Mark Wielaard wrote:

--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2016-02-23  Mark Wielaard  
+   Jakub Jelinek  
+
+   PR c/69911
+   * cgraphunit.c (check_global_declaration): Check main_input_filename
+   and DECL_SOURCE_FILE are not NULL.
+
  2016-02-20  Mark Wielaard  


This is ok for trunk if it passes testing.  Thanks.


diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 27a073a..8b3fddc 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -917,6 +917,7 @@ walk_polymorphic_call_targets (hash_set 
*reachable_call_targets,
  static void
  check_global_declaration (symtab_node *snode)
  {
+  const char *decl_file;
tree decl = snode->decl;

/* Warn about any function declared static but not defined.  We don't
@@ -944,8 +945,10 @@ check_global_declaration (symtab_node *snode)
 || (((warn_unused_variable && ! TREE_READONLY (decl))
|| (warn_unused_const_variable > 0 && TREE_READONLY (decl)
&& (warn_unused_const_variable == 2
-   || filename_cmp (main_input_filename,
-DECL_SOURCE_FILE (decl)) == 0)))
+   || (main_input_filename != NULL
+   && (decl_file = DECL_SOURCE_FILE (decl)) != NULL
+   && filename_cmp (main_input_filename,
+decl_file) == 0



Can we please please please hide this ugliness behind an (inline?) function 
such as bool in_main_file_at (location_t) in input.[ch]? The condition here is 
quickly becoming unreadable.


Also because in the future somebody would want to re-implement this using 
MAIN_FILE_P() from line-map.h, which is faster.


Cheers,

Manuel.




Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable.

2016-02-23 Thread Jakub Jelinek
On Tue, Feb 23, 2016 at 09:51:05AM +, Manuel López-Ibáñez wrote:
> >>diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> >>index 27a073a..8b3fddc 100644
> >>--- a/gcc/cgraphunit.c
> >>+++ b/gcc/cgraphunit.c
> >>@@ -917,6 +917,7 @@ walk_polymorphic_call_targets (hash_set 
> >>*reachable_call_targets,
> >>  static void
> >>  check_global_declaration (symtab_node *snode)
> >>  {
> >>+  const char *decl_file;
> >>tree decl = snode->decl;
> >>
> >>/* Warn about any function declared static but not defined.  We don't
> >>@@ -944,8 +945,10 @@ check_global_declaration (symtab_node *snode)
> >> || (((warn_unused_variable && ! TREE_READONLY (decl))
> >>|| (warn_unused_const_variable > 0 && TREE_READONLY (decl)
> >>&& (warn_unused_const_variable == 2
> >>-   || filename_cmp (main_input_filename,
> >>-DECL_SOURCE_FILE (decl)) == 0)))
> >>+   || (main_input_filename != NULL
> >>+   && (decl_file = DECL_SOURCE_FILE (decl)) != NULL
> >>+   && filename_cmp (main_input_filename,
> >>+decl_file) == 0
> 
> 
> Can we please please please hide this ugliness behind an (inline?) function
> such as bool in_main_file_at (location_t) in input.[ch]? The condition here
> is quickly becoming unreadable.
> 
> Also because in the future somebody would want to re-implement this using
> MAIN_FILE_P() from line-map.h, which is faster.

I'm not against that, but I'd prefer if it is done incrementally, we don't
want to keep the trunk broken too much for too long.  So if Mark is already
testing this patch, IMHO it is better to commit it in this shape sooner.

Jakub


Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)

2016-02-23 Thread Bernd Edlinger
On 23/02/15 10:42, Jonathan Wakely wrote:
>On 23/02/16 07:15 +, Bernd Edlinger wrote:
>>as described in the PR 69881 it happens quite often that cstddef is
>>called with __need_size_t because we still support gmp-4.3.2 which
>>is installed by contrib/download_prerequisites.  This causes a kind
>>of undefined behavior.  It is just by chance that this does not cause
>>the gcc-6 boot-strap to fail, but it causes gcc-4.9 bootstrap to fail
>>when the gcc-6 version of cstddef is around.  So it looks like a
>>regression, because the new cstddef is more fragile than before.
>
>Is it? cstddef hasn't been changed since 2013-06-11. cstdarg hasn't
>been changed since 2011-01-30.
>
>What made them more fragile?

Good question.

The cstddef had this even in gcc.4.9 that's true, but it was not used
by default:

#if __cplusplus >= 201103L
namespace std
{
  // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
  using ::max_align_t;
}
#endif


Previously the g++ default was --std=gnu++98,
but gcc-6 changed the default to --std=gnu++14.

And when building gcc-4.9, stage1 does not override that with
--std=gnu++98.

That has changed, and that triggers the latent bug.


Bernd.

Re: [Patch, testsuite] Require int32 target support in sso tests

2016-02-23 Thread Mike Stump
On Feb 22, 2016, at 11:52 PM, Senthil Kumar Selvaraj 
 wrote:
> 
> Yes that works

Ok.

Committed revision 233621.

Scream if anything goes wrong.  Thanks for testing.

Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)

2016-02-23 Thread Jakub Jelinek
On Tue, Feb 23, 2016 at 10:00:58AM +, Bernd Edlinger wrote:
> Previously the g++ default was --std=gnu++98,
> but gcc-6 changed the default to --std=gnu++14.
> 
> And when building gcc-4.9, stage1 does not override that with
> --std=gnu++98.
> 
> That has changed, and that triggers the latent bug.

So just use -std=gnu++98 in STAGE1_CXXFLAGS or configure with
CXX='g++ -std=gnu++98' if you try to build gcc-4.9 with gcc 6?

I really don't think we should work around this in GCC 6.

Jakub


[wwwdocs] Add a link to porting_to

2016-02-23 Thread Marek Polacek
Committed.

Index: porting_to.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-6/porting_to.html,v
retrieving revision 1.14
diff -u -r1.14 porting_to.html
--- porting_to.html 14 Feb 2016 13:13:43 -  1.14
+++ porting_to.html 23 Feb 2016 10:13:06 -
@@ -408,5 +408,9 @@
 
 Links
 
+
+Marek Polacek https://lists.fedoraproject.org/archives/list/de...@lists.fedoraproject.org/message/DH7M2ADHM6XCRFTRRSKZD6MWFUJKHBZK/";>Fedora
 mass rebuild 2016 on x86_64
+
+
 
 

Marek


Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)

2016-02-23 Thread Jonathan Wakely

On 23/02/16 10:00 +, Bernd Edlinger wrote:

On 23/02/15 10:42, Jonathan Wakely wrote:

On 23/02/16 07:15 +, Bernd Edlinger wrote:

as described in the PR 69881 it happens quite often that cstddef is
called with __need_size_t because we still support gmp-4.3.2 which
is installed by contrib/download_prerequisites.  This causes a kind
of undefined behavior.  It is just by chance that this does not cause
the gcc-6 boot-strap to fail, but it causes gcc-4.9 bootstrap to fail
when the gcc-6 version of cstddef is around.  So it looks like a
regression, because the new cstddef is more fragile than before.


Is it? cstddef hasn't been changed since 2013-06-11. cstdarg hasn't
been changed since 2011-01-30.

What made them more fragile?


Good question.

The cstddef had this even in gcc.4.9 that's true, but it was not used
by default:

#if __cplusplus >= 201103L
namespace std
{
 // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
 using ::max_align_t;
}
#endif


Previously the g++ default was --std=gnu++98,
but gcc-6 changed the default to --std=gnu++14.


Ah yes.


And when building gcc-4.9, stage1 does not override that with
--std=gnu++98.

That has changed, and that triggers the latent bug.


Alright then, the patch is OK for trunk.

I might revert it once we stop using the buggy GMP in
contrib/download_prerequisites.



[Committed 2/3] S/390: Move movstr-2.c into vector subdir.

2016-02-23 Thread Andreas Krebbel
gcc/testsuite/ChangeLog:

* gcc.target/s390/md/movstr-2.c: Move and rename to ...
* gcc.target/s390/vector/stpcpy-1.c: ... this one.
---
 gcc/testsuite/gcc.target/s390/md/movstr-2.c |  98 ---
 gcc/testsuite/gcc.target/s390/vector/stpcpy-1.c | 100 
 2 files changed, 100 insertions(+), 98 deletions(-)
 delete mode 100644 gcc/testsuite/gcc.target/s390/md/movstr-2.c
 create mode 100644 gcc/testsuite/gcc.target/s390/vector/stpcpy-1.c

diff --git a/gcc/testsuite/gcc.target/s390/md/movstr-2.c 
b/gcc/testsuite/gcc.target/s390/md/movstr-2.c
deleted file mode 100644
index 1b977a2..000
--- a/gcc/testsuite/gcc.target/s390/md/movstr-2.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* The z13 stpcpy implementation plays some alignment tricks for good
-   performance.  This test tries to make sure it works correctly and
-   does not access bytes beyond the source and destination
-   strings.  */
-
-/* { dg-do run } */
-
-#include 
-#include 
-
-#define PAGE_SIZE 4096
-
-struct {
-  char unused[PAGE_SIZE - 32];
-  char m32[15]; /* page bndry - 32 */
-  char m17[1];
-  char m16[1];
-  char m15[14];
-  char m1[1];
-  char next_page[PAGE_SIZE];
-} s, d __attribute__((aligned(PAGE_SIZE)));
-
-char *__attribute__((noinline))
-my_stpcpy(char *dest, const char *src)
-{
-  return __builtin_stpcpy (dest, src);
-}
-
-void __attribute__ ((noinline))
-check (char *dest, char *src, size_t len)
-{
-  char *result;
-
-  result = my_stpcpy (dest, src);
-  if (result != dest + len)
-__builtin_abort ();
-  if (__builtin_memcmp (src, dest, len) != 0)
-__builtin_abort ();
-}
-
-int
-main ()
-{
-  char *src[5] = { s.m32, s.m17, s.m16, s.m15, s.m1 };
-  char *dst[5] = { d.m32, d.m17, d.m16, d.m15, d.m1 };
-  int len[8] = { 33, 32, 31, 17, 16, 15, 1, 0 };
-  int i, j, k;
-  char backup;
-
-  for (i = 0; i < sizeof (s); i++)
-((char*)&s)[i] = i % 26 + 97;
-
-  for (i = 0; i < 5; i++)
-for (j = 0; j < 5; j++)
-  for (k = 0; k < 8; k++)
-   {
- backup = src[j][len[k]];
- src[j][len[k]] = 0;
- __builtin_memset (&d, 0, sizeof (d));
- check (dst[i], src[j], len[k]);
- src[j][len[k]] = backup;
-   }
-
-  /* Make all source strings end before the page boundary.  */
-  backup = s.m1[0];
-  s.m1[0] = 0;
-
-  if (mprotect (&s.next_page, PAGE_SIZE, PROT_NONE) == -1)
-perror ("mprotect src");
-
-  for (i = 0; i < 5; i++)
-for (j = 0; j < 5; j++)
-  check (dst[i], src[j],
-PAGE_SIZE - ((unsigned long)src[j] & ((1UL << 12) - 1)) - 1);
-
-  if (mprotect (&s.next_page, PAGE_SIZE, PROT_READ | PROT_WRITE) == -1)
-perror ("mprotect src");
-
-  s.m1[0] = backup;
-
-  if (mprotect (&d.next_page, PAGE_SIZE, PROT_NONE) == -1)
-perror ("mprotect dst");
-
-  for (i = 0; i < 5; i++)
-for (j = 0; j < 5; j++)
-  {
-   int len = PAGE_SIZE - ((unsigned long)dst[i] & ((1UL << 12) - 1)) - 1;
-   char backup = src[j][len];
-
-   src[j][len] = 0;
-   __builtin_memset (&d, 0,
- (unsigned long)&d.next_page - (unsigned long)&d);
-   check (dst[i], src[j], len);
-   src[j][len] = backup;
-  }
-
-  return 0;
-}
diff --git a/gcc/testsuite/gcc.target/s390/vector/stpcpy-1.c 
b/gcc/testsuite/gcc.target/s390/vector/stpcpy-1.c
new file mode 100644
index 000..91c1f7c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/vector/stpcpy-1.c
@@ -0,0 +1,100 @@
+/* The z13 stpcpy implementation plays some alignment tricks for good
+   performance.  This test tries to make sure it works correctly and
+   does not access bytes beyond the source and destination
+   strings.  */
+
+/* { dg-do run } */
+/* { dg-require-effective-target vector } */
+/* { dg-options "-O3 -mzarch -march=z13" } */
+
+#include 
+#include 
+
+#define PAGE_SIZE 4096
+
+struct {
+  char unused[PAGE_SIZE - 32];
+  char m32[15]; /* page bndry - 32 */
+  char m17[1];
+  char m16[1];
+  char m15[14];
+  char m1[1];
+  char next_page[PAGE_SIZE];
+} s, d __attribute__((aligned(PAGE_SIZE)));
+
+char *__attribute__((noinline))
+my_stpcpy(char *dest, const char *src)
+{
+  return __builtin_stpcpy (dest, src);
+}
+
+void __attribute__ ((noinline))
+check (char *dest, char *src, size_t len)
+{
+  char *result;
+
+  result = my_stpcpy (dest, src);
+  if (result != dest + len)
+__builtin_abort ();
+  if (__builtin_memcmp (src, dest, len) != 0)
+__builtin_abort ();
+}
+
+int
+main ()
+{
+  char *src[5] = { s.m32, s.m17, s.m16, s.m15, s.m1 };
+  char *dst[5] = { d.m32, d.m17, d.m16, d.m15, d.m1 };
+  int len[8] = { 33, 32, 31, 17, 16, 15, 1, 0 };
+  int i, j, k;
+  char backup;
+
+  for (i = 0; i < sizeof (s); i++)
+((char*)&s)[i] = i % 26 + 97;
+
+  for (i = 0; i < 5; i++)
+for (j = 0; j < 5; j++)
+  for (k = 0; k < 8; k++)
+   {
+ backup = src[j][len[k]];
+ src[j][len[k]] = 0;
+ __builtin_memset (&d, 0, sizeof (d));
+ check (dst[i], src[j], len[k]);
+ src[j][len[k]

Re: [PATCH] Make cstddef / cstdarg more robust (PR 69881)

2016-02-23 Thread Jonathan Wakely

On 23/02/16 11:09 +0100, Jakub Jelinek wrote:

On Tue, Feb 23, 2016 at 10:00:58AM +, Bernd Edlinger wrote:

Previously the g++ default was --std=gnu++98,
but gcc-6 changed the default to --std=gnu++14.

And when building gcc-4.9, stage1 does not override that with
--std=gnu++98.

That has changed, and that triggers the latent bug.


So just use -std=gnu++98 in STAGE1_CXXFLAGS or configure with
CXX='g++ -std=gnu++98' if you try to build gcc-4.9 with gcc 6?

I really don't think we should work around this in GCC 6.


I agree, but #undefining those macros doesn't hurt, and hopefully the
issue will go away.



[Committed 3/3] S/390: Move vcond-shift.c to vector subdir.

2016-02-23 Thread Andreas Krebbel
gcc/testsuite/ChangeLog:

* gcc.target/s390/vcond-shift.c: Move to ...
* gcc.target/s390/vector/vcond-shift.c: ... here.
---
 gcc/testsuite/gcc.target/s390/vcond-shift.c| 61 --
 gcc/testsuite/gcc.target/s390/vector/vcond-shift.c | 61 ++
 2 files changed, 61 insertions(+), 61 deletions(-)
 delete mode 100644 gcc/testsuite/gcc.target/s390/vcond-shift.c
 create mode 100644 gcc/testsuite/gcc.target/s390/vector/vcond-shift.c

diff --git a/gcc/testsuite/gcc.target/s390/vcond-shift.c 
b/gcc/testsuite/gcc.target/s390/vcond-shift.c
deleted file mode 100644
index f58bd1f..000
--- a/gcc/testsuite/gcc.target/s390/vcond-shift.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Check if conditional vector instructions are simplified
-   into shift operations.  */
-/* { dg-do compile { target { s390*-*-* } } } */
-/* { dg-options "-O3 -march=z13 -mzarch" } */
-
-/* { dg-final { scan-assembler "vesraf\t%v.?,%v.?,31" } } */
-/* { dg-final { scan-assembler "vesrah\t%v.?,%v.?,15" } } */
-/* { dg-final { scan-assembler "vesrab\t%v.?,%v.?,7" } } */
-/* { dg-final { scan-assembler-not "vzero\t*" } } */
-/* { dg-final { scan-assembler "vesrlf\t%v.?,%v.?,31" } } */
-/* { dg-final { scan-assembler "vesrlh\t%v.?,%v.?,15" } } */
-/* { dg-final { scan-assembler "vesrlb\t%v.?,%v.?,7" } } */
-
-#define SZ 4
-#define SZ2 8
-#define SZ3 16
-
-void foo(int *w)
-{
-  int i;
-  /* Should expand to (w + (w < 0 ? 1 : 0)) >> 1
- which in turn should get simplified to (w + (w >> 31)) >> 1.  */
-  for (i = 0; i < SZ; i++)
-w[i] = w[i] / 2;
-}
-
-void foo2(short *w)
-{
-  int i;
-  for (i = 0; i < SZ2; i++)
-w[i] = w[i] / 2;
-}
-
-
-void foo3(signed char *w)
-{
-  int i;
-  for (i = 0; i < SZ3; i++)
-w[i] = w[i] / 2;
-}
-
-int baz(int *x)
-{
-  int i;
-  for (i = 0; i < SZ; i++)
-x[i] = x[i] < 0 ? -1 : 0;
-}
-
-int baf(short *x)
-{
-  int i;
-  for (i = 0; i < SZ2; i++)
-x[i] = x[i] >= 0 ? 0 : 1;
-}
-
-int bal(signed char *x)
-{
-  int i;
-  for (i = 0; i < SZ3; i++)
-x[i] = x[i] >= 0 ? 0 : -1;
-}
diff --git a/gcc/testsuite/gcc.target/s390/vector/vcond-shift.c 
b/gcc/testsuite/gcc.target/s390/vector/vcond-shift.c
new file mode 100644
index 000..f58bd1f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/vector/vcond-shift.c
@@ -0,0 +1,61 @@
+/* Check if conditional vector instructions are simplified
+   into shift operations.  */
+/* { dg-do compile { target { s390*-*-* } } } */
+/* { dg-options "-O3 -march=z13 -mzarch" } */
+
+/* { dg-final { scan-assembler "vesraf\t%v.?,%v.?,31" } } */
+/* { dg-final { scan-assembler "vesrah\t%v.?,%v.?,15" } } */
+/* { dg-final { scan-assembler "vesrab\t%v.?,%v.?,7" } } */
+/* { dg-final { scan-assembler-not "vzero\t*" } } */
+/* { dg-final { scan-assembler "vesrlf\t%v.?,%v.?,31" } } */
+/* { dg-final { scan-assembler "vesrlh\t%v.?,%v.?,15" } } */
+/* { dg-final { scan-assembler "vesrlb\t%v.?,%v.?,7" } } */
+
+#define SZ 4
+#define SZ2 8
+#define SZ3 16
+
+void foo(int *w)
+{
+  int i;
+  /* Should expand to (w + (w < 0 ? 1 : 0)) >> 1
+ which in turn should get simplified to (w + (w >> 31)) >> 1.  */
+  for (i = 0; i < SZ; i++)
+w[i] = w[i] / 2;
+}
+
+void foo2(short *w)
+{
+  int i;
+  for (i = 0; i < SZ2; i++)
+w[i] = w[i] / 2;
+}
+
+
+void foo3(signed char *w)
+{
+  int i;
+  for (i = 0; i < SZ3; i++)
+w[i] = w[i] / 2;
+}
+
+int baz(int *x)
+{
+  int i;
+  for (i = 0; i < SZ; i++)
+x[i] = x[i] < 0 ? -1 : 0;
+}
+
+int baf(short *x)
+{
+  int i;
+  for (i = 0; i < SZ2; i++)
+x[i] = x[i] >= 0 ? 0 : 1;
+}
+
+int bal(signed char *x)
+{
+  int i;
+  for (i = 0; i < SZ3; i++)
+x[i] = x[i] >= 0 ? 0 : -1;
+}
-- 
1.9.1



[Committed 0/3] S/390: Move recently added testcases to correct subdirs

2016-02-23 Thread Andreas Krebbel
Andreas Krebbel (3):
  S/390: Turn movstr-1.c into compile only test.
  S/390: Move movstr-2.c into vector subdir.
  S/390: Move vcond-shift.c to vector subdir.

 gcc/testsuite/gcc.target/s390/md/movstr-1.c|  16 +---
 gcc/testsuite/gcc.target/s390/md/movstr-2.c|  98 
 gcc/testsuite/gcc.target/s390/vcond-shift.c|  61 -
 gcc/testsuite/gcc.target/s390/vector/stpcpy-1.c| 100 +
 gcc/testsuite/gcc.target/s390/vector/vcond-shift.c |  61 +
 5 files changed, 163 insertions(+), 173 deletions(-)
 delete mode 100644 gcc/testsuite/gcc.target/s390/md/movstr-2.c
 delete mode 100644 gcc/testsuite/gcc.target/s390/vcond-shift.c
 create mode 100644 gcc/testsuite/gcc.target/s390/vector/stpcpy-1.c
 create mode 100644 gcc/testsuite/gcc.target/s390/vector/vcond-shift.c

-- 
1.9.1



[Committed 1/3] S/390: Turn movstr-1.c into compile only test.

2016-02-23 Thread Andreas Krebbel
gcc/testsuite/ChangeLog:

* gcc.target/s390/md/movstr-1.c: Turn into compile test.
---
 gcc/testsuite/gcc.target/s390/md/movstr-1.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/gcc/testsuite/gcc.target/s390/md/movstr-1.c 
b/gcc/testsuite/gcc.target/s390/md/movstr-1.c
index da98415..b83ed6d 100644
--- a/gcc/testsuite/gcc.target/s390/md/movstr-1.c
+++ b/gcc/testsuite/gcc.target/s390/md/movstr-1.c
@@ -1,7 +1,7 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run } */
-/* { dg-options "-dP -save-temps" } */
+/* { dg-do compile } */
+/* { dg-options "-dP" } */
 
 __attribute__ ((noinline))
 void test(char *dest, const char *src)
@@ -10,15 +10,3 @@ void test(char *dest, const char *src)
 }
 
 /* { dg-final { scan-assembler-times {{[*]movstr}|{vec_vfenesv16qi}} 1 } } */
-
-#define LEN 200
-char buf[LEN];
-
-int main(void)
-{
-  __builtin_memset(buf, 0, LEN);
-  test(buf, "hello world!");
-  if (__builtin_strcmp(buf, "hello world!") != 0)
-__builtin_abort();
-  return 0;
-}
-- 
1.9.1



Re: [PATCH] Fix PR56888

2016-02-23 Thread Jan Hubicka
> On Mon, 22 Feb 2016, Jakub Jelinek wrote:
> 
> > On Mon, Feb 22, 2016 at 01:44:09PM +0100, Richard Biener wrote:
> > > --- 1079,1086 
> > > || !dominated_by_p (CDI_DOMINATORS,
> > > loop->latch, gimple_bb (stmt)))
> > >   return;
> > > +   if (cgraph_node::get (cfun->decl)->aliases (BUILT_IN_MEMSET))
> > > + return;
> > 
> > Perhaps also punt here for:
> > BUILT_IN_MEMSET_CHK
> > BUILT_IN_TM_MEMSET
> > BUILT_IN_BZERO
> > ?
> > 
> > > partition->kind = PKIND_MEMSET;
> > > partition->main_dr = single_store;
> > > partition->niter = nb_iter;
> > > *** classify_partition (loop_p loop, struct
> > > *** 1135,1140 
> > > --- 1138,1146 
> > >   }
> > > free_dependence_relation (ddr);
> > > loops.release ();
> > > +   if (cgraph_node::get (cfun->decl)->aliases (BUILT_IN_MEMCPY)
> > > +   || cgraph_node::get (cfun->decl)->aliases (BUILT_IN_MEMMOVE))
> > > + return;
> > 
> > And here for
> > BUILT_IN_MEMCPY_CHK
> > BUILT_IN_TM_MEMCPY
> > BUILT_IN_TM_MEMCPY_RNWT
> > BUILT_IN_TM_MEMCPY_RTWN
> > BUILT_IN_MEMPCPY
> > BUILT_IN_MEMPCPY_CHK
> > BUILT_IN_MEMMOVE_CHK
> > BUILT_IN_TM_MEMMOVE
> > BUILT_IN_BCOPY
> > ?
> 
> I'm going to wait for Honzas feedback.  Testing all of the above
> looks expensive - if those are implemented in terms of memcpy/memset
> then hopefully in libc itself which hopefully always does local
> calls.

Well, other problem will be if memcpy itself is implemented by calling a
function that does the actual copying job (for example, for large block sizes
or so). So for ultimate QOI fix you really want to check if the function you
are optimizing is reachable from any of those bultins. This is of course
doable by means of simple propagation pass, but I am not sure if it makes
sense to get that far.

The checks however should not be that bad - they are done only when we
recognize the memcpy pattern and want to optimize it and that is not too common
case, right?
> 
> It's not going to be an exhaustive check anyway, just a QOI one
> covering those cases we've seen in the wild.  Esp. as indirection
> will break the detection (so does using asm(".alias XXX") which glibc
> does).

To lookup definition of the bulitin, you don't really need assembler name
lookup.  Just get cgraph node for the builtin decl and look
next_sharing_asm_name and prev_shaing_asm_name lists (this works only when asm
name hash is initialized, so to be sure just call
symtab->symtab_initialize_asm_name_hash ();

For next stage1 I have queued patch that makes duplicated decls to be
transparent alises, so you will need to only lookup the ultimate alias target.
I did not commited it to mainline becuase it requires lto-symtab like linking
to be done each time new duplciate is inserted into the symbol table and it
tends to find new user errors on misuse of asm("...") constructs.
Also one needs to fix the chkp issues

Honza
> 
> Richard.


Re: [PATCH] Fix PR56888

2016-02-23 Thread Jan Hubicka
> 
> Ok, so maybe a better question to symtab would be if there is an
> actual definition for what __builtin_FOO will call.  Not really
> whether that definition is cfun.  Of course all the fortify
> always-inline wrappers should not count as such (just in case
> the symtab code is confused about those).

Also GNU extern inlines that are often used to deal special cases.
> 
> So,
> 
> bool symbol_table::have_definition (enum built_in_fn);
> 
> ?  Not sure how to best implement that either.  asmname lookups are
> expensive ...

I am back from China trip, so i can handle you patch if you want.

I see that by stopping the optimization on whole translation unit that
defines memcpy/memset will solve the reachability issue I mentioned
in previous mail, but also when LTOing stuff like Linux kernel, it will
prevent the optimization on the whole program.
I am not quite sure how to deal with the alwaysinline wrappers however,
because there theoretically may contain memcpy/memset loops themselves.

Honza
> 
> Richard.


Re: [Patch, fortran, pr67451, v1] [5/6 Regression] ICE with sourced allocation from coarray

2016-02-23 Thread Andre Vehreschild
Hi Paul,

thanks for the review. Committed as r233625.

Regards,
Andre

On Wed, 17 Feb 2016 14:13:48 +0100
Paul Richard Thomas  wrote:

> Dear Andre,
> 
> I had left this to somebody else, since I am travelling!
> 
> The patch is verging on 'obvious' and so it is OK for trunk.
> 
> Could you check the line terminators please? I am seeing CR-LFs but
> this might be an effect of transmission.
> 
> Thanks for the patch.
> 
> Paul
> 
> On 10 February 2016 at 12:26, Andre Vehreschild  wrote:
> > Hi all,
> >
> > unfortunately was my last patch for pr67451 not perfect and introduced
> > regressions occurring on s390(x) and with the sanitizer. These were
> > caused, because when taking the array specs from the source=-expression
> > also its attributes, like coarray state and so on where taken from
> > there. This additionally added a corank to local objects to allocate,
> > that were no coarrays overwriting data in the array handle. The attached
> > patch fixes both issues.
> >
> > The patch for gcc-5 is not affected, because in gcc-5 the feature of
> > taking the array spec from the source=-expression is not implemented.
> >
> > Bootstrapped and regtested ok on x86_64-linux-gnu/F23.
> >
> > Ok for trunk?
> >
> > Regards,
> > Andre
> >
> > On Tue, 2 Feb 2016 19:24:46 +0100
> > Paul Richard Thomas  wrote:
> >  
> >> Hi Andre,
> >>
> >> This looks to be OK for trunk.
> >>
> >> I'll move to the 5-branch patch right away.
> >>
> >> Thanks
> >>
> >> Paul
> >>
> >> On 29 January 2016 at 19:17, Andre Vehreschild  wrote:  
> >> > Hi all,
> >> >
> >> > attached is a patch to fix a regression in current gfortran when a
> >> > coarray is used in the source=-expression of an allocate(). The ICE was
> >> > caused by the class information, i.e., _vptr and so on, not at the
> >> > expected place. The patch fixes this.
> >> >
> >> > The patch also fixes pr69418, which I will flag as a duplicate in a
> >> > second.
> >> >
> >> > Bootstrapped and regtested ok on x86_64-linux-gnu/F23.
> >> >
> >> > Ok for trunk?
> >> >
> >> > Backport to gcc-5 is pending, albeit more difficult, because the
> >> > allocate() implementation on 5 is not as advanced the one in 6.
> >> >
> >> > Regards,
> >> > Andre
> >> > --
> >> > Andre Vehreschild * Email: vehre ad gmx dot de  
> >>
> >>
> >>  
> >
> >
> > --
> > Andre Vehreschild * Email: vehre ad gmx dot de  
> 
> 
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
Index: gcc/fortran/ChangeLog
===
--- gcc/fortran/ChangeLog	(Revision 233624)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,9 @@
+2016-02-23  Andre Vehreschild  
+
+	PR fortran/67451
+	* trans-array.c (gfc_array_allocate): Take the attributes from the
+	expression to allocate and not from the source=-expression.
+
 2016-02-20  Paul Thomas  
 
 	PR fortran/69423
Index: gcc/fortran/trans-array.c
===
--- gcc/fortran/trans-array.c	(Revision 233624)
+++ gcc/fortran/trans-array.c	(Arbeitskopie)
@@ -5401,17 +5401,8 @@
   if (!retrieve_last_ref (&ref, &prev_ref))
 return false;
 
-  if (ref->u.ar.type == AR_FULL && expr3 != NULL)
-{
-  /* F08:C633: Array shape from expr3.  */
-  ref = expr3->ref;
-
-  /* Find the last reference in the chain.  */
-  if (!retrieve_last_ref (&ref, &prev_ref))
-	return false;
-  alloc_w_e3_arr_spec = true;
-}
-
+  /* Take the allocatable and coarray properties solely from the expr-ref's
+ attributes and not from source=-expression.  */
   if (!prev_ref)
 {
   allocatable = expr->symtree->n.sym->attr.allocatable;
@@ -5428,6 +5419,17 @@
   if (!dimension)
 gcc_assert (coarray);
 
+  if (ref->u.ar.type == AR_FULL && expr3 != NULL)
+{
+  /* F08:C633: Array shape from expr3.  */
+  ref = expr3->ref;
+
+  /* Find the last reference in the chain.  */
+  if (!retrieve_last_ref (&ref, &prev_ref))
+	return false;
+  alloc_w_e3_arr_spec = true;
+}
+
   /* Figure out the size of the array.  */
   switch (ref->u.ar.type)
 {
@@ -5463,7 +5465,8 @@
   gfc_init_block (&set_descriptor_block);
   size = gfc_array_init_size (se->expr, alloc_w_e3_arr_spec ? expr->rank
 			   : ref->u.ar.as->rank,
-			  ref->u.ar.as->corank, &offset, lower, upper,
+			  coarray ? ref->u.ar.as->corank : 0,
+			  &offset, lower, upper,
 			  &se->pre, &set_descriptor_block, &overflow,
 			  expr3_elem_size, nelems, expr3, e3_arr_desc,
 			  e3_is_array_constr, expr);
Index: gcc/testsuite/ChangeLog
===
--- gcc/testsuite/ChangeLog	(Revision 233624)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@
+2016-02-23  Andre Vehreschild  
+
+	PR fortran/67451
+	* gfortran.dg/coarray_allocate_5.f08: New test.
+
 2016-02-23  Andreas Krebbel  
 
 	* gcc.target/s390/vcond-shift.c: Move to ...
Index: gcc/testsuite/gfortran.dg/coarray_

Re: RFA: Prevent an ICE when redeclaring a static function as weak

2016-02-23 Thread Nick Clifton
Hi Jeff,

> My inclination would be to defer to gcc-7.  Richi, Jakub or Joseph, as 
> release managers, would have the final say though.

It's OK.  I will resubmit after gcc 6 branches.

Cheers
  Nick



Re: [PATCH] Fix PR56888

2016-02-23 Thread Richard Biener
On Tue, 23 Feb 2016, Jan Hubicka wrote:

> > 
> > Ok, so maybe a better question to symtab would be if there is an
> > actual definition for what __builtin_FOO will call.  Not really
> > whether that definition is cfun.  Of course all the fortify
> > always-inline wrappers should not count as such (just in case
> > the symtab code is confused about those).
> 
> Also GNU extern inlines that are often used to deal special cases.
> > 
> > So,
> > 
> > bool symbol_table::have_definition (enum built_in_fn);
> > 
> > ?  Not sure how to best implement that either.  asmname lookups are
> > expensive ...
> 
> I am back from China trip, so i can handle you patch if you want.
> 
> I see that by stopping the optimization on whole translation unit that
> defines memcpy/memset will solve the reachability issue I mentioned
> in previous mail, but also when LTOing stuff like Linux kernel, it will
> prevent the optimization on the whole program.

Yes, but I think it's reasonable to disable such transform if the
memcpy implementation is being optimized.

> I am not quite sure how to deal with the alwaysinline wrappers however,
> because there theoretically may contain memcpy/memset loops themselves.

It might be a non-issue as we are doing the transforms only after
inlining when those bodies should be gone and thus symtab shouldn't see
such implementation.

Better to double-check, of course.  We'd want

#include 

int main()
{
  int s[1204];
  for (int i = 0; i < 1204; ++i)
   s[i] = 0;
  memset (s, 0, sizeof (s));
}

still be optimized as memset.

Richard.

> Honza
> > 
> > Richard.
> 
> 

-- 
Richard Biener 
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)


Re: [PATCH, ARM] Fix redefinition of cpp macros with #pragma GCC pop,reset

2016-02-23 Thread Kyrill Tkachov

Hi Christian,

On 17/02/16 12:50, Christian Bruel wrote:

target_option_current_node, used in c-pragma.c to check if a state
should be popped or reseted to the previous value, was not set when
switching state with #pragma GCC target (I missed to see that, since it
is done for pop,reset). So in some cases the state might not be reset
correctly.

This patch sets it for #pragma GCC target paths and update the comments
as well to clarify this point.

As a benefit we now use this cached value instead of
build_target_option_node (&global_options), this should speed up (a
little bit) this path when processing arm_neon.h.

One effect of it is that some predicate tests (e.g arm_neonv2_ok) in the
testsuite was returning the wrong value, thus marking some test as
UNRESOLVED instead of PASS. See the reduced case of the issue attached
is the patch.

Regtested, a few new PASS for -mfpu=neon-fp-armv8



Ok.
Thanks,
Kyrill


Re: [RFC] [P2] [PR tree-optimization/33562] Lowering more complex assignments.

2016-02-23 Thread Richard Biener
On Mon, Feb 22, 2016 at 5:32 PM, Jeff Law  wrote:
> On 02/22/2016 07:32 AM, Richard Biener wrote:
>
>>> Presumably DOM is not looking at r = s.r and realizing it could look s.r
>>> piece-wise in the available expression table.  If it did, it would
>>> effectively turn that fragment into:
>>>
>>>  s = { {1, 2}, 3 };
>>>  s.r.x = 1;
>>>  s.r.y = 2;
>>>  struct R r = {1, 2}
>>>  s.z = 3;
>>>
>>> At which point we no longer have the may-read of s.r.{x,y} and DSE would
>>> see
>>> the initial assignment as dead.
>>
>>
>> Yeah, but if it does not become dead you just increased code size or
>> lifetime...
>
> Increasing lifetimes is inherent in just about any CSE optimization. But as
> I mentioned, I'm not sure trying to add this aggregate handling to DOM is
> wise.
>
>>
>> FRE does something related - it looks at all piecewise uses of 'r' and
>> eventually replaces them with pieces of s.r when seeing the r = s.r
>> aggregate assignment.  Of course that only makes the store to r dead if
>> there
>> are no uses of it left.
>
> *If* we were to try and do something similar in DOM, we'd probably want to
> try and share much of the infrastructure.  I'll keep the FRE code in mind.
>
>>
>>> I also looked a bit at cases where we find that while an entire store
>>> (such
>>> as an aggregate initialization or mem*) may not be dead, pieces of the
>>> store
>>> may be dead.   That's trivial to detect.   It triggers relatively often.
>>> The trick is once detected, we have to go back and rewrite the original
>>> statement to only store the live parts.  I've only written the detection
>>> code, the rewriting might be somewhat painful.
>>
>>
>> Yes.  I think SRA has all the code to do that though, see how it
>> does scalarization of constant pool loads like
>
> Ohhh.  Good idea, I'll dig around SRA for a bit and see if there's something
> that can be re-used.
>
>>> I'm starting to wonder if what we have is a 3-part series.
>>>
>>> [1/3] The basic tracking to handle 33562, possibly included in gcc-6
>>> [2/3] Ignore reads that reference stuff not in live_bytes for gcc-7
>>> [3/3] Detect partially dead aggregate stores, rewriting the partially
>>>dead store to only store the live bytes.  Also for gcc-7.
>>>
>>>
>>> Obviously [1/3] would need compile-time benchmarking, but I really don't
>>> expect any issues there.
>>
>>
>> So what's the overall statistic result on [1/3] if you exclude the
>> clobbers?
>
> Very few, call it a dozen, all in libstdc++.  They weren't significantly
> different than ssa-dse-9.c, so I didn't try to build nice reduced testcases
> for them given we've got existing coverage.
>
> One could argue that with the few real world cases that 33562 could be
> punted to P4 and and patch series deferred to gcc-7.  I wouldn't lose sleep
> over that option.

Way to go at this point IMHO.  That is, keep at P2 please, P4 is for sth else.
It's not a P1 blocker anyway.

Richard.

> Jeff
>


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

2016-02-23 Thread Alan Lawrence

On 22/02/16 12:03, Jakub Jelinek wrote:


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


Well, with just those two, this fixes 416.gamess, and passes all tests in 
gfortran, with only a few scan-dump/warning tests failing in gcc...


--Alan


Re: [PATCH] Note that -Wunreachable-code used to be a warning option (PR c/69900)

2016-02-23 Thread Richard Biener
On Mon, Feb 22, 2016 at 10:18 PM, Jakub Jelinek  wrote:
> Hi!
>
> While we ignore -Wunreachable-code option now, as we require
> that GCC diagnostic options are CL_WARNING only, we should remember
> that this is a former Warning option (similarly for -Werror=).
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Richard.

> 2016-02-22  Jakub Jelinek  
>
> PR c/69900
> * common.opt (Wunreachable-code): Add Warning flag.
>
> * gcc.dg/pr69900.c: New test.
>
> --- gcc/common.opt.jj   2016-02-16 21:43:38.0 +0100
> +++ gcc/common.opt  2016-02-22 12:16:53.393949080 +0100
> @@ -728,7 +728,7 @@ Common Var(warn_maybe_uninitialized) War
>  Warn about maybe uninitialized automatic variables.
>
>  Wunreachable-code
> -Common Ignore
> +Common Ignore Warning
>  Does nothing. Preserved for backward compatibility.
>
>  Wunused
> --- gcc/testsuite/gcc.dg/pr69900.c.jj   2016-02-22 12:29:22.177681519 +0100
> +++ gcc/testsuite/gcc.dg/pr69900.c  2016-02-22 12:29:09.0 +0100
> @@ -0,0 +1,6 @@
> +/* PR c/69900 */
> +/* { dg-do compile } */
> +
> +#pragma GCC diagnostic error "-Wunreachable-code"  /* { dg-bogus "is not 
> an option that controls warnings" } */
> +#pragma GCC diagnostic warning "-Wunreachable-code"/* { dg-bogus "is not 
> an option that controls warnings" } */
> +#pragma GCC diagnostic ignored "-Wunreachable-code"/* { dg-bogus "is not 
> an option that controls warnings" } */
>
> Jakub


Re: [PATCH] Another -Wnonnull-compare false positive fix (PR c++/69902)

2016-02-23 Thread Richard Biener
On Mon, Feb 22, 2016 at 10:30 PM, Jakub Jelinek  wrote:
> Hi!
>
> Here is a fix for another -Wnonnull-compare false positive - the problem
> is that during folding the NE_EXPR of a nonnull_arg_p with NULL (on which
> the C++ FE set TREE_NO_WARNING, because it is an artificial comparison
> for dynamic_cast) is changed by fold-const.c into EQ_EXPR, and the
> TREE_NO_WARNING flag is lost.  Unfortunately it is deep enough in an
> expression passed to fold that cp_fold can't easily tweak that.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok.

Thanks,
Richard.

> 2016-02-22  Jakub Jelinek  
>
> PR c++/69902
> * fold-const.c (fold_truth_not_expr): Propagate TREE_NO_WARNING
> when inverting comparison.
>
> * g++.dg/warn/Wnonnull-compare-5.C: New test.
>
> --- gcc/fold-const.c.jj 2016-02-19 08:55:05.0 +0100
> +++ gcc/fold-const.c2016-02-22 17:46:26.870468937 +0100
> @@ -3589,8 +3589,11 @@ fold_truth_not_expr (location_t loc, tre
>if (code == ERROR_MARK)
> return NULL_TREE;
>
> -  return build2_loc (loc, code, type, TREE_OPERAND (arg, 0),
> -TREE_OPERAND (arg, 1));
> +  tree ret = build2_loc (loc, code, type, TREE_OPERAND (arg, 0),
> +TREE_OPERAND (arg, 1));
> +  if (TREE_NO_WARNING (arg))
> +   TREE_NO_WARNING (ret) = 1;
> +  return ret;
>  }
>
>switch (code)
> --- gcc/testsuite/g++.dg/warn/Wnonnull-compare-5.C.jj   2016-02-22 
> 17:48:16.996963704 +0100
> +++ gcc/testsuite/g++.dg/warn/Wnonnull-compare-5.C  2016-02-22 
> 17:56:58.235839294 +0100
> @@ -0,0 +1,18 @@
> +// PR c++/69902
> +// { dg-do compile }
> +// { dg-options "-Wall" }
> +
> +struct A { virtual ~A (); };
> +struct B : A {};
> +
> +bool
> +foo (A &a)
> +{
> +  return dynamic_cast(&a) == (B *) 0; // { dg-bogus "nonnull 
> argument" }
> +}
> +
> +bool
> +bar (A &a)
> +{
> +  return dynamic_cast(&a) != (B *) 0; // { dg-bogus "nonnull 
> argument" }
> +}
>
> Jakub


Re: Fix/work around PR57676, LRA terminates prematurely

2016-02-23 Thread Richard Biener
On Mon, Feb 22, 2016 at 4:34 PM, Jeff Law  wrote:
> On 02/22/2016 07:34 AM, Richard Biener wrote:
>
>> Hum, but then you get to "inifinite" compiles again when LRA is buggy
>> or the user presents it with an impossible to handle asm.
>
> Neither should be happening in practice, even an impossible asm should cause
> LRA to halt in some way or another.
>
> In practice looping has occurred due to bugs in machine descriptions are are
> typically seen during development/porting.  Hence the desire to put it under
> -fchecking for gcc-6 and possibly implement something smarter for gcc-7
> (where we'd track more precisely whether or not we're making forward
> progress).
>
>>
>> I don't think that's a good idea - maybe bumping the limit is the way to
>> go instead?
>
> No, because one just needs to build a longer chain of insns needing
> reloading.
>
>>
>> 30 constraint passes sounds excessive and a sign of a bug to me anyway.
>
> Not really.  If you look at the testcase and the chain of reloads, it's
> legitimate.  Essentially each pass exposes a case where spill a register in
> an insn that previously had a register allocated.

But requiring another full reload pass to handle such chains is pointing at
a wrong algorithm IMHO.  Isn't this also quadratic in the length of the chain?

Richard.

> Jeff


Re: [PATCH] PR28901 Add two levels for -Wunused-const-variable.

2016-02-23 Thread Mark Wielaard
On Tue, 2016-02-23 at 09:51 +, Manuel López-Ibáñez wrote:
> On 23/02/16 08:56, Jakub Jelinek wrote:
> > On Tue, Feb 23, 2016@09:53:57AM +0100, Mark Wielaard wrote:
> >> --- a/gcc/ChangeLog
> >> +++ b/gcc/ChangeLog
> >> @@ -1,3 +1,10 @@
> >> +2016-02-23  Mark Wielaard  
> >> +  Jakub Jelinek  
> >> +
> >> +  PR c/69911
> >> +  * cgraphunit.c (check_global_declaration): Check main_input_filename
> >> +  and DECL_SOURCE_FILE are not NULL.
> >> +
> >>   2016-02-20  Mark Wielaard  
> >
> > This is ok for trunk if it passes testing.  Thanks.
> >
> >> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> >> index 27a073a..8b3fddc 100644
> >> --- a/gcc/cgraphunit.c
> >> +++ b/gcc/cgraphunit.c
> >> @@ -917,6 +917,7 @@ walk_polymorphic_call_targets (hash_set 
> >> *reachable_call_targets,
> >>   static void
> >>   check_global_declaration (symtab_node *snode)
> >>   {
> >> +  const char *decl_file;
> >> tree decl = snode->decl;
> >>
> >> /* Warn about any function declared static but not defined.  We don't
> >> @@ -944,8 +945,10 @@ check_global_declaration (symtab_node *snode)
> >>  || (((warn_unused_variable && ! TREE_READONLY (decl))
> >>|| (warn_unused_const_variable > 0 && TREE_READONLY (decl)
> >>&& (warn_unused_const_variable == 2
> >> -  || filename_cmp (main_input_filename,
> >> -   DECL_SOURCE_FILE (decl)) == 0)))
> >> +  || (main_input_filename != NULL
> >> +  && (decl_file = DECL_SOURCE_FILE (decl)) != NULL
> >> +  && filename_cmp (main_input_filename,
> >> +   decl_file) == 0
> 
> 
> Can we please please please hide this ugliness behind an (inline?) function 
> such as bool in_main_file_at (location_t) in input.[ch]? The condition here 
> is 
> quickly becoming unreadable.
> 
> Also because in the future somebody would want to re-implement this using 
> MAIN_FILE_P() from line-map.h, which is faster.

Sorry, I pushed the minimum fix. I am too embarrassed already for
breaking stuff to risk refactoring anything and making another dumb
mistake. (My mistake was only checking the top-level compiler .sum
files, I had forgotten to check the library ones).

It might be a good idea to file a bug for this and write a patch to
submit during next stage one if you believe this is a useful cleanup.

Cheers,

Mark


Re: [patch, libgfortran] PR69456 Namelist value with trailing sign is ignored without error

2016-02-23 Thread Dominique d'Humières
Hi Jerry,

The patch works as advertised without regression.

Just one nit, I am puzzled by the comment in the line of 
gfortran.dg/namelist_89.f90

+write(99,*) " c1=(1-,1+1)" ! Treated as 1e-1?!

Should not it be

+write(99,*) "  c1=(1-,1+1)" ! Should give error on item number 5

or something else?

Thanks for working on the issue,

Dominique



[PATCH] Fix DF bitmap memory stat accounting and some minor mem-stat stuff

2016-02-23 Thread Richard Biener

The following fixes

df-problems.c:4405 (df_md_alloc)  
-39759960:4741239668736.0%   -40520627:  0.6%   0   
0  heap
df-problems.c:225 (df_rd_alloc)   
-17948440:4741239668736.0%   -40284572:  0.3%   0   
0  heap

you can sometimes see by properly accounting the "bitmap_move" operation
it does.  The patch below also fixes statistics for free_node to use
tree_size properly (lto also frees STRING_CSTs) - that reduces the
amount if ICEing in the testsuite when mem-stats are enabled but doesn't
completely eliminate them - we've got some global destructors that appear
to run out-of-order and crashing (just use valgrind on a mem-stat
compiler - seems to happen with LTO only).

The patch should also fix stat printing on hosts where long is only
32bits but pointers are larger (windows?).

Bootstrapped on x86_64-unknown-linux-gnu, testing mightly successful.

Will install soon.

Richard.

2016-02-23  Richard Biener  

* mem-stats.h (struct mem_usage): Use PRIu64 for printing size_t.
* bitmap.h (struct bitmap_usage): Likewise.
(bitmap_move): Declare.
* bitmap.c (register_overhead): Take size_t argument.
(bitmap_move): New function.
* df-problems.c (df_rd_transfer_function): Use bitmap_move
to properly account overhead.
* tree.c (free_node): Use tree_size.

Index: gcc/mem-stats.h
===
*** gcc/mem-stats.h (revision 233620)
--- gcc/mem-stats.h (working copy)
*** struct mem_usage
*** 190,199 
{
  char *location_string = loc->to_string ();
  
! fprintf (stderr, "%-48s %10li:%5.1f%%%10li%10li:%5.1f%%%10s\n",
!location_string,
!(long)m_allocated, get_percent (m_allocated, total.m_allocated),
!(long)m_peak, (long)m_times,
 get_percent (m_times, total.m_times), loc->m_ggc ? "ggc" : "heap");
  
  free (location_string);
--- 190,200 
{
  char *location_string = loc->to_string ();
  
! fprintf (stderr, "%-48s %10" PRIu64 ":%5.1f%%"
!"%10" PRIu64 "%10" PRIu64 ":%5.1f%%%10s\n",
!location_string, (uint64_t)m_allocated,
!get_percent (m_allocated, total.m_allocated),
!(uint64_t)m_peak, (uint64_t)m_times,
 get_percent (m_times, total.m_times), loc->m_ggc ? "ggc" : "heap");
  
  free (location_string);
*** struct mem_usage
*** 204,211 
dump_footer () const
{
  print_dash_line ();
! fprintf (stderr, "%s%54li%27li\n", "Total", (long)m_allocated,
!(long)m_times);
  print_dash_line ();
}
  
--- 205,212 
dump_footer () const
{
  print_dash_line ();
! fprintf (stderr, "%s%54" PRIu64 "%27" PRIu64 "\n", "Total",
!(uint64_t)m_allocated, (uint64_t)m_times);
  print_dash_line ();
}
  
Index: gcc/bitmap.h
===
*** gcc/bitmap.h(revision 233620)
--- gcc/bitmap.h(working copy)
*** struct bitmap_usage: public mem_usage
*** 157,168 
{
  char *location_string = loc->to_string ();
  
! fprintf (stderr, "%-48s %10li:%5.1f%%%10li%10li:%5.1f%%%12li%12li%10s\n",
!location_string,
!(long)m_allocated, get_percent (m_allocated, total.m_allocated),
!(long)m_peak, (long)m_times,
 get_percent (m_times, total.m_times),
!(long)m_nsearches, (long)m_search_iter,
 loc->m_ggc ? "ggc" : "heap");
  
  free (location_string);
--- 157,170 
{
  char *location_string = loc->to_string ();
  
! fprintf (stderr, "%-48s %10" PRIu64 ":%5.1f%%"
!"%10" PRIu64 "%10" PRIu64 ":%5.1f%%"
!"%12" PRIu64 "%12" PRIu64 "%10s\n",
!location_string, (uint64_t)m_allocated,
!get_percent (m_allocated, total.m_allocated),
!(uint64_t)m_peak, (uint64_t)m_times,
 get_percent (m_times, total.m_times),
!m_nsearches, m_search_iter,
 loc->m_ggc ? "ggc" : "heap");
  
  free (location_string);
*** extern void bitmap_clear (bitmap);
*** 253,258 
--- 255,263 
  /* Copy a bitmap to another bitmap.  */
  extern void bitmap_copy (bitmap, const_bitmap);
  
+ /* Move a bitmap to another bitmap.  */
+ extern void bitmap_move (bitmap, bitmap);
+ 
  /* True if two bitmaps are identical.  */
  extern bool bitmap_equal_p (const_bitmap, const_bitmap);
  
Index: gcc/bitmap.c
===
*** gcc/bitmap.c(revision 233620)
--- gcc/bitmap.c(working copy)
*** bitmap_register (bitmap b MEM_STAT_DECL)
*** 35,41 
  
  /* Account the overhead.  */
  static void
! register_overhead (bitmap b, int amount)
  {
if (bitmap_mem_desc.contains_descriptor_for_instance 

[testsuite, i386] Require alias support in gcc.target/i386/chkp-hidden-def.c

2016-02-23 Thread Rainer Orth
gcc.target/i386/chkp-hidden-def.c currently FAILs on Solaris/x86.  When
investigating, I found that on Darwin/x86 the test fails in a different
way:

FAIL: gcc.target/i386/chkp-hidden-def.c (test for excess errors)
UNRESOLVED: gcc.target/i386/chkp-hidden-def.c scan-assembler-not test.chkp

Excess errors:
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.target/i386/chkp-hidden-def.c:14:24:
 error: only weak aliases are supported in this configuration

The following patch fixes this.  Tested with the appropriate runtest
invocations on x86_64-apple-darwin11.4.2 and x86_64-pc-linux-gnu,
installed on mainline.  Could be installed on the gcc-5 branch, too,
where the same problem exists, but I don't test that branch on Darwin.

Rainer


2016-02-22  Rainer Orth  

* gcc.target/i386/chkp-hidden-def.c: Require alias support.

# HG changeset patch
# Parent  6d2d660feb49617a55dabb3e1e010638e3500355
Require alias support in gcc.target/i386/chkp-hidden-def.c

diff --git a/gcc/testsuite/gcc.target/i386/chkp-hidden-def.c b/gcc/testsuite/gcc.target/i386/chkp-hidden-def.c
--- a/gcc/testsuite/gcc.target/i386/chkp-hidden-def.c
+++ b/gcc/testsuite/gcc.target/i386/chkp-hidden-def.c
@@ -1,4 +1,5 @@
 /* { dg-do compile { target { ! x32 } } } */
+/* { dg-require-alias "" } */
 /* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */
 /* { dg-final { scan-assembler-not "test.chkp" } } */
 

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


Re: [PATCH, PR middle-end/68134] Reject scalar modes in default get_mask_mode hook

2016-02-23 Thread Alan Lawrence

On 20/02/16 09:29, Ilya Enkovich wrote:

2016-02-19 20:36 GMT+03:00 Alan Lawrence :

Mostly this is fairly straightforward, relatively little midend code is
required, and the backend cleans up quite a bit. However, I get stuck on the
case of singleton vectors (64x1). No surprises there, then...

The PR/68134 fix, makes the 'mask mode' for comparing 64x1 vectors, into
BLKmode, so that we get past this in expand_vector_operations:

/* A scalar operation pretending to be a vector one.  */
   if (VECTOR_BOOLEAN_TYPE_P (type)
   && !VECTOR_MODE_P (TYPE_MODE (type))
   && TYPE_MODE (type) != BLKmode)
 return;

and we do the operation piecewise. (Which is what we want; there is only one
piece!)

However, with my vec_cmp + vcond_mask changes, dropping vconddidi, this
means we look for a vcond_maskdiblk and vec_cmpdiblk. Which doesn't really
feel right - it feels like the 64x1 mask should be a DImode, just like other
64x1 vectors.


The problem here is to distinguish vector mask of one DI element and
DI scalar mask.  We don't want to lower scalar mask manipulations
because they are simple integer operations, not vector ones. Probably
vector of a single DI should have V1DI mode and not pretend to be a
scalar?  This would make things easier.


Thanks for the quick reply, Ilya.

What's the difference between, as you say, a "simple integer operation" and a 
"vector" operation of just one element?


This is why we do *not* have V1DImode in the AArch64 (or ARM) backends, but 
instead treat 64x1 vectors as DImode - the operations are the same; so keeping 
them as the same mode, enables CSE and lots of other optimizations, plus we 
don't have to have two near-identical copies (DI + V1DI) for many patterns, etc...


If the operations were on a "DI scalar mask", when would the first part of that 
test, VECTOR_BOOLEAN_TYPE_P, hold?


Thanks, Alan



Re: [PATCH 5/9] S/390: Get rid of Y constraint in arithmetic right shift patterns.

2016-02-23 Thread Andreas Krebbel
On 02/01/2016 02:35 PM, Ulrich Weigand wrote:
> Andreas Krebbel wrote:
> 
>> +; This is like the addr_style_op substitution above but with a CC clobber.
>> +(define_subst "addr_style_op_cc_subst"
> 
>> +; This is like the masked_op substitution but with a CC clobber.
>> +(define_subst "masked_op_cc_subst"
> 
> A bit unfortunate that these need to be duplicated.  Does the subst always
> have to match the full pattern, or can it match and operate on just one
> element of a PARALLEL?

Yes. The match is always on the full pattern.

-Andreas-




Re: [PATCH 6/9] S/390: Get rid of Y constraint in tabort.

2016-02-23 Thread Andreas Krebbel
On 02/01/2016 02:36 PM, Ulrich Weigand wrote:
> Andreas Krebbel wrote:
> 
>>  (define_insn "*tabort_1"
>> -  [(unspec_volatile [(match_operand:SI 0 "shift_count_or_setmem_operand" 
>> "Y")]
>> +  [(unspec_volatile [(match_operand:SI 0 "addrreg_or_constint_operand" 
>> "a,n")]
>>  UNSPECV_TABORT)]
>>"TARGET_HTM && operands != NULL"
>> -  "tabort\t%Y0"
>> +  "@
>> +   tabort\t0(%0)
>> +   tabort\t%0"
>> +  [(set_attr "op_type" "S")])
>> +
>> +(define_insn "*tabort_1_plus"
>> +  [(unspec_volatile [(plus:SI (match_operand:SI 0 "register_operand"  "a")
>> +  (match_operand:SI 1 "const_int_operand" "J"))]
>> +UNSPECV_TABORT)]
>> +  "TARGET_HTM && operands != NULL"
>> +  "tabort\t%1(%0)"
> 
> This seems dangerous: const_int_operand may match a constant that does
> not fit into the "J" constraint, which would lead to an abort in reload.

Right. The insn condition should make sure it fits already when matching the 
insn.

> What is the semantics for the abort code anyway?  It is supposed to be
> automatically truncated or not?

Not to my knowledge.  There seem to be a full 64 bit slot in the transaction 
diagnostic buffer where
this value will be copied to.

-Andreas-



[PATCH] Reduce pool allocator overhead for !CHECKING_P

2016-02-23 Thread Richard Biener

The following patch reverts an earlier decision of me to make the id
member unconditional.  On PR26854 we can see

df_chain_block pool df-problems.c:2398 (df_chain_alloc) 

152 0:  0.0% 937593072  61860737: 90.1%  24

thus a peak of 900MB used for df chains (16 bytes each but with overhead
24 bytes).  With the patch (and release checking) that's down to

df_chain_block pool alloc-pool.h:478 (df_chain_alloc)   

146 0:  0.0% 625062048  61860715: 90.1%  16

which is a good savings.

In the future somebody might make that checking code more intelligently
(using some compile-time walking the allocated blocks and doing some
range checking on the object pointers instead).

Build with and without checking, going to commit if a release checking
build reaches stage3 (I missed no -Werror).

Richard.

2016-02-23  Richard Biener  

* alloc-pool.h (struct allocation_object): Make id member
conditional on CHECKING_P again.
(get_instance): Adjust.
(base_pool_allocator): Likewise.

Index: gcc/alloc-pool.h
===
*** gcc/alloc-pool.h(revision 233633)
--- gcc/alloc-pool.h(working copy)
*** private:
*** 156,163 
--- 156,165 
  
struct allocation_object
{
+ #if CHECKING_P
  /* The ID of alloc pool which the object was allocated from.  */
  ALLOC_POOL_ID_TYPE id;
+ #endif
  
  union
{
*** private:
*** 172,177 
--- 174,180 
int64_t align_i;
} u;
  
+ #if CHECKING_P
  static inline allocation_object*
  get_instance (void *data_ptr)
  {
*** private:
*** 179,184 
--- 182,188 
  - offsetof (allocation_object,
  u.data));
  }
+ #endif
  
  static inline void*
  get_data (void *instance_ptr)
*** base_pool_allocator ::a
*** 388,394 
--- 392,400 
header->next = NULL;
  
/* Mark the element to be free.  */
+ #if CHECKING_P
((allocation_object*) block)->id = 0;
+ #endif
VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (header,size));
m_returned_free_list = header;
m_virgin_free_list += m_elt_size;
*** base_pool_allocator ::a
*** 403,409 
--- 409,417 
m_elts_free--;
  
/* Set the ID for element.  */
+ #if CHECKING_P
allocation_object::get_instance (header)->id = m_id;
+ #endif
VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (header, size));
  
return (void *)(header);
*** base_pool_allocator ::r
*** 420,435 
  {
gcc_assert (m_initialized);
gcc_assert (object
! /* Check if we free more than we allocated, which is Bad (TM).  */
! && m_elts_free < m_elts_allocated
! /* Check whether the PTR was allocated from POOL.  */
! && m_id == allocation_object::get_instance (object)->id);
  
memset (object, 0xaf, size);
  }
  
/* Mark the element to be free.  */
allocation_object::get_instance (object)->id = 0;
  
allocation_pool_list *header = new (object) allocation_pool_list;
header->next = m_returned_free_list;
--- 428,447 
  {
gcc_assert (m_initialized);
gcc_assert (object
! /* Check if we free more than we allocated.  */
! && m_elts_free < m_elts_allocated);
! #if CHECKING_P
!   /* Check whether the PTR was allocated from POOL.  */
!   gcc_assert (m_id == allocation_object::get_instance (object)->id);
! #endif
  
memset (object, 0xaf, size);
  }
  
+ #if CHECKING_P 
/* Mark the element to be free.  */
allocation_object::get_instance (object)->id = 0;
+ #endif
  
allocation_pool_list *header = new (object) allocation_pool_list;
header->next = m_returned_free_list;


[PATCH 2/9] S/390: Use enabled attribute overrides to disable alternatives.

2016-02-23 Thread Andreas Krebbel
So far whenever we wanted to disable an alternative we have used mode
attributes emitting constraints matching an earlier alternative
assuming that due to this the later alternative will never be chosen.

With this patch the `enabled' attribute, which so far is only set from
`cpu_facility', is overridden to 0 to disable certain alternatives.
This comes handy when defining the substitutions later and while
adding it anyway I've used it for the existing cases as well.

gcc/ChangeLog:

* config/s390/s390.md ("op_type", "atype", "length" attributes):
Remove RRR type.  It doesn't really exist.
("RRer", "f0", "v0", "vf", "vd", "op1", "Rf"): Remove mode
attributes.
("BFP", "DFP", "nDSF", "nDFDI"): Add mode attributes.
("*cmp_ccs", "floatdi2", "add3")
("*add3_cc", "*add3_cconly", "sub3")
("*sub3_cc", "*sub3_cconly", "mul3")
("fma4", "fms4", "div3", "*neg2")
("*abs2", "*negabs2", "sqrt2"): Override
`enabled' attribute.
---
 gcc/config/s390/s390.md | 215 +---
 1 file changed, 111 insertions(+), 104 deletions(-)

diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 2c90eae..b878ec2 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -366,7 +366,7 @@
 ;; Used to determine defaults for length and other attribute values.
 
 (define_attr "op_type"
-  
"NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,RRR,SIL,RRS,RIS,VRI,VRR,VRS,VRV,VRX"
+  
"NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,SIL,RRS,RIS,VRI,VRR,VRS,VRV,VRX"
   (const_string "NN"))
 
 ;; Instruction type attribute used for scheduling.
@@ -393,7 +393,7 @@
 ;;   reg: Instruction does not use the agen unit
 
 (define_attr "atype" "agen,reg"
-  (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF,RRR")
+  (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF")
(const_string "reg")
(const_string "agen")))
 
@@ -434,8 +434,8 @@
 ;; Length in bytes.
 
 (define_attr "length" ""
-  (cond [(eq_attr "op_type" "E,RR")  (const_int 2)
- (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF,RRR")  (const_int 4)]
+  (cond [(eq_attr "op_type" "E,RR")  (const_int 2)
+ (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF")  (const_int 4)]
 (const_int 6)))
 
 
@@ -618,27 +618,14 @@
 ;; fp register operands.  The following attributes allow to merge the bfp and
 ;; dfp variants in a single insn definition.
 
-;; This attribute is used to set op_type accordingly.
-(define_mode_attr RRer [(TF "RRE") (DF "RRE") (SF "RRE") (TD "RRR")
-(DD "RRR") (SD "RRR")])
-
-;; This attribute is used in the operand constraint list in order to have the
-;; first and the second operand match for bfp modes.
-(define_mode_attr f0 [(TF "0") (DF "0") (SF "0") (TD "f") (DD "f") (DD "f")])
-
-;; This attribute is used to merge the scalar vector instructions into
-;; the FP patterns.  For non-supported modes (all but DF) it expands
-;; to constraints which are supposed to be matched by an earlier
-;; variant.
-(define_mode_attr v0  [(TF "0") (DF "v") (SF "0") (TD "0") (DD "0") (DD 
"0") (TI "0") (DI "v") (SI "0")])
-(define_mode_attr vf  [(TF "f") (DF "v") (SF "f") (TD "f") (DD "f") (DD 
"f") (TI "f") (DI "v") (SI "f")])
-(define_mode_attr vd  [(TF "d") (DF "v") (SF "d") (TD "d") (DD "d") (DD 
"d") (TI "d") (DI "v") (SI "d")])
-
-;; This attribute is used in the operand list of the instruction to have an
-;; additional operand for the dfp instructions.
-(define_mode_attr op1 [(TF "") (DF "") (SF "")
-   (TD "%1,") (DD "%1,") (SD "%1,")])
-
+;; These mode attributes are supposed to be used in the `enabled' insn
+;; attribute to disable certain alternatives for certain modes.
+(define_mode_attr nBFP [(TF "0") (DF "0") (SF "0") (TD "*") (DD "*") (DD "*")])
+(define_mode_attr nDFP [(TF "*") (DF "*") (SF "*") (TD "0") (DD "0") (DD "0")])
+(define_mode_attr DSF [(TF "0") (DF "*") (SF "*") (TD "0") (DD "0") (SD "0")])
+(define_mode_attr DFDI [(TF "0") (DF "*") (SF "0")
+   (TD "0") (DD "0") (DD "0")
+   (TI "0") (DI "*") (SI "0")])
 
 ;; This attribute is used in the operand constraint list
 ;; for instructions dealing with the sign bit of 32 or 64bit fp values.
@@ -648,10 +635,6 @@
 ;; target operand uses the same fp register.
 (define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
 
-;; In FP templates, "" will expand to "f" in TFmode and "R" otherwise.
-;; This is used to disable the memory alternative in TFmode patterns.
-(define_mode_attr Rf [(TF "f") (DF "R") (SF "R") (TD "f") (DD "f") (SD "f")])
-
 ;; This attribute adds b for bfp instructions and t for dfp instructions and 
is used
 ;; within instruction mnemonics.
 (define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
@@ -1260,13 +1243,14 @

[PATCH 6/9] S/390: Get rid of Y constraint in tabort.

2016-02-23 Thread Andreas Krebbel
This removes the Y constraint from the tabort pattern definition.  In
this case it is easier without using substitutions.

gcc/ChangeLog:

* config/s390/s390.md ("*tabort_1"): Change predicate to
nonmemory_operand.  Add a second alternative to cover
register as well as const int operands.
("*tabort_1_plus"): New pattern definition.
---
 gcc/config/s390/s390.md | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index a058f58..3ce687c 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -10697,7 +10697,7 @@
 ; Transaction abort
 
 (define_expand "tabort"
-  [(unspec_volatile [(match_operand:SI 0 "shift_count_or_setmem_operand" "")]
+  [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "")]
UNSPECV_TABORT)]
   "TARGET_HTM && operands != NULL"
 {
@@ -10712,10 +10712,21 @@
 })
 
 (define_insn "*tabort_1"
-  [(unspec_volatile [(match_operand:SI 0 "shift_count_or_setmem_operand" "Y")]
+  [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "a,J")]
UNSPECV_TABORT)]
   "TARGET_HTM && operands != NULL"
-  "tabort\t%Y0"
+  "@
+   tabort\t0(%0)
+   tabort\t%0"
+  [(set_attr "op_type" "S")])
+
+(define_insn "*tabort_1_plus"
+  [(unspec_volatile [(plus:SI (match_operand:SI 0 "register_operand"  "a")
+ (match_operand:SI 1 "const_int_operand" "J"))]
+   UNSPECV_TABORT)]
+  "TARGET_HTM && operands != NULL
+   && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'J', \"J\")"
+  "tabort\t%1(%0)"
   [(set_attr "op_type" "S")])
 
 ; Transaction extract nesting depth
-- 
1.9.1



[PATCH 1/9] gensupport: Fix define_subst operand renumbering.

2016-02-23 Thread Andreas Krebbel
When processing substitutions the operands are renumbered.  To find a
free operand number the array used_operands_numbers is used.
Currently this array is used to assign new numbers before all the
RTXes in the vector have been processed.  I did run into problems with
this for insns where a match_dup occurred in a later (use ...) operand
referring to an earlier operand (e.g. s390.md "setmem_long").

The patch splits the loop doing the processing into two in order to
have all the operand numbers collected already when assigning new
numbers.

Bootstrapped and regtested on s390, s390x, and x86_64.

Ok for mainline?

Bye,

-Andreas-

gcc/ChangeLog:

* gensupport.c (process_substs_on_one_elem): Split loop to
complete mark_operands_used_in_match_dup on all expressions in the
vector first.
(adjust_operands_numbers): Inline into process_substs_on_one_elem
and remove function.
---
 gcc/gensupport.c | 45 -
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/gcc/gensupport.c b/gcc/gensupport.c
index 8c5a1ab..de29579 100644
--- a/gcc/gensupport.c
+++ b/gcc/gensupport.c
@@ -126,7 +126,10 @@ static const char * duplicate_each_alternative (const char 
* str, int n_dup);
 
 typedef const char * (*constraints_handler_t) (const char *, int);
 static rtx alter_constraints (rtx, int, constraints_handler_t);
-static rtx adjust_operands_numbers (rtx);
+
+static void mark_operands_used_in_match_dup (rtx);
+static void renumerate_operands_in_pattern (rtx);
+
 static rtx replace_duplicating_operands_in_pattern (rtx);
 
 /* Make a version of gen_rtx_CONST_INT so that GEN_INT can be used in
@@ -1844,7 +1847,18 @@ process_substs_on_one_elem (struct queue_elem *elem,
  subst_pattern = alter_constraints (subst_pattern, alternatives,
 duplicate_each_alternative);
 
- subst_pattern = adjust_operands_numbers (subst_pattern);
+ mark_operands_used_in_match_dup (subst_pattern);
+ RTVEC_ELT (subst_pattern_vec, j) = subst_pattern;
+   }
+
+  for (j = 0; j < XVECLEN (subst_elem->data, 3); j++)
+   {
+ subst_pattern = RTVEC_ELT (subst_pattern_vec, j);
+
+ /* The number of MATCH_OPERANDs in the output pattern might
+change.  This routine assigns new numbers to the
+MATCH_OPERAND expressions to avoid collisions.  */
+ renumerate_operands_in_pattern (subst_pattern);
 
  /* Substitute match_dup and match_op_dup in the new pattern and
 duplicate constraints.  */
@@ -1857,7 +1871,6 @@ process_substs_on_one_elem (struct queue_elem *elem,
  if (GET_CODE (elem->data) == DEFINE_EXPAND)
remove_constraints (subst_pattern);
 
- RTVEC_ELT (subst_pattern_vec, j) = subst_pattern;
}
   XVEC (elem->data, 1) = subst_pattern_vec;
 
@@ -1927,7 +1940,7 @@ mark_operands_from_match_dup (rtx pattern)
 }
 }
 
-/* This is a subroutine of adjust_operands_numbers.
+/* This is a subroutine of process_substs_on_one_elem.
It goes through all expressions in PATTERN and when MATCH_DUP is
met, all MATCH_OPERANDs inside it is marked as occupied.  The
process of marking is done by routin mark_operands_from_match_dup.  */
@@ -1973,10 +1986,9 @@ find_first_unused_number_of_operand ()
   return MAX_OPERANDS;
 }
 
-/* This is subroutine of adjust_operands_numbers.
-   It visits all expressions in PATTERN and assigns not-occupied
-   operand indexes to MATCH_OPERANDs and MATCH_OPERATORs of this
-   PATTERN.  */
+/* This is a subroutine of process_substs_on_one_elem.  It visits all
+   expressions in PATTERN and assigns not-occupied operand indexes to
+   MATCH_OPERANDs and MATCH_OPERATORs of this PATTERN.  */
 static void
 renumerate_operands_in_pattern (rtx pattern)
 {
@@ -2011,23 +2023,6 @@ renumerate_operands_in_pattern (rtx pattern)
 }
 }
 
-/* If output pattern of define_subst contains MATCH_DUP, then this
-   expression would be replaced with the pattern, matched with
-   MATCH_OPERAND from input pattern.  This pattern could contain any
-   number of MATCH_OPERANDs, MATCH_OPERATORs etc., so it's possible
-   that a MATCH_OPERAND from output_pattern (if any) would have the
-   same number, as MATCH_OPERAND from copied pattern.  To avoid such
-   indexes overlapping, we assign new indexes to MATCH_OPERANDs,
-   laying in the output pattern outside of MATCH_DUPs.  */
-static rtx
-adjust_operands_numbers (rtx pattern)
-{
-  mark_operands_used_in_match_dup (pattern);
-
-  renumerate_operands_in_pattern (pattern);
-
-  return pattern;
-}
 
 /* Generate RTL expression
(match_dup OPNO)
-- 
1.9.1



[PATCH 0/9] S/390 rework shift count handling - v2

2016-02-23 Thread Andreas Krebbel
This is an updated version of the shift count rework in the S/390
backend.  I think I've addressed most of the feedback from Ulrich and
Bernd (gensupport patch).

https://gcc.gnu.org/ml/gcc-patches/2016-01/msg00940.html

Andreas Krebbel (9):
  gensupport: Fix define_subst operand renumbering.
  S/390: Use enabled attribute overrides to disable alternatives.
  S/390: Get rid of Y constraint in rotate patterns.
  S/390: Get rid of Y constraint in left and logical right shift
patterns.
  S/390: Get rid of Y constraint in arithmetic right shift patterns.
  S/390: Get rid of Y constraint in tabort.
  S/390: Get rid of Y constraint in vector.md.
  S/390: Use define_subst for the setmem patterns.
  S/390: Disallow SImode in s390_decompose_address

 gcc/config/s390/predicates.md |  10 +
 gcc/config/s390/s390.c|  31 ++-
 gcc/config/s390/s390.md   | 553 +++---
 gcc/config/s390/subst.md  | 154 
 gcc/config/s390/vector.md | 138 ++-
 gcc/gensupport.c  |  45 ++--
 6 files changed, 478 insertions(+), 453 deletions(-)
 create mode 100644 gcc/config/s390/subst.md

-- 
1.9.1



[PATCH 8/9] S/390: Use define_subst for the setmem patterns.

2016-02-23 Thread Andreas Krebbel
While trying to get rid of the Y constraint in the setmem patterns I
noticed that for these patterns it isn't even a problem since these
always only use the constraint with a Pmode match_operand.  But while
being at it I've tried to fold some of the patterns a bit.

gcc/ChangeLog:

* config/s390/predicates.md ("const_int_8bitset_operand"): New 
predicate.
* config/s390/s390.md ("*setmem_long", "*setmem_long_and"): Merge
into ...
("*setmem_long"): New pattern.
("*setmem_long_31z", "*setmem_long_and_31z"): Merge
into ...
("*setmem_long_31z"): New pattern.
* config/s390/subst.md ("setmem_31z_subst", "setmem_and_subst"):
New substitution rules with the required attributes.
---
 gcc/config/s390/predicates.md |  6 ++
 gcc/config/s390/s390.md   | 35 ++-
 gcc/config/s390/subst.md  | 25 +
 3 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/gcc/config/s390/predicates.md b/gcc/config/s390/predicates.md
index 9e91b5c..9585b1f 100644
--- a/gcc/config/s390/predicates.md
+++ b/gcc/config/s390/predicates.md
@@ -119,6 +119,12 @@
 (define_predicate "const_int_6bitset_operand"
  (and (match_code "const_int")
   (match_test "(INTVAL (op) & 63) == 63")))
+
+; An integer operand with the lowest order 8 bit all ones.
+(define_predicate "const_int_8bitset_operand"
+ (and (match_code "const_int")
+  (match_test "(INTVAL (op) & 255) == 255")))
+
 (define_predicate "nonzero_shift_count_operand"
   (and (match_code "const_int")
(match_test "IN_RANGE (INTVAL (op), 1, GET_MODE_BITSIZE (mode) - 1)")))
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 3ce687c..49784b3 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -3323,7 +3323,7 @@
 
 ; Patterns for 31 bit + Esa and 64 bit + Zarch.
 
-(define_insn "*setmem_long"
+(define_insn "*setmem_long"
   [(clobber (match_operand: 0 "register_operand" "=d"))
(set (mem:BLK (subreg:P (match_operand: 3 "register_operand" "0") 0))
 (unspec:BLK [(match_operand:P 2 "shift_count_or_setmem_operand" "Y")
@@ -3336,26 +3336,10 @@
   [(set_attr "length" "8")
(set_attr "type" "vs")])
 
-(define_insn "*setmem_long_and"
-  [(clobber (match_operand: 0 "register_operand" "=d"))
-   (set (mem:BLK (subreg:P (match_operand: 3 "register_operand" "0") 0))
-(unspec:BLK [(and:P
- (match_operand:P 2 "shift_count_or_setmem_operand" "Y")
- (match_operand:P 4 "const_int_operand" "n"))
-   (subreg:P (match_dup 3) )]
-   UNSPEC_REPLICATE_BYTE))
-   (use (match_operand: 1 "register_operand" "d"))
-   (clobber (reg:CC CC_REGNUM))]
-  "(TARGET_64BIT || !TARGET_ZARCH) &&
-   (INTVAL (operands[4]) & 255) == 255"
-  "mvcle\t%0,%1,%Y2\;jo\t.-4"
-  [(set_attr "length" "8")
-   (set_attr "type" "vs")])
-
 ; Variants for 31 bit + Zarch, necessary because of the odd in-register offsets
 ; of the SImode subregs.
 
-(define_insn "*setmem_long_31z"
+(define_insn "*setmem_long_31z"
   [(clobber (match_operand:TI 0 "register_operand" "=d"))
(set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
 (unspec:BLK [(match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
@@ -3367,21 +3351,6 @@
   [(set_attr "length" "8")
(set_attr "type" "vs")])
 
-(define_insn "*setmem_long_and_31z"
-  [(clobber (match_operand:TI 0 "register_operand" "=d"))
-   (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
-(unspec:BLK [(and:SI
- (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
- (match_operand:SI 4 "const_int_operand" "n"))
-   (subreg:SI (match_dup 3) 12)] UNSPEC_REPLICATE_BYTE))
-   (use (match_operand:TI 1 "register_operand" "d"))
-   (clobber (reg:CC CC_REGNUM))]
-  "(!TARGET_64BIT && TARGET_ZARCH) &&
-   (INTVAL (operands[4]) & 255) == 255"
-  "mvcle\t%0,%1,%Y2\;jo\t.-4"
-  [(set_attr "length" "8")
-   (set_attr "type" "vs")])
-
 ;
 ; cmpmemM instruction pattern(s).
 ;
diff --git a/gcc/config/s390/subst.md b/gcc/config/s390/subst.md
index 08704c2..f03e678 100644
--- a/gcc/config/s390/subst.md
+++ b/gcc/config/s390/subst.md
@@ -127,3 +127,28 @@
(clobber (match_scratch:DSI 0 "=d,d,d,d"))])
 
 (define_subst_attr "cconly" "cconly_subst" "" "_cconly")
+
+
+;; setmem substitution patterns
+
+; Add an AND operation on the padding byte operand.  Only the lowest 8
+; bit are used and the rest is ignored.
+(define_subst "setmem_and_subst"
+  [(clobber (match_operand:TDI  0 "register_operand" ""))
+   (set (mem:BLK (subreg:DSI (match_operand:TDI 1 "register_operand" "") 0))
+(unspec:BLK [(match_operand:DSI 2 
"shift_count_or_setmem_operand" "")
+(match_operand:DSI 3 "register_operand" "")]
+UNSPEC_REPLICATE_BYTE))
+   (use (match_op

[PATCH 4/9] S/390: Get rid of Y constraint in left and logical right shift patterns.

2016-02-23 Thread Andreas Krebbel
With this patch the substitution patterns added earlier are used for
the logical right shift and all the left shift patterns.

* config/s390/s390.md ("3"): Change predicate of
op2 to nonmemory_operand.
("*di3_31", "*di3_31_and"):
Merge into single pattern definition ...
("*di3_31"): New pattern.
("*3", "*3_and"): Merge into single
pattern definition ...
("*3"): New pattern.
---
 gcc/config/s390/s390.md | 63 ++---
 1 file changed, 23 insertions(+), 40 deletions(-)

diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 9703a30..b4983cd 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -8395,60 +8395,43 @@
 (define_expand "3"
   [(set (match_operand:DSI 0 "register_operand" "")
 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
-   (match_operand:SI 2 "shift_count_or_setmem_operand" "")))]
+   (match_operand:SI 2 "nonmemory_operand" "")))]
   ""
   "")
 
+; ESA 64 bit register pair shift with reg or imm shift count
 ; sldl, srdl
-(define_insn "*di3_31"
-  [(set (match_operand:DI 0 "register_operand" "=d")
-(SHIFT:DI (match_operand:DI 1 "register_operand" "0")
-  (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
+(define_insn "*di3_31"
+  [(set (match_operand:DI 0 "register_operand"   "=d,d")
+(SHIFT:DI (match_operand:DI 1 "register_operand"  "0,0")
+  (match_operand:SI 2 "nonmemory_operand" "a,n")))]
   "!TARGET_ZARCH"
-  "sdl\t%0,%Y2"
+  "@
+   sdl\t%0,(%2)
+   sdl\t%0,%Y2"
   [(set_attr "op_type"  "RS")
(set_attr "atype""reg")
+   (set_attr "enabled"  "*,")
(set_attr "z196prop" "z196_cracked")])
 
-; sll, srl, sllg, srlg, sllk, srlk
-(define_insn "*3"
-  [(set (match_operand:GPR 0 "register_operand"  
"=d,d")
-(SHIFT:GPR (match_operand:GPR 1 "register_operand" 
",d")
-   (match_operand:SI 2 "shift_count_or_setmem_operand"
"Y,Y")))]
-  ""
-  "@
-   sl\t%0,<1>%Y2
-   sl\t%0,%1,%Y2"
-  [(set_attr "op_type"  "RS,RSY")
-   (set_attr "atype""reg,reg")
-   (set_attr "cpu_facility" "*,z196")
-   (set_attr "z10prop" "z10_super_E1,*")])
-
-; sldl, srdl
-(define_insn "*di3_31_and"
-  [(set (match_operand:DI 0 "register_operand" "=d")
-(SHIFT:DI (match_operand:DI 1 "register_operand" "0")
-  (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" 
"Y")
- (match_operand:SI 3 "const_int_operand"   "n"]
-  "!TARGET_ZARCH && (INTVAL (operands[3]) & 63) == 63"
-  "sdl\t%0,%Y2"
-  [(set_attr "op_type"  "RS")
-   (set_attr "atype""reg")])
 
+; 64 bit register shift with reg or imm shift count
 ; sll, srl, sllg, srlg, sllk, srlk
-(define_insn "*3_and"
-  [(set (match_operand:GPR 0 "register_operand"
 "=d,d")
-(SHIFT:GPR (match_operand:GPR 1 "register_operand"
",d")
-   (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" 
  "Y,Y")
-  (match_operand:SI 3 "const_int_operand"  
 "n,n"]
-  "(INTVAL (operands[3]) & 63) == 63"
+(define_insn "*3"
+  [(set (match_operand:GPR 0 "register_operand"  "=d,   d,d,d")
+(SHIFT:GPR (match_operand:GPR 1 "register_operand" ",,d,d")
+   (match_operand:SI 2 "nonmemory_operand""a,   n,a,n")))]
+  ""
   "@
+   sl\t%0,<1>(%2)
sl\t%0,<1>%Y2
+   sl\t%0,%1,(%2)
sl\t%0,%1,%Y2"
-  [(set_attr "op_type"  "RS,RSY")
-   (set_attr "atype""reg,reg")
-   (set_attr "cpu_facility" "*,z196")
-   (set_attr "z10prop" "z10_super_E1,*")])
+  [(set_attr "op_type"  "RS,RS,RSY,RSY")
+   (set_attr "atype""reg,reg,reg,reg")
+   (set_attr "cpu_facility" "*,*,z196,z196")
+   (set_attr "enabled"  "*,,*,")
+   (set_attr "z10prop"  "z10_super_E1,z10_super_E1,*,*")])
 
 ;
 ; ashr(di|si)3 instruction pattern(s).
-- 
1.9.1



[PATCH 5/9] S/390: Get rid of Y constraint in arithmetic right shift patterns.

2016-02-23 Thread Andreas Krebbel
The arithmetic shift patterns set also the condition code.  This adds
more substitution potential.  Depending on whether the actual result
or the CC output will be used 3 different variants of each of these
patterns are needed.  This multiplied with the PLUS and the AND
operands from the earlier substitutions enables a lot of folding.

* config/s390/s390.md ("*ashrdi3_cc_31")
("*ashrdi3_cconly_31""*ashrdi3_cc_31_and")
("*ashrdi3_cconly_31_and", "*ashrdi3_31_and", "*ashrdi3_31"):
Merge insn definitions into ...
("*ashrdi3_31"):
New pattern definition.
("*ashr3_cc", "*ashr3_cconly", "ashr3", )
("*ashr3_cc_and", "*ashr3_cconly_and")
("*ashr3_and"): Merge insn definitions into ...
("*ashr3"):
New pattern definition.
* config/s390/subst.md ("addr_style_op_cc_subst")
("masked_op_cc_subst", "setcc_subst", "cconly_subst"): New
substitutions patterns plus attributes.
---
 gcc/config/s390/s390.md  | 189 +++
 gcc/config/s390/subst.md |  61 +++
 2 files changed, 88 insertions(+), 162 deletions(-)

diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index b4983cd..a058f58 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -8441,183 +8441,48 @@
   [(parallel
 [(set (match_operand:DSI 0 "register_operand" "")
   (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
-(match_operand:SI 2 "shift_count_or_setmem_operand" 
"")))
+(match_operand:SI 2 "nonmemory_operand" "")))
  (clobber (reg:CC CC_REGNUM))])]
   ""
   "")
 
-(define_insn "*ashrdi3_cc_31"
-  [(set (reg CC_REGNUM)
-(compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
-  (match_operand:SI 2 
"shift_count_or_setmem_operand" "Y"))
- (const_int 0)))
-   (set (match_operand:DI 0 "register_operand" "=d")
-(ashiftrt:DI (match_dup 1) (match_dup 2)))]
-  "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)"
-  "srda\t%0,%Y2"
-  [(set_attr "op_type"  "RS")
-   (set_attr "atype""reg")])
-
-(define_insn "*ashrdi3_cconly_31"
-  [(set (reg CC_REGNUM)
-(compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
-  (match_operand:SI 2 
"shift_count_or_setmem_operand" "Y"))
- (const_int 0)))
-   (clobber (match_scratch:DI 0 "=d"))]
-  "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)"
-  "srda\t%0,%Y2"
-  [(set_attr "op_type"  "RS")
-   (set_attr "atype""reg")])
-
-(define_insn "*ashrdi3_31"
-  [(set (match_operand:DI 0 "register_operand" "=d")
-(ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
- (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
+; FIXME: The number of alternatives is doubled here to match the fix
+; number of 4 in the subst pattern for the (clobber (match_scratch...
+; The right fix should be to support match_scratch in the output
+; pattern of a define_subst.
+(define_insn "*ashrdi3_31"
+  [(set (match_operand:DI 0 "register_operand"  "=d,d,d,d")
+(ashiftrt:DI (match_operand:DI 1 "register_operand"  "0,0,0,0")
+ (match_operand:SI 2 "nonmemory_operand" "a,n,a,n")))
(clobber (reg:CC CC_REGNUM))]
   "!TARGET_ZARCH"
-  "srda\t%0,%Y2"
-  [(set_attr "op_type"  "RS")
-   (set_attr "atype""reg")])
-
-; sra, srag, srak
-(define_insn "*ashr3_cc"
-  [(set (reg CC_REGNUM)
-(compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" 
 ",d")
-   (match_operand:SI 2 
"shift_count_or_setmem_operand" "Y,Y"))
- (const_int 0)))
-   (set (match_operand:GPR 0 "register_operand"
   "=d,d")
-(ashiftrt:GPR (match_dup 1) (match_dup 2)))]
-  "s390_match_ccmode(insn, CCSmode)"
   "@
-   sra\t%0,<1>%Y2
-   sra\t%0,%1,%Y2"
-  [(set_attr "op_type"  "RS,RSY")
-   (set_attr "atype""reg,reg")
-   (set_attr "cpu_facility" "*,z196")
-   (set_attr "z10prop" "z10_super_E1,*")])
+   srda\t%0,(%2)
+   srda\t%0,%Y2
+   srda\t%0,(%2)
+   srda\t%0,%Y2"
+  [(set_attr "op_type" "RS")
+   (set_attr "enabled" 
"*,,*,")
+   (set_attr "atype"   "reg")])
 
-; sra, srag, srak
-(define_insn "*ashr3_cconly"
-  [(set (reg CC_REGNUM)
-(compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" 
 ",d")
-   (match_operand:SI 2 
"shift_count_or_setmem_operand" "Y,Y"))
- (const_int 0)))
-   (clobber (match_scratch:GPR 0   
   "=d,d"))]
-  "s390_match_ccmode(insn, CCSmode)"
-  "@
-   sra\t%0,<1>%Y2
-   sra\t%0,%1,%Y2"
-  [(set_attr "op_type"  "RS,RSY")
-   (set_attr "atype""reg,reg")
-   (set_attr "cpu_facility" "*,z196")
-   (set_attr "z10prop" "z10_super_E1,*")])
 
 ; sra, srag
-(define_insn "*ashr3"
-  [(set (match

[PATCH 9/9] S/390: Disallow SImode in s390_decompose_address

2016-02-23 Thread Andreas Krebbel
After Y is never used anymore with SImode operands we can finally
disallow SImode (if != Pmode) in s390_decompose_address.  In fact that
was the whole point of the patch series.

gcc/ChangeLog:

* config/s390/s390.c (s390_decompose_address): Don't accept SImode
anymore.
---
 gcc/config/s390/s390.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 43219dd..8924367 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -2817,9 +2817,7 @@ s390_decompose_address (rtx addr, struct s390_address 
*out)
return false;
  }
 
-  if (!REG_P (base)
- || (GET_MODE (base) != SImode
- && GET_MODE (base) != Pmode))
+  if (!REG_P (base) || GET_MODE (base) != Pmode)
return false;
 
   if (REGNO (base) == STACK_POINTER_REGNUM
@@ -2865,9 +2863,7 @@ s390_decompose_address (rtx addr, struct s390_address 
*out)
return false;
  }
 
-  if (!REG_P (indx)
- || (GET_MODE (indx) != SImode
- && GET_MODE (indx) != Pmode))
+  if (!REG_P (indx) || GET_MODE (indx) != Pmode)
return false;
 
   if (REGNO (indx) == STACK_POINTER_REGNUM
-- 
1.9.1



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

2016-02-23 Thread Andreas Krebbel
This patch introduces substitution patterns to add PLUS const_int, and
AND operands to patterns and uses this to rewrite the existing rotate
pattern.

gcc/ChangeLog:

* config/s390/predicates.md (const_int_6bitset_operand): New
predicates.
* config/s390/s390.md: Include subst.md.
("rotl3"): New expander.
("rotl3", "*rotl3_and"): Merge insn definitions into
...
("*rotl3"): New insn definition.
* config/s390/subst.md: New file.
---
 gcc/config/s390/predicates.md |  4 +++
 gcc/config/s390/s390.c| 23 +++
 gcc/config/s390/s390.md   | 34 +++---
 gcc/config/s390/subst.md  | 67 +++
 4 files changed, 105 insertions(+), 23 deletions(-)
 create mode 100644 gcc/config/s390/subst.md

diff --git a/gcc/config/s390/predicates.md b/gcc/config/s390/predicates.md
index cbc8092..9e91b5c 100644
--- a/gcc/config/s390/predicates.md
+++ b/gcc/config/s390/predicates.md
@@ -115,6 +115,10 @@
   return true;
 })
 
+; An integer operand with the lowest order 6 bit all ones.
+(define_predicate "const_int_6bitset_operand"
+ (and (match_code "const_int")
+  (match_test "(INTVAL (op) & 63) == 63")))
 (define_predicate "nonzero_shift_count_operand"
   (and (match_code "const_int")
(match_test "IN_RANGE (INTVAL (op), 1, GET_MODE_BITSIZE (mode) - 1)")))
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index cd53b15..43219dd 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -2994,18 +2994,18 @@ s390_decompose_address (rtx addr, struct s390_address 
*out)
 bool
 s390_decompose_shift_count (rtx op, rtx *base, HOST_WIDE_INT *offset)
 {
-  HOST_WIDE_INT off = 0;
+  rtx off = NULL_RTX;
 
   /* We can have an integer constant, an address register,
  or a sum of the two.  */
-  if (GET_CODE (op) == CONST_INT)
+  if (CONST_SCALAR_INT_P (op))
 {
-  off = INTVAL (op);
+  off = op;
   op = NULL_RTX;
 }
-  if (op && GET_CODE (op) == PLUS && GET_CODE (XEXP (op, 1)) == CONST_INT)
+  if (op && GET_CODE (op) == PLUS && CONST_SCALAR_INT_P (XEXP (op, 1)))
 {
-  off = INTVAL (XEXP (op, 1));
+  off = XEXP (op, 1);
   op = XEXP (op, 0);
 }
   while (op && GET_CODE (op) == SUBREG)
@@ -3015,7 +3015,18 @@ s390_decompose_shift_count (rtx op, rtx *base, 
HOST_WIDE_INT *offset)
 return false;
 
   if (offset)
-*offset = off;
+{
+  if (off == NULL_RTX)
+   *offset = 0;
+  else if (CONST_INT_P (off))
+   *offset = INTVAL (off);
+  else if (CONST_WIDE_INT_P (off))
+   /* The offset will anyway be cut down to 12 bits so take just
+  the lowest order chunk of the wide int.  */
+   *offset = CONST_WIDE_INT_ELT (off, 0);
+  else
+   gcc_unreachable ();
+}
   if (base)
 *base = op;
 
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index b878ec2..9703a30 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -741,6 +741,8 @@
 (define_mode_attr asm_fcmp [(CCVEQ "e") (CCVFH "h") (CCVFHE "he")])
 (define_mode_attr insn_cmp [(CCVEQ "eq") (CCVH "h") (CCVHU "hl") (CCVFH "h") 
(CCVFHE "he")])
 
+;; Subst pattern definitions
+(include "subst.md")
 
 (include "vector.md")
 
@@ -8360,28 +8362,26 @@
 ; rotl(di|si)3 instruction pattern(s).
 ;
 
-; rll, rllg
-(define_insn "rotl3"
-  [(set (match_operand:GPR 0 "register_operand" "=d")
-   (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
-   (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
+(define_expand "rotl3"
+  [(set (match_operand:GPR 0 "register_operand" "")
+(rotate:GPR (match_operand:GPR 1 "register_operand" "")
+   (match_operand:SI 2 "nonmemory_operand" "")))]
   "TARGET_CPU_ZARCH"
-  "rll\t%0,%1,%Y2"
-  [(set_attr "op_type"  "RSE")
-   (set_attr "atype""reg")
-   (set_attr "z10prop" "z10_super_E1")])
+  "")
 
 ; rll, rllg
-(define_insn "*rotl3_and"
-  [(set (match_operand:GPR 0 "register_operand" "=d")
-   (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
-   (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" 
"Y")
-   (match_operand:SI 3 "const_int_operand"   "n"]
-  "TARGET_CPU_ZARCH && (INTVAL (operands[3]) & 63) == 63"
-  "rll\t%0,%1,%Y2"
+(define_insn "*rotl3"
+  [(set (match_operand:GPR 0 "register_operand" "=d,d")
+   (rotate:GPR (match_operand:GPR 1 "register_operand"  "d,d")
+   (match_operand:SI  2 "nonmemory_operand" "a,n")))]
+  "TARGET_CPU_ZARCH"
+  "@
+   rll\t%0,%1,(%2)
+   rll\t%0,%1,%Y2"
   [(set_attr "op_type"  "RSE")
(set_attr "atype""reg")
-   (set_attr "z10prop" "z10_super_E1")])
+   (set_attr "enabled"  "*,")
+   (set_attr "z10prop"  "z10_super_E1")])
 
 
 ;;
diff --git a/gcc/config/s390/subst.md b/gcc/config/s390/subst.md
new file mode 100644
index 000..8443c69
--- /dev/null
+++ b/gcc/config/s390/subst.md
@@ -0,0 +

[PATCH 7/9] S/390: Get rid of Y constraint in vector.md.

2016-02-23 Thread Andreas Krebbel
This finally removes the Y constraint from the vector patterns while
folding some of them using a code iterator.

gcc/ChangeLog:

* config/s390/subst.md (SUBST mode iterator): Add ashiftrt.
(DSI_VI): New mode iterator.
("addr_style_op_subst"): Use DSI_VI instead of DSI.
* config/s390/vector.md ("vec_set"): Move expander before
the insn definition.
("*vec_set"): Change predicate and add alternative to
support only either register or const_int operands as element
selector.
("*vec_set_plus"): New pattern to support reg + const_int
operands.
("vec_extract"): New expander.
("*vec_extract"): New insn definition supporting reg and
const_int element selectors.
("*vec_extract_plus"): New insn definition supporting
reg+const_int element selectors.
("rotl3", "ashl3", "ashr3"): Merge into the
following expander+insn definition.
("3"): New expander.
("*3"): New insn definition.
---
 gcc/config/s390/subst.md  |  15 ++---
 gcc/config/s390/vector.md | 138 +++---
 2 files changed, 89 insertions(+), 64 deletions(-)

diff --git a/gcc/config/s390/subst.md b/gcc/config/s390/subst.md
index 1e2b1ba..08704c2 100644
--- a/gcc/config/s390/subst.md
+++ b/gcc/config/s390/subst.md
@@ -19,20 +19,21 @@
 ;; along with GCC; see the file COPYING3.  If not see
 ;; .
 
-(define_code_iterator SUBST [ashift lshiftrt rotate])
+(define_code_iterator SUBST [ashift lshiftrt rotate ashiftrt])
+(define_mode_iterator DSI_VI [SI DI V2QI V4QI V8QI V16QI V2HI V4HI V8HI V2SI 
V4SI V2DI])
 
 ; This expands an register/immediate operand to a register+immediate
 ; operand to draw advantage of the address style operand format
 ; providing a addition for free.
 (define_subst "addr_style_op_subst"
-  [(set (match_operand:DSI 0 "" "")
-(SUBST:DSI (match_operand:DSI 1 "" "")
-  (match_operand:SI 2 "" "")))]
+  [(set (match_operand:DSI_VI 0 "" "")
+(SUBST:DSI_VI (match_operand:DSI_VI 1 "" "")
+ (match_operand:SI 2 "" "")))]
   ""
   [(set (match_dup 0)
-(SUBST:DSI (match_dup 1)
-  (plus:SI (match_operand:SI 2 "register_operand" "a")
-   (match_operand 3 "const_int_operand"   "n"])
+(SUBST:DSI_VI (match_dup 1)
+ (plus:SI (match_operand:SI 2 "register_operand" "a")
+  (match_operand 3 "const_int_operand"   "n"])
 
 ; Use this in the insn name.
 (define_subst_attr "addr_style_op" "addr_style_op_subst" "" "_plus")
diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md
index cc3287c..a1b208c 100644
--- a/gcc/config/s390/vector.md
+++ b/gcc/config/s390/vector.md
@@ -307,44 +307,81 @@
 
 ; vec_store_lanes?
 
+; vec_set is supposed to *modify* an existing vector so operand 0 is
+; duplicated as input operand.
+(define_expand "vec_set"
+  [(set (match_operand:V0 "register_operand"  
"")
+   (unspec:V [(match_operand: 1 "general_operand"   
"")
+  (match_operand:SI2 "shift_count_or_setmem_operand" 
"")
+  (match_dup 0)]
+  UNSPEC_VEC_SET))]
+  "TARGET_VX")
+
 ; FIXME: Support also vector mode operands for 1
 ; FIXME: A target memory operand seems to be useful otherwise we end
 ; up with vl vlvgg vst.  Shouldn't the middle-end be able to handle
 ; that itself?
 (define_insn "*vec_set"
-  [(set (match_operand:V0 "register_operand" 
"=v, v,v")
-   (unspec:V [(match_operand: 1 "general_operand"   
"d,QR,K")
-  (match_operand:SI2 "shift_count_or_setmem_operand" 
"Y, I,I")
-  (match_operand:V 3 "register_operand"  
"0, 0,0")]
+  [(set (match_operand:V0 "register_operand" "=v,v,v,v")
+   (unspec:V [(match_operand: 1 "general_operand"   "d,d,QR,K")
+  (match_operand:SI2 "nonmemory_operand" "a,n,I,I")
+  (match_operand:V 3 "register_operand"  "0,0,0,0")]
  UNSPEC_VEC_SET))]
-  "TARGET_VX"
+  "TARGET_VX
+   && (!CONST_INT_P (operands[2])
+   || UINTVAL (operands[2]) < GET_MODE_NUNITS (mode))"
   "@
-   vlvg\t%v0,%1,%Y2
+   vlvg\t%v0,%1,0(%2)
+   vlvg\t%v0,%1,%2
vle\t%v0,%1,%2
vlei\t%v0,%1,%2"
-  [(set_attr "op_type" "VRS,VRX,VRI")])
+  [(set_attr "op_type" "VRS,VRS,VRX,VRI")])
+
+(define_insn "*vec_set_plus"
+  [(set (match_operand:V  0 "register_operand" "=v")
+   (unspec:V [(match_operand:   1 "general_operand"   "d")
+  (plus:SI (match_operand:SI 2 "register_operand"  "a")
+   (match_operand:SI 4 "const_int_operand" "n"))
+  (match_operand:V   3 "register_operand"  "0")]
+ UNSP

Re: [pr 69666] No SRA default_def replacements for unscalarizable

2016-02-23 Thread H.J. Lu
On Fri, Feb 19, 2016 at 8:21 AM, Martin Jambor  wrote:
> Hi,
>
> in PR 69666, SRA attempts to turn a load from an aggregate that is
> uninitialized into a load from a default definition SSA name (which
> something it does to generate an appropriate warning later) but
> unfortunately it does so using an access structure which is
> representable with __int128 when the load in question is smaller.  It
> then attempts to fix it up only to create an invalid V_C_E.  In this
> case, the correct thing to do is not to attempt the transformation,
> when there are smaller accesses, which can be figured out by looking
> at the unscalarizable_region flag of the access.
>
> Bootstrapped and tested on x86_64, OK for trunk and later for the 5
> branch?
>

This may have caused:

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

-- 
H.J.


Re: [Fortran,4.9/5/6 Regression]ICE for Fortran files when specifying a file instead of an include directory

2016-02-23 Thread Dominique d'Humières
Hi Jerry,

> Let me no if any objections.

The test gfortran.dg/include_6.f90 should be updated:

before the patch

f951: Warning: 'gfortran.log' is not a directory

after

f951: Fatal Error: 'gfortran.log' is not a directory

Thanks,

Dominique



[PATCH] Fix PR c++/69736

2016-02-23 Thread Patrick Palka
finish_call_expr thinks that a call to a function which has been
obfuscated by force_paren_expr is a call to an unknown function.  This
eventually leads us to not make use of the function's default arguments
when processing the argument list.  So a function call like f() may
compile and yet (f)() may not, if f has defaulted arguments.

This patch fixes this inconsistency by making finish_call_expr undo the
obfuscation performed by force_paren_expr.

Bootstrapped + regtested + boost-tested on x86_64-pc-linux-gnu, does
this look OK to commit?

gcc/cp/ChangeLog:

PR c++/69736
* cp-tree.h (REF_PARENTHESIZED_P): Adjust documentation.
(maybe_undo_parenthesized_ref): Declare.
* semantics.c (maybe_undo_parenthesized_ref): Split out from
check_return_expr.
(finish_call_expr): Use it.
* typeck.c (check_return_expr): Use it.

gcc/testsuite/ChangeLog:

PR c++/69736
* g++.dg/cpp1y/paren2.C: New test.
---
 gcc/cp/cp-tree.h|  3 ++-
 gcc/cp/semantics.c  | 28 
 gcc/cp/typeck.c | 12 +---
 gcc/testsuite/g++.dg/cpp1y/paren2.C | 25 +
 4 files changed, 56 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/paren2.C

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 3c23a83a..88c6367 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3393,7 +3393,7 @@ extern void decl_shadowed_for_var_insert (tree, tree);
   TREE_LANG_FLAG_0 (STRING_CST_CHECK (NODE))
 
 /* Indicates whether a COMPONENT_REF has been parenthesized, or an
-   INDIRECT_REF comes from parenthesizing a VAR_DECL.  Currently only set
+   INDIRECT_REF comes from parenthesizing a _DECL.  Currently only set
some of the time in C++14 mode.  */
 
 #define REF_PARENTHESIZED_P(NODE) \
@@ -6361,6 +6361,7 @@ extern tree finish_label_stmt (tree);
 extern void finish_label_decl  (tree);
 extern cp_expr finish_parenthesized_expr   (cp_expr);
 extern tree force_paren_expr   (tree);
+extern tree maybe_undo_parenthesized_ref   (tree);
 extern tree finish_non_static_data_member   (tree, tree, tree);
 extern tree begin_stmt_expr(void);
 extern tree finish_stmt_expr_expr  (tree, tree);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 38c7516..e7f2e8b 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1673,6 +1673,30 @@ force_paren_expr (tree expr)
   return expr;
 }
 
+/* If T is an id-expression obfuscated by force_paren_expr, undo the
+   obfuscation and return the underlying id-expression.  Otherwise
+   return T.  */
+
+tree
+maybe_undo_parenthesized_ref (tree t)
+{
+  if (cxx_dialect >= cxx14
+  && INDIRECT_REF_P (t)
+  && REF_PARENTHESIZED_P (t))
+{
+  t = TREE_OPERAND (t, 0);
+  while (TREE_CODE (t) == NON_LVALUE_EXPR
+|| TREE_CODE (t) == NOP_EXPR)
+   t = TREE_OPERAND (t, 0);
+
+  gcc_assert (TREE_CODE (t) == ADDR_EXPR
+ || TREE_CODE (t) == STATIC_CAST_EXPR);
+  t = TREE_OPERAND (t, 0);
+}
+
+  return t;
+}
+
 /* Finish a parenthesized expression EXPR.  */
 
 cp_expr
@@ -2332,6 +2356,10 @@ finish_call_expr (tree fn, vec **args, bool 
disallow_virtual,
   && TREE_CODE (TREE_OPERAND (fn, 0)) == OVERLOAD)
 fn = TREE_OPERAND (fn, 0);
 
+  /* If FN is a FUNCTION_DECL obfuscated by force_paren_expr, undo
+ it so that we can tell this is a call to a known function.  */
+  fn = maybe_undo_parenthesized_ref (fn);
+
   if (is_overloaded_fn (fn))
 fn = baselink_for_fns (fn);
 
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index d7ce327..3da6ea1 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -8929,17 +8929,7 @@ check_return_expr (tree retval, bool *no_warning)
 
   /* If we had an id-expression obfuscated by force_paren_expr, we need
 to undo it so we can try to treat it as an rvalue below.  */
-  if (cxx_dialect >= cxx14
- && INDIRECT_REF_P (retval)
- && REF_PARENTHESIZED_P (retval))
-   {
- retval = TREE_OPERAND (retval, 0);
- while (TREE_CODE (retval) == NON_LVALUE_EXPR
-|| TREE_CODE (retval) == NOP_EXPR)
-   retval = TREE_OPERAND (retval, 0);
- gcc_assert (TREE_CODE (retval) == ADDR_EXPR);
- retval = TREE_OPERAND (retval, 0);
-   }
+  retval = maybe_undo_parenthesized_ref (retval);
 
   /* Under C++11 [12.8/32 class.copy], a returned lvalue is sometimes
 treated as an rvalue for the purposes of overload resolution to
diff --git a/gcc/testsuite/g++.dg/cpp1y/paren2.C 
b/gcc/testsuite/g++.dg/cpp1y/paren2.C
new file mode 100644
index 000..12462be
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/paren2.C
@@ -0,0 +1,25 @@
+// PR c++/69736
+
+void fn1(bool = true)
+{
+  (fn1)();
+}
+
+template 
+void fn2()
+{
+  (fn1)();
+}
+
+struct X
+{
+  static void fn3(

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

2016-02-23 Thread Bin.Cheng
On Fri, Feb 19, 2016 at 10:24 PM, Jeff Law  wrote:
> On 02/16/2016 11:43 AM, Bin Cheng wrote:
>>
>> 
>> From: Jeff Law 
>> Sent: 11 February 2016 23:26
>> To: Bin.Cheng
>> Cc: Bin Cheng; gcc-patches@gcc.gnu.org; nd
>> Subject: Re: [PATCH PR69052]Check if loop inv can be propagated into mem
>> ref with additional addr expr canonicalization
>>
 On 02/11/2016 10:59 AM, Bin.Cheng wrote:
>>
>>
 Hi Jeff,
 Thanks for detailed review.  I also think a generic canonical
 interface for RTL is much better.  I will give it a try.  But with
 high chance it's a next stage1 stuff.
>>>
>>> That is, of course, fine.  However, if you do get something ready, I'd
>>> support using it within LICM for gcc-6, then using it in other places
>>> for gcc-7.
>>
>> Hi,
>> This is the updated version patch.  It fixes the problem by introducing a
>> generic address canonicalization interface.  This new interface
>> canonicalizes address expression in following steps:
>>   1) Rewrite ASHIFT into MULT recursively.
>>   2) Divide address into sub expressions with PLUS as the separator.
>>   3) Sort sub expressions according to precedence defined for
>> communative operations.
>>   4) Simplify CONST_INT_P sub expressions.
>>   5) Create new canonicalized address and return.
>>
>> According to review comments, this interface is now restricted in LCIM,
>> and will probably be expanded to other passes like fwprop and combine after
>> entering GCC7.
>> Bootstrap and test on x86_64 and AArch64.  Is it OK?
>>
>> Thanks,
>> bin
>>
>> 2016-02-15  Bin Cheng  
>>
>> PR tree-optimization/69052
>> * loop-invariant.c (canonicalize_address_mult): New function.
>> (MAX_CANON_ADDR_PARTS): New macro.
>> (collect_address_parts): New function.
>> (compare_address_parts, canonicalize_address): New functions.
>> (inv_can_prop_to_addr_use): Check validity of address expression
>> which is canonicalized by above canonicalize_address.
>>
>> gcc/testsuite/ChangeLog
>> 2016-02-15  Bin Cheng  
>>
>> PR tree-optimization/69052
>> * gcc.target/i386/pr69052.c: New test.
>
> This is exactly what I was looking for from a design standpoint.
>
> My only question is why didn't you use FOR_EACH_SUBRTX_VRA from rtl-iter.h
> to walk the RTX expressions in collect_address_parts and
> canonicalize_address_mult?
Hi Jeff,
Here comes the updated patch using FOR_EACH_SUBRTX_VAR in both
functions you mentioned.
Bootstrap and test on x86_64 and AArch64, is it OK?  The ChangeLog
isn't affected.

Thanks,
bin
>
> Jeff
>
>
>>
>>>
>>> Jeff
>>
>>
>
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 707f044..dcbe932 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfgloop.h"
 #include "expr.h"
 #include "params.h"
+#include "rtl-iter.h"
 #include "dumpfile.h"
 
 /* The data stored for the loop.  */
@@ -754,6 +755,130 @@ create_new_invariant (struct def *def, rtx_insn *insn, 
bitmap depends_on,
   return inv;
 }
 
+/* Return a canonical version of X for the address, from the point of view,
+   that all multiplications are represented as MULT instead of the multiply
+   by a power of 2 being represented as ASHIFT.
+
+   Callers should prepare a copy of X because this function may modify it
+   in place.  */
+
+static void
+canonicalize_address_mult (rtx x)
+{
+  subrtx_var_iterator::array_type array;
+  FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
+{
+  rtx sub = *iter;
+
+  if (GET_CODE (sub) == ASHIFT
+ && CONST_INT_P (XEXP (sub, 1))
+ && INTVAL (XEXP (sub, 1)) < GET_MODE_BITSIZE (GET_MODE (sub))
+ && INTVAL (XEXP (sub, 1)) >= 0)
+   {
+ HOST_WIDE_INT shift = INTVAL (XEXP (sub, 1));
+ PUT_CODE (sub, MULT);
+ XEXP (sub, 1) = gen_int_mode ((HOST_WIDE_INT) 1 << shift,
+   GET_MODE (sub));
+ iter.skip_subrtxes ();
+   }
+}
+}
+
+/* Maximum number of sub expressions in address.  We set it to
+   a small integer since it's unlikely to have a complicated
+   address expression.  */
+
+#define MAX_CANON_ADDR_PARTS (5)
+
+/* Collect sub expressions in address X with PLUS as the seperator.
+   Sub expressions are stored in vector ADDR_PARTS.  */
+
+static void
+collect_address_parts (rtx x, vec *addr_parts)
+{
+  subrtx_var_iterator::array_type array;
+  FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
+{
+  rtx sub = *iter;
+
+  if (GET_CODE (sub) != PLUS)
+   {
+ addr_parts->safe_push (sub);
+ iter.skip_subrtxes ();
+   }
+}
+}
+
+/* Compare function for sorting sub expressions X and Y based on
+   precedence defined for communitive operations.  */
+
+static int
+compare_address_parts (const void *x, const void *y)
+{
+  const rtx *rx = (const rtx *)x;
+  const rtx *ry = (const rtx *)y;
+  int px 

Re: Use plain -fopenacc to enable OpenACC kernels processing

2016-02-23 Thread Thomas Schwinge
Hi!

On Mon, 15 Feb 2016 17:53:58 +0100, Tom de Vries  wrote:
> On 10/02/16 15:40, Thomas Schwinge wrote:
> > On Fri, 5 Feb 2016 13:06:17 +0100, I wrote:
> >> On Mon, 9 Nov 2015 18:39:19 +0100, Tom de Vries  
> >> wrote:
> >>> On 09/11/15 16:35, Tom de Vries wrote:
>  this patch series for stage1 trunk adds support to:
>  - parallelize oacc kernels regions using parloops, and
>  - map the loops onto the oacc gang dimension.
> >>
> >>> Atm, the parallelization behaviour for the kernels region is controlled
> >>> by flag_tree_parallelize_loops, which is also used to control generic
> >>> auto-parallelization by autopar using omp. That is not ideal, and we may
> >>> want a separate flag (or param) to control the behaviour for oacc
> >>> kernels, f.i. -foacc-kernels-gang-parallelize=. I'm open to 
> >>> suggestions.
> >>
> >> I suggest to use plain -fopenacc to enable OpenACC kernels processing
> >> (which just makes sense, I hope) ;-) and have later processing stages
> >> determine the actual parametrization (currently: number of gangs) (that
> >> is, Nathan's recent "Default compute dimensions" patches).
> 
> That makes a lot of sense.  Thanks for working on this.

> >> Originally, I want to use:
> >>
> >>  OMP_CLAUSE_NUM_GANGS_EXPR (clause) = build_int_cst 
> >> (integer_type_node, n_threads == 0 ? -1 : n_threads);
> >>
> >> ... to store -1 "have the compiler decidew" (instead of now 0 "have the
> >> run-time decide", which might prevent some code optimizations, as I
> >> understand it) for the n_threads == 0 case, but it seems that for an
> >> offloaded OpenACC kernels region, gcc/omp-low.c:oacc_validate_dims is
> >> called with the parameter "used" set to 0 instead of "gang", and then the
> >> "Default anything left to 1 or a partitioned default" logic will default
> >> dims["gang"] to oacc_min_dims["gang"] (that is, 1) instead of the
> >> oacc_default_dims["gang"] (that is, 32).  Nathan, does that smell like a
> >> bug (and could you look into that)?

 filed.  (Nathan?)

> >> --- gcc/tree-parloops.c
> >> +++ gcc/tree-parloops.c

> The oacc-parloops changes look good to me. I approve them for 6.0 stage 
> 4 (given that using the ftree-parallelize-loops= flag for oacc 
> kernels parallelization was was just a placeholder waiting to be 
> replaced by an oacc-based approach). [ And I'd expect that the 
> tree-ssa-loop.c changes and the mechanical testsuite changes can be 
> regarded as trivial. ]

Thanks; committed (without changes) in r233634:

commit 3a37a410bbfed45d04f06887c348938182369d5a
Author: tschwinge 
Date:   Tue Feb 23 15:07:54 2016 +

Use plain -fopenacc to enable OpenACC kernels processing

gcc/
* tree-parloops.c (create_parallel_loop, gen_parallel_loop)
(parallelize_loops): In OpenACC kernels mode, set n_threads to
zero.
(pass_parallelize_loops::gate): In OpenACC kernels mode, gate on
flag_openacc.
* tree-ssa-loop.c (gate_oacc_kernels): Likewise.
gcc/testsuite/
* c-c++-common/goacc/kernels-counter-vars-function-scope.c: Adjust
to -ftree-parallelize-loops/-fopenacc changes.
* c-c++-common/goacc/kernels-double-reduction-n.c: Likewise.
* c-c++-common/goacc/kernels-double-reduction.c: Likewise.
* c-c++-common/goacc/kernels-loop-2.c: Likewise.
* c-c++-common/goacc/kernels-loop-3.c: Likewise.
* c-c++-common/goacc/kernels-loop-g.c: Likewise.
* c-c++-common/goacc/kernels-loop-mod-not-zero.c: Likewise.
* c-c++-common/goacc/kernels-loop-n.c: Likewise.
* c-c++-common/goacc/kernels-loop-nest.c: Likewise.
* c-c++-common/goacc/kernels-loop.c: Likewise.
* c-c++-common/goacc/kernels-one-counter-var.c: Likewise.
* c-c++-common/goacc/kernels-reduction.c: Likewise.
* gfortran.dg/goacc/kernels-loop-inner.f95: Likewise.
* gfortran.dg/goacc/kernels-loops-adjacent.f95: Likewise.
libgomp/
* oacc-parallel.c (GOACC_parallel_keyed): Initialize dims.
* plugin/plugin-nvptx.c (nvptx_exec): Provide default values for
dims.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-2.c: Adjust to
-ftree-parallelize-loops/-fopenacc changes.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-3.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-3.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-4.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-5.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-6.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-collapse.c:
Likewise.
* testsuite/lib

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

2016-02-23 Thread Richard Biener
On Wed, Nov 4, 2015 at 4:03 PM, Mikhail Maltsev  wrote:
> On 11/03/2015 02:35 AM, Jeff Law wrote:
>> This is good fore the trunk too.  Please install.
>>
>> Thanks!
>>
>> jeff
>
> Committed as r229758.

> grep ENABLE_CHECKING *.[ch]
dwarf2out.c:#if ENABLE_CHECKING
dwarf2out.c:#if ENABLE_CHECKING
dwarf2out.c:#if ENABLE_CHECKING
dwarf2out.h:#if ENABLE_CHECKING
hsa-gen.c:#ifdef ENABLE_CHECKING
hsa-regalloc.c:#ifdef ENABLE_CHECKING
> grep ENABLE_CHECKING ada/gcc-interface/*.[ch]
ada/gcc-interface/utils.c:#ifdef ENABLE_CHECKING


> --
> Regards,
> Mikhail Maltsev


Re: [PATCH] Fix PR c++/69736

2016-02-23 Thread Marek Polacek
On Tue, Feb 23, 2016 at 09:58:41AM -0500, Patrick Palka wrote:
> finish_call_expr thinks that a call to a function which has been
> obfuscated by force_paren_expr is a call to an unknown function.  This
> eventually leads us to not make use of the function's default arguments
> when processing the argument list.  So a function call like f() may
> compile and yet (f)() may not, if f has defaulted arguments.
> 
> This patch fixes this inconsistency by making finish_call_expr undo the
> obfuscation performed by force_paren_expr.
 
Thanks for the fix.

> new file mode 100644
> index 000..12462be
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp1y/paren2.C
> @@ -0,0 +1,25 @@
> +// PR c++/69736
> +

I'd expect
// { dg-do compile { target c++14 } }
here.

> +void fn1(bool = true)
> +{
> +  (fn1)();
> +}
> +
> +template 
> +void fn2()
> +{
> +  (fn1)();
> +}

The test seems to fail here though because of
testsuite/g++.dg/cpp1y/paren2.C:11:9: error: too few arguments to function
Why's that?

Marek


[PATCH] Fix normal_inner_ref expansion (PR middle-end/69909)

2016-02-23 Thread Jakub Jelinek
Hi!

When the base of a handled component (BIT_FIELD_REF in the testcase)
is SSA_NAME which happens to be expanded as some MEM (on the testcase
it is SSA_NAME set to VIEW_CONVERT_EXPR of an SSA_NAME that has MEM as
DECL_RTL), expand_expr_real_1 can try to update the MEM attributes from
exp, but that is wrong, it might change the alias set of the MEM, etc.
If the base is SSA_NAME, we should keep the attributes unmodified.
The patch actually also tests for !MEM_P (orig_op0), so that if
the SSA_NAME expanded to non-MEM (e.g. constant or REG), but the
normal_inner_ref expansion forces it for whatever reason in memory,
we still set the attributes of such a MEM, it is a temporary in that
case, rather than the original read.

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

2016-02-23  Jakub Jelinek  
Richard Biener  

PR middle-end/69909
* expr.c (expand_expr_real_1) : Avoid
set_mem_attributes if tem is SSA_NAME which got expanded
as a MEM.

* gcc.dg/torture/pr69909.c: New test.

--- gcc/expr.c.jj   2016-02-23 13:54:02.0 +0100
+++ gcc/expr.c  2016-02-23 14:30:23.810657866 +0100
@@ -10521,7 +10521,11 @@ expand_expr_real_1 (tree exp, rtx target
if (op0 == orig_op0)
  op0 = copy_rtx (op0);
 
-   set_mem_attributes (op0, exp, 0);
+   /* Don't set memory attributes if the base expression is
+  SSA_NAME that got expanded as a MEM.  In that case, we should
+  just honor its original memory attributes.  */
+   if (TREE_CODE (tem) != SSA_NAME || !MEM_P (orig_op0))
+ set_mem_attributes (op0, exp, 0);
 
if (REG_P (XEXP (op0, 0)))
  mark_reg_pointer (XEXP (op0, 0), MEM_ALIGN (op0));
--- gcc/testsuite/gcc.dg/torture/pr69909.c.jj   2016-02-23 14:25:27.819719259 
+0100
+++ gcc/testsuite/gcc.dg/torture/pr69909.c  2016-02-23 14:25:27.818719272 
+0100
@@ -0,0 +1,35 @@
+/* PR middle-end/69909 */
+/* { dg-do run { target int128 } } */
+/* { dg-additional-options "-w" } */
+
+typedef unsigned V __attribute__ ((vector_size (32)));
+typedef __int128 T;
+typedef __int128 U __attribute__ ((vector_size (32)));
+
+__attribute__((noinline, noclone)) T
+foo (T a, V b, V c, V d, V e, U f)
+{
+  d[6] ^= 0x10;
+  f -= (U) d;
+  f[1] |= f[1] << (a & 127);
+  c ^= d;
+  return b[7] + c[2] + c[2] + d[6] + e[2] + f[1];
+}
+
+int
+main ()
+{
+  if (__CHAR_BIT__ != 8 || sizeof (unsigned) != 4 || sizeof (T) != 16)
+return 0;
+
+  T x = foo (1, (V) { 9, 2, 5, 8, 1, 2, 9, 3 },
+   (V) { 1, 2, 3, 4, 5, 6, 7, 8 },
+   (V) { 4, 1, 2, 9, 8, 3, 5, 2 },
+   (V) { 3, 6, 1, 3, 2, 9, 4, 8 }, (U) { 3, 5 });
+  if (((unsigned long long) (x >> 64) != 0xULL
+   || (unsigned long long) x != 0xfffe001aULL)
+  && ((unsigned long long) (x >> 64) != 0xfffdULL
+ || (unsigned long long) x != 0x0022ULL))
+__builtin_abort ();
+  return 0;
+}

Jakub


Re: [PATCH] Fix PR c++/69736

2016-02-23 Thread Patrick Palka

On Tue, 23 Feb 2016, Marek Polacek wrote:


On Tue, Feb 23, 2016 at 09:58:41AM -0500, Patrick Palka wrote:

finish_call_expr thinks that a call to a function which has been
obfuscated by force_paren_expr is a call to an unknown function.  This
eventually leads us to not make use of the function's default arguments
when processing the argument list.  So a function call like f() may
compile and yet (f)() may not, if f has defaulted arguments.

This patch fixes this inconsistency by making finish_call_expr undo the
obfuscation performed by force_paren_expr.


Thanks for the fix.


new file mode 100644
index 000..12462be
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/paren2.C
@@ -0,0 +1,25 @@
+// PR c++/69736
+


I'd expect
// { dg-do compile { target c++14 } }
here.


Okay.




+void fn1(bool = true)
+{
+  (fn1)();
+}
+
+template 
+void fn2()
+{
+  (fn1)();
+}


The test seems to fail here though because of
testsuite/g++.dg/cpp1y/paren2.C:11:9: error: too few arguments to function
Why's that?


Oops... The call to maybe_undo_parenthesized_ref managed to mysteriously
move itself to the wrong place.  It should be called before the
processing_template_decl logic, before FN gets wrapped in a
NON_DEPENDENT_EXPR.

Here's the updated patch, which I'm going to retest just in case.

-- >8 --

gcc/cp/ChangeLog:

PR c++/69736
* cp-tree.h (REF_PARENTHESIZED_P): Adjust documentation.
(maybe_undo_parenthesized_ref): Declare.
* semantics.c (maybe_undo_parenthesized_ref): Split out from
check_return_expr.
(finish_call_expr): Use it.
* typeck.c (check_return_expr): Use it.

gcc/testsuite/ChangeLog:

PR c++/69736
* g++.dg/cpp1y/paren2.C: New test.
---
 gcc/cp/cp-tree.h|  3 ++-
 gcc/cp/semantics.c  | 28 
 gcc/cp/typeck.c | 12 +---
 gcc/testsuite/g++.dg/cpp1y/paren2.C | 26 ++
 4 files changed, 57 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/paren2.C

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 3c23a83a..88c6367 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3393,7 +3393,7 @@ extern void decl_shadowed_for_var_insert (tree, tree);
   TREE_LANG_FLAG_0 (STRING_CST_CHECK (NODE))

 /* Indicates whether a COMPONENT_REF has been parenthesized, or an
-   INDIRECT_REF comes from parenthesizing a VAR_DECL.  Currently only set
+   INDIRECT_REF comes from parenthesizing a _DECL.  Currently only set
some of the time in C++14 mode.  */

 #define REF_PARENTHESIZED_P(NODE) \
@@ -6361,6 +6361,7 @@ extern tree finish_label_stmt (tree);
 extern void finish_label_decl  (tree);
 extern cp_expr finish_parenthesized_expr   (cp_expr);
 extern tree force_paren_expr   (tree);
+extern tree maybe_undo_parenthesized_ref   (tree);
 extern tree finish_non_static_data_member   (tree, tree, tree);
 extern tree begin_stmt_expr(void);
 extern tree finish_stmt_expr_expr  (tree, tree);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 38c7516..e5ecf48 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1673,6 +1673,30 @@ force_paren_expr (tree expr)
   return expr;
 }

+/* If T is an id-expression obfuscated by force_paren_expr, undo the
+   obfuscation and return the underlying id-expression.  Otherwise
+   return T.  */
+
+tree
+maybe_undo_parenthesized_ref (tree t)
+{
+  if (cxx_dialect >= cxx14
+  && INDIRECT_REF_P (t)
+  && REF_PARENTHESIZED_P (t))
+{
+  t = TREE_OPERAND (t, 0);
+  while (TREE_CODE (t) == NON_LVALUE_EXPR
+|| TREE_CODE (t) == NOP_EXPR)
+   t = TREE_OPERAND (t, 0);
+
+  gcc_assert (TREE_CODE (t) == ADDR_EXPR
+ || TREE_CODE (t) == STATIC_CAST_EXPR);
+  t = TREE_OPERAND (t, 0);
+}
+
+  return t;
+}
+
 /* Finish a parenthesized expression EXPR.  */

 cp_expr
@@ -2265,6 +2289,10 @@ finish_call_expr (tree fn, vec **args, bool 
disallow_virtual,

   orig_fn = fn;

+  /* If FN is a FUNCTION_DECL obfuscated by force_paren_expr, undo
+ it so that we can tell this is a call to a known function.  */
+  fn = maybe_undo_parenthesized_ref (fn);
+
   if (processing_template_decl)
 {
   /* If the call expression is dependent, build a CALL_EXPR node
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index d7ce327..3da6ea1 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -8929,17 +8929,7 @@ check_return_expr (tree retval, bool *no_warning)

   /* If we had an id-expression obfuscated by force_paren_expr, we need
 to undo it so we can try to treat it as an rvalue below.  */
-  if (cxx_dialect >= cxx14
- && INDIRECT_REF_P (retval)
- && REF_PARENTHESIZED_P (retval))
-   {
- retval = TREE_OPERAND (retval, 0);
- while (TREE_CODE (retval) == NON_LVALUE_EXPR
-|| TREE_COD

Re: [PATCH] gcov: Configurable destination for error output

2016-02-23 Thread Aaron Conole
Nathan Sidwell  writes:

> On 02/22/16 14:35, Aaron Conole wrote:
>
>> D'oh, you're probably right. In my excitement to contribute, I forgot
>> this was shared. I think 'w' should be correct, since this isn't
>> intended to be read at all, but I could be convinced otherwise.
>
> sorry, I misremembered the encoding of write append, which is "a" --
> don't clobber the existing contents.  I think that's the usual
> behaviour for error logging (.xsession-error and the like).

Done.

>> By lazy load, do you mean only after the first gcov_error call? That's
>> probably a better approach, and I can recook, test, and resubmit with
>> these corrected.
>
> Lazy opening -- open on first error output.   Something like
>
> if (!gcov_error_file)
>   gcov_error_file = gcov_open_error_file ();
>
> in gcov_error?

Before I start cooking up this change, is it possible I need to worry about
gcov_error being invoked from multiple threads? If so, I'll need some
kind of mutex which I think is not needed with the current design.

> FWIW, I think this has missed the boat for gcc 6.1, as we're now in stage  4.

No worries.

-Aaron

> nathan


Re: [PATCH] Fix PR c++/69736

2016-02-23 Thread Patrick Palka

On Tue, 23 Feb 2016, Patrick Palka wrote:


On Tue, 23 Feb 2016, Marek Polacek wrote:


On Tue, Feb 23, 2016 at 09:58:41AM -0500, Patrick Palka wrote:

finish_call_expr thinks that a call to a function which has been
obfuscated by force_paren_expr is a call to an unknown function.  This
eventually leads us to not make use of the function's default arguments
when processing the argument list.  So a function call like f() may
compile and yet (f)() may not, if f has defaulted arguments.

This patch fixes this inconsistency by making finish_call_expr undo the
obfuscation performed by force_paren_expr.


Thanks for the fix.


new file mode 100644
index 000..12462be
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/paren2.C
@@ -0,0 +1,25 @@
+// PR c++/69736
+


I'd expect
// { dg-do compile { target c++14 } }
here.


Okay.




+void fn1(bool = true)
+{
+  (fn1)();
+}
+
+template 
+void fn2()
+{
+  (fn1)();
+}


The test seems to fail here though because of
testsuite/g++.dg/cpp1y/paren2.C:11:9: error: too few arguments to function
Why's that?


Oops... The call to maybe_undo_parenthesized_ref managed to mysteriously
move itself to the wrong place.  It should be called before the
processing_template_decl logic, before FN gets wrapped in a
NON_DEPENDENT_EXPR.

Here's the updated patch, which I'm going to retest just in case.



Actually, this patch is also wrong since we later reject the function
call (fn1)() when we attempt to instantiate the enclosing template function
fn2<>.  Example:

template 
void fn2(T a)
{
  (fn1)();
}

void foo ()
{
  fn2 (true);
}

This happens because when processing_template_decl, in finish_call_expr we
build a non-dependent CALL_EXPR using the obfuscated orig_fn.  Then during
instantiation, when tsubst_copy_and_build rebuilds this INDIRECT_REF (which is
the orig_fn) it does not copy the REF_PARENTHESIZED_P flag to the newly built
INDIRECT_REF.  So in the subsequent call to finish_call_expr FN is no longer
considered to be a parenthesized ref so maybe_undo_parenthesized_ref becomes a
no-op.

So this can be fixed either by

1. making tsubst_copy_and_build retain the REF_PARENTHESIZED_P flag when
processing an INDIRECT_REF, or by

2. moving the call to maybe_undo_parenthesized_ref in finish_call_expr before
the assignment of orig_fn so that orig_fn will be un-obfuscated as well, or by

3. making tsubst_copy_and_build call maybe_undo_parenthesized_ref when
processing a CALL_EXPR.

I don't know which solution is better.


RE: [RFC] [MIPS] Enable non-executable PT_GNU_STACK support

2016-02-23 Thread Faraz Shahbazker
Bump.

From: Faraz Shahbazker [faraz.shahbaz...@imgtec.com]
Sent: 05 February 2016 10:36
To: gcc-patches@gcc.gnu.org
Cc: Matthew Fortune
Subject: [RFC] [MIPS] Enable non-executable PT_GNU_STACK support

Enable non-executable stack mode if assembler and linker support it.

Currently the MIPS FPU emulator uses eXecute Out of Line (XOL) on the stack to
handle instructions in the delay slots of FPU branches.  Because of this MIPS
cannot have a non-executable stack. While the solution on the kernel side is
not yet finalized, we propose changes required on the tools-side to make them
ready for a seamless transition whenever a fixed kernel becomes available.

glibc/dynamic linker:

* When non-executable stack is requested, first check AT_FLAGS in the
  auxiliary vector to decide if this kernel supports a non-executable
  stack. Persist with the non-executable mode specified on the
  PT_GNU_STACK segment only if kernel supports it, else revert to an
  executable stack.

* The 25th bit (1<<24) in AT_FLAGS is reserved for use by the kernel to
  indicate that it supports a non-executable stack on MIPS.

* glibc's ABIVERSION is incremented from 3 to 5, so that applications linked
  for this glibc can't be accidentally run against older versions. ABIVERSION
  4 has been skipped over because it was chosen for IFUNC support, which is
  still under review.

Patch under review: https://sourceware.org/ml/libc-alpha/2016-01/msg00567.html

binutils:

* Increment the ABIVERSION to 5 for objects with non-executable stacks.

Patch under review: https://sourceware.org/ml/binutils/2016-02/msg00087.html

gcc:

* Check if assembler/dynamic linker support the new behaviour
  (ABIVERSION >= 5). If yes, enable non-executable stack by default
  for all objects.

gcc/ChangeLog
* configure.ac: Check if assembler supports the new PT_GNU_STACK
ABI change; if yes, enable non-executable stack mode by default.
* configure: Regenerate.
* config.in: Regenerate.
* config/mips/mips.c: Define TARGET_ASM_FILE_END to indicate
stack mode for each C file if LD_MIPS_GNUSTACK is enabled.

libgcc/ChangeLog
config/mips/crti.S: Add .note.GNU-stack marker if LD_MIPS_GNUSTACK
support is enabled.
config/mips/crtn.S: Add .note.GNU-stack marker if LD_MIPS_GNUSTACK
support is enabled.
config/mips/mips16.S: Add .note.GNU-stack marker if
LD_MIPS_GNUSTACK support is enabled.
config/mips/vr4120-div.S: Add .note.GNU-stack marker if
LD_MIPS_GNUSTACK support is enabled.

-- gcc/configure.ac gcc/config/mips/mip.c config/mips/crti.S config/mips/crtn.S 
config/mips/mips16.S config/mips/vr4120-div.S
---
 gcc/config/mips/mips.c  |5 +
 gcc/configure.ac|   23 +++
 libgcc/config/mips/crti.S   |6 ++
 libgcc/config/mips/crtn.S   |6 ++
 libgcc/config/mips/mips16.S |7 +++
 libgcc/config/mips/vr4120-div.S |7 +++
 6 files changed, 54 insertions(+)

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index ea18ad6..c3eefc0 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -20194,6 +20194,11 @@ mips_promote_function_mode (const_tree type 
ATTRIBUTE_UNUSED,
 #undef TARGET_HARD_REGNO_SCRATCH_OK
 #define TARGET_HARD_REGNO_SCRATCH_OK mips_hard_regno_scratch_ok

+#if HAVE_LD_MIPS_GNUSTACK
+#undef TARGET_ASM_FILE_END
+#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+#endif
+
 struct gcc_target targetm = TARGET_INITIALIZER;

 #include "gt-mips.h"
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 0a626e9..9b8190e 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4562,6 +4562,29 @@ pointers into PC-relative form.])
   AC_MSG_ERROR(
[Requesting --with-nan= requires assembler support for -mnan=])
 fi
+
+AC_CACHE_CHECK([linker for GNU-stack ABI support],
+  [gcc_cv_ld_mips_gnustack],
+  [gcc_cv_ld_mips_gnustack=no
+   if test x$gcc_cv_as != x \
+  -a x$gcc_cv_ld != x \
+  -a x$gcc_cv_readelf != x ; then
+cat > conftest.s < /dev/null 2>&1 \
+   && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1; then
+  abi_version=`$gcc_cv_readelf -h conftest 2>&1 | grep "ABI Version:" 
| cut -d: -f2 | tr -d '[[:space:]]'`
+  if test "$abi_version" -ge 5; then
+gcc_cv_ld_mips_gnustack=yes
+  fi
+fi
+   fi
+   rm -f conftest.s conftest.o conftest])
+if test x$gcc_cv_ld_mips_gnustack = xyes; then
+   AC_DEFINE(HAVE_LD_MIPS_GNUSTACK, 1,
+  [Define if your linker can handle PT_GNU_STACK segments correctly.])
+fi
 ;;
 s390*-*-*)
 gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
diff --git a/libgcc/config/mips/crti.S b/libgcc/config/mips/crti.S
index 8521d3c..aa85d94 100644
--- a/libgcc/config/mips/crti.S
+++ b/libgcc/config/mips/crti.S
@@ -21,6 +21,12 @@ a copy 

Re: [PATCH] gcov: Configurable destination for error output

2016-02-23 Thread Nathan Sidwell

On 02/23/16 11:04, Aaron Conole wrote:


Before I start cooking up this change, is it possible I need to worry about
gcov_error being invoked from multiple threads? If so, I'll need some
kind of mutex which I think is not needed with the current design.


As I recall the main entry points to the gcov machinery (__gcov_dump etc) have a 
lock already.  So I think you're ok.


nathan



Re: [RFC] [PATCH] Add __array_size keyword

2016-02-23 Thread Stuart Brady
On Wed, Feb 17, 2016 at 12:29:34AM +, Stuart Brady wrote:
> > - should __array_size (b) be an integer constant (size_t)2, or should it 
> > be non-constant (size_t)2 because the argument is a VLA (albeit a VLA 
> > whose top-level dimension is an integer constant expression)?
> 
> Ouch.  I would say it should be an integer constant (size_t)2, simply as
> that seems to me to be a reasonable expectation.  Unfortunately, this is
> not what happens with my patch, as I get a -Wint-conversion warning. :-(

[snip]

Okay.  So, unsurprisingly, it turns out the problem here was in my code.
When I added c_expr_array_size_expr() and c_expr_array_size_type() it
seems I had not understood that C_TYPE_VARIABLE_SIZE and therefore also
c_vla_type_p are non-zero (true) for VLAs where the outermost subscript
is not variable, behaviour I can now clearly see in grokdeclarator().

This certainly supports the notion that test cases and documentation are
of greater importance than the patch itself, at this stage.

I now seem to have an __array_size keyword that behaves as I would expect
in this case, too.  I'll resubmit the patch once I have gone through the
final draft of C11.

It is still not entirely clear to me whether I must do something to
prevent constant folding for use of __array_size with VLAs, but I am not
so highly concerned just at the moment.
-- 
Many thanks,
Stuart Brady


[committed] Remove __seg_tls before first release

2016-02-23 Thread Richard Henderson
The addition of named address spaces to the i386 backend is new for gcc6.

I had invented __seg_tls while thinking about how it might be used within
glibc.  But during the last couple of weeks I've had occasion to attempt to use
the feature within the linux kernel.  There, things weren't quite so easy.

My conclusion is that __seg_tls is too specialized, and that what's really
needed is user-defined named address spaces, so that each project can define
its own mapping between segment base and the generic (flat) address space.

Therefore I have deleted __seg_tls before the first release, so that we don't
have to support this going forward.  The __seg_fs and __seg_gs namespaces are
still present in gcc6, and (with effort and casting) these can still be used to
produce memory references with segment overrides.


r~
* config/i386/i386-c.c (ix86_target_macros): Remove __SEG_TLS.
(ix86_register_pragmas): Remove __seg_tls.
* config/i386/i386-protos.h (ADDR_SPACE_SEG_TLS): Remove.
* config/i386/i386.c (ix86_print_operand_address_as): Don't handle it.
(ix86_addr_space_subset_p, TARGET_ADDR_SPACE_SUBSET_P): Remove.
(ix86_addr_space_convert, TARGET_ADDR_SPACE_CONVERT): Remove.
(ix86_addr_space_debug, TARGET_ADDR_SPACE_DEBUG): Remove.
* doc/extend.texi (__seg_tls): Remove item.
testsuite/
* gcc.target/i386/addr-space-3.c: Remove test.


diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c
index ea0c5df..f93a09d 100644
--- a/gcc/config/i386/i386-c.c
+++ b/gcc/config/i386/i386-c.c
@@ -591,7 +591,6 @@ ix86_target_macros (void)
 
   cpp_define (parse_in, "__SEG_FS");
   cpp_define (parse_in, "__SEG_GS");
-  cpp_define (parse_in, "__SEG_TLS");
 }
 
 
@@ -608,7 +607,6 @@ ix86_register_pragmas (void)
 
   c_register_addr_space ("__seg_fs", ADDR_SPACE_SEG_FS);
   c_register_addr_space ("__seg_gs", ADDR_SPACE_SEG_GS);
-  c_register_addr_space ("__seg_tls", ADDR_SPACE_SEG_TLS);
 
 #ifdef REGISTER_SUBTARGET_PRAGMAS
   REGISTER_SUBTARGET_PRAGMAS ();
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 252bb19..e4652f3 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -332,4 +332,3 @@ struct ix86_first_cycle_multipass_data_
 
 const addr_space_t ADDR_SPACE_SEG_FS = 1;
 const addr_space_t ADDR_SPACE_SEG_GS = 2;
-const addr_space_t ADDR_SPACE_SEG_TLS = 3;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 29c73f6..d8a2909 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -17395,8 +17395,6 @@ ix86_print_operand_address_as (FILE *file, rtx addr,
 {
   const char *string;
 
-  if (as == ADDR_SPACE_SEG_TLS)
-   as = DEFAULT_TLS_SEG_REG;
   if (as == ADDR_SPACE_SEG_FS)
string = (ASSEMBLER_DIALECT == ASM_ATT ? "%fs:" : "fs:");
   else if (as == ADDR_SPACE_SEG_GS)
@@ -54256,54 +54254,8 @@ ix86_optab_supported_p (int op, machine_mode mode1, 
machine_mode,
 without resorting to a system call, we cannot convert a
 non-default address space to a default address space.
 Therefore we do not claim %fs or %gs are subsets of generic.
-(e) However, __seg_tls uses UNSPEC_TP as the base (which itself is
-   stored at __seg_tls:0) so we can map between tls and generic.  */
 
-static bool
-ix86_addr_space_subset_p (addr_space_t subset, addr_space_t superset)
-{
-return (subset == superset
-   || (superset == ADDR_SPACE_GENERIC
-   && subset == ADDR_SPACE_SEG_TLS));
-}
-#undef TARGET_ADDR_SPACE_SUBSET_P
-#define TARGET_ADDR_SPACE_SUBSET_P ix86_addr_space_subset_p
-
-static rtx
-ix86_addr_space_convert (rtx op, tree from_type, tree to_type)
-{
-  addr_space_t from_as = TYPE_ADDR_SPACE (TREE_TYPE (from_type));
-  addr_space_t to_as = TYPE_ADDR_SPACE (TREE_TYPE (to_type));
-
-  /* Conversion between SEG_TLS and GENERIC is handled by adding or
- subtracting the thread pointer.  */
-  if ((from_as == ADDR_SPACE_GENERIC && to_as == ADDR_SPACE_SEG_TLS)
-  || (from_as == ADDR_SPACE_SEG_TLS && to_as == ADDR_SPACE_GENERIC))
-{
-  machine_mode mode = GET_MODE (op);
-  if (mode == VOIDmode)
-   mode = ptr_mode;
-  rtx tp = get_thread_pointer (mode, optimize || mode != ptr_mode);
-  return expand_binop (mode, (to_as == ADDR_SPACE_GENERIC
- ? add_optab : sub_optab),
-  op, tp, NULL, 1, OPTAB_WIDEN);
-}
-
-  return op;
-}
-#undef TARGET_ADDR_SPACE_CONVERT
-#define TARGET_ADDR_SPACE_CONVERT ix86_addr_space_convert
-
-static int
-ix86_addr_space_debug (addr_space_t as)
-{
-  /* Fold __seg_tls to __seg_fs or __seg_gs for debugging.  */
-  if (as == ADDR_SPACE_SEG_TLS)
-as = DEFAULT_TLS_SEG_REG;
-  return as;
-}
-#undef TARGET_ADDR_SPACE_DEBUG
-#define TARGET_ADDR_SPACE_DEBUG ix86_addr_space_debug
+   Therefore we can (mostly) use the default hooks.  */
 
 /* All use of segmentation is assumed to make address 0 valid

Re: [patch] Clarify interaction of -Wnarrowing with -std

2016-02-23 Thread Jonathan Wakely

On 19/02/16 13:17 -0700, Sandra Loosemore wrote:

On 02/19/2016 12:01 PM, Jason Merrill wrote:

On 02/19/2016 07:42 AM, Jonathan Wakely wrote:

In PR69864 Manu suggests improving the docs to explain that
-Wnarrowing sometimes produces errors not warnings.

I think the right way to do that is clarify how it interacts with
-std. Specifically that the effect of -Wnarrowing listed first in the
manual *only* applies to C++98 modes, For all later modes (not just
with -std=c++11 as it says now), narrowing conversions produce errors
or warnings by default.

OK for trunk?


OK, thanks.


I suppose the patch is OK as it stands, but I was going to suggest 
restructuring it so that it talks about the default behavior first and 
what it does with non-default -std= options after that, instead of 
vice-versa.  Unfortunately I am backlogged on other things right now 
and it might take me a day or two before I have time to come up with 
some alternate wording.  If we are in a rush, go ahead and commit the 
existing patch meanwhile, I guess.


Is this better?


diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 490df93..8d56efa 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2753,10 +2753,17 @@ During the link-time optimization warn about type mismatches in
 global declarations from different compilation units.
 Requires @option{-flto} to be enabled.  Enabled by default.
 
-@item -Wnarrowing @r{(C++ and Objective-C++ only)}
+@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
 @opindex Wnarrowing
 @opindex Wno-narrowing
-With @option{-std=gnu++98} or @option{-std=c++98}, warn when a narrowing
+For C++11 and later standards, narrowing conversions are diagnosed by default,
+as required by the standard.  A narrowing conversion from a constant produces
+an error, and a narrowing conversion from a non-constant produces a warning,
+but @option{-Wno-narrowing} suppresses the diagnostic.
+Note that this does not affect the meaning of well-formed code;
+narrowing conversions are still considered ill-formed in SFINAE contexts.
+
+With @option{-Wnarrowing} in C++98, warn when a narrowing
 conversion prohibited by C++11 occurs within
 @samp{@{ @}}, e.g.
 
@@ -2766,14 +2773,6 @@ int i = @{ 2.2 @}; // error: narrowing from double to int
 
 This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
 
-When a later standard is in effect, e.g. when using @option{-std=c++11},
-narrowing conversions are diagnosed by default, as required by the standard.
-A narrowing conversion from a constant produces an error,
-and a narrowing conversion from a non-constant produces a warning,
-but @option{-Wno-narrowing} suppresses the diagnostic.
-Note that this does not affect the meaning of well-formed code;
-narrowing conversions are still considered ill-formed in SFINAE contexts.
-
 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
 @opindex Wnoexcept
 @opindex Wno-noexcept


Re: [PATCH] Fix c_parser_for_statement for ObjC (PR objc/69844)

2016-02-23 Thread Marek Polacek
On Thu, Feb 18, 2016 at 10:39:02PM +0100, Jakub Jelinek wrote:
> Hi!
> 
> Here is an attempt to fix up the token reclassification after for statement,
> where we lexed the next token with the declaration from for in scope and
> need to undo that if it wasn't else.
> 
> If token->id_kind is C_ID_CLASSNAME (ObjC only), then token->value has
> changed already, but in that case I think it means we can just keep it as
> is, it can't be shadowed by the for init declaration (because it would be
> C_ID_ID or C_ID_TYPENAME? otherwise).
> Otherwise, this patch tries to model the handling closer to what
> c_lex_one_token does, i.e. set it to C_ID_ID, except when decl is non-NULL
> and TYPE_DECL, or for the ObjC case where for init declaration shadowed
> a class declaration.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2016-02-18  Jakub Jelinek  
> 
>   PR objc/69844
>   * c-parser.c (c_parser_for_statement): Properly handle ObjC classes
>   in id_kind reclassification.
> 
>   * objc.dg/pr69844.m: New test.
> 
> --- gcc/c/c-parser.c.jj   2016-02-16 16:29:54.0 +0100
> +++ gcc/c/c-parser.c  2016-02-18 17:36:55.025067859 +0100
> @@ -5887,12 +5887,27 @@ c_parser_for_statement (c_parser *parser
>  {
>c_token *token = c_parser_peek_token (parser);
>tree decl = lookup_name (token->value);
> -  if (decl == NULL_TREE || VAR_P (decl))
> - /* If DECL is null, we don't know what this token might be.  Treat
> -it as an ID for better diagnostics; we'll error later on.  */
> - token->id_kind = C_ID_ID;
> -  else if (TREE_CODE (decl) == TYPE_DECL)
> - token->id_kind = C_ID_TYPENAME;
> +  if (token->id_kind != C_ID_CLASSNAME)
> + {
> +   token->id_kind = C_ID_ID;

I think let's sink the lookup_name call here.  If id_kind is C_ID_CLASSNAME
we're not looking at decl at all.

> +   if (decl)
> + {
> +   if (TREE_CODE (decl) == TYPE_DECL)
> + token->id_kind = C_ID_TYPENAME;
> + }
> +   else if (c_dialect_objc ())
> + {
> +   tree objc_interface_decl = objc_is_class_name (token->value);

This objc_is_class_name is a weird stub that always returns NULL_TREE but
I know that the same code is in c_lex_one_token so let's keep it this way.

I've tried a bunch of invalid ObjC testcases and saw no ICEs and from the
C point of view this patch is safe.

Ok with that lookup_name change, thanks.

Marek


Re: [PATCH] New plugin events when evaluating constexpr expressions.

2016-02-23 Thread Daniel Gutson
On Tue, Nov 3, 2015 at 9:09 AM, Andres Tiraboschi
 wrote:
>  Hi
>  This patch adds two plugins events when evaluated call expression and
> an init or modify expression in constexpr.
>  The goal of this patch is to allow the plugins to analyze and or
> modify the evaluation of constant expressions.
>
>  This patch also adds an event that is called when the parsing of a
> file is finished.

ping

Any update on this?

Thanks!

   Daniel.

>
> Thanks,
> Andrés.



-- 

Daniel F. Gutson
Chief Engineering Officer, SPD

San Lorenzo 47, 3rd Floor, Office 5
Córdoba, Argentina

Phone:   +54 351 4217888 / +54 351 4218211
Skype:dgutson
LinkedIn: http://ar.linkedin.com/in/danielgutson


Re: [PATCH] Fix c_parser_for_statement for ObjC (PR objc/69844)

2016-02-23 Thread Jakub Jelinek
On Tue, Feb 23, 2016 at 08:24:06PM +0100, Marek Polacek wrote:
> > --- gcc/c/c-parser.c.jj 2016-02-16 16:29:54.0 +0100
> > +++ gcc/c/c-parser.c2016-02-18 17:36:55.025067859 +0100
> > @@ -5887,12 +5887,27 @@ c_parser_for_statement (c_parser *parser
> >  {
> >c_token *token = c_parser_peek_token (parser);
> >tree decl = lookup_name (token->value);
> > -  if (decl == NULL_TREE || VAR_P (decl))
> > -   /* If DECL is null, we don't know what this token might be.  Treat
> > -  it as an ID for better diagnostics; we'll error later on.  */
> > -   token->id_kind = C_ID_ID;
> > -  else if (TREE_CODE (decl) == TYPE_DECL)
> > -   token->id_kind = C_ID_TYPENAME;
> > +  if (token->id_kind != C_ID_CLASSNAME)
> > +   {
> > + token->id_kind = C_ID_ID;
> 
> I think let's sink the lookup_name call here.  If id_kind is C_ID_CLASSNAME
> we're not looking at decl at all.

Done (and committed).  Thanks for review.

> > + if (decl)
> > +   {
> > + if (TREE_CODE (decl) == TYPE_DECL)
> > +   token->id_kind = C_ID_TYPENAME;
> > +   }
> > + else if (c_dialect_objc ())
> > +   {
> > + tree objc_interface_decl = objc_is_class_name (token->value);
> 
> This objc_is_class_name is a weird stub that always returns NULL_TREE but

It is a weird stub only in the cc1 binary, in cc1obj binary it comes from
objc/objc-act.c and does various ObjC magic.

Jakub


[patch] libstdc++/69893 make work with C++11

2016-02-23 Thread Jonathan Wakely

The  header was implicitly relying on the fact that the
additional overloads defined by C++11 were not added to the global
namespace, so that it could do "using ::acosh;" to get the C library's
acosh(double) declaration only, and not the C++11 overloads.

With the new  in GCC 6 that no longer works, because including
 before  means that "using ::acosh;" adds all the
C++11 overloads to namespace std::tr1, and then adding new overloads
with the same signatures is an error. (The same error can be triggered
in earlier versions of GCC with an explicit "using std::acosh;" at
global scope before including ).

The solution is to use the C++11 functions when possible, via "using
std::acosh;", and not add anything extra to namespace std::tr1. For
C++03 the additional overloads aren't in namespace std, so we continue
to define them explicitly in namespace std::tr1.

The new  also breaks the special handling for tr1::fabs,
because "using ::fabs;" might now bring in the unwanted std::fabs
overload for std::complex<>. The solution is similar to what is
already done for tr1::pow. I reworded the comment for tr1::pow,
because the problem being solved wasn't very clear to me at first
(even though I was already dealing with the same issue for fabs!)

Tested x86_64-linux, committed to trunk.

commit e8c6279426372f6b4469ee09e61d8c95422d3aa7
Author: Jonathan Wakely 
Date:   Mon Feb 22 23:52:26 2016 +

libstdc++/69893 make  work with C++11

	PR libstdc++/69893
	* include/tr1/cmath (acosh, asinh, atanh, cbrt, copysign, erf, erfc,
	exp2, expm1, fdim, fma, fmax, fmin, hypot, ilogb, lgamma, llrint,
	llround, log1p, log2, logb, lrint, lround, nan, nearbyint, nextafter,
	nexttoward, remainder, remquo, rint, round, scalbln, scalbn, tgamma,
	trunc) [__cplusplus >= 201103L]: Import from namespace std.
	(fabs) [__cplusplus < 201103L]: Import from namespace std.
	* include/tr1/complex (acosh, asinh, atanh) [__cplusplus >= 201103L]:
	Likewise.
	* testsuite/tr1/headers/c++200x/complex.cc: Add std::fabs to global
	namespace before including TR1 headers.
	* testsuite/tr1/headers/c++200x/math.cc: New test.

diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath
index 14737e3..48466a0 100644
--- a/libstdc++-v3/include/tr1/cmath
+++ b/libstdc++-v3/include/tr1/cmath
@@ -151,6 +151,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if _GLIBCXX_USE_C99_MATH_TR1
 
+  // Using declarations to bring names from libc's  into std::tr1.
+
   // types
   using ::double_t;
   using ::float_t;
@@ -416,8 +418,77 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if _GLIBCXX_USE_C99_MATH_TR1
 
-  /// Additional overloads [8.16.4].
+  /** Additional overloads [8.16.4].
+   *  @{
+   */
+
+  // For functions defined in C++03 the additional overloads are already
+  // declared in  so we can just re-declare them in std::tr1.
+
   using std::acos;
+  using std::asin;
+  using std::atan;
+  using std::atan2;
+  using std::ceil;
+  using std::cos;
+  using std::cosh;
+  using std::exp;
+  using std::floor;
+  using std::fmod;
+  using std::frexp;
+  using std::ldexp;
+  using std::log;
+  using std::log10;
+  using std::sin;
+  using std::sinh;
+  using std::sqrt;
+  using std::tan;
+  using std::tanh;
+
+#if __cplusplus >= 201103L
+
+  // Since C++11,  defines additional overloads for these functions
+  // in namespace std.
+
+  using std::acosh;
+  using std::asinh;
+  using std::atanh;
+  using std::cbrt;
+  using std::copysign;
+  using std::erf;
+  using std::erfc;
+  using std::exp2;
+  using std::expm1;
+  using std::fdim;
+  using std::fma;
+  using std::fmax;
+  using std::fmin;
+  using std::hypot;
+  using std::ilogb;
+  using std::lgamma;
+  using std::llrint;
+  using std::llround;
+  using std::log1p;
+  using std::log2;
+  using std::logb;
+  using std::lrint;
+  using std::lround;
+  using std::nan;
+  using std::nearbyint;
+  using std::nextafter;
+  using std::nexttoward;
+  using std::remainder;
+  using std::remquo;
+  using std::rint;
+  using std::round;
+  using std::scalbln;
+  using std::scalbn;
+  using std::tgamma;
+  using std::trunc;
+
+#else // __cplusplus < 201103L
+
+  // In C++03 we need to provide the additional overloads.
 
 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
   inline float
@@ -435,8 +506,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 acosh(_Tp __x)
 { return __builtin_acosh(__x); }
 
-  using std::asin;
-
 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
   inline float
   asinh(float __x)
@@ -453,9 +522,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 asinh(_Tp __x)
 { return __builtin_asinh(__x); }
 
-  using std::atan;
-  using std::atan2;
-
 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
   inline float
   atanh(float __x)
@@ -488,8 +554,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 cbrt(_Tp __x)
 { return __builtin_cbrt(__x); }
 
-  using std::ceil;
-
 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
   inline float
   copysign(float __x, float __y)
@@ -508,9 +572,6 @@ _GLIBCXX_BEG

[patch] Document __STDCPP_WANT_MATH_SPEC_FUNCS__ macro

2016-02-23 Thread Jonathan Wakely

Committed to trunk.

commit 6da32ab58d56e2909ed39e5fc2170717ad26e895
Author: Jonathan Wakely 
Date:   Tue Feb 23 20:01:35 2016 +

Document __STDCPP_WANT_MATH_SPEC_FUNCS__ macro

	* doc/xml/manual/using.xml: Document __STDCPP_WANT_MATH_SPEC_FUNCS__.
	* doc/html/*: Regenerate.

diff --git a/libstdc++-v3/doc/html/manual/using_macros.html b/libstdc++-v3/doc/html/manual/using_macros.html
index 6b1fc1e..2ef05af 100644
--- a/libstdc++-v3/doc/html/manual/using_macros.html
+++ b/libstdc++-v3/doc/html/manual/using_macros.html
@@ -89,4 +89,6 @@
   _GLIBCXX_PROFILEUndefined by default. When defined, compiles user code
 	using the profile
 	mode.
+  __STDCPP_WANT_MATH_SPEC_FUNCS__Undefined by default. When defined to a non-zero integer constant,
+	enables support for ISO/IEC 29124 Special Math Functions.
   Prev??Up??NextHeaders??Home??Dual ABI
\ No newline at end of file
diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml
index 96ae686..6e022d5 100644
--- a/libstdc++-v3/doc/xml/manual/using.xml
+++ b/libstdc++-v3/doc/xml/manual/using.xml
@@ -955,6 +955,13 @@ g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe
 	mode.
   
 
+
+__STDCPP_WANT_MATH_SPEC_FUNCS__
+
+  Undefined by default. When defined to a non-zero integer constant,
+	enables support for ISO/IEC 29124 Special Math Functions.
+  
+
 
 
   


[PATCH] Fix thinko in build_vector_from_ctor (PR middle-end/69915)

2016-02-23 Thread Jakub Jelinek
Hi!

This function has changed last year to support embedded VECTOR_CSTs in the
ctor elements.  Before that change, there was no pos var and idx used to
match exactly the indices in the new vector, but if there is any VECTOR_CST,
it will fill in more positions.
Unfortunately, the final loop which zeros in any positions not filled in yet
has not changed, which is wrong for the case when there were any
VECTOR_CSTs.  E.g. on the testcase, we have a V16HImode type ctor which
contains two V8HImode VECTOR_CSTs (full of zeros).  Each of them fills in
8 positions, so the final loop shouldn't add anything, but as idx at that
point is 2, it will add further 14 elements, resulting in alloca
buffer overflow.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2016-02-23  Jakub Jelinek  

PR middle-end/69915
* tree.c (build_vector_from_ctor): Fix handling of VECTOR_CST
elements.

* gcc.dg/pr69915.c: New test.

--- gcc/tree.c.jj   2016-02-08 18:39:17.0 +0100
+++ gcc/tree.c  2016-02-23 15:50:03.566700694 +0100
@@ -1749,7 +1749,7 @@ build_vector_from_ctor (tree type, vec

[PATCH] Bump max-ssa-name-query-depth default (PR c/69918)

2016-02-23 Thread Jakub Jelinek
Hi!

As mentioned in the PR, the builtin-integral-1.c testcase fails on
i?86 Solaris.  The problem is that on Solaris the dg-add-options c99_runtime 
adds -std=c99, which turns -fexcess-precision=standard, and that on some
arches changes
  _388 = (double) i1_63(D);
  _389 = (double) i2_335(D);
  _390 = _388 * _389;
  _391 = (long double) _390;
  _392 = __builtin_ceill (_391);
into
  _398 = (double) i1_63(D);
  _399 = (long double) _398;
  _400 = (double) i2_335(D);
  _401 = (long double) _400;
  _402 = _399 * _401;
  _403 = __builtin_ceill (_402);
But the default value of the max-ssa-name-query-depth param prevents in this
case from recognizing the argument to __builtin_ciell will always be
integral value.  We have the possibility to either tweak the testcase
(e.g. add -fexcess-precision=fast, or --param max-ssa-name-query-depth=3),
or change the IMHO way too low default.  As only the latter will help
for excess precision code in real-world even for simple addition of two
values, I think it is best to bump the default.  Perhaps even 5 wouldn't
hurt, but maybe we can increase it more for gcc 7.

Bootstrapped/regtested on x86_64-linux and i686-linux, tested on the
testcase using cross to i386-pc-solaris2.11.  Ok for trunk?

2016-02-23  Jakub Jelinek  

PR c/69918
* params.def (PARAM_MAX_SSA_NAME_QUERY_DEPTH): Bump default from
2 to 3.

--- gcc/params.def.jj   2016-02-01 23:34:34.0 +0100
+++ gcc/params.def  2016-02-23 18:43:04.359322654 +0100
@@ -1191,7 +1191,7 @@ DEFPARAM (PARAM_MAX_SSA_NAME_QUERY_DEPTH
  "max-ssa-name-query-depth",
  "Maximum recursion depth allowed when querying a property of an"
  " SSA name.",
- 2, 1, 0)
+ 3, 1, 0)
 
 DEFPARAM (PARAM_MAX_RTL_IF_CONVERSION_INSNS,
  "max-rtl-if-conversion-insns",

Jakub


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

2016-02-23 Thread Eelis

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

Thanks,

Eelis
Index: libstdc++-v3/include/debug/formatter.h
===
--- libstdc++-v3/include/debug/formatter.h	(revision 233636)
+++ libstdc++-v3/include/debug/formatter.h	(working copy)
@@ -87,6 +87,8 @@
 __msg_splice_bad,
 __msg_splice_other,
 __msg_splice_overlap,
+// std::initializer_list checks
+__msg_empty_init_list,
 // iterator checks
 __msg_init_singular,
 __msg_init_copy_singular,
Index: libstdc++-v3/src/c++11/debug.cc
===
--- libstdc++-v3/src/c++11/debug.cc	(revision 233636)
+++ libstdc++-v3/src/c++11/debug.cc	(working copy)
@@ -139,6 +139,8 @@
 "attempt to splice an iterator from a different container",
 "splice destination %1.name;"
 " occurs within source range [%2.name;, %3.name;)",
+// std::initializer_list checks
+"%1;(): empty initializer_list",
 // iterator checks
 "attempt to initialize an iterator that will immediately become singular",
 "attempt to copy-construct an iterator from a singular iterator",
Index: libstdc++-v3/include/debug/macros.h
===
--- libstdc++-v3/include/debug/macros.h	(revision 233636)
+++ libstdc++-v3/include/debug/macros.h	(working copy)
@@ -69,6 +69,12 @@
 		  ._M_iterator(_First, #_First)			\
 		  ._M_iterator(_Last, #_Last))
 
+// Verify that the initializer_list is non-empty.
+#define __glibcxx_check_non_empty_init_list(_List)			\
+_GLIBCXX_DEBUG_VERIFY(_List.size() != 0,\
+		  _M_message(__gnu_debug::__msg_empty_init_list)	\
+		  ._M_string(__func__))
+
 /** Verify that we can insert into *this with the iterator _Position.
  *  Insertion into a container at a specific position requires that
  *  the iterator be nonsingular, either dereferenceable or past-the-end,
Index: libstdc++-v3/include/debug/debug.h
===
--- libstdc++-v3/include/debug/debug.h	(revision 233636)
+++ libstdc++-v3/include/debug/debug.h	(working copy)
@@ -62,6 +62,7 @@
 
 # define __glibcxx_requires_cond(_Cond,_Msg)
 # define __glibcxx_requires_valid_range(_First,_Last)
+# define __glibcxx_requires_non_empty_init_list(_List)
 # define __glibcxx_requires_sorted(_First,_Last)
 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
@@ -99,6 +100,8 @@
 # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
 # define __glibcxx_requires_valid_range(_First,_Last)	\
   __glibcxx_check_valid_range(_First,_Last)
+# define __glibcxx_requires_non_empty_init_list(_List)	\
+  __glibcxx_check_non_empty_init_list(_List)
 # define __glibcxx_requires_non_empty_range(_First,_Last)	\
   __glibcxx_check_non_empty_range(_First,_Last)
 # define __glibcxx_requires_sorted(_First,_Last)	\
Index: libstdc++-v3/include/bits/stl_algo.h
===
--- libstdc++-v3/include/bits/stl_algo.h	(revision 233636)
+++ libstdc++-v3/include/bits/stl_algo.h	(working copy)
@@ -3452,25 +3452,37 @@
 _GLIBCXX14_CONSTEXPR
 inline _Tp
 min(initializer_list<_Tp> __l)
-{ return *std::min_element(__l.begin(), __l.end()); }
+{
+  __glibcxx_requires_non_empty_init_list(__l);
+  return *std::min_element(__l.begin(), __l.end());
+}
 
   template
 _GLIBCXX14_CONSTEXPR
 inline _Tp
 min(initializer_list<_Tp> __l, _Compare __comp)
-{ return *std::min_element(__l.begin(), __l.end(), __comp); }
+{
+  __glibcxx_requires_non_empty_init_list(__l);
+  return *std::min_element(__l.begin(), __l.end(), __comp);
+}
 
   template
 _GLIBCXX14_CONSTEXPR
 inline _Tp
 max(initializer_list<_Tp> __l)
-{ return *std::max_element(__l.begin(), __l.end()); }
+{
+  __glibcxx_requires_non_empty_init_list(__l);
+  return *std::max_element(__l.begin(), __l.end());
+}
 
   template
 _GLIBCXX14_CONSTEXPR
 inline _Tp
 max(initializer_list<_Tp> __l, _Compare __comp)
-{ return *std::max_element(__l.begin(), __l.end(), __comp); }
+{
+  __glibcxx_requires_non_empty_init_list(__l);
+  return *std::max_element(__l.begin(), __l.end(), __comp);
+}
 
   template
 _GLIBCXX14_CONSTEXPR
@@ -3477,6 +3489,7 @@
 inline pair<_Tp, _Tp>
 minmax(initializer_list<_Tp> __l)
 {
+  __glibcxx_requires_non_empty_init_list(__l);
   pair __p =
 	std::minmax_element(__l.begin(), __l.end());
   return std::make_pair(*__p.first, *__p.second);
@@ -3487,6 +3500,7 @@
 inline pair<_Tp, _Tp>
 minmax(initializer_list<_Tp> __l, _Compare __comp)
 {
+  __glibcxx_requires_non_empty_init_list(__l)

[COMMITTED][AArch64] Tweak the pipeline model for Exynos M1

2016-02-23 Thread Evandro Menezes

Minor tweaks to the cost and scheduling models for Exynos M1.

Committed as r233646 and r233647.

--
Evandro Menezes

>From ab6127823e706361315f1c8b87fb4c32bc299b65 Mon Sep 17 00:00:00 2001
From: evandro 
Date: Tue, 23 Feb 2016 20:21:23 +
Subject: [PATCH 1/2] * gcc/config/aarch64/aarch64.c
 (exynosm1_tunings): Enable the Newton series for reciprocal square
 root in Exynos M1.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233646 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog| 5 +
 gcc/config/aarch64/aarch64.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3c629ef..22dd022 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-23  Evandro Menezes  
+
+* config/aarch64/aarch64.c (exynosm1_tunings): Enable the Newton
+series for reciprocal square root in Exynos M1.
+
 2016-02-23  Martin Sebor  
 
 	PR c/69759
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 923a4b3..dc3dfea 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -538,7 +538,7 @@ static const struct tune_params exynosm1_tunings =
   48,	/* max_case_values.  */
   64,	/* cache_line_size.  */
   tune_params::AUTOPREFETCHER_OFF, /* autoprefetcher_model.  */
-  (AARCH64_EXTRA_TUNE_NONE) /* tune_flags.  */
+  (AARCH64_EXTRA_TUNE_RECIP_SQRT) /* tune_flags.  */
 };
 
 static const struct tune_params thunderx_tunings =
-- 
1.9.1

>From 01cadc5b883a2613f847aa7a88b86aed454d9413 Mon Sep 17 00:00:00 2001
From: evandro 
Date: Tue, 23 Feb 2016 21:31:00 +
Subject: [PATCH 2/2] Tweak the pipeline model for Exynos M1

gcc/
	* config/aarch64/aarch64.c (exynosm1_tunings): Enable fusion of AES{D,E}
	and AESMC pairs.
	* config/arm/exynos-m1.md: Change cost of STP, fix bypass for stores
	and add bypass for AES{D,E} and AESMC pairs.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233647 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog|  7 +++
 gcc/config/aarch64/aarch64.c |  2 +-
 gcc/config/arm/exynos-m1.md  | 26 +-
 3 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 22dd022..07b50b5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
 2016-02-23  Evandro Menezes  
 
+	* config/arm/exynos-m1.md: Change cost of STP, fix bypass for stores
+	and add bypass for AES{D,E} and AESMC pairs.
+	* config/aarch64/aarch64.c (exynosm1_tunings): Enable fusion of AES{D,E}
+	and AESMC pairs.
+
+2016-02-23  Evandro Menezes  
+
 * config/aarch64/aarch64.c (exynosm1_tunings): Enable the Newton
 series for reciprocal square root in Exynos M1.
 
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index dc3dfea..6dc8330 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -526,7 +526,7 @@ static const struct tune_params exynosm1_tunings =
   &generic_branch_cost,
   4,	/* memmov_cost  */
   3,	/* issue_rate  */
-  (AARCH64_FUSE_NOTHING), /* fusible_ops  */
+  (AARCH64_FUSE_AES_AESMC), /* fusible_ops  */
   4,	/* function_align.  */
   4,	/* jump_align.  */
   4,	/* loop_align.  */
diff --git a/gcc/config/arm/exynos-m1.md b/gcc/config/arm/exynos-m1.md
index 2f52b22..318b151 100644
--- a/gcc/config/arm/exynos-m1.md
+++ b/gcc/config/arm/exynos-m1.md
@@ -248,10 +248,6 @@
 	  (eq_attr "type" "neon_load4_all_lanes, neon_load4_all_lanes_q")
 	(const_string "neon_load4_all")
 
-	  (eq_attr "type" "f_stores, f_stored,\
-			   neon_stp, neon_stp_q")
-	(const_string "neon_store")
-
 	  (eq_attr "type" "neon_store1_1reg, neon_store1_1reg_q")
 	(const_string "neon_store1_1")
 
@@ -730,8 +726,14 @@
 (define_insn_reservation
   "exynos_m1_neon_store" 1
   (and (eq_attr "tune" "exynosm1")
-   (eq_attr "exynos_m1_neon_type" "neon_store"))
-  "(em1_fst, em1_st)")
+   (eq_attr "type" "f_stores, f_stored, neon_stp"))
+  "em1_sfst")
+
+(define_insn_reservation
+  "exynos_m1_neon_store_q" 3
+  (and (eq_attr "tune" "exynosm1")
+   (eq_attr "type" "neon_stp_q"))
+  "(em1_sfst * 2)")
 
 (define_insn_reservation
   "exynos_m1_neon_store1_1" 1
@@ -761,7 +763,7 @@
   "exynos_m1_neon_store1_one" 7
   (and (eq_attr "tune" "exynosm1")
(eq_attr "exynos_m1_neon_type" "neon_store1_one"))
-  "(em1_fst, em1_st)")
+  "em1_sfst")
 
 (define_insn_reservation
   "exynos_m1_neon_store2" 7
@@ -892,7 +894,9 @@
 
 ;; Pre-decrement and post-increment addressing modes update the register quickly.
 ;; TODO: figure out how to tell the addressing mode register from the loaded one.
-(define_bypass 1 "exynos_m1_store*" "exynos_m1_store*")
+(define_bypass 1 "exynos_m1_store*, exynos_m1_neon_store*"
+		 "exynos_m1_store*, exynos_m1_neon_store*,
+		  exynos_m1_load*, exynos_m1_neon_load*")
 
 ;; MLAs can feed other MLAs quickly.
 (define_bypass 1 "exynos_m1_mla*" "exynos_m1_mla*")
@@ -908,7 +912,6 @@
 (define_bypass 5 "exynos_m1_neon_fp_

[PATCH] Fix PR target/69810

2016-02-23 Thread David Edelsohn
Anton reported a latent bug in the rs6000 port discovered with csmith.
Splitters for extendqihi2 and zero_extendqihi2 can generate invalid
compare RTL.  PowerPC can load and store bytes or halfwords, but
computations operate on registers.  Currently the extend patterns
exist for HImode, although no instructions directly operate on
registers in that mode.

For GCC 7, I plan to disable the extendqihi2 and zero_extendqihi2
patterns, forcing GCC to use SUBREGs, but that is too dangerous for
Stage 4.

In the interim, this patch converts the splitters to normal combiner
patterns that directly emit the two instruction sequence when cr0 is
not available.  There is not a lot of scheduling opportunity after the
splitter, so not a huge degradation.  The temporary is allocated as
HImode, but always is a full register.  The compare is hard coded as
cmpw, but the condition bits will be the same for sign-extended or
zero-extended QImode whether the register is interpreted as word or
doubleword.

PR target/69810
* config/rs6000/rs6000.md (zero_extendqi2_dot): Convert from
define_insn_and_split to define_insn.
(zero_extendqi2_dot2): Same.
(extendqi2_dot): Same.
(extendqi2_dot2): Same.

Bootstrapped on powerpc-ibm-aix7.1.0.0 and powerpc64le-linux.

Thanks, David
Index: rs6000.md
===
--- rs6000.md   (revision 232439)
+++ rs6000.md   (working copy)
@@ -701,7 +701,7 @@
rlwinm %0,%1,0,0xff"
   [(set_attr "type" "load,shift")])
 
-(define_insn_and_split "*zero_extendqi2_dot"
+(define_insn "*zero_extendqi2_dot"
   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
(compare:CC (zero_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" 
"r,r"))
(const_int 0)))
@@ -709,19 +709,12 @@
   "rs6000_gen_cell_microcode"
   "@
andi. %0,%1,0xff
-   #"
-  "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
-  [(set (match_dup 0)
-   (zero_extend:EXTQI (match_dup 1)))
-   (set (match_dup 2)
-   (compare:CC (match_dup 0)
-   (const_int 0)))]
-  ""
+   rlwinm %0,%1,0,0xff\;cmpwi %2,%0,0"
   [(set_attr "type" "logical")
(set_attr "dot" "yes")
(set_attr "length" "4,8")])
 
-(define_insn_and_split "*zero_extendqi2_dot2"
+(define_insn "*zero_extendqi2_dot2"
   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
(compare:CC (zero_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" 
"r,r"))
(const_int 0)))
@@ -730,14 +723,7 @@
   "rs6000_gen_cell_microcode"
   "@
andi. %0,%1,0xff
-   #"
-  "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
-  [(set (match_dup 0)
-   (zero_extend:EXTQI (match_dup 1)))
-   (set (match_dup 2)
-   (compare:CC (match_dup 0)
-   (const_int 0)))]
-  ""
+   rlwinm %0,%1,0,0xff\;cmpwi %2,%0,0"
   [(set_attr "type" "logical")
(set_attr "dot" "yes")
(set_attr "length" "4,8")])
@@ -855,7 +841,7 @@
   "extsb %0,%1"
   [(set_attr "type" "exts")])
 
-(define_insn_and_split "*extendqi2_dot"
+(define_insn "*extendqi2_dot"
   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
(compare:CC (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" 
"r,r"))
(const_int 0)))
@@ -863,19 +849,12 @@
   "rs6000_gen_cell_microcode"
   "@
extsb. %0,%1
-   #"
-  "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
-  [(set (match_dup 0)
-   (sign_extend:EXTQI (match_dup 1)))
-   (set (match_dup 2)
-   (compare:CC (match_dup 0)
-   (const_int 0)))]
-  ""
+   extsb %0,%1\;cmpwi %2,%0,0"
   [(set_attr "type" "exts")
(set_attr "dot" "yes")
(set_attr "length" "4,8")])
 
-(define_insn_and_split "*extendqi2_dot2"
+(define_insn "*extendqi2_dot2"
   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
(compare:CC (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" 
"r,r"))
(const_int 0)))
@@ -884,14 +863,7 @@
   "rs6000_gen_cell_microcode"
   "@
extsb. %0,%1
-   #"
-  "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
-  [(set (match_dup 0)
-   (sign_extend:EXTQI (match_dup 1)))
-   (set (match_dup 2)
-   (compare:CC (match_dup 0)
-   (const_int 0)))]
-  ""
+   extsb %0,%1\;cmpwi %2,%0,0"
   [(set_attr "type" "exts")
(set_attr "dot" "yes")
(set_attr "length" "4,8")])


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

2016-02-23 Thread Jonathan Wakely

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

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


Nice, thanks for the patch.


Thanks,

Eelis



Index: libstdc++-v3/include/debug/formatter.h
===
--- libstdc++-v3/include/debug/formatter.h  (revision 233636)
+++ libstdc++-v3/include/debug/formatter.h  (working copy)
@@ -87,6 +87,8 @@
__msg_splice_bad,
__msg_splice_other,
__msg_splice_overlap,
+// std::initializer_list checks
+__msg_empty_init_list,
// iterator checks
__msg_init_singular,
__msg_init_copy_singular,
Index: libstdc++-v3/src/c++11/debug.cc
===
--- libstdc++-v3/src/c++11/debug.cc (revision 233636)
+++ libstdc++-v3/src/c++11/debug.cc (working copy)
@@ -139,6 +139,8 @@
"attempt to splice an iterator from a different container",
"splice destination %1.name;"
" occurs within source range [%2.name;, %3.name;)",
+// std::initializer_list checks
+"%1;(): empty initializer_list",
// iterator checks
"attempt to initialize an iterator that will immediately become singular",
"attempt to copy-construct an iterator from a singular iterator",


New entries should go at the end, so you don't alter the positions of
existing entries.



Index: libstdc++-v3/include/debug/macros.h
===
--- libstdc++-v3/include/debug/macros.h (revision 233636)
+++ libstdc++-v3/include/debug/macros.h (working copy)
@@ -69,6 +69,12 @@
  ._M_iterator(_First, #_First) \
  ._M_iterator(_Last, #_Last))

+// Verify that the initializer_list is non-empty.
+#define __glibcxx_check_non_empty_init_list(_List) \
+_GLIBCXX_DEBUG_VERIFY(_List.size() != 0,   \
+ _M_message(__gnu_debug::__msg_empty_init_list)\
+ ._M_string(__func__))
+
/** Verify that we can insert into *this with the iterator _Position.
 *  Insertion into a container at a specific position requires that
 *  the iterator be nonsingular, either dereferenceable or past-the-end,
Index: libstdc++-v3/include/debug/debug.h
===
--- libstdc++-v3/include/debug/debug.h  (revision 233636)
+++ libstdc++-v3/include/debug/debug.h  (working copy)
@@ -62,6 +62,7 @@

# define __glibcxx_requires_cond(_Cond,_Msg)
# define __glibcxx_requires_valid_range(_First,_Last)
+# define __glibcxx_requires_non_empty_init_list(_List)
# define __glibcxx_requires_sorted(_First,_Last)
# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
# define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)


This should be enabled for _GLIBCXX_ASSERTIONS not only
_GLIBCXX_DEBUG.

Otherwise this looks good, but will have to wait until after the GCC 6
release now. If I forget about it please send a ping email to remind
us once GCC 6 has been released, thanks.





Re: Fix/work around PR57676, LRA terminates prematurely

2016-02-23 Thread Vladimir Makarov

On 02/23/2016 06:56 AM, Richard Biener wrote:

On Mon, Feb 22, 2016 at 4:34 PM, Jeff Law  wrote:

On 02/22/2016 07:34 AM, Richard Biener wrote:


Hum, but then you get to "inifinite" compiles again when LRA is buggy
or the user presents it with an impossible to handle asm.

Neither should be happening in practice, even an impossible asm should cause
LRA to halt in some way or another.

In practice looping has occurred due to bugs in machine descriptions are are
typically seen during development/porting.  Hence the desire to put it under
-fchecking for gcc-6 and possibly implement something smarter for gcc-7
(where we'd track more precisely whether or not we're making forward
progress).


I don't think that's a good idea - maybe bumping the limit is the way to
go instead?

No, because one just needs to build a longer chain of insns needing
reloading.


30 constraint passes sounds excessive and a sign of a bug to me anyway.

Not really.  If you look at the testcase and the chain of reloads, it's
legitimate.  Essentially each pass exposes a case where spill a register in
an insn that previously had a register allocated.

But requiring another full reload pass to handle such chains is pointing at
a wrong algorithm IMHO.  Isn't this also quadratic in the length of the chain?

This is a pathological case.  It is not quadratic although we have 
quadratic algorithms already in GCC.  IRA building conflict graphs (as 
the old global.c)  can be quadratic for some pathological cases.  
Actually reload + IRA can be slow as LRA for this case too if we takes 
into account that reload is asking IRA to reallocate a spilled pseudo 
each time.


But you are right for this case we can speed up LRA for such cases 
considering rebuilding live info only for places where there are 
changes.  Probably it will speed up most other cases too.


Re: better debug info for C++ cdtors, aliases, thunks and other trampolines

2016-02-23 Thread Alexandre Oliva
Hi, Richard,

Thanks for the feedback.  I'm afraid I can't quite figure out what
you're getting at.  Please see below.

On Feb 22, 2016, Richard Biener  wrote:

> I think this breaks early-debug assumptions in creating new decl DIEs
> rather than just annotating old ones.

Can you elaborate on it, or point at where these assumptions you allude
to are documented?  I'm afraid I can't even tell whether the problem you
allude to has to do with users of the debug hooks interface or the
dwarf2out implementation thereof.

Sure enough, we haven't created DIEs for user-introduced or C++ cdtor
aliases before, so there are no DIEs for us to annotate, and there are
no other uses of the debug hooks interface related with them, that could
possibly interfere with them.

Conversely, alias decls for which we *have* created DIEs are ones that
cgraph turned into aliases; we do NOT want to pretend they're the same
function, and ideally we'd emit separate debug information for them, but
we can't retroactively figure out blocks, line numbers, variable
locations and whatnot for the unrelated function that happened to
optimize to the same executable code.  The best we can do for such
aliases ATM is to leave them alone; that's unchanged.

> So assemble_aliases is the wrong spot to do this.

Here, you seem to be talking about *users* of the debug hooks interface.
But then, I'd argue that the fact that debug info for aliases in
dwarf2out is implemented as DIEs is an internal implementation detail,
so why should assumptions made by the user side of the interface matter?

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer


[PATCH] 69912 - [6 regression] ICE in build_ctor_subob_ref initializing a flexible array member

2016-02-23 Thread Martin Sebor

The attached patch removes the assumption that the initializer for
a flexible array member is an array of the same cv-qualified type
as the array, avoiding the ICE.

Martin
PR c++/69912 - [6 regression] ICE in build_ctor_subob_ref initializing
	a flexible array member

gcc/testsuite/ChangeLog:
2016-02-23  Martin Sebor  

	PR c++/69912
	* g++.dg/ext/flexary15.C: New test.

gcc/cp/ChangeLog:
2016-02-23  Martin Sebor  

	PR c++/69912
	* tree.c (build_ctor_subob_ref): Compare types' main variants
instead of the types as they are.

Index: gcc/cp/tree.c
===
--- gcc/cp/tree.c	(revision 233652)
+++ gcc/cp/tree.c	(working copy)
@@ -2592,8 +2592,10 @@ build_ctor_subob_ref (tree index, tree t
 	{
 	  /* When the destination object refers to a flexible array member
 	 verify that it matches the type of the source object except
-	 for its domain.  */
-	  gcc_assert (comptypes (type, objtype, COMPARE_REDECLARATION));
+	 for its domain and qualifiers.  */
+	  gcc_assert (comptypes (TYPE_MAIN_VARIANT (type),
+	  			 TYPE_MAIN_VARIANT (objtype),
+	  			 COMPARE_REDECLARATION));
 	}
   else
 	gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, objtype));
Index: gcc/testsuite/g++.dg/ext/flexary15.C
===
--- gcc/testsuite/g++.dg/ext/flexary15.C	(revision 0)
+++ gcc/testsuite/g++.dg/ext/flexary15.C	(working copy)
@@ -0,0 +1,14 @@
+// PR c++/69912 - [6 regression] ICE in build_ctor_subob_ref initializing
+//a flexible array member
+// { dg-do compile }
+// { dg-options "-Wno-pedantic -Wno-write-strings -fpermissive" }
+
+struct S {
+  int n; 
+  char *a[];
+};
+
+void foo (const char *a)
+{
+  const S s = { 1, { a, "b" } };   // { dg-warning "invalid conversion" }
+}