[Bug rtl-optimization/89354] [7 Regression] Combine pass yields wrong code with -O2 and -msse2 for 32bit target

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89354

Jakub Jelinek  changed:

   What|Removed |Added

Summary|[7/8/9 Regression] Combine  |[7 Regression] Combine pass
   |pass yields wrong code with |yields wrong code with -O2
   |-O2 and -msse2 for 32bit|and -msse2 for 32bit target
   |target  |

--- Comment #6 from Jakub Jelinek  ---
Fixed for 8.3+ so far.

[Bug testsuite/88920] [9 regression] GCC is not configured to support amdgcn-unknown-amdhsa as offload target

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88920

Jakub Jelinek  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #28 from Jakub Jelinek  ---
Fixed.

[Bug tree-optimization/89278] ICE in gimplify_modify_expr, at gimplify.c:5821

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89278

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Jakub Jelinek  ---
Fixed for 8.3+.

[Bug c/89340] [7/8 Regression] ICE in function_and_variable_visibility, at ipa-visibility.c:707

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89340

Jakub Jelinek  changed:

   What|Removed |Added

Summary|[7/8/9 Regression] ICE in   |[7/8 Regression] ICE in
   |function_and_variable_visib |function_and_variable_visib
   |ility, at   |ility, at
   |ipa-visibility.c:707|ipa-visibility.c:707

--- Comment #6 from Jakub Jelinek  ---
Fixed on the trunk.  Not really sure if this should be backported, for the
release branches it might be better to silently ignore the weak flag.

[Bug testsuite/88920] [9 regression] GCC is not configured to support amdgcn-unknown-amdhsa as offload target

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88920

--- Comment #27 from Jakub Jelinek  ---
Author: jakub
Date: Fri Feb 15 07:52:50 2019
New Revision: 268930

URL: https://gcc.gnu.org/viewcvs?rev=268930=gcc=rev
Log:
PR other/69006
PR testsuite/88920
* lib/gcc-dg.exp: If llvm_binutils effective target, set
allow_blank_lines to 2 during initialization.
(dg-allow-blank-lines-in-output): Set allow_blank_lines to 1 only if
it was previously zero.
(gcc-dg-prune): Don't check for llvm_binutils effective target here.
Clear allow_blank_lines afterwards whenever it was 1.
* gdc.test/gdc-test.exp (dmd2dg): Don't call
dg-allow-blank-lines-in-output here.
(gdc-do-test): Set allow_blank_lines to 3 if it is 0 before running
the tests and restore it back at the end.

Modified:
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gdc.test/gdc-test.exp
trunk/gcc/testsuite/lib/gcc-dg.exp

[Bug other/69006] [6 Regression] Extraneous newline emitted between error messages in GCC 6

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69006

--- Comment #7 from Jakub Jelinek  ---
Author: jakub
Date: Fri Feb 15 07:52:50 2019
New Revision: 268930

URL: https://gcc.gnu.org/viewcvs?rev=268930=gcc=rev
Log:
PR other/69006
PR testsuite/88920
* lib/gcc-dg.exp: If llvm_binutils effective target, set
allow_blank_lines to 2 during initialization.
(dg-allow-blank-lines-in-output): Set allow_blank_lines to 1 only if
it was previously zero.
(gcc-dg-prune): Don't check for llvm_binutils effective target here.
Clear allow_blank_lines afterwards whenever it was 1.
* gdc.test/gdc-test.exp (dmd2dg): Don't call
dg-allow-blank-lines-in-output here.
(gdc-do-test): Set allow_blank_lines to 3 if it is 0 before running
the tests and restore it back at the end.

Modified:
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gdc.test/gdc-test.exp
trunk/gcc/testsuite/lib/gcc-dg.exp

[Bug other/89342] ICE in maybe_default_option, at opts.c:347

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89342

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |8.3

--- Comment #4 from Jakub Jelinek  ---
Fixed for 8.3+.

[Bug tree-optimization/89278] ICE in gimplify_modify_expr, at gimplify.c:5821

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89278

--- Comment #7 from Jakub Jelinek  ---
Author: jakub
Date: Fri Feb 15 07:50:26 2019
New Revision: 268928

URL: https://gcc.gnu.org/viewcvs?rev=268928=gcc=rev
Log:
PR tree-optimization/89278
* tree-loop-distribution.c: Include tree-eh.h.
(generate_memset_builtin, generate_memcpy_builtin): Call
rewrite_to_non_trapping_overflow on builtin->size before passing it
to force_gimple_operand_gsi.

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

Added:
branches/gcc-8-branch/gcc/testsuite/gcc.dg/pr89278.c
Modified:
branches/gcc-8-branch/gcc/ChangeLog
branches/gcc-8-branch/gcc/testsuite/ChangeLog
branches/gcc-8-branch/gcc/tree-loop-distribution.c

Re: [PATCH] Fix tree-loop-distribution.c ICE with -ftrapv (PR tree-optimization/89278)

2019-02-14 Thread Jakub Jelinek
On Fri, Feb 15, 2019 at 08:33:44AM +0100, Jakub Jelinek wrote:
> On Fri, Feb 15, 2019 at 03:25:33PM +0800, Bin.Cheng wrote:
> > So with what condition we can safely rewrite trapping operations into
> > non trapping one?  Does the rewrite nullify -ftrapv which requires
> > trap behavior?
> 
> For the particular expression?  Yes, otherwise no.
> 
> -ftrapv should be either replaced with -fsanitize=signed-integer-overflow
> -fsanitize-undefined-trap-on-error, or at least implemented that way in the
> middle-end (perhaps with a separate ifn, so that we can pattern recognize it
> during expansion and use library calls where the inline call is not small
> enough).  We haven't done that yet though.

To clarify, the current -ftrapv implementation doesn't guarantee you get
traps on overflow, it will happily optimize computations away at any time
during GIMPLE optimizations, or turn stuff into unsigned computations etc.
(not just through this rewrite function, but many other ways).
For -fsanitize=signed-integer-overflow -fsanitize-undefined-trap-on-error
there are no guarantees either, but we try hard not to optimize those away,
we have TYPE_OVERFLOW_SANITIZED checks that punt certain optimizations in
fold-const.c/match.pd and early (right after going into ssa form) we turn
the arithmetics into ifns, which are optimized away only if we can prove
there will be no overflow.  On the other side, it can hinder other
optimizations (a lot).  And possibly overflowing computations introduced
during later optimizations are not sanitized.
The question is what -ftrapv users want, plus right now they have a choice,
catch perhaps less UB with more optimization opportunities (-ftrapv)
or catch more optimize less (UBSan).

Jakub


[Bug target/89355] Unnecessary ENDBR

2019-02-14 Thread crazylht at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89355

--- Comment #2 from 刘袋鼠  ---
(In reply to H.J. Lu from comment #0)
> [hjl@gnu-cfl-2 gcc]$ cat x.i
> int
> test (int* val)
> {
>   int status = 99;
> 
>   if((val == 0))
> {
>   status = 22;
>   goto end;
> }
> 
>   extern int x;
>   *val = x;
> 
>   status = 0;
> end:
>   return status;
> }
> 
> [hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -S -O2 -fcf-protection  x.i
> [hjl@gnu-cfl-2 gcc]$ cat x.s
>   .file   "x.i"
>   .text
>   .p2align 4
>   .globl  test
>   .type   test, @function
> test:
> .LFB0:
>   .cfi_startproc
>   endbr64
>   testq   %rdi, %rdi
>   je  .L3
>   movlx(%rip), %eax
>   movl%eax, (%rdi)
>   xorl%eax, %eax
>   ret
>   .p2align 4,,10
>   .p2align 3
> .L3:
> .L2:
>   endbr64  <<< Why is ENDBR here?  There is no indirect branch.
>   movl$22, %eax
>   ret
>   .cfi_endproc
> .LFE0:
>   .size   test, .-test
>   .ident  "GCC: (GNU) 9.0.1 20190214 (experimental)"
>   .section.note.GNU-stack,"",@progbits
>   .section.note.gnu.property,"a"
>   .align 8
>   .long1f - 0f
>   .long4f - 1f
>   .long5
> 0:
>   .string  "GNU"
> 1:
>   .align 8
>   .long0xc002
>   .long3f - 2f
> 2:
>   .long0x3
> 3:
>   .align 8
> 4:
> [hjl@gnu-cfl-2 gcc]$

I investigate the second endbr64 in the upper case:
for dump x.i.312r.cet

(code_label 24 27 23 4 3 (nil) [1 uses])
(note 23 24 13 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(note 13 23 39 4 ("end") NOTE_INSN_DELETED_LABEL 2)
(insn 39 13 5 4 (unspec_volatile [
(const_int 0 [0])
] UNSPECV_NOP_ENDBR) -1
 (nil))


(note 13 23 39 4 ("end") NOTE_INSN_DELETED_LABEL 2)
will enter following branch which emit endbr64
for gcc source code:

if ((LABEL_P (insn) && LABEL_PRESERVE_P (insn))
 || (NOTE_P (insn)
 && NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL))
/* TODO.  Check /s bit also.  */
{
  cet_eb = gen_nop_endbr ();
  emit_insn_after (cet_eb, insn);
  continue;
}


Following patch would fix this problem:

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 12bc7926f86..2282816ae19 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2734,9 +2734,10 @@ rest_of_insert_endbranch (void)
  continue;
}

- if ((LABEL_P (insn) && LABEL_PRESERVE_P (insn))
+ if ((LABEL_P (insn)
  || (NOTE_P (insn)
  && NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL))
+ && LABEL_PRESERVE_P (insn))
/* TODO.  Check /s bit also.  */
{
  cet_eb = gen_nop_endbr ();

[Bug target/89355] Unnecessary ENDBR

2019-02-14 Thread crazylht at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89355

--- Comment #1 from 刘袋鼠  ---
(In reply to H.J. Lu from comment #0)
> [hjl@gnu-cfl-2 gcc]$ cat x.i
> int
> test (int* val)
> {
>   int status = 99;
> 
>   if((val == 0))
> {
>   status = 22;
>   goto end;
> }
> 
>   extern int x;
>   *val = x;
> 
>   status = 0;
> end:
>   return status;
> }
> 
> [hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -S -O2 -fcf-protection  x.i
> [hjl@gnu-cfl-2 gcc]$ cat x.s
>   .file   "x.i"
>   .text
>   .p2align 4
>   .globl  test
>   .type   test, @function
> test:
> .LFB0:
>   .cfi_startproc
>   endbr64
>   testq   %rdi, %rdi
>   je  .L3
>   movlx(%rip), %eax
>   movl%eax, (%rdi)
>   xorl%eax, %eax
>   ret
>   .p2align 4,,10
>   .p2align 3
> .L3:
> .L2:
>   endbr64  <<< Why is ENDBR here?  There is no indirect branch.
>   movl$22, %eax
>   ret
>   .cfi_endproc
> .LFE0:
>   .size   test, .-test
>   .ident  "GCC: (GNU) 9.0.1 20190214 (experimental)"
>   .section.note.GNU-stack,"",@progbits
>   .section.note.gnu.property,"a"
>   .align 8
>   .long1f - 0f
>   .long4f - 1f
>   .long5
> 0:
>   .string  "GNU"
> 1:
>   .align 8
>   .long0xc002
>   .long3f - 2f
> 2:
>   .long0x3
> 3:
>   .align 8
> 4:
> [hjl@gnu-cfl-2 gcc]$

I investigate the second endbr64 in the upper case:
for dump x.i.312r.cet

(code_label 24 27 23 4 3 (nil) [1 uses])
(note 23 24 13 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(note 13 23 39 4 ("end") NOTE_INSN_DELETED_LABEL 2)
(insn 39 13 5 4 (unspec_volatile [
(const_int 0 [0])
] UNSPECV_NOP_ENDBR) -1
 (nil))


for gcc source code:
if ((LABEL_P (insn) && LABEL_PRESERVE_P (insn))
 || (NOTE_P (insn)
   && NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL))
/* TODO.  Check /s bit also.  */
{
  cet_eb = gen_nop_endbr ();
  emit_insn_after (cet_eb, insn);
  continue;
}

[Bug tree-optimization/89278] ICE in gimplify_modify_expr, at gimplify.c:5821

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89278

--- Comment #6 from Jakub Jelinek  ---
Author: jakub
Date: Fri Feb 15 07:39:45 2019
New Revision: 268927

URL: https://gcc.gnu.org/viewcvs?rev=268927=gcc=rev
Log:
PR tree-optimization/89278
* tree-loop-distribution.c: Include tree-eh.h.
(generate_memset_builtin, generate_memcpy_builtin): Call
rewrite_to_non_trapping_overflow on builtin->size before passing it
to force_gimple_operand_gsi.

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

Added:
trunk/gcc/testsuite/gcc.dg/pr89278.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-loop-distribution.c

[Bug c/89340] [7/8/9 Regression] ICE in function_and_variable_visibility, at ipa-visibility.c:707

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89340

--- Comment #5 from Jakub Jelinek  ---
Author: jakub
Date: Fri Feb 15 07:38:09 2019
New Revision: 268926

URL: https://gcc.gnu.org/viewcvs?rev=268926=gcc=rev
Log:
PR c/89340
* c-decl.c (start_function): Clear TREE_PUBLIC on nested functions
before c_decl_attributes rather than after it.

* gcc.dg/pr89340.c: New test.
* gcc.dg/torture/pr57036-2.c (jpgDecode_convert): Expect a warning
that leaf attribute on nested function is useless.

Added:
trunk/gcc/testsuite/gcc.dg/pr89340.c
Modified:
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-decl.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/torture/pr57036-2.c

[Bug other/89342] ICE in maybe_default_option, at opts.c:347

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89342

--- Comment #3 from Jakub Jelinek  ---
Author: jakub
Date: Fri Feb 15 07:36:23 2019
New Revision: 268925

URL: https://gcc.gnu.org/viewcvs?rev=268925=gcc=rev
Log:
PR other/89342
* optc-save-gen.awk: Handle optimize_fast like optimize_size or
optimize_debug.
* opth-gen.awk: Likewise.

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

Added:
branches/gcc-8-branch/gcc/testsuite/gcc.dg/pr89342.c
Modified:
branches/gcc-8-branch/gcc/ChangeLog
branches/gcc-8-branch/gcc/optc-save-gen.awk
branches/gcc-8-branch/gcc/opth-gen.awk
branches/gcc-8-branch/gcc/testsuite/ChangeLog

Re: [PATCH] Fix tree-loop-distribution.c ICE with -ftrapv (PR tree-optimization/89278)

2019-02-14 Thread Jakub Jelinek
On Fri, Feb 15, 2019 at 03:25:33PM +0800, Bin.Cheng wrote:
> So with what condition we can safely rewrite trapping operations into
> non trapping one?  Does the rewrite nullify -ftrapv which requires
> trap behavior?

For the particular expression?  Yes, otherwise no.

-ftrapv should be either replaced with -fsanitize=signed-integer-overflow
-fsanitize-undefined-trap-on-error, or at least implemented that way in the
middle-end (perhaps with a separate ifn, so that we can pattern recognize it
during expansion and use library calls where the inline call is not small
enough).  We haven't done that yet though.

Jakub


Re: riscv64 dep. computation

2019-02-14 Thread Paulo Matos



On 14/02/2019 19:56, Jim Wilson wrote:
> On 2/14/19 3:13 AM, Paulo Matos wrote:
>> If I compile this with -O2, sched1 groups all loads and all stores
>> together. That's perfect. However, if I change TYPE to unsigned char and
>> recompile, the stores and loads are interleaved.
>>
>> Further investigation shows that for unsigned char there are extra
>> dependencies that block the scheduler from grouping stores and loads.
> 
> The ISO C standard says that anything can be casted to char *, and char
> * can be casted to anything.  Hence, a char * pointer aliases everything.
> 
> If you look at the alias set info in the MEMs, you can see that the char
> * references are in alias set 0, which means that they alias everything.
>  The short * references are in alias set 2 which means they only alias
> other stuff in alias set 2.  The difference here is that short * does
> not alias the structure pointers, but char * does.  I haven't tried
> debugging your example, but this is presumably where the difference
> comes from.
>

OK, that seems to make sense. Indeed if I use restrict on the argument
pointers, the compiler will sort itself out and group the loads and stores.

> Because x and y are pointer parameters, the compiler must assume that
> they might alias.  And because char * aliases everything, the char
> references alias them too.  If you change x and y to global variables,
> then they no longer alias each other, and the compiler will schedule all
> of the loads first, even for char.
> 

Are global variables not supposed to alias each other?
If I indeed do that, gcc still won't group loads and stores:
https://cx.rv8.io/g/rFjGLa

-- 
Paulo Matos


Re: [PATCH] Fix tree-loop-distribution.c ICE with -ftrapv (PR tree-optimization/89278)

2019-02-14 Thread Bin.Cheng
On Fri, Feb 15, 2019 at 6:52 AM Jakub Jelinek  wrote:
>
> Hi!
>
> The following testcase ICEs, because we try to gimplify a complex expression
> that with -ftrapv wants to emit multiple bbs.  Fixed by using
> rewrite_to_non_trapping_overflow.  Bootstrapped/regtested on x86_64-linux
So with what condition we can safely rewrite trapping operations into
non trapping one?  Does the rewrite nullify -ftrapv which requires
trap behavior?

Thanks,
bin
> and i686-linux, ok for trunk and 8.3?
>
> 2019-02-14  Richard Biener  
> Jakub Jelinek  
>
> PR tree-optimization/89278
> * tree-loop-distribution.c: Include tree-eh.h.
> (generate_memset_builtin, generate_memcpy_builtin): Call
> rewrite_to_non_trapping_overflow on builtin->size before passing it
> to force_gimple_operand_gsi.
>
> * gcc.dg/pr89278.c: New test.
>
> --- gcc/tree-loop-distribution.c.jj 2019-01-10 11:43:02.255576992 +0100
> +++ gcc/tree-loop-distribution.c2019-02-14 12:17:24.403403131 +0100
> @@ -114,6 +114,7 @@ along with GCC; see the file COPYING3.
>  #include "tree-scalar-evolution.h"
>  #include "params.h"
>  #include "tree-vectorizer.h"
> +#include "tree-eh.h"
>
>
>  #define MAX_DATAREFS_NUM \
> @@ -996,7 +997,7 @@ generate_memset_builtin (struct loop *lo
>/* The new statements will be placed before LOOP.  */
>gsi = gsi_last_bb (loop_preheader_edge (loop)->src);
>
> -  nb_bytes = builtin->size;
> +  nb_bytes = rewrite_to_non_trapping_overflow (builtin->size);
>nb_bytes = force_gimple_operand_gsi (, nb_bytes, true, NULL_TREE,
>false, GSI_CONTINUE_LINKING);
>mem = builtin->dst_base;
> @@ -1048,7 +1049,7 @@ generate_memcpy_builtin (struct loop *lo
>/* The new statements will be placed before LOOP.  */
>gsi = gsi_last_bb (loop_preheader_edge (loop)->src);
>
> -  nb_bytes = builtin->size;
> +  nb_bytes = rewrite_to_non_trapping_overflow (builtin->size);
>nb_bytes = force_gimple_operand_gsi (, nb_bytes, true, NULL_TREE,
>false, GSI_CONTINUE_LINKING);
>dest = builtin->dst_base;
> --- gcc/testsuite/gcc.dg/pr89278.c.jj   2019-02-14 12:18:38.778173413 +0100
> +++ gcc/testsuite/gcc.dg/pr89278.c  2019-02-14 12:18:19.065499344 +0100
> @@ -0,0 +1,23 @@
> +/* PR tree-optimization/89278 */
> +/* { dg-do compile } */
> +/* { dg-options "-O1 -ftrapv -ftree-loop-distribute-patterns --param 
> max-loop-header-insns=2" } */
> +
> +void
> +foo (int *w, int x, int y, int z)
> +{
> +  while (x < y + z)
> +{
> +  w[x] = 0;
> +  ++x;
> +}
> +}
> +
> +void
> +bar (int *__restrict u, int *__restrict w, int x, int y, int z)
> +{
> +  while (x < y + z)
> +{
> +  w[x] = u[x];
> +  ++x;
> +}
> +}
>
> Jakub


Re: [PATCH] Avoid assuming valid_constant_size_p argument is a constant expression (PR 89294)

2019-02-14 Thread Eric Botcazou
> The attached patch removes the assumption introduced earlier today
> in my fix for bug 87996 that the valid_constant_size_p argument is
> a constant expression.  I couldn't come up with a C/C++ test case
> where this isn't true but apparently it can happen in Ada which I
> inadvertently didn't build.

Can we do something here?  Our internal testers have been down for 3 days 
because of this blunder...

-- 
Eric Botcazou


[Bug other/89342] ICE in maybe_default_option, at opts.c:347

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89342

--- Comment #2 from Jakub Jelinek  ---
Author: jakub
Date: Fri Feb 15 07:17:24 2019
New Revision: 268924

URL: https://gcc.gnu.org/viewcvs?rev=268924=gcc=rev
Log:
PR other/89342
* optc-save-gen.awk: Handle optimize_fast like optimize_size or
optimize_debug.
* opth-gen.awk: Likewise.

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

Added:
trunk/gcc/testsuite/gcc.dg/pr89342.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/optc-save-gen.awk
trunk/gcc/opth-gen.awk
trunk/gcc/testsuite/ChangeLog

Re: [PATCH] Fix tree-loop-distribution.c ICE with -ftrapv (PR tree-optimization/89278)

2019-02-14 Thread Richard Biener
On February 14, 2019 11:52:17 PM GMT+01:00, Jakub Jelinek  
wrote:
>Hi!
>
>The following testcase ICEs, because we try to gimplify a complex
>expression
>that with -ftrapv wants to emit multiple bbs.  Fixed by using
>rewrite_to_non_trapping_overflow.  Bootstrapped/regtested on
>x86_64-linux
>and i686-linux, ok for trunk and 8.3?

OK. 

Richard. 

>2019-02-14  Richard Biener  
>   Jakub Jelinek  
>
>   PR tree-optimization/89278
>   * tree-loop-distribution.c: Include tree-eh.h.
>   (generate_memset_builtin, generate_memcpy_builtin): Call
>   rewrite_to_non_trapping_overflow on builtin->size before passing it
>   to force_gimple_operand_gsi.
>
>   * gcc.dg/pr89278.c: New test.
>
>--- gcc/tree-loop-distribution.c.jj2019-01-10 11:43:02.255576992 +0100
>+++ gcc/tree-loop-distribution.c   2019-02-14 12:17:24.403403131 +0100
>@@ -114,6 +114,7 @@ along with GCC; see the file COPYING3.
> #include "tree-scalar-evolution.h"
> #include "params.h"
> #include "tree-vectorizer.h"
>+#include "tree-eh.h"
> 
> 
> #define MAX_DATAREFS_NUM \
>@@ -996,7 +997,7 @@ generate_memset_builtin (struct loop *lo
>   /* The new statements will be placed before LOOP.  */
>   gsi = gsi_last_bb (loop_preheader_edge (loop)->src);
> 
>-  nb_bytes = builtin->size;
>+  nb_bytes = rewrite_to_non_trapping_overflow (builtin->size);
>  nb_bytes = force_gimple_operand_gsi (, nb_bytes, true, NULL_TREE,
>  false, GSI_CONTINUE_LINKING);
>   mem = builtin->dst_base;
>@@ -1048,7 +1049,7 @@ generate_memcpy_builtin (struct loop *lo
>   /* The new statements will be placed before LOOP.  */
>   gsi = gsi_last_bb (loop_preheader_edge (loop)->src);
> 
>-  nb_bytes = builtin->size;
>+  nb_bytes = rewrite_to_non_trapping_overflow (builtin->size);
>  nb_bytes = force_gimple_operand_gsi (, nb_bytes, true, NULL_TREE,
>  false, GSI_CONTINUE_LINKING);
>   dest = builtin->dst_base;
>--- gcc/testsuite/gcc.dg/pr89278.c.jj  2019-02-14 12:18:38.778173413
>+0100
>+++ gcc/testsuite/gcc.dg/pr89278.c 2019-02-14 12:18:19.065499344 +0100
>@@ -0,0 +1,23 @@
>+/* PR tree-optimization/89278 */
>+/* { dg-do compile } */
>+/* { dg-options "-O1 -ftrapv -ftree-loop-distribute-patterns --param
>max-loop-header-insns=2" } */
>+
>+void
>+foo (int *w, int x, int y, int z)
>+{
>+  while (x < y + z)
>+{
>+  w[x] = 0;
>+  ++x;
>+}
>+}
>+
>+void
>+bar (int *__restrict u, int *__restrict w, int x, int y, int z)
>+{
>+  while (x < y + z)
>+{
>+  w[x] = u[x];
>+  ++x;
>+}
>+}
>
>   Jakub



[Bug tree-optimization/88835] overly aggressive -Werror=format-overflow for printf since r265648

2019-02-14 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88835

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org

--- Comment #13 from Eric Gallager  ---
(In reply to Martin Sebor from comment #10)
> I've built the top of binutils-gdb with the patch referenced in comment #8
> applied and with -Wformat-overflow=2 and -Wformat-truncation=2 and got the
> following breakdown:
> 
> DiagnosticCount   UniqueFiles
> -Wformat-overflow=   19   19   10
> -Wformat-truncation= 12   127
> -Wconflicts-sr777
> -Wmaybe-uninitialized 333
> -Wstringop-truncation 222
> -Wconflicts-rr222
> -Wsign-compare111
> -Wother   111

Tangent, but -Wconflicts-sr, -Wconflicts-rr, and -Wother are from bison, not
gcc, so you might want to update whatever tool you use to generate these pretty
tables to filter them out

[Bug tree-optimization/89350] [9 Regression] Wrong -Wstringop-overflow= warning since r261518

2019-02-14 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89350

--- Comment #2 from Eric Gallager  ---
(In reply to Martin Sebor from comment #1)
> 
> The test case makes the tacit assumption that argc is necessarily
> non-negative.  That makes sense for the argc argument to main but not in
> other situations.  

Would it be possible to propose an update to the C standard that allows the
argc argument to main to be unsigned? Could GCC start accepting unsigned argc
as an extension so that -Wmain allows it?

[Bug tree-optimization/85316] [meta-bug] VRP range propagation missed cases

2019-02-14 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316

--- Comment #2 from Eric Gallager  ---
There's probably a lot more bugs that should fall under this meta-bug than
currently do; I'll leave finding them all for another day though (or for
someone else to do)

[PATCH] i386: Insert ENDBR for NOTE_INSN_DELETED_LABEL only if needed

2019-02-14 Thread H.J. Lu
NOTE_INSN_DELETED_LABEL is used to mark what used to be a 'code_label',
but was not used for other purposes than taking its address and was
transformed to mark that no code jumps to it.  NOTE_INSN_DELETED_LABEL
is generated only in 3 places:

1. When delete_insn sees an unused label which is an explicit label in
the input source code or its address is taken, it turns the label into
a NOTE_INSN_DELETED_LABEL note.
2. When rtl_tidy_fallthru_edge deletes a tablejump, it turns the
tablejump into a NOTE_INSN_DELETED_LABEL note.
3. ix86_init_large_pic_reg creats a NOTE_INSN_DELETED_LABEL note, .L2,
to initialize large model PIC register:

L2:
movabsq $_GLOBAL_OFFSET_TABLE_-.L2, %r11
leaq.L2(%rip), %rax
movabsq $val@GOT, %rdx
addq%r11, %rax

Among of them, ENDBR is needed only when the label address is taken.
rest_of_insert_endbranch has

  if ((LABEL_P (insn) && LABEL_PRESERVE_P (insn))
  || (NOTE_P (insn)
  && NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL))
/* TODO.  Check /s bit also.  */
{
  cet_eb = gen_nop_endbr ();
  emit_insn_after (cet_eb, insn);
  continue;
}

For NOTE_INSN_DELETED_LABEL, we should check if forced_labels to see
if its address is taken.  Also ix86_init_large_pic_reg shouldn't set
LABEL_PRESERVE_P (in_struct) since NOTE_INSN_DELETED_LABEL is suffcient
to keep the label.

gcc/

PR target/89355
* config/i386/i386.c (rest_of_insert_endbranch): Check
forced_labels to see if the address of NOTE_INSN_DELETED_LABEL
is taken.
(ix86_init_large_pic_reg): Don't set LABEL_PRESERVE_P.

gcc/testsuite/

PR target/89355
* gcc.target/i386/cet-label-3.c: New test.
* gcc.target/i386/cet-label-4.c: Likewise.
* gcc.target/i386/cet-label-5.c: Likewise.
---
 gcc/config/i386/i386.c  |  9 +---
 gcc/testsuite/gcc.target/i386/cet-label-3.c | 23 +
 gcc/testsuite/gcc.target/i386/cet-label-4.c | 12 +++
 gcc/testsuite/gcc.target/i386/cet-label-5.c | 13 
 4 files changed, 54 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-label-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-label-4.c
 create mode 100644 gcc/testsuite/gcc.target/i386/cet-label-5.c

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index fd05873ba39..ed53fbea9ae 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2734,10 +2734,14 @@ rest_of_insert_endbranch (void)
  continue;
}
 
+ /* NB: Add an ENDBR for NOTE_INSN_DELETED_LABEL only if its
+addresss is taken.  */
  if ((LABEL_P (insn) && LABEL_PRESERVE_P (insn))
  || (NOTE_P (insn)
- && NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL))
-   /* TODO.  Check /s bit also.  */
+ && NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL
+ && vec_safe_contains
+  (forced_labels,
+   static_cast (insn
{
  cet_eb = gen_nop_endbr ();
  emit_insn_after (cet_eb, insn);
@@ -7002,7 +7006,6 @@ ix86_init_large_pic_reg (unsigned int tmp_regno)
   gcc_assert (Pmode == DImode);
   label = gen_label_rtx ();
   emit_label (label);
-  LABEL_PRESERVE_P (label) = 1;
   tmp_reg = gen_rtx_REG (Pmode, tmp_regno);
   gcc_assert (REGNO (pic_offset_table_rtx) != tmp_regno);
   emit_insn (gen_set_rip_rex64 (pic_offset_table_rtx,
diff --git a/gcc/testsuite/gcc.target/i386/cet-label-3.c 
b/gcc/testsuite/gcc.target/i386/cet-label-3.c
new file mode 100644
index 000..9f427a866f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-label-3.c
@@ -0,0 +1,23 @@
+/* PR target/89355  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcf-protection" } */
+/* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */
+int
+test (int* val)
+{
+  int status = 99;
+
+  if (!val)
+{
+  status = 22;
+  goto end;
+}
+
+  extern int x;
+  *val = x;
+
+  status = 0;
+end:
+  return status;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-label-4.c 
b/gcc/testsuite/gcc.target/i386/cet-label-4.c
new file mode 100644
index 000..d743d2bf202
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-label-4.c
@@ -0,0 +1,12 @@
+/* PR target/89355  */
+/* { dg-do compile { target { fpic && lp64 } } } */
+/* { dg-options "-O2 -fcf-protection -fPIC -mcmodel=large" } */
+/* { dg-final { scan-assembler-times "endbr64" 1 } } */
+
+extern int val;
+
+int
+test (void)
+{
+  return val;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cet-label-5.c 
b/gcc/testsuite/gcc.target/i386/cet-label-5.c
new file mode 100644
index 000..4d5ca816598
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cet-label-5.c
@@ -0,0 +1,13 

Re: [PATCH] Add testcases for multiple -fsanitize=, -fno-sanitize= or -fno-sanitize-recover= options (take 2)

2019-02-14 Thread Mike Stump
On Feb 14, 2019, at 6:15 AM, Jakub Jelinek  wrote:
> Ah, yes, UNRESOLVED doesn't show up visible when running tests by hand,
> rather than doing test_summary.  Here is an updated patch that adds the
> needed dg-skip-if directives.  Ok for trunk?

Ok.


Re: [PATCH] Fix up and improve allow_blank_lines testsuite handling (PR other/69006, PR testsuite/88920)

2019-02-14 Thread Mike Stump
On Feb 13, 2019, at 1:09 AM, Jakub Jelinek  wrote:
> 
> ok for trunk?

Ok.


Re: [PATCH] Fix up and improve allow_blank_lines testsuite handling (PR other/69006, PR testsuite/88920, take 2)

2019-02-14 Thread Mike Stump
On Feb 13, 2019, at 5:37 AM, Jakub Jelinek  wrote:
> Here is an updated patch that documents it.  Bootstrapped/regtested on
> x86_64-linux and i686-linux, ok for trunk?

Ok.


[Bug c++/89356] [9 Regression] sorry, unimplemented: mangling implicit_conv_expr in nodejs8 package since r268321

2019-02-14 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89356

--- Comment #4 from Marek Polacek  ---
reshape_init turns {NON_LVALUE_EXPR <2>} into NON_LVALUE_EXPR <2> and then the
mangled name misses "tlE".

[Bug c++/89356] [9 Regression] sorry, unimplemented: mangling implicit_conv_expr in nodejs8 package since r268321

2019-02-14 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89356

--- Comment #3 from Marek Polacek  ---
That revision also changes mangling of fn from
decltype (unsigned short{2u}+((int)(3))) fn()
to
decltype ((2u)+((int)(3))) fn()

template
auto fn () -> decltype(unsigned{2u} + (T)3) { return 42; }

template auto fn() -> decltype(unsigned{2u} + (int)3);

[Bug fortran/70149] [F08] Character pointer initialization causes ICE

2019-02-14 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70149

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|NEW |WAITING

--- Comment #13 from Dominique d'Humieres  ---
> Has this gone away? I seem to have applied what I believe to be
> the right patch as fallout from another PR.

Any answer to this question?

Go patch committed: Harmonize types referenced by both C and Go

2019-02-14 Thread Ian Lance Taylor
This patch to the Go frontend and libgo by Nikhil Benesch harmonizes
types referenced by both C and Go.  Compiling with LTO revealed a
number of cases in the runtime and standard library where C and Go
disagreed about the type of an object or function (or where Go and
code generated by the compiler disagreed).  In all cases the
underlying representation was the same (e.g., uintptr vs.void*), so
this wasn't causing actual problems, but it did result in a number of
annoying warnings when compiling with LTO.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 268922)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-4a6f2bb2c8d3f00966f001a5b03c57cb4a278265
+03e28273a4fcb114f5204d52ed107591404002f4
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===
--- gcc/go/gofrontend/expressions.cc(revision 268891)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -1344,7 +1344,7 @@ Func_descriptor_expression::make_func_de
   if (Func_descriptor_expression::descriptor_type != NULL)
 return;
   Type* uintptr_type = Type::lookup_integer_type("uintptr");
-  Type* struct_type = Type::make_builtin_struct_type(1, "code", uintptr_type);
+  Type* struct_type = Type::make_builtin_struct_type(1, "fn", uintptr_type);
   Func_descriptor_expression::descriptor_type =
 Type::make_builtin_named_type("functionDescriptor", struct_type);
 }
@@ -3874,7 +3874,9 @@ Unsafe_type_conversion_expression::do_ge
  || et->integer_type() != NULL
   || et->is_nil_type());
   else if (et->is_unsafe_pointer_type())
-go_assert(t->points_to() != NULL);
+go_assert(t->points_to() != NULL
+ || (t->integer_type() != NULL
+ && t->integer_type() == 
Type::lookup_integer_type("uintptr")->real_type()));
   else if (t->interface_type() != NULL)
 {
   bool empty_iface = t->interface_type()->is_empty();
Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc   (revision 268891)
+++ gcc/go/gofrontend/gogo.cc   (working copy)
@@ -4513,13 +4513,13 @@ Build_recover_thunks::can_recover_arg(Lo
 builtin_return_address =
   Gogo::declare_builtin_rf_address("__builtin_return_address");
 
+  Type* uintptr_type = Type::lookup_integer_type("uintptr");
   static Named_object* can_recover;
   if (can_recover == NULL)
 {
   const Location bloc = Linemap::predeclared_location();
   Typed_identifier_list* param_types = new Typed_identifier_list();
-  Type* voidptr_type = Type::make_pointer_type(Type::make_void_type());
-  param_types->push_back(Typed_identifier("a", voidptr_type, bloc));
+  param_types->push_back(Typed_identifier("a", uintptr_type, bloc));
   Type* boolean_type = Type::lookup_bool_type();
   Typed_identifier_list* results = new Typed_identifier_list();
   results->push_back(Typed_identifier("", boolean_type, bloc));
@@ -4539,6 +4539,7 @@ Build_recover_thunks::can_recover_arg(Lo
   args->push_back(zexpr);
 
   Expression* call = Expression::make_call(fn, args, false, location);
+  call = Expression::make_unsafe_cast(uintptr_type, call, location);
 
   args = new Expression_list();
   args->push_back(call);
Index: gcc/go/gofrontend/runtime.cc
===
--- gcc/go/gofrontend/runtime.cc(revision 268369)
+++ gcc/go/gofrontend/runtime.cc(working copy)
@@ -60,8 +60,6 @@ enum Runtime_function_type
   RFT_IFACE,
   // Go type interface{}, C type struct __go_empty_interface.
   RFT_EFACE,
-  // Go type func(unsafe.Pointer), C type void (*) (void *).
-  RFT_FUNC_PTR,
   // Pointer to Go type descriptor.
   RFT_TYPE,
   // [2]string.
@@ -176,15 +174,6 @@ runtime_function_type(Runtime_function_t
  t = Type::make_empty_interface_type(bloc);
  break;
 
-   case RFT_FUNC_PTR:
- {
-   Typed_identifier_list* param_types = new Typed_identifier_list();
-   Type* ptrtype = runtime_function_type(RFT_POINTER);
-   param_types->push_back(Typed_identifier("", ptrtype, bloc));
-   t = Type::make_function_type(NULL, param_types, NULL, bloc);
- }
- break;
-
case RFT_TYPE:
  t = Type::make_type_descriptor_ptr_type();
  break;
@@ -265,7 +254,6 @@ convert_to_runtime_function_type(Runtime
 case RFT_COMPLEX128:
 case RFT_STRING:
 case RFT_POINTER:
-case RFT_FUNC_PTR:
   {
Type* t = runtime_function_type(bft);
if (!Type::are_identical(t, e->type(), true, NULL))
Index: gcc/go/gofrontend/runtime.def

[Bug go/89168] FAIL: cmd/go/internal/load

2019-02-14 Thread ian at airs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89168

Ian Lance Taylor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #2 from Ian Lance Taylor  ---
Fixed.

Re: [C PATCH] Reject weak nested functions (PR c/89340)

2019-02-14 Thread Joseph Myers
On Fri, 15 Feb 2019, Jakub Jelinek wrote:

> Hi!
> 
> We ICE on the following testcase, because C nested functions are turned into
> !TREE_PUBLIC ones very soon,  and the IPA code asserts that DECL_WEAK 
> functions
> are either TREE_PUBLIC or DECL_EXTERNAL.
> As we reject static __attribute__((weak)) void foo () {}, I think we should
> reject weak nested functions, they don't make much sense either, they are
> TU local too.
> 
> The following patch fixes that.  The other effect of the patch is that leaf
> attribute is warned and ignored on the nested function, but similarly, we
> ignore and warn for leaf attribute on other TU local functions, we see the
> nested function body and can analyze everything in it.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

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


Re: [PATCH] Fix ICE with optimize("Ofast") due to option handling (PR other/89342)

2019-02-14 Thread Joseph Myers
On Thu, 14 Feb 2019, Jakub Jelinek wrote:

> Hi!
> 
> We ICE on the following testcase, because while we save optimize,
> and optimize_{size,debug} vars during option saving/restoring, we don't save
> optimize_fast, and because of that end up with optimize 0 optimize_fast 1
> which the option handling code ICEs on - 
>   if (fast)
> gcc_assert (level == 3);
> in maybe_default_option.  Fixed thusly, just treat optimize_fast like
> the other flags, bootstrapped/regtested on x86_64-linux and i686-linux, ok
> for trunk/8.3?

OK.

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


[Bug tree-optimization/88835] overly aggressive -Werror=format-overflow for printf since r265648

2019-02-14 Thread mark at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88835

--- Comment #12 from Mark Wielaard  ---
(In reply to Martin Sebor from comment #11)
> Ah, but you mentioned elfutilts, not binutils.  I've now downloaded and
> built elfutils-0.175.  It took a bit more effort because --disable-werror
> doesn't work there but once I got past that I just got the three
> -Wformat-truncation instances below:
> 
> DiagnosticCount   UniqueFiles
> -Wformat-truncation=  332
> 
> -Wformat-truncation Instances:
>   /src/elfutils-0.175/src/ar.c:1468
>   /src/elfutils-0.175/src/ar.c:859
>   /src/elfutils-0.175/src/arlib.c:63

I am not seeing these, but they might have been fixed in git. We like to keep
the code warning free since we always build with -Werror.

> I'm probably not using the same sources as you, but shouldn't I be seeing at
> least some of the warnings?  (I couldn't find an easy way build the top of
> trunk -- there's no configure script.)

I am using git master. git://sourceware.org/git/elfutils.git
See the README for build instructions:

To build a git checkout do:
  autoreconf -i -f && \
  ./configure --enable-maintainer-mode && \
  make && make check

Note that the warning/error only occurs on 32bit systems, like these fedora
koji arm32 and i686 builds:
https://koji.fedoraproject.org/koji/taskinfo?taskID=32816136

To get the same on a 64bit system build with CFLAGS="-g -O2 -m32"

libgo patch committed: Run examples

2019-02-14 Thread Ian Lance Taylor
This patch to the libgo gotest script runs examples when appropriate
in the libgo testsuite.  An example with a "// Output:" comment is
supposed to be run, comparing the output of the example with the text
in the comment.  Up until now we were not actually doing that, so we
were in effect skipping some tests.  This changes that.  The changes
to the script are not fully general for all Go code, but should be
sufficient for the code that actually appears in libgo.  One example
had to be tweaked to match the output generated by gccgo.

This patch also cleans up some cruft in gotest, and should fix GCC PR 89168.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 268904)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-c2fc3b83d832725accd4fa5874a5b5ca02dd90dc
+4a6f2bb2c8d3f00966f001a5b03c57cb4a278265
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/example_test.go
===
--- libgo/go/runtime/example_test.go(revision 268369)
+++ libgo/go/runtime/example_test.go(working copy)
@@ -31,7 +31,7 @@ func ExampleFrames() {
// To keep this example's output stable
// even if there are changes in the testing package,
// stop unwinding when we leave package runtime.
-   if !strings.Contains(frame.File, "runtime/") {
+   if !strings.Contains(frame.File, "runtime/") && 
!strings.Contains(frame.File, "/test/") {
break
}
fmt.Printf("- more:%v | %s\n", more, frame.Function)
@@ -47,8 +47,8 @@ func ExampleFrames() {
a()
// Output:
// - more:true | runtime.Callers
-   // - more:true | runtime_test.ExampleFrames.func1
-   // - more:true | runtime_test.ExampleFrames.func2
-   // - more:true | runtime_test.ExampleFrames.func3
+   // - more:true | runtime_test.ExampleFrames..func1
+   // - more:true | runtime_test.ExampleFrames..func2
+   // - more:true | runtime_test.ExampleFrames..func3
// - more:true | runtime_test.ExampleFrames
 }
Index: libgo/testsuite/gotest
===
--- libgo/testsuite/gotest  (revision 268369)
+++ libgo/testsuite/gotest  (working copy)
@@ -289,12 +289,6 @@ x)
;;
 esac
 
-# Some tests expect the _obj directory created by the gc Makefiles.
-mkdir _obj
-
-# Some tests expect the _test directory created by the gc Makefiles.
-mkdir _test
-
 case "x$gofiles" in
 x)
for f in `ls *_test.go`; do
@@ -404,14 +398,6 @@ x)
;;
 esac
 
-# Run any commands given in sources, like
-#   // gotest: $GC foo.go
-# to build any test-only dependencies.
-holdGC="$GC"
-GC="$GC -g -c -I ."
-sed -n 's/^\/\/ gotest: //p' $gofiles | sh
-GC="$holdGC"
-
 case "x$pkgfiles" in
 x)
pkgbasefiles=`ls *.go | grep -v _test.go 2>/dev/null`
@@ -514,26 +500,29 @@ localname() {
 #
 symtogo() {
   result=""
-  for tp in $*
-  do
+  for tp in $*; do
 s=$(echo "$tp" | sed -e 's/\.\.z2f/%/g' | sed -e 's/.*%//')
-# screen out methods (X.Y.Z)
+# Screen out methods (X.Y.Z).
 if ! expr "$s" : '^[^.]*\.[^.]*$' >/dev/null 2>&1; then
   continue
 fi
-echo "$s"
+tname=$(testname $s)
+# Skip TestMain.
+if test x$tname = xTestMain; then
+  continue
+fi
+# Check that the function is defined in a test file,
+# not an ordinary non-test file.
+if grep "^func $tname(" $gofiles $xgofiles >/dev/null 2>&1; then
+  echo "$s"
+fi
   done
 }
 
 {
-   text="T"
-
# On systems using PPC64 ELF ABI v1 function symbols show up
-   # as descriptors in the data section.  We assume that $goarch
-   # distinguishes v1 (ppc64) from v2 (ppc64le).
-   if test "$goos" != "aix" && test "$goarch" = "ppc64"; then
-   text="[TD]"
-   fi
+   # as descriptors in the data section.
+   text="[TD]"
 
# test functions are named TestFoo
# the grep -v eliminates methods and other special names
@@ -575,13 +564,10 @@ symtogo() {
# test array
echo
echo 'var tests = []testing.InternalTest {'
-   for i in $tests
-   do
+   for i in $tests; do
n=$(testname $i)
-   if test "$n" != "TestMain"; then
-   j=$(localname $i)
-   echo '  {"'$n'", '$j'},'
-   fi
+   j=$(localname $i)
+   echo '  {"'$n'", '$j'},'
done
echo '}'
 
@@ -589,8 +575,7 @@ symtogo() {
# The comment makes the multiline declaration
# gofmt-safe even when there 

[Bug go/89168] FAIL: cmd/go/internal/load

2019-02-14 Thread ian at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89168

--- Comment #1 from ian at gcc dot gnu.org  ---
Author: ian
Date: Fri Feb 15 00:36:50 2019
New Revision: 268922

URL: https://gcc.gnu.org/viewcvs?rev=268922=gcc=rev
Log:
PR go/89168
libgo: change gotest to run examples with output

Change the gotest script to act like "go test" and run examples that
have "output" comments.  This is not done with full generality, but
just enough to run the libgo tests.  Other packages should be tested
with "go test" as usual.

While we're here clean up some old bits of gotest, and only run
TestXXX functions that are actually in *_test.go files.  The latter
change should fix https://gcc.gnu.org/PR89168.

Reviewed-on: https://go-review.googlesource.com/c/162139

Modified:
trunk/gcc/go/gofrontend/MERGE
trunk/libgo/go/runtime/example_test.go
trunk/libgo/testsuite/gotest

Re: Go patch committed: Compile thunks with -Os

2019-02-14 Thread Ian Lance Taylor
On Wed, Feb 13, 2019 at 5:21 PM Ian Lance Taylor  wrote:
>
> Nikhil Benesch noticed that changes in the GCC backend were making the
> use of defer functions that call recover less efficient.  A defer
> thunk is a generated function that looks like this (this is the entire
> function body):
>
> if !runtime.setdeferretaddr() {
> deferredFunction()
> }
> L:
>
> The idea is that the address of the label passed to setdeferretaddr is
> the address to which deferredFunction returns.  The code in canrecover
> compares the return address of the function to this saved address to
> see whether the recover function can return non-nil.  This is
> explained in marginally more detail at
> https://www.airs.com/blog/archives/376 .
>
> When the return address does not match, the canrecover code does a
> more costly check that requires unwinding the stack.  What Nikhil
> Benesch noticed is that we were always taking that fallback.
>
> It turned out that the label address passed to setdeferretaddr was not
> the label to which the deferred function would return.  And that was
> because the epilogue was being duplicated by the bb-reorder pass, and
> the label was moved to one copy of the epilogue while the deferred
> function returned to the other epilogue.
>
> Of course there is no reason to duplicate the epilogue in such a small
> function.  One easy way to disable that epilogue duplication is to
> compile the function with -Os.  That is what this patch does.  This
> patch compiles all thunks, not just defer thunks, with -Os, but since
> they are all small that does no harm.
>
> Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
> to mainline.
>
> Ian
>
> 2019-02-13  Ian Lance Taylor  
>
> * go-gcc.cc: #include "opts.h".
> (Gcc_backend::function): Compile thunks with -Os.

This change revealed that changing function optimization attributes
can cause the compiler to switch to the options stored in
optimization_default_node.  That caused the change to
flag_strict_aliasing in go_imported_unsafe to be lost.  I fixed that
with this patch, which simply updates optimization_default_node.  I
don't know if there is a better way to do this.  For this patch
bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian

2019-02-14  Ian Lance Taylor  

* go-backend.c (go_imported_unsafe): Update
optimization_default_node.
Index: go-backend.c
===
--- go-backend.c(revision 268917)
+++ go-backend.c(working copy)
@@ -89,6 +89,7 @@ void
 go_imported_unsafe (void)
 {
   flag_strict_aliasing = false;
+  TREE_OPTIMIZATION (optimization_default_node)->x_flag_strict_aliasing = 
false;
 
   /* Let the backend know that the options have changed.  */
   targetm.override_options_after_change ();


[Bug tree-optimization/88835] overly aggressive -Werror=format-overflow for printf since r265648

2019-02-14 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88835

--- Comment #11 from Martin Sebor  ---
Ah, but you mentioned elfutilts, not binutils.  I've now downloaded and built
elfutils-0.175.  It took a bit more effort because --disable-werror doesn't
work there but once I got past that I just got the three -Wformat-truncation
instances below:

DiagnosticCount   UniqueFiles
-Wformat-truncation=  332

-Wformat-truncation Instances:
  /src/elfutils-0.175/src/ar.c:1468
  /src/elfutils-0.175/src/ar.c:859
  /src/elfutils-0.175/src/arlib.c:63

The code at line 10167 in readelf.c looks like this:

static void
print_debug_str_offsets_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
 Ebl *ebl,
 GElf_Ehdr *ehdr __attribute__ ((unused)),
 Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
  printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
  elf_ndxscn (scn), section_name (ebl, shdr),
  (uint64_t) shdr->sh_offset);

I'm probably not using the same sources as you, but shouldn't I be seeing at
least some of the warnings?  (I couldn't find an easy way build the top of
trunk -- there's no configure script.)

[Bug tree-optimization/88835] overly aggressive -Werror=format-overflow for printf since r265648

2019-02-14 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88835

--- Comment #10 from Martin Sebor  ---
I've built the top of binutils-gdb with the patch referenced in comment #8
applied and with -Wformat-overflow=2 and -Wformat-truncation=2 and got the
following breakdown:

DiagnosticCount   UniqueFiles
-Wformat-overflow=   19   19   10
-Wformat-truncation= 12   127
-Wconflicts-sr777
-Wmaybe-uninitialized 333
-Wstringop-truncation 222
-Wconflicts-rr222
-Wsign-compare111
-Wother   111


The -Wformat-overflow warnings are:

/src/binutils-gdb/gas/macro.c:386:18: warning: ‘sprintf’ may write a
terminating nul past the end of the destination [-Wformat-overflow=]
/src/binutils-gdb/binutils/arsup.c:158:20: warning: ‘%.*s’ directive output
between 0 and 2147483647 bytes may exceed minimum required size of 4095
[-Wformat-overflow=]
/src/binutils-gdb/binutils/wrstabs.c:426:21: warning: ‘sprintf’ may write a
terminating nul past the end of the destination [-Wformat-overflow=]
/src/binutils-gdb/binutils/wrstabs.c:739:27: warning: ‘%u’ directive writing
between 1 and 10 bytes into a region of size between 7 and 45
[-Wformat-overflow=]
/src/binutils-gdb/binutils/wrstabs.c:620:26: warning: ‘%ld’ directive writing
between 1 and 20 bytes into a region of size between 19 and 38
[-Wformat-overflow=]
/src/binutils-gdb/binutils/wrstabs.c:595:26: warning: ‘%ld’ directive writing
between 1 and 20 bytes into a region of size between 19 and 38
[-Wformat-overflow=]
eelf_iamcu.c:635:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf_iamcu.c:628:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf_x86_64.c:638:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf_x86_64.c:631:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf_i386.c:638:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf_i386.c:631:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf32_x86_64.c:638:25: warning: ‘%.*s’ directive output between 0 and
2147483647 bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf32_x86_64.c:631:25: warning: ‘%.*s’ directive output between 0 and
2147483647 bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf_k1om.c:638:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf_k1om.c:631:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf_l1om.c:638:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
eelf_l1om.c:631:25: warning: ‘%.*s’ directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095 [-Wformat-overflow=]
/src/binutils-gdb/gdb/gdbserver/remote-utils.c:1188:21: warning: ‘%s’ directive
output between 0 and 8191 bytes may exceed minimum required size of 4095
[-Wformat-overflow=]

None for readelf.c.  I think they are all for sprintf (and not printf or
fprintf), so I'm not sure where the ones you are seeing are coming from.

[Bug c++/89356] [9 Regression] sorry, unimplemented: mangling implicit_conv_expr in nodejs8 package since r268321

2019-02-14 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89356

--- Comment #2 from Marek Polacek  ---
A similar testcase

template auto fn () -> decltype(unsigned{0} + T(1));
auto e = fn();

[PATCH wwwdocs] changes.html for "asm inline"

2019-02-14 Thread Segher Boessenkool
Hi!

I did the following patch for the GCC 8 changes.html (in the 8.3 section):

Index: htdocs/gcc-8/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-8/changes.html,v
retrieving revision 1.98
diff -u -r1.98 changes.html
--- htdocs/gcc-8/changes.html   29 Dec 2018 21:09:09 -  1.98
+++ htdocs/gcc-8/changes.html   14 Feb 2019 23:39:34 -
@@ -1354,6 +1354,14 @@
 
 GCC 8.3 is not yet released.
 
+C family
+
+
+  Support has been added for asm inline. An asm
+  that is inline is counted as minimum length for inlining
+  decisions, irrespective of how big it looks otherwise.
+
+
 Windows
 
 


Is that okay?  Also okay for GCC 7.5?  And for GCC 9?


Segher


[PATCH, i386]: Enable MMX, SSE and SSE2 by default in TARGET_SUBTARGET64_ISA_DEFAULT

2019-02-14 Thread Uros Bizjak
No functional changes.

2019-02-15  Uroš Bizjak  

* config/i386/i386.h (TARGET_SUBTARGET64_ISA_DEFAULT):
Enable MMX, SSE and SSE2 by default.
* config/i386/i386.c (ix86_option_override_internal): Do not
explicitly set MMX, SSE and SSE2 flags for TARGET_64BIT here.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 268907)
+++ config/i386/i386.c  (working copy)
@@ -4165,14 +4165,9 @@ ix86_option_override_internal (bool main_args_p,
   opts->x_target_flags
|= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
 
-  /* Enable by default the SSE and MMX builtins.  Do allow the user to
-explicitly disable any of these.  In particular, disabling SSE and
-MMX for kernel code is extremely useful.  */
   if (!ix86_arch_specified)
-  opts->x_ix86_isa_flags
-   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_MMX
-| TARGET_SUBTARGET64_ISA_DEFAULT)
-& ~opts->x_ix86_isa_flags_explicit);
+   opts->x_ix86_isa_flags
+ |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
 
   if (TARGET_RTD_P (opts->x_target_flags))
warning (0,
Index: config/i386/i386.h
===
--- config/i386/i386.h  (revision 268907)
+++ config/i386/i386.h  (working copy)
@@ -633,7 +633,9 @@ extern tree x86_mfence;
 
 /* Extra bits to force on w/ 64-bit mode.  */
 #define TARGET_SUBTARGET64_DEFAULT 0
-#define TARGET_SUBTARGET64_ISA_DEFAULT 0
+/* Enable MMX, SSE and SSE2 by default.  */
+#define TARGET_SUBTARGET64_ISA_DEFAULT \
+  (OPTION_MASK_ISA_MMX | OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_SSE2)
 
 /* Replace MACH-O, ifdefs by in-line tests, where possible. 
(a) Macros defined in config/i386/darwin.h  */


[Bug tree-optimization/89350] [9 Regression] Wrong -Wstringop-overflow= warning since r261518

2019-02-14 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89350

--- Comment #1 from Martin Sebor  ---
The -Wstringop-overflow warning is a consequence of pointer offsets being
treated as unsigned integers, argc being signed, and the object size
computation returning scalars rather than ranges.  In the first test case (with
argc + 0):

   [local count: 354334802]:
  _1 = (sizetype) argc_5(D);
  _2 = -_1;
  dst_7 = [(void *) + 128B] + _2;
  src.0_3 = src;
  __builtin_memcpy (dst_7, src.0_3, _1);

When computing the size of dst_7 the compute_objsize() function determines the
offset _2 to be in the range [1, SIZE_MAX] and doesn't consider the fact that
the upper half of the range represents negative values.  As a result, it
determines the size to be zero.  The number of bytes to write (i.e.,
(size_t)(argc + 1) is [1, SIZE_MAX]).

The test case makes the tacit assumption that argc is necessarily non-negative.
 That makes sense for the argc argument to main but not in other situations. 
Changing the if condition to make the assumption explicit 'if (argc > 0)'
eliminates the warning.  This makes range of the offset [-INT_MAX, -1], and
because compute_objsize() doesn't handle negative offsets, it fails to
determine the size.  There's a comment indicating that is not a feature but a
known limitation:

  /* Ignore negative offsets for now.  For others,
 use the lower bound as the most optimistic
 estimate of the (remaining)size.  */

If I recall I did that not because negative offsets cannot be handled better
but to keep the code simple.  Either way, with negative offsets handled the
warning will not be issued.

The missing -Wstringop-overflow in the second test case (with argc + 1):

   [local count: 354334802]:
  _1 = (sizetype) argc_7(D);
  _2 = -_1;
  dst_9 = [(void *) + 128B] + _2;
  _3 = argc_7(D) + 1;
  _4 = (long unsigned int) _3;
  src.0_5 = src;
  __builtin_memcpy (dst_9, src.0_5, _4);

is due to the number of bytes to write is [0, INT_MAX] so the warning doesn't
trigger.

The bogus warning can be avoided in the first case simply by punting on offsets
that could be in the negative range, but almost certainly not without some
false negatives.  I'm not sure it's necessarily a good tradeoff (I don't know
that it isn't either).  Is this code representative of some wide-spread idiom?

A more robust solution, one that gets rid of the false positives without as
many false negatives, will involve changing compute_objsize() to return a range
of sizes rather than a constant.  But that will have to wait for GCC 10.

[Bug middle-end/70090] add non-constant variant of __builtin_object_size for _FORTIFY_SOURCE and -fsanitize=object-size

2019-02-14 Thread danielmicay at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70090

--- Comment #2 from Daniel Micay  ---
This has now been implemented in Clang as __builtin_dynamic_object_size.
There's a thread on the GCC mailing list about it at
https://www.mail-archive.com/gcc@gcc.gnu.org/msg87230.html.

Re: [PATCH 37/40] i386: Allow MMX intrinsic emulation with SSE

2019-02-14 Thread H.J. Lu
On Thu, Feb 14, 2019 at 3:21 PM Uros Bizjak  wrote:
>
> On Fri, Feb 15, 2019 at 12:14 AM H.J. Lu  wrote:
>
> > > > > > > > > gcc/
> > > > > > > > >
> > > > > > > > > PR target/89021
> > > > > > > > > * config/i386/i386-builtin.def: Enable MMX intrinsics 
> > > > > > > > > with
> > > > > > > > > SSE/SSE2/SSSE3.
> > > > > > > > > * config/i386/i386.c (ix86_option_override_internal): 
> > > > > > > > > Don't
> > > > > > > > > enable MMX ISA with TARGET_MMX_WITH_SSE by default.
> > > > > > > > > (ix86_init_mmx_sse_builtins): Enable MMX intrinsics 
> > > > > > > > > with
> > > > > > > > > SSE/SSE2/SSSE3.
> > > > > > > > > (ix86_expand_builtin): Allow SSE/SSE2/SSSE3 to 
> > > > > > > > > emulate MMX
> > > > > > > > > intrinsics with TARGET_MMX_WITH_SSE.
> > > > > > > > > * config/i386/mmintrin.h: Don't require MMX in 64-bit 
> > > > > > > > > mode.
> > > > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > > > > > > > > index a9abbe8706b..1d417e08734 100644
> > > > > > > > > --- a/gcc/config/i386/i386.c
> > > > > > > > > +++ b/gcc/config/i386/i386.c
> > > > > > > > > @@ -4165,12 +4165,15 @@ ix86_option_override_internal (bool 
> > > > > > > > > main_args_p,
> > > > > > > > >opts->x_target_flags
> > > > > > > > > |= TARGET_SUBTARGET64_DEFAULT & 
> > > > > > > > > ~opts_set->x_target_flags;
> > > > > > > > >
> > > > > > > > > -  /* Enable by default the SSE and MMX builtins.  Do 
> > > > > > > > > allow the user to
> > > > > > > > > -explicitly disable any of these.  In particular, 
> > > > > > > > > disabling SSE and
> > > > > > > > > -MMX for kernel code is extremely useful.  */
> > > > > > > > > +  /* Enable the SSE and MMX builtins by default.  Don't 
> > > > > > > > > enable MMX
> > > > > > > > > + ISA with TARGET_MMX_WITH_SSE by default.  Do allow 
> > > > > > > > > the user to
> > > > > > > > > +explicitly disable any of these.  In particular, 
> > > > > > > > > disabling SSE
> > > > > > > > > +and MMX for kernel code is extremely useful.  */
> > > > > > > > >if (!ix86_arch_specified)
> > > > > > > > >opts->x_ix86_isa_flags
> > > > > > > > > -   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | 
> > > > > > > > > OPTION_MASK_ISA_MMX
> > > > > > > > > +   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > > > > > > > > +| (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > > > > > > > +   ? 0 : OPTION_MASK_ISA_MMX)
> > > > > > > > >  | TARGET_SUBTARGET64_ISA_DEFAULT)
> > > > > > > > >  & ~opts->x_ix86_isa_flags_explicit);
> > > > > > > >
> > > > > > > > Please split the above into two clauses, the first that sets 
> > > > > > > > SSE and
> > > > > > > > MMX by default, and the second to or with
> > > > > > > >
> > > > > > > > opts->x_ix86_isa_flags
> > > > > > > >  |= TARGET_SUBTARGET64_ISA_DEFAULT & 
> > > > > > > > ~opts->x_ix86_isa_flags_explicit
> > > > > > > >
> > > > > > >
> > > > > > > Like this?
> > > > > >
> > > > > > Yes, but also split the comment.
> > > > >
> > > > > I will go with
> > > > >
> > > > >  /* Enable by default the SSE and MMX builtins.  Do allow the 
> > > > > user to
> > > > >  explicitly disable any of these.  In particular, disabling 
> > > > > SSE and
> > > > >  MMX for kernel code is extremely useful.  */
> > > > >   if (!ix86_arch_specified)
> > > > > {
> > > > >   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
> > > > >   opts->x_ix86_isa_flags
> > > > > |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > > > >  | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > > > ? 0 : OPTION_MASK_ISA_MMX))
> > > > > & ~opts->x_ix86_isa_flags_explicit);
> > > > >   opts->x_ix86_isa_flags
> > > > > |= (TARGET_SUBTARGET64_ISA_DEFAULT
> > > > > & ~opts->x_ix86_isa_flags_explicit);
> > > > > }
> > > >
> > > > I'll commit the following patch that finally defines
> > > > TARGET_SUBTARGET64_ISA_DEFAULT. You could then simply clear the MMX
> > > > bit from x_i86_isa_flags, like:
> > > >
> > > >   if (!ix86_arch_specified)
> > > > opts->x_ix86_isa_flags
> > > >   |= TARGET_SUBTARGET64_ISA_DEFAULT & 
> > > > ~opts->x_ix86_isa_flags_explicit;
> > > >
> > > >   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
> > > >   if (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags))
> > > > opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_MMX;
> > >
> > > I think it should be:
> > >
> > >   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
> > >   if (!(opts->x_ix86_isa_flags & OPTION_MASK_ISA_MMX)
> > I meant opts->x_ix86_isa_flags_explicit.
> > >   && TARGET_MMX_WITH_SSE_P 

Re: [PATCH 37/40] i386: Allow MMX intrinsic emulation with SSE

2019-02-14 Thread Uros Bizjak
On Fri, Feb 15, 2019 at 12:14 AM H.J. Lu  wrote:

> > > > > > > > gcc/
> > > > > > > >
> > > > > > > > PR target/89021
> > > > > > > > * config/i386/i386-builtin.def: Enable MMX intrinsics 
> > > > > > > > with
> > > > > > > > SSE/SSE2/SSSE3.
> > > > > > > > * config/i386/i386.c (ix86_option_override_internal): 
> > > > > > > > Don't
> > > > > > > > enable MMX ISA with TARGET_MMX_WITH_SSE by default.
> > > > > > > > (ix86_init_mmx_sse_builtins): Enable MMX intrinsics with
> > > > > > > > SSE/SSE2/SSSE3.
> > > > > > > > (ix86_expand_builtin): Allow SSE/SSE2/SSSE3 to emulate 
> > > > > > > > MMX
> > > > > > > > intrinsics with TARGET_MMX_WITH_SSE.
> > > > > > > > * config/i386/mmintrin.h: Don't require MMX in 64-bit 
> > > > > > > > mode.
> > > > > > > >
> > > > > >
> > > > > > >
> > > > > > > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > > > > > > > index a9abbe8706b..1d417e08734 100644
> > > > > > > > --- a/gcc/config/i386/i386.c
> > > > > > > > +++ b/gcc/config/i386/i386.c
> > > > > > > > @@ -4165,12 +4165,15 @@ ix86_option_override_internal (bool 
> > > > > > > > main_args_p,
> > > > > > > >opts->x_target_flags
> > > > > > > > |= TARGET_SUBTARGET64_DEFAULT & 
> > > > > > > > ~opts_set->x_target_flags;
> > > > > > > >
> > > > > > > > -  /* Enable by default the SSE and MMX builtins.  Do allow 
> > > > > > > > the user to
> > > > > > > > -explicitly disable any of these.  In particular, 
> > > > > > > > disabling SSE and
> > > > > > > > -MMX for kernel code is extremely useful.  */
> > > > > > > > +  /* Enable the SSE and MMX builtins by default.  Don't 
> > > > > > > > enable MMX
> > > > > > > > + ISA with TARGET_MMX_WITH_SSE by default.  Do allow 
> > > > > > > > the user to
> > > > > > > > +explicitly disable any of these.  In particular, 
> > > > > > > > disabling SSE
> > > > > > > > +and MMX for kernel code is extremely useful.  */
> > > > > > > >if (!ix86_arch_specified)
> > > > > > > >opts->x_ix86_isa_flags
> > > > > > > > -   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | 
> > > > > > > > OPTION_MASK_ISA_MMX
> > > > > > > > +   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > > > > > > > +| (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > > > > > > +   ? 0 : OPTION_MASK_ISA_MMX)
> > > > > > > >  | TARGET_SUBTARGET64_ISA_DEFAULT)
> > > > > > > >  & ~opts->x_ix86_isa_flags_explicit);
> > > > > > >
> > > > > > > Please split the above into two clauses, the first that sets SSE 
> > > > > > > and
> > > > > > > MMX by default, and the second to or with
> > > > > > >
> > > > > > > opts->x_ix86_isa_flags
> > > > > > >  |= TARGET_SUBTARGET64_ISA_DEFAULT & 
> > > > > > > ~opts->x_ix86_isa_flags_explicit
> > > > > > >
> > > > > >
> > > > > > Like this?
> > > > >
> > > > > Yes, but also split the comment.
> > > >
> > > > I will go with
> > > >
> > > >  /* Enable by default the SSE and MMX builtins.  Do allow the user 
> > > > to
> > > >  explicitly disable any of these.  In particular, disabling SSE 
> > > > and
> > > >  MMX for kernel code is extremely useful.  */
> > > >   if (!ix86_arch_specified)
> > > > {
> > > >   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
> > > >   opts->x_ix86_isa_flags
> > > > |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > > >  | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > > ? 0 : OPTION_MASK_ISA_MMX))
> > > > & ~opts->x_ix86_isa_flags_explicit);
> > > >   opts->x_ix86_isa_flags
> > > > |= (TARGET_SUBTARGET64_ISA_DEFAULT
> > > > & ~opts->x_ix86_isa_flags_explicit);
> > > > }
> > >
> > > I'll commit the following patch that finally defines
> > > TARGET_SUBTARGET64_ISA_DEFAULT. You could then simply clear the MMX
> > > bit from x_i86_isa_flags, like:
> > >
> > >   if (!ix86_arch_specified)
> > > opts->x_ix86_isa_flags
> > >   |= TARGET_SUBTARGET64_ISA_DEFAULT & 
> > > ~opts->x_ix86_isa_flags_explicit;
> > >
> > >   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
> > >   if (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags))
> > > opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_MMX;
> >
> > I think it should be:
> >
> >   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
> >   if (!(opts->x_ix86_isa_flags & OPTION_MASK_ISA_MMX)
> I meant opts->x_ix86_isa_flags_explicit.
> >   && TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags))
> > opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_MMX;

Well ... I didn't test this part. OTOH, maybe this part is not needed,
MMX disabling can go *after*

  /* Turn on MMX builtins for -msse.  */
  if (TARGET_SSE_P (opts->x_ix86_isa_flags))

[Bug c++/67491] [meta-bug] concepts issues

2019-02-14 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67491
Bug 67491 depends on bug 89036, which changed state.

Bug 89036 Summary: [8 Regression] ICE if destructor has a requires
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89036

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

[Bug c++/89036] [8 Regression] ICE if destructor has a requires

2019-02-14 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89036

David Malcolm  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from David Malcolm  ---
Fixed on gcc-8-branch by r268916; marking as FIXED.

[Bug c++/89036] [8 Regression] ICE if destructor has a requires

2019-02-14 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89036

--- Comment #7 from David Malcolm  ---
Author: dmalcolm
Date: Thu Feb 14 23:17:51 2019
New Revision: 268916

URL: https://gcc.gnu.org/viewcvs?rev=268916=gcc=rev
Log:
C++ concepts: fix ICE with requires on dtors (PR c++/89036)

PR c++/89036 reports an ICE due to this assertion failing

1136  /* A class should never have more than one destructor.  */
1137  gcc_assert (!current_fns || via_using || !DECL_DESTRUCTOR_P
(method));

on this template with a pair of dtors, with
mutually exclusive "requires" clauses:

template
struct Y {
~Y() requires(true) = default;
~Y() requires(false) {}
};

Nathan introduced this assertion as part of:

  ca9219bf18c68a001d62ecb981bc9176b0feaf12 (aka r251340):
2017-08-24  Nathan Sidwell  
   Conversion operators kept on single overload set

which, amongst other changes to add_method had this:
 /* A class should never have more than one destructor.  */
  -  if (current_fns && DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (method))
  -return false;
  +  gcc_assert (!current_fns || !DECL_DESTRUCTOR_P (method));

The following patch drops the assertion.

gcc/cp/ChangeLog:
2019-02-13  David Malcolm  
Backport of r268847 from trunk.

PR c++/89036
* class.c (add_method): Drop destructor assertion.

gcc/testsuite/ChangeLog:
2019-02-13  David Malcolm  
Backport of r268847 from trunk.

PR c++/89036
* g++.dg/concepts/pr89036.C: New test.


Added:
branches/gcc-8-branch/gcc/testsuite/g++.dg/concepts/pr89036.C
Modified:
branches/gcc-8-branch/gcc/cp/ChangeLog
branches/gcc-8-branch/gcc/cp/class.c
branches/gcc-8-branch/gcc/testsuite/ChangeLog

[committed] Fix combiner's make_extraction (PR rtl-optimization/89354)

2019-02-14 Thread Jakub Jelinek
Hi!

The following testcase is miscompiled on i686-linux, because
make_extraction is asked to make an extraction of 33 bits from DImode MEM
at position 0 and happily returns ZERO_EXTRACT with SImode (even when SImode
can hold only 32 bits), the caller (make_field_assignment) then on this
testcase because of that throws away the |= 0x1ULL.

Fixed thusly, bootstrapped/regtested on {x86_64,i686,powerpc64{,le}}-linux,
preapproved by Segher on IRC, committed to trunk and 8.x branch.

I've also gathered statistics and the only time during those bootstraps and
(except for still pending (second) powerpc64-linux regtest) regtests the
only time this patch made any difference was on this newly added testcase on
i686-linux.

2019-02-14  Jakub Jelinek  

PR rtl-optimization/89354
* combine.c (make_extraction): Punt if extraction_mode is narrower
than len bits.

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

--- gcc/combine.c.jj2019-02-05 16:38:28.0 +0100
+++ gcc/combine.c   2019-02-14 16:45:41.445096523 +0100
@@ -7830,6 +7830,10 @@ make_extraction (machine_mode mode, rtx
   && partial_subreg_p (extraction_mode, mode))
 extraction_mode = mode;
 
+  /* Punt if len is too large for extraction_mode.  */
+  if (maybe_gt (len, GET_MODE_PRECISION (extraction_mode)))
+return NULL_RTX;
+
   if (!MEM_P (inner))
 wanted_inner_mode = wanted_inner_reg_mode;
   else
--- gcc/testsuite/gcc.dg/pr89354.c.jj   2019-02-14 17:02:26.013552853 +0100
+++ gcc/testsuite/gcc.dg/pr89354.c  2019-02-14 17:01:44.431237813 +0100
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/89354 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+
+static unsigned long long q = 0;
+
+__attribute__((noipa)) static void
+foo (void)
+{
+  q = (q & ~0x1ULL) | 0x1ULL;
+}
+
+int
+main ()
+{
+  __asm volatile ("" : "+m" (q));
+  foo ();
+  if (q != 0x1ULL)
+__builtin_abort ();
+  return 0;
+}

Jakub


[Bug c++/88795] ICE on class-template argument deduction if non-type parameter has indirection

2019-02-14 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88795

--- Comment #6 from David Malcolm  ---
Author: dmalcolm
Date: Thu Feb 14 23:14:56 2019
New Revision: 268915

URL: https://gcc.gnu.org/viewcvs?rev=268915=gcc=rev
Log:
Fix ICE on class-template argument deduction (PR c++/88795)

PR c++/88795 reports an ICE building a function_type for a deduction guide
when the substitution into the function signature fails, due to an
error_mark_node being returned from tsubst_arg_types but not being checked
for.  This error_mark_node gets used as the TYPE_ARG_TYPES, leading to
ICEs in various places that assume this is a TREE_LIST.

This patch checks the result of tsubst_arg_types and propagates the failure
if it returns error_mark_node.  It also adds an assertion to
build_function_type, to fail faster if passed in error_mark_node.

gcc/cp/ChangeLog:
Backport of r267957 from trunk.
2019-01-15  David Malcolm  

PR c++/88795
* pt.c (build_deduction_guide): Bail out if tsubst_arg_types
fails.

gcc/testsuite/ChangeLog:
Backport of r267957 from trunk.
2019-01-15  David Malcolm  

PR c++/88795
* g++.dg/template/pr88795.C: New test.

gcc/ChangeLog:
Backport of r267957 from trunk.
2019-01-15  David Malcolm  

PR c++/88795
* tree.c (build_function_type): Assert that arg_types is not
error_mark_node.


Added:
branches/gcc-8-branch/gcc/testsuite/g++.dg/template/pr88795.C
Modified:
branches/gcc-8-branch/gcc/ChangeLog
branches/gcc-8-branch/gcc/cp/ChangeLog
branches/gcc-8-branch/gcc/cp/pt.c
branches/gcc-8-branch/gcc/testsuite/ChangeLog
branches/gcc-8-branch/gcc/tree.c

Re: [PATCH 37/40] i386: Allow MMX intrinsic emulation with SSE

2019-02-14 Thread H.J. Lu
On Thu, Feb 14, 2019 at 3:12 PM H.J. Lu  wrote:
>
> On Thu, Feb 14, 2019 at 2:57 PM Uros Bizjak  wrote:
> >
> > On Thu, Feb 14, 2019 at 10:02 PM H.J. Lu  wrote:
> >
> > > > > > > gcc/
> > > > > > >
> > > > > > > PR target/89021
> > > > > > > * config/i386/i386-builtin.def: Enable MMX intrinsics with
> > > > > > > SSE/SSE2/SSSE3.
> > > > > > > * config/i386/i386.c (ix86_option_override_internal): 
> > > > > > > Don't
> > > > > > > enable MMX ISA with TARGET_MMX_WITH_SSE by default.
> > > > > > > (ix86_init_mmx_sse_builtins): Enable MMX intrinsics with
> > > > > > > SSE/SSE2/SSSE3.
> > > > > > > (ix86_expand_builtin): Allow SSE/SSE2/SSSE3 to emulate MMX
> > > > > > > intrinsics with TARGET_MMX_WITH_SSE.
> > > > > > > * config/i386/mmintrin.h: Don't require MMX in 64-bit 
> > > > > > > mode.
> > > > > > >
> > > > >
> > > > > >
> > > > > > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > > > > > > index a9abbe8706b..1d417e08734 100644
> > > > > > > --- a/gcc/config/i386/i386.c
> > > > > > > +++ b/gcc/config/i386/i386.c
> > > > > > > @@ -4165,12 +4165,15 @@ ix86_option_override_internal (bool 
> > > > > > > main_args_p,
> > > > > > >opts->x_target_flags
> > > > > > > |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
> > > > > > >
> > > > > > > -  /* Enable by default the SSE and MMX builtins.  Do allow 
> > > > > > > the user to
> > > > > > > -explicitly disable any of these.  In particular, 
> > > > > > > disabling SSE and
> > > > > > > -MMX for kernel code is extremely useful.  */
> > > > > > > +  /* Enable the SSE and MMX builtins by default.  Don't 
> > > > > > > enable MMX
> > > > > > > + ISA with TARGET_MMX_WITH_SSE by default.  Do allow the 
> > > > > > > user to
> > > > > > > +explicitly disable any of these.  In particular, 
> > > > > > > disabling SSE
> > > > > > > +and MMX for kernel code is extremely useful.  */
> > > > > > >if (!ix86_arch_specified)
> > > > > > >opts->x_ix86_isa_flags
> > > > > > > -   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | 
> > > > > > > OPTION_MASK_ISA_MMX
> > > > > > > +   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > > > > > > +| (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > > > > > +   ? 0 : OPTION_MASK_ISA_MMX)
> > > > > > >  | TARGET_SUBTARGET64_ISA_DEFAULT)
> > > > > > >  & ~opts->x_ix86_isa_flags_explicit);
> > > > > >
> > > > > > Please split the above into two clauses, the first that sets SSE and
> > > > > > MMX by default, and the second to or with
> > > > > >
> > > > > > opts->x_ix86_isa_flags
> > > > > >  |= TARGET_SUBTARGET64_ISA_DEFAULT & 
> > > > > > ~opts->x_ix86_isa_flags_explicit
> > > > > >
> > > > >
> > > > > Like this?
> > > >
> > > > Yes, but also split the comment.
> > >
> > > I will go with
> > >
> > >  /* Enable by default the SSE and MMX builtins.  Do allow the user to
> > >  explicitly disable any of these.  In particular, disabling SSE 
> > > and
> > >  MMX for kernel code is extremely useful.  */
> > >   if (!ix86_arch_specified)
> > > {
> > >   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
> > >   opts->x_ix86_isa_flags
> > > |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > >  | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > ? 0 : OPTION_MASK_ISA_MMX))
> > > & ~opts->x_ix86_isa_flags_explicit);
> > >   opts->x_ix86_isa_flags
> > > |= (TARGET_SUBTARGET64_ISA_DEFAULT
> > > & ~opts->x_ix86_isa_flags_explicit);
> > > }
> >
> > I'll commit the following patch that finally defines
> > TARGET_SUBTARGET64_ISA_DEFAULT. You could then simply clear the MMX
> > bit from x_i86_isa_flags, like:
> >
> >   if (!ix86_arch_specified)
> > opts->x_ix86_isa_flags
> >   |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
> >
> >   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
> >   if (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags))
> > opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_MMX;
>
> I think it should be:
>
>   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
>   if (!(opts->x_ix86_isa_flags & OPTION_MASK_ISA_MMX)
I meant opts->x_ix86_isa_flags_explicit.
>   && TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags))
> opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_MMX;
>
> Thanks.
>
> --
> H.J.



-- 
H.J.


[Bug rtl-optimization/89354] [7/8/9 Regression] Combine pass yields wrong code with -O2 and -msse2 for 32bit target

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89354

--- Comment #5 from Jakub Jelinek  ---
Author: jakub
Date: Thu Feb 14 23:12:26 2019
New Revision: 268914

URL: https://gcc.gnu.org/viewcvs?rev=268914=gcc=rev
Log:
PR rtl-optimization/89354
* combine.c (make_extraction): Punt if extraction_mode is narrower
than len bits.

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

Added:
branches/gcc-8-branch/gcc/testsuite/gcc.dg/pr89354.c
Modified:
branches/gcc-8-branch/gcc/ChangeLog
branches/gcc-8-branch/gcc/combine.c
branches/gcc-8-branch/gcc/testsuite/ChangeLog

Re: [PATCH 37/40] i386: Allow MMX intrinsic emulation with SSE

2019-02-14 Thread H.J. Lu
On Thu, Feb 14, 2019 at 2:57 PM Uros Bizjak  wrote:
>
> On Thu, Feb 14, 2019 at 10:02 PM H.J. Lu  wrote:
>
> > > > > > gcc/
> > > > > >
> > > > > > PR target/89021
> > > > > > * config/i386/i386-builtin.def: Enable MMX intrinsics with
> > > > > > SSE/SSE2/SSSE3.
> > > > > > * config/i386/i386.c (ix86_option_override_internal): Don't
> > > > > > enable MMX ISA with TARGET_MMX_WITH_SSE by default.
> > > > > > (ix86_init_mmx_sse_builtins): Enable MMX intrinsics with
> > > > > > SSE/SSE2/SSSE3.
> > > > > > (ix86_expand_builtin): Allow SSE/SSE2/SSSE3 to emulate MMX
> > > > > > intrinsics with TARGET_MMX_WITH_SSE.
> > > > > > * config/i386/mmintrin.h: Don't require MMX in 64-bit mode.
> > > > > >
> > > >
> > > > >
> > > > > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > > > > > index a9abbe8706b..1d417e08734 100644
> > > > > > --- a/gcc/config/i386/i386.c
> > > > > > +++ b/gcc/config/i386/i386.c
> > > > > > @@ -4165,12 +4165,15 @@ ix86_option_override_internal (bool 
> > > > > > main_args_p,
> > > > > >opts->x_target_flags
> > > > > > |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
> > > > > >
> > > > > > -  /* Enable by default the SSE and MMX builtins.  Do allow the 
> > > > > > user to
> > > > > > -explicitly disable any of these.  In particular, disabling 
> > > > > > SSE and
> > > > > > -MMX for kernel code is extremely useful.  */
> > > > > > +  /* Enable the SSE and MMX builtins by default.  Don't enable 
> > > > > > MMX
> > > > > > + ISA with TARGET_MMX_WITH_SSE by default.  Do allow the 
> > > > > > user to
> > > > > > +explicitly disable any of these.  In particular, disabling 
> > > > > > SSE
> > > > > > +and MMX for kernel code is extremely useful.  */
> > > > > >if (!ix86_arch_specified)
> > > > > >opts->x_ix86_isa_flags
> > > > > > -   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | 
> > > > > > OPTION_MASK_ISA_MMX
> > > > > > +   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > > > > > +| (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > > > > +   ? 0 : OPTION_MASK_ISA_MMX)
> > > > > >  | TARGET_SUBTARGET64_ISA_DEFAULT)
> > > > > >  & ~opts->x_ix86_isa_flags_explicit);
> > > > >
> > > > > Please split the above into two clauses, the first that sets SSE and
> > > > > MMX by default, and the second to or with
> > > > >
> > > > > opts->x_ix86_isa_flags
> > > > >  |= TARGET_SUBTARGET64_ISA_DEFAULT & 
> > > > > ~opts->x_ix86_isa_flags_explicit
> > > > >
> > > >
> > > > Like this?
> > >
> > > Yes, but also split the comment.
> >
> > I will go with
> >
> >  /* Enable by default the SSE and MMX builtins.  Do allow the user to
> >  explicitly disable any of these.  In particular, disabling SSE and
> >  MMX for kernel code is extremely useful.  */
> >   if (!ix86_arch_specified)
> > {
> >   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
> >   opts->x_ix86_isa_flags
> > |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> >  | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > ? 0 : OPTION_MASK_ISA_MMX))
> > & ~opts->x_ix86_isa_flags_explicit);
> >   opts->x_ix86_isa_flags
> > |= (TARGET_SUBTARGET64_ISA_DEFAULT
> > & ~opts->x_ix86_isa_flags_explicit);
> > }
>
> I'll commit the following patch that finally defines
> TARGET_SUBTARGET64_ISA_DEFAULT. You could then simply clear the MMX
> bit from x_i86_isa_flags, like:
>
>   if (!ix86_arch_specified)
> opts->x_ix86_isa_flags
>   |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
>
>   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
>   if (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags))
> opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_MMX;

I think it should be:

  /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
  if (!(opts->x_ix86_isa_flags & OPTION_MASK_ISA_MMX)
  && TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags))
opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_MMX;

Thanks.

-- 
H.J.


[Bug rtl-optimization/89354] [7/8/9 Regression] Combine pass yields wrong code with -O2 and -msse2 for 32bit target

2019-02-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89354

--- Comment #4 from Jakub Jelinek  ---
Author: jakub
Date: Thu Feb 14 23:10:47 2019
New Revision: 268913

URL: https://gcc.gnu.org/viewcvs?rev=268913=gcc=rev
Log:
PR rtl-optimization/89354
* combine.c (make_extraction): Punt if extraction_mode is narrower
than len bits.

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

Added:
trunk/gcc/testsuite/gcc.dg/pr89354.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/combine.c
trunk/gcc/testsuite/ChangeLog

Re: [PATCH][DOC] Document new features for GCC 9.

2019-02-14 Thread Martin Sebor

On 2/14/19 3:37 PM, David Malcolm wrote:

On Thu, 2019-02-14 at 14:19 -0700, Martin Sebor wrote:

On 2/13/19 6:48 AM, Martin Liška wrote:

Hi.

I'm sending patch where I document changes I made during GCC 9
development. I would appreciate both language and factical comments
about the patch.


Nothing technical, just a few very minor language nits/suggestions.

Martin

diff --git a/htdocs/gcc-9/changes.html b/htdocs/gcc-9/changes.html
index 13243c2..9fec9e2 100644
--- a/htdocs/gcc-9/changes.html
+++ b/htdocs/gcc-9/changes.html
@@ -50,11 +50,64 @@ a work-in-progress.
   General Improvements
   
 
-A new option -flive-patching=[inline-only-static|inline-clone]
is
+A new option
-flive-patching=[inline-only-static|inline-clone] is

s/is/has been/ would be better (and either a comma after option or
a definite article without the comma).

   introduced to provide a safe compilation for live-patching. At
the
same
   time, provides multiple-level control on the enabled IPA
optimizations.
   See the user guide for further information about the option for
more
-details.
+details.


Ideally we should add URLs any time we mention an option, linking to
the docs for that option.  texinfo's HTML toolchain does give us per-
option anchors.  They're not visible [1], but "View Source" shows us
that they do exist; in the form:

https://gcc.gnu.org/onlinedocs/gcc/SOMETHING.html#indexOPTION

though annoyingly the SOMETHING varies depending on what kind of option
it is.

The pertinent one here is:
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-flive-patching

(FWIW, I have a patch for GCC 10 that emits terminal sequences to
"linkify" the output when diagnostics mention option names, adding a
URL to the docs for the pertinent option).


That sounds awesome!

Martin



[...snip...]

Dave

[1] I've emailed the texinfo project about this





[Bug c++/86329] Bogus fix-it hint: note: suggested alternative: '._72'

2019-02-14 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86329

--- Comment #6 from David Malcolm  ---
Author: dmalcolm
Date: Thu Feb 14 23:02:45 2019
New Revision: 268909

URL: https://gcc.gnu.org/viewcvs?rev=268909=gcc=rev
Log:
C++: don't offer bogus "._0" suggestions (PR c++/86329)

PR c++/86329 reports that the C++ frontend can offer bogus suggestions like:

  #include 

  int compare()
  {
return __n1 - __n2;
  }

suggested.cc: In function 'int compare()':
suggested.cc:5:10: error: '__n1' was not declared in this scope
   return __n1 - __n2;
  ^~~~
suggested.cc:5:10: note: suggested alternative: '._61'
   return __n1 - __n2;
  ^~~~
  ._61
suggested.cc:5:17: error: '__n2' was not declared in this scope
   return __n1 - __n2;
 ^~~~
suggested.cc:5:17: note: suggested alternative: '._72'
   return __n1 - __n2;
 ^~~~
 ._72

The dot-prefixed names are an implementation detail of how we implement
anonymous enums found in the header files, generated via
anon_aggrname_format in make_anon_name.

This patch uses anon_aggrname_p to filter them out when considering
which names to suggest.

gcc/cp/ChangeLog:
Backport of r262199 from trunk.
2018-06-27  David Malcolm  

PR c++/86329
* name-lookup.c (consider_binding_level): Filter out names that
match anon_aggrname_p.

gcc/testsuite/ChangeLog:
Backport of r262199 from trunk.
2018-06-27  David Malcolm  

PR c++/86329
* g++.dg/lookup/pr86329.C: New test.


Added:
branches/gcc-8-branch/gcc/testsuite/g++.dg/lookup/pr86329.C
Modified:
branches/gcc-8-branch/gcc/cp/ChangeLog
branches/gcc-8-branch/gcc/cp/name-lookup.c
branches/gcc-8-branch/gcc/testsuite/ChangeLog

Re: [C++ PATCH] preview: Fix braces around scalar initializer (C++/88572) Inbox x

2019-02-14 Thread Jason Merrill

On 2/12/19 6:04 PM, will wray wrote:

A proposed patch for Bug 88572 is attached to the bug report along
with a short description and Change Log (a link there gives a pretty
diff of the patch):

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88572#c15

I'd appreciate any review of this patch, as well as testing on more
platforms. The patch with updated tests passes for me on x86_64.

There's also test code in bug comment #1 that demonstrates SFINAE
based on the nesting of braces. It could also be added to the
testsuite - I'm not sure how to do that or if it is needed.



+ if (cxx_dialect < cxx11 || first_initializer_p)


I would expect this to miss the error in

struct A { int i; } a = {{{42}}};

I see that we end up complaining about this in convert_like_real because 
implicit_conversion catches the problem here, but I think we ought to 
catch it in reshape_init_r as well.  So, also complain if the element of 
the CONSTRUCTOR is also BRACE_ENCLOSED_INITIALIZER_P.


Jason


[C PATCH] Reject weak nested functions (PR c/89340)

2019-02-14 Thread Jakub Jelinek
Hi!

We ICE on the following testcase, because C nested functions are turned into
!TREE_PUBLIC ones very soon,  and the IPA code asserts that DECL_WEAK functions
are either TREE_PUBLIC or DECL_EXTERNAL.
As we reject static __attribute__((weak)) void foo () {}, I think we should
reject weak nested functions, they don't make much sense either, they are
TU local too.

The following patch fixes that.  The other effect of the patch is that leaf
attribute is warned and ignored on the nested function, but similarly, we
ignore and warn for leaf attribute on other TU local functions, we see the
nested function body and can analyze everything in it.

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

2019-02-14  Jakub Jelinek  

PR c/89340
* c-decl.c (start_function): Clear TREE_PUBLIC on nested functions
before c_decl_attributes rather than after it.

* gcc.dg/pr89340.c: New test.
* gcc.dg/torture/pr57036-2.c (jpgDecode_convert): Expect a warning
that leaf attribute on nested function is useless.

--- gcc/c/c-decl.c.jj   2019-02-06 09:53:49.0 +0100
+++ gcc/c/c-decl.c  2019-02-14 14:03:23.630109817 +0100
@@ -8904,6 +8904,10 @@ start_function (struct c_declspecs *decl
 
   loc = DECL_SOURCE_LOCATION (decl1);
 
+  /* A nested function is not global.  */
+  if (current_function_decl != NULL_TREE)
+TREE_PUBLIC (decl1) = 0;
+
   c_decl_attributes (, attributes, 0);
 
   if (DECL_DECLARED_INLINE_P (decl1)
@@ -8945,10 +8949,6 @@ start_function (struct c_declspecs *decl
  error_mark_node is replaced below (in pop_scope) with the BLOCK.  */
   DECL_INITIAL (decl1) = error_mark_node;
 
-  /* A nested function is not global.  */
-  if (current_function_decl != NULL_TREE)
-TREE_PUBLIC (decl1) = 0;
-
   /* If this definition isn't a prototype and we had a prototype declaration
  before, copy the arg type info from that prototype.  */
   old_decl = lookup_name_in_scope (DECL_NAME (decl1), current_scope);
--- gcc/testsuite/gcc.dg/pr89340.c.jj   2019-02-14 14:16:35.998034363 +0100
+++ gcc/testsuite/gcc.dg/pr89340.c  2019-02-14 14:10:31.936033775 +0100
@@ -0,0 +1,9 @@
+/* PR c/89340 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void bar (void)
+{
+  __attribute__((weak)) void foo () {} /* { dg-error "weak declaration of 
'foo' must be public" } */
+  foo ();
+}
--- gcc/testsuite/gcc.dg/torture/pr57036-2.c.jj 2014-11-11 00:06:07.247079690 
+0100
+++ gcc/testsuite/gcc.dg/torture/pr57036-2.c2019-02-14 22:04:04.936850407 
+0100
@@ -9,7 +9,7 @@ int jpgDecode_convert (unsigned i)
   int j;
 
   inline void __attribute__((always_inline,leaf)) f(void)
-{
+{  /* { dg-warning "'leaf' attribute has no effect" } */
   g();
 }
 

Jakub


[Bug middle-end/89337] Bogus "exceeds maximum object size" on unreachable code

2019-02-14 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89337

--- Comment #9 from Martin Sebor  ---
The warning is very simple: it just looks for excessive sizes in calls emitted
in the optimized IL.  When the call is there (either because it's in the source
code as is or because it's been synthesized by GCC based on the invariants it
can infer from the code) it triggers.  It runs after all high-level
optimizations, including DCE, and assumes that if the statement is in the IL it
is reachable.  Compiling the test case with -fdump-tree-optimized=/dev/stdout
shows the GIMPLE the warning works with:

   [local count: 233860936]:
  # iftmp.6_113 = PHI 
  memset (iftmp.6_113, 0, 18446744073709551613);

I think the issue can essentially be reduced to the following:

$ cat z.c && gcc -O2 -S -fdump-tree-optimized=/dev/stdout z.c
void f (char *d, const char *s)
{
  if (__builtin_strstr (s, "ABC"))
{
  __SIZE_TYPE__ n = __builtin_strlen (s) - 3;

  if (n > __builtin_strlen (s))   // cannot be true
__builtin_memset (d, 0, n - __builtin_strlen (s));
  }
}

;; Function f (f, funcdef_no=0, decl_uid=1907, cgraph_uid=1, symbol_order=0)

Removing basic block 6
Removing basic block 7
f (char * d, const char * s)
{
  char * _1;
  long unsigned int _2;

   [local count: 1073741824]:
  _1 = __builtin_strstr (s_5(D), "ABC");
  if (_1 != 0B)
goto ; [70.00%]
  else
goto ; [30.00%]

   [local count: 751619278]:
  _2 = __builtin_strlen (s_5(D));
  if (_2 <= 2)
goto ; [33.00%]
  else
goto ; [67.00%]

   [local count: 248034361]:
  __builtin_memset (d_6(D), 0, 18446744073709551613); [tail call]

   [local count: 1073741824]:
  return;

}


z.c: In function ‘f’:
z.c:8:9: warning: ‘__builtin_memset’ specified size 18446744073709551613
exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
8 | __builtin_memset (d, 0, n - __builtin_strlen (s));
  | ^

GCC doesn't have the smarts to figure out that when s contains a substring of
length 3 then strlen(s) must be at least 3.  As a result, it doesn't eliminate
the memset call in the function and the warning triggers.  Suppose we teach GCC
how to figure this out from the strstr call (which might be a useful
optimization) and then someone comes along with a test case that uses strspn()
instead of strstr().  We can also teach GCC about strstr() but then someone
else might use regcomp() or some user-defined function that we won't have
access to.  At some point we'll have to call it good enough.

It's helpful to keep in mind that no control flow or data flow-based warning is
free of false positives (or negatives), either in GCC or in any static
analyzer.  Analyzing only provably reachable code would mean not diagnosing
bugs in translation units without main because we cannot prove that they're
ever called.  Similarly, at the function level, it would mean not diagnosing
bugs in conditional statements unless the conditions could be proven to be true
at compile time.  That would make not only the false positive rate nearly zero,
it would also make the true positive rate nearly zero. In effect, it would make
the diagnostics virtually useless, able to detect only bugs in the simplest
code.  If you find a non-zero rate of false positives unacceptable then my
suggestion is to turn warnings off.  Not just this one but all others as most
have some false positives, including the front-ends ones that have no notion of
reachability.  Otherwise, if you accept that some false positives are
unavoidable and worth the checking GCC does, then until the strstr optimization
above is implemented, I would recommend to make use of __builtin_unreachable():

  void trim_asterisk(seastar::sstring ) {
if (name.find("ABC") != seastar::sstring::npos) {
  if (name.length () < 3)
__builtin_unreachable ();
  name.resize(name.length() - 3);
}
  }

Chances are that besides avoiding the warning it will also improve the quality
of the object code.  When hidden behind a well-named macro it might also
improve readability.

[Bug c++/85515] Bogus suggestions from "GCC's leaky abstractions"

2019-02-14 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85515

--- Comment #7 from David Malcolm  ---
Author: dmalcolm
Date: Thu Feb 14 22:57:34 2019
New Revision: 268908

URL: https://gcc.gnu.org/viewcvs?rev=268908=gcc=rev
Log:
Don't offer suggestions for compiler-generated variables (PR c++/85515)

gcc/cp/ChangeLog:
Backport of r259720 from trunk.
2018-04-27  David Malcolm  

PR c++/85515
* name-lookup.c (consider_binding_level): Skip compiler-generated
variables.
* search.c (lookup_field_fuzzy_info::fuzzy_lookup_field): Flatten
nested if statements into a series of rejection tests.  Reject
lambda-ignored entities as suggestions.

gcc/testsuite/ChangeLog:
Backport of r259720 from trunk.
2018-04-27  David Malcolm  

PR c++/85515
* g++.dg/pr85515-1.C: New test.
* g++.dg/pr85515-2.C: New test.


Added:
branches/gcc-8-branch/gcc/testsuite/g++.dg/pr85515-1.C
branches/gcc-8-branch/gcc/testsuite/g++.dg/pr85515-2.C
Modified:
branches/gcc-8-branch/gcc/cp/ChangeLog
branches/gcc-8-branch/gcc/cp/name-lookup.c
branches/gcc-8-branch/gcc/cp/search.c
branches/gcc-8-branch/gcc/testsuite/ChangeLog

Re: [PATCH 37/40] i386: Allow MMX intrinsic emulation with SSE

2019-02-14 Thread Uros Bizjak
On Thu, Feb 14, 2019 at 10:02 PM H.J. Lu  wrote:

> > > > > gcc/
> > > > >
> > > > > PR target/89021
> > > > > * config/i386/i386-builtin.def: Enable MMX intrinsics with
> > > > > SSE/SSE2/SSSE3.
> > > > > * config/i386/i386.c (ix86_option_override_internal): Don't
> > > > > enable MMX ISA with TARGET_MMX_WITH_SSE by default.
> > > > > (ix86_init_mmx_sse_builtins): Enable MMX intrinsics with
> > > > > SSE/SSE2/SSSE3.
> > > > > (ix86_expand_builtin): Allow SSE/SSE2/SSSE3 to emulate MMX
> > > > > intrinsics with TARGET_MMX_WITH_SSE.
> > > > > * config/i386/mmintrin.h: Don't require MMX in 64-bit mode.
> > > > >
> > >
> > > >
> > > > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > > > > index a9abbe8706b..1d417e08734 100644
> > > > > --- a/gcc/config/i386/i386.c
> > > > > +++ b/gcc/config/i386/i386.c
> > > > > @@ -4165,12 +4165,15 @@ ix86_option_override_internal (bool 
> > > > > main_args_p,
> > > > >opts->x_target_flags
> > > > > |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
> > > > >
> > > > > -  /* Enable by default the SSE and MMX builtins.  Do allow the 
> > > > > user to
> > > > > -explicitly disable any of these.  In particular, disabling 
> > > > > SSE and
> > > > > -MMX for kernel code is extremely useful.  */
> > > > > +  /* Enable the SSE and MMX builtins by default.  Don't enable 
> > > > > MMX
> > > > > + ISA with TARGET_MMX_WITH_SSE by default.  Do allow the user 
> > > > > to
> > > > > +explicitly disable any of these.  In particular, disabling 
> > > > > SSE
> > > > > +and MMX for kernel code is extremely useful.  */
> > > > >if (!ix86_arch_specified)
> > > > >opts->x_ix86_isa_flags
> > > > > -   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | 
> > > > > OPTION_MASK_ISA_MMX
> > > > > +   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > > > > +| (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > > > +   ? 0 : OPTION_MASK_ISA_MMX)
> > > > >  | TARGET_SUBTARGET64_ISA_DEFAULT)
> > > > >  & ~opts->x_ix86_isa_flags_explicit);
> > > >
> > > > Please split the above into two clauses, the first that sets SSE and
> > > > MMX by default, and the second to or with
> > > >
> > > > opts->x_ix86_isa_flags
> > > >  |= TARGET_SUBTARGET64_ISA_DEFAULT & 
> > > > ~opts->x_ix86_isa_flags_explicit
> > > >
> > >
> > > Like this?
> >
> > Yes, but also split the comment.
>
> I will go with
>
>  /* Enable by default the SSE and MMX builtins.  Do allow the user to
>  explicitly disable any of these.  In particular, disabling SSE and
>  MMX for kernel code is extremely useful.  */
>   if (!ix86_arch_specified)
> {
>   /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
>   opts->x_ix86_isa_flags
> |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
>  | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> ? 0 : OPTION_MASK_ISA_MMX))
> & ~opts->x_ix86_isa_flags_explicit);
>   opts->x_ix86_isa_flags
> |= (TARGET_SUBTARGET64_ISA_DEFAULT
> & ~opts->x_ix86_isa_flags_explicit);
> }

I'll commit the following patch that finally defines
TARGET_SUBTARGET64_ISA_DEFAULT. You could then simply clear the MMX
bit from x_i86_isa_flags, like:

  if (!ix86_arch_specified)
opts->x_ix86_isa_flags
  |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;

  /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
  if (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags))
opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_MMX;

Uros.
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 268907)
+++ config/i386/i386.c  (working copy)
@@ -4165,14 +4165,9 @@ ix86_option_override_internal (bool main_args_p,
   opts->x_target_flags
|= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
 
-  /* Enable by default the SSE and MMX builtins.  Do allow the user to
-explicitly disable any of these.  In particular, disabling SSE and
-MMX for kernel code is extremely useful.  */
   if (!ix86_arch_specified)
-  opts->x_ix86_isa_flags
-   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_MMX
-| TARGET_SUBTARGET64_ISA_DEFAULT)
-& ~opts->x_ix86_isa_flags_explicit);
+   opts->x_ix86_isa_flags
+ |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
 
   if (TARGET_RTD_P (opts->x_target_flags))
warning (0,
Index: config/i386/i386.h
===
--- config/i386/i386.h  (revision 268907)
+++ config/i386/i386.h  (working copy)
@@ -633,7 +633,9 @@ extern tree x86_mfence;
 
 /* Extra bits 

[PATCH] Fix ICE with optimize("Ofast") due to option handling (PR other/89342)

2019-02-14 Thread Jakub Jelinek
Hi!

We ICE on the following testcase, because while we save optimize,
and optimize_{size,debug} vars during option saving/restoring, we don't save
optimize_fast, and because of that end up with optimize 0 optimize_fast 1
which the option handling code ICEs on - 
  if (fast)
gcc_assert (level == 3);
in maybe_default_option.  Fixed thusly, just treat optimize_fast like
the other flags, bootstrapped/regtested on x86_64-linux and i686-linux, ok
for trunk/8.3?

2019-02-14  Jakub Jelinek  

PR other/89342
* optc-save-gen.awk: Handle optimize_fast like optimize_size or
optimize_debug.
* opth-gen.awk: Likewise.

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

--- gcc/optc-save-gen.awk.jj2019-02-14 08:06:39.436519588 +0100
+++ gcc/optc-save-gen.awk   2019-02-14 13:12:37.789488847 +0100
@@ -81,7 +81,7 @@ print "void";
 print "cl_optimization_save (struct cl_optimization *ptr, struct gcc_options 
*opts)";
 print "{";
 
-n_opt_char = 3;
+n_opt_char = 4;
 n_opt_short = 0;
 n_opt_int = 0;
 n_opt_enum = 0;
@@ -90,9 +90,11 @@ n_opt_other = 0;
 var_opt_char[0] = "optimize";
 var_opt_char[1] = "optimize_size";
 var_opt_char[2] = "optimize_debug";
+var_opt_char[3] = "optimize_fast";
 var_opt_range["optimize"] = "0, 255";
 var_opt_range["optimize_size"] = "0, 1";
 var_opt_range["optimize_debug"] = "0, 1";
+var_opt_range["optimize_fast"] = "0, 1";
 
 # Sort by size to mimic how the structure is laid out to be friendlier to the
 # cache.
@@ -767,16 +769,19 @@ for (i = 0; i < n_target_val; i++) {
 
 print "}";
 
-n_opt_val = 3;
+n_opt_val = 4;
 var_opt_val[0] = "x_optimize"
 var_opt_val_type[0] = "char "
 var_opt_hash[0] = 1;
 var_opt_val[1] = "x_optimize_size"
+var_opt_val_type[1] = "char "
 var_opt_hash[1] = 1;
 var_opt_val[2] = "x_optimize_debug"
-var_opt_hash[2] = 1;
-var_opt_val_type[1] = "char "
 var_opt_val_type[2] = "char "
+var_opt_hash[2] = 1;
+var_opt_val[3] = "x_optimize_fast"
+var_opt_val_type[3] = "char "
+var_opt_hash[3] = 1;
 for (i = 0; i < n_opts; i++) {
if (flag_set_p("(Optimization|PerFunction)", flags[i])) {
name = var_name(flags[i])
--- gcc/opth-gen.awk.jj 2019-01-01 12:37:18.562951898 +0100
+++ gcc/opth-gen.awk2019-02-14 13:13:15.919858043 +0100
@@ -132,7 +132,7 @@ print "/* Structure to save/restore opti
 print "struct GTY(()) cl_optimization";
 print "{";
 
-n_opt_char = 3;
+n_opt_char = 4;
 n_opt_short = 0;
 n_opt_int = 0;
 n_opt_enum = 0;
@@ -140,6 +140,7 @@ n_opt_other = 0;
 var_opt_char[0] = "unsigned char x_optimize";
 var_opt_char[1] = "unsigned char x_optimize_size";
 var_opt_char[2] = "unsigned char x_optimize_debug";
+var_opt_char[3] = "unsigned char x_optimize_fast";
 
 for (i = 0; i < n_opts; i++) {
if (flag_set_p("(Optimization|PerFunction)", flags[i])) {
--- gcc/testsuite/gcc.dg/pr89342.c.jj   2019-02-14 13:17:48.061355967 +0100
+++ gcc/testsuite/gcc.dg/pr89342.c  2019-02-14 13:17:03.494093205 +0100
@@ -0,0 +1,11 @@
+/* PR other/89342 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+__attribute__((optimize("Ofast")))
+void foo (void)
+{
+  __attribute__((optimize("no-inline")))
+  void bar (void) {}
+  bar ();
+}

Jakub


[PATCH] Fix tree-loop-distribution.c ICE with -ftrapv (PR tree-optimization/89278)

2019-02-14 Thread Jakub Jelinek
Hi!

The following testcase ICEs, because we try to gimplify a complex expression
that with -ftrapv wants to emit multiple bbs.  Fixed by using
rewrite_to_non_trapping_overflow.  Bootstrapped/regtested on x86_64-linux
and i686-linux, ok for trunk and 8.3?

2019-02-14  Richard Biener  
Jakub Jelinek  

PR tree-optimization/89278
* tree-loop-distribution.c: Include tree-eh.h.
(generate_memset_builtin, generate_memcpy_builtin): Call
rewrite_to_non_trapping_overflow on builtin->size before passing it
to force_gimple_operand_gsi.

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

--- gcc/tree-loop-distribution.c.jj 2019-01-10 11:43:02.255576992 +0100
+++ gcc/tree-loop-distribution.c2019-02-14 12:17:24.403403131 +0100
@@ -114,6 +114,7 @@ along with GCC; see the file COPYING3.
 #include "tree-scalar-evolution.h"
 #include "params.h"
 #include "tree-vectorizer.h"
+#include "tree-eh.h"
 
 
 #define MAX_DATAREFS_NUM \
@@ -996,7 +997,7 @@ generate_memset_builtin (struct loop *lo
   /* The new statements will be placed before LOOP.  */
   gsi = gsi_last_bb (loop_preheader_edge (loop)->src);
 
-  nb_bytes = builtin->size;
+  nb_bytes = rewrite_to_non_trapping_overflow (builtin->size);
   nb_bytes = force_gimple_operand_gsi (, nb_bytes, true, NULL_TREE,
   false, GSI_CONTINUE_LINKING);
   mem = builtin->dst_base;
@@ -1048,7 +1049,7 @@ generate_memcpy_builtin (struct loop *lo
   /* The new statements will be placed before LOOP.  */
   gsi = gsi_last_bb (loop_preheader_edge (loop)->src);
 
-  nb_bytes = builtin->size;
+  nb_bytes = rewrite_to_non_trapping_overflow (builtin->size);
   nb_bytes = force_gimple_operand_gsi (, nb_bytes, true, NULL_TREE,
   false, GSI_CONTINUE_LINKING);
   dest = builtin->dst_base;
--- gcc/testsuite/gcc.dg/pr89278.c.jj   2019-02-14 12:18:38.778173413 +0100
+++ gcc/testsuite/gcc.dg/pr89278.c  2019-02-14 12:18:19.065499344 +0100
@@ -0,0 +1,23 @@
+/* PR tree-optimization/89278 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -ftrapv -ftree-loop-distribute-patterns --param 
max-loop-header-insns=2" } */
+
+void
+foo (int *w, int x, int y, int z)
+{
+  while (x < y + z)
+{
+  w[x] = 0;
+  ++x;
+}
+}
+
+void
+bar (int *__restrict u, int *__restrict w, int x, int y, int z)
+{
+  while (x < y + z)
+{
+  w[x] = u[x];
+  ++x;
+}
+}

Jakub


[Bug tree-optimization/88835] overly aggressive -Werror=format-overflow for printf since r265648

2019-02-14 Thread mark at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88835

--- Comment #9 from Mark Wielaard  ---
(In reply to Martin Sebor from comment #8)
> The patch I posted for the related pr88993 also relaxes this warning for
> printf and fprintf:  https://gcc.gnu.org/ml/gcc-patches/2019-02/msg00224.html
> 
> Like in the case of pr88993, the warning is by design and (in my view) makes
> sense for sprintf but it's not very useful for the other functions where
> very little code worries about exceeding these limits (or even cares about
> the functions failing as they can for many other reasons).

I tried that patch, but it does not fix this issue. This case now triggers the
following warning, which isn't guarded by is_string_func:

  /* The directive output or either causes or may cause the total
 length of output to exceed INT_MAX bytes.  */

  if (likelyximax && fmtres.range.min == fmtres.range.max)
warned = fmtwarn (dirloc, argloc, NULL, info.warnopt (),
  "%<%.*s%> directive output of %wu bytes causes "
  "result to exceed %", dirlen,
  target_to_host (hostdir, sizeof hostdir, dir.beg),
  fmtres.range.min);

So with that patch we get:

/home/mark/src/elfutils/src/readelf.c: In function ‘print_debug_str_section’:
/home/mark/src/elfutils/src/readelf.c:10167:15: error: ‘]  "’ directive output
of 4 bytes causes result to exceed ‘INT_MAX’ [-Werror=format-overflow=]
10167 |   printf (" [%*" PRIx64 "]  \"%s\"\n", digits, (uint64_t) offset,
str);
  |   ^~
/home/mark/src/elfutils/src/readelf.c:10167:30: note: format string is defined
here
10167 |   printf (" [%*" PRIx64 "]  \"%s\"\n", digits, (uint64_t) offset,
str);
  |  ^
cc1: all warnings being treated as errors

Which is actually more mysterious than the previous warning (without the patch
as shown in description).

Re: Backport of various patches to gcc 8

2019-02-14 Thread Jakub Jelinek
On Thu, Feb 14, 2019 at 06:23:37PM -0500, David Malcolm wrote:
> It's not clear to me what the rules are on backports (do
> I need approval, or re-review?) but the following have
> all been bootstrapped and regression-tested relative to
> today's gcc-8-branch (on x86_64-pc-linux-gnu):
> 
> r259720: "Don't offer suggestions for compiler-generated variables (PR 
> c++/85515)"
> r262199: "C++: don't offer bogus "._0" suggestions (PR c++/86329)"
> r263275: "Fix memory leak of pretty_printer prefixes"
> r263295: "docs: fix stray duplicated words"
> r263339: "Fix memory leak in selftest::test_expansion_to_rtl"
> r267957: "Fix ICE on class-template argument deduction (PR c++/88795)"
> r268847: "C++ concepts: fix ICE with requires on dtors (PR c++/89036)"
> 
> Are these OK for gcc-8-branch?

Ok, thanks.

Jakub


gcc-7-20190214 is now available

2019-02-14 Thread gccadmin
Snapshot gcc-7-20190214 is now available on
  ftp://gcc.gnu.org/pub/gcc/snapshots/7-20190214/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 7 SVN branch
with the following options: svn://gcc.gnu.org/svn/gcc/branches/gcc-7-branch 
revision 268907

You'll find:

 gcc-7-20190214.tar.xzComplete GCC

  SHA256=fd4aa146e4354b847a3c073f6b7ebce83462d236a0107a66b930c566d85a5762
  SHA1=406ecabeee26380bf1fe22e7130ae3bf99d47157

Diffs from 7-20190207 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-7
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.


[Bug fortran/89077] ICE using * as len specifier for character parameter

2019-02-14 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89077

--- Comment #16 from Harald Anlauf  ---
Regarding the unwanted padding with \0, the following patch seems to
solve the issue with transfer.

Index: decl.c
===
--- decl.c  (revision 268897)
+++ decl.c  (working copy)
@@ -1754,6 +1754,12 @@
   free (expr->value.character.string);
   expr->value.character.string = s;
   expr->value.character.length = len;
+  if (expr->representation.length)
+   {
+ expr->representation.length = 0;
+ free (expr->representation.string);
+ expr->representation.string = NULL;
+   }
 }
 }

Testcase:

  character(8) ,parameter :: s = transfer ('ab', 'cd')
  character(8) ,parameter :: t = 2Hxy
  print *, "'", s, "'"
  print *, "'", t, "'"
end

./a.out  | cat -v
 'ab  '
 'xy  '

Re: [PATCH][DOC] Document new features for GCC 9.

2019-02-14 Thread David Malcolm
On Thu, 2019-02-14 at 14:19 -0700, Martin Sebor wrote:
> On 2/13/19 6:48 AM, Martin Liška wrote:
> > Hi.
> > 
> > I'm sending patch where I document changes I made during GCC 9
> > development. I would appreciate both language and factical comments
> > about the patch.
> 
> Nothing technical, just a few very minor language nits/suggestions.
> 
> Martin
> 
> diff --git a/htdocs/gcc-9/changes.html b/htdocs/gcc-9/changes.html
> index 13243c2..9fec9e2 100644
> --- a/htdocs/gcc-9/changes.html
> +++ b/htdocs/gcc-9/changes.html
> @@ -50,11 +50,64 @@ a work-in-progress.
>   General Improvements
>   
> 
> -A new option -flive-patching=[inline-only-static|inline-clone]
> is
> +A new option 
> -flive-patching=[inline-only-static|inline-clone] is
> 
> s/is/has been/ would be better (and either a comma after option or
> a definite article without the comma).
> 
>   introduced to provide a safe compilation for live-patching. At
> the 
> same
>   time, provides multiple-level control on the enabled IPA 
> optimizations.
>   See the user guide for further information about the option for
> more
> -details.
> +details.

Ideally we should add URLs any time we mention an option, linking to
the docs for that option.  texinfo's HTML toolchain does give us per-
option anchors.  They're not visible [1], but "View Source" shows us
that they do exist; in the form:

https://gcc.gnu.org/onlinedocs/gcc/SOMETHING.html#indexOPTION

though annoyingly the SOMETHING varies depending on what kind of option
it is.

The pertinent one here is:
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-flive-patching

(FWIW, I have a patch for GCC 10 that emits terminal sequences to
"linkify" the output when diagnostics mention option names, adding a
URL to the docs for the pertinent option).

[...snip...]

Dave

[1] I've emailed the texinfo project about this


[PATCH 5/7] Fix memory leak in selftest::test_expansion_to_rtl

2019-02-14 Thread David Malcolm
"make selftest-valgrind" shows:

187 bytes in 1 blocks are definitely lost in loss record 567 of 669
at 0x4A081D4: calloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x1F08260: xcalloc (xmalloc.c:162)
by 0xB24F32: init_emit() (emit-rtl.c:5843)
by 0xC10080: prepare_function_start() (function.c:4803)
by 0xC10254: init_function_start(tree_node*) (function.c:4877)
by 0x1CDF92A: selftest::test_expansion_to_rtl() (function-tests.c:595)
by 0x1CE007C: selftest::function_tests_c_tests() (function-tests.c:676)
by 0x1E010E7: selftest::run_tests() (selftest-run-tests.c:98)
by 0x1062D1E: toplev::run_self_tests() (toplev.c:2225)
by 0x1062F40: toplev::main(int, char**) (toplev.c:2303)
by 0x1E5B90A: main (main.c:39)

The allocation in question is:

  crtl->emit.regno_pointer_align
= XCNEWVEC (unsigned char, crtl->emit.regno_pointer_align_length);

This patch fixes this leak (and makes the output of
"make selftest-valgrind" clean) by calling free_after_compilation at the
end of the selftest in question.

gcc/ChangeLog:
Backport of r263339 from trunk.
2018-08-06  David Malcolm  

* function-tests.c (selftest::test_expansion_to_rtl): Call
free_after_compilation.
---
 gcc/function-tests.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/function-tests.c b/gcc/function-tests.c
index 1b5ebf3..196b3a3 100644
--- a/gcc/function-tests.c
+++ b/gcc/function-tests.c
@@ -661,6 +661,7 @@ test_expansion_to_rtl ()
   ASSERT_STR_CONTAINS (dump, ") ;; function \"test_fn\"\n");
 
   free (dump);
+  free_after_compilation (fun);
 }
 
 /* Run all of the selftests within this file.  */
-- 
1.8.5.3



[PATCH 3/7] Fix memory leak of pretty_printer prefixes

2019-02-14 Thread David Malcolm
We were rather sloppy about handling the ownership of prefixes for
pretty_printer, and this lead to a memory leak for any time a
diagnostic_show_locus call emits multiple line spans.

This showed up in "make selftest-valgrind" as:

3,976 bytes in 28 blocks are definitely lost in loss record 632 of 669
   at 0x4A0645D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x1F08227: xmalloc (xmalloc.c:147)
   by 0x1F083E6: xvasprintf (xvasprintf.c:58)
   by 0x1E7EC7D: build_message_string(char const*, ...) (diagnostic.c:78)
   by 0x1E7F438: diagnostic_get_location_text(diagnostic_context*, 
expanded_location) (diagnostic.c:328)
   by 0x1E7FD54: default_diagnostic_start_span_fn(diagnostic_context*, 
expanded_location) (diagnostic.c:626)
   by 0x1EB3508: 
selftest::test_diagnostic_context::start_span_cb(diagnostic_context*, 
expanded_location) (selftest-diagnostic.c:57)
   by 0x1E89215: diagnostic_show_locus(diagnostic_context*, rich_location*, 
diagnostic_t) (diagnostic-show-locus.c:1992)
   by 0x1E8ECAD: 
selftest::test_fixit_insert_containing_newline_2(selftest::line_table_case 
const&) (diagnostic-show-locus.c:3044)
   by 0x1EB0606: selftest::for_each_line_table_case(void 
(*)(selftest::line_table_case const&)) (input.c:3525)
   by 0x1E8F3F5: selftest::diagnostic_show_locus_c_tests() 
(diagnostic-show-locus.c:3164)
   by 0x1E010BF: selftest::run_tests() (selftest-run-tests.c:88)

4,004 bytes in 28 blocks are definitely lost in loss record 633 of 669
   at 0x4A0645D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x1F08227: xmalloc (xmalloc.c:147)
   by 0x1F083E6: xvasprintf (xvasprintf.c:58)
   by 0x1E7EC7D: build_message_string(char const*, ...) (diagnostic.c:78)
   by 0x1E7F438: diagnostic_get_location_text(diagnostic_context*, 
expanded_location) (diagnostic.c:328)
   by 0x1E7FD54: default_diagnostic_start_span_fn(diagnostic_context*, 
expanded_location) (diagnostic.c:626)
   by 0x1EB3508: 
selftest::test_diagnostic_context::start_span_cb(diagnostic_context*, 
expanded_location) (selftest-diagnostic.c:57)
   by 0x1E89215: diagnostic_show_locus(diagnostic_context*, rich_location*, 
diagnostic_t) (diagnostic-show-locus.c:1992)
   by 0x1E8B373: 
selftest::test_diagnostic_show_locus_fixit_lines(selftest::line_table_case 
const&) (diagnostic-show-locus.c:2500)
   by 0x1EB0606: selftest::for_each_line_table_case(void 
(*)(selftest::line_table_case const&)) (input.c:3525)
   by 0x1E8F3B9: selftest::diagnostic_show_locus_c_tests() 
(diagnostic-show-locus.c:3159)
   by 0x1E010BF: selftest::run_tests() (selftest-run-tests.c:88)

This patch fixes the leaks by ensuring that the pretty_printer "owns"
the prefix if it's non-NULL, freeing it in the dtor and in pp_set_prefix.

gcc/cp/ChangeLog:
Backport of r263275 from trunk.
2018-08-02  David Malcolm  

* error.c (cxx_print_error_function): Duplicate "file" before
passing it to pp_set_prefix.
(cp_print_error_function): Use pp_take_prefix when saving the
existing prefix.

gcc/ChangeLog:
Backport of r263275 from trunk.
2018-08-02  David Malcolm  

* diagnostic-show-locus.c (diagnostic_show_locus): Use
pp_take_prefix when saving the existing prefix.
* diagnostic.c (diagnostic_append_note): Likewise.
* langhooks.c (lhd_print_error_function): Likewise.
* pretty-print.c (pp_set_prefix): Drop the "const" from "prefix"
param's type.  Free the existing prefix.
(pp_take_prefix): New function.
(pretty_printer::pretty_printer): Drop the prefix parameter.
Rename the length parameter to match the comment.
(pretty_printer::~pretty_printer): Free the prefix.
* pretty-print.h (pretty_printer::pretty_printer): Drop the prefix
parameter.
(struct pretty_printer): Drop the "const" from "prefix" field's
type and clarify memory management.
(pp_set_prefix): Drop the "const" from the 2nd param.
(pp_take_prefix): New decl.
---
 gcc/cp/error.c  |  9 +++--
 gcc/diagnostic-show-locus.c |  2 +-
 gcc/diagnostic.c|  3 +--
 gcc/langhooks.c |  2 +-
 gcc/pretty-print.c  | 31 +++
 gcc/pretty-print.h  | 14 --
 6 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 95b8b84..f7895de 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -3286,8 +3286,13 @@ void
 cxx_print_error_function (diagnostic_context *context, const char *file,
  diagnostic_info *diagnostic)
 {
+  char *prefix;
+  if (file)
+prefix = xstrdup (file);
+  else
+prefix = NULL;
   lhd_print_error_function (context, file, diagnostic);
-  pp_set_prefix (context->printer, file);
+  pp_set_prefix (context->printer, prefix);
   maybe_print_instantiation_context (context);
 }
 
@@ -3315,7 +3320,7 @@ cp_print_error_function 

[PATCH 6/7] Fix ICE on class-template argument deduction (PR c++/88795)

2019-02-14 Thread David Malcolm
PR c++/88795 reports an ICE building a function_type for a deduction guide
when the substitution into the function signature fails, due to an
error_mark_node being returned from tsubst_arg_types but not being checked
for.  This error_mark_node gets used as the TYPE_ARG_TYPES, leading to
ICEs in various places that assume this is a TREE_LIST.

This patch checks the result of tsubst_arg_types and propagates the failure
if it returns error_mark_node.  It also adds an assertion to
build_function_type, to fail faster if passed in error_mark_node.

gcc/cp/ChangeLog:
Backport of r267957 from trunk.
2019-01-15  David Malcolm  

PR c++/88795
* pt.c (build_deduction_guide): Bail out if tsubst_arg_types
fails.

gcc/testsuite/ChangeLog:
Backport of r267957 from trunk.
2019-01-15  David Malcolm  

PR c++/88795
* g++.dg/template/pr88795.C: New test.

gcc/ChangeLog:
Backport of r267957 from trunk.
2019-01-15  David Malcolm  

PR c++/88795
* tree.c (build_function_type): Assert that arg_types is not
error_mark_node.
---
 gcc/cp/pt.c |  2 ++
 gcc/testsuite/g++.dg/template/pr88795.C | 23 +++
 gcc/tree.c  |  2 ++
 3 files changed, 27 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/template/pr88795.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 72dc1e0..895cb5a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -26494,6 +26494,8 @@ build_deduction_guide (tree ctor, tree outer_args, 
tsubst_flags_t complain)
  targs = template_parms_to_args (tparms);
  fparms = tsubst_arg_types (fparms, tsubst_args, NULL_TREE,
 complain, ctor);
+ if (fparms == error_mark_node)
+   ok = false;
  fargs = tsubst (fargs, tsubst_args, complain, ctor);
  if (ci)
ci = tsubst_constraint_info (ci, tsubst_args, complain, ctor);
diff --git a/gcc/testsuite/g++.dg/template/pr88795.C 
b/gcc/testsuite/g++.dg/template/pr88795.C
new file mode 100644
index 000..918aa6d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr88795.C
@@ -0,0 +1,23 @@
+// { dg-do compile { target c++17 } }
+
+template
+struct Array {};
+
+template
+struct Foo {
+  static constexpr int size() {
+  return size_;
+  }
+
+  template
+  Foo(U, Array) {}
+};
+
+template
+Foo(U, Array) -> Foo;
+
+int main() {
+  Array arr{};
+
+  Foo foo{2.0, arr};
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index ca5d810..091a63a 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -8023,6 +8023,8 @@ build_function_type (tree value_type, tree arg_types)
   bool any_structural_p, any_noncanonical_p;
   tree canon_argtypes;
 
+  gcc_assert (arg_types != error_mark_node);
+
   if (TREE_CODE (value_type) == FUNCTION_TYPE)
 {
   error ("function return type cannot be function");
-- 
1.8.5.3



[PATCH 7/7] C++ concepts: fix ICE with requires on dtors (PR c++/89036)

2019-02-14 Thread David Malcolm
PR c++/89036 reports an ICE due to this assertion failing

1136  /* A class should never have more than one destructor.  */
1137  gcc_assert (!current_fns || via_using || !DECL_DESTRUCTOR_P (method));

on this template with a pair of dtors, with
mutually exclusive "requires" clauses:

template
struct Y {
~Y() requires(true) = default;
~Y() requires(false) {}
};

Nathan introduced this assertion as part of:

  ca9219bf18c68a001d62ecb981bc9176b0feaf12 (aka r251340):
2017-08-24  Nathan Sidwell  
   Conversion operators kept on single overload set

which, amongst other changes to add_method had this:
 /* A class should never have more than one destructor.  */
  -  if (current_fns && DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (method))
  -return false;
  +  gcc_assert (!current_fns || !DECL_DESTRUCTOR_P (method));

The following patch drops the assertion.

gcc/cp/ChangeLog:
2019-02-13  David Malcolm  
Backport of r268847 from trunk.

PR c++/89036
* class.c (add_method): Drop destructor assertion.

gcc/testsuite/ChangeLog:
2019-02-13  David Malcolm  
Backport of r268847 from trunk.

PR c++/89036
* g++.dg/concepts/pr89036.C: New test.
---
 gcc/cp/class.c  | 3 ---
 gcc/testsuite/g++.dg/concepts/pr89036.C | 8 
 2 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/concepts/pr89036.C

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index d524a98..834ba17 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1141,9 +1141,6 @@ add_method (tree type, tree method, bool via_using)
}
 }
 
-  /* A class should never have more than one destructor.  */
-  gcc_assert (!current_fns || !DECL_DESTRUCTOR_P (method));
-
   current_fns = ovl_insert (method, current_fns, via_using);
 
   if (!COMPLETE_TYPE_P (type) && !DECL_CONV_FN_P (method)
diff --git a/gcc/testsuite/g++.dg/concepts/pr89036.C 
b/gcc/testsuite/g++.dg/concepts/pr89036.C
new file mode 100644
index 000..f83ef8b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/pr89036.C
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "-fconcepts" }
+
+template
+struct Y {
+  ~Y() requires(true) = default;
+  ~Y() requires(false) {}
+};
-- 
1.8.5.3



[PATCH 2/7] C++: don't offer bogus "._0" suggestions (PR c++/86329)

2019-02-14 Thread David Malcolm
PR c++/86329 reports that the C++ frontend can offer bogus suggestions like:

  #include 

  int compare()
  {
return __n1 - __n2;
  }

suggested.cc: In function 'int compare()':
suggested.cc:5:10: error: '__n1' was not declared in this scope
   return __n1 - __n2;
  ^~~~
suggested.cc:5:10: note: suggested alternative: '._61'
   return __n1 - __n2;
  ^~~~
  ._61
suggested.cc:5:17: error: '__n2' was not declared in this scope
   return __n1 - __n2;
 ^~~~
suggested.cc:5:17: note: suggested alternative: '._72'
   return __n1 - __n2;
 ^~~~
 ._72

The dot-prefixed names are an implementation detail of how we implement
anonymous enums found in the header files, generated via
anon_aggrname_format in make_anon_name.

This patch uses anon_aggrname_p to filter them out when considering
which names to suggest.

gcc/cp/ChangeLog:
Backport of r262199 from trunk.
2018-06-27  David Malcolm  

PR c++/86329
* name-lookup.c (consider_binding_level): Filter out names that
match anon_aggrname_p.

gcc/testsuite/ChangeLog:
Backport of r262199 from trunk.
2018-06-27  David Malcolm  

PR c++/86329
* g++.dg/lookup/pr86329.C: New test.
---
 gcc/cp/name-lookup.c  |  5 +
 gcc/testsuite/g++.dg/lookup/pr86329.C | 11 +++
 2 files changed, 16 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/lookup/pr86329.C

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 86fa03b..4e8263b 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5873,6 +5873,11 @@ consider_binding_level (tree name, best_match  ,
   if (!suggestion)
continue;
 
+  /* Don't suggest names that are for anonymous aggregate types, as
+they are an implementation detail generated by the compiler.  */
+  if (anon_aggrname_p (suggestion))
+   continue;
+
   const char *suggestion_str = IDENTIFIER_POINTER (suggestion);
 
   /* Ignore internal names with spaces in them.  */
diff --git a/gcc/testsuite/g++.dg/lookup/pr86329.C 
b/gcc/testsuite/g++.dg/lookup/pr86329.C
new file mode 100644
index 000..fc091ba
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/pr86329.C
@@ -0,0 +1,11 @@
+/* PR c++/86329: ensure we don't erroneously offer suggestions like "._0",
+   which are an implementation detail of how e.g. anonymous enums are
+   handled internally.  */
+   
+enum {NONEMPTY};
+
+int test()
+{
+  return __0; // { dg-error "'__0' was not declared in this scope" }
+  // { dg-bogus "suggested alternative" "" { target *-*-* } .-1 }
+}
-- 
1.8.5.3



Backport of various patches to gcc 8

2019-02-14 Thread David Malcolm
It's not clear to me what the rules are on backports (do
I need approval, or re-review?) but the following have
all been bootstrapped and regression-tested relative to
today's gcc-8-branch (on x86_64-pc-linux-gnu):

r259720: "Don't offer suggestions for compiler-generated variables (PR 
c++/85515)"
r262199: "C++: don't offer bogus "._0" suggestions (PR c++/86329)"
r263275: "Fix memory leak of pretty_printer prefixes"
r263295: "docs: fix stray duplicated words"
r263339: "Fix memory leak in selftest::test_expansion_to_rtl"
r267957: "Fix ICE on class-template argument deduction (PR c++/88795)"
r268847: "C++ concepts: fix ICE with requires on dtors (PR c++/89036)"

Are these OK for gcc-8-branch?

Thanks
Dave

David Malcolm (7):
  Don't offer suggestions for compiler-generated variables (PR
c++/85515)
  C++: don't offer bogus "._0" suggestions (PR c++/86329)
  Fix memory leak of pretty_printer prefixes
  docs: fix stray duplicated words
  Fix memory leak in selftest::test_expansion_to_rtl
  Fix ICE on class-template argument deduction (PR c++/88795)
  C++ concepts: fix ICE with requires on dtors (PR c++/89036)

 gcc/cp/class.c  |  3 ---
 gcc/cp/error.c  |  9 +++--
 gcc/cp/name-lookup.c| 11 +++
 gcc/cp/pt.c |  2 ++
 gcc/cp/search.c | 13 ++---
 gcc/diagnostic-show-locus.c |  2 +-
 gcc/diagnostic.c|  3 +--
 gcc/doc/gcov.texi   |  2 +-
 gcc/doc/invoke.texi | 14 +++---
 gcc/function-tests.c|  1 +
 gcc/langhooks.c |  2 +-
 gcc/pretty-print.c  | 31 +++
 gcc/pretty-print.h  | 14 --
 gcc/testsuite/g++.dg/concepts/pr89036.C |  8 
 gcc/testsuite/g++.dg/lookup/pr86329.C   | 11 +++
 gcc/testsuite/g++.dg/pr85515-1.C| 18 ++
 gcc/testsuite/g++.dg/pr85515-2.C| 22 ++
 gcc/testsuite/g++.dg/template/pr88795.C | 23 +++
 gcc/tree.c  |  2 ++
 19 files changed, 157 insertions(+), 34 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/concepts/pr89036.C
 create mode 100644 gcc/testsuite/g++.dg/lookup/pr86329.C
 create mode 100644 gcc/testsuite/g++.dg/pr85515-1.C
 create mode 100644 gcc/testsuite/g++.dg/pr85515-2.C
 create mode 100644 gcc/testsuite/g++.dg/template/pr88795.C

-- 
1.8.5.3



[PATCH 4/7] docs: fix stray duplicated words

2019-02-14 Thread David Malcolm
gcc/ChangeLog:
Backport of 263295 from trunk.
2018-08-03  David Malcolm  

* doc/gcov.texi (-x): Remove duplicate "to".
* doc/invoke.texi (-Wnoexcept-type): Remove duplicate "calls".
(-Wif-not-aligned): Remove duplicate "is".
(-flto): Remove duplicate "the".
(MicroBlaze Options): In examples of "-mcpu=cpu-type", remove
duplicate "v5.00.b".
(MSP430 Options): Remove duplicate "and" from the description
of "-mgprel-sec=regexp".
(x86 Options): Remove duplicate copies of "vmldLog102" and
vmlsLog104 from description of "-mveclibabi=type".
---
 gcc/doc/gcov.texi   |  2 +-
 gcc/doc/invoke.texi | 14 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi
index 5923587..cc1376f 100644
--- a/gcc/doc/gcov.texi
+++ b/gcc/doc/gcov.texi
@@ -333,7 +333,7 @@ Print verbose informations related to basic blocks and arcs.
 
 @item -x
 @itemx --hash-filenames
-By default, gcov uses the full pathname of the source files to to create
+By default, gcov uses the full pathname of the source files to create
 an output filename.  This can lead to long filenames that can overflow
 filesystem limits.  This option creates names of the form
 @file{@var{source-file}##@var{md5}.gcov},
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 8ec5f01..e5c4e81 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -3020,7 +3020,7 @@ void h() @{ f(g); @}
 @end smallexample
 
 @noindent
-In C++14, @code{f} calls calls @code{f}, but in
+In C++14, @code{f} calls @code{f}, but in
 C++17 it calls @code{f}.
 
 @item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
@@ -4539,7 +4539,7 @@ The @option{-Wimplicit-fallthrough=3} warning is enabled 
by @option{-Wextra}.
 @opindex Wif-not-aligned
 @opindex Wno-if-not-aligned
 Control if warning triggered by the @code{warn_if_not_aligned} attribute
-should be issued.  This is is enabled by default.
+should be issued.  This is enabled by default.
 Use @option{-Wno-if-not-aligned} to disable it.
 
 @item -Wignored-qualifiers @r{(C and C++ only)}
@@ -9479,7 +9479,7 @@ for LTO, use @command{gcc-ar} and @command{gcc-ranlib} 
instead of @command{ar}
 and @command{ranlib}; 
 to show the symbols of object files with GIMPLE bytecode, use
 @command{gcc-nm}.  Those commands require that @command{ar}, @command{ranlib}
-and @command{nm} have been compiled with plugin support.  At link time, use 
the the
+and @command{nm} have been compiled with plugin support.  At link time, use the
 flag @option{-fuse-linker-plugin} to ensure that the library participates in
 the LTO optimization process:
 
@@ -20084,7 +20084,7 @@ Use features of, and schedule code for, the given CPU.
 Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
 where @var{X} is a major version, @var{YY} is the minor version, and
 @var{Z} is compatibility code.  Example values are @samp{v3.00.a},
-@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v5.00.b}, @samp{v6.00.a}.
+@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
 
 @item -mxl-soft-mul
 @opindex mxl-soft-mul
@@ -21746,7 +21746,7 @@ GP-relative addressing.  It is most useful in 
conjunction with
 The @var{regexp} is a POSIX Extended Regular Expression.
 
 This option does not affect the behavior of the @option{-G} option, and 
-and the specified sections are in addition to the standard @code{.sdata} 
+the specified sections are in addition to the standard @code{.sdata}
 and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
 
 @item -mr0rel-sec=@var{regexp}
@@ -27588,11 +27588,11 @@ To use this option, both @option{-ftree-vectorize} and
 ABI-compatible library must be specified at link time.
 
 GCC currently emits calls to @code{vmldExp2},
-@code{vmldLn2}, @code{vmldLog102}, @code{vmldLog102}, @code{vmldPow2},
+@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
 @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
 @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
 @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
-@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4}, @code{vmlsLog104},
+@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
 @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
 @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
 @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
-- 
1.8.5.3



[PATCH 1/7] Don't offer suggestions for compiler-generated variables (PR c++/85515)

2019-02-14 Thread David Malcolm
gcc/cp/ChangeLog:
Backport of r259720 from trunk.
2018-04-27  David Malcolm  

PR c++/85515
* name-lookup.c (consider_binding_level): Skip compiler-generated
variables.
* search.c (lookup_field_fuzzy_info::fuzzy_lookup_field): Flatten
nested if statements into a series of rejection tests.  Reject
lambda-ignored entities as suggestions.

gcc/testsuite/ChangeLog:
Backport of r259720 from trunk.
2018-04-27  David Malcolm  

PR c++/85515
* g++.dg/pr85515-1.C: New test.
* g++.dg/pr85515-2.C: New test.
---
 gcc/cp/name-lookup.c |  6 ++
 gcc/cp/search.c  | 13 ++---
 gcc/testsuite/g++.dg/pr85515-1.C | 18 ++
 gcc/testsuite/g++.dg/pr85515-2.C | 22 ++
 4 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr85515-1.C
 create mode 100644 gcc/testsuite/g++.dg/pr85515-2.C

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 4ce632c..86fa03b 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5863,6 +5863,12 @@ consider_binding_level (tree name, best_match  ,
  && DECL_ANTICIPATED (d))
continue;
 
+  /* Skip compiler-generated variables (e.g. __for_begin/__for_end
+within range for).  */
+  if (TREE_CODE (d) == VAR_DECL
+ && DECL_ARTIFICIAL (d))
+   continue;
+
   tree suggestion = DECL_NAME (d);
   if (!suggestion)
continue;
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index ca04dca..d4214d4 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -1227,9 +1227,16 @@ lookup_field_fuzzy_info::fuzzy_lookup_field (tree type)
 
   for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
 {
-  if (!m_want_type_p || DECL_DECLARES_TYPE_P (field))
-   if (DECL_NAME (field))
- m_candidates.safe_push (DECL_NAME (field));
+  if (m_want_type_p && !DECL_DECLARES_TYPE_P (field))
+   continue;
+
+  if (!DECL_NAME (field))
+   continue;
+
+  if (is_lambda_ignored_entity (field))
+   continue;
+
+  m_candidates.safe_push (DECL_NAME (field));
 }
 }
 
diff --git a/gcc/testsuite/g++.dg/pr85515-1.C b/gcc/testsuite/g++.dg/pr85515-1.C
new file mode 100644
index 000..0e27a9d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr85515-1.C
@@ -0,0 +1,18 @@
+// { dg-require-effective-target c++14 }
+
+void test_1 ()
+{
+  auto lambda = [val = 2](){};
+  lambda.val; // { dg-bogus "did you mean" }
+  // { dg-error "has no member named 'val'" "" { target *-*-* } .-1 }
+}
+
+int test_2 ()
+{
+  auto lambda = [val = 2](){ return val; };
+
+  // TODO: should we issue an error for the following assignment?
+  lambda.__val = 4;
+
+  return lambda();
+}
diff --git a/gcc/testsuite/g++.dg/pr85515-2.C b/gcc/testsuite/g++.dg/pr85515-2.C
new file mode 100644
index 000..621ddb8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr85515-2.C
@@ -0,0 +1,22 @@
+// { dg-require-effective-target c++11 }
+
+void test_1 ()
+{
+  int arr[] = {1, 2, 3, 4, 5};
+  for (const auto v: arr) {
+_forbegin; // { dg-bogus "suggested alternative" }
+// { dg-error "'_forbegin' was not declared in this scope" "" { target 
*-*-*} .-1 }
+  }
+}
+
+int test_2 ()
+{
+  int arr[] = {1, 2, 3, 4, 5};
+  int sum = 0;
+  for (const auto v: arr) {
+sum += v;
+// TODO: should we issue an error for the following assignment?
+__for_begin = __for_end;
+  }
+  return sum;
+}
-- 
1.8.5.3



[Bug fortran/88248] [F18] Bogus warning about obsolescent feature: Labeled DO statement

2019-02-14 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88248

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #10 from Dominique d'Humieres  ---
> Fixed.

So closing!

[PATCH, testsuite]: Re-enable 64-bit form in gcc.target/i386/ssse3-*.c on AVX targets

2019-02-14 Thread Uros Bizjak
2019-02-14  Uroš Bizjak  

* gcc.target/i386/ssse3-pabsb.c: Re-enable 64-bit form on AVX targets.
* gcc.target/i386/ssse3-pabsd.c: Ditto.
* gcc.target/i386/ssse3-pabsw.c: Ditto.
* gcc.target/i386/ssse3-palignr.c: Ditto.
* gcc.target/i386/ssse3-phaddd.c: Ditto.
* gcc.target/i386/ssse3-phaddsw.c: Ditto.
* gcc.target/i386/ssse3-phaddw.c: Ditto.
* gcc.target/i386/ssse3-phsubd.c: Ditto.
* gcc.target/i386/ssse3-phsubsw.c: Ditto.
* gcc.target/i386/ssse3-phsubw.c: Ditto.
* gcc.target/i386/ssse3-pmaddubsw.c: Ditto.
* gcc.target/i386/ssse3-pmulhrsw.c: Ditto.
* gcc.target/i386/ssse3-pshufb.c: Ditto.
* gcc.target/i386/ssse3-psignb.c: Ditto.
* gcc.target/i386/ssse3-psignd.c: Ditto.
* gcc.target/i386/ssse3-psignw.c: Ditto.

Tested on x86_64-linux-gnu {,-m32} w/ and w/o -mavx.

Committed to mainline SVN.

Uros.
Index: gcc.target/i386/ssse3-pabsb.c
===
--- gcc.target/i386/ssse3-pabsb.c   (revision 268854)
+++ gcc.target/i386/ssse3-pabsb.c   (working copy)
@@ -15,7 +15,6 @@
 #include "ssse3-vals.h"
 #include 
 
-#ifndef __AVX__
 /* Test the 64-bit form */
 static void
 ssse3_test_pabsb (int *i1, int *r)
@@ -24,7 +23,6 @@
   *(__m64 *) r = _mm_abs_pi8 (t1);
   _mm_empty ();
 }
-#endif
 
 /* Test the 128-bit form */
 static void
@@ -63,12 +61,10 @@
   /* Manually compute the result */
   compute_correct_result([i + 0], ck);
 
-#ifndef __AVX__
   /* Run the 64-bit tests */
   ssse3_test_pabsb ([i + 0], [0]);
   ssse3_test_pabsb ([i + 2], [2]);
   fail += chk_128 (ck, r);
-#endif
 
   /* Run the 128-bit tests */
   ssse3_test_pabsb128 ([i + 0], r);
Index: gcc.target/i386/ssse3-pabsd.c
===
--- gcc.target/i386/ssse3-pabsd.c   (revision 268854)
+++ gcc.target/i386/ssse3-pabsd.c   (working copy)
@@ -16,7 +16,6 @@
 
 #include 
 
-#ifndef __AVX__
 /* Test the 64-bit form */
 static void
 ssse3_test_pabsd (int *i1, int *r)
@@ -25,7 +24,6 @@
   *(__m64 *) r = _mm_abs_pi32 (t1);
   _mm_empty ();
 }
-#endif
 
 /* Test the 128-bit form */
 static void
@@ -62,12 +60,10 @@
   /* Manually compute the result */
   compute_correct_result([i + 0], ck);
 
-#ifndef __AVX__
   /* Run the 64-bit tests */
   ssse3_test_pabsd ([i + 0], [0]);
   ssse3_test_pabsd ([i + 2], [2]);
   fail += chk_128 (ck, r);
-#endif
 
   /* Run the 128-bit tests */
   ssse3_test_pabsd128 ([i + 0], r);
Index: gcc.target/i386/ssse3-pabsw.c
===
--- gcc.target/i386/ssse3-pabsw.c   (revision 268854)
+++ gcc.target/i386/ssse3-pabsw.c   (working copy)
@@ -16,7 +16,6 @@
 
 #include 
 
-#ifndef __AVX__
 /* Test the 64-bit form */
 static void
 ssse3_test_pabsw (int *i1, int *r)
@@ -25,7 +24,6 @@
   *(__m64 *) r = _mm_abs_pi16 (t1);
   _mm_empty ();
 }
-#endif
 
 /* Test the 128-bit form */
 static void
@@ -64,12 +62,10 @@
   /* Manually compute the result */
   compute_correct_result ([i + 0], ck);
 
-#ifndef __AVX__
   /* Run the 64-bit tests */
   ssse3_test_pabsw ([i + 0], [0]);
   ssse3_test_pabsw ([i + 2], [2]);
   fail += chk_128 (ck, r);
-#endif
 
   /* Run the 128-bit tests */
   ssse3_test_pabsw128 ([i + 0], r);
Index: gcc.target/i386/ssse3-palignr.c
===
--- gcc.target/i386/ssse3-palignr.c (revision 268854)
+++ gcc.target/i386/ssse3-palignr.c (working copy)
@@ -17,7 +17,6 @@
 #include 
 #include 
 
-#ifndef __AVX__
 /* Test the 64-bit form */
 static void
 ssse3_test_palignr (int *i1, int *i2, unsigned int imm, int *r)
@@ -82,7 +81,6 @@
 
_mm_empty();
 }
-#endif
 
 /* Test the 128-bit form */
 static void
@@ -214,7 +212,6 @@
   bout[i] = buf[imm + i];
 }
 
-#ifndef __AVX__
 static void
 compute_correct_result_64 (int *i1, int *i2, unsigned int imm, int *r)
 {
@@ -242,7 +239,6 @@
 else
   bout[i + 8] = buf[imm + i];
 }
-#endif
 
 static void
 TEST (void)
@@ -256,7 +252,6 @@
   for (i = 0; i < 256; i += 8)
 for (imm = 0; imm < 100; imm++)
   {
-#ifndef __AVX__
/* Manually compute the result */
compute_correct_result_64 ([i + 0], [i + 4], imm, ck);
 
@@ -264,7 +259,6 @@
ssse3_test_palignr ([i + 0], [i + 4], imm, [0]);
ssse3_test_palignr ([i + 2], [i + 6], imm, [2]);
fail += chk_128 (ck, r);
-#endif
 
/* Recompute the results for 128-bits */
compute_correct_result_128 ([i + 0], [i + 4], imm, ck);
Index: gcc.target/i386/ssse3-phaddd.c
===
--- gcc.target/i386/ssse3-phaddd.c  (revision 268854)
+++ gcc.target/i386/ssse3-phaddd.c  (working copy)
@@ -16,7 +16,6 @@
 
 #include 
 
-#ifndef __AVX__
 /* Test the 64-bit form */
 static void
 ssse3_test_phaddd (int *i1, int *i2, int *r)
@@ -26,7 

[Bug fortran/81552] -finit-integer=n is restricted to 32-bit INTEGER.

2019-02-14 Thread jb at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81552

Janne Blomqvist  changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 CC||jb at gcc dot gnu.org
 Resolution|--- |FIXED

--- Comment #6 from Janne Blomqvist  ---
Fixed on trunk, closing.

The patch uses strtol() since that is in C89 and thus available everywhere.
This close to the GCC 9 release I didn't want to risk breaking some targets I
don't have a GCC development environment setup on.

strtoll and int64_t are in C99 and with some GCC headers and libiberty they
should be available everywhere, which would make this patch work on 32-bit and
LLP64 (e.g. win64) targets. If anyone is interested in pursuing this I suggest
reopening this bug report and submitting a patch when GCC is in stage 1.

[PATCH, fortran] PR 81552 Improve and document -flag-init-integer

2019-02-14 Thread Janne Blomqvist
Make the option handling code parse the -flag-init-integer value as a
C long type, allowing a larger range on systems where long is a larger
type than int.  Document the behavior.

Regtested on x86_64-pc-linux-gnu, committed as obvious.

2019-02-14  Janne Blomqvist  

PR fortran/81552
* gfortran.h (gfc_option_t): Make flag_init_integer_value a long.
* options.c (gfc_handle_option): Use strtol instead of atoi.
* invoke.texi: Document -finit-integer behavior in more detail.
---
 gcc/fortran/gfortran.h  | 2 +-
 gcc/fortran/invoke.texi | 5 +
 gcc/fortran/options.c   | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 0a0fef81d9f..526897c4170 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2681,7 +2681,7 @@ typedef struct
   int flag_preprocessed;
   int flag_d_lines;
   int flag_init_integer;
-  int flag_init_integer_value;
+  long flag_init_integer_value;
   int flag_init_logical;
   int flag_init_character;
   char flag_init_character_value;
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 0e0c2bcb20d..a5d81960a61 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -1779,6 +1779,11 @@ use @option{-finit-real=snan}; note, however, that 
compile-time
 optimizations may convert them into quiet NaN and that trapping
 needs to be enabled (e.g. via @option{-ffpe-trap}).
 
+The @option{-finit-integer} option will parse the value into an
+integer of type @code{INTEGER(kind=C_LONG)} on the host.  Said value
+is then assigned to the integer variables in the Fortran code, which
+might result in wraparound if the value is too large for the kind.
+
 Finally, note that enabling any of the @option{-finit-*} options will
 silence warnings that would have been emitted by @option{-Wuninitialized}
 for the affected local variables.
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 4e55adec6fe..f2a0151670e 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -708,7 +708,7 @@ gfc_handle_option (size_t scode, const char *arg, 
HOST_WIDE_INT value,
 
 case OPT_finit_integer_:
   gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
-  gfc_option.flag_init_integer_value = atoi (arg);
+  gfc_option.flag_init_integer_value = strtol (arg, NULL, 10);
   break;
 
 case OPT_finit_character_:
-- 
2.17.1



[Bug fortran/81552] -finit-integer=n is restricted to 32-bit INTEGER.

2019-02-14 Thread jb at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81552

--- Comment #5 from Janne Blomqvist  ---
Author: jb
Date: Thu Feb 14 21:33:29 2019
New Revision: 268906

URL: https://gcc.gnu.org/viewcvs?rev=268906=gcc=rev
Log:
PR 81552 Improve and document -flag-init-integer

Make the option handling code parse the -flag-init-integer value as a
C long type, allowing a larger range on systems where long is a larger
type than int.  Document the behavior.

Regtested on x86_64-pc-linux-gnu, committed as obvious.

2019-02-14  Janne Blomqvist  

PR fortran/81552
* gfortran.h (gfc_option_t): Make flag_init_integer_value a long.
* options.c (gfc_handle_option): Use strtol instead of atoi.
* invoke.texi: Document -finit-integer behavior in more detail

Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/invoke.texi
trunk/gcc/fortran/options.c

[PATCH, d] Committed Add netbsd support to GDC

2019-02-14 Thread Iain Buclaw
Hi,

This is a combine of netbsd patches sent by Maya, and related upstream
druntime changes.

Bootstrapped and regression tested on x86_64-linux-gnu, which only
confirms that the scoping is correct.  I trust that Maya tested the
netbsd-d.c part, nothing looks out of place there anyway.

Committed to trunk as r268905.

-- 
Iain
---
gcc/ChangeLog:

2019-02-14  Maya Rashish  

* config.gcc (*-*-netbsd*): Add netbsd-d.o
* config/netbsd-d.c: New file.
* config/t-netbsd: Add netbsd-d.o

gcc/d/ChangeLog:

2019-02-14  Maya Rashish  

* d-system.h: NetBSD is POSIX.

libphobos/ChangeLog:

2019-02-14  Maya Rashish  

* configure.tgt: Add netbsd/x86 as supported target.

---
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 31b47c51b7b..3ee31c5993d 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -839,6 +839,7 @@ case ${target} in
   tm_p_file="${tm_p_file} netbsd-protos.h"
   tmake_file="t-netbsd t-slibgcc"
   extra_objs="${extra_objs} netbsd.o"
+  d_target_objs="${d_target_objs} netbsd-d.o"
   gas=yes
   gnu_ld=yes
   use_gcc_stdint=wrap
@@ -847,6 +848,7 @@ case ${target} in
   esac
   nbsd_tm_file="netbsd.h netbsd-stdint.h netbsd-elf.h"
   default_use_cxa_atexit=yes
+  target_has_targetdm=yes
   ;;
 *-*-openbsd*)
   tmake_file="t-openbsd"
diff --git a/gcc/config/netbsd-d.c b/gcc/config/netbsd-d.c
new file mode 100644
index 000..76342aacae3
--- /dev/null
+++ b/gcc/config/netbsd-d.c
@@ -0,0 +1,41 @@
+/* Functions for generic NetBSD as target machine for GNU D compiler.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tree.h"
+#include "varasm.h"
+#include "netbsd-protos.h"
+#include "tm_p.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+static void
+netbsd_d_os_builtins (void)
+{
+  d_add_builtin_version ("Posix");
+  d_add_builtin_version ("NetBSD");
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS netbsd_d_os_builtins
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
diff --git a/gcc/config/t-netbsd b/gcc/config/t-netbsd
index 4626e963ebf..716a94f86c6 100644
--- a/gcc/config/t-netbsd
+++ b/gcc/config/t-netbsd
@@ -19,3 +19,7 @@
 netbsd.o: $(srcdir)/config/netbsd.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
+
+netbsd-d.o: $(srcdir)/config/netbsd-d.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
index cd59b827812..c32825d4ad1 100644
--- a/gcc/d/d-system.h
+++ b/gcc/d/d-system.h
@@ -24,7 +24,8 @@
 
 /* Used by the dmd front-end to determine if we have POSIX-style IO.  */
 #define POSIX (__linux__ || __GLIBC__ || __gnu_hurd__ || __APPLE__ \
-	   || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun)
+	   || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ \
+	   || __sun)
 
 /* Forward assert invariants to gcc_assert.  */
 #undef assert
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index 2b2a9746811..0471bfd816b 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -30,6 +30,8 @@ case "${target}" in
 	;;
   x86_64-*-linux* | i?86-*-linux*)
 	;;
+  x86_64-*-netbsd* | i?86-*-netbsd*)
+	;;
   *)
 	UNSUPPORTED=1
 	;;
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 921b954aafb..09ce8d03566 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-2fd957307d94b5ce89eb173910cc7f1995d99031
+fb4bda91b0b43b5a18e1c143943c101ad4e17667
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/core/stdc/assert_.d b/libphobos/libdruntime/core/stdc/assert_.d
index ead9c05f35c..ca7afe93b1e 100644
--- a/libphobos/libdruntime/core/stdc/assert_.d
+++ b/libphobos/libdruntime/core/stdc/assert_.d
@@ -53,6 +53,13 @@ else version (FreeBSD)
  */
 void __assert(const(char)* exp, const(char)* file, uint line);
 }
+else version (NetBSD)
+{
+/***
+ * Assert failure function in the NetBSD C library.
+ */
+void __assert(const(char)* file, int line, const(char)* exp);
+}
 else version (DragonFlyBSD)
 {
 /***
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
index c0223b5c776..c04b9c41228 100644
--- 

[Bug go/89321] cross build with riscv64 gccgo compilation failed due to assert in constructor_expression

2019-02-14 Thread ian at airs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89321

Ian Lance Taylor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Ian Lance Taylor  ---
Should be fixed.

Re: [PATCH][DOC] Document new features for GCC 9.

2019-02-14 Thread Martin Sebor

On 2/13/19 6:48 AM, Martin Liška wrote:

Hi.

I'm sending patch where I document changes I made during GCC 9
development. I would appreciate both language and factical comments
about the patch.


Nothing technical, just a few very minor language nits/suggestions.

Martin

diff --git a/htdocs/gcc-9/changes.html b/htdocs/gcc-9/changes.html
index 13243c2..9fec9e2 100644
--- a/htdocs/gcc-9/changes.html
+++ b/htdocs/gcc-9/changes.html
@@ -50,11 +50,64 @@ a work-in-progress.
 General Improvements
 
   
-A new option -flive-patching=[inline-only-static|inline-clone] is
+A new option 
-flive-patching=[inline-only-static|inline-clone] is


s/is/has been/ would be better (and either a comma after option or
a definite article without the comma).

 introduced to provide a safe compilation for live-patching. At the 
same
 time, provides multiple-level control on the enabled IPA 
optimizations.

 See the user guide for further information about the option for more
-details.
+details.

It seems we should choose between "for further information" and "for
more details" but we don't need both.

+  
+  
+  A new option --completion<\>code is added to provide more fine
+  option completion in a shell.  It is intended for Bash-completion 
project.


Missing article: for "a Bash-completion project" (or perhaps "to be
used by Bash completion." not sure exactly what project it refers to).

+  
+  
+  Alignment-related options -falign-functions,

Since you're naming them use a definite article: "The alignment-related
options..."

+  -falign-labels, -falign-loops
+  and -falign-jumps received support for a secondary
+  alignment (e.g. -falign-loops=n:m:n2:m2).
+  
+  
+  A new built-in __builtin_expect_with_probability has 
been added.


I'm really nit-picking now but again, since you are referring to
a specific option a definite article would be more appropriate.
Alternatively: "A new built-in function,
__builtin_expect_with_probability, has been added.

+  
+  
+  Switch expansion has been improved by using a different strategy
+  (jump table, bit test, decision tree) for a subset of switch cases.
+  
+  
+  A linear function expression defined as switch statement with cases

Maybe a missing article?  "defined as a switch statement with cases"
(if that's what you meant.)

+  can be transformed by -ftree-switch-conversion.  For 
example:

+
+int
+foo (int how)
+{
+  switch (how) {
+case 2: how = 205; break;
+case 3: how = 305; break;
+case 4: how = 405; break;
+case 5: how = 505; break;
+case 6: how = 605; break;
+  }
+  return how;
+}
+
+  can be transformed into 100 * how + 5 (for values 
defined

+  in the switch statement).
+  
+  
+  The gcov tool received a new option --use-hotness-colors
+  (-q) that can provide perf-like coloring of hot 
functions.

+  
+  
+  The gcov tool has changed intermediate format to a new JSON format.

Missing article: "has changed an (or "its?") intermediate format..."
depending on how many intermediate formats it has.

+  
+  
+  New pair of profiling options (-fprofile-filter-files
+  and -fprofile-exclude-files) has been added.
+  The options help to filter which source files are instrumented.
+  
+  
+  AddressSanitizer generates more compact red-zones for automatic 
variables.

+  That helps to reduce memory footprint of a sanitized binary.
   
 

@@ -137,7 +190,7 @@ a work-in-progress.
 D
 
   Support for the D programming language has been added to GCC,
-implementing version 2.076 of the language and run-time library.
+implementing version 2.076 of the language and run-time library.
   
 

@@ -294,7 +347,11 @@ a work-in-progress.

 

-
+IA-32/x86-64
+
+  Support of Intel MPX (Memory Protection Extensions) has been 
removed.

+
+

 




Re: Fortran vector math header

2019-02-14 Thread Steve Ellcey
On Wed, 2019-02-13 at 12:34 +0100, Martin Liška wrote:
> May I please ping this so that we can reach mainline soon?
> 
> Thanks,
> Martin

Martin, I can't approve this patch but I can say that I have used it on
Aarch64 and created a follow up patch for aarch64 to create a
get_multilib_abi_name target function for that platform.  Everything
seemed to work fine for me and I did not have any problems or see any
regressions when using your patch.  I hope it gets approved and checked
in soon.

Steve Ellcey
sell...@marvell.com


[Bug go/89321] cross build with riscv64 gccgo compilation failed due to assert in constructor_expression

2019-02-14 Thread ian at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89321

--- Comment #7 from ian at gcc dot gnu.org  ---
Author: ian
Date: Thu Feb 14 21:07:13 2019
New Revision: 268904

URL: https://gcc.gnu.org/viewcvs?rev=268904=gcc=rev
Log:
PR go/89321
compiler: copy has_padding field from converted struct

Test case is https://golang.org/cl/162617.

Fixes https://gcc.gnu.org/PR89321

Reviewed-on: https://go-review.googlesource.com/c/162618

Modified:
trunk/gcc/go/gofrontend/MERGE
trunk/gcc/go/gofrontend/types.cc

Go patch committed: Copy has_padding field if struct backend type exists

2019-02-14 Thread Ian Lance Taylor
This patch fixes the Go frontend to copy the has_padding field if a
struct backend type already exists.  The has_padding field is set when
creating the struct backend type, and checked when creating a
composite literal of that struct type.  When two structs shared the
same backend type, because they were identical, the has_padding field
was not set correctly for the second struct.  This fixes that problem.
The test case is https://golang.org/cl/162617.  This fixes GCC PR
89321.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 268891)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-a487c86418488f6a17dab4f9945e2a5d495e3ddb
+c2fc3b83d832725accd4fa5874a5b5ca02dd90dc
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===
--- gcc/go/gofrontend/types.cc  (revision 268891)
+++ gcc/go/gofrontend/types.cc  (working copy)
@@ -1003,6 +1003,16 @@ Type::get_backend(Gogo* gogo)
  ins.first->second.is_placeholder = false;
}
 
+  // We set the has_padding field of a Struct_type when we convert
+  // to the backend type, so if we have multiple Struct_type's
+  // mapping to the same backend type we need to copy the
+  // has_padding field.  FIXME: This is awkward.  We shouldn't
+  // really change the type when setting the backend type, but
+  // there isn't any other good time to add the padding field.
+  if (ins.first->first->struct_type() != NULL
+ && ins.first->first->struct_type()->has_padding())
+   this->struct_type()->set_has_padding();
+
   return ins.first->second.btype;
 }
 


[Bug lto/89358] Combining -std=c++14 and -std=c++17 objects gives ODR warnings

2019-02-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89358

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-02-14
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
Confirmed. I can't see any difference between std::less in C++14 and
C++17, so I have no idea what the ODR violation is supposed to be.

[Bug lto/89358] New: Combining -std=c++14 and -std=c++17 objects gives ODR warnings

2019-02-14 Thread rogero at howzatt dot demon.co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89358

Bug ID: 89358
   Summary: Combining -std=c++14 and -std=c++17 objects gives ODR
warnings
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: lto
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rogero at howzatt dot demon.co.uk
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

When object modules compiled with -std=c+14 and -std=c++17 are linked together
with -flto there can be warnings about ODR violations in standard library
headers

Example:
-- main.cpp --
#include 

extern void test();

int main()
{
std::map m;
test();
}
-- test.cpp --
#include 

void test()
{
std::map m;
}
-- ends --

g++ -flto -std=c++17 -c main.cpp
g++ -flto -std=c++14 -c test.cpp
g++ -flto main.o test.o

-- output --

/usr/share/gcc-trunk/include/c++/9.0.0/bits/stl_function.h:381:12: note: type
'struct less' itself violates the C++ One Definition Rule
  381 | struct less : public binary_function<_Tp, _Tp, bool>
  |^
/usr/share/gcc-trunk/include/c++/9.0.0/bits/stl_tree.h:684:9: note: type
'struct _Rb_tree_impl' itself violates the C++ One Definition Rule
  684 |  struct _Rb_tree_impl
  | ^
/usr/share/gcc-trunk/include/c++/9.0.0/bits/stl_map.h:100:11: note: type
'struct _Rep_type' itself violates the C++ One Definition Rule
  100 | class map
  |   ^

With gcc trunk from 2019-01-19 on Cygwin.
Almost identical messages appear on RHEL with devtools-7 and with gcc 7.30 on
WSL

Re: [PATCH 37/40] i386: Allow MMX intrinsic emulation with SSE

2019-02-14 Thread H.J. Lu
On Thu, Feb 14, 2019 at 12:54 PM Uros Bizjak  wrote:
>
> On Thu, Feb 14, 2019 at 9:50 PM H.J. Lu  wrote:
> >
> > On Thu, Feb 14, 2019 at 12:07 PM Uros Bizjak  wrote:
> > >
> > > On Thu, Feb 14, 2019 at 1:33 PM H.J. Lu  wrote:
> > > >
> > > > Allow MMX intrinsic emulation with SSE/SSE2/SSSE3.  Don't enable MMX ISA
> > > > by default with TARGET_MMX_WITH_SSE.
> > > >
> > > > For pr82483-1.c and pr82483-2.c, "-mssse3 -mno-mmx" compiles in 64-bit
> > > > mode since MMX intrinsics can be emulated wit SSE.
> > > >
> > > > gcc/
> > > >
> > > > PR target/89021
> > > > * config/i386/i386-builtin.def: Enable MMX intrinsics with
> > > > SSE/SSE2/SSSE3.
> > > > * config/i386/i386.c (ix86_option_override_internal): Don't
> > > > enable MMX ISA with TARGET_MMX_WITH_SSE by default.
> > > > (ix86_init_mmx_sse_builtins): Enable MMX intrinsics with
> > > > SSE/SSE2/SSSE3.
> > > > (ix86_expand_builtin): Allow SSE/SSE2/SSSE3 to emulate MMX
> > > > intrinsics with TARGET_MMX_WITH_SSE.
> > > > * config/i386/mmintrin.h: Don't require MMX in 64-bit mode.
> > > >
> >
> > >
> > > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > > > index a9abbe8706b..1d417e08734 100644
> > > > --- a/gcc/config/i386/i386.c
> > > > +++ b/gcc/config/i386/i386.c
> > > > @@ -4165,12 +4165,15 @@ ix86_option_override_internal (bool main_args_p,
> > > >opts->x_target_flags
> > > > |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
> > > >
> > > > -  /* Enable by default the SSE and MMX builtins.  Do allow the 
> > > > user to
> > > > -explicitly disable any of these.  In particular, disabling SSE 
> > > > and
> > > > -MMX for kernel code is extremely useful.  */
> > > > +  /* Enable the SSE and MMX builtins by default.  Don't enable MMX
> > > > + ISA with TARGET_MMX_WITH_SSE by default.  Do allow the user to
> > > > +explicitly disable any of these.  In particular, disabling SSE
> > > > +and MMX for kernel code is extremely useful.  */
> > > >if (!ix86_arch_specified)
> > > >opts->x_ix86_isa_flags
> > > > -   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | 
> > > > OPTION_MASK_ISA_MMX
> > > > +   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > > > +| (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > > +   ? 0 : OPTION_MASK_ISA_MMX)
> > > >  | TARGET_SUBTARGET64_ISA_DEFAULT)
> > > >  & ~opts->x_ix86_isa_flags_explicit);
> > >
> > > Please split the above into two clauses, the first that sets SSE and
> > > MMX by default, and the second to or with
> > >
> > > opts->x_ix86_isa_flags
> > >  |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit
> > >
> >
> > Like this?
>
> Yes, but also split the comment.

I will go with

 /* Enable by default the SSE and MMX builtins.  Do allow the user to
 explicitly disable any of these.  In particular, disabling SSE and
 MMX for kernel code is extremely useful.  */
  if (!ix86_arch_specified)
{
  /* Don't enable MMX ISA with TARGET_MMX_WITH_SSE.  */
  opts->x_ix86_isa_flags
|= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
 | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
? 0 : OPTION_MASK_ISA_MMX))
& ~opts->x_ix86_isa_flags_explicit);
  opts->x_ix86_isa_flags
|= (TARGET_SUBTARGET64_ISA_DEFAULT
& ~opts->x_ix86_isa_flags_explicit);
}


-- 
H.J.


Re: [Committed][PATCH][GCC][Arm] Fix test directive

2019-02-14 Thread Christophe Lyon
On Thu, 14 Feb 2019 at 19:27, Tamar Christina  wrote:
>
> Hi All,
>
> This patch fixes a failing testcase due to a use of dg-options instead of
> dg-additional-options.
>
Makes sense.
It doesn't fail in any of the configurations I test though, in what
case do you see it failing?

> Committed under the GCC obvious
>
> Bootstrapped Regtested on arm-none-eabi and no issues.
>
> Ok for trunk?
>
> Thanks,
> Tamar
>
> gcc/testsuite/ChangeLog:
>
> 2019-02-14  Tamar Christina  
>
> * gcc.target/arm/pr88850.c: change options to additional option.
>
> --


Re: [PATCH 40/40] i386: Also enable SSSE3 __m64 tests in 64-bit mode

2019-02-14 Thread H.J. Lu
On Thu, Feb 14, 2019 at 12:43 PM Uros Bizjak  wrote:
>
> On Thu, Feb 14, 2019 at 9:21 PM Uros Bizjak  wrote:
> >
> > On Thu, Feb 14, 2019 at 1:30 PM H.J. Lu  wrote:
> > >
> > > Since we now emulate MMX intrinsics with SSE in 64-bit mode, we can
> > > enable SSSE3 __m64 tests even when AVX is enabled.
> > >
> > > PR target/89021
> > > * gcc.target/i386/ssse3-pabsb.c: Also enable __m64 check in
> > > 64-bit mode.
> > > * gcc.target/i386/ssse3-pabsd.c: Likewise.
> > > * gcc.target/i386/ssse3-pabsw.c: Likewise.
> > > * gcc.target/i386/ssse3-palignr.c: Likewise.
> > > * gcc.target/i386/ssse3-phaddd.c: Likewise.
> > > * gcc.target/i386/ssse3-phaddsw.c: Likewise.
> > > * gcc.target/i386/ssse3-phaddw.c: Likewise.
> > > * gcc.target/i386/ssse3-phsubd.c: Likewise.
> > > * gcc.target/i386/ssse3-phsubsw.c: Likewise.
> > > * gcc.target/i386/ssse3-phsubw.c: Likewise.
> > > * gcc.target/i386/ssse3-pmaddubsw.c: Likewise.
> > > * gcc.target/i386/ssse3-pmulhrsw.c: Likewise.
> > > * gcc.target/i386/ssse3-pshufb.c: Likewise.
> > > * gcc.target/i386/ssse3-psignb.c: Likewise.
> > > * gcc.target/i386/ssse3-psignd.c: Likewise.
> > > * gcc.target/i386/ssse3-psignw.c: Likewise.
> > > ---
> > >  gcc/testsuite/gcc.target/i386/ssse3-pabsb.c | 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-pabsd.c | 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-pabsw.c | 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-palignr.c   | 6 +++---
> > >  gcc/testsuite/gcc.target/i386/ssse3-phaddd.c| 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-phaddsw.c   | 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-phaddw.c| 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-phsubd.c| 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-phsubsw.c   | 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-phsubw.c| 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-pmaddubsw.c | 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-pmulhrsw.c  | 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-pshufb.c| 6 +++---
> > >  gcc/testsuite/gcc.target/i386/ssse3-psignb.c| 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-psignd.c| 4 ++--
> > >  gcc/testsuite/gcc.target/i386/ssse3-psignw.c| 4 ++--
> > >  16 files changed, 34 insertions(+), 34 deletions(-)
> > >
> > > diff --git a/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c 
> > > b/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
> > > index 7caa1b6c3a6..eef4ccae222 100644
> > > --- a/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
> > > +++ b/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
> > > @@ -15,7 +15,7 @@
> > >  #include "ssse3-vals.h"
> > >  #include 
> > >
> > > -#ifndef __AVX__
> > > +#if !defined __AVX__ || defined __x86_64__
> >
> > Better add || defined __x86_64__.
> >
> > I also wonder why AVX has to be disabled here. MMX should be orthogonal to 
> > AVX.
>
> Actually, current trunk passes tests with #ifndef __AVX__ removed and:

I don't remember why AVX was disabled.  It is possible that AVX SDE at
the time didn't
support MMX with AVX.Can you check in a separate patch to remove
__AVX__ check?

Thanks.

> gmake -k check-gcc
> RUNTESTFLAGS="--target_board=unix\{,-m32\}\{,-mavx\}
> i386.exp=ssse3-*.c"
>
> === gcc tests ===
>
> Schedule of variations:
> unix
> unix/-mavx
> unix/-m32
> unix/-m32/-mavx
>
> === gcc Summary ===
>
> # of expected passes128
>
> Uros.

-- 
H.J.


Re: [PATCH 37/40] i386: Allow MMX intrinsic emulation with SSE

2019-02-14 Thread Uros Bizjak
On Thu, Feb 14, 2019 at 9:50 PM H.J. Lu  wrote:
>
> On Thu, Feb 14, 2019 at 12:07 PM Uros Bizjak  wrote:
> >
> > On Thu, Feb 14, 2019 at 1:33 PM H.J. Lu  wrote:
> > >
> > > Allow MMX intrinsic emulation with SSE/SSE2/SSSE3.  Don't enable MMX ISA
> > > by default with TARGET_MMX_WITH_SSE.
> > >
> > > For pr82483-1.c and pr82483-2.c, "-mssse3 -mno-mmx" compiles in 64-bit
> > > mode since MMX intrinsics can be emulated wit SSE.
> > >
> > > gcc/
> > >
> > > PR target/89021
> > > * config/i386/i386-builtin.def: Enable MMX intrinsics with
> > > SSE/SSE2/SSSE3.
> > > * config/i386/i386.c (ix86_option_override_internal): Don't
> > > enable MMX ISA with TARGET_MMX_WITH_SSE by default.
> > > (ix86_init_mmx_sse_builtins): Enable MMX intrinsics with
> > > SSE/SSE2/SSSE3.
> > > (ix86_expand_builtin): Allow SSE/SSE2/SSSE3 to emulate MMX
> > > intrinsics with TARGET_MMX_WITH_SSE.
> > > * config/i386/mmintrin.h: Don't require MMX in 64-bit mode.
> > >
>
> >
> > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > > index a9abbe8706b..1d417e08734 100644
> > > --- a/gcc/config/i386/i386.c
> > > +++ b/gcc/config/i386/i386.c
> > > @@ -4165,12 +4165,15 @@ ix86_option_override_internal (bool main_args_p,
> > >opts->x_target_flags
> > > |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
> > >
> > > -  /* Enable by default the SSE and MMX builtins.  Do allow the user 
> > > to
> > > -explicitly disable any of these.  In particular, disabling SSE 
> > > and
> > > -MMX for kernel code is extremely useful.  */
> > > +  /* Enable the SSE and MMX builtins by default.  Don't enable MMX
> > > + ISA with TARGET_MMX_WITH_SSE by default.  Do allow the user to
> > > +explicitly disable any of these.  In particular, disabling SSE
> > > +and MMX for kernel code is extremely useful.  */
> > >if (!ix86_arch_specified)
> > >opts->x_ix86_isa_flags
> > > -   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | 
> > > OPTION_MASK_ISA_MMX
> > > +   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > > +| (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > > +   ? 0 : OPTION_MASK_ISA_MMX)
> > >  | TARGET_SUBTARGET64_ISA_DEFAULT)
> > >  & ~opts->x_ix86_isa_flags_explicit);
> >
> > Please split the above into two clauses, the first that sets SSE and
> > MMX by default, and the second to or with
> >
> > opts->x_ix86_isa_flags
> >  |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit
> >
>
> Like this?

Yes, but also split the comment.

Thanks,
Uros.

>   /* Enable the SSE and MMX builtins by default.  Don't enable MMX
>  ISA with TARGET_MMX_WITH_SSE by default.  Do allow the user to
>  explicitly disable any of these.  In particular, disabling SSE
>  and MMX for kernel code is extremely useful.  */
>   if (!ix86_arch_specified)
> {
>   opts->x_ix86_isa_flags
> |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
>  | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> ? 0 : OPTION_MASK_ISA_MMX))
> & ~opts->x_ix86_isa_flags_explicit);
>   opts->x_ix86_isa_flags
> |= (TARGET_SUBTARGET64_ISA_DEFAULT
> & ~opts->x_ix86_isa_flags_explicit);
> }
>
>
> > > diff --git a/gcc/config/i386/mmintrin.h b/gcc/config/i386/mmintrin.h
> > > index 238b3df3121..7b613658111 100644
> > > --- a/gcc/config/i386/mmintrin.h
> > > +++ b/gcc/config/i386/mmintrin.h
> > > @@ -30,7 +30,7 @@
> > >  #if defined __x86_64__ && !defined __SSE__ || !defined __MMX__
> > >  #pragma GCC push_options
> > >  #ifdef __x86_64__
> > > -#pragma GCC target("sse,mmx")
> > > +#pragma GCC target("sse2")
> >
> > You will need to involve __MMX_WITH_SSE__ here, probably to something like:
> >
> > #ifdef __MMX_WITH_SSE__
> > #pragma GCC target("sse2")
> > #elif defined __x86_64__
> > #pragma GCC target("sse,mmx")
> > #else
> > #pragma GCC target("mmx")
> > #endif
> >
> > >  #else
> > >  #pragma GCC target("mmx")
> > >  #endif
> > > @@ -315,7 +315,11 @@ _m_paddd (__m64 __m1, __m64 __m2)
> > >  /* Add the 64-bit values in M1 to the 64-bit values in M2.  */
> > >  #ifndef __SSE2__
> > >  #pragma GCC push_options
> > > +#ifdef __x86_64__
> >
> > #ifdef __MMX_WITH_SSE__
> >
> > > +#pragma GCC target("sse2")
> > > +#else
> > >  #pragma GCC target("sse2,mmx")
> > > +#endif
> > >  #define __DISABLE_SSE2__
> > >  #endif /* __SSE2__ */
> > >
> > > @@ -427,7 +431,11 @@ _m_psubd (__m64 __m1, __m64 __m2)
> > >  /* Add the 64-bit values in M1 to the 64-bit values in M2.  */
> > >  #ifndef __SSE2__
> > >  #pragma GCC push_options
> > > +#ifdef __x86_64__
> >
> > #ifdef __MMX_WITH_SSE__
> >
> > > +#pragma GCC target("sse2")
> > > +#else
> > >  #pragma GCC target("sse2,mmx")
> > > +#endif
> > >  #define __DISABLE_SSE2__
> > >  

Re: [PATCH 37/40] i386: Allow MMX intrinsic emulation with SSE

2019-02-14 Thread H.J. Lu
On Thu, Feb 14, 2019 at 12:07 PM Uros Bizjak  wrote:
>
> On Thu, Feb 14, 2019 at 1:33 PM H.J. Lu  wrote:
> >
> > Allow MMX intrinsic emulation with SSE/SSE2/SSSE3.  Don't enable MMX ISA
> > by default with TARGET_MMX_WITH_SSE.
> >
> > For pr82483-1.c and pr82483-2.c, "-mssse3 -mno-mmx" compiles in 64-bit
> > mode since MMX intrinsics can be emulated wit SSE.
> >
> > gcc/
> >
> > PR target/89021
> > * config/i386/i386-builtin.def: Enable MMX intrinsics with
> > SSE/SSE2/SSSE3.
> > * config/i386/i386.c (ix86_option_override_internal): Don't
> > enable MMX ISA with TARGET_MMX_WITH_SSE by default.
> > (ix86_init_mmx_sse_builtins): Enable MMX intrinsics with
> > SSE/SSE2/SSSE3.
> > (ix86_expand_builtin): Allow SSE/SSE2/SSSE3 to emulate MMX
> > intrinsics with TARGET_MMX_WITH_SSE.
> > * config/i386/mmintrin.h: Don't require MMX in 64-bit mode.
> >

>
> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > index a9abbe8706b..1d417e08734 100644
> > --- a/gcc/config/i386/i386.c
> > +++ b/gcc/config/i386/i386.c
> > @@ -4165,12 +4165,15 @@ ix86_option_override_internal (bool main_args_p,
> >opts->x_target_flags
> > |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
> >
> > -  /* Enable by default the SSE and MMX builtins.  Do allow the user to
> > -explicitly disable any of these.  In particular, disabling SSE and
> > -MMX for kernel code is extremely useful.  */
> > +  /* Enable the SSE and MMX builtins by default.  Don't enable MMX
> > + ISA with TARGET_MMX_WITH_SSE by default.  Do allow the user to
> > +explicitly disable any of these.  In particular, disabling SSE
> > +and MMX for kernel code is extremely useful.  */
> >if (!ix86_arch_specified)
> >opts->x_ix86_isa_flags
> > -   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | 
> > OPTION_MASK_ISA_MMX
> > +   |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > +| (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > +   ? 0 : OPTION_MASK_ISA_MMX)
> >  | TARGET_SUBTARGET64_ISA_DEFAULT)
> >  & ~opts->x_ix86_isa_flags_explicit);
>
> Please split the above into two clauses, the first that sets SSE and
> MMX by default, and the second to or with
>
> opts->x_ix86_isa_flags
>  |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit
>

Like this?

  /* Enable the SSE and MMX builtins by default.  Don't enable MMX
 ISA with TARGET_MMX_WITH_SSE by default.  Do allow the user to
 explicitly disable any of these.  In particular, disabling SSE
 and MMX for kernel code is extremely useful.  */
  if (!ix86_arch_specified)
{
  opts->x_ix86_isa_flags
|= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
 | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
? 0 : OPTION_MASK_ISA_MMX))
& ~opts->x_ix86_isa_flags_explicit);
  opts->x_ix86_isa_flags
|= (TARGET_SUBTARGET64_ISA_DEFAULT
& ~opts->x_ix86_isa_flags_explicit);
}


> > diff --git a/gcc/config/i386/mmintrin.h b/gcc/config/i386/mmintrin.h
> > index 238b3df3121..7b613658111 100644
> > --- a/gcc/config/i386/mmintrin.h
> > +++ b/gcc/config/i386/mmintrin.h
> > @@ -30,7 +30,7 @@
> >  #if defined __x86_64__ && !defined __SSE__ || !defined __MMX__
> >  #pragma GCC push_options
> >  #ifdef __x86_64__
> > -#pragma GCC target("sse,mmx")
> > +#pragma GCC target("sse2")
>
> You will need to involve __MMX_WITH_SSE__ here, probably to something like:
>
> #ifdef __MMX_WITH_SSE__
> #pragma GCC target("sse2")
> #elif defined __x86_64__
> #pragma GCC target("sse,mmx")
> #else
> #pragma GCC target("mmx")
> #endif
>
> >  #else
> >  #pragma GCC target("mmx")
> >  #endif
> > @@ -315,7 +315,11 @@ _m_paddd (__m64 __m1, __m64 __m2)
> >  /* Add the 64-bit values in M1 to the 64-bit values in M2.  */
> >  #ifndef __SSE2__
> >  #pragma GCC push_options
> > +#ifdef __x86_64__
>
> #ifdef __MMX_WITH_SSE__
>
> > +#pragma GCC target("sse2")
> > +#else
> >  #pragma GCC target("sse2,mmx")
> > +#endif
> >  #define __DISABLE_SSE2__
> >  #endif /* __SSE2__ */
> >
> > @@ -427,7 +431,11 @@ _m_psubd (__m64 __m1, __m64 __m2)
> >  /* Add the 64-bit values in M1 to the 64-bit values in M2.  */
> >  #ifndef __SSE2__
> >  #pragma GCC push_options
> > +#ifdef __x86_64__
>
> #ifdef __MMX_WITH_SSE__
>
> > +#pragma GCC target("sse2")
> > +#else
> >  #pragma GCC target("sse2,mmx")
> > +#endif
> >  #define __DISABLE_SSE2__
> >  #endif /* __SSE2__ */
> >
> > diff --git a/gcc/testsuite/gcc.target/i386/pr82483-1.c 
> > b/gcc/testsuite/gcc.target/i386/pr82483-1.c

I will do

diff --git a/gcc/config/i386/mmintrin.h b/gcc/config/i386/mmintrin.h
index 238b3df3121..c4b2e0c7b25 100644
--- a/gcc/config/i386/mmintrin.h
+++ b/gcc/config/i386/mmintrin.h
@@ -29,7 +29,9 @@

 #if defined __x86_64__ && 

Re: [PATCH 40/40] i386: Also enable SSSE3 __m64 tests in 64-bit mode

2019-02-14 Thread Uros Bizjak
On Thu, Feb 14, 2019 at 9:21 PM Uros Bizjak  wrote:
>
> On Thu, Feb 14, 2019 at 1:30 PM H.J. Lu  wrote:
> >
> > Since we now emulate MMX intrinsics with SSE in 64-bit mode, we can
> > enable SSSE3 __m64 tests even when AVX is enabled.
> >
> > PR target/89021
> > * gcc.target/i386/ssse3-pabsb.c: Also enable __m64 check in
> > 64-bit mode.
> > * gcc.target/i386/ssse3-pabsd.c: Likewise.
> > * gcc.target/i386/ssse3-pabsw.c: Likewise.
> > * gcc.target/i386/ssse3-palignr.c: Likewise.
> > * gcc.target/i386/ssse3-phaddd.c: Likewise.
> > * gcc.target/i386/ssse3-phaddsw.c: Likewise.
> > * gcc.target/i386/ssse3-phaddw.c: Likewise.
> > * gcc.target/i386/ssse3-phsubd.c: Likewise.
> > * gcc.target/i386/ssse3-phsubsw.c: Likewise.
> > * gcc.target/i386/ssse3-phsubw.c: Likewise.
> > * gcc.target/i386/ssse3-pmaddubsw.c: Likewise.
> > * gcc.target/i386/ssse3-pmulhrsw.c: Likewise.
> > * gcc.target/i386/ssse3-pshufb.c: Likewise.
> > * gcc.target/i386/ssse3-psignb.c: Likewise.
> > * gcc.target/i386/ssse3-psignd.c: Likewise.
> > * gcc.target/i386/ssse3-psignw.c: Likewise.
> > ---
> >  gcc/testsuite/gcc.target/i386/ssse3-pabsb.c | 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-pabsd.c | 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-pabsw.c | 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-palignr.c   | 6 +++---
> >  gcc/testsuite/gcc.target/i386/ssse3-phaddd.c| 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-phaddsw.c   | 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-phaddw.c| 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-phsubd.c| 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-phsubsw.c   | 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-phsubw.c| 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-pmaddubsw.c | 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-pmulhrsw.c  | 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-pshufb.c| 6 +++---
> >  gcc/testsuite/gcc.target/i386/ssse3-psignb.c| 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-psignd.c| 4 ++--
> >  gcc/testsuite/gcc.target/i386/ssse3-psignw.c| 4 ++--
> >  16 files changed, 34 insertions(+), 34 deletions(-)
> >
> > diff --git a/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c 
> > b/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
> > index 7caa1b6c3a6..eef4ccae222 100644
> > --- a/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
> > +++ b/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
> > @@ -15,7 +15,7 @@
> >  #include "ssse3-vals.h"
> >  #include 
> >
> > -#ifndef __AVX__
> > +#if !defined __AVX__ || defined __x86_64__
>
> Better add || defined __x86_64__.
>
> I also wonder why AVX has to be disabled here. MMX should be orthogonal to 
> AVX.

Actually, current trunk passes tests with #ifndef __AVX__ removed and:

gmake -k check-gcc
RUNTESTFLAGS="--target_board=unix\{,-m32\}\{,-mavx\}
i386.exp=ssse3-*.c"

=== gcc tests ===

Schedule of variations:
unix
unix/-mavx
unix/-m32
unix/-m32/-mavx

=== gcc Summary ===

# of expected passes128

Uros.
Index: gcc.target/i386/ssse3-pabsb.c
===
--- gcc.target/i386/ssse3-pabsb.c   (revision 268854)
+++ gcc.target/i386/ssse3-pabsb.c   (working copy)
@@ -15,7 +15,6 @@
 #include "ssse3-vals.h"
 #include 
 
-#ifndef __AVX__
 /* Test the 64-bit form */
 static void
 ssse3_test_pabsb (int *i1, int *r)
@@ -24,7 +23,6 @@
   *(__m64 *) r = _mm_abs_pi8 (t1);
   _mm_empty ();
 }
-#endif
 
 /* Test the 128-bit form */
 static void
@@ -63,12 +61,10 @@
   /* Manually compute the result */
   compute_correct_result([i + 0], ck);
 
-#ifndef __AVX__
   /* Run the 64-bit tests */
   ssse3_test_pabsb ([i + 0], [0]);
   ssse3_test_pabsb ([i + 2], [2]);
   fail += chk_128 (ck, r);
-#endif
 
   /* Run the 128-bit tests */
   ssse3_test_pabsb128 ([i + 0], r);
Index: gcc.target/i386/ssse3-pabsd.c
===
--- gcc.target/i386/ssse3-pabsd.c   (revision 268854)
+++ gcc.target/i386/ssse3-pabsd.c   (working copy)
@@ -16,7 +16,6 @@
 
 #include 
 
-#ifndef __AVX__
 /* Test the 64-bit form */
 static void
 ssse3_test_pabsd (int *i1, int *r)
@@ -25,7 +24,6 @@
   *(__m64 *) r = _mm_abs_pi32 (t1);
   _mm_empty ();
 }
-#endif
 
 /* Test the 128-bit form */
 static void
@@ -62,12 +60,10 @@
   /* Manually compute the result */
   compute_correct_result([i + 0], ck);
 
-#ifndef __AVX__
   /* Run the 64-bit tests */
   ssse3_test_pabsd ([i + 0], [0]);
   ssse3_test_pabsd ([i + 2], [2]);
   fail += chk_128 (ck, r);
-#endif
 
   /* Run the 128-bit tests */
   ssse3_test_pabsd128 ([i + 0], r);
Index: gcc.target/i386/ssse3-pabsw.c
===
--- gcc.target/i386/ssse3-pabsw.c   (revision 

[Bug fortran/88248] [F18] Bogus warning about obsolescent feature: Labeled DO statement

2019-02-14 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88248

--- Comment #9 from Harald Anlauf  ---
Fixed.

[PATCH] v2: Fix excess warnings from -Wtype-limits with location wrappers (PR c++/88680)

2019-02-14 Thread David Malcolm
On Thu, 2019-02-14 at 17:32 +0100, Jakub Jelinek wrote:
> On Thu, Feb 14, 2019 at 11:26:15AM -0500, David Malcolm wrote:
> > There's an asymmetry in the warning; it's looking for a comparison
> > of a
> > LHS expression against an RHS constant 0, spelled as "0".
> > 
> > If we fold_for_warn on the RHS, then that folding introduces a
> > warning
> > for expressions that aren't spelled as "0" but can be folded to 0,
> > e.g., with:
> > 
> > enum { FOO, BAR };
> 
> So, shouldn't it be made symmetric?  Check if one argument is literal
> 0
> before folding, and only if it is, fold_for_warn the other argument?
> 
>   Jakub

The reference to symmetry in my earlier email was somewhat
misleading, sorry.

The test happens after a canonicalization of the ordering happens
here, near the top of shorten_compare:

  /* If first arg is constant, swap the args (changing operation
 so value is preserved), for canonicalization.  Don't do this if
 the second arg is 0.  */

so this already gives us symmetry.

Here's an updated version of the patch which add the fold_for_warn in
a slightly later place, and adds a comment, and some more test cases.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

OK for trunk?


Blurb from v1:

PR c++/88680 reports excess warnings from -Wtype-limits after the C++
FE's use of location wrappers was extended in r267272 for cases such as:

  const unsigned n = 8;
  static_assert (n >= 0 && n % 2 == 0, "");

t.C:3:18: warning: comparison of unsigned expression >= 0 is always true
  [-Wtype-limits]
3 | static_assert (n >= 0 && n % 2 == 0, "");
  |~~^~~~

The root cause is that the location wrapper around "n" breaks the
suppression of the warning for the "if OP0 is a constant that is >= 0"
case.

This patch fixes it by calling fold_for_warn on OP0, extracting the
constant.

gcc/c-family/ChangeLog:
PR c++/88680
* c-common.c (shorten_compare): Call fold_for_warn on op0 when
implementing -Wtype-limits.

gcc/testsuite/ChangeLog:
PR c++/88680
* g++.dg/wrappers/pr88680.C: New test.
---
 gcc/c-family/c-common.c | 13 ++--
 gcc/testsuite/g++.dg/wrappers/pr88680.C | 56 +
 2 files changed, 66 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/wrappers/pr88680.C

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index ae23e59..c6856c9 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3117,6 +3117,12 @@ shorten_compare (location_t loc, tree *op0_ptr, tree 
*op1_ptr,
   primop0 = op0;
   primop1 = op1;
 
+  /* We want to fold unsigned comparisons of >= and < against zero.
+For these, we may also issue a warning if we have a non-constant
+compared against zero, where the zero was spelled as "0" (rather
+than merely folding to it).
+If we have at least one constant, then op1 is constant
+and we may have a non-constant expression as op0.  */
   if (!real1 && !real2 && integer_zerop (primop1)
  && TYPE_UNSIGNED (*restype_ptr))
{
@@ -3125,13 +3131,14 @@ shorten_compare (location_t loc, tree *op0_ptr, tree 
*op1_ptr,
 if OP0 is a constant that is >= 0, the signedness of
 the comparison isn't an issue, so suppress the
 warning.  */
+ tree folded_op0 = fold_for_warn (op0);
  bool warn = 
warn_type_limits && !in_system_header_at (loc)
-   && !(TREE_CODE (primop0) == INTEGER_CST
+   && !(TREE_CODE (folded_op0) == INTEGER_CST
 && !TREE_OVERFLOW (convert (c_common_signed_type (type),
-primop0)))
+folded_op0)))
/* Do not warn for enumeration types.  */
-   && (TREE_CODE (expr_original_type (primop0)) != ENUMERAL_TYPE);
+   && (TREE_CODE (expr_original_type (folded_op0)) != ENUMERAL_TYPE);
  
  switch (code)
{
diff --git a/gcc/testsuite/g++.dg/wrappers/pr88680.C 
b/gcc/testsuite/g++.dg/wrappers/pr88680.C
new file mode 100644
index 000..5497cda
--- /dev/null
+++ b/gcc/testsuite/g++.dg/wrappers/pr88680.C
@@ -0,0 +1,56 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wtype-limits" }
+
+const unsigned N = 8;
+const unsigned P = 0;
+
+enum { FOO, BAR };
+
+static_assert (N >= 0 && N % 2 == 0, "");
+static_assert (FOO >= 0, "");
+static_assert (FOO >= FOO, "");
+static_assert (FOO >= P, "");
+static_assert (BAR >= P, "");
+static_assert (N >= FOO, "");
+
+void test(unsigned n)
+{
+  if (N >= 0 && N % 2 == 0)
+return;
+  if (FOO >= 0)
+return;
+  if (FOO >= FOO)
+return;
+  if (FOO >= P)
+return;
+  if (BAR >= P)
+return;
+  if (N >= FOO)
+return;
+  if (n >= 0) // { dg-warning ">= 0 is always true" }
+return;
+  if (n < 0) // { dg-warning "< 0 is always false" }
+return;
+  if (n >= FOO)

Re: [PR fortran/88248, patch] - [F18] Bogus warning about obsolescent feature: Labeled DO statement

2019-02-14 Thread Harald Anlauf
Commited as rev. 268895:

Sendinggcc/fortran/ChangeLog
Sendinggcc/fortran/symbol.c
Sendinggcc/testsuite/ChangeLog
Sendinggcc/testsuite/gfortran.dg/f2018_obs.f90
Adding gcc/testsuite/gfortran.dg/pr88248.f90
Transmitting file data .done
Committing transaction...
Committed revision 268895.

Thanks for the review, Jerry.

Harald

On 02/14/19 01:45, Jerry DeLisle wrote:
> On 2/13/19 2:38 PM, Harald Anlauf wrote:
>> The attached patch moves the check for labeled DO statements to
>> the place where a label is referenced instead of where a label
>> was defined, which lead to false positives.
>>
>> Regtested on x86_64-pc-linux-gnu.
>>
>> OK for trunk?
>>
> 
> Thanks Harald,
> 
> All OK with test case.
> 
> Jerry
> 



  1   2   3   4   >