Re: [PATCH] Fix loop-header copying do-while loop detection (PR85116)

2018-04-27 Thread Richard Biener
On Fri, 27 Apr 2018, Richard Biener wrote:

> On Fri, 27 Apr 2018, David Edelsohn wrote:
> 
> > Hi, Richi
> > 
> > This patches causes a boostrap failure on AIX.  Everything miscompares.
> > The code itself is the same, but the DWARF debug information contains many
> > differences.
> 
> Does AIX use bootstrap-debug by default?  I don't see how the patch
> can cause this kind of issue directly but of course it will change
> CH decisions which may expose latent bugs somewhere.
> 
> Can you provide more details please, like actual differences?
> I would have expected the dwarf2out.c change to be a more likely
> candidate for such symtoms but I trust that you did properly
> bisect to my patch?

OK, so the x86-64 -O3 bootstrap failure is not caused by this patch,
reverting it doesn't fix the issue.

The difference w/ the patch reverted is in debug info, all (indirect)
strings reside at different offsets.  If I strip the objects they
compare identical.

I'm trying reversal of that dwarf2out patch now.

Richard.


Re: ATTRIBUTE_NONSTRING

2018-04-27 Thread Alan Modra
On Fri, Apr 27, 2018 at 06:24:28PM -0400, Hans-Peter Nilsson wrote:
> On Fri, 27 Apr 2018, Alan Modra wrote:
> 
> > This patch adds ATTRIBUTE_NONSTRING, which will be used to curb
> > -Wstringop-truncation warnings in binutils.  OK to apply?
> >
> > * ansidecl.h (ATTRIBUTE_NONSTRING): Define.
> >
> > diff --git a/include/ansidecl.h b/include/ansidecl.h
> > index c11daff..ec5f34d 100644
> > --- a/include/ansidecl.h
> > +++ b/include/ansidecl.h
> > @@ -283,6 +283,15 @@ So instead we use the macro below and test it against 
> > specific values.  */
> >  # endif /* GNUC >= 4.9 */
> >  #endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */
> >
> > +/* Attribute 'nonstring' was valid as of gcc 8.  */
> > +#ifndef ATTRIBUTE_NONSTRING
> > +# if GCC_VERSION >= 8000
> > +#  define ATTRIBUTE_NONSTRING __attribute__ ((nonstring))
> 
> Uglify nonstring (as __nonstring__)?

Yes, that would be better.  I copied the immediately preceding
ATTRIBUTE_NO_SANITIZE_UNDEFINED without thinking.

-- 
Alan Modra
Australia Development Lab, IBM


[ARM] Fix PR85434: spill of stack protector's guard address

2018-04-27 Thread Thomas Preudhomme
On Arm (Aarch32 and Aarch64) the stack protector's guard is accessed by
loading its address first before loading its value from it as part of
the stack_protect_set or stack_protect_check insn pattern. This creates
the risk of spilling between the two.

It is particularly likely on Aarch32 when compiling PIC code because
- computing the address takes several instructions (first compute the
  GOT base and then the GOT entry by adding an offset) which increases
  the likelyhood of CSE
- the address computation can be CSEd due to the GOT entry computation
  being a MEM of the GOT base + an UNSPEC offset rather than an UNSPEC
  of a MEM like on AArche64.

This patch address both issues by (i) adding some scheduler barriers
around the stack protector code and (ii) making all memory loads
involved in computing the guard's address volatile. The use of volatile
rather than unspec was chosen so that the patterns for computing the
guard address can be the same as for normal global variable access thus
reusing more code. Finally the patch also improves the documentation to
mention the need to be careful when computing the address of the guard.

ChangeLog entry is as follows:

*** gcc/ChangeLog ***

2018-04-27  Thomas Preud'homme  

PR target/85434
* cfgexpand.c (stack_protect_prologue): Emit scheduler barriers around
stack protector code.
* function.c (stack_protect_epilogue): Likewise.
* config/arm/arm-protos.h (arm_stack_chk_guard_decl_p): Declare.
* config/arm/arm.md (calculate_pic_address): Mark memory volatile if
is computing address of stack protector's guard.
(calculate_pic_address splitter): Likewise.
* config/arm/arm.c (require_pic_register): Add parameter to control
whether to insert instruction at the end of the instruction stream.
(legitimize_pic_address): Force computing PIC address at the end of
instruction stream and adapt logic to change in calculate_pic_address
insn pattern.
(arm_stack_chk_guard_decl_p): New function.
(arm_emit_call_insn): Adapt to change in require_pic_register().
* target.def (TARGET_STACK_PROTECT_GUARD): Document requirement on
guard's address computation to be careful about not spilling.
* doc/tm.texi: Regenerate.

*** gcc/testsuite/ChangeLog ***

2018-04-27  Thomas Preud'homme  

PR target/85434
* gcc.target/arm/pr85434.c: New testcase.

Testing: The code has been boostraped on an Armv8-A machine targeting:
- Aarch32 ARM mode with -mfpu=neon-fpv4 and hardfloat ABI
- Aarch64
Testsuite has been run for the following sets of flag:

- arm-eabi-aem/-mthumb/-march=armv4t
- arm-eabi-aem/-marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp
- 
arm-eabi-aem/-mthumb/-march=armv8-a/-mfpu=crypto-neon-fp-armv8/-mfloat-abi=hard

(thereby testing the code for ARM, Thumb-2 and Thumb-1 mode) without any
regression.

Is it ok for trunk?

Best regards,

Thomas
From 76c48e31130f212721addeeca830477e3b6f5e10 Mon Sep 17 00:00:00 2001
From: Thomas Preud'homme 
Date: Mon, 23 Apr 2018 14:37:11 +0100
Subject: [PATCH] [ARM] Fix PR85434: spill of stack protector's guard address

On Arm (Aarch32 and Aarch64) the stack protector's guard is accessed by
loading its address first before loading its value from it as part of
the stack_protect_set or stack_protect_check insn pattern. This creates
the risk of spilling between the two.

It is particularly likely on Aarch32 when compiling PIC code because
- computing the address takes several instructions (first compute the
  GOT base and then the GOT entry by adding an offset) which increases
  the likelyhood of CSE
- the address computation can be CSEd due to the GOT entry computation
  being a MEM of the GOT base + an UNSPEC offset rather than an UNSPEC
  of a MEM like on AArche64.

This patch address both issues by (i) adding some scheduler barriers
around the stack protector code and (ii) making all memory loads
involved in computing the guard's address volatile. The use of volatile
rather than unspec was chosen so that the patterns for computing the
guard address can be the same as for normal global variable access thus
reusing more code. Finally the patch also improves the documentation to
mention the need to be careful when computing the address of the guard.

ChangeLog entry is as follows:

*** gcc/ChangeLog ***

2018-04-27  Thomas Preud'homme  

	* cfgexpand.c (stack_protect_prologue): Emit scheduler barriers around
	stack protector code.
	* function.c (stack_protect_epilogue): Likewise.
	* config/arm/arm-protos.h (arm_stack_chk_guard_decl_p): Declare.
	* config/arm/arm.md (calculate_pic_address): Mark memory volatile if
	is computing address of stack protector's guard.
	(calculate_pic_address splitter): Likewise.
	* config/arm/arm.c (require_pic_register): Add parameter to control
	whether to insert instruction at the end of the instruction stream.
	(legitimize_pic_address): Force computing PIC addr

Re: [C++ PATCH] Fix value initialized decltype(nullptr) in constexpr (PR c++/85553)

2018-04-27 Thread Paolo Carlini

Hi again,

I'm now pretty sure that we have a latent issue in ocp_convert. The bug 
fixed by Jakub shows that we used to not have issues with 
integer_zero_node. That's easy to explain: at the beginning of 
ocp_convert there is code which handles first some special / simple 
cases when same_type_ignoring_top_level_qualifiers_p is true. That code 
isn't of course used for integer_zero_node as source expression, which 
therefore is handled by:


  if (NULLPTR_TYPE_P (type) && e && null_ptr_cst_p (e))
    {
  if (complain & tf_warning)
    maybe_warn_zero_as_null_pointer_constant (e, loc);
  return nullptr_node;
    }

which does the right thing. On the other hand the code at the beginning 
of ocp_covert *is* used for nullptr_node but it doesn't notice that the 
conversion is really trivial and wraps type and expr in a NOP_EXPR. 
Therefore, I think we should handle the special case there, like we 
handle it at the beginning of decay_conversion (careful with side 
effects, as we (I) learned the hard way with a bug!). Tested 
x86_64-linux, of course I also separately checked that the below would 
fix 85553 in a different way.


Thanks,
Paolo.

//
2018-04-28  Paolo Carlini  

* cvt.c (ocp_convert): Early handle the special case of
nullptr converted to nullptr.
Index: cvt.c
===
--- cvt.c   (revision 259731)
+++ cvt.c   (working copy)
@@ -736,6 +736,8 @@ ocp_convert (tree type, tree expr, int convtype, i
  TREE_TYPE (e) = TREE_TYPE (TARGET_EXPR_SLOT (e)) = type;
  return e;
}
+  else if (NULLPTR_TYPE_P (type) && !TREE_SIDE_EFFECTS (e))
+   return nullptr_node;
   else
{
  /* We shouldn't be treating objects of ADDRESSABLE type as


Re: [wwwdocs] Add no_sanitize attribute

2018-04-27 Thread Jeff Law
On 04/18/2018 06:22 AM, Martin Liška wrote:
> I would like to mention the attribute in GCC 8 changes.
OK.
jeff


[openacc, testsuite, PR85527, committed] Fix undefined behaviour in atomic_capture-1.f90

2018-04-27 Thread Tom de Vries

Hi,

Consider this test-case, minimized from atomic_capture-1.f90:
...
program main
  real fgot, fexp, ftmp
  integer, parameter :: N = 32

  fgot = 1234.0
  fexp = 1266.0

  !$acc parallel loop copy (fgot, ftmp) 


  do i = 1, N
 !$acc atomic capture 


 ftmp = fgot
 fgot = fgot + 1.0
 !$acc end atomic 


  end do
  !$acc end parallel loop 



  if (ftmp /= fexp - 1.0) call abort
end program main
...

We write different values to the scalar ftmp in a parallel loop.

So, roughly equivalent to:
...
  !$acc parallel loop copy (ftmp) 


  do i = 1, N
 ftmp = i
  end do
  !$acc end parallel loop
...

This is undefined behaviour, which happens to make the test fail on Titan V.

The patch fixes this by writing the values to an array.

Build x86_64 with nvptx accelerator and ran testcase.

Committed to trunk.

Thanks,
- Tom
[openacc, testsuite] Fix undefined behaviour in atomic_capture-1.f90

2018-04-28  Tom de Vries  

	PR testsuite/85527
	* testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 (main): Store
	atomic capture results obtained in parallel loop to an array, instead of
	to a scalar.

---
 .../libgomp.oacc-fortran/atomic_capture-1.f90  | 244 +++--
 1 file changed, 171 insertions(+), 73 deletions(-)

diff --git a/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90
index 5a7e1e5..5a4a1e0 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90
+++ b/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90
@@ -1,10 +1,12 @@
 ! { dg-do run }
 
 program main
+  integer, parameter :: N = 32
   integer igot, iexp, itmp
+  integer, dimension (0:N) :: iarr
   real fgot, fexp, ftmp
+  real, dimension (0:N) :: farr
   logical lgot, lexp, ltmp
-  integer, parameter :: N = 32
 
   igot = 0
   iexp = N * 2
@@ -27,13 +29,17 @@ program main
   !$acc parallel loop copy (fgot, ftmp)
 do i = 1, N
   !$acc atomic capture
-  ftmp = fgot
+  farr(i) = fgot
   fgot = fgot + 1.0
   !$acc end atomic
 end do
   !$acc end parallel loop
 
-  if (ftmp /= fexp - 1.0) STOP 3
+  do i = 1, N
+ if (.not. &
+  (1234.0 <= farr(i) .and. farr(i) < fexp &
+  .and. aint (farr(i)) == farr(i))) STOP 3
+  end do
   if (fgot /= fexp) STOP 4
 
   fgot = 1.0
@@ -42,13 +48,17 @@ program main
   !$acc parallel loop copy (fgot, ftmp)
 do i = 1, N
   !$acc atomic capture
-  ftmp = fgot
+  farr(i) = fgot
   fgot = fgot * 2.0
   !$acc end atomic
 end do
   !$acc end parallel loop
 
-  if (ftmp /= fexp / 2.0) STOP 5
+  do i = 1, N
+ if (.not. &
+  (1.0 <= farr(i) .and. farr(i) < fexp &
+  .and. aint (farr(i)) == farr(i))) STOP 5
+  end do
   if (fgot /= fexp) STOP 6
 
   fgot = 32.0
@@ -57,13 +67,17 @@ program main
   !$acc parallel loop copy (fgot, ftmp)
 do i = 1, N
   !$acc atomic capture
-  ftmp = fgot
+  farr(i) = fgot
   fgot = fgot - 1.0
   !$acc end atomic
 end do
   !$acc end parallel loop
 
-  if (ftmp /= fexp + 1.0) STOP 7
+  do i = 1, N
+ if (.not. &
+  (fexp < farr(i) .and. farr(i) <= 32.0 &
+  .and. aint (farr(i)) == farr(i))) STOP 7
+  end do
   if (fgot /= fexp) STOP 8
 
   fgot = 2**32.0
@@ -72,13 +86,17 @@ program main
   !$acc parallel loop copy (fgot, ftmp)
 do i = 1, N
   !$acc atomic capture
-  ftmp = fgot
+  farr(i) = fgot
   fgot = fgot / 2.0
   !$acc end atomic
 end do
   !$acc end parallel loop
 
-  if (ftmp /= fgot * 2.0) STOP 9
+  do i = 1, N
+ if (.not. &
+  (fexp < farr(i) .and. farr(i) <= 2**32.0 &
+  .and. aint (farr(i)) == farr(i))) STOP 9
+  end do
   if (fgot /= fexp) STOP 10
 
   lgot = .TRUE.
@@ -139,13 +157,17 @@ program main
   !$acc parallel loop copy (fgot, ftmp)
 do i = 1, N
   !$acc atomic capture
-  ftmp = fgot
+  farr(i) = fgot
   fgot = 1.0 + fgot
   !$acc end atomic
 end do
   !$acc end parallel loop
 
-  if (ftmp /= fexp - 1.0) STOP 19 
+  do i = 1, N
+ if (.not. &
+  (1234.0 <= farr(i) .and. farr(i) < fexp &
+  .and. aint (farr(i)) == farr(i))) STOP 19
+  end do
   if (fgot /= fexp) STOP 20
 
   fgot = 1.0
@@ -154,13 +176,17 @@ program main
   !$acc parallel loop copy (fgot, ftmp)
 do i = 1, N
   !$acc atomic capture
-  ftmp = fgot
+  farr(i) = fgot
   fgot = 2.0 * fgot
   !$acc end atomic
 end do
   !$acc end parallel loop
 
-  if (ftmp /= fexp / 2.0) STOP 21
+  do i = 1, N
+ if (.not. &
+  (1.0 <= farr(i) .and. farr(i) < fexp &
+  .and. aint (farr(i)) == farr(i))) STOP 21
+  end do
   if (fgot /= fexp) STOP 22
 
   fgot = 32.0
@@ -169,13 +195,15 @@ program main
   !$acc parallel loop copy (fgot, ftmp)
 do i = 1, N
   !$acc atomic capture
-  ftmp = fgot
+  farr(i) = fgot
   fgot = 2.0 - fgot
   !$acc end atomic
 end do
   !$acc end parallel loop
 
-  if (ftmp /= 2.0 - fexp) STOP 23
+  do i = 1, N
+ if (.not. (farr(i) == 

Re: [PATCHv2][PR 81376] Remove unnecessary float casts in comparisons

2018-04-27 Thread Jeff Law
On 02/19/2018 12:47 PM, Richard Sandiford wrote:
> Yuri Gribov  writes:
>> Hi all,
>>
>> This is a second iteration of patch which gets rid of float casts in
>> comparisons when all values of casted integral type are exactly
>> representable by the float type
>> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81376). The new version
>> addresses Richard's review
>> (https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00481.html).
>>
>> Bootstrapped and regtested on x64_64. Ok to commit?
>>
>> -Y
>>
>> From 1ea62f7bf4394142e0c473a69de8a0e9b1718a69 Mon Sep 17 00:00:00 2001
>> From: Yury Gribov 
>> Date: Fri, 29 Sep 2017 07:34:54 +0200
>> Subject: [PATCH] Add pattern to remove useless float casts in comparison.
>>
>> 2018-02-17  Yury Gribov  
>>
>>  PR middle-end/81376
>>
>> gcc/
>>  * real.c (format_helper::can_represent_integral_type_p): New function
>>  * real.h (format_helper::can_represent_integral_type_p): Ditto.
>>  * match.pd: New pattern.
>>
>> gcc/testsuite/
>>  * c-c++-common/pr81376.c: New test.
>> ---
>>  gcc/match.pd | 30 ---
>>  gcc/real.c   | 13 
>>  gcc/real.h   |  1 +
>>  gcc/testsuite/c-c++-common/pr81376.c | 39 
>> 
>>  4 files changed, 76 insertions(+), 7 deletions(-)
>>  create mode 100644 gcc/testsuite/c-c++-common/pr81376.c
>>
>> diff --git a/gcc/match.pd b/gcc/match.pd
>> index 4452b58..33a5f36 100644
>> --- a/gcc/match.pd
>> +++ b/gcc/match.pd
>> @@ -3252,6 +3252,27 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>>(if (! HONOR_NANS (@0))
>>  (cmp @0 @1))
>>  
>> +/* Optimize various special cases of (FTYPE) N CMP (FTYPE) M.  */
>> +(for cmp (tcc_comparison)
>> + (simplify
>> +  (cmp (float@0 @1) (float @2))
>> +   (if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (@0))
>> +&& ! DECIMAL_FLOAT_TYPE_P (TREE_TYPE (@0)))
>> +(with
>> + {
>> +   format_helper fmt (REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (@0;
>> +   tree type1 = TREE_TYPE (@1);
>> +   tree type2 = TREE_TYPE (@2);
>> + }
>> + (if (fmt.can_represent_integral_type_p (type1)
>> +  && fmt.can_represent_integral_type_p (type2))
>> +  (if (TYPE_PRECISION (type1) > TYPE_PRECISION (type2))
>> +   (cmp @1 (convert @2))
>> +   (if (TYPE_PRECISION (type1) < TYPE_PRECISION (type2))
>> +(cmp (convert:type2 @1) @2)
>> +(if (TYPE_SIGN (type1) == TYPE_SIGN (type2))
>> + (cmp @1 @2)
> 
> I think this would mishandle combinations in which the wider type
> is unsigned and the narrower type is signed, like @1:short @2:unsigned int.
I think you're right.  I suspect most of the cases where this is going
to apply in the real world will have @1 and @2 of the same type.  So
just rejecting those cases seems quite reasonable to me.  With that
fixed and a testcase for that situation this should be OK.

jeff



Re: ATTRIBUTE_NONSTRING

2018-04-27 Thread Hans-Peter Nilsson
On Fri, 27 Apr 2018, Alan Modra wrote:

> This patch adds ATTRIBUTE_NONSTRING, which will be used to curb
> -Wstringop-truncation warnings in binutils.  OK to apply?
>
>   * ansidecl.h (ATTRIBUTE_NONSTRING): Define.
>
> diff --git a/include/ansidecl.h b/include/ansidecl.h
> index c11daff..ec5f34d 100644
> --- a/include/ansidecl.h
> +++ b/include/ansidecl.h
> @@ -283,6 +283,15 @@ So instead we use the macro below and test it against 
> specific values.  */
>  # endif /* GNUC >= 4.9 */
>  #endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */
>
> +/* Attribute 'nonstring' was valid as of gcc 8.  */
> +#ifndef ATTRIBUTE_NONSTRING
> +# if GCC_VERSION >= 8000
> +#  define ATTRIBUTE_NONSTRING __attribute__ ((nonstring))

Uglify nonstring (as __nonstring__)?

brgds, H-P


RFA (clobbers, gimplification): PATCH for c++/61982, dead stores to destroyed objects

2018-04-27 Thread Jason Merrill
61982 notes that an explicit destructor call or delete expression ends
the lifetime of an object, but we weren't clobbering affected objects
if their destructors are trivial.  This patch fixes that.

The first commit just adds a helper function, build_clobber.

The second commit changes explicit destruction to clobber the affected
object.  As a result, I needed to change the gimplifier to handle the
more general forms of lvalue we might be clobbering, by introducing a
temporary.  I'm not sure why clobbers are so picky about the form of
lvalue they can use, but this makes it work.

Tested x86_64-pc-linux-gnu.  OK for trunk (9)?
commit f9da73d68a552474e75a1baa561f62dc7564f220
Author: Jason Merrill 
Date:   Wed Apr 25 16:52:02 2018 -0400

build-clobber

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 03bc041780f..07f3a61fed6 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -14874,8 +14874,7 @@ build_clobber_this ()
   if (!vbases)
 ctype = CLASSTYPE_AS_BASE (ctype);
 
-  tree clobber = build_constructor (ctype, NULL);
-  TREE_THIS_VOLATILE (clobber) = true;
+  tree clobber = build_clobber (ctype);
 
   tree thisref = current_class_ref;
   if (ctype != current_class_type)
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index c32869b4c59..b5b80ab7d98 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1379,9 +1379,8 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
 	  && !is_gimple_reg (t)
 	  && flag_stack_reuse != SR_NONE)
 	{
-	  tree clobber = build_constructor (TREE_TYPE (t), NULL);
+	  tree clobber = build_clobber (TREE_TYPE (t));
 	  gimple *clobber_stmt;
-	  TREE_THIS_VOLATILE (clobber) = 1;
 	  clobber_stmt = gimple_build_assign (t, clobber);
 	  gimple_set_location (clobber_stmt, end_locus);
 	  gimplify_seq_add_stmt (&cleanup, clobber_stmt);
@@ -6603,9 +6602,7 @@ gimplify_target_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 	{
 	  if (flag_stack_reuse == SR_ALL)
 	{
-	  tree clobber = build_constructor (TREE_TYPE (temp),
-		NULL);
-	  TREE_THIS_VOLATILE (clobber) = true;
+	  tree clobber = build_clobber (TREE_TYPE (temp));
 	  clobber = build2 (MODIFY_EXPR, TREE_TYPE (temp), temp, clobber);
 	  gimple_push_cleanup (temp, clobber, false, pre_p, true);
 	}
diff --git a/gcc/tree.c b/gcc/tree.c
index e93f24dd4d3..b661d3d0dcd 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -2059,6 +2059,16 @@ build_constructor_va (tree type, int nelts, ...)
   return build_constructor (type, v);
 }
 
+/* Return a node of type TYPE for which TREE_CLOBBER_P is true.  */
+
+tree
+build_clobber (tree type)
+{
+  tree clobber = build_constructor (type, NULL);
+  TREE_THIS_VOLATILE (clobber) = true;
+  return clobber;
+}
+
 /* Return a new FIXED_CST node whose type is TYPE and value is F.  */
 
 tree
diff --git a/gcc/tree.h b/gcc/tree.h
index 1e14d9f5866..74a0d1881a6 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4173,6 +4173,7 @@ extern tree build_constructor (tree, vec *);
 extern tree build_constructor_single (tree, tree, tree);
 extern tree build_constructor_from_list (tree, tree);
 extern tree build_constructor_va (tree, int, ...);
+extern tree build_clobber (tree);
 extern tree build_real_from_int_cst (tree, const_tree);
 extern tree build_complex (tree, tree, tree);
 extern tree build_complex_inf (tree, bool);

commit c34ac8c8066afb18c13ca44b47521a1a2d824e96
Author: Jason Merrill 
Date:   Fri Apr 27 13:14:30 2018 -0400

PR c++/61982 - dead stores to destroyed objects.

* call.c (build_trivial_dtor_call): New, assigns a clobber.
(build_over_call, build_special_member_call): Use it.
* cp-tree.h: Declare it.
* init.c (build_delete): Remove trivial path.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index fb6d71d260d..d3ee152808a 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7629,6 +7629,33 @@ conv_binds_ref_to_prvalue (conversion *c)
   return false;
 }
 
+/* Call the trivial destructor for INSTANCE, which can be either an lvalue of
+   class type or a pointer to class type.  */
+
+tree
+build_trivial_dtor_call (tree instance)
+{
+  gcc_assert (!is_dummy_object (instance));
+
+  if (!flag_lifetime_dse)
+{
+no_clobber:
+  return fold_convert (void_type_node, instance);
+}
+
+  if (POINTER_TYPE_P (TREE_TYPE (instance)))
+{
+  if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (instance
+	goto no_clobber;
+  instance = cp_build_fold_indirect_ref (instance);
+}
+
+  /* A trivial destructor should still clobber the object.  */
+  tree clobber = build_clobber (TREE_TYPE (instance));
+  return build2 (MODIFY_EXPR, void_type_node,
+		 instance, clobber);
+}
+
 /* Subroutine of the various build_*_call functions.  Overload resolution
has chosen a winning candidate CAND; build up a CALL_EXPR accordingly.
ARGS is a TREE_LIST of the unconverted arguments to the call.  FLAGS is a
@@ -8240,7 +8267,7 @@ build_over_call (struct z_candidate *cand, int

Re: [PATCH 5/5] [ARC] Clear the instruction cache using syscalls.

2018-04-27 Thread Andrew Burgess
* Claudiu Zissulescu  [2018-04-06 11:00:14 
+0200]:

> Clear the instruction cache from `beg' to `end'.  This makes an inline
> system call to SYS_cacheflush.
> 
> gcc/
> 2017-03-28  Claudiu Zissulescu  
> 
>   * config/arc/linux.h (CLEAR_INSN_CACHE): Define.


Looks good.

Thanks,
Andrew

> ---
>  gcc/config/arc/linux.h | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/gcc/config/arc/linux.h b/gcc/config/arc/linux.h
> index 4e87dfe..96d548e 100644
> --- a/gcc/config/arc/linux.h
> +++ b/gcc/config/arc/linux.h
> @@ -109,3 +109,17 @@ along with GCC; see the file COPYING3.  If not see
>  /* Build attribute: procedure call standard.  */
>  #undef ATTRIBUTE_PCS
>  #define ATTRIBUTE_PCS 3
> +
> +/* Clear the instruction cache from `beg' to `end'.  This makes an
> +   inline system call to SYS_cacheflush.  */
> +#undef CLEAR_INSN_CACHE
> +#define CLEAR_INSN_CACHE(beg, end)   \
> +{\
> +  register unsigned long _beg __asm ("r0") = (unsigned long) (beg);  \
> +  register unsigned long _end __asm ("r1") = (unsigned long) (end);  \
> +  register unsigned long _xtr __asm ("r2") = 0;  
> \
> +  register unsigned long _scno __asm ("r8") = 244;   \
> +  __asm __volatile ("trap_s 0; sys_cache_sync"   
> \
> + : "=r" (_beg)   \
> + : "0" (_beg), "r" (_end), "r" (_xtr), "r" (_scno)); \
> +}
> -- 
> 1.9.1
> 


Re: [PATCH 4/5] [ARC] Cleanup sdata handling.

2018-04-27 Thread Andrew Burgess
* Claudiu Zissulescu  [2018-04-06 11:00:13 
+0200]:

> From: Claudiu Zissulescu 
> 
> Clean up how we handle small data load/store operations. This patch clears 
> -flto-fat-lto-object LTO related errors.
> 
> gcc/
> 2018-01-18  Claudiu Zissulescu  
> 
>   * config/arc/arc-protos.h (prepare_extend_operands): Remove.
>   (small_data_pattern): Likewise.
>   (arc_rewrite_small_data): Likewise.
>   * config/arc/arc.c (LEGITIMATE_SMALL_DATA_OFFSET_P): Remove.
>   (LEGITIMATE_SMALL_DATA_ADDRESS_P): Likewise.
>   (get_symbol_alignment): New function.
>   (legitimate_small_data_address_p): Likewise.
>   (legitimate_scaled_address): Update, call
>   legitimate_small_data_address_p.
>   (output_sdata): New static variable.
>   (arc_print_operand): Update how we handle small data operands.
>   (arc_print_operand_address): Likewise.
>   (arc_legitimate_address_p): Update, use
>   legitimate_small_data_address_p.
>   (arc_rewrite_small_data_p): Remove.
>   (arc_rewrite_small_data_1): Likewise.
>   (arc_rewrite_small_data): Likewise.
>   (small_data_pattern): Likewise.
>   (compact_sda_memory_operand): Update to use
>   legitimate_small_data_address_p and get_symbol_alignment.
>   (prepare_move_operands): Don't rewite sdata pattern.
>   (prepare_extend_operands): Remove.
>   * config/arc/arc.md (zero_extendqihi2): Don't rewrite sdata
>   pattern.
>   (zero_extendqisi2): Likewise.
>   (zero_extendhisi2): Likewise.
>   (extendqihi2): Likewise.
>   (extendqisi2): Likewise.
>   (extendhisi2): Likewise.
>   (addsi3): Likewise.
>   (subsi3): Likewise.
>   (andsi3): Likewise.
>   * config/arc/constraints.md (Usd): Change it to memory constraint.
> 
> gcc/testsuite
> 2018-01-18  Claudiu Zissulescu  
> 
>   * gcc.target/arc/interrupt-8.c: Update test.
>   * gcc.target/arc/loop-4.c: Likewise.
>   * gcc.target/arc/loop-hazard-1.c: Likewise.
>   * gcc.target/arc/sdata-3.c: Likewise.

Looks like a good clean up.

Thanks,
Andrew

> ---
>  gcc/config/arc/arc-protos.h  |   4 -
>  gcc/config/arc/arc.c | 309 
> ---
>  gcc/config/arc/arc.md|  22 +-
>  gcc/config/arc/constraints.md|   6 +-
>  gcc/testsuite/gcc.target/arc/interrupt-8.c   |   5 +-
>  gcc/testsuite/gcc.target/arc/loop-4.c|   2 +-
>  gcc/testsuite/gcc.target/arc/loop-hazard-1.c |   2 +-
>  gcc/testsuite/gcc.target/arc/sdata-3.c   |   8 +-
>  8 files changed, 110 insertions(+), 248 deletions(-)
> 
> diff --git a/gcc/config/arc/arc-protos.h b/gcc/config/arc/arc-protos.h
> index 0ba6871..67f3b4e 100644
> --- a/gcc/config/arc/arc-protos.h
> +++ b/gcc/config/arc/arc-protos.h
> @@ -33,8 +33,6 @@ extern void arc_print_operand (FILE *, rtx, int);
>  extern void arc_print_operand_address (FILE *, rtx);
>  extern void arc_final_prescan_insn (rtx_insn *, rtx *, int);
>  extern const char *arc_output_libcall (const char *);
> -extern bool prepare_extend_operands (rtx *operands, enum rtx_code code,
> -  machine_mode omode);
>  extern int arc_output_addsi (rtx *operands, bool, bool);
>  extern int arc_output_commutative_cond_exec (rtx *operands, bool);
>  extern bool arc_expand_movmem (rtx *operands);
> @@ -65,8 +63,6 @@ extern bool arc_raw_symbolic_reference_mentioned_p (rtx, 
> bool);
>  extern bool arc_is_longcall_p (rtx);
>  extern bool arc_is_shortcall_p (rtx);
>  extern bool valid_brcc_with_delay_p (rtx *);
> -extern bool small_data_pattern (rtx , machine_mode);
> -extern rtx arc_rewrite_small_data (rtx);
>  extern bool arc_ccfsm_cond_exec_p (void);
>  struct secondary_reload_info;
>  extern int arc_register_move_cost (machine_mode, enum reg_class,
> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> index 2ccdce8..2ce1744 100644
> --- a/gcc/config/arc/arc.c
> +++ b/gcc/config/arc/arc.c
> @@ -96,22 +96,6 @@ HARD_REG_SET overrideregs;
> ? 0 \
> : -(-GET_MODE_SIZE (MODE) | -4) >> 1)))
>  
> -#define LEGITIMATE_SMALL_DATA_OFFSET_P(X)\
> -  (GET_CODE (X) == CONST \
> -   && GET_CODE (XEXP ((X), 0)) == PLUS   
> \
> -   && GET_CODE (XEXP (XEXP ((X), 0), 0)) == SYMBOL_REF   
> \
> -   && SYMBOL_REF_SMALL_P (XEXP (XEXP ((X), 0), 0))   \
> -   && GET_CODE (XEXP(XEXP ((X), 0), 1)) == CONST_INT \
> -   && INTVAL (XEXP (XEXP ((X), 0), 1)) <= g_switch_value)
> -
> -#define LEGITIMATE_SMALL_DATA_ADDRESS_P(X)   \
> -  (GET_CODE (X) == PLUS  
> \
> - && REG_P (XEXP ((X), 0))
> \
> - && REGNO (XEXP ((X), 0)) == SDATA_BASE_REGNUM   \
> - && ((GET_CODE (XEXP 

Re: [PATCH 3/5] [ARC] Update movhi and movdi patterns.

2018-04-27 Thread Andrew Burgess
* Claudiu Zissulescu  [2018-04-06 11:00:12 
+0200]:

> From: Claudiu Zissulescu 
> 
> Allow signed 6-bit short immediates into st[d] instructions.
> 
> 2017-10-19  Claudiu Zissulescu  
> 
>   * config/arc/arc.c (arc_split_move): Allow signed 6-bit constants
>   as source of std instructions.
>   * config/arc/arc.md (movsi_insn): Update pattern predicate to
>   allow 6-bit constants as source for store instructions.
>   (movdi_insn): Update instruction pattern to allow 6-bit constants
>   as source for store instructions.
> 
> testsuite/
> 2017-10-19  Claudiu Zissulescu  
> 
>   * gcc.target/arc/store-merge-1.c: New test.
>   * gcc.target/arc/add_n-combine.c: Update test.

Looks good thanks,

Andrew


> ---
>  gcc/config/arc/arc.c |  3 ++-
>  gcc/config/arc/arc.md| 25 +
>  gcc/testsuite/gcc.target/arc/add_n-combine.c |  2 +-
>  gcc/testsuite/gcc.target/arc/store-merge-1.c | 17 +
>  4 files changed, 33 insertions(+), 14 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/arc/store-merge-1.c
> 
> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> index 47d3ba4..2ccdce8 100644
> --- a/gcc/config/arc/arc.c
> +++ b/gcc/config/arc/arc.c
> @@ -9669,7 +9669,8 @@ arc_split_move (rtx *operands)
>  
>if (TARGET_LL64
>&& ((memory_operand (operands[0], mode)
> -&& even_register_operand (operands[1], mode))
> +&& (even_register_operand (operands[1], mode)
> +|| satisfies_constraint_Cm3 (operands[1])))
> || (memory_operand (operands[1], mode)
> && even_register_operand (operands[0], mode
>  {
> diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md
> index ffd9d5b..0fc7aba 100644
> --- a/gcc/config/arc/arc.md
> +++ b/gcc/config/arc/arc.md
> @@ -740,7 +740,9 @@ archs4x, archs4xd, archs4xd_slow"
> /* Don't use a LIMM that we could load with a single insn - we loose
> delay-slot filling opportunities.  */
> && !satisfies_constraint_I (operands[1])
> -   && satisfies_constraint_Usc (operands[0]))"
> +   && satisfies_constraint_Usc (operands[0]))
> +   || (satisfies_constraint_Cm3 (operands[1])
> +  && memory_operand (operands[0], SImode))"
>"@
> mov%? %0,%1%& ;0
> mov%? %0,%1%& ;1
> @@ -1237,10 +1239,12 @@ archs4x, archs4xd, archs4xd_slow"
>")
>  
>  (define_insn_and_split "*movdi_insn"
> -  [(set (match_operand:DI 0 "move_dest_operand"  "=w, w,r,m")
> - (match_operand:DI 1 "move_double_src_operand" "c,Hi,m,c"))]
> +  [(set (match_operand:DI 0 "move_dest_operand"  "=w, w,r,   m")
> + (match_operand:DI 1 "move_double_src_operand" "c,Hi,m,cCm3"))]
>"register_operand (operands[0], DImode)
> -   || register_operand (operands[1], DImode)"
> +   || register_operand (operands[1], DImode)
> +   || (satisfies_constraint_Cm3 (operands[1])
> +  && memory_operand (operands[0], DImode))"
>"*
>  {
>switch (which_alternative)
> @@ -1250,19 +1254,16 @@ archs4x, archs4xd, archs4xd_slow"
>  
>  case 2:
>  if (TARGET_LL64
> - && ((even_register_operand (operands[0], DImode)
> -  && memory_operand (operands[1], DImode))
> - || (memory_operand (operands[0], DImode)
> - && even_register_operand (operands[1], DImode
> +&& memory_operand (operands[1], DImode)
> + && even_register_operand (operands[0], DImode))
>return \"ldd%U1%V1 %0,%1%&\";
>  return \"#\";
>  
>  case 3:
>  if (TARGET_LL64
> - && ((even_register_operand (operands[0], DImode)
> -  && memory_operand (operands[1], DImode))
> - || (memory_operand (operands[0], DImode)
> - && even_register_operand (operands[1], DImode
> + && memory_operand (operands[0], DImode)
> + && (even_register_operand (operands[1], DImode)
> + || satisfies_constraint_Cm3 (operands[1])))
>   return \"std%U0%V0 %1,%0\";
>  return \"#\";
>  }
> diff --git a/gcc/testsuite/gcc.target/arc/add_n-combine.c 
> b/gcc/testsuite/gcc.target/arc/add_n-combine.c
> index db6454f..cd32ed3 100644
> --- a/gcc/testsuite/gcc.target/arc/add_n-combine.c
> +++ b/gcc/testsuite/gcc.target/arc/add_n-combine.c
> @@ -45,4 +45,4 @@ void f() {
>a(at3.bn[bu]);
>  }
>  
> -/* { dg-final { scan-rtl-dump-times "\\*add_n" 3 "combine" } } */
> +/* { dg-final { scan-rtl-dump-times "\\*add_n" 2 "combine" } } */
> diff --git a/gcc/testsuite/gcc.target/arc/store-merge-1.c 
> b/gcc/testsuite/gcc.target/arc/store-merge-1.c
> new file mode 100644
> index 000..4bb8dcb
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/arc/store-merge-1.c
> @@ -0,0 +1,17 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O3" } */
> +
> +/* This tests checks if we use st w6,[reg] format.  */
> +
> +typedef struct {
> +  unsigned long __val[2];
> +} sigset_t;
> +
> +int sigemptyset2 (sigset_t *set)
> +{
> +  set->__val[0] = 0;
> +  set->__v

Re: [wwwdocs]Mention -ftree-loop-distribution

2018-04-27 Thread Jeff Law
On 04/03/2018 09:51 AM, Bin Cheng wrote:
> Hi,
> 
> Option -ftree-loop-distribution is improved and enabled by default at -O3 for 
> GCC8.
> This patch describes the change, is it OK?
Yes.  This is fine.
jeff


Re: [C++ PATCH] Fix value initialized decltype(nullptr) in constexpr (PR c++/85553)

2018-04-27 Thread Paolo Carlini

On 27/04/2018 22:25, Paolo Carlini wrote:

Hi,

On 27/04/2018 22:13, Jason Merrill wrote:

Ok
Maybe for 8.2.0 or whatever, would it make sense to special case 
convert itself? See what we do in, say, decay_conversion, we aren't 
afraid to immediately return nullptr_node...
... or more generally ocp_convert which already handles explicitly 
NULLPTR_TYPE, I'm coming to the conclusion that something is wrong or 
missing in it.


Paolo.


Re: [C++ PATCH] Fix value initialized decltype(nullptr) in constexpr (PR c++/85553)

2018-04-27 Thread Paolo Carlini

Hi,

On 27/04/2018 22:13, Jason Merrill wrote:

Ok
Maybe for 8.2.0 or whatever, would it make sense to special case convert 
itself? See what we do in, say, decay_conversion, we aren't afraid to 
immediately return nullptr_node...


Paolo.


[committed] input.h: convert some macros to inline functions

2018-04-27 Thread David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

Committed to trunk as r259727.

gcc/ChangeLog:
* input.h (in_system_header_at): Convert from macro to inline
function.
(from_macro_expansion_at): Likewise.
(from_macro_definition_at): Likewise.
---
 gcc/input.h | 34 --
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/gcc/input.h b/gcc/input.h
index 38b45dc..da5451e 100644
--- a/gcc/input.h
+++ b/gcc/input.h
@@ -73,17 +73,31 @@ extern location_t input_location;
Note that this function returns 1 if LOCATION belongs to a token
that is part of a macro replacement-list defined in a system
header, but expanded in a non-system file.  */
-#define in_system_header_at(LOC) \
-  (linemap_location_in_system_header_p (line_table, LOC))
-/* Return a positive value if LOCATION is the locus of a token that
-   comes from a macro expansion, O otherwise.  */
-#define from_macro_expansion_at(LOC) \
-  ((linemap_location_from_macro_expansion_p (line_table, LOC)))
-/* Return a positive value if LOCATION is the locus of a token that comes from
-   a macro definition, O otherwise.  This differs from from_macro_expansion_at
+
+static inline int
+in_system_header_at (location_t loc)
+{
+  return linemap_location_in_system_header_p (line_table, loc);
+}
+
+/* Return true if LOCATION is the locus of a token that
+   comes from a macro expansion, false otherwise.  */
+
+static inline bool
+from_macro_expansion_at (location_t loc)
+{
+  return linemap_location_from_macro_expansion_p (line_table, loc);
+}
+
+/* Return true if LOCATION is the locus of a token that comes from
+   a macro definition, false otherwise.  This differs from 
from_macro_expansion_at
in its treatment of macro arguments, for which this returns false.  */
-#define from_macro_definition_at(LOC) \
-  ((linemap_location_from_macro_definition_p (line_table, LOC)))
+
+static inline bool
+from_macro_definition_at (location_t loc)
+{
+  return linemap_location_from_macro_definition_p (line_table, loc);
+}
 
 static inline location_t
 get_pure_location (location_t loc)
-- 
1.8.5.3



Re: [C++ PATCH] Fix value initialized decltype(nullptr) in constexpr (PR c++/85553)

2018-04-27 Thread Jason Merrill
Ok

On Fri, Apr 27, 2018, 2:07 PM Jakub Jelinek  wrote:

> Hi!
>
> init = fold (convert (type, nullptr_node)); unfortunately creates
> a NOP_EXPR around INTEGER_CST and constexpr.c doesn't consider that a valid
> constant; fold (convert (type, integer_zero_node)) we used previously
> on the other side emitted warnings.
>
> The following patch just builds the INTEGER_CST directly.
>
> Tested on x86_64-linux with make check-c++-all, ok for trunk and 8.1
> if it passes full bootstrap/regtest on {x86_64,i686}-linux?
>
> 2018-04-27  Jakub Jelinek  
>
> PR c++/85553
> * init.c (build_zero_init_1): For zero initialization of
> NULLPTR_TYPE_P type use build_int_cst directly.
>
> * g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C: Add dg-bogus
> directive.
> * g++.dg/cpp0x/constexpr-85553.C: New test.
>
> --- gcc/cp/init.c.jj2018-04-27 19:11:56.613549524 +0200
> +++ gcc/cp/init.c   2018-04-27 19:20:50.102839130 +0200
> @@ -180,8 +180,10 @@ build_zero_init_1 (tree type, tree nelts
> items with static storage duration that are not otherwise
> initialized are initialized to zero.  */
>  ;
> -  else if (TYPE_PTR_OR_PTRMEM_P (type) || NULLPTR_TYPE_P (type))
> +  else if (TYPE_PTR_OR_PTRMEM_P (type))
>  init = fold (convert (type, nullptr_node));
> +  else if (NULLPTR_TYPE_P (type))
> +init = build_int_cst (type, 0);
>else if (SCALAR_TYPE_P (type))
>  init = fold (convert (type, integer_zero_node));
>else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type)))
> --- gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C.jj
> 2018-04-12 10:22:56.640162364 +0200
> +++ gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C
>  2018-04-27 19:23:58.349941329 +0200
> @@ -3,4 +3,4 @@
>  // { dg-options "-Wzero-as-null-pointer-constant" }
>
>  int* no_warn = {};
> -decltype( nullptr ) warn = {};
> +decltype( nullptr ) warn = {}; // { dg-bogus "zero as null pointer
> constant" }
> --- gcc/testsuite/g++.dg/cpp0x/constexpr-85553.C.jj 2018-04-27
> 19:24:33.547960437 +0200
> +++ gcc/testsuite/g++.dg/cpp0x/constexpr-85553.C2018-04-27
> 19:24:51.456970160 +0200
> @@ -0,0 +1,4 @@
> +// PR c++/85553
> +// { dg-do compile { target c++11 } }
> +using T = decltype(nullptr);
> +const constexpr T foo{};
>
> Jakub
>


Re: [C++ PATCH] Fix value initialized decltype(nullptr) in constexpr (PR c++/85553)

2018-04-27 Thread Jakub Jelinek
On Fri, Apr 27, 2018 at 08:07:36PM +0200, Jakub Jelinek wrote:
> init = fold (convert (type, nullptr_node)); unfortunately creates
> a NOP_EXPR around INTEGER_CST and constexpr.c doesn't consider that a valid
> constant; fold (convert (type, integer_zero_node)) we used previously
> on the other side emitted warnings.
> 
> The following patch just builds the INTEGER_CST directly.
> 
> Tested on x86_64-linux with make check-c++-all, ok for trunk and 8.1
> if it passes full bootstrap/regtest on {x86_64,i686}-linux?

Now successfully bootstrapped/regtested on both.  Ok?

> 2018-04-27  Jakub Jelinek  
> 
>   PR c++/85553
>   * init.c (build_zero_init_1): For zero initialization of
>   NULLPTR_TYPE_P type use build_int_cst directly.
> 
>   * g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C: Add dg-bogus
>   directive.
>   * g++.dg/cpp0x/constexpr-85553.C: New test.

Jakub


Re: Remove tilegx port

2018-04-27 Thread Jeff Law
On 04/27/2018 11:42 AM, Richard Biener wrote:
> On April 27, 2018 7:26:19 PM GMT+02:00, Jeff Law  wrote:
>> On 04/27/2018 09:36 AM, Joseph Myers wrote:
>>> Since tile support has been removed from the Linux kernel for 4.17,
>>> this patch removes the (unmaintained) port to tilegx from glibc (the
>>> tilepro support having been previously removed).  This reflects the
>>> general principle that a glibc port needs upstream support for the
>>> architecture in all the components it build-depends on (so binutils,
>>> GCC and the Linux kernel, for the normal case of a port supporting
>> the
>>> Linux kernel but no other OS), in order to be maintainable.
>>>
>>> Apart from removal of sysdeps/tile and sysdeps/unix/sysv/linux/tile
>>> (omitted from the diffs below), there are updates to various comments
>>> referencing tile for which removal of those references seemed
>>> appropriate.  The configuration is removed from README and from
>>> build-many-glibcs.py.  contrib.texi keeps mention of removed
>>> contributions, but I updated Chris Metcalf's entry to reflect that he
>>> also contributed the non-removed support for the generic Linux kernel
>>> syscall interface.  __ASSUME_FADVISE64_64_NO_ALIGN support is
>> removed,
>>> as it was only used by tile.
>> Given tilegx/tilepro removal from the kernel and glibc, should we go
>> ahead and deprecate them in GCC?  The only tilegx/tilepro
>> configurations
>> are -linux.
> 
> Makes sense to me. Let's deprecate it for GCC 8 and remove from trunk. 
> 
> Richard. 
> 
>> Jeff
> 

Here's what I committed to the trunk and the release branch.  I'll
find/update the appropriate web page momentarily.

jeff
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4db67b8d069..f81b09f8739 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2018-04-27  Jeff Law  
+
+   * config.gcc: Mark tile* targets as deprecated/obsolete.
+
 2018-04-27  Richard Biener  
 
* config/aarch64/aarch64.c: Simplify ap.__stack advance and
diff --git a/gcc/config.gcc b/gcc/config.gcc
index e58494c1c17..a5defb0f005 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -237,6 +237,7 @@ md_file=
 # Obsolete configurations.
 case ${target} in
   powerpc*-*-*spe* \
+  | tile*-*-*  \
  )
 if test "x$enable_obsolete" != xyes; then
   echo "*** Configuration ${target} is obsolete." >&2


Re: [PATCH][arm][FreeBSD] PR libgcc/84292

2018-04-27 Thread Andreas Tobler

On 26.04.18 09:49, Richard Biener wrote:

On Wed, Apr 25, 2018 at 10:41 PM, Andreas Tobler
 wrote:

Hi all,

I'm going to commit this patch to all active branches as soon as the branch
status permits.
Built and tested on native armv5 FreeBSD12.


If you think it is safe then it's fine for gcc-8-branch now.


It is safe and it really only affects armv4/5 on FreeBSD.
But I'm not that fast and I do not manage it to commit to the branches 
within the next days.


Thanks,
Andreas


Thanks,
Andreas

2018-04-25  Andreas Tobler  
 Maryse Levavasseur 

 PR libgcc/84292
 * config/arm/freebsd-atomic.c (SYNC_OP_AND_FETCH_N): Fix the
 op_and_fetch to return the right result.






Re: libgo patch committed, RFA for GCC 8 release branch: Solaris assembler support

2018-04-27 Thread Ian Lance Taylor
On Fri, Apr 27, 2018 at 11:04 AM, Jakub Jelinek  wrote:
> On Fri, Apr 27, 2018 at 11:00:41AM -0700, Ian Lance Taylor wrote:
>> This libgo patch fixes the go tool to use Solaris assembler syntax for
>> the buildid file.  The Solaris assembler uses a different syntax for
>> section directives.  This is https://golang.org/cl/109140 ported over
>> to gccgo.  This fixes PR 85429.  Bootstrapped and ran Go tests on
>> x86_64-pc-linux-gnu and SPARC/Solaris 11 (there are other unrelated
>> failures on SPARC Solaris).  Committed to mainline.
>>
>> Release managers: OK for GCC 8 branch?
>
> Ok if you can commit very soon, would like to do rc2 shortly.

Thanks.  Committed to branch.


> BTW, could you please update gcc-8/changes.html for Go ?

Done.

Ian


[C++ PATCH] Fix value initialized decltype(nullptr) in constexpr (PR c++/85553)

2018-04-27 Thread Jakub Jelinek
Hi!

init = fold (convert (type, nullptr_node)); unfortunately creates
a NOP_EXPR around INTEGER_CST and constexpr.c doesn't consider that a valid
constant; fold (convert (type, integer_zero_node)) we used previously
on the other side emitted warnings.

The following patch just builds the INTEGER_CST directly.

Tested on x86_64-linux with make check-c++-all, ok for trunk and 8.1
if it passes full bootstrap/regtest on {x86_64,i686}-linux?

2018-04-27  Jakub Jelinek  

PR c++/85553
* init.c (build_zero_init_1): For zero initialization of
NULLPTR_TYPE_P type use build_int_cst directly.

* g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C: Add dg-bogus
directive.
* g++.dg/cpp0x/constexpr-85553.C: New test.

--- gcc/cp/init.c.jj2018-04-27 19:11:56.613549524 +0200
+++ gcc/cp/init.c   2018-04-27 19:20:50.102839130 +0200
@@ -180,8 +180,10 @@ build_zero_init_1 (tree type, tree nelts
items with static storage duration that are not otherwise
initialized are initialized to zero.  */
 ;
-  else if (TYPE_PTR_OR_PTRMEM_P (type) || NULLPTR_TYPE_P (type))
+  else if (TYPE_PTR_OR_PTRMEM_P (type))
 init = fold (convert (type, nullptr_node));
+  else if (NULLPTR_TYPE_P (type))
+init = build_int_cst (type, 0);
   else if (SCALAR_TYPE_P (type))
 init = fold (convert (type, integer_zero_node));
   else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type)))
--- gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C.jj
2018-04-12 10:22:56.640162364 +0200
+++ gcc/testsuite/g++.dg/cpp0x/Wzero-as-null-pointer-constant-3.C   
2018-04-27 19:23:58.349941329 +0200
@@ -3,4 +3,4 @@
 // { dg-options "-Wzero-as-null-pointer-constant" }
 
 int* no_warn = {};
-decltype( nullptr ) warn = {};
+decltype( nullptr ) warn = {}; // { dg-bogus "zero as null pointer constant" }
--- gcc/testsuite/g++.dg/cpp0x/constexpr-85553.C.jj 2018-04-27 
19:24:33.547960437 +0200
+++ gcc/testsuite/g++.dg/cpp0x/constexpr-85553.C2018-04-27 
19:24:51.456970160 +0200
@@ -0,0 +1,4 @@
+// PR c++/85553
+// { dg-do compile { target c++11 } }
+using T = decltype(nullptr);
+const constexpr T foo{};

Jakub


Re: libgo patch committed, RFA for GCC 8 release branch: Solaris assembler support

2018-04-27 Thread Jakub Jelinek
On Fri, Apr 27, 2018 at 11:00:41AM -0700, Ian Lance Taylor wrote:
> This libgo patch fixes the go tool to use Solaris assembler syntax for
> the buildid file.  The Solaris assembler uses a different syntax for
> section directives.  This is https://golang.org/cl/109140 ported over
> to gccgo.  This fixes PR 85429.  Bootstrapped and ran Go tests on
> x86_64-pc-linux-gnu and SPARC/Solaris 11 (there are other unrelated
> failures on SPARC Solaris).  Committed to mainline.
> 
> Release managers: OK for GCC 8 branch?

Ok if you can commit very soon, would like to do rc2 shortly.

BTW, could you please update gcc-8/changes.html for Go ?

> Index: gcc/go/gofrontend/MERGE
> ===
> --- gcc/go/gofrontend/MERGE   (revision 259531)
> +++ gcc/go/gofrontend/MERGE   (working copy)
> @@ -1,4 +1,4 @@
> -7b37b9c3f9338a1387ee1e2301de89c3d2d87d2b
> +32861fd0acb0f3232f66be4791388b27e71c9990
>  
>  The first line of this file holds the git revision number of the last
>  merge done from the gofrontend repository.
> Index: libgo/go/cmd/go/internal/work/buildid.go
> ===
> --- libgo/go/cmd/go/internal/work/buildid.go  (revision 259359)
> +++ libgo/go/cmd/go/internal/work/buildid.go  (working copy)
> @@ -309,7 +309,11 @@ func (b *Builder) gccgoBuildIDELFFile(a
>   sfile := a.Objdir + "_buildid.s"
>  
>   var buf bytes.Buffer
> - fmt.Fprintf(&buf, "\t"+`.section .go.buildid,"e"`+"\n")
> + if cfg.Goos != "solaris" {
> + fmt.Fprintf(&buf, "\t"+`.section .go.buildid,"e"`+"\n")
> + } else {
> + fmt.Fprintf(&buf, "\t"+`.section ".go.buildid",#exclude`+"\n")
> + }
>   fmt.Fprintf(&buf, "\t.byte ")
>   for i := 0; i < len(a.buildID); i++ {
>   if i > 0 {
> @@ -322,8 +326,10 @@ func (b *Builder) gccgoBuildIDELFFile(a
>   fmt.Fprintf(&buf, "%#02x", a.buildID[i])
>   }
>   fmt.Fprintf(&buf, "\n")
> - fmt.Fprintf(&buf, "\t"+`.section .note.GNU-stack,"",@progbits`+"\n")
> - fmt.Fprintf(&buf, "\t"+`.section 
> .note.GNU-split-stack,"",@progbits`+"\n")
> + if cfg.Goos != "solaris" {
> + fmt.Fprintf(&buf, "\t"+`.section 
> .note.GNU-stack,"",@progbits`+"\n")
> + fmt.Fprintf(&buf, "\t"+`.section 
> .note.GNU-split-stack,"",@progbits`+"\n")
> + }
>  
>   if cfg.BuildN || cfg.BuildX {
>   for _, line := range bytes.Split(buf.Bytes(), []byte("\n")) {


Jakub


libgo patch committed, RFA for GCC 8 release branch: Solaris assembler support

2018-04-27 Thread Ian Lance Taylor
This libgo patch fixes the go tool to use Solaris assembler syntax for
the buildid file.  The Solaris assembler uses a different syntax for
section directives.  This is https://golang.org/cl/109140 ported over
to gccgo.  This fixes PR 85429.  Bootstrapped and ran Go tests on
x86_64-pc-linux-gnu and SPARC/Solaris 11 (there are other unrelated
failures on SPARC Solaris).  Committed to mainline.

Release managers: OK for GCC 8 branch?

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 259531)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-7b37b9c3f9338a1387ee1e2301de89c3d2d87d2b
+32861fd0acb0f3232f66be4791388b27e71c9990
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/cmd/go/internal/work/buildid.go
===
--- libgo/go/cmd/go/internal/work/buildid.go(revision 259359)
+++ libgo/go/cmd/go/internal/work/buildid.go(working copy)
@@ -309,7 +309,11 @@ func (b *Builder) gccgoBuildIDELFFile(a
sfile := a.Objdir + "_buildid.s"
 
var buf bytes.Buffer
-   fmt.Fprintf(&buf, "\t"+`.section .go.buildid,"e"`+"\n")
+   if cfg.Goos != "solaris" {
+   fmt.Fprintf(&buf, "\t"+`.section .go.buildid,"e"`+"\n")
+   } else {
+   fmt.Fprintf(&buf, "\t"+`.section ".go.buildid",#exclude`+"\n")
+   }
fmt.Fprintf(&buf, "\t.byte ")
for i := 0; i < len(a.buildID); i++ {
if i > 0 {
@@ -322,8 +326,10 @@ func (b *Builder) gccgoBuildIDELFFile(a
fmt.Fprintf(&buf, "%#02x", a.buildID[i])
}
fmt.Fprintf(&buf, "\n")
-   fmt.Fprintf(&buf, "\t"+`.section .note.GNU-stack,"",@progbits`+"\n")
-   fmt.Fprintf(&buf, "\t"+`.section 
.note.GNU-split-stack,"",@progbits`+"\n")
+   if cfg.Goos != "solaris" {
+   fmt.Fprintf(&buf, "\t"+`.section 
.note.GNU-stack,"",@progbits`+"\n")
+   fmt.Fprintf(&buf, "\t"+`.section 
.note.GNU-split-stack,"",@progbits`+"\n")
+   }
 
if cfg.BuildN || cfg.BuildX {
for _, line := range bytes.Split(buf.Bytes(), []byte("\n")) {


Re: [PR 85549] Add mising check to aggregate IPA-CP propagation

2018-04-27 Thread Richard Biener
On April 27, 2018 5:36:27 PM GMT+02:00, Martin Jambor  wrote:
>Hi,
>
>On Fri, Apr 27 2018, Martin Jambor wrote:
>> Hi,
>>
>> this is a fix for another fallout from the fix for 84149
>
>sorry, I have mistakenly hit the send key.  Anyway, this is a fix for
>another fallout from the fix for 84149, in which I have relaxed
>conditions to propagate values along self recursive edges, but in the
>case of aggregate values I forgot to add a check that the pass-though
>jump function along the edge also preserves data passed by reference
>through that pointer.
>
>Fixed by adding the check, the pass has passed bootstrap and LTO
>bootstrap and checking on x86_64-linux.  OK for trunk and the gcc 8
>branch?

OK. 

Thanks, 
Richard. 

>Thanks,
>
>Martin
>
>
>
>2018-04-27  Martin Jambor  
>
>   PR ipa/85549
>   * ipa-cp.c (find_aggregate_values_for_callers_subset): Make sure
>   the jump function allows for passing through aggregate values.
>
>   testsuite/
>   * g++.dg/ipa/pr85549.C: New test.
>---
> gcc/ipa-cp.c   |  4 +++-
> gcc/testsuite/g++.dg/ipa/pr85549.C | 28 
> 2 files changed, 31 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/g++.dg/ipa/pr85549.C
>
>diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
>index 1b8f335fd32..4f28a55b862 100644
>--- a/gcc/ipa-cp.c
>+++ b/gcc/ipa-cp.c
>@@ -4372,7 +4372,9 @@ find_aggregate_values_for_callers_subset (struct
>cgraph_node *node,
>   {
> struct ipa_jump_func *jfunc
>   = ipa_get_ith_jump_func (IPA_EDGE_REF (cs), i);
>-if (self_recursive_pass_through_p (cs, jfunc, i))
>+if (self_recursive_pass_through_p (cs, jfunc, i)
>+&& (!plats->aggs_by_ref
>+|| ipa_get_jf_pass_through_agg_preserved (jfunc)))
>   continue;
> inter = intersect_aggregates_with_edge (cs, i, inter);
> 
>diff --git a/gcc/testsuite/g++.dg/ipa/pr85549.C
>b/gcc/testsuite/g++.dg/ipa/pr85549.C
>new file mode 100644
>index 000..ae0336e16b7
>--- /dev/null
>+++ b/gcc/testsuite/g++.dg/ipa/pr85549.C
>@@ -0,0 +1,28 @@
>+/* { dg-do run } */
>+/* { dg-options "-O2" } */
>+
>+#include 
>+
>+#define N 10
>+
>+static void visit(int &level, int n, int k, std::vector< int > &value)
>{
>+  level = level + 1;
>+  value[k] = level;
>+  for (int i = 0 ; i < n; i++)
>+if (value[i] == 0)
>+  visit(level, n, i, value);
>+}
>+void permutations()
>+{
>+  std::vector< int > value(N);
>+  int level = -1;
>+  visit(level, N, 0, value);
>+}
>+void testExtendByBox() {
>+  permutations();
>+}
>+
>+int main() {
>+  testExtendByBox();
>+  return 0;
>+}



Re: Remove tilegx port

2018-04-27 Thread Richard Biener
On April 27, 2018 7:26:19 PM GMT+02:00, Jeff Law  wrote:
>On 04/27/2018 09:36 AM, Joseph Myers wrote:
>> Since tile support has been removed from the Linux kernel for 4.17,
>> this patch removes the (unmaintained) port to tilegx from glibc (the
>> tilepro support having been previously removed).  This reflects the
>> general principle that a glibc port needs upstream support for the
>> architecture in all the components it build-depends on (so binutils,
>> GCC and the Linux kernel, for the normal case of a port supporting
>the
>> Linux kernel but no other OS), in order to be maintainable.
>> 
>> Apart from removal of sysdeps/tile and sysdeps/unix/sysv/linux/tile
>> (omitted from the diffs below), there are updates to various comments
>> referencing tile for which removal of those references seemed
>> appropriate.  The configuration is removed from README and from
>> build-many-glibcs.py.  contrib.texi keeps mention of removed
>> contributions, but I updated Chris Metcalf's entry to reflect that he
>> also contributed the non-removed support for the generic Linux kernel
>> syscall interface.  __ASSUME_FADVISE64_64_NO_ALIGN support is
>removed,
>> as it was only used by tile.
>Given tilegx/tilepro removal from the kernel and glibc, should we go
>ahead and deprecate them in GCC?  The only tilegx/tilepro
>configurations
>are -linux.

Makes sense to me. Let's deprecate it for GCC 8 and remove from trunk. 

Richard. 

>Jeff



Re: Remove tilegx port

2018-04-27 Thread Jeff Law
On 04/27/2018 09:36 AM, Joseph Myers wrote:
> Since tile support has been removed from the Linux kernel for 4.17,
> this patch removes the (unmaintained) port to tilegx from glibc (the
> tilepro support having been previously removed).  This reflects the
> general principle that a glibc port needs upstream support for the
> architecture in all the components it build-depends on (so binutils,
> GCC and the Linux kernel, for the normal case of a port supporting the
> Linux kernel but no other OS), in order to be maintainable.
> 
> Apart from removal of sysdeps/tile and sysdeps/unix/sysv/linux/tile
> (omitted from the diffs below), there are updates to various comments
> referencing tile for which removal of those references seemed
> appropriate.  The configuration is removed from README and from
> build-many-glibcs.py.  contrib.texi keeps mention of removed
> contributions, but I updated Chris Metcalf's entry to reflect that he
> also contributed the non-removed support for the generic Linux kernel
> syscall interface.  __ASSUME_FADVISE64_64_NO_ALIGN support is removed,
> as it was only used by tile.
Given tilegx/tilepro removal from the kernel and glibc, should we go
ahead and deprecate them in GCC?  The only tilegx/tilepro configurations
are -linux.

Jeff



Re: C++ PATCH for c++/85545, ICE with noexcept static_cast

2018-04-27 Thread Jason Merrill
On Fri, Apr 27, 2018 at 11:00 AM, Jason Merrill  wrote:
> With Nathan's patch for 85437, constexpr evaluation now breaks open a
> PTRMEM_CST that has a non-qualification conversion.  Then actually
> performing the conversion means messing with the contents of the
> CONSTRUCTOR.

And some follow-on tweaks, for trunk only:
commit 92b7fa5697724db5fda39457a69d644a7f7b45f7
Author: Jason Merrill 
Date:   Fri Apr 27 12:49:50 2018 -0400

* cvt.c (cp_fold_convert): Use convert_ptrmem.

* typeck.c (convert_ptrmem): Add a NOP even if no adjustment.

diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 0f045e2ab12..d9e3cb520c3 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -601,16 +601,20 @@ cp_fold_convert (tree type, tree expr)
   tree conv;
   if (TREE_TYPE (expr) == type)
 conv = expr;
-  else if (TREE_CODE (expr) == PTRMEM_CST)
+  else if (TREE_CODE (expr) == PTRMEM_CST
+	   && same_type_p (TYPE_PTRMEM_CLASS_TYPE (type),
+			   PTRMEM_CST_CLASS (expr)))
 {
   /* Avoid wrapping a PTRMEM_CST in NOP_EXPR.  */
   conv = copy_node (expr);
   TREE_TYPE (conv) = type;
 }
-  else if (TREE_CODE (expr) == CONSTRUCTOR
-	   && TYPE_PTRMEMFUNC_P (type))
-conv = build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr,
-			 true, false, tf_warning_or_error);
+  else if (TYPE_PTRMEM_P (type))
+{
+  conv = convert_ptrmem (type, expr, true, false,
+			 tf_warning_or_error);
+  conv = cp_fully_fold (conv);
+}
   else
 {
   conv = fold_convert (type, expr);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 19db3154e81..05ae00ed6df 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6844,15 +6844,16 @@ convert_ptrmem (tree type, tree expr, bool allow_inverse_p,
 
   if (TYPE_PTRDATAMEM_P (type))
 {
+  tree obase = TYPE_PTRMEM_CLASS_TYPE (TREE_TYPE (expr));
+  tree nbase = TYPE_PTRMEM_CLASS_TYPE (type);
   tree delta = (get_delta_difference
-		(TYPE_PTRMEM_CLASS_TYPE (TREE_TYPE (expr)),
-		 TYPE_PTRMEM_CLASS_TYPE (type),
+		(obase, nbase,
 		 allow_inverse_p, c_cast_p, complain));
 
   if (delta == error_mark_node)
 	return error_mark_node;
 
-  if (!integer_zerop (delta))
+  if (!same_type_p (obase, nbase))
 	{
 	  if (TREE_CODE (expr) == PTRMEM_CST)
 	expr = cplus_expand_constant (expr);


Re: [C++ Patch] PR 84691 ("[6/7/8/9 Regression] internal compiler error: in poplevel_class...")

2018-04-27 Thread Jason Merrill
OK.

On Fri, Apr 27, 2018 at 5:33 AM, Paolo Carlini  wrote:
> Hi,
>
> this small error-recovery issue remained in my todo list of 8 regressions:
> just clear the friendp flag in this case too - like we do a few lines above
> for virtual declarations - and avoid problems later. Tested x86_64-linux.
>
> Thanks, Paolo.
>
> 
>


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

2018-04-27 Thread Jason Merrill
On Thu, Apr 26, 2018 at 8:09 PM, David Malcolm  wrote:
> On Thu, 2018-04-26 at 15:53 -0400, Jason Merrill wrote:
>> On Thu, Apr 26, 2018 at 3:45 AM, Richard Biener
>>  wrote:
>> > On Wed, Apr 25, 2018 at 7:10 PM, Nathan Sidwell 
>> > wrote:
>> > > On 04/25/2018 11:41 AM, David Malcolm wrote:
>> > > >
>> > > > Jason Turner's video C++ Weekly - Ep 112 - GCC's Leaky
>> > > > Abstractions shows
>> > > > two issues where g++ offers suggestions about implementation
>> > > > details:
>> > >
>> > >
>> > > > For the lambda capture case, there are multiple members:
>> > > >
>> > > > $9 = 
>> > >
>> > >
>> > > These names have a space at the end, so the user cannot name
>> > > them.  We could
>> > > move the space to the beginning, if that helps?
>> >
>> > I think compiler-generated entities that are not supposed to be
>> > user-visible should be DECL_ARTIFICIAL.
>>
>> Agreed, add_capture should set that flag on the FIELD_DECLs.
>
> I had tried flagging the lambda-captured vars as DECL_ARTIFICIAL,
> but it lead to a "too many initializers" error from reshape_init,
> so (before I saw your email), I tried the following approach: rather
> than looking at underscores, it uses is_lambda_ignored_entity (similar
> to qualify_lookup without LOOKUP_HIDDEN).
>
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
>
> Do you want me to do the DECL_ARTIFICAL approach, or is this OK?

This is OK.


Re: [PR 85549] Add mising check to aggregate IPA-CP propagation

2018-04-27 Thread Martin Jambor
Hi,

On Fri, Apr 27 2018, Martin Jambor wrote:
> Hi,
>
> this is a fix for another fallout from the fix for 84149

sorry, I have mistakenly hit the send key.  Anyway, this is a fix for
another fallout from the fix for 84149, in which I have relaxed
conditions to propagate values along self recursive edges, but in the
case of aggregate values I forgot to add a check that the pass-though
jump function along the edge also preserves data passed by reference
through that pointer.

Fixed by adding the check, the pass has passed bootstrap and LTO
bootstrap and checking on x86_64-linux.  OK for trunk and the gcc 8
branch?

Thanks,

Martin



2018-04-27  Martin Jambor  

PR ipa/85549
* ipa-cp.c (find_aggregate_values_for_callers_subset): Make sure
the jump function allows for passing through aggregate values.

testsuite/
* g++.dg/ipa/pr85549.C: New test.
---
 gcc/ipa-cp.c   |  4 +++-
 gcc/testsuite/g++.dg/ipa/pr85549.C | 28 
 2 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr85549.C

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 1b8f335fd32..4f28a55b862 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -4372,7 +4372,9 @@ find_aggregate_values_for_callers_subset (struct 
cgraph_node *node,
{
  struct ipa_jump_func *jfunc
= ipa_get_ith_jump_func (IPA_EDGE_REF (cs), i);
- if (self_recursive_pass_through_p (cs, jfunc, i))
+ if (self_recursive_pass_through_p (cs, jfunc, i)
+ && (!plats->aggs_by_ref
+ || ipa_get_jf_pass_through_agg_preserved (jfunc)))
continue;
  inter = intersect_aggregates_with_edge (cs, i, inter);
 
diff --git a/gcc/testsuite/g++.dg/ipa/pr85549.C 
b/gcc/testsuite/g++.dg/ipa/pr85549.C
new file mode 100644
index 000..ae0336e16b7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr85549.C
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include 
+
+#define N 10
+
+static void visit(int &level, int n, int k, std::vector< int > &value) {
+  level = level + 1;
+  value[k] = level;
+  for (int i = 0 ; i < n; i++)
+if (value[i] == 0)
+  visit(level, n, i, value);
+}
+void permutations()
+{
+  std::vector< int > value(N);
+  int level = -1;
+  visit(level, N, 0, value);
+}
+void testExtendByBox() {
+  permutations();
+}
+
+int main() {
+  testExtendByBox();
+  return 0;
+}
-- 
2.16.3


[PR 85549] Add mising check to aggregate IPA-CP propagation

2018-04-27 Thread Martin Jambor
Hi,

this is a fix for another fallout from the fix for 84149


2018-04-27  Martin Jambor  

PR ipa/85549
* ipa-cp.c (find_aggregate_values_for_callers_subset): Make sure
the jump function allows for passing through aggregate values.

testsuite/
* g++.dg/ipa/pr85549.C: New test.
---
 gcc/ipa-cp.c   |  4 +++-
 gcc/testsuite/g++.dg/ipa/pr85549.C | 28 
 2 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr85549.C

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 1b8f335fd32..4f28a55b862 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -4372,7 +4372,9 @@ find_aggregate_values_for_callers_subset (struct 
cgraph_node *node,
{
  struct ipa_jump_func *jfunc
= ipa_get_ith_jump_func (IPA_EDGE_REF (cs), i);
- if (self_recursive_pass_through_p (cs, jfunc, i))
+ if (self_recursive_pass_through_p (cs, jfunc, i)
+ && (!plats->aggs_by_ref
+ || ipa_get_jf_pass_through_agg_preserved (jfunc)))
continue;
  inter = intersect_aggregates_with_edge (cs, i, inter);
 
diff --git a/gcc/testsuite/g++.dg/ipa/pr85549.C 
b/gcc/testsuite/g++.dg/ipa/pr85549.C
new file mode 100644
index 000..ae0336e16b7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr85549.C
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include 
+
+#define N 10
+
+static void visit(int &level, int n, int k, std::vector< int > &value) {
+  level = level + 1;
+  value[k] = level;
+  for (int i = 0 ; i < n; i++)
+if (value[i] == 0)
+  visit(level, n, i, value);
+}
+void permutations()
+{
+  std::vector< int > value(N);
+  int level = -1;
+  visit(level, N, 0, value);
+}
+void testExtendByBox() {
+  permutations();
+}
+
+int main() {
+  testExtendByBox();
+  return 0;
+}
-- 
2.16.3



C++ PATCH for c++/85545, ICE with noexcept static_cast

2018-04-27 Thread Jason Merrill
With Nathan's patch for 85437, constexpr evaluation now breaks open a
PTRMEM_CST that has a non-qualification conversion.  Then actually
performing the conversion means messing with the contents of the
CONSTRUCTOR.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 487666e08d885b64235a72c4e9a941acc2cd1512
Author: Jason Merrill 
Date:   Fri Apr 27 07:45:02 2018 -0400

PR c++/85545 - ICE with noexcept PMF conversion.

* cvt.c (cp_fold_convert): Pass PMF CONSTRUCTORs to
build_ptrmemfunc.
* typeck.c (build_ptrmemfunc): Don't build a NOP_EXPR for zero
adjustment.
(build_ptrmemfunc_access_expr): Special-case CONSTRUCTORs.

diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index a3735a1cffe..0f045e2ab12 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -601,14 +601,16 @@ cp_fold_convert (tree type, tree expr)
   tree conv;
   if (TREE_TYPE (expr) == type)
 conv = expr;
-  else if (TREE_CODE (expr) == PTRMEM_CST
-	   || (TREE_CODE (expr) == CONSTRUCTOR
-	   && TYPE_PTRMEMFUNC_P (type)))
+  else if (TREE_CODE (expr) == PTRMEM_CST)
 {
   /* Avoid wrapping a PTRMEM_CST in NOP_EXPR.  */
   conv = copy_node (expr);
   TREE_TYPE (conv) = type;
 }
+  else if (TREE_CODE (expr) == CONSTRUCTOR
+	   && TYPE_PTRMEMFUNC_P (type))
+conv = build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr,
+			 true, false, tf_warning_or_error);
   else
 {
   conv = fold_convert (type, expr);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 907d31d9786..d881a95322c 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3042,6 +3042,17 @@ build_ptrmemfunc_access_expr (tree ptrmem, tree member_name)
   tree ptrmem_type;
   tree member;
 
+  if (TREE_CODE (ptrmem) == CONSTRUCTOR)
+{
+  unsigned int ix;
+  tree index, value;
+  FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ptrmem),
+ix, index, value)
+	if (index && DECL_P (index) && DECL_NAME (index) == member_name)
+	  return value;
+  gcc_unreachable ();
+}
+
   /* This code is a stripped down version of
  build_class_member_access_expr.  It does not work to use that
  routine directly because it expects the object to be of class
@@ -8517,7 +8528,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p,
 	{
 	  if (same_type_p (to_type, pfn_type))
 	return pfn;
-	  else if (integer_zerop (n))
+	  else if (integer_zerop (n) && TREE_CODE (pfn) != CONSTRUCTOR)
 	return build_reinterpret_cast (to_type, pfn, 
complain);
 	}
@@ -8537,12 +8548,15 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p,
   /* Just adjust the DELTA field.  */
   gcc_assert  (same_type_ignoring_top_level_qualifiers_p
 		   (TREE_TYPE (delta), ptrdiff_type_node));
-  if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta)
-	n = cp_build_binary_op (input_location,
-LSHIFT_EXPR, n, integer_one_node,
-complain);
-  delta = cp_build_binary_op (input_location,
-  PLUS_EXPR, delta, n, complain);
+  if (!integer_zerop (n))
+	{
+	  if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta)
+	n = cp_build_binary_op (input_location,
+LSHIFT_EXPR, n, integer_one_node,
+complain);
+	  delta = cp_build_binary_op (input_location,
+  PLUS_EXPR, delta, n, complain);
+	}
   return build_ptrmemfunc1 (to_type, delta, npfn);
 }
 


Re: [PATCH] Fix aarch64 ILP32 ICE with vaarg gimplified code

2018-04-27 Thread Kyrill Tkachov


On 27/04/18 15:25, James Greenhalgh wrote:

On Fri, Apr 27, 2018 at 10:02:11AM +0100, Richard Biener wrote:
> On Fri, 27 Apr 2018, Kyrill Tkachov wrote:
>
> >
> > On 26/04/18 15:04, Christophe Lyon wrote:
> > > On 26 April 2018 at 15:41, Richard Biener  wrote:
> > > > On Thu, 26 Apr 2018, Christophe Lyon wrote:
> > > >
> > > >> On 26 April 2018 at 14:09, Richard Biener  wrote:
> > > >> >
> > > >> > Seen by  Christophe Lyon, verified with a cross that this fixes the
> > > >> > issue.
> > > >> >
> > > >> > aarch64 people, can you please test & commit this?
> > > >> >
> > > >>
> > > >> As I have just written in bugzilla, this patch avoids an ICE when
> > > >> compiling newlib's sysopen.i,
> > > >> but I still see a similar crash when compiling vfprintf.i.
> > > >
> > > > There's a similar case still left. Complete patch:
> > > >
> > > With this version, the toolchain build completes, but I didn't run
> > > make check, nor tried aarch64-linux-gnu.
> > >
> >
> > A bootstrap and test on aarch64-none-linux-gnu shows no problems.
> > I don't know if there was a rationale for having the conversion to
> > intDI_type_node.
>
> If that is somehow a required detail for SImode pointers then
> there needs to be a conversion from the pointer to uintSI_type_node
> before then extending to intDI_type_node.  uintSI to match the
> setting of POINTERS_EXTEND_UNSIGNED for aarch64.

Looks OK to me. Thanks for the patch and explanation. Kyrill, if you
have it in tree you can commit it if that's what is wanted.



I've committed the patch with r259711.
Thanks,
Kyrill


Thanks,
James





Re: [PATCH] Fix aarch64 ILP32 ICE with vaarg gimplified code

2018-04-27 Thread James Greenhalgh
On Fri, Apr 27, 2018 at 10:02:11AM +0100, Richard Biener wrote:
> On Fri, 27 Apr 2018, Kyrill Tkachov wrote:
> 
> > 
> > On 26/04/18 15:04, Christophe Lyon wrote:
> > > On 26 April 2018 at 15:41, Richard Biener  wrote:
> > > > On Thu, 26 Apr 2018, Christophe Lyon wrote:
> > > >
> > > >> On 26 April 2018 at 14:09, Richard Biener  wrote:
> > > >> >
> > > >> > Seen by  Christophe Lyon, verified with a cross that this fixes the
> > > >> > issue.
> > > >> >
> > > >> > aarch64 people, can you please test & commit this?
> > > >> >
> > > >>
> > > >> As I have just written in bugzilla, this patch avoids an ICE when
> > > >> compiling newlib's sysopen.i,
> > > >> but I still see a similar crash when compiling vfprintf.i.
> > > >
> > > > There's a similar case still left.  Complete patch:
> > > >
> > > With this version, the toolchain build completes, but I didn't run
> > > make check, nor tried aarch64-linux-gnu.
> > > 
> > 
> > A bootstrap and test on aarch64-none-linux-gnu shows no problems.
> > I don't know if there was a rationale for having the conversion to
> > intDI_type_node.
> 
> If that is somehow a required detail for SImode pointers then
> there needs to be a conversion from the pointer to uintSI_type_node
> before then extending to intDI_type_node.  uintSI to match the
> setting of POINTERS_EXTEND_UNSIGNED for aarch64.

Looks OK to me. Thanks for the patch and explanation. Kyrill, if you
have it in tree you can commit it if that's what is wanted.

Thanks,
James



[C++ PATCH] cleanup 2

2018-04-27 Thread Nathan Sidwell
When working on the recent ptrmem static_cast bug, I noticed 
convert_ptrmem could do with a bit of modernization.


Thusly moved its local var decls to their assignments.

nathan
--
Nathan Sidwell
2018-04-27  Nathan Sidwell  

	* typeck.c (convert_ptrmem): Move local var decls to initialization.

Index: typeck.c
===
--- typeck.c	(revision 259709)
+++ typeck.c	(working copy)
@@ -6833,34 +6833,28 @@ convert_ptrmem (tree type, tree expr, bo
 
   if (TYPE_PTRDATAMEM_P (type))
 {
-  tree delta;
+  tree delta = (get_delta_difference
+		(TYPE_PTRMEM_CLASS_TYPE (TREE_TYPE (expr)),
+		 TYPE_PTRMEM_CLASS_TYPE (type),
+		 allow_inverse_p, c_cast_p, complain));
 
-  delta = get_delta_difference (TYPE_PTRMEM_CLASS_TYPE (TREE_TYPE (expr)),
-TYPE_PTRMEM_CLASS_TYPE (type),
-allow_inverse_p,
-c_cast_p, complain);
   if (delta == error_mark_node)
 	return error_mark_node;
 
   if (!integer_zerop (delta))
 	{
-	  tree cond, op1, op2;
-
 	  if (TREE_CODE (expr) == PTRMEM_CST)
 	expr = cplus_expand_constant (expr);
-	  cond = cp_build_binary_op (input_location,
- EQ_EXPR,
- expr,
- build_int_cst (TREE_TYPE (expr), -1),
- complain);
-	  op1 = build_nop (ptrdiff_type_node, expr);
-	  op2 = cp_build_binary_op (input_location,
-PLUS_EXPR, op1, delta,
-complain);
+
+	  tree cond = cp_build_binary_op (input_location, EQ_EXPR, expr,
+	  build_int_cst (TREE_TYPE (expr), -1),
+	  complain);
+	  tree op1 = build_nop (ptrdiff_type_node, expr);
+	  tree op2 = cp_build_binary_op (input_location, PLUS_EXPR, op1, delta,
+	 complain);
 
 	  expr = fold_build3_loc (input_location,
-			  COND_EXPR, ptrdiff_type_node, cond, op1, op2);
-			 
+  COND_EXPR, ptrdiff_type_node, cond, op1, op2);
 	}
 
   return build_nop (type, expr);


Re: [patch] allow '-' for stdout dump

2018-04-27 Thread Nathan Sidwell

On 04/26/2018 01:31 PM, Sandra Loosemore wrote:

Hmmm, I'm not crazy about putting this material in the middle of a discussion 
about how the compiler comes up with its default dump file names.  How about 
splitting the existing paragraph into 3:


Yeah, that documentation is rather a mess.  I tried rationalizing the developer 
options into different subsections, but that quickly turned into a rat hole. 
Here I've just pulled out the filename creation to an earlier paragraph.


WDYT?

nathan
--
Nathan Sidwell
2018-04-27  Nathan Sidwell  

	* dumpfile.c (dump_open): Allow '-' for stdout.
	* doc/invoke.texi (Developer Options): Document dump filename
	determination early.  Document stdin/stdout selection.

Index: invoke.texi
===
--- invoke.texi	(revision 259683)
+++ invoke.texi	(working copy)
@@ -13357,6 +13357,25 @@ configuration, such as where it searches
 rarely need to use any of these options for ordinary compilation and
 linking tasks.
 
+Many developer options control dump output, and may take an optional
+@option{=@var{filename}} suffix.  If that is omitted, a default
+filename is determined by appending a pass number & phase letter,
+followed by the pass name to a @var{dumpname}.  The files are created
+in the directory of the output file.  The @var{dumpname} is the name
+of the output file, if explicitly specified and not an executable,
+otherwise it is the source file name.  The pass number is determined
+when a particular pass is registered with the compiler's pass manager.
+Usually passes executed in the order of registration, so this number
+corresponds to the pass execution order.  However, passes registered
+by plugins, passes specific to compilation targets, or passes that are
+otherwise registered after all the other passes are numbered higher
+than a pass named "final", even if they are executed earlier.  The
+phase letter is `i', `l', `r' or `t'.
+
+The default can be overridden by appending a @option{=@var{filename}}
+suffix to the option.  You can specify @code{stdout} or @code{-} to
+refer to standard output, and @code{stderr} for standard error.
+
 @table @gcctabopt
 
 @item -d@var{letters}
@@ -13366,20 +13385,7 @@ linking tasks.
 @opindex fdump-rtl-@var{pass}
 Says to make debugging dumps during compilation at times specified by
 @var{letters}.  This is used for debugging the RTL-based passes of the
-compiler.  The file names for most of the dumps are made by appending
-a pass number and a word to the @var{dumpname}, and the files are
-created in the directory of the output file.  In case of
-@option{=@var{filename}} option, the dump is output on the given file
-instead of the pass numbered dump files.  Note that the pass number is
-assigned as passes are registered into the pass manager.  Most passes
-are registered in the order that they will execute and for these passes
-the number corresponds to the pass execution order.  However, passes
-registered by plugins, passes specific to compilation targets, or
-passes that are otherwise registered after all the other passes are
-numbered higher than a pass named "final", even if they are executed
-earlier.  @var{dumpname} is generated from the name of the output
-file if explicitly specified and not an executable, otherwise it is
-the basename of the source file.  
+compiler.
 
 Some @option{-d@var{letters}} switches have different meaning when
 @option{-E} is used for preprocessing.  @xref{Preprocessor Options},
@@ -13767,15 +13773,11 @@ counters for each function compiled.
 @opindex fdump-tree-all
 @opindex fdump-tree
 Control the dumping at various stages of processing the intermediate
-language tree to a file.  The file name is generated by appending a
-switch-specific suffix to the source file name, and the file is
-created in the same directory as the output file. In case of
-@option{=@var{filename}} option, the dump is output on the given file
-instead of the auto named dump files.  If the @samp{-@var{options}}
-form is used, @var{options} is a list of @samp{-} separated options
-which control the details of the dump.  Not all options are applicable
-to all dumps; those that are not meaningful are ignored.  The
-following options are available
+language tree to a file.  If the @samp{-@var{options}} form is used,
+@var{options} is a list of @samp{-} separated options which control
+the details of the dump.  Not all options are applicable to all dumps;
+those that are not meaningful are ignored.  The following options are
+available
 
 @table @samp
 @item address
@@ -13838,26 +13840,9 @@ passes).
 @item note
 Enable other detailed optimization information (only available in
 certain passes).
-@item =@var{filename}
-Instead of an auto named dump file, output into the given file
-name. The file names @file{stdout} and @file{stderr} are treated
-specially and are considered already open standard streams. For
-example,
-
-@smallexample
-gcc -O2 -ftree-vectorize -fdump-tre

Re: [patch][i386] Goldmont -march/-mtune options

2018-04-27 Thread Uros Bizjak
On Fri, Apr 27, 2018 at 10:04 AM, Makhotina, Olga
 wrote:
> Hi,
>
> This patch implements Goldmont -march/-mtune.
>
> 2018-04-27  Olga Makhotina  
>
> gcc/
>
> * config.gcc: Support "goldmont".
> * config/i386/driver-i386.c (host_detect_local_cpu): Detect 
> "goldmont".
> * config/i386/i386-c.c (ix86_target_macros_internal): Handle
> PROCESSOR_GOLDMONT.
> * config/i386/i386.c (m_GOLDMONT): Define.
> (processor_target_table): Add "goldmont".
> (PTA_GOLDMONT): Define.
> (ix86_lea_outperforms): Add TARGET_GOLDMONT.
> (get_builtin_code_for_version): Handle PROCESSOR_GOLDMONT.
> (fold_builtin_cpu): Add M_INTEL_GOLDMONT.
> (fold_builtin_cpu): Add "goldmont".
> (ix86_add_stmt_cost): Add TARGET_GOLDMONT.
> (ix86_option_override_internal): Add "goldmont".
> * config/i386/i386.h (processor_costs): Define TARGET_GOLDMONT.
> (processor_type): Add PROCESSOR_GOLDMONT.
> * config/i386/i386.md: Add CPU "glm".
> * config/i386/glm.md: New file.
> * config/i386/x86-tune.def: Add m_GOLDMONT.
> * doc/invoke.texi: Add goldmont as x86 -march=/-mtune= CPU type.
>
> libgcc/
> * config/i386/cpuinfo.h (processor_types): Add INTEL_GOLDMONT.
> * config/i386/cpuinfo.c (get_intel_cpu): Detect Goldmont.
>
> gcc/testsuite/
>
> * gcc.target/i386/builtin_target.c: Test goldmont.
> * gcc.target/i386/funcspec-56.inc: Tests for arch=goldmont and
> arch=silvermont.
>
> Is it OK?

@@ -3484,6 +3486,9 @@ ix86_option_override_internal (bool main_args_p,
 | PTA_AVX512F | PTA_AVX512CD;
   const wide_int_bitmask PTA_BONNELL = PTA_CORE2 | PTA_MOVBE;
   const wide_int_bitmask PTA_SILVERMONT = PTA_WESTMERE | PTA_MOVBE | PTA_RDRND;
+  const wide_int_bitmask PTA_GOLDMONT = (PTA_SILVERMONT | PTA_SHA | PTA_XSAVE
+| PTA_RDSEED | PTA_XSAVEC | PTA_XSAVES | PTA_CLFLUSHOPT | PTA_XSAVEOPT
+| PTA_FSGSBASE);
   const wide_int_bitmask PTA_KNM = PTA_KNL | PTA_AVX5124VNNIW
 | PTA_AVX5124FMAPS | PTA_AVX512VPOPCNTDQ;

No need for parenthesis in the above code.

I didn't look at glm.md in details but OK for mainline.

Thanks,
Uros.


Re: [libstdc++; pr66689; pr68397] Backport special function fixes to 7.

2018-04-27 Thread Jonathan Wakely

On 26/04/18 23:17 -0400, Ed Smith-Rowland wrote:
I'm thinking of going back on my choice not to fix special function 
bugs on 7.


These build and test clean on gcc-7.

OK?


OK for gcc-7-branch, thanks.




[C++ PATCH] some cleanups

2018-04-27 Thread Nathan Sidwell

A few cleanups from the modules branch.

* The TEMPLATE_INFO comments still described TREE_LIST contents.
* we didn't check we were looking at a TEMPLATE_INFO in one case
* we declared some (now?) non-existent dump functions
* we made a name-lookup internal dumping function extern
* we made a template (now?) internal creator function extern

committing to trunk.

nathan
--
Nathan Sidwell
2018-04-27  Nathan Sidwell  

	* cp-tree.h (TEMPLATE_INFO): Fix comments.
	(TI_PENDING_TEMPLATE_FLAG): Check TEMPLATE_INFO.
	(NON_DEFAULT_TEMPLATE_ARG_COUNT): Wrap line.
	(dump, print_other_binding_stacks): Remove declarations.
	* name-lookup.c (print_other_binding_stack): Make static.
	* pt.c (build_template_decl): Make static.

Index: cp-tree.h
===
--- cp-tree.h	(revision 259683)
+++ cp-tree.h	(working copy)
@@ -3273,11 +3273,11 @@ extern void decl_shadowed_for_var_insert
DECL_USE_TEMPLATE is nonzero) or the abstract instance of the
template itself.
 
-   In either case, DECL_TEMPLATE_INFO is a TREE_LIST, whose
-   TREE_PURPOSE is the TEMPLATE_DECL of which this entity is a
-   specialization or abstract instance.  The TREE_VALUE is the
+   In either case, DECL_TEMPLATE_INFO is a TEMPLATE_INFO, whose
+   TI_TEMPLATE is the TEMPLATE_DECL of which this entity is a
+   specialization or abstract instance.  The TI_ARGS is the
template arguments used to specialize the template.
-   
+
Consider:
 
   template  struct S { friend void f(T) {} };
@@ -3344,11 +3344,14 @@ extern void decl_shadowed_for_var_insert
 
 #define TI_TEMPLATE(NODE) TREE_TYPE (TEMPLATE_INFO_CHECK (NODE))
 #define TI_ARGS(NODE) TREE_CHAIN (TEMPLATE_INFO_CHECK (NODE))
-#define TI_PENDING_TEMPLATE_FLAG(NODE) TREE_LANG_FLAG_1 (NODE)
+#define TI_PENDING_TEMPLATE_FLAG(NODE) \
+  TREE_LANG_FLAG_1 (TEMPLATE_INFO_CHECK (NODE))
 /* For a given TREE_VEC containing a template argument list,
this property contains the number of arguments that are not
defaulted.  */
-#define NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) TREE_CHAIN (TREE_VEC_CHECK (NODE))
+#define NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) \
+  TREE_CHAIN (TREE_VEC_CHECK (NODE))
+
 /* Below are the setter and getter of the NON_DEFAULT_TEMPLATE_ARGS_COUNT
property.  */
 #define SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE, INT_VALUE) \
@@ -6229,9 +6232,6 @@ extern tree strip_fnptr_conv			(tree);
 extern void maybe_push_cleanup_level		(tree);
 extern tree make_anon_name			(void);
 extern tree check_for_out_of_scope_variable	(tree);
-extern void dump(cp_binding_level &ref);
-extern void dump(cp_binding_level *ptr);
-extern void print_other_binding_stack		(cp_binding_level *);
 extern tree maybe_push_decl			(tree);
 extern tree current_decl_namespace		(void);
 
Index: name-lookup.c
===
--- name-lookup.c	(revision 259683)
+++ name-lookup.c	(working copy)
@@ -3742,7 +3742,7 @@ debug (cp_binding_level *ptr)
 }
 
 
-void
+static void
 print_other_binding_stack (cp_binding_level *stack)
 {
   cp_binding_level *level;
Index: pt.c
===
--- pt.c	(revision 259683)
+++ pt.c	(working copy)
@@ -4674,7 +4674,7 @@ maybe_update_decl_type (tree orig_type,
template PARMS and constraints, CONSTR.  If MEMBER_TEMPLATE_P is true,
the new  template is a member template. */
 
-tree
+static tree
 build_template_decl (tree decl, tree parms, bool member_template_p)
 {
   tree tmpl = build_lang_decl (TEMPLATE_DECL, DECL_NAME (decl), NULL_TREE);


[PATCH] More stmt verification pruning

2018-04-27 Thread Richard Biener

I'll merge verify_expr into verify_gimple_stmt and as a first step
the following marks all dead code as gcc_unreachable.  The 2nd step
will remove duplicate checking and adjust verify_gimple_stmt where
it lacks compared to verify_expr.  Note that this gives us slightly
more checking since verify_expr is only ever called when we have a
CFG built but verify_gimple_stmt is called starting from after
gimplification.

Bootstrap running on x86_64-unknown-linux-gnu.

Richard.

2018-04-27  Richard Biener  

* tree-cfg.c (verify_expr): Make dead code hit gcc_unreachable.

Index: gcc/tree-cfg.c
===
--- gcc/tree-cfg.c  (revision 259695)
+++ gcc/tree-cfg.c  (working copy)
@@ -3141,18 +3141,7 @@ verify_expr (tree *tp, int *walk_subtree
   }
 
 case COND_EXPR:
-  x = COND_EXPR_COND (t);
-  if (!INTEGRAL_TYPE_P (TREE_TYPE (x)))
-   {
- error ("non-integral used in condition");
- return x;
-   }
-  if (!is_gimple_condexpr (x))
-{
- error ("invalid conditional operand");
- return x;
-   }
-  break;
+  gcc_unreachable ();
 
 case NON_LVALUE_EXPR:
 case TRUTH_NOT_EXPR:
@@ -3164,8 +3153,7 @@ verify_expr (tree *tp, int *walk_subtree
 case NEGATE_EXPR:
 case ABS_EXPR:
 case BIT_NOT_EXPR:
-  CHECK_OP (0, "invalid operand to unary operator");
-  break;
+  gcc_unreachable ();
 
 case REALPART_EXPR:
 case IMAGPART_EXPR:
@@ -3261,65 +3249,12 @@ verify_expr (tree *tp, int *walk_subtree
   break;
 case PLUS_EXPR:
 case MINUS_EXPR:
-  /* PLUS_EXPR and MINUS_EXPR don't work on pointers, they should be done 
using
-POINTER_PLUS_EXPR. */
-  if (POINTER_TYPE_P (TREE_TYPE (t)))
-   {
- error ("invalid operand to plus/minus, type is a pointer");
- return t;
-   }
-  CHECK_OP (0, "invalid operand to binary operator");
-  CHECK_OP (1, "invalid operand to binary operator");
-  break;
+  gcc_unreachable ();
 
 case POINTER_DIFF_EXPR:
-  if (!POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0)))
- || !POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 1
-   {
- error ("invalid operand to pointer diff, operand is not a pointer");
- return t;
-   }
-  if (TREE_CODE (TREE_TYPE (t)) != INTEGER_TYPE
- || TYPE_UNSIGNED (TREE_TYPE (t))
- || (TYPE_PRECISION (TREE_TYPE (t))
- != TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (t, 0)
-   {
- error ("invalid type for pointer diff");
- return t;
-   }
-  CHECK_OP (0, "invalid operand to pointer diff");
-  CHECK_OP (1, "invalid operand to pointer diff");
-  break;
+  gcc_unreachable ();
 
 case POINTER_PLUS_EXPR:
-  /* Check to make sure the first operand is a pointer or reference type. 
*/
-  if (!POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0
-   {
- error ("invalid operand to pointer plus, first operand is not a 
pointer");
- return t;
-   }
-  /* Check to make sure the second operand is a ptrofftype.  */
-  if (!ptrofftype_p (TREE_TYPE (TREE_OPERAND (t, 1
-   {
- error ("invalid operand to pointer plus, second operand is not an "
-"integer type of appropriate width");
- return t;
-   }
-  /* FALLTHROUGH */
-case LT_EXPR:
-case LE_EXPR:
-case GT_EXPR:
-case GE_EXPR:
-case EQ_EXPR:
-case NE_EXPR:
-case UNORDERED_EXPR:
-case ORDERED_EXPR:
-case UNLT_EXPR:
-case UNLE_EXPR:
-case UNGT_EXPR:
-case UNGE_EXPR:
-case UNEQ_EXPR:
-case LTGT_EXPR:
 case MULT_EXPR:
 case TRUNC_DIV_EXPR:
 case CEIL_DIV_EXPR:
@@ -3340,6 +3275,23 @@ verify_expr (tree *tp, int *walk_subtree
 case BIT_IOR_EXPR:
 case BIT_XOR_EXPR:
 case BIT_AND_EXPR:
+  gcc_unreachable ();
+
+case LT_EXPR:
+case LE_EXPR:
+case GT_EXPR:
+case GE_EXPR:
+case EQ_EXPR:
+case NE_EXPR:
+case UNORDERED_EXPR:
+case ORDERED_EXPR:
+case UNLT_EXPR:
+case UNLE_EXPR:
+case UNGT_EXPR:
+case UNGE_EXPR:
+case UNEQ_EXPR:
+case LTGT_EXPR:
+  /* Reachable via COND_EXPR condition which is GENERIC.  */
   CHECK_OP (0, "invalid operand to binary operator");
   CHECK_OP (1, "invalid operand to binary operator");
   break;



[PATCH] Remove MPX support

2018-04-27 Thread Martin Liška
Hi.

I'm sending patch that removes MPX. It preserves all options 
-fcheck-pointer-bounds, -fchkp-* and -mmpx
target option. These options are now NOP. On the contrary following options 
were removed:
--static-libmpx  -static-libmpxwrappers. Is it fine to remove them?

Patch can bootstrap on x86_64-linux-gnu, ppc64le-linux-gnu and survives 
regression tests.
And the patch bootstraps also on aarch64-linux-gnu.

Note that the patch is trim for files (some) that are removed. Doing that was 
necessary to
fit in 100K with bzip2 patch file.

Ready to be installed after some time?
Martin


0001-Remove-MPX-without-removed-v2.patch.bz2
Description: application/bzip


[PATCH] Shave some bit of work off verify_gimple_in_cfg

2018-04-27 Thread Richard Biener

This makes us not record all stmts in the visited_stmts hash-set
but only those that are possibly valid EH stmts.  Should save us
some cycles here.

Bootstrap running on x86_64-unknown-linux-gnu.

Richard.

2018-04-27  Richard Biener  

* tree-cfg.c (verify_gimple_phi): Take a gphi * argument.
(verify_gimple_in_cfg): Rename visited_stmts to visited_throwing_stmts
to reflect use.  Only add interesting stmts.

Index: gcc/tree-cfg.c
===
--- gcc/tree-cfg.c  (revision 259695)
+++ gcc/tree-cfg.c  (working copy)
@@ -5103,7 +5103,7 @@ verify_gimple_stmt (gimple *stmt)
and false otherwise.  */
 
 static bool
-verify_gimple_phi (gimple *phi)
+verify_gimple_phi (gphi *phi)
 {
   bool err = false;
   unsigned i;
@@ -5422,7 +5422,7 @@ verify_gimple_in_cfg (struct function *f
 
   timevar_push (TV_TREE_STMT_VERIFY);
   hash_set visited;
-  hash_set visited_stmts;
+  hash_set visited_throwing_stmts;
 
   /* Collect all BLOCKs referenced by the BLOCK tree of FN.  */
   hash_set blocks;
@@ -5444,8 +5444,6 @@ verify_gimple_in_cfg (struct function *f
  bool err2 = false;
  unsigned i;
 
- visited_stmts.add (phi);
-
  if (gimple_bb (phi) != bb)
{
  error ("gimple_bb (phi) is set to a wrong basic block");
@@ -5501,8 +5499,6 @@ verify_gimple_in_cfg (struct function *f
  tree addr;
  int lp_nr;
 
- visited_stmts.add (stmt);
-
  if (gimple_bb (stmt) != bb)
{
  error ("gimple_bb (stmt) is set to a wrong basic block");
@@ -5554,6 +5550,7 @@ verify_gimple_in_cfg (struct function *f
  lp_nr = lookup_stmt_eh_lp (stmt);
  if (lp_nr > 0)
{
+ visited_throwing_stmts.add (stmt);
  if (!stmt_could_throw_p (stmt))
{
  if (verify_nothrow)
@@ -5575,11 +5572,11 @@ verify_gimple_in_cfg (struct function *f
}
 }
 
-  eh_error_found = false;
   hash_map *eh_table = get_eh_throw_stmt_table (cfun);
+  eh_error_found = false;
   if (eh_table)
 eh_table->traverse *, verify_eh_throw_stmt_node>
-  (&visited_stmts);
+  (&visited_throwing_stmts);
 
   if (err || eh_error_found)
 internal_error ("verify_gimple failed");


Re: [PATCH] [Microblaze]: PIC Data Text Relative

2018-04-27 Thread Andrew Sadek
Thanks Michael.
Please find below updated Change Log.

2018-04-27 Andrew Sadek  

Microblaze Target: PIC data text relative
* gcc/config/microblaze/microblaze.opt: add new option
-mpic-is-data-text-relative.
* gcc/config/microblaze/microblaze-protos.h (microblaze_constant_address_p):
Add microblaze_constant_address_p function to encapsulate CONSTANT_ADDRESS_P
in microblaze.h.
* gcc/config/microblaze/microblaze.h (microblaze_constant_address_p):
change CONSTANT_ADDRESS_P definition to microblaze_constant_address_p.
* gcc/config/microblaze/microblaze.c (TARGET_PIC_DATA_TEXT_REL):
New addressing mode
for data-text relative position independent code.
(microblaze_classify_unspec): add 'UNSPEC_TEXT' case ->
'ADDRESS_SYMBOLIC_TXT_REL'.
(microblaze_classify_address): add handling for UNSPEC + CONST_INT
+ SYMBOL_REF.
(microblaze_legitimate_pic_operand): exclude function calls from
pic operands
in case of TARGET_PIC_DATA_TEXT_REL option.
(microblaze_legitimize_address): generate 'UNSPEC_TEXT' for all possible
addresses cases.
(microblaze_address_insns): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand): add 'ADDRESS_SYMBOLIC_TXT_REL' case.
(print_operand_address): add 'ADDRESS_SYMBOLIC_TXT_REL' case + handling for
'address + offset' + set strict with 2 in microblaze_classify_address call.
(microblaze_expand_prologue): add new function prologue call for
'r20' assignation.
(microblaze_asm_generate_pic_addr_dif_vec): override new target hook
'TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC' to disable address diff vector
table in case of TARGET_PIC_DATA_TEXT_REL.
(expand_pic_symbol_ref): add handling for TARGET_PIC_DATA_TEXT_REL cases.
* gcc/config/microblaze/microblaze.md (TARGET_PIC_DATA_TEXT_REL):
Add new macros 'UNSPEC_TEXT' and 'UNSPEC_SET_TEXT' +
add rule for setting r20 in function prologue + exclude function calls
from 'UNSPEC_PLT' in case of data text relative mode.
* gcc/doc/tm.texi.in (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
Add new target hook for generating address diff vector tables in
case of flag_pic.
* gcc/doc/tm.texi : Regenerate.
* gcc/stmt.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): append new condition
'targetm.asm_out.generate_pic_addr_diff_vec' to flag_pic in case
of address diff vector generation.
* gcc/target.def (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC): add
target hook definition.
* gcc/targhooks.c (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
add default function for generate_pic_addr_diff_vec -> flag_pic.
* gcc/targhooks.h (TARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC):
add function declaration for generate_pic_addr_diff_vec.
* gcc/doc/invoke.texi (Add new pic option): Add new microblaze pic
option -mpic-is-data-text-relative.
* gcc/testsuite/gcc.target/microblaze/others/data_var1.c: include
PIC case of r20 base register.
* gcc/testsuite/gcc.target/microblaze/others/data_var2.c: include
PIC case of r20 base register.
* gcc/testsuite/gcc.target/microblaze/others/picdtr.c: add new
test case for -mpic-is-data-text-relative.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var1.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var2.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var3.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var4.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var5.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/sdata_var6.c: add
-fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/string_cst1_gpopt.c:
add -fno-pic to exclude small data from PIC.
* gcc/testsuite/gcc.target/microblaze/others/string_cst2_gpopt.c:
add -fno-pic to exclude small data from PIC.

On Fri, Apr 27, 2018 at 3:36 AM, Michael Eager  wrote:
> On 04/19/2018 03:43 AM, Andrew Sadek wrote:
>>
>> On Wed, Apr 18, 2018 at 6:57 PM, Michael Eager  wrote:
>>>
>>>
>>> Hi Andrew --
>>>
>>> Check indents in the following files:
>>> (Make sure that your tabs are set at 8 chars.)
>>> --- gcc/config/microblaze/microblaze.c
>>> --- gcc/config/microblaze/microblaze.md
>>>
>> I have re-run check_GNU_Style.sh and no are issues are found now.
>
>
> I corrected a large number of indent problems in microblaze.c.
>
>>> Just a couple coding notes:
>>>
>>> microblaze.c:
>>>
>>> @@ -858,6 +879,16 @@ microblaze_classify_address (struct microblaze_add
>>> +   && strict == 2)
>>>
>>> Include comment in function header describing meaning of strict == 2.
>>
>>
>> Done
>>
>>>
>>> @@ -1022,7 +1065,7 @@ microblaze_legitimize_address (rtx x, rtx oldx ATT
>>>else if (flag_pic == 2 && !TARGET_PIC_DATA_TEXT_REL)
>>>  {
>>>...
>>>  }
>>>  

[C++ Patch] PR 84691 ("[6/7/8/9 Regression] internal compiler error: in poplevel_class...")

2018-04-27 Thread Paolo Carlini

Hi,

this small error-recovery issue remained in my todo list of 8 
regressions: just clear the friendp flag in this case too - like we do a 
few lines above for virtual declarations - and avoid problems later. 
Tested x86_64-linux.


Thanks, Paolo.



/cp
2018-04-27  Paolo Carlini  

PR c++/84691
* decl.c (grokdeclarator): Clear friendp upon definition in local
class definition error.

/testsuite
2018-04-27  Paolo Carlini  

PR c++/84691
* g++.dg/cpp0x/friend3.C: New.
Index: cp/decl.c
===
--- cp/decl.c   (revision 259697)
+++ cp/decl.c   (working copy)
@@ -11298,9 +11298,11 @@ grokdeclarator (const cp_declarator *declarator,
if (decl_context == NORMAL)
  error ("friend declaration not in class definition");
if (current_function_decl && funcdef_flag)
- error ("can%'t define friend function %qs in a local "
-"class definition",
-name);
+ {
+   error ("can%'t define friend function %qs in a local "
+  "class definition", name);
+   friendp = 0;
+ }
  }
else if (ctype && sfk == sfk_conversion)
  {
Index: testsuite/g++.dg/cpp0x/friend3.C
===
--- testsuite/g++.dg/cpp0x/friend3.C(nonexistent)
+++ testsuite/g++.dg/cpp0x/friend3.C(working copy)
@@ -0,0 +1,11 @@
+// PR c++/84691
+// { dg-do compile { target c++11 } }
+
+template
+struct a {
+  unsigned b = [] {
+union {
+  friend void c() {}  // { dg-error "local class" }
+};  // { dg-error "no members" }
+  };
+};


Re: [patch] allow '-' for stdout dump

2018-04-27 Thread Richard Biener
On Thu, Apr 26, 2018 at 7:12 PM, Nathan Sidwell  wrote:
> Here's the patch to allow '-' as a synonym for 'stdout'.  It's easier to
> type, and a convention used elsewhere.
>
> Also document the existing stdout/stderr selection along with the new
> behaviour?
>
> ok for trunk?

OK for the dumpfile.c part.  Please iterate on the doc part with Sandra.

Richard.

> nathan
> --
> Nathan Sidwell


Re: [PATCH] Do not set nothrow flag on recursive function with stack checking

2018-04-27 Thread Richard Biener
On Thu, Apr 26, 2018 at 4:29 PM, Eric Botcazou  wrote:
> Hi,
>
> when stack checking is enabled in Ada, it is supposed to be able to handle the
> case of a recursive function that does essentially nothing.  But in this case
> the IPA machinery will compute that the function is nothrow, which means that
> the Storage_Error exception cannot be caught by the caller.
>
> Tested on x86-64/Linux, OK for the mainline?

This looks not a generic enough fix to me - consider

void foo(void) { int a[10]; a[0] = 1; a[9] = 1; }
int main() { try { foo (); } catch (...) {} }

with -fnon-call-exceptions.  If we'd like to catch the SEGV from stack overflows
then your fix doesn't handle the non-recursive case nor the case where
-fstack-check
is not supplied.  But the compiler - when the accesses are in-range - will not
consider the accesses trapping.

So to me your attempt in fixing this isn't complete but a complete fix would
be quite pessimizing :/ (for -fnon-call-exceptions)

At least all this should be documented somewhere, that is, what to expect
when trying to catch stack faults in general with -fnon-call-exceptions
[-fstack-check].

Richard.

>
> 2018-04-26  Eric Botcazou  
>
> * ipa-pure-const.c (check_call): In non-IPA mode, set can_throw flag
> for a recursive call that can throw if stack checking is enabled.
> (check_stmt): Fix formatting.
> (propagate_nothrow): Set can_throw for a recursive call if exceptions
> and stack checking are enabled.
> (pass_nothrow::execute): Do not set the nothrow flag if there is a
> recursive call that can throw and stack checking is enabled.
>
>
> 2018-04-26  Eric Botcazou  
>
> * gnat.dg/stack_check4.adb: New test.
>
> --
> Eric Botcazou


[PATCH 2/2, i386]: Emit inter-unit moves using preferred_for_speed infrastructure

2018-04-27 Thread Uros Bizjak
Second part of the patch.

2018-04-27  Uros Bizjak  

* config/i386/i386.md (*movti_internal): Substitute Ye constraint
with Yd constraint. Set "preferred_for_speed" attribute from
TARGET_INTER_UNIT_MOVES_{FROM,TO}_VEC for alternatives
with Yd constraint.
(*movdi_internal): Ditto.
(movti_interunit splitters): Remove
TARGET_INTER_UNIT_MOVES_{FROM,TO}_VEC from insn condition.
(movdi_interunit splitters): Ditto.
* config/i386/constraints.md (Ye): Remove.
(Yd): Do not depend on TARGET_INTER_UNIT_MOVES_{FROM,TO}_VEC.

Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
Index: config/i386/constraints.md
===
--- config/i386/constraints.md  (revision 259682)
+++ config/i386/constraints.md  (working copy)
@@ -99,10 +99,8 @@
 
 ;; We use the Y prefix to denote any number of conditional register sets:
 ;;  z  First SSE register.
-;;  d  any EVEX encodable SSE register for AVX512BW target or any SSE register
-;; for SSE4_1 target, when inter-unit moves to SSE register are enabled
-;;  e  any EVEX encodable SSE register for AVX512BW target or any SSE register
-;; for SSE4_1 target, when inter-unit moves from SSE register are enabled
+;;  d  any EVEX encodable SSE register for AVX512BW target or
+;; any SSE register for SSE4_1 target.
 ;;  p  Integer register when TARGET_PARTIAL_REG_STALL is disabled
 ;;  a  Integer register when zero extensions with AND are disabled
 ;;  b  Any register that can be used as the GOT base when calling
@@ -120,21 +118,9 @@
  "First SSE register (@code{%xmm0}).")
 
 (define_register_constraint "Yd"
- "TARGET_INTER_UNIT_MOVES_TO_VEC
-  ? (TARGET_AVX512DQ
- ? ALL_SSE_REGS
- : (TARGET_SSE4_1 ? SSE_REGS : NO_REGS))
-  : NO_REGS"
- "@internal Any EVEX encodable SSE register (@code{%xmm0-%xmm31}) for AVX512DQ 
target or any SSE register for SSE4_1 target, when inter-unit moves to vector 
registers are enabled.")
+ "TARGET_AVX512DQ ? ALL_SSE_REGS : TARGET_SSE4_1 ? SSE_REGS : NO_REGS"
+ "@internal Any EVEX encodable SSE register (@code{%xmm0-%xmm31}) for AVX512DQ 
target or any SSE register for SSE4_1 target.")
 
-(define_register_constraint "Ye"
- "TARGET_INTER_UNIT_MOVES_FROM_VEC
-  ? (TARGET_AVX512DQ
- ? ALL_SSE_REGS
- : (TARGET_SSE4_1 ? SSE_REGS : NO_REGS))
-  : NO_REGS"
- "@internal Any EVEX encodable SSE register (@code{%xmm0-%xmm31}) for AVX512DQ 
target or any SSE register for SSE4_1 target, when inter-unit moves from vector 
registers are enabled.")
-
 (define_register_constraint "Yp"
  "TARGET_PARTIAL_REG_STALL ? NO_REGS : GENERAL_REGS"
  "@internal Any integer register when TARGET_PARTIAL_REG_STALL is disabled.")
Index: config/i386/i386.md
===
--- config/i386/i386.md (revision 259682)
+++ config/i386/i386.md (working copy)
@@ -2123,7 +2123,7 @@
 
 (define_insn "*movti_internal"
   [(set (match_operand:TI 0 "nonimmediate_operand" "=!r ,o ,v,v ,v ,m,?r,?Yd")
-   (match_operand:TI 1 "general_operand"  "riFo,re,C,BC,vm,v,Ye,r"))]
+   (match_operand:TI 1 "general_operand"  "riFo,re,C,BC,vm,v,Yd,r"))]
   "(TARGET_64BIT
 && !(MEM_P (operands[0]) && MEM_P (operands[1])))
|| (TARGET_SSE
@@ -2203,12 +2203,19 @@
   (match_test "optimize_function_for_size_p (cfun)")
 (const_string "V4SF")
   ]
-  (const_string "TI")))])
+  (const_string "TI")))
+   (set (attr "preferred_for_speed")
+ (cond [(eq_attr "alternative" "6")
+ (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
+   (eq_attr "alternative" "7")
+ (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
+  ]
+  (symbol_ref "true")))])
 
 (define_split
   [(set (match_operand:TI 0 "sse_reg_operand")
 (match_operand:TI 1 "general_reg_operand"))]
-  "TARGET_64BIT && TARGET_SSE4_1 && TARGET_INTER_UNIT_MOVES_TO_VEC
+  "TARGET_64BIT && TARGET_SSE4_1
&& reload_completed"
   [(set (match_dup 2)
(vec_merge:V2DI
@@ -2227,7 +2234,7 @@
   [(set (match_operand:DI 0 "nonimmediate_operand"
 "=r  ,o  ,r,r  ,r,m ,*y,*y,?*y,?m,?r,?*y,*v,*v,*v,m ,m,?r 
,?*Yd,?r,?*v,?*y,?*x,*k,*k ,*r,*m")
(match_operand:DI 1 "general_operand"
-"riFo,riF,Z,rem,i,re,C ,*y,m  ,*y,*y,r  ,C ,*v,m ,*v,v,*Ye,r   ,*v,r  ,*x 
,*y ,*r,*km,*k,*k"))]
+"riFo,riF,Z,rem,i,re,C ,*y,m  ,*y,*y,r  ,C ,*v,m ,*v,v,*Yd,r   ,*v,r  ,*x 
,*y ,*r,*km,*k,*k"))]
   "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
 {
   switch (get_attr_type (insn))
@@ -2379,9 +2386,9 @@
   ]
   (const_string "DI")))
(set (attr "preferred_for_speed")
- (cond [(eq_attr "alternative" "10,19")
+ (cond [(eq_attr "alternative" "10,17,19")
  (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
-   (eq_attr "alternative" "11,20")
+   (eq_attr "alternative" "11,18,20")
   

Re: [PATCH] Fix aarch64 ILP32 ICE with vaarg gimplified code

2018-04-27 Thread Richard Biener
On Fri, 27 Apr 2018, Kyrill Tkachov wrote:

> 
> On 26/04/18 15:04, Christophe Lyon wrote:
> > On 26 April 2018 at 15:41, Richard Biener  wrote:
> > > On Thu, 26 Apr 2018, Christophe Lyon wrote:
> > >
> > >> On 26 April 2018 at 14:09, Richard Biener  wrote:
> > >> >
> > >> > Seen by  Christophe Lyon, verified with a cross that this fixes the
> > >> > issue.
> > >> >
> > >> > aarch64 people, can you please test & commit this?
> > >> >
> > >>
> > >> As I have just written in bugzilla, this patch avoids an ICE when
> > >> compiling newlib's sysopen.i,
> > >> but I still see a similar crash when compiling vfprintf.i.
> > >
> > > There's a similar case still left.  Complete patch:
> > >
> > With this version, the toolchain build completes, but I didn't run
> > make check, nor tried aarch64-linux-gnu.
> > 
> 
> A bootstrap and test on aarch64-none-linux-gnu shows no problems.
> I don't know if there was a rationale for having the conversion to
> intDI_type_node.

If that is somehow a required detail for SImode pointers then
there needs to be a conversion from the pointer to uintSI_type_node
before then extending to intDI_type_node.  uintSI to match the
setting of POINTERS_EXTEND_UNSIGNED for aarch64.

Richard.

> Thanks,
> Kyrill
> 
> > > Index: gcc/config/aarch64/aarch64.c
> > > ===
> > > --- gcc/config/aarch64/aarch64.c(revision 259669)
> > > +++ gcc/config/aarch64/aarch64.c(working copy)
> > > @@ -12267,23 +12267,17 @@ aarch64_gimplify_va_arg_expr (tree valis
> > >if (align > 8)
> > >  {
> > >/* if (alignof(type) > 8) (arg = arg + 15) & -16;  */
> > > -  t = fold_convert (intDI_type_node, arg);
> > > -  t = build2 (PLUS_EXPR, TREE_TYPE (t), t,
> > > - build_int_cst (TREE_TYPE (t), 15));
> > > +  t = fold_build_pointer_plus_hwi (arg, 15);
> > >t = build2 (BIT_AND_EXPR, TREE_TYPE (t), t,
> > >   build_int_cst (TREE_TYPE (t), -16));
> > > -  t = fold_convert (TREE_TYPE (arg), t);
> > >roundup = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg, t);
> > >  }
> > >else
> > >  roundup = NULL;
> > >/* Advance ap.__stack  */
> > > -  t = fold_convert (intDI_type_node, arg);
> > > -  t = build2 (PLUS_EXPR, TREE_TYPE (t), t,
> > > - build_int_cst (TREE_TYPE (t), size + 7));
> > > +  t = fold_build_pointer_plus_hwi (arg, size + 7);
> > >t = build2 (BIT_AND_EXPR, TREE_TYPE (t), t,
> > >   build_int_cst (TREE_TYPE (t), -8));
> > > -  t = fold_convert (TREE_TYPE (arg), t);
> > >t = build2 (MODIFY_EXPR, TREE_TYPE (stack), unshare_expr (stack), t);
> > >/* String up roundup and advance.  */
> > >if (roundup)
> > >
> > >
> > >> Thanks,
> > >>
> > >> Christophe
> > >>
> > >> > Thanks,
> > >> > Richard.
> > >> >
> > >> > 2018-04-26  Richard Biener 
> > >> >
> > >> > * config/aarch64/aarch64.c: Simplify ap.__stack advance and
> > >> > fix for ILP32.
> > >> >
> > >> > Index: gcc/config/aarch64/aarch64.c
> > >> > ===
> > >> > --- gcc/config/aarch64/aarch64.c (revision 259669)
> > >> > +++ gcc/config/aarch64/aarch64.c (working copy)
> > >> > @@ -12278,12 +12278,9 @@ aarch64_gimplify_va_arg_expr (tree valis
> > >> >else
> > >> >  roundup = NULL;
> > >> >/* Advance ap.__stack  */
> > >> > -  t = fold_convert (intDI_type_node, arg);
> > >> > -  t = build2 (PLUS_EXPR, TREE_TYPE (t), t,
> > >> > - build_int_cst (TREE_TYPE (t), size + 7));
> > >> > +  t = fold_build_pointer_plus_hwi (arg, size + 7);
> > >> >t = build2 (BIT_AND_EXPR, TREE_TYPE (t), t,
> > >> >   build_int_cst (TREE_TYPE (t), -8));
> > >> > -  t = fold_convert (TREE_TYPE (arg), t);
> > >> >t = build2 (MODIFY_EXPR, TREE_TYPE (stack), unshare_expr (stack),
> > t);
> > >> >/* String up roundup and advance.  */
> > >> >if (roundup)
> > >>
> > >>
> > >
> > > --
> > > Richard Biener 
> > > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB
> > 21284 (AG Nuernberg)
> 
> 

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


Re: [PATCH] Fix aarch64 ILP32 ICE with vaarg gimplified code

2018-04-27 Thread Kyrill Tkachov


On 26/04/18 15:04, Christophe Lyon wrote:

On 26 April 2018 at 15:41, Richard Biener  wrote:
> On Thu, 26 Apr 2018, Christophe Lyon wrote:
>
>> On 26 April 2018 at 14:09, Richard Biener  wrote:
>> >
>> > Seen by  Christophe Lyon, verified with a cross that this fixes the
>> > issue.
>> >
>> > aarch64 people, can you please test & commit this?
>> >
>>
>> As I have just written in bugzilla, this patch avoids an ICE when
>> compiling newlib's sysopen.i,
>> but I still see a similar crash when compiling vfprintf.i.
>
> There's a similar case still left.  Complete patch:
>
With this version, the toolchain build completes, but I didn't run
make check, nor tried aarch64-linux-gnu.



A bootstrap and test on aarch64-none-linux-gnu shows no problems.
I don't know if there was a rationale for having the conversion to
intDI_type_node.

Thanks,
Kyrill


> Index: gcc/config/aarch64/aarch64.c
> ===
> --- gcc/config/aarch64/aarch64.c(revision 259669)
> +++ gcc/config/aarch64/aarch64.c(working copy)
> @@ -12267,23 +12267,17 @@ aarch64_gimplify_va_arg_expr (tree valis
>if (align > 8)
>  {
>/* if (alignof(type) > 8) (arg = arg + 15) & -16;  */
> -  t = fold_convert (intDI_type_node, arg);
> -  t = build2 (PLUS_EXPR, TREE_TYPE (t), t,
> - build_int_cst (TREE_TYPE (t), 15));
> +  t = fold_build_pointer_plus_hwi (arg, 15);
>t = build2 (BIT_AND_EXPR, TREE_TYPE (t), t,
>   build_int_cst (TREE_TYPE (t), -16));
> -  t = fold_convert (TREE_TYPE (arg), t);
>roundup = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg, t);
>  }
>else
>  roundup = NULL;
>/* Advance ap.__stack  */
> -  t = fold_convert (intDI_type_node, arg);
> -  t = build2 (PLUS_EXPR, TREE_TYPE (t), t,
> - build_int_cst (TREE_TYPE (t), size + 7));
> +  t = fold_build_pointer_plus_hwi (arg, size + 7);
>t = build2 (BIT_AND_EXPR, TREE_TYPE (t), t,
>   build_int_cst (TREE_TYPE (t), -8));
> -  t = fold_convert (TREE_TYPE (arg), t);
>t = build2 (MODIFY_EXPR, TREE_TYPE (stack), unshare_expr (stack), t);
>/* String up roundup and advance.  */
>if (roundup)
>
>
>> Thanks,
>>
>> Christophe
>>
>> > Thanks,
>> > Richard.
>> >
>> > 2018-04-26  Richard Biener 
>> >
>> > * config/aarch64/aarch64.c: Simplify ap.__stack advance and
>> > fix for ILP32.
>> >
>> > Index: gcc/config/aarch64/aarch64.c
>> > ===
>> > --- gcc/config/aarch64/aarch64.c (revision 259669)
>> > +++ gcc/config/aarch64/aarch64.c (working copy)
>> > @@ -12278,12 +12278,9 @@ aarch64_gimplify_va_arg_expr (tree valis
>> >else
>> >  roundup = NULL;
>> >/* Advance ap.__stack  */
>> > -  t = fold_convert (intDI_type_node, arg);
>> > -  t = build2 (PLUS_EXPR, TREE_TYPE (t), t,
>> > - build_int_cst (TREE_TYPE (t), size + 7));
>> > +  t = fold_build_pointer_plus_hwi (arg, size + 7);
>> >t = build2 (BIT_AND_EXPR, TREE_TYPE (t), t,
>> >   build_int_cst (TREE_TYPE (t), -8));
>> > -  t = fold_convert (TREE_TYPE (arg), t);
>> >t = build2 (MODIFY_EXPR, TREE_TYPE (stack), unshare_expr (stack), t);
>> >/* String up roundup and advance.  */
>> >if (roundup)
>>
>>
>
> --
> Richard Biener 
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)




Re: [PATCH][arm] PR target/82518: Return false in ARRAY_MODE_SUPPORTED_P for BYTES_BIG_ENDIAN

2018-04-27 Thread Kyrill Tkachov


On 25/04/18 18:31, Maxim Kuvyrkov wrote:

On Mar 20, 2018, at 8:11 PM, Kyrill Tkachov  wrote:

Hi all,

This PR shows that we get the load/store_lanes logic wrong for arm big-endian.
It is tricky to get right. Aarch64 does it by adding the appropriate 
lane-swapping
operations during expansion.

I'd like to do the same on arm eventually, but we'd need to port and validate 
the VTBL-generating
code and add it to all the right places and I'm not comfortable enough doing it 
for GCC 8, but I am keen
in getting the wrong-code fixed.
As I say in the PR, vectorisation on armeb is already severely restricted (we 
disable many patterns on BYTES_BIG_ENDIAN)
and the load/store_lanes patterns really were not working properly at all, so 
disabling them is not
a radical approach.

The way to do that is to return false in ARRAY_MODE_SUPPORTED_P for 
BYTES_BIG_ENDIAN.

Bootstrapped and tested on arm-none-linux-gnueabihf.
Also tested on armeb-none-eabi.

Committing to trunk.

...

--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6609,7 +6609,8 @@ proc check_effective_target_vect_load_lanes { } {
verbose "check_effective_target_vect_load_lanes: using cached result" 2
  } else {
set et_vect_load_lanes 0
-   if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])
+   # We don't support load_lanes correctly on big-endian arm.
+   if { ([istarget arm-*-*] && [check_effective_target_arm_neon_ok])
 || [istarget aarch64*-*-*] } {
set et_vect_load_lanes 1
}


Hi Kyrill,

This part makes armv8l-linux-gnueabihf target fail a few of slp-perm-* tests.  
Using [check_effective_target_arm_little_endian] should fix this.

Would you please fix this on master and gcc-7-branch?


Hi Maxim,

Thanks for catching this. This patch fixes the failures (I've reproduced them 
on a armv8l-linux-gnueabihf target).
Committing to trunk.
Richi, Jakub, is this ok to commit to the GCC 8 branch at this time?

Thanks,
Kyrill

2018-04-27  Kyrylo Tkachov  

* lib/target-supports.exp (check_effective_target_vect_load_lanes):
Use check_effective_target_arm_little_endian.

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 00f988cc756b4f5898b9c6290722d1353240b3a3..6d497fbcf8033cae06f54e0601f14e4affe29923 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6588,7 +6588,7 @@ proc check_effective_target_vect_load_lanes { } {
 } else {
 	set et_vect_load_lanes 0
 	# We don't support load_lanes correctly on big-endian arm.
-	if { ([istarget arm-*-*] && [check_effective_target_arm_neon_ok])
+	if { ([check_effective_target_arm_little_endian] && [check_effective_target_arm_neon_ok])
 	 || [istarget aarch64*-*-*] } {
 	set et_vect_load_lanes 1
 	}


Re: [PATCH] Fix loop-header copying do-while loop detection (PR85116)

2018-04-27 Thread Richard Biener
On Fri, 27 Apr 2018, David Edelsohn wrote:

> Hi, Richi
> 
> This patches causes a boostrap failure on AIX.  Everything miscompares.
> The code itself is the same, but the DWARF debug information contains many
> differences.

Does AIX use bootstrap-debug by default?  I don't see how the patch
can cause this kind of issue directly but of course it will change
CH decisions which may expose latent bugs somewhere.

Can you provide more details please, like actual differences?
I would have expected the dwarf2out.c change to be a more likely
candidate for such symtoms but I trust that you did properly
bisect to my patch?

Thanks,
Richard.

> - David
> 
> 

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


Re: [PATCH][AArch64] PR target/85512: Tighten SIMD right shift immediate constraints

2018-04-27 Thread James Greenhalgh
On Fri, Apr 27, 2018 at 09:29:28AM +0100, Kyrill Tkachov wrote:
> 
> On 26/04/18 14:47, Richard Sandiford wrote:
> > Kyrill  Tkachov  writes:
> >> On 24/04/18 17:41, Jakub Jelinek wrote:
> >>> On Tue, Apr 24, 2018 at 05:22:15PM +0100, Kyrill Tkachov wrote:
>  I've cleaned up the testcase a bit to leave only the function that
>  generates the invalid instruction,
>  making it shorter.
> 
>  Jakub, is the patch ok to go in for GCC 8 from your perspective?
> >>> The PR is marked P1 now, so sure, please commit this for GCC 8, the sooner
> >>> the better.  We have only one other P1 left.
> >> Thanks, I've committed it as 259614.
> >>
> >>> The only thing I'm unsure about is whether you want to make the top of the
> >>> range 32 and 64 rather than just 31 and 63, after all the operand
> >>> predicate used there requires < 32 and < 64, and from middle-end's POV
> >>> shifts by 32 or 64 are undefined (unless SHIFT_COUNT_TRUNCATED, but
> >>> aarch64 defines it to
> >>> #define SHIFT_COUNT_TRUNCATED (!TARGET_SIMD)
> >>>
> >>> So, using
> >>> (match_test "IN_RANGE (ival, 1, 31)")))
> >>> and
> >>> (match_test "IN_RANGE (ival, 1, 63)")))
> >>> would feel safer to me, but your call.
> >> I don't think this is necessary.
> >> We already nominally allow shifts up to 32/64 in the SIMD versions
> >> (see aarch64_simd_ashr in aarch64-simd.md) though I imagine if such 
> >> shifts
> >> are undefined in the midend then it will just not generate them or at 
> >> least blow
> >> up somewhere along the way.
> >>
> >> So I've left the range as is.
> > But as Jakub says, it's wrong for the constraints to accept something
> > that the predicates don't.  That must never happen for reloadable
> > operands.  E.g. we could enter RA with a 32-bit shift by a register R
> > that is known to be equal to 32.  As it stands, the constraints allow
> > the RA to replace R with 32 (e.g. if R would otherwise be spilled) but
> > the predicates would reject the result.  We'd then get an unrecognisable
> > insn ICE.
> >
> > So I think we either need to adjust the predicate to accept the wider
> > range, or adjust the constraint as above.  At this stage adjusting the
> > constraint seems safer.
> 
> Ok, thanks for the explanation. I think I misunderstood the issue initially.
> This patch tightens the new constraints to 31 and 63 at the upper limit.

Given the discussion, I'd say this is the obvious fix, but as you've
asked - this is OK.

Thanks,
James

> 2018-04-27  Kyrylo Tkachov  
> 
>  * config/aarch64/constraints.md (Usg): Limit to 31.
>  (Usj): Limit to 63.
> 




Re: [PATCH][AArch64] PR target/85512: Tighten SIMD right shift immediate constraints

2018-04-27 Thread Kyrill Tkachov


On 26/04/18 14:47, Richard Sandiford wrote:

Kyrill  Tkachov  writes:

On 24/04/18 17:41, Jakub Jelinek wrote:

On Tue, Apr 24, 2018 at 05:22:15PM +0100, Kyrill Tkachov wrote:

I've cleaned up the testcase a bit to leave only the function that
generates the invalid instruction,
making it shorter.

Jakub, is the patch ok to go in for GCC 8 from your perspective?

The PR is marked P1 now, so sure, please commit this for GCC 8, the sooner
the better.  We have only one other P1 left.

Thanks, I've committed it as 259614.


The only thing I'm unsure about is whether you want to make the top of the
range 32 and 64 rather than just 31 and 63, after all the operand
predicate used there requires < 32 and < 64, and from middle-end's POV
shifts by 32 or 64 are undefined (unless SHIFT_COUNT_TRUNCATED, but
aarch64 defines it to
#define SHIFT_COUNT_TRUNCATED (!TARGET_SIMD)

So, using
(match_test "IN_RANGE (ival, 1, 31)")))
and
(match_test "IN_RANGE (ival, 1, 63)")))
would feel safer to me, but your call.

I don't think this is necessary.
We already nominally allow shifts up to 32/64 in the SIMD versions
(see aarch64_simd_ashr in aarch64-simd.md) though I imagine if such shifts
are undefined in the midend then it will just not generate them or at least blow
up somewhere along the way.

So I've left the range as is.

But as Jakub says, it's wrong for the constraints to accept something
that the predicates don't.  That must never happen for reloadable
operands.  E.g. we could enter RA with a 32-bit shift by a register R
that is known to be equal to 32.  As it stands, the constraints allow
the RA to replace R with 32 (e.g. if R would otherwise be spilled) but
the predicates would reject the result.  We'd then get an unrecognisable
insn ICE.

So I think we either need to adjust the predicate to accept the wider
range, or adjust the constraint as above.  At this stage adjusting the
constraint seems safer.


Ok, thanks for the explanation. I think I misunderstood the issue initially.
This patch tightens the new constraints to 31 and 63 at the upper limit.

Bootstrapped and tested on aarch64-none-linux-gnu.

Ok for trunk?
Thanks,
Kyrill


2018-04-27  Kyrylo Tkachov  

* config/aarch64/constraints.md (Usg): Limit to 31.
(Usj): Limit to 63.

diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md
index b5da997e7bab1541ed1401a94a3b94a0cde8017f..32a0fa60a198c714f7c0b8b987da6bc26992845d 100644
--- a/gcc/config/aarch64/constraints.md
+++ b/gcc/config/aarch64/constraints.md
@@ -158,14 +158,14 @@ (define_constraint "Usg"
   A constraint that matches an immediate right shift constant in SImode
   suitable for a SISD instruction."
   (and (match_code "const_int")
-   (match_test "IN_RANGE (ival, 1, 32)")))
+   (match_test "IN_RANGE (ival, 1, 31)")))
 
 (define_constraint "Usj"
   "@internal
   A constraint that matches an immediate right shift constant in DImode
   suitable for a SISD instruction."
   (and (match_code "const_int")
-   (match_test "IN_RANGE (ival, 1, 64)")))
+   (match_test "IN_RANGE (ival, 1, 63)")))
 
 (define_constraint "UsM"
   "@internal


Re: [PATCH] Prevent excessive loop-header copying with multiple exits

2018-04-27 Thread Richard Biener
On Thu, 26 Apr 2018, Richard Biener wrote:

> 
> The following makes loop-header copying stop after the first exit test
> it copied.  The reports rightfully complain about too much peeling.
> If some cases pop up which show we should peel up to a specific test
> we need to improve this heuristic which simply errs on the easy side.
> 
> Bootstrap & regtest running on x86_64-unknown-linux-gnu.

Bootstrap went ok but it showed a few required testsuite adjustments.

gcc.dg/tree-ssa/cunroll-13.c looks fragile (it was a test for a
profile mismatch), so I rewrote it as a GIMPLE testcase.

With the ivopt_mult_[12].c testcases IVOPTs no longer elminiates
an IV due to the change in IL -- what loop header copying does now
looks more sensible than before though, so I added GIMPLE testcase
variants that verify IVOPTs can still pull off the trick but I
had to XFAIL the C testcases (less IVs still look good and I fail
to see why the trick shouldn't work with the new IL - sth to
investigate).

Re-bootstrapping and testing on x86_64-unknown-linux-gnu now.

Richard.

2018-04-26  Richard Biener  

PR tree-optimization/28364
PR tree-optimization/85275
* tree-ssa-loop-ch.c (ch_base::copy_headers): Stop after
copying first exit test.

* gcc.dg/tree-ssa/copy-headers-5.c: New testcase.
* gcc.dg/tree-ssa/predcom-8.c: Likewise.
* gcc.dg/tree-ssa/cunroll-13.c: Rewrite to gimple testcase.
* gcc.dg/tree-ssa/ivopt_mult_1.c: XFAIL.
* gcc.dg/tree-ssa/ivopt_mult_1g.c: Add gimple variant that
still passes.
* gcc.dg/tree-ssa/ivopt_mult_2.c: XFAIL.
* gcc.dg/tree-ssa/ivopt_mult_2g.c: Add gimple variant that
still passes.
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Adjust.
* gcc.dg/tree-ssa/20030710-1.c: Likewise.
* gcc.dg/tree-ssa/20030711-1.c: Likewise.

Index: gcc/tree-ssa-loop-ch.c
===
--- gcc/tree-ssa-loop-ch.c  (revision 259695)
+++ gcc/tree-ssa-loop-ch.c  (working copy)
@@ -340,6 +340,11 @@ ch_base::copy_headers (function *fun)
  bbs[n_bbs++] = header;
  gcc_assert (bbs_size > n_bbs);
  header = exit->dest;
+ /* Make sure to stop copying after we copied the first exit test.
+Without further heuristics we do not want to rotate the loop
+any further.  */
+ if (loop_exits_from_bb_p (loop, exit->src))
+   break;
}
 
   if (!exit)
Index: gcc/testsuite/gcc.dg/tree-ssa/copy-headers-5.c
===
--- gcc/testsuite/gcc.dg/tree-ssa/copy-headers-5.c  (nonexistent)
+++ gcc/testsuite/gcc.dg/tree-ssa/copy-headers-5.c  (working copy)
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-ch2-details" } */
+
+int is_sorted(int *a, int n)
+{
+  for (int i = 0; i < n - 1; i++)
+if (a[i] > a[i + 1])
+  return 0;
+  return 1;
+}
+
+/* Verify we apply loop header copying but only copy the IV test and
+   not the alternate exit test.  */
+
+/* { dg-final { scan-tree-dump "is now do-while loop" "ch2" } } */
+/* { dg-final { scan-tree-dump-times "  if " 3 "ch2" } } */
Index: gcc/testsuite/gcc.dg/tree-ssa/predcom-8.c
===
--- gcc/testsuite/gcc.dg/tree-ssa/predcom-8.c   (nonexistent)
+++ gcc/testsuite/gcc.dg/tree-ssa/predcom-8.c   (working copy)
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-pcom-details" } */
+
+int is_sorted(int *a, int n)
+{
+  for (int i = 0; i < n - 1; i++)
+if (a[i] > a[i + 1])
+  return 0;
+  return 1;
+}
+
+/* { dg-final { scan-tree-dump "Executing predictive commoning without 
unrolling" "pcom" } } */
Index: gcc/testsuite/gcc.dg/tree-ssa/cunroll-13.c
===
--- gcc/testsuite/gcc.dg/tree-ssa/cunroll-13.c  (revision 259695)
+++ gcc/testsuite/gcc.dg/tree-ssa/cunroll-13.c  (working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O3 -fdisable-tree-evrp -fdisable-tree-cunrolli 
-fdisable-tree-vrp1 -fdump-tree-cunroll-blocks-details" } */
+/* { dg-options "-O3 -fgimple -fdump-tree-cunroll-blocks-details" } */
 
 #if __SIZEOF_INT__ < 4
 __extension__ typedef __INT32_TYPE__ i32;
@@ -7,15 +7,53 @@ __extension__ typedef __INT32_TYPE__ i32
 typedef int i32;
 #endif
 
-struct a {int a[8];int b;};
-void
-t(struct a *a)
+struct a {i32 a[8];i32 b;};
+
+void __GIMPLE (startwith("fix_loops"))
+t (struct a * a)
 {
-  for (i32 i=0;i<123456 && a->a[i];i++)
-a->a[i]++;
+  i32 i;
+  i32 _1;
+  i32 _2;
+  i32 _9;
+  i32 _11;
+
+bb_2:
+  _11 = a_6(D)->a[0];
+  if (_11 != _Literal (i32) 0)
+goto bb_6;
+  else
+goto bb_3;
+
+bb_3:
+  return;
+
+bb_4:
+  _1 = _2 + 1;
+  a_6(D)->a[i_19] = _1;
+  i_8 = i_19 + _Literal (i32) 1;
+  if (i_8 <= _Literal (i32) 123455)
+goto bb_5;
+  else
+goto bb_3;
+
+bb_5:
+

Re: PR85532, crtend.o built without --enable-initfini-array has bad .eh_frame

2018-04-27 Thread Alan Modra
On Fri, Apr 27, 2018 at 09:31:37AM +0200, Jakub Jelinek wrote:
> On Fri, Apr 27, 2018 at 02:27:40AM -0500, Segher Boessenkool wrote:
> > Hi Alan,
> > 
> > On Fri, Apr 27, 2018 at 10:49:14AM +0930, Alan Modra wrote:
> > > This patch is aimed at removing bogus .eh_frame info emitted after the
> > > zero terminator in crtend.o, which will cause a ld warning and slow
> > > exception handling.  The right fix for the PR is probably to change
> > > libgcc/Makefile.in to always supply -fno-asynchronous-unwind-tables
> > > when building crtbegin.o and crtend.o, since the utility of such
> > > unwind info is limited to say the least;  To what handler would you be
> > > unwinding to?
> > > 
> > > This patch instead carries on in the tradition of pr31868 and pr80037,
> > > and just fixes the problem for powerpc..  alpha, i386, s390, tilepro,
> > > tilegx already disable unwind info for these files.  Bootstrapped and
> > > regression tested powerpc64le-linux.  OK for master and gcc-8?
> > > 
> > >   PR libgcc/85532
> > >   * config/rs6000/t-crtstuff (CRTSTUFF_T_CFLAGS): Add
> > >   -fno-asynchronous-unwind-tables.
> > 
> > This is okay from the rs6000 perspective.  Please apply to trunk.  For
> > the 8 branch it is desirable too; RMs, is it okay for there?
> 
> Ok for 8.1.
> 
> Doesn't aarch64 need a similar change?

No.  aarch64 always uses .init_array/.fini_array, accomplished by
CTOR_LIST_BEGIN and other macros in gcc/config/aarch64/aarch64-elf.h.

-- 
Alan Modra
Australia Development Lab, IBM


[patch][i386] Goldmont -march/-mtune options

2018-04-27 Thread Makhotina, Olga
Hi,

This patch implements Goldmont -march/-mtune.

2018-04-27  Olga Makhotina  

gcc/

* config.gcc: Support "goldmont".
* config/i386/driver-i386.c (host_detect_local_cpu): Detect "goldmont".
* config/i386/i386-c.c (ix86_target_macros_internal): Handle
PROCESSOR_GOLDMONT.
* config/i386/i386.c (m_GOLDMONT): Define.
(processor_target_table): Add "goldmont".
(PTA_GOLDMONT): Define.
(ix86_lea_outperforms): Add TARGET_GOLDMONT.
(get_builtin_code_for_version): Handle PROCESSOR_GOLDMONT.
(fold_builtin_cpu): Add M_INTEL_GOLDMONT.
(fold_builtin_cpu): Add "goldmont".
(ix86_add_stmt_cost): Add TARGET_GOLDMONT.
(ix86_option_override_internal): Add "goldmont".
* config/i386/i386.h (processor_costs): Define TARGET_GOLDMONT.
(processor_type): Add PROCESSOR_GOLDMONT.
* config/i386/i386.md: Add CPU "glm".
* config/i386/glm.md: New file.
* config/i386/x86-tune.def: Add m_GOLDMONT.
* doc/invoke.texi: Add goldmont as x86 -march=/-mtune= CPU type.

libgcc/
* config/i386/cpuinfo.h (processor_types): Add INTEL_GOLDMONT.
* config/i386/cpuinfo.c (get_intel_cpu): Detect Goldmont.

gcc/testsuite/

* gcc.target/i386/builtin_target.c: Test goldmont.
* gcc.target/i386/funcspec-56.inc: Tests for arch=goldmont and
arch=silvermont.

Is it OK?

Thanks.


0001-goldmont.patch
Description: 0001-goldmont.patch


Re: PR85532, crtend.o built without --enable-initfini-array has bad .eh_frame

2018-04-27 Thread Jakub Jelinek
On Fri, Apr 27, 2018 at 02:27:40AM -0500, Segher Boessenkool wrote:
> Hi Alan,
> 
> On Fri, Apr 27, 2018 at 10:49:14AM +0930, Alan Modra wrote:
> > This patch is aimed at removing bogus .eh_frame info emitted after the
> > zero terminator in crtend.o, which will cause a ld warning and slow
> > exception handling.  The right fix for the PR is probably to change
> > libgcc/Makefile.in to always supply -fno-asynchronous-unwind-tables
> > when building crtbegin.o and crtend.o, since the utility of such
> > unwind info is limited to say the least;  To what handler would you be
> > unwinding to?
> > 
> > This patch instead carries on in the tradition of pr31868 and pr80037,
> > and just fixes the problem for powerpc..  alpha, i386, s390, tilepro,
> > tilegx already disable unwind info for these files.  Bootstrapped and
> > regression tested powerpc64le-linux.  OK for master and gcc-8?
> > 
> > PR libgcc/85532
> > * config/rs6000/t-crtstuff (CRTSTUFF_T_CFLAGS): Add
> > -fno-asynchronous-unwind-tables.
> 
> This is okay from the rs6000 perspective.  Please apply to trunk.  For
> the 8 branch it is desirable too; RMs, is it okay for there?

Ok for 8.1.

Doesn't aarch64 need a similar change?

Jakub


Re: PR85532, crtend.o built without --enable-initfini-array has bad .eh_frame

2018-04-27 Thread Segher Boessenkool
Hi Alan,

On Fri, Apr 27, 2018 at 10:49:14AM +0930, Alan Modra wrote:
> This patch is aimed at removing bogus .eh_frame info emitted after the
> zero terminator in crtend.o, which will cause a ld warning and slow
> exception handling.  The right fix for the PR is probably to change
> libgcc/Makefile.in to always supply -fno-asynchronous-unwind-tables
> when building crtbegin.o and crtend.o, since the utility of such
> unwind info is limited to say the least;  To what handler would you be
> unwinding to?
> 
> This patch instead carries on in the tradition of pr31868 and pr80037,
> and just fixes the problem for powerpc..  alpha, i386, s390, tilepro,
> tilegx already disable unwind info for these files.  Bootstrapped and
> regression tested powerpc64le-linux.  OK for master and gcc-8?
> 
>   PR libgcc/85532
>   * config/rs6000/t-crtstuff (CRTSTUFF_T_CFLAGS): Add
>   -fno-asynchronous-unwind-tables.

This is okay from the rs6000 perspective.  Please apply to trunk.  For
the 8 branch it is desirable too; RMs, is it okay for there?


Segher


> diff --git a/libgcc/config/rs6000/t-crtstuff b/libgcc/config/rs6000/t-crtstuff
> index 0b2601b..d5ff959 100644
> --- a/libgcc/config/rs6000/t-crtstuff
> +++ b/libgcc/config/rs6000/t-crtstuff
> @@ -3,4 +3,4 @@
>  # Do not build crtend.o with -Os as that can result in references to
>  # out-of-line register save/restore functions, which may be unresolved
>  # as crtend.o is linked after libgcc.a.  See PR45053.
> -CRTSTUFF_T_CFLAGS = -msdata=none -O2
> +CRTSTUFF_T_CFLAGS = -msdata=none -O2 -fno-asynchronous-unwind-tables
> 


gcc 8 trunk broken O3 on x86_64

2018-04-27 Thread graham stott via gcc-patches
All 
Just a heads the trunk has been broken since about Weds most files fail compare 
during bootstrap at O3 but pass at O2
My last succesful boostrap at O3 was Tuesday
I no idea which commit caused it
Graham

Re: [PATCH] Fix reassoc var_bound optimization (PR tree-optimization/85529)

2018-04-27 Thread Richard Biener
On Thu, 26 Apr 2018, Jakub Jelinek wrote:

> Hi!
> 
> As explained in the comment below, when doing the inter-bb range test
> optimization and are trying to optimize the
> a >= 0 && a < b
> where b is known to be >= 0 into
> (unsigned) a < (unsigned) b, we need to be careful if the a >= 0 condition
> is in a different bb from the a < b one and the a >= 0 bb dominates the
> block with the def stmt of b; then get_nonzero_bits can return flow
> dependent value range that isn't really valid if we optimize the a >= 0
> condition into true and modify the a < b condition to do unsigned
> comparison.
> 
> Unfortunately, giving up completely breaks some testcases in the testsuite
> distilled from real-world code, so the patch handles the most common cases
> where b is known to be non-negative no matter what, in particular
> zero extension and masking the MSB off.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and 8.1?
> Or do we want it for 8.2 only?
> The last testcase fails on 7.x branch too.

Looks good to me for 8.1, we eventually will need a RC2 anyways.

Thanks,
Richard.

> 2018-04-26  Jakub Jelinek  
> 
>   PR tree-optimization/85529
>   * tree-ssa-reassoc.c (optimize_range_tests_var_bound): Add FIRST_BB
>   argument.  Don't call get_nonzero_bits if opcode is ERROR_MARK_NODE,
>   rhs2 def stmt's bb is dominated by first_bb and it isn't an obvious
>   zero extension or masking of the MSB bit.
>   (optimize_range_tests): Add FIRST_BB argument, pass it through
>   to optimize_range_tests_var_bound.
>   (maybe_optimize_range_tests, reassociate_bb): Adjust
>   optimize_range_tests callers.
> 
>   * gcc.c-torture/execute/pr85529-1.c: New test.
>   * gcc.c-torture/execute/pr85529-2.c: New test.
>   * gcc.dg/pr85529.c: New test.
> 
> --- gcc/tree-ssa-reassoc.c.jj 2018-03-16 09:06:06.431752536 +0100
> +++ gcc/tree-ssa-reassoc.c2018-04-26 17:23:14.850769612 +0200
> @@ -3035,7 +3035,8 @@ optimize_range_tests_cmp_bitwise (enum t
>  static bool
>  optimize_range_tests_var_bound (enum tree_code opcode, int first, int length,
>   vec *ops,
> - struct range_entry *ranges)
> + struct range_entry *ranges,
> + basic_block first_bb)
>  {
>int i;
>bool any_changes = false;
> @@ -3143,6 +3144,60 @@ optimize_range_tests_var_bound (enum tre
>if (idx == NULL)
>   continue;
>  
> +  /* maybe_optimize_range_tests allows statements without side-effects
> +  in the basic blocks as long as they are consumed in the same bb.
> +  Make sure rhs2's def stmt is not among them, otherwise we can't
> +  use safely get_nonzero_bits on it.  E.g. in:
> +   # RANGE [-83, 1] NONZERO 173
> +   # k_32 = PHI 
> +  ...
> +   if (k_32 >= 0)
> + goto ; [26.46%]
> +   else
> + goto ; [73.54%]
> +
> +[local count: 140323371]:
> +   # RANGE [0, 1] NONZERO 1
> +   _5 = (int) k_32;
> +   # RANGE [0, 4] NONZERO 4
> +   _21 = _5 << 2;
> +   # RANGE [0, 4] NONZERO 4
> +   iftmp.0_44 = (char) _21;
> +   if (k_32 < iftmp.0_44)
> + goto ; [84.48%]
> +   else
> + goto ; [15.52%]
> +  the ranges on _5/_21/iftmp.0_44 are flow sensitive, assume that
> +  k_32 >= 0.  If we'd optimize k_32 >= 0 to true and k_32 < iftmp.0_44
> +  to (unsigned) k_32 < (unsigned) iftmp.0_44, then we would execute
> +  those stmts even for negative k_32 and the value ranges would be no
> +  longer guaranteed and so the optimization would be invalid.  */
> +  if (opcode == ERROR_MARK)
> + {
> +   gimple *g = SSA_NAME_DEF_STMT (rhs2);
> +   basic_block bb2 = gimple_bb (g);
> +   if (bb2
> +   && bb2 != first_bb
> +   && dominated_by_p (CDI_DOMINATORS, bb2, first_bb))
> + {
> +   /* As an exception, handle a few common cases.  */
> +   if (gimple_assign_cast_p (g)
> +   && INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (g)))
> +   && TYPE_UNSIGNED (TREE_TYPE (gimple_assign_rhs1 (g)))
> +   && (TYPE_PRECISION (TREE_TYPE (rhs2))
> +   > TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (g)
> + /* Zero-extension is always ok.  */ ;
> +   else if (is_gimple_assign (g)
> +&& gimple_assign_rhs_code (g) == BIT_AND_EXPR
> +&& TREE_CODE (gimple_assign_rhs2 (g)) == INTEGER_CST
> +&& !wi::neg_p (wi::to_wide (gimple_assign_rhs2 (g
> + /* Masking with INTEGER_CST with MSB clear is always ok
> +too.  */ ;
> +   else
> + continue;
> + }
> + }
> +
>wide_int nz = get_nonzero_bits (rhs2);
>if (wi::neg_p (nz))
>   continue;
> @@ -3269,11 +3324,12 @@ optimize_range_tests_var_bound (enum tre
> maybe_optimize_ra