Re: Fix lto-symtab ICE during Ada LTO bootstrap

2015-12-20 Thread Eric Botcazou
> I finally got around comitting the DCE patch so mainline lto bootstrap works
> up to this point.

Thanks!

> It would be great if you could take a look so we can get it finally fixed.

Let me commit a couple of Ada patches first and then I'll look into it.

-- 
Eric Botcazou


[Ada] Fix spurious warning in ASIS mode

2015-12-20 Thread Eric Botcazou
Tested on x86_64-suse-linux, applied on the mainline.


2015-12-20  Eric Botcazou  

* gcc-interface/utils.c (maybe_pad_type): In type_annotate_only mode,
retrieve the component type if this is an array and do not issue the
warning for concurrent types.

-- 
Eric BotcazouIndex: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 231856)
+++ gcc-interface/utils.c	(working copy)
@@ -1411,19 +1411,28 @@ maybe_pad_type (tree type, tree size, un
   rest_of_record_type_compilation (record);
 
 built:
-  /* If the size was widened explicitly, maybe give a warning.  Take the
- original size as the maximum size of the input if there was an
- unconstrained record involved and round it up to the specified alignment,
- if one was specified.  But don't do it if we are just annotating types
- and the type is tagged, since tagged types aren't fully laid out in this
- mode.  */
+  /* If a simple size was explicitly given, maybe issue a warning.  */
   if (!size
   || TREE_CODE (size) == COND_EXPR
   || TREE_CODE (size) == MAX_EXPR
-  || No (gnat_entity)
-  || (type_annotate_only && Is_Tagged_Type (Etype (gnat_entity
+  || No (gnat_entity))
 return record;
 
+  /* But don't do it if we are just annotating types and the type is tagged or
+ concurrent, since these types aren't fully laid out in this mode.  */
+  if (type_annotate_only)
+{
+  Entity_Id gnat_type
+	= is_component_type
+	  ? Component_Type (gnat_entity) : Etype (gnat_entity);
+
+  if (Is_Tagged_Type (gnat_type) || Is_Concurrent_Type (gnat_type))
+	return record;
+}
+
+  /* Take the original size as the maximum size of the input if there was an
+ unconstrained record involved and round it up to the specified alignment,
+ if one was specified, but only for aggregate types.  */
   if (CONTAINS_PLACEHOLDER_P (orig_size))
 orig_size = max_size (orig_size, true);
 


[Ada] Fix layout inconsistency in ASIS mode

2015-12-20 Thread Eric Botcazou
Tested on x86_64-suse-linux, applied on the mainline.


2015-12-20  Eric Botcazou  

* gcc-interface/decl.c (gnat_to_gnu_entity) : During
layout in type_annotate_only mode, skip discriminants of derived
tagged types renaming those of the parent type.
In type_annotate_only mode, if the type is tagged, do not override a
size clause but take into account the alignment of the tag.
(annotate_rep): In type_annotate_only mode, deal with  discriminants
of derived tagged types renaming those of the parent type.

-- 
Eric BotcazouIndex: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 231856)
+++ gcc-interface/decl.c	(working copy)
@@ -3181,6 +3181,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 		  && Present (Corresponding_Discriminant (gnat_field)))
 		continue;
 
+	  /* However, if we are just annotating types, the Parent_Subtype
+		 doesn't exist so we need skip the discriminant altogether.  */
+	  if (type_annotate_only
+		  && Is_Tagged_Type (gnat_entity)
+		  && Is_Derived_Type (gnat_entity)
+		  && Present (Corresponding_Discriminant (gnat_field)))
+		continue;
+
 	  gnu_field
 		= gnat_to_gnu_field (gnat_field, gnu_type, packed, definition,
  debug_info_p);
@@ -5321,15 +5329,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 
 	  /* If we are just annotating types and the type is tagged, the tag
 	 and the parent components are not generated by the front-end so
-	 sizes must be adjusted if there is no representation clause.  */
+	 alignment and sizes must be adjusted if there is no rep clause.  */
 	  if (type_annotate_only
 	  && Is_Tagged_Type (gnat_entity)
+	  && Unknown_RM_Size (gnat_entity)
 	  && !VOID_TYPE_P (gnu_type)
 	  && (!TYPE_FIELDS (gnu_type)
 		  || integer_zerop (bit_position (TYPE_FIELDS (gnu_type)
 	{
-	  tree pointer_size = bitsize_int (POINTER_SIZE), offset;
-	  Uint uint_size;
+	  tree offset;
 
 	  if (Is_Derived_Type (gnat_entity))
 		{
@@ -5338,7 +5346,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 		  Set_Alignment (gnat_entity, Alignment (gnat_parent));
 		}
 	  else
-		offset = pointer_size;
+		{
+		  unsigned int align
+		= MAX (TYPE_ALIGN (gnu_type), POINTER_SIZE) / BITS_PER_UNIT;
+		  offset = bitsize_int (POINTER_SIZE);
+		  Set_Alignment (gnat_entity, UI_From_Int (align));
+		}
 
 	  if (TYPE_FIELDS (gnu_type))
 		offset
@@ -5346,10 +5359,22 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 
 	  gnu_size = size_binop (PLUS_EXPR, gnu_size, offset);
 	  gnu_size = round_up (gnu_size, POINTER_SIZE);
-	  uint_size = annotate_value (gnu_size);
-	  Set_Esize (gnat_entity, uint_size);
+	  Uint uint_size = annotate_value (gnu_size);
 	  Set_RM_Size (gnat_entity, uint_size);
+	  Set_Esize (gnat_entity, uint_size);
+	}
+
+	  /* If there is a rep clause, only adjust alignment and Esize.  */
+	  else if (type_annotate_only && Is_Tagged_Type (gnat_entity))
+	{
+	  unsigned int align
+		= MAX (TYPE_ALIGN (gnu_type), POINTER_SIZE) / BITS_PER_UNIT;
+	  Set_Alignment (gnat_entity, UI_From_Int (align));
+	  gnu_size = round_up (gnu_size, POINTER_SIZE);
+	  Set_Esize (gnat_entity, annotate_value (gnu_size));
 	}
+
+	  /* Otherwise no adjustment is needed.  */
 	  else
 	Set_Esize (gnat_entity, annotate_value (gnu_size));
 	}
@@ -7933,12 +7958,19 @@ annotate_rep (Entity_Id gnat_entity, tre
 	  {
 	/* If there is no entry, this is an inherited component whose
 	   position is the same as in the parent type.  */
-	Set_Component_Bit_Offset
-	  (gnat_field,
-	   Component_Bit_Offset (Original_Record_Component (gnat_field)));
+	Entity_Id gnat_orig_field = Original_Record_Component (gnat_field);
 
-	Set_Esize (gnat_field,
-		   Esize (Original_Record_Component (gnat_field)));
+	/* If we are just annotating types, discriminants renaming those of
+	   the parent have no entry so deal with them specifically.  */
+	if (type_annotate_only
+		&& gnat_orig_field == gnat_field
+		&& Ekind (gnat_field) == E_Discriminant)
+	  gnat_orig_field = Corresponding_Discriminant (gnat_field);
+
+	Set_Component_Bit_Offset (gnat_field,
+  Component_Bit_Offset (gnat_orig_field));
+
+	Set_Esize (gnat_field, Esize (gnat_orig_field));
 	  }
   }
 }


[Ada] Fix ICE on component of complex as Out parameter

2015-12-20 Thread Eric Botcazou
This is a regression present on the mainline only, a small oversight in the 
overhaul of the implementation of renaming.

Tested on x86_64-suse-linux, applied on the mainline.


2015-12-20  Eric Botcazou  

* gcc-interface/utils2.c (gnat_rewrite_reference) : New
case identical to FLOAT_EXPR.
: Likewise.


2015-12-20  Eric Botcazou  

* gnat.dg/complex1.adb: New test.
* gnat.dg/complex1_pkg.ads: New helper.


-- 
Eric BotcazouIndex: gcc-interface/utils2.c
===
--- gcc-interface/utils2.c	(revision 231856)
+++ gcc-interface/utils2.c	(working copy)
@@ -2664,6 +2664,8 @@ gnat_rewrite_reference (tree ref, rewrit
 CASE_CONVERT:
 case FLOAT_EXPR:
 case FIX_TRUNC_EXPR:
+case REALPART_EXPR:
+case IMAGPART_EXPR:
 case VIEW_CONVERT_EXPR:
   result
 	= build1 (code, type,
-- { dg-do compile }

with Ada.Numerics.Complex_types; use Ada.Numerics.Complex_types;
with Complex1_Pkg; use Complex1_Pkg;

procedure Complex1 is
  Z : Complex;
begin
  Coord (Z.Re, Z.Im);
end;
package Complex1_Pkg is

  procedure Coord (x,y : out Float);

end Complex1_Pkg;


Re: [PATCH, i386] Introduce support for PKU instructions.

2015-12-20 Thread Uros Bizjak
On Fri, Dec 18, 2015 at 8:15 AM, Kirill Yukhin  wrote:
> Hello,
> Patch in the bottom introduces support Intel PKRU instructions:
> rdpkru and wrpkru.
> It is pretty straight-forward, so I hope it is still suitable for v6.
>
> Names for new intrinsics will appear shortly in new revision of SDM.
>
> Bootstrapped & regtested.
>
> Is it ok for trunk?

The patch mostly looks OK, but md patterns are written in the wrong
way. Please see comments bellow.

> gcc/
> * common/config/i386/i386-common.c (OPTION_MASK_ISA_PKU_SET): New.
> (OPTION_MASK_ISA_PKU_UNSET): Ditto.
> (ix86_handle_option): Handle OPT_mpku.
> * config.gcc: Add pkuintrin.h to i[34567]86-*-* and x86_64-*-*
> targets.
> * config/i386/cpuid.h (host_detect_local_cpu): Detect PKU feature.
> * config/i386/i386-c.c (ix86_target_macros_internal): Handle PKU ISA
> flag.
> * config/i386/i386.c (ix86_target_string): Add "-mpku" to
> ix86_target_opts.
> (ix86_option_override_internal): Define PTA_PKU, mention new key
> in skylake-avx512. Handle new ISA bits.
> (ix86_valid_target_attribute_inner_p): Add "pku".
> (enum ix86_builtins): Add IX86_BUILTIN_RDPKRU and IX86_BUILTIN_WRPKRU.
> (builtin_description bdesc_special_args[]): Add new built-ins.
> * config/i386/i386.h (define TARGET_PKU): New.
> (define TARGET_PKU_P): Ditto.
> * config/i386/i386.md (define_c_enum "unspec"): Add UNSPEC_PKU.
> (define_c_enum "unspecv"): Add UNSPECV_PKU.
> (define_expand "rdpkru"): New.
> (define_insn "rdpkru_2"): Ditto.
> (define_expand "wrpkru"): Ditto.
> (define_insn "wrpkru_2"): Ditto.
> * config/i386/i386.opt (mpku): Ditto.
> * config/i386/pkuintrin.h: New file.
> * config/i386/x86intrin.h: Include pkuintrin.h
> * doc/extend.texi: Describe new built-ins.
> * doc/invoke.texi: Describe new switches.
>
> gcc/testsuite/
> * g++.dg/other/i386-2.C: Add -mpku.
> * g++.dg/other/i386-3.C: Ditto.
> * gcc.target/i386/rdpku-1.c: New test.
> * gcc.target/i386/sse-12.c: Add -mpku.
> * gcc.target/i386/sse-13.c: Ditto..
> * gcc.target/i386/sse-22.c: Ditto..
> * gcc.target/i386/sse-33.c: Ditto..
> * gcc.target/i386/wrpku-1.c: New test.
>

> +(define_expand "rdpkru"
> +  [(set (match_operand:SI 0 "register_operand")
> +   (unspec:SI [(const_int 0)] UNSPEC_PKU))
> +   (set (reg:SI CX_REG)
> +   (const_int 0))
> +   (clobber (reg:SI DX_REG))]
> +  "TARGET_PKU"
> +{
> +  emit_move_insn (gen_rtx_REG (SImode, CX_REG), CONST0_RTX (SImode));
> +  emit_insn (gen_rdpkru_2 (operands[0]));
> +  DONE;
> +})

You should use "parallel" to emit insn with several parallel
expressions. So, in the preparation statements, you move const0 to a
pseudo, so the RA will later use correct register. And please leave to
the expander to emit the pattern.

> +(define_insn "rdpkru_2"
> +  [(set (match_operand:SI 0 "register_operand" "=a")
> +   (unspec:SI [(const_int 0)] UNSPEC_PKU))
> +   (clobber (reg:SI DX_REG))
> +   (use (reg:SI CX_REG))]
> +  "TARGET_PKU"
> +  "rdpkru"
> +  [(set_attr "type" "other")])

Please do not use explicit hard registers. There are appropriate
single-reg constraints available for use. Without seeing the
documentation, I think the above should look like:

(define_insn "*rdpkru"
  [(set (match_operand:SI 0 "register_operand" "=a")
   (unspec:SI [(match_operand:SI 1 "register_operand" "c")] UNSPEC_PKU))
   (clobber (rmatch_operand "register_operand "=d"))
  "TARGET_PKU"
  "rdpkru"
  [(set_attr "type" "other")])

> +(define_expand "wrpkru"
> +  [(unspec_volatile:SI [(match_operand:SI 0 "register_operand")] UNSPECV_PKU)
> +   (set (reg:SI CX_REG)
> +   (const_int 0))
> +   (set (reg:SI DX_REG)
> +   (const_int 0))]
> +  "TARGET_PKU"
> +{
> +  emit_move_insn (gen_rtx_REG (SImode, CX_REG), CONST0_RTX (SImode));
> +  emit_move_insn (gen_rtx_REG (SImode, DX_REG), CONST0_RTX (SImode));
> +  emit_insn (gen_wrpkru_2 (operands[0]));
> +  DONE;
> +})
> +
> +(define_insn "wrpkru_2"
> +  [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "a")] 
> UNSPECV_PKU)
> +   (use (reg:SI CX_REG))
> +   (use (reg:SI DX_REG))]
> +  "TARGET_PKU"
> +  "wrpkru"
> +  [(set_attr "type" "other")])
>
Please move all input operands to the insisde of the unspec, but it
looks that this pattern is missing clobber, as in the above rdpkru
pattern.

Uros.


Re: [Patch, fortran] [6 Regression] ICE: in gfc_get_descriptor_dimension, at fortran/trans-array.c:268

2015-12-20 Thread Dominique d'Humières
Dear Paul,
> This is a rather trivial patch... going on 'obvious' in fact. However,
> I must confess to not being entirely sure why the problem is
> occurring. Deferred arrays are emanating from the finalizer that are
> being presented as ARRAY_TYPES rather than descriptors. What ever is
> the reason, the fix is both safe and does what is required.
The patch works as advertised. However the test should be either compile only, 
or "dejagnufied".

Cheers,

Dominique



Re: [PATCH] shrink-wrap: Once more PRs 67778, 68634, and now 68909

2015-12-20 Thread Segher Boessenkool
On Fri, Dec 18, 2015 at 02:19:37AM +0100, Bernd Schmidt wrote:
> On 12/17/2015 10:07 PM, Segher Boessenkool wrote:
> >It turns out v4 wasn't quite complete anyway; so here "v5".
> >
> >If a candidate PRE cannot get the prologue because a block BB is
> >reachable from it, but PRE does not dominate BB, we try again with the
> >dominators of PRE.  That "try again" needs to again consider BB though,
> >we aren't done with it.
> >
> >This fixes this problem.  Tested on the 68909 testcase, and bootstrapped
> >and regression checked on powerpc64-linux.  Is this okay for trunk?
> 
> This code is getting really quite confusing,

Yes :-(  I don't think stage 3 is the time to completely rewrite it though.

> and at the least I think we 
> need more documentation of what exactly vec is supposed to contain at 
> the entry to the inner while loop here.

Same as in the other loop: vec is a stack of blocks that still need to
be looked at.  I can duplicate the comment if you want?

> I'm also beginning to think we should disable this part of the code for 
> gcc-6.

That would be a regression (from GCC 5); but I understand your worry.
How about we disable it if any further problems show up?


Segher


2 C++ PATCHes for c++/67411 (const var in generic lambda)

2015-12-20 Thread Jason Merrill
Our treatment of references to outer const variables in lambdas has been 
to defer deciding whether or not to capture them until instantiation 
time, at which point their initializers will have been processed.  But 
that doesn't work for generic lambdas, since by the time we instantiate 
the lambda call operator the closure class is already complete, so we 
can't add any captures.


The first patch deals with this specifically for the case of a capture 
proxy (as in the bug report), which is const unless the lambda is 
declared mutable; a capture proxy can never be used in a constant 
expression, so decl_maybe_const_var_p should return false.


The second patch deals with this more generally, for constant variables 
within a generic lambda.  There are two changes: First, within a generic 
lambda we try harder to extract a constant value from a variable by way 
of instantiate_non_dependent_expr.  If that fails, we capture the variable.


Longer term we need to reconsider our model for generic lambdas in 
templates, as really we ought to partially instantiate the lambda body 
when its context is instantiated.


Tested x86_64-pc-linux-gnu, applying to trunk.  First patch applying to 
5 as well.
commit 6804dee422ff9a85298a24ae0912e82ed0d7e988
Author: Jason Merrill 
Date:   Thu Dec 17 15:41:32 2015 -0500

	PR c++/67411

	* decl2.c (decl_maybe_constant_var_p): A proxy isn't constant.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 5ae6266..1e4282a 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4222,6 +4222,9 @@ decl_maybe_constant_var_p (tree decl)
 return false;
   if (DECL_DECLARED_CONSTEXPR_P (decl))
 return true;
+  if (DECL_VALUE_EXPR (decl))
+/* A proxy isn't constant.  */
+return false;
   return (CP_TYPE_CONST_NON_VOLATILE_P (type)
 	  && INTEGRAL_OR_ENUMERATION_TYPE_P (type));
 }
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-const1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-const1.C
new file mode 100644
index 000..8b54578
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-const1.C
@@ -0,0 +1,18 @@
+// PR c++/67411
+// { dg-do compile { target c++14 } }
+
+template 
+void f()
+{
+  int i = 42;
+  [x = i] {
+[&](auto) {
+  [=] { return x; }();
+}(1);
+  }();
+}
+
+int main()
+{
+  f();
+}
commit 025bb7af15ee0f0468e9b111a144ec3350aed22a
Author: Jason Merrill 
Date:   Fri Dec 18 23:02:11 2015 -0500

	PR c++/67411

	* lambda.c (generic_lambda_fn_p): Split out from...
	(maybe_add_lambda_conv_op): ...here.
	* semantics.c (process_outer_var_ref): Don't defer maybe-constant
	variables in a generic lambda.
	* pt.c (instantiate_non_dependent_or_null): New.
	* init.c (constant_value_1): Use it.
	* cp-tree.h: Declare it and generic_lambda_fn_p.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 058324f..f0f7e36c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6158,6 +6158,7 @@ extern bool reregister_specialization		(tree, tree, tree);
 extern tree instantiate_non_dependent_expr	(tree);
 extern tree instantiate_non_dependent_expr_sfinae (tree, tsubst_flags_t);
 extern tree instantiate_non_dependent_expr_internal (tree, tsubst_flags_t);
+extern tree instantiate_non_dependent_or_null   (tree);
 extern bool variable_template_specialization_p  (tree);
 extern bool alias_type_or_template_p(tree);
 extern bool alias_template_specialization_p (const_tree);
@@ -6473,6 +6474,7 @@ extern tree maybe_resolve_dummy			(tree, bool);
 extern tree current_nonlambda_function		(void);
 extern tree nonlambda_method_basetype		(void);
 extern tree current_nonlambda_scope		(void);
+extern bool generic_lambda_fn_p			(tree);
 extern void maybe_add_lambda_conv_op(tree);
 extern bool is_lambda_ignored_entity(tree);
 
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 1d5cc65..09c1183 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2080,6 +2080,8 @@ constant_value_1 (tree decl, bool strict_p, bool return_aggregate_cst_ok_p)
 	  && TREE_CODE (init) == TREE_LIST
 	  && TREE_CHAIN (init) == NULL_TREE)
 	init = TREE_VALUE (init);
+  /* Instantiate a non-dependent initializer.  */
+  init = instantiate_non_dependent_or_null (init);
   if (!init
 	  || !TREE_TYPE (init)
 	  || !TREE_CONSTANT (init)
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 8d1ee14..d50e48d 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -851,6 +851,16 @@ prepare_op_call (tree fn, int nargs)
   return t;
 }
 
+/* Return true iff CALLOP is the op() for a generic lambda.  */
+
+bool
+generic_lambda_fn_p (tree callop)
+{
+  return (LAMBDA_FUNCTION_P (callop)
+	  && DECL_TEMPLATE_INFO (callop)
+	  && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (callop)));
+}
+
 /* If the closure TYPE has a static op(), also add a conversion to function
pointer.  */
 
@@ -867,9 +877,7 @@ maybe_add_lambda_conv_op (tree type)
   if (processing_template_decl)
 return;
 
-  bool const generic_lambda_p
-= (DECL_T

Re: 2 C++ PATCHes for c++/67411 (const var in generic lambda)

2015-12-20 Thread Jakub Jelinek
On Sun, Dec 20, 2015 at 01:34:51PM -0500, Jason Merrill wrote:
> commit 6804dee422ff9a85298a24ae0912e82ed0d7e988
> Author: Jason Merrill 
> Date:   Thu Dec 17 15:41:32 2015 -0500
> 
>   PR c++/67411
> 
>   * decl2.c (decl_maybe_constant_var_p): A proxy isn't constant.
> 
> diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
> index 5ae6266..1e4282a 100644
> --- a/gcc/cp/decl2.c
> +++ b/gcc/cp/decl2.c
> @@ -4222,6 +4222,9 @@ decl_maybe_constant_var_p (tree decl)
>  return false;
>if (DECL_DECLARED_CONSTEXPR_P (decl))
>  return true;
> +  if (DECL_VALUE_EXPR (decl))
> +/* A proxy isn't constant.  */
> +return false;

Shouldn't this be DECL_HAS_VALUE_EXPR_P (decl) instead?
Or are you for proxies doing SET_DECL_VALUE_EXPR without setting
DECL_HAS_VALUE_EXPR_P bit?  DECL_HAS_VALUE_EXPR_P is very cheap,
while DECL_VALUE_EXPR is a hash table lookup.

>return (CP_TYPE_CONST_NON_VOLATILE_P (type)
> && INTEGRAL_OR_ENUMERATION_TYPE_P (type));
>  }

Jakub


[Committed/AARCH64] Fix a few failures with LSE enabled

2015-12-20 Thread Andrew Pinski
Hi,
 With LSE enabled by default a few failures in libgomp happen.
The shortest testcase I came up with was:
extern void abort (void);
int x = 6;
int f(void) __attribute__((noinline,noclone));
int f(void)
{
  return 32;
}

int
main ()
{
  int v, l = 2, s = 1;
  x = f();
  #pragma omp atomic capture
v = x = 5 | x;
  if (v != 37)
abort ();
  return 0;
}
--- CUT ---
What happen was register allocator decided to use the same register
for the input as the clobber register:
Before:
(insn 13 12 14 2 (parallel [
(set (reg:SI 74 [ _5 ])
(ior:SI (mem/v:SI (reg/f:DI 76) [-1  S4 A32])
(reg:SI 80)))
(set (mem/v:SI (reg/f:DI 76) [-1  S4 A32])
(unspec_volatile:SI [
(mem/v:SI (reg/f:DI 76) [-1  S4 A32])
(reg:SI 80)
(const_int 0 [0])
] UNSPECV_ATOMIC_LDOP))
(clobber (scratch:SI))
]) t.c:14 2895 {aarch64_atomic_or_fetchsi_lse}
 (expr_list:REG_DEAD (reg:SI 80)
(expr_list:REG_DEAD (reg/f:DI 76)
(nil

After:
(insn 13 12 14 2 (parallel [
(set (reg:SI 2 x2 [orig:74 _5 ] [74])
(ior:SI (mem/v:SI (reg/f:DI 1 x1 [76]) [-1  S4 A32])
(reg:SI 0 x0 [80])))
(set (mem/v:SI (reg/f:DI 1 x1 [76]) [-1  S4 A32])
(unspec_volatile:SI [
(mem/v:SI (reg/f:DI 1 x1 [76]) [-1  S4 A32])
(reg:SI 0 x0 [80])
(const_int 0 [0])
] UNSPECV_ATOMIC_LDOP))
(clobber (reg:SI 0 x0 [82]))
]) t.c:14 2895 {aarch64_atomic_or_fetchsi_lse}
 (nil))

And split came along and used the clobber register as a temporary to
store the the result of the ldset and then did an or with that
register and the original input register.

This is incorrect as the clobber register needs to be marked as early
clobber so it does not match up with the input register.

This obvious patch fixes the problem by marking the clobber register
as an early clobber so the register allocator does not choose the same
register as an input register.

Committed as obvious after a bootstrap/test on aarch64-linux-gnu
configured with/without --with-cpu=thunderx+lse on a pass 2 ThunderX
CPU (which has ARMv8.1 support).

Thanks,
Andrew

ChangeLog:
2015-12-20  Andrew Pinsi  

* config/aarch64/atomics.md
(aarch64_atomic__fetch_lse): Add early clobber
to the scratch register.
Index: config/aarch64/atomics.md
===
--- config/aarch64/atomics.md   (revision 231852)
+++ config/aarch64/atomics.md   (working copy)
@@ -428,7 +428,7 @@
(match_dup 2)
(match_operand:SI 3 "const_int_operand")]
   UNSPECV_ATOMIC_LDOP))
- (clobber (match_scratch:ALLI 4 "=r"))]
+ (clobber (match_scratch:ALLI 4 "=&r"))]
   "TARGET_LSE"
   "#"
   "&& reload_completed"


Re: Fix lto-symtab ICE during Ada LTO bootstrap

2015-12-20 Thread Eric Botcazou
> BTW for the LTO type merging issues one could probably just drop those types
> and all derivations to alias set 0. But indeed rewriting them to pointers
> would be better, especially for ABI compatibility.
> 
> The Ada ICE I get is:
> Continuing.
> +===GNAT BUG DETECTED==+
> | 6.0.0 20151122 (experimental) (x86_64-pc-linux-gnu) Assert_Failure
> | atree.adb:6776| Error detected at system.ads:107:4   

It's apparently another bug in the DCE pass.  From:

  :
  # DEBUG id => e_186
  _11422 = atree__unchecked_access__node4.localalias.3007 (e_186);

  :
  # DEBUG id => NULL
  # DEBUG n => _11422
  # DEBUG n => NULL
  if (_11422 == 0)
goto  ();
  else
goto ;

in phicprop2, we have in cddce2:

Deleting : if (_11422 == 0)

and then:

  :
  # DEBUG id => e_186
  _11422 = atree__unchecked_access__node4.localalias.3007 (e_186);

  :
  # DEBUG id => NULL
  # DEBUG n => _11422
  # DEBUG n => NULL
  # DEBUG id => e_186
  goto ;

which is wrong since it's the only exit of the loop in sem_prag.adb:22878:

   loop
  Set_Warnings_Off
(E, (Chars (Get_Pragma_Arg (Arg1)) =
  Name_Off));

  --  For OFF case, make entry in warnings off
  --  pragma table for later processing. But we do
  --  not do that within an instance, since these
  --  warnings are about what is needed in the
  --  template, not an instance of it.

  if Chars (Get_Pragma_Arg (Arg1)) = Name_Off
and then Warn_On_Warnings_Off
and then not In_Instance
  then
 Warnings_Off_Pragmas.Append ((N, E, Reason));
  end if;

  if Is_Enumeration_Type (E) then
 declare
Lit : Entity_Id;
 begin
Lit := First_Literal (E);
while Present (Lit) loop
   Set_Warnings_Off (Lit);
   Next_Literal (Lit);
end loop;
 end;
  end if;

  exit when No (Homonym (E));
  E := Homonym (E);
   end loop;

Note that the change you installed is not exactly the patch you had posted, it 
contains an additional hunk:

@@ -134,7 +137,7 @@ mark_stmt_necessary (gimple *stmt, bool
   gimple_set_plf (stmt, STMT_NECESSARY, true);
   if (add_to_worklist)
 worklist.safe_push (stmt);
-  if (bb_contains_live_stmts && !is_gimple_debug (stmt))
+  if (add_to_worklist && bb_contains_live_stmts && !is_gimple_debug (stmt))
 bitmap_set_bit (bb_contains_live_stmts, gimple_bb (stmt)->index);
 }
 
which is not documented in the installed ChangeLog either.

-- 
Eric Botcazou


Re: 2 C++ PATCHes for c++/67411 (const var in generic lambda)

2015-12-20 Thread Jason Merrill

On 12/20/2015 01:51 PM, Jakub Jelinek wrote:

Shouldn't this be DECL_HAS_VALUE_EXPR_P (decl) instead?


Good point.  Fixed.

Jason




Re: [RFA][PATCH][PR tree-optimization/64910] x86 backend improvement

2015-12-20 Thread Jeff Law

On 12/19/2015 11:06 AM, Uros Bizjak wrote:

Hello!

+ 2015-12-19  Jeff Law  
+
+ PR tree-optimization/64910
+ * config/i386/i386.md (testqi_ext_3): Allow HImode.

OK for mainline and branch.
Thanks.  I double-checked and gcc-5 has not regressed, presumably 
there's an additional interaction that's causing this to only manifest 
on the trunk.  Perhaps in combine or in the optabs bits that figure out 
the modes to use on these insns.


Given gcc-5 isn't regressing, I didn't install the patch on the branch.

Jeff