Re: [PATCH] allow setting LDFLAGS_FOR_TARGET in top-level configuration.

2011-05-09 Thread Paolo Bonzini

On 05/09/2011 04:38 AM, Doug Kwan (關振德) wrote:

Sorry, forgot the patch and the ChangeLog

2011-05-08  Doug Kwan

* configure.ac: Propagate LDFLAGS_FOR_TARGET.
* configure: Regenerated.
* Makefile.tpl (LDFLAGS_FOR_TARGET): Use LDFLAGS_FOR_TARGET
value from configure.
* Makefile.in: Regenerated.


Ok.

Paolo


Re: Minor type merging optimization

2011-05-09 Thread Jan Hubicka
> On Fri, May 6, 2011 at 10:24 PM, Jan Hubicka  wrote:
> > Hi,
> > while looking at type merging code I noticed that type pairs can be managed
> > to be ordered by their UIDs.  This save some of hashing overhead in one of
> > most intensively querried hashes.
> >
> > Also gimple_lookup_type_leader is hot function that is better to be inlined.
> >
> > I also wonder, why unionfind algorithm is not used here to maintain the
> > positive answers?
> 
> Can you elaborate?

Well, just use unionfind to record the equivalences found and then
prior checking the hashtable ask it for equivalence class representative.
Either you will already find that the pairs are equivalent (in faster
way than by querying the hash) or you at least save the memory by caching
the negative andwers only across the equivalence classes.

I hacked quick unionfind two days ago, but the stopper is that the cache
is temporarily caching equilvaences in SCC regions.  You mentioned it is no
longer neccesary, so perhaps if you send me patch to remove this, I can give
a try to this idea.

Honza


Re: [pph] Allow streamer to define unique INTEGER_CST nodes (issue4489044)

2011-05-09 Thread Richard Guenther
On Fri, 6 May 2011, Diego Novillo wrote:

> 
> I'm not altogether happy with this approach, so I'm looking for
> suggestions on how to address this issue.
> 
> The front end defines a bunch of unique constants in c_global_trees
> that are not meant to be shared and are subject to pointer comparisons
> throughout the front end.  Morevoer, some constants do not even have a
> "valid" type.  For instance, void_zero_node has type void, which
> build_int_cst_wide refuses to build.  So, we were ICEing when trying
> to materialize these functions in the reader.
> 
> Other constants are fine, but they are pointer-compared against
> c_global_trees[], so I need them to be materialized into the same
> address.
> 
> Initially, I thought I would just make the streamer treat constants
> the same as any other tree node, but this increases the size of the
> on-disk representation.  Writing cache references for constants takes
> more space.  It was also quite invasive, I was introducing regressions
> in LTO and having a perfectly horrible time with it.
> 
> The approach I ended up taking is to allow the streamer to declare
> that it has some INTEGER_CSTs that need to be unique.  Since those
> unique constants are preloaded in the cache, we can simply stream
> references to them if we find a match.
> 
> So, regular constants are streamed like always, but unique constants
> are streamed as cache references.  This does not affect the gimple
> streamer and allows the C++ FE to preload these constants in the cache
> and continue to use pointer equality throughout the parser.
> 
> This was the least invasive and quick solution I could come up for
> now.  Any other ideas?

We have the same issue for va_list_type_node which is compared
by equality, too, but may be merged with other types.  I thought
about inventing sth similar to builtin function codes for such
stuff ...

But I'm not sure that's really the way to go.  At least the problem
sounds similar to yours.

Richard.

> Tested on x86_64.  Committed to pph.
> 
> 
> Diego.
> 
> cp/ChangeLog.pph
> 
>   * pph-streamer.c (pph_stream_hooks_init): Set
>   has_unique_integer_csts_p field to true.
> 
> ChangeLog.pph
> 
>   * lto-streamer-out.c (lto_output_tree): If the streamer
>   has unique INTEGER_CST nodes and a match is found in the
>   streamer cache, do not call lto_output_integer_cst.
>   * lto-streamer.h (struct lto_streamer_hooks): Add field
>   has_unique_integer_csts_p.
> 
> diff --git a/gcc/cp/pph-streamer.c b/gcc/cp/pph-streamer.c
> index efac32e..18a5e25 100644
> --- a/gcc/cp/pph-streamer.c
> +++ b/gcc/cp/pph-streamer.c
> @@ -101,6 +101,7 @@ pph_stream_hooks_init (void)
>h->unpack_value_fields = pph_stream_unpack_value_fields;
>h->alloc_tree = pph_stream_alloc_tree;
>h->output_tree_header = pph_stream_output_tree_header;
> +  h->has_unique_integer_csts_p = true;
>  }
>  
>  
> diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
> index b578419..a7f0965 100644
> --- a/gcc/lto-streamer-out.c
> +++ b/gcc/lto-streamer-out.c
> @@ -1387,8 +1387,27 @@ lto_output_tree (struct output_block *ob, tree expr, 
> bool ref_p)
>   to be materialized by the reader (to implement TYPE_CACHED_VALUES).  */
>if (TREE_CODE (expr) == INTEGER_CST)
>  {
> -  lto_output_integer_cst (ob, expr, ref_p);
> -  return;
> +  bool is_special;
> +
> + /* There are some constants that are special to the streamer
> + (e.g., void_zero_node, truthvalue_false_node).
> + These constants cannot be rematerialized with
> + build_int_cst_wide because they may actually lack a type (like
> + void_zero_node) and they need to be pointer-identical to trees
> + materialized by the compiler tables like global_trees or
> + c_global_trees.
> +
> + If the streamer told us that it has special constants, they
> + will be preloaded in the streamer cache.  If we find a match,
> + then stream the constant as a reference so the reader can
> + re-materialize it from the cache.  */
> +  is_special = streamer_hooks ()->has_unique_integer_csts_p
> +&& lto_streamer_cache_lookup (ob->writer_cache, expr, NULL);
> +  if (!is_special)
> + {
> +   lto_output_integer_cst (ob, expr, ref_p);
> +   return;
> + }
>  }
>  
>existed_p = lto_streamer_cache_insert (ob->writer_cache, expr, &ix);
> diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
> index 8be17da..9b64619 100644
> --- a/gcc/lto-streamer.h
> +++ b/gcc/lto-streamer.h
> @@ -113,6 +113,12 @@ typedef struct lto_streamer_hooks {
>   global symbol tables.  */
>unsigned register_decls_in_symtab_p : 1;
>  
> +  /* Non-zero if the streamer has special constants that cannot be
> + shared and are used in pointer-equality tests (e.g., void_zero_node,
> + truthvalue_false_node, etc).  These constants will be present in
> + the streamer cache and should be streamed as references.  */
> +  unsigned has_unique_intege

Re: fix up hot/cold partitioning on ports that don't have long conditional branches

2011-05-09 Thread Eric Botcazou
[Sorry for the delay]

> > The patch contains long lines.
>
> Didn't know we had switched over to caring that much.  Want me to fix all
> of gcc/*.[ch]?

Nope, just not introduce new long lines.

> Ok?

Almost.  It looks like we now pass twice the same argument to follow_jumps, 
i.e. we have LABEL == JUMP_LABEL (JUMP).  So I'd just pass JUMP:


  /* Follow any unconditional jump at JUMP's target label; return the ultimate
 label reached by any such chain of jumps.  If the target label is not
 followed by a jump, return it.  If the chain loops or we can't find end,
 return it as well, since that tells the caller to avoid changing the insn.
 If the chain of jumps ever crosses a section boundary, and the port
 doesn't have long condition branches and JUMP is a conditional branch,
 return the first such label before any such crossing.  */
 
 static rtx
-follow_jumps (rtx label)
+follow_jumps (rtx jump)


+  /* If a label crosses a section boundary and we're thinking
+about changing a conditional jump to be a conditional jump
+across that boundary, don't do it if the port doesn't have
+long conditional branches.  We can however jump to the label
+just before we cross such a boundary.  */
+  if (!HAS_LONG_COND_BRANCH
+ && find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)
+ && any_condjump_p (jump))
+   return value;

"If a jump crosses a..."


  if (target_label && next_active_insn (target_label) == next
- && ! condjump_in_parallel_p (insn))
+ && ! condjump_in_parallel_p (insn)
+ && find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX) == NULL_RTX)

Either !find_reg_note here or find_reg_note (...) != NULL_RTX above.


-- 
Eric Botcazou


Re: Minor type merging optimization

2011-05-09 Thread Richard Guenther
On Mon, 9 May 2011, Jan Hubicka wrote:

> > On Fri, May 6, 2011 at 10:24 PM, Jan Hubicka  wrote:
> > > Hi,
> > > while looking at type merging code I noticed that type pairs can be 
> > > managed
> > > to be ordered by their UIDs.  This save some of hashing overhead in one of
> > > most intensively querried hashes.
> > >
> > > Also gimple_lookup_type_leader is hot function that is better to be 
> > > inlined.
> > >
> > > I also wonder, why unionfind algorithm is not used here to maintain the
> > > positive answers?
> > 
> > Can you elaborate?
> 
> Well, just use unionfind to record the equivalences found and then
> prior checking the hashtable ask it for equivalence class representative.
> Either you will already find that the pairs are equivalent (in faster
> way than by querying the hash) or you at least save the memory by caching
> the negative andwers only across the equivalence classes.
> 
> I hacked quick unionfind two days ago, but the stopper is that the cache
> is temporarily caching equilvaences in SCC regions.  You mentioned it is no
> longer neccesary, so perhaps if you send me patch to remove this, I can give
> a try to this idea.

I think we already do exactly this.

Richard.

Re: Minor type merging optimization

2011-05-09 Thread Richard Guenther
On Mon, 9 May 2011, Jan Hubicka wrote:

> > On Fri, May 6, 2011 at 10:24 PM, Jan Hubicka  wrote:
> > > Hi,
> > > while looking at type merging code I noticed that type pairs can be 
> > > managed
> > > to be ordered by their UIDs.  This save some of hashing overhead in one of
> > > most intensively querried hashes.
> > >
> > > Also gimple_lookup_type_leader is hot function that is better to be 
> > > inlined.
> > >
> > > I also wonder, why unionfind algorithm is not used here to maintain the
> > > positive answers?
> > 
> > Can you elaborate?
> 
> Well, just use unionfind to record the equivalences found and then
> prior checking the hashtable ask it for equivalence class representative.
> Either you will already find that the pairs are equivalent (in faster
> way than by querying the hash) or you at least save the memory by caching
> the negative andwers only across the equivalence classes.
> 
> I hacked quick unionfind two days ago, but the stopper is that the cache
> is temporarily caching equilvaences in SCC regions.  You mentioned it is no
> longer neccesary, so perhaps if you send me patch to remove this, I can give
> a try to this idea.

I haven't yet tested this (apart from with running the LTO testsuite),
but I'm going to give the following bootstrap & SPEC2k6 LTO build tests.

Richard.

2011-05-09  Richard Guenther  

* gimple.c (gtc_visited, gtc_ob, struct type_pair_d, type_pair_t,
type_pair_hash, type_pair_eq, lookup_type_pair): Remove.
(gtc_visit): Adjust.  Use the first type to identify the
part of the SCC we are visiting.
(gimple_types_compatible_p_1): Likewise.
(gimple_types_compatible_p): Likewise.
(print_gimple_types_stats): Do not print comparison cache stats.
(free_gimple_type_tables): Do not free the comparison cache.

Index: gcc/gimple.c
===
--- gcc/gimple.c(revision 173560)
+++ gcc/gimple.c(working copy)
@@ -50,11 +50,6 @@ static GTY((if_marked ("tree_int_map_mar
 static GTY((if_marked ("tree_int_map_marked_p"), param_is (struct 
tree_int_map)))
   htab_t canonical_type_hash_cache;
 
-/* Global type comparison cache.  This is by TYPE_UID for space efficiency
-   and thus cannot use and does not need GC.  */
-static htab_t gtc_visited;
-static struct obstack gtc_ob;
-
 /* All the tuples have their operand vector (if present) at the very bottom
of the structure.  Therefore, the offset required to find the
operands vector the size of the structure minus the size of the 1
@@ -3210,92 +3205,6 @@ gimple_call_copy_skip_args (gimple stmt,
 
 static hashval_t gimple_type_hash_1 (const void *, enum gtc_mode);
 
-/* Structure used to maintain a cache of some type pairs compared by
-   gimple_types_compatible_p when comparing aggregate types.  There are
-   three possible values for SAME_P:
-
-   -2: The pair (T1, T2) has just been inserted in the table.
-0: T1 and T2 are different types.
-1: T1 and T2 are the same type.
-
-   The two elements in the SAME_P array are indexed by the comparison
-   mode gtc_mode.  */
-
-struct type_pair_d
-{
-  unsigned int uid1;
-  unsigned int uid2;
-  signed char same_p[2];
-};
-typedef struct type_pair_d *type_pair_t;
-
-DEF_VEC_P(type_pair_t);
-DEF_VEC_ALLOC_P(type_pair_t,heap);
-
-/* Return a hash value for the type pair pointed-to by P.  */
-
-static hashval_t
-type_pair_hash (const void *p)
-{
-  const struct type_pair_d *pair = (const struct type_pair_d *) p;
-  hashval_t val1 = pair->uid1;
-  hashval_t val2 = pair->uid2;
-  return iterative_hash_hashval_t (val1, val2);
-}
-
-/* Compare two type pairs pointed-to by P1 and P2.  */
-
-static int
-type_pair_eq (const void *p1, const void *p2)
-{
-  const struct type_pair_d *pair1 = (const struct type_pair_d *) p1;
-  const struct type_pair_d *pair2 = (const struct type_pair_d *) p2;
-  return (pair1->uid1 == pair2->uid1 && pair1->uid2 == pair2->uid2);
-}
-
-/* Lookup the pair of types T1 and T2 in *VISITED_P.  Insert a new
-   entry if none existed.  */
-
-static type_pair_t
-lookup_type_pair (tree t1, tree t2, htab_t *visited_p, struct obstack *ob_p)
-{
-  struct type_pair_d pair;
-  type_pair_t p;
-  void **slot;
-
-  if (*visited_p == NULL)
-{
-  *visited_p = htab_create (251, type_pair_hash, type_pair_eq, NULL);
-  gcc_obstack_init (ob_p);
-}
-
-  if (TYPE_UID (t1) < TYPE_UID (t2))
-{
-  pair.uid1 = TYPE_UID (t1);
-  pair.uid2 = TYPE_UID (t2);
-}
-  else
-{
-  pair.uid1 = TYPE_UID (t2);
-  pair.uid2 = TYPE_UID (t1);
-}
-  slot = htab_find_slot (*visited_p, &pair, INSERT);
-
-  if (*slot)
-p = *((type_pair_t *) slot);
-  else
-{
-  p = XOBNEW (ob_p, struct type_pair_d);
-  p->uid1 = pair.uid1;
-  p->uid2 = pair.uid2;
-  p->same_p[0] = -2;
-  p->same_p[1] = -2;
-  *slot = (void *) p;
-}
-
-  return p;
-}
-
 /* Per pointer state for the SCC finding.  The o

Re: Minor type merging optimization

2011-05-09 Thread Jan Hubicka
> > 
> > I hacked quick unionfind two days ago, but the stopper is that the cache
> > is temporarily caching equilvaences in SCC regions.  You mentioned it is no
> > longer neccesary, so perhaps if you send me patch to remove this, I can give
> > a try to this idea.
> 
> I think we already do exactly this.

Hmm, I am still having problems to understand what type pair cache is good for 
then.
Well, if you hand me the patch to remove it you told me, I will benchmark it.

Honza


Re: Minor type merging optimization

2011-05-09 Thread Richard Guenther
On Mon, 9 May 2011, Jan Hubicka wrote:

> > > 
> > > I hacked quick unionfind two days ago, but the stopper is that the cache
> > > is temporarily caching equilvaences in SCC regions.  You mentioned it is 
> > > no
> > > longer neccesary, so perhaps if you send me patch to remove this, I can 
> > > give
> > > a try to this idea.
> > 
> > I think we already do exactly this.
> 
> Hmm, I am still having problems to understand what type pair cache is good 
> for then.
> Well, if you hand me the patch to remove it you told me, I will benchmark it.

It's not good for anything.  It was good to handle cycles before we
started to properly build SCCs (and thus do it the real value-numbering 
way).

Richard.


Re: Minor type merging optimization

2011-05-09 Thread Jan Hubicka
> I haven't yet tested this (apart from with running the LTO testsuite),
> but I'm going to give the following bootstrap & SPEC2k6 LTO build tests.
> 
> Richard.
> 
> 2011-05-09  Richard Guenther  
> 
>   * gimple.c (gtc_visited, gtc_ob, struct type_pair_d, type_pair_t,
>   type_pair_hash, type_pair_eq, lookup_type_pair): Remove.
>   (gtc_visit): Adjust.  Use the first type to identify the
>   part of the SCC we are visiting.
>   (gimple_types_compatible_p_1): Likewise.
>   (gimple_types_compatible_p): Likewise.
>   (print_gimple_types_stats): Do not print comparison cache stats.
>   (free_gimple_type_tables): Do not free the comparison cache.

Thanks,
I will benchmark Mozilla now.
Honza


Re: [PATCH] allow setting LDFLAGS_FOR_TARGET in top-level configuration.

2011-05-09 Thread Joseph S. Myers
On Sun, 8 May 2011, Doug Kwan wrote:

> Hi,
> 
> The x86 Android toolchain needs setting LDFLAGS_FOR_TARGET to
> build.  This patch does that.  The patch was tested by bootstrapping
> natively on x86_64 linux.  Do I also need to submit this to binutils
> as well?

My view is that you don't need to *submit* it separately, but a toplevel 
commit to GCC should always be immediately followed by committing the same 
changes to the src repository without needing separate approval.

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


Re: [C++ Patch] PRs 48737 & 48744

2011-05-09 Thread Paolo Carlini

Hi,

On 05/08/2011 12:51 PM, Paolo Carlini wrote:

@@ -5203,7 +5203,7 @@ reshape_init_r (tree type, reshape_iter *d, bool f
 {
   ++d->cur;
   gcc_assert (BRACE_ENCLOSED_INITIALIZER_P (init));
-  return reshape_init (type, init);
+  return reshape_init (type, init, tf_warning_or_error);
Any reason not to SFINAEify reshape_init_r as well?  Same question for 
process_init_constructor*.
No reason, really, in the first try I simply did the minimal set of 
changes fixing the reported issues. In the second try below I'm 
consistently changing all those functions too, everything seems fine, 
regtests ok on x86_64-linux. The only minimally non-trivial bits are the 
uses of PICFLAG_ERRONEOUS as a sort of error_mark_node in some 
process_init_constructor_* functions. I didn't invent that, anyway, and 
should work fine because first thing after calling those functions 
process_init_constructor checks the return value for PICFLAG_ERRONEOUS 
and in case transforms it to error_mark_node and bails out.


Ok?

Thanks,
Paolo.


/cp
2011-05-09  Paolo Carlini  

PR c++/48737
PR c++/48744
* decl.c (reshape_init): Take a complain parameter and do
not call error if tf_error is not set.
(check_initializer, reshape_init_r, reshape_init_array,
reshape_init_array_1, reshape_init_vector, reshape_init_class):
Adjust.
* typeck2.c (digest_init_r): Take a complain parameter and
pass it to convert_for_initialization.
(digest_init, digest_init_flags, process_init_constructor_array,
process_init_constructor_record, process_init_constructor_union,
process_init_constructor, digest_init_r): Adjust.
* init.c (expand_default_init, build_new_1): Likewise.
* typeck.c (cp_build_modify_expr): Likewise.
* decl2.c (grokfield): Likewise.
* call.c (convert_like_real, convert_default_arg): Likewise.
* semantics.c (finish_compound_literal): Pass complain to
reshape_init and digest_init.
* cp-tree.h: Adjust declarations.

/testsuite
2011-05-09  Paolo Carlini  

PR c++/48737
PR c++/48744
* g++.dg/template/sfinae28.C: New.
* g++.dg/template/sfinae29.C: Likewise.
Index: testsuite/g++.dg/template/sfinae28.C
===
--- testsuite/g++.dg/template/sfinae28.C(revision 0)
+++ testsuite/g++.dg/template/sfinae28.C(revision 0)
@@ -0,0 +1,13 @@
+// PR c++/48737
+// { dg-options "-std=c++0x" }
+
+template
+T&& create();
+
+template
+decltype(T{create()...}, char()) f(int);
+
+template
+char (&f(...))[2];
+
+static_assert(sizeof(f(0)) != 1, "Error");
Index: testsuite/g++.dg/template/sfinae29.C
===
--- testsuite/g++.dg/template/sfinae29.C(revision 0)
+++ testsuite/g++.dg/template/sfinae29.C(revision 0)
@@ -0,0 +1,23 @@
+// PR c++/48744
+// { dg-options "-std=c++0x" }
+
+template
+struct add_rval_ref {
+  typedef T&& type;
+};
+
+template<>
+struct add_rval_ref {
+  typedef void type;
+};
+
+template
+typename add_rval_ref::type create();
+
+template
+decltype(T{create()}, char()) f(int);
+
+template
+char (&f(...))[2];
+
+static_assert(sizeof(f(0)) != 1, "Error");
Index: cp/typeck.c
===
--- cp/typeck.c (revision 173561)
+++ cp/typeck.c (working copy)
@@ -6715,7 +6715,7 @@ cp_build_modify_expr (tree lhs, enum tree_code mod
}
  if (check_array_initializer (lhs, lhstype, newrhs))
return error_mark_node;
- newrhs = digest_init (lhstype, newrhs);
+ newrhs = digest_init (lhstype, newrhs, complain);
}
 
   else if (!same_or_base_type_p (TYPE_MAIN_VARIANT (lhstype),
Index: cp/init.c
===
--- cp/init.c   (revision 173561)
+++ cp/init.c   (working copy)
@@ -1435,7 +1435,7 @@ expand_default_init (tree binfo, tree true_exp, tr
 {
   /* A brace-enclosed initializer for an aggregate.  In C++0x this can
 happen for direct-initialization, too.  */
-  init = digest_init (type, init);
+  init = digest_init (type, init, complain);
   init = build2 (INIT_EXPR, TREE_TYPE (exp), exp, init);
   TREE_SIDE_EFFECTS (init) = 1;
   finish_expr_stmt (init);
@@ -2375,7 +2375,7 @@ build_new_1 (VEC(tree,gc) **placement, tree type,
 "verify length of initializer-list");
}
  arraytype = build_cplus_array_type (type, domain);
- vecinit = digest_init (arraytype, vecinit);
+ vecinit = digest_init (arraytype, vecinit, complain);
}
  else if (*init)
 {
Index: cp/decl.c
===
--- cp/decl.c   (revision 173561)
+++ cp/decl.c 

[Patch,AVR]: Fix PR48896

2011-05-09 Thread Georg-Johann Lay
Fixed the build warnings mentioned in PR48896.

Johann

--

2011-05-09  Georg-Johann Lay  

PR target/48896
* config/avr/avr.c (avr_ret_register): Return unsigned int
instead of int.
(avr_function_value): Mark fn_decl_or_type as unused, don't pass
it to avr_libcall_value.
avr_expand_builtin): Use EXPAND_NORMAL as arg 4 in calls to
expand_expr.
(avr_expand_binop_builtin): Ditto.
(avr_expand_unop_builtin): Ditto.
Index: config/avr/avr.c
===
--- config/avr/avr.c	(Revision 173561)
+++ config/avr/avr.c	(Arbeitskopie)
@@ -6178,7 +6178,7 @@ avr_reorg (void)
 
 /* Returns register number for function return value.*/
 
-static inline int
+static inline unsigned int
 avr_ret_register (void)
 {
   return 24;
@@ -6209,18 +6209,14 @@ avr_libcall_value (enum machine_mode mod
function returns a value of data type VALTYPE.  */
 
 static rtx
-avr_function_value (const_tree type, const_tree fn_decl_or_type,
-		bool outgoing ATTRIBUTE_UNUSED)
+avr_function_value (const_tree type,
+const_tree fn_decl_or_type ATTRIBUTE_UNUSED,
+bool outgoing ATTRIBUTE_UNUSED)
 {
   unsigned int offs;
-  const_rtx func = fn_decl_or_type;
-
-  if (fn_decl_or_type
-  && !DECL_P (fn_decl_or_type))
-  fn_decl_or_type = NULL;
 
   if (TYPE_MODE (type) != BLKmode)
-return avr_libcall_value (TYPE_MODE (type), func);
+return avr_libcall_value (TYPE_MODE (type), NULL_RTX);
   
   offs = int_size_in_bytes (type);
   if (offs < 2)
@@ -6711,7 +6707,7 @@ avr_expand_unop_builtin (enum insn_code
 {
   rtx pat;
   tree arg0 = CALL_EXPR_ARG (exp, 0);
-  rtx op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
+  rtx op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
   enum machine_mode op0mode = GET_MODE (op0);
   enum machine_mode tmode = insn_data[icode].operand[0].mode;
   enum machine_mode mode0 = insn_data[icode].operand[1].mode;
@@ -6752,8 +6748,8 @@ avr_expand_binop_builtin (enum insn_code
   rtx pat;
   tree arg0 = CALL_EXPR_ARG (exp, 0);
   tree arg1 = CALL_EXPR_ARG (exp, 1);
-  rtx op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
-  rtx op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
+  rtx op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  rtx op1 = expand_expr (arg1, NULL_RTX, VOIDmode, EXPAND_NORMAL);
   enum machine_mode op0mode = GET_MODE (op0);
   enum machine_mode op1mode = GET_MODE (op1);
   enum machine_mode tmode = insn_data[icode].operand[0].mode;
@@ -6845,7 +6841,7 @@ avr_expand_builtin (tree exp, rtx target
 case AVR_BUILTIN_DELAY_CYCLES:
   {
 arg0 = CALL_EXPR_ARG (exp, 0);
-op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
+op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
 if (! CONST_INT_P (op0))
   error ("__builtin_avr_delay_cycles expects a compile time integer constant.");


Fix thinko in var-tracking.c

2011-05-09 Thread Eric Botcazou
There is a known pitfall with REG_OFFSET/MEM_OFFSET: the former is an integer 
whereas the latter is a RTX.  So a test like MEM_OFFSET (node->loc) == 0 is 
essentially never true for user MEMs since you have const0_rtx instead.

The attached patch fixes 3 occurrences introduced in the VTA merge; since this 
doesn't affect code generation, I think it's appropriate for all branches.  It 
seems to introduce a couple of XPASSes in the guality testsuite on i586:

XPASS: gcc.dg/guality/inline-params.c  -O2 -flto  execution test
XPASS: gcc.dg/guality/pr41447-1.c  -O2 -flto  execution test

Tested on i586-suse-linux and x86_64-suse-linux, applied on mainline, 4.6 and 
4.5 branches.


2011-05-09  Eric Botcazou  

* var-tracking.c (find_mem_expr_in_1pdv): Fix thinko.
(dataflow_set_preserve_mem_locs): Likewise.


-- 
Eric Botcazou
Index: var-tracking.c
===
--- var-tracking.c	(revision 173545)
+++ var-tracking.c	(working copy)
@@ -4113,8 +4113,9 @@ find_mem_expr_in_1pdv (tree expr, rtx va
   VALUE_RECURSED_INTO (val) = true;
 
   for (node = var->var_part[0].loc_chain; node; node = node->next)
-if (MEM_P (node->loc) && MEM_EXPR (node->loc) == expr
-	&& MEM_OFFSET (node->loc) == 0)
+if (MEM_P (node->loc)
+	&& MEM_EXPR (node->loc) == expr
+	&& INT_MEM_OFFSET (node->loc) == 0)
   {
 	where = node;
 	break;
@@ -4177,11 +4178,10 @@ dataflow_set_preserve_mem_locs (void **s
 	{
 	  for (loc = var->var_part[0].loc_chain; loc; loc = loc->next)
 	{
-	  /* We want to remove dying MEMs that doesn't refer to
-		 DECL.  */
+	  /* We want to remove dying MEMs that doesn't refer to DECL.  */
 	  if (GET_CODE (loc->loc) == MEM
 		  && (MEM_EXPR (loc->loc) != decl
-		  || MEM_OFFSET (loc->loc))
+		  || INT_MEM_OFFSET (loc->loc) != 0)
 		  && !mem_dies_at_call (loc->loc))
 		break;
 	  /* We want to move here MEMs that do refer to DECL.  */
@@ -4225,7 +4225,7 @@ dataflow_set_preserve_mem_locs (void **s
 
 	  if (GET_CODE (loc->loc) != MEM
 	  || (MEM_EXPR (loc->loc) == decl
-		  && MEM_OFFSET (loc->loc) == 0)
+		  && INT_MEM_OFFSET (loc->loc) == 0)
 	  || !mem_dies_at_call (loc->loc))
 	{
 	  if (old_loc != loc->loc && emit_notes)


Re: [PATCH] allow setting LDFLAGS_FOR_TARGET in top-level configuration.

2011-05-09 Thread Paolo Bonzini

On 05/09/2011 11:49 AM, Joseph S. Myers wrote:

>   The x86 Android toolchain needs setting LDFLAGS_FOR_TARGET to
>  build.  This patch does that.  The patch was tested by bootstrapping
>  natively on x86_64 linux.  Do I also need to submit this to binutils
>  as well?

My view is that you don't need to*submit*  it separately, but a toplevel
commit to GCC should always be immediately followed by committing the same
changes to the src repository without needing separate approval.


This is correct; but if you want to CC binutils, that's also kind.

Paolo


Re: [PATCH, IRA]: Fix PR 48927 - Issues with "enable" attribute and IRA register preferences

2011-05-09 Thread Bernd Schmidt
On 05/08/2011 09:39 PM, Uros Bizjak wrote:

> Attached patch fixes changed register allocation where "enabled"
> attribute is used. The core of the problem was with IRA, where IRA
> does not look at "enabled" attribute when scanning through
> alternatives string to perform various tasks (including register
> allocation preferences).
> 
> Attached patch teaches IRA to handle "enabled" attribute. In effect,
> the patch skips current alternative in the same way as when "#"
> character is found.

Ok.


Bernd


[PATCH 11/n, i386]: Merge SSE and AVX patterns using "enable" attribute.

2011-05-09 Thread Uros Bizjak
Hello!

After PR 48972 fix, these two patterns can be merged without testsuite
scan-asm failures.

2011-05-09  Uros Bizjak  

* config/i386/sse.md (*vec_concatv4si): Merge from *vec_concatv4si_1
and *vec_concatv4si_1_avx.

Tested on x86_64-pc-linux-gnu {,-m32} AVX and non-AVX target,
committed to mainline SVN.

Uros.
Index: config/i386/sse.md
===
--- config/i386/sse.md  (revision 173557)
+++ config/i386/sse.md  (working copy)
@@ -6660,31 +6660,22 @@
   [(set_attr "type" "sselog,ssemov,mmxcvt,mmxmov")
(set_attr "mode" "V4SF,V4SF,DI,DI")])
 
-(define_insn "*vec_concatv4si_1_avx"
-  [(set (match_operand:V4SI 0 "register_operand"   "=x,x")
+(define_insn "*vec_concatv4si"
+  [(set (match_operand:V4SI 0 "register_operand"   "=Y2,x,x,x,x")
(vec_concat:V4SI
- (match_operand:V2SI 1 "register_operand" " x,x")
- (match_operand:V2SI 2 "nonimmediate_operand" " x,m")))]
-  "TARGET_AVX"
-  "@
-   vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
-   vmovhps\t{%2, %1, %0|%0, %1, %2}"
-  [(set_attr "type" "sselog,ssemov")
-   (set_attr "prefix" "vex")
-   (set_attr "mode" "TI,V2SF")])
-
-(define_insn "*vec_concatv4si_1"
-  [(set (match_operand:V4SI 0 "register_operand"   "=Y2,x,x")
-   (vec_concat:V4SI
- (match_operand:V2SI 1 "register_operand" " 0 ,0,0")
- (match_operand:V2SI 2 "nonimmediate_operand" " Y2,x,m")))]
+ (match_operand:V2SI 1 "register_operand" " 0 ,x,0,0,x")
+ (match_operand:V2SI 2 "nonimmediate_operand" " Y2,x,x,m,m")))]
   "TARGET_SSE"
   "@
punpcklqdq\t{%2, %0|%0, %2}
+   vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
movlhps\t{%2, %0|%0, %2}
-   movhps\t{%2, %0|%0, %2}"
-  [(set_attr "type" "sselog,ssemov,ssemov")
-   (set_attr "mode" "TI,V4SF,V2SF")])
+   movhps\t{%2, %0|%0, %2}
+   vmovhps\t{%2, %1, %0|%0, %1, %2}"
+  [(set_attr "isa" "noavx,avx,noavx,noavx,avx")
+   (set_attr "type" "sselog,sselog,ssemov,ssemov,ssemov")
+   (set_attr "prefix" "orig,vex,orig,orig,vex")
+   (set_attr "mode" "TI,TI,V4SF,V2SF,V2SF")])
 
 ;; movd instead of movq is required to handle broken assemblers.
 (define_insn "*vec_concatv2di_rex64_sse4_1"


Re: [PATCH, IRA]: Fix PR 48927 - Issues with "enable" attribute and IRA register preferences

2011-05-09 Thread Andreas Krebbel
On Sun, May 08, 2011 at 09:39:09PM +0200, Uros Bizjak wrote:
> Hello!
> 
> Attached patch fixes changed register allocation where "enabled"
> attribute is used. The core of the problem was with IRA, where IRA
> does not look at "enabled" attribute when scanning through
> alternatives string to perform various tasks (including register
> allocation preferences).
> 
> Attached patch teaches IRA to handle "enabled" attribute. In effect,
> the patch skips current alternative in the same way as when "#"
> character is found.
> 
> 2011-05-08  Uros Bizjak  
> 
>   PR rtl-optimization/48927
>   * ira-conflicts.c (commutative_constraint_p): Use
>   recog_data.alternative_enabled_p to disable alternatives where
>   "enabled" attribute is false.
>   (get_dup_num): Ditto.
>   * ira-lives.c (single_reg_class): Ditto.
>   (ira_implicitly_set_insn_hard_regs): Ditto.
> 
> Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
> {,-m32} with and without -with-fpmath=avx. Also, the patch fixes both
> i386 scan-asm failures when the patch to merge *vec_concatv4si_1_avx
> and *vec_concatv4si_1 patterns is applied (please see the PR [1] for
> details).
> 
> OK for mainline?

I've bootstrapped and regtested the patch on s390x. No regressions!

Bye,

-Andreas-


Re: Fix thinko in var-tracking.c

2011-05-09 Thread Joseph S. Myers
On Mon, 9 May 2011, Eric Botcazou wrote:

> doesn't affect code generation, I think it's appropriate for all branches.  
> It 
> seems to introduce a couple of XPASSes in the guality testsuite on i586:
> 
> XPASS: gcc.dg/guality/inline-params.c  -O2 -flto  execution test
> XPASS: gcc.dg/guality/pr41447-1.c  -O2 -flto  execution test

The guality tests have random results.  I don't know if that's the issue 
here, but perhaps someone can review Jeff's patch 
 to make them 
more predictable.  Without that, I generally just ignore them in 
comparisons of test results.

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


[PATCH, MELT] fix useless forcing of GCC garbage collector

2011-05-09 Thread Pierre Vittet

This patch is for the MELT branch.

My GCC contributor number is 634276.

After speaking with Basile Starynkevitch, we saw that there might be a 
useless forcing of the garbage collector in melt-runtime.c . I tested 
with the patch, and I haven't seen any problem (I could compile GCC, 
using a MELT plugin with the patched version).
I have also measured a small time improvement while compiling the file 
gcc.c (which is more that 8000 lines):


Whithout the modification:
usersys
1.563   0.145s

With  the modification:
usersys
1.144  0.106s


Changelog:

2011-05-09  Pierre Vittet  

 	* melt-runtime.c: Remove variable forcing the garbage collector while 
it was not needed.


Thanks

Pierre Vittet
Index: melt-runtime.c
===
--- melt-runtime.c  (revision 173571)
+++ melt-runtime.c  (working copy)
@@ -1159,16 +1159,13 @@
melt_nb_garbcoll, melt_startalz, melt_endalz);
   if (needfull)
 {
-  bool wasforced = ggc_force_collect;
   melt_nb_full_garbcoll++;
   debugeprintf ("melt_garbcoll #%ld fullgarbcoll #%ld",
melt_nb_garbcoll, melt_nb_full_garbcoll);
   /* force major collection, with our callback */
-  ggc_force_collect = true;
-  debugeprintf ("melt_garbcoll forcing fullgarbcoll #%ld", 
melt_nb_full_garbcoll);
+  debugeprintf ("melt_garbcoll calling gcc_collect #%ld", 
melt_nb_full_garbcoll);
   ggc_collect ();
-  ggc_force_collect = wasforced;
-  debugeprintf ("melt_garbcoll forced fullgarbcoll #%ld", 
melt_nb_full_garbcoll);
+  debugeprintf ("melt_garbcoll after fullgarbcoll #%ld", 
melt_nb_full_garbcoll);
   /* Delete the unmarked specials.  */
   prevspecptr = &melt_oldspeclist;
   for (specp = melt_oldspeclist; specp; specp = nextspecp)


[Comitted] S/390: Fix TD/TF mem to reg splitter for -m31 -mzarch

2011-05-09 Thread Andreas Krebbel
Hi,

the attached patch fixes a testsuite failure with -m31 -mzarch.  The
TD/TF mem to reg move splitter uses the first word mode register of
the target operand as temporary register for storing the address.
This generates an invalid address when having a 64 bit word mode and a
32 bit address mode as it happens with -m31 -mzarch.

Fixed with the attached patch. 

Bootstrapped and regtested with -with-mode=zarch.

Applied to mainline and 4.6.

Bye,

-Andreas-


2011-05-09  Andreas Krebbel  

* config/s390/s390.md (TD/TF mem to reg move splitter): Make the
temporary register to match Pmode.

Index: gcc/config/s390/s390.md
===
--- gcc/config/s390/s390.md.orig
+++ gcc/config/s390/s390.md
@@ -2026,6 +2026,7 @@
   [(set (match_dup 0) (match_dup 1))]
 {
   rtx addr = operand_subword (operands[0], 1, 0, mode);
+  addr = gen_lowpart (Pmode, addr);
   s390_load_address (addr, XEXP (operands[1], 0));
   operands[1] = replace_equiv_address (operands[1], addr);
 })


Ping Re: [PATCH] Canonicalize compares in combine [3/3] ARM backend part

2011-05-09 Thread Chung-Lin Tang
Ping.

On 04/22/2011 11:21 PM, Chung-Lin Tang wrote:
> Hi Richard, this part's for you.
> 
> The ARM backend changes needed are very little after the prior patches,
> basically just a case in arm_canonicalize_comparison() to detect
> (zero_extend:SI (subreg:QI (reg:SI ...) 0)), and swap it into (and:SI
> (reg:SI) #255).
> 
> Had we not tried the combine modifications, this testcase probably could
> have also be solved by implementing another version of the corresponding
> *andsi3_compare0/_scratch patterns, with ZERO_EXTEND in the body, and
> "ands" in the output assembly. Maybe that's an acceptable solution too...
> 
> About the (ab)use of CANONICALIZE_COMPARISON, if it really should be
> another macro/hook, then this ARM patch will need updating, but the code
> should be similar.
> 
> Thanks,
> Chung-Lin



[PATCH][1/n] LTO type merging cleanup

2011-05-09 Thread Richard Guenther

This makes gimple_types_compatible_p private to gimple.c again,
removing the need to call it from lto-symtab.c as we now merge
types early (and thus we can resort to the middle-end types_compatible_p
function).

Bootstrapped on x86_64-unknown-linux-gnu, testing and SPEC2k6 build
in progress.

Richard.

2011-05-09  Richard Guenther  

* lto-symtab.c (lto_cgraph_replace_node): Use types_compatible_p
for diagnostics.
(lto_symtab_merge): Likewise.  Do not register types here.
(lto_symtab_merge_decls_2): Likewise.
(lto_symtab_merge_decls_1): Likewise.
* gimple.h (enum gtc_mode, gimple_types_compatible_p): Do not declare.
* gimple.c (enum gtc_mode): Declare.
(gimple_types_compatible_p): Make static.

Index: gcc/lto-symtab.c
===
*** gcc/lto-symtab.c(revision 173560)
--- gcc/lto-symtab.c(working copy)
*** lto_cgraph_replace_node (struct cgraph_n
*** 243,250 
  
/* Redirect all incoming edges.  */
compatible_p
! = gimple_types_compatible_p (TREE_TYPE (TREE_TYPE 
(prevailing_node->decl)),
!TREE_TYPE (TREE_TYPE (node->decl)), GTC_DIAG);
for (e = node->callers; e; e = next)
  {
next = e->next_caller;
--- 243,250 
  
/* Redirect all incoming edges.  */
compatible_p
! = types_compatible_p (TREE_TYPE (TREE_TYPE (prevailing_node->decl)),
! TREE_TYPE (TREE_TYPE (node->decl)));
for (e = node->callers; e; e = next)
  {
next = e->next_caller;
*** lto_symtab_merge (lto_symtab_entry_t pre
*** 360,367 
  
if (TREE_CODE (decl) == FUNCTION_DECL)
  {
!   if (!gimple_types_compatible_p (TREE_TYPE (prevailing_decl),
! TREE_TYPE (decl), GTC_DIAG))
/* If we don't have a merged type yet...sigh.  The linker
   wouldn't complain if the types were mismatched, so we
   probably shouldn't either.  Just use the type from
--- 360,367 
  
if (TREE_CODE (decl) == FUNCTION_DECL)
  {
!   if (!types_compatible_p (TREE_TYPE (prevailing_decl),
!  TREE_TYPE (decl)))
/* If we don't have a merged type yet...sigh.  The linker
   wouldn't complain if the types were mismatched, so we
   probably shouldn't either.  Just use the type from
*** lto_symtab_merge (lto_symtab_entry_t pre
*** 390,400 
prevailing_type = TYPE_MAIN_VARIANT (TREE_TYPE (prevailing_decl));
type = TYPE_MAIN_VARIANT (TREE_TYPE (decl));
  
!   /* We have to register and fetch canonical types here as the global
!  fixup process didn't yet run.  */
!   prevailing_type = gimple_register_type (prevailing_type);
!   type = gimple_register_type (type);
!   if (!gimple_types_compatible_p (prevailing_type, type, GTC_DIAG))
  {
if (COMPLETE_TYPE_P (type))
return false;
--- 390,396 
prevailing_type = TYPE_MAIN_VARIANT (TREE_TYPE (prevailing_decl));
type = TYPE_MAIN_VARIANT (TREE_TYPE (decl));
  
!   if (!types_compatible_p (prevailing_type, type))
  {
if (COMPLETE_TYPE_P (type))
return false;
*** lto_symtab_merge (lto_symtab_entry_t pre
*** 419,427 
  if (TREE_CODE (tem1) != TREE_CODE (tem2))
return false;
  
! if (!gimple_types_compatible_p (gimple_register_type (tem1),
! gimple_register_type (tem2),
! GTC_DIAG))
return false;
}
  
--- 415,421 
  if (TREE_CODE (tem1) != TREE_CODE (tem2))
return false;
  
! if (!types_compatible_p (tem1, tem2))
return false;
}
  
*** lto_symtab_merge_decls_2 (void **slot, b
*** 620,627 
/* Diagnose all mismatched re-declarations.  */
FOR_EACH_VEC_ELT (tree, mismatches, i, decl)
  {
!   if (!gimple_types_compatible_p (TREE_TYPE (prevailing->decl),
! TREE_TYPE (decl), GTC_DIAG))
diagnosed_p |= warning_at (DECL_SOURCE_LOCATION (decl), 0,
   "type of %qD does not match original "
   "declaration", decl);
--- 614,620 
/* Diagnose all mismatched re-declarations.  */
FOR_EACH_VEC_ELT (tree, mismatches, i, decl)
  {
!   if (!types_compatible_p (TREE_TYPE (prevailing->decl), TREE_TYPE 
(decl)))
diagnosed_p |= warning_at (DECL_SOURCE_LOCATION (decl), 0,
   "type of %qD does not match original "
   "declaration", decl);
*** lto_symtab_merge_decls_1 (void **slot, v
*** 744,753 
inform (DECL_SOURCE_LOCATION (prevailing->decl),
  "previously declared here");
  
-   /* Register and adjust types of the entries.  */
-   for (e = (lt

[v3] Fix libstdc++/48933

2011-05-09 Thread Paolo Carlini

Hi,

tested x86_64-linux, committed to mainline.

Thanks,
Paolo.

///
2011-05-09  Paolo Carlini  

PR libstdc++/48933
* include/c_global/cmath (acosh, asinh, atanh, cbrt, copysign,
erf, erfc, exp2, expm1, fdim, fma, fmax, hypot, ilogb, lgamma,
llrint, llround, log1p, log2, logb, lrint, lround, nearbyint,
nextafter, nexttoward, remainder, remquo, rint, round, scalbln,
scalbn, tgamma, trunc): Use __enable_if on the return type.
* include/tr1/cmath: Likewise.
* testsuite/26_numerics/headers/cmath/overloads_c++0x_neg.cc: New.
* testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc: Likewise.
Index: include/c_global/cmath
===
--- include/c_global/cmath  (revision 173567)
+++ include/c_global/cmath  (working copy)
@@ -1,7 +1,7 @@
 // -*- C++ -*- C forwarding header.
 
 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007, 2008, 2009, 2010
+// 2006, 2007, 2008, 2009, 2010, 2011
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -1120,12 +1120,10 @@
   { return __builtin_acoshl(__x); }
 
   template
-inline typename __gnu_cxx::__promote<_Tp>::__type 
+inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 
+  double>::__type
 acosh(_Tp __x)
-{
-  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-  return acosh(__type(__x));
-}
+{ return __builtin_acosh(__x); }
 
   inline float
   asinh(float __x)
@@ -1136,12 +1134,10 @@
   { return __builtin_asinhl(__x); }
 
   template
-inline typename __gnu_cxx::__promote<_Tp>::__type 
+inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 
+  double>::__type
 asinh(_Tp __x)
-{
-  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-  return asinh(__type(__x));
-}
+{ return __builtin_asinh(__x); }
 
   inline float
   atanh(float __x)
@@ -1152,12 +1148,10 @@
   { return __builtin_atanhl(__x); }
 
   template
-inline typename __gnu_cxx::__promote<_Tp>::__type 
+inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 
+  double>::__type
 atanh(_Tp __x)
-{
-  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-  return atanh(__type(__x));
-}
+{ return __builtin_atanh(__x); }
 
   inline float
   cbrt(float __x)
@@ -1168,12 +1162,10 @@
   { return __builtin_cbrtl(__x); }
 
   template
-inline typename __gnu_cxx::__promote<_Tp>::__type 
+inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 
+  double>::__type
 cbrt(_Tp __x)
-{
-  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-  return cbrt(__type(__x));
-}
+{ return __builtin_cbrt(__x); }
 
   inline float
   copysign(float __x, float __y)
@@ -1184,7 +1176,11 @@
   { return __builtin_copysignl(__x, __y); }
 
   template
-inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
+inline
+typename __gnu_cxx::__promote_2<
+typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
+   && __is_arithmetic<_Up>::__value,
+   _Tp>::__type, _Up>::__type
 copysign(_Tp __x, _Up __y)
 {
   typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
@@ -1200,12 +1196,10 @@
   { return __builtin_erfl(__x); }
 
   template
-inline typename __gnu_cxx::__promote<_Tp>::__type 
+inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 
+  double>::__type
 erf(_Tp __x)
-{
-  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-  return erf(__type(__x));
-}
+{ return __builtin_erf(__x); }
 
   inline float
   erfc(float __x)
@@ -1216,12 +1210,10 @@
   { return __builtin_erfcl(__x); }
 
   template
-inline typename __gnu_cxx::__promote<_Tp>::__type 
+inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 
+  double>::__type
 erfc(_Tp __x)
-{
-  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-  return erfc(__type(__x));
-}
+{ return __builtin_erfc(__x); }
 
   inline float
   exp2(float __x)
@@ -1232,12 +1224,10 @@
   { return __builtin_exp2l(__x); }
 
   template
-inline typename __gnu_cxx::__promote<_Tp>::__type 
+inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 
+  double>::__type
 exp2(_Tp __x)
-{
-  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-  return exp2(__type(__x));
-}
+{ return __builtin_exp2(__x); }
 
   inline float
   expm1(float __x)
@

Re: [patch] make default linker --hash-style configurable option

2011-05-09 Thread Paul Pluzhnikov
Ping? Ping? Ping? Ping? Ping?

http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00246.html

CC'ing the rest of build system maintainers.

On Mon, May 2, 2011 at 8:56 AM, Paul Pluzhnikov  wrote:
> On Mon, May 2, 2011 at 7:59 AM, Joseph S. Myers  
> wrote:
>
> Thanks for your comments.
>
>> When pinging, please include the URL of the patch being pinged and CC
>
> http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00246.html
>
>> relevant maintainers (in this case, build system maintainers).
>
> All of them? [I've started with two ...]


Thanks!

-- 
Paul Pluzhnikov


Re: [patch] make default linker --hash-style configurable option

2011-05-09 Thread Paolo Bonzini

On 05/09/2011 05:59 PM, Paul Pluzhnikov wrote:

Ping? Ping? Ping? Ping? Ping?

http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00246.html

CC'ing the rest of build system maintainers.


None of the build system maintainers can approve gcc.c changes.  And 
those can be approved only by either a global reviewer, or by Joseph. 
That's why I haven't replied anything up to now.


Paolo


Re: [PATCH][ARM] Thumb2 replicated constants

2011-05-09 Thread Andrew Stubbs

On 06/05/11 12:18, Richard Earnshaw wrote:

+   RETURN_SEQUENCE must be an int[4].

It would be a more robust coding style to define a struct with an int[4]
array as its only member.  Then it wouldn't be possible to pass an
undersized object to these routines.


I've attached an updated patch with this change.


OK with a change to do that.


Thanks, I can't commit this until my ADDW/SUBW patch has been committed.

Andrew
2011-05-09  Andrew Stubbs  

	gcc/
	* config/arm/arm.c (struct four_ints): New type.
	(count_insns_for_constant): Delete function.
	(find_best_start): Delete function.
	(optimal_immediate_sequence): New function.
	(optimal_immediate_sequence_1): New function.
	(arm_gen_constant): Move constant splitting code to
	optimal_immediate_sequence.
	Rewrite constant negation/invertion code.

	gcc/testsuite/
	* gcc.target/arm/thumb2-replicated-constant1.c: New file.
	* gcc.target/arm/thumb2-replicated-constant2.c: New file.
	* gcc.target/arm/thumb2-replicated-constant3.c: New file.
	* gcc.target/arm/thumb2-replicated-constant4.c: New file.

--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -64,6 +64,11 @@ typedef struct minipool_fixup   Mfix;
 
 void (*arm_lang_output_object_attributes_hook)(void);
 
+struct four_ints
+{
+  int i[4];
+};
+
 /* Forward function declarations.  */
 static bool arm_needs_doubleword_align (enum machine_mode, const_tree);
 static int arm_compute_static_chain_stack_bytes (void);
@@ -129,7 +134,13 @@ static void thumb1_output_function_prologue (FILE *, HOST_WIDE_INT);
 static int arm_comp_type_attributes (const_tree, const_tree);
 static void arm_set_default_type_attributes (tree);
 static int arm_adjust_cost (rtx, rtx, rtx, int);
-static int count_insns_for_constant (HOST_WIDE_INT, int);
+static int optimal_immediate_sequence (enum rtx_code code,
+   unsigned HOST_WIDE_INT val,
+   struct four_ints *return_sequence);
+static int optimal_immediate_sequence_1 (enum rtx_code code,
+	 unsigned HOST_WIDE_INT val,
+	 struct four_ints *return_sequence,
+	 int i);
 static int arm_get_strip_length (int);
 static bool arm_function_ok_for_sibcall (tree, tree);
 static enum machine_mode arm_promote_function_mode (const_tree,
@@ -2441,68 +2452,41 @@ arm_split_constant (enum rtx_code code, enum machine_mode mode, rtx insn,
 			   1);
 }
 
-/* Return the number of instructions required to synthesize the given
-   constant, if we start emitting them from bit-position I.  */
-static int
-count_insns_for_constant (HOST_WIDE_INT remainder, int i)
-{
-  HOST_WIDE_INT temp1;
-  int step_size = TARGET_ARM ? 2 : 1;
-  int num_insns = 0;
-
-  gcc_assert (TARGET_ARM || i == 0);
-
-  do
-{
-  int end;
-
-  if (i <= 0)
-	i += 32;
-  if (remainder & (((1 << step_size) - 1) << (i - step_size)))
-	{
-	  end = i - 8;
-	  if (end < 0)
-	end += 32;
-	  temp1 = remainder & ((0x0ff << end)
-| ((i < end) ? (0xff >> (32 - end)) : 0));
-	  remainder &= ~temp1;
-	  num_insns++;
-	  i -= 8 - step_size;
-	}
-  i -= step_size;
-} while (remainder);
-  return num_insns;
-}
-
+/* Return a sequence of integers, in RETURN_SEQUENCE that fit into
+   ARM/THUMB2 immediates, and add up to VAL.
+   Thr function return value gives the number of insns required.  */
 static int
-find_best_start (unsigned HOST_WIDE_INT remainder)
+optimal_immediate_sequence (enum rtx_code code, unsigned HOST_WIDE_INT val,
+			struct four_ints *return_sequence)
 {
   int best_consecutive_zeros = 0;
   int i;
   int best_start = 0;
+  int insns1, insns2;
+  struct four_ints tmp_sequence;
 
   /* If we aren't targetting ARM, the best place to start is always at
- the bottom.  */
-  if (! TARGET_ARM)
-return 0;
-
-  for (i = 0; i < 32; i += 2)
+ the bottom, otherwise look more closely.  */
+  if (TARGET_ARM)
 {
-  int consecutive_zeros = 0;
-
-  if (!(remainder & (3 << i)))
+  for (i = 0; i < 32; i += 2)
 	{
-	  while ((i < 32) && !(remainder & (3 << i)))
-	{
-	  consecutive_zeros += 2;
-	  i += 2;
-	}
-	  if (consecutive_zeros > best_consecutive_zeros)
+	  int consecutive_zeros = 0;
+
+	  if (!(val & (3 << i)))
 	{
-	  best_consecutive_zeros = consecutive_zeros;
-	  best_start = i - consecutive_zeros;
+	  while ((i < 32) && !(val & (3 << i)))
+		{
+		  consecutive_zeros += 2;
+		  i += 2;
+		}
+	  if (consecutive_zeros > best_consecutive_zeros)
+		{
+		  best_consecutive_zeros = consecutive_zeros;
+		  best_start = i - consecutive_zeros;
+		}
+	  i -= 2;
 	}
-	  i -= 2;
 	}
 }
 
@@ -2529,13 +2513,161 @@ find_best_start (unsigned HOST_WIDE_INT remainder)
  the constant starting from `best_start', and also starting from
  zero (i.e. with bit 31 first to be output).  If `best_start' doesn't
  yield a shorter sequence, we may as well use zero.  */
+  insns1 = optimal_immediate_sequence_1 (code, val, return_sequence, best_start);
   if (best_start != 0
-  && unsigned HOST_WIDE_INT)

[C++0x] contiguous bitfields race implementation

2011-05-09 Thread Aldy Hernandez
Seeing that the current C++ draft has been approved, I'd like to submit 
this for mainline, and get the proper review everyone's being quietly 
avoiding :).


To refresh everyone's memory, here is the problem:

struct
{
unsigned int a : 4;
unsigned char b;
unsigned int c: 6;
} var;


void seta(){
  var.a = 12;
}


In the new C++ standard, stores into  cannot touch , so we can't 
store with anything wider (e.g. a 32 bit store) that will touch . 
This problem can be seen on strictly aligned targets such as ARM, where 
we store the above sequence with a 32-bit store. Or on x86-64 with  
being volatile (PR48124).


This patch fixes both problems, but only for the C++ memory model. This 
is NOT a generic fix PR48124, only a fix when using "--param 
allow-store-data-races=0".  I will gladly change the parameter name, if 
another is preferred.


The gist of this patch is in max_field_size(), where we calculate the 
maximum number of bits we can store into. In doing this calculation I 
assume we can store into the padding without causing any races. So, 
padding between fields and at the end of the structure are included.


Tested on x86-64 both with and without "--param 
allow-store-data-races=0", and visually inspecting the assembly on 
arm-linux and ia64-linux.


OK for trunk?
Aldy
* params.h (ALLOW_STORE_DATA_RACES): New.
* params.def (PARAM_ALLOW_STORE_DATA_RACES): New.
* Makefile.in (expr.o): Depend on PARAMS_H.
* machmode.h (get_best_mode): Add argument.
* fold-const.c (optimize_bit_field_compare): Add argument to
get_best_mode.
(fold_truthop): Same.
* ifcvt.c (noce_emit_move_insn): Add argument to store_bit_field.
* expr.c (emit_group_store): Same.
(copy_blkmode_from_reg): Same.
(write_complex_part): Same.
(optimize_bitfield_assignment_op): Add argument.
Add argument to get_best_mode.
(max_field_size): New.
(expand_assignment): Calculate maxbits and pass it down
accordingly.
(store_field): New argument.
(expand_expr_real_2): New argument to store_field.
Include params.h.
* expr.h (store_bit_field): New argument.
* stor-layout.c (get_best_mode): Restrict mode expansion by taking
into account maxbits.
* calls.c (store_unaligned_arguments_into_pseudos): New argument
to store_bit_field.
* expmed.c (store_bit_field_1): New argument.  Use it.
(store_bit_field): Same.
(store_fixed_bit_field): Same.
(store_split_bit_field): Same.
(extract_bit_field_1): Pass new argument to get_best_mode.
(extract_bit_field): Same.
* stmt.c (store_bit_field): Pass new argument to store_bit_field.
* tree.h (DECL_THREAD_VISIBLE_P): New.
* doc/invoke.texi: Document parameter allow-store-data-races.

Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 173263)
+++ doc/invoke.texi (working copy)
@@ -8886,6 +8886,11 @@ The maximum number of conditional stores
 if either vectorization (@option{-ftree-vectorize}) or if-conversion
 (@option{-ftree-loop-if-convert}) is disabled.  The default is 2.
 
+@item allow-store-data-races
+Allow optimizers to introduce new data races on stores.
+Set to 1 to allow, otherwise to 0.  This option is enabled by default
+unless implicitly set by the @option{-fmemory-model=} option.
+
 @end table
 @end table
 
Index: machmode.h
===
--- machmode.h  (revision 173263)
+++ machmode.h  (working copy)
@@ -248,7 +248,9 @@ extern enum machine_mode mode_for_vector
 
 /* Find the best mode to use to access a bit field.  */
 
-extern enum machine_mode get_best_mode (int, int, unsigned int,
+extern enum machine_mode get_best_mode (int, int,
+   unsigned HOST_WIDE_INT,
+   unsigned int,
enum machine_mode, int);
 
 /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT.  */
Index: tree.h
===
--- tree.h  (revision 173263)
+++ tree.h  (working copy)
@@ -3156,6 +3156,10 @@ struct GTY(()) tree_parm_decl {
 #define DECL_THREAD_LOCAL_P(NODE) \
   (VAR_DECL_CHECK (NODE)->decl_with_vis.tls_model >= TLS_MODEL_REAL)
 
+/* Return true if a VAR_DECL is visible from another thread.  */
+#define DECL_THREAD_VISIBLE_P(NODE) \
+  (TREE_STATIC (NODE) && !DECL_THREAD_LOCAL_P (NODE))
+
 /* In a non-local VAR_DECL with static storage duration, true if the
variable has an initialization priority.  If false, the variable
will be initialized at the DEFAULT_INIT_PRIORITY.  */
Index: fold-const.c
===
--- fold-const.c(revision 173263)
+++ fold-const.c(working copy)
@@ -34

[PATCH, testsuite]: Add -mprefer-avx128 to DEFAULT_VECTCFLAGS

2011-05-09 Thread Uros Bizjak
Hello!

Vectorizer testsuite assumes 128bit vector widths. AVX breaks this
assumption and that results in various spurious testsuite failures.

Attached patch clears all failures on AVX target.

2011-05-09  Uros Bizjak  

* lib/target-supports.exp (check_vect_support_and_set_flags)
: Add -mprefer-avx128 to DEFAULT_VECTCFLAGS.

Uros.

Index: lib/target-supports.exp
===
--- lib/target-supports.exp (revision 173569)
+++ lib/target-supports.exp (working copy)
@@ -3845,6 +3845,8 @@
 set dg-do-what-default run
 } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
 lappend DEFAULT_VECTCFLAGS "-msse2"
+   # FIXME: Vectorizer testsuite assumes 128bit vector widths.
+   lappend DEFAULT_VECTCFLAGS "-mprefer-avx128"
 if { [check_effective_target_sse2_runtime] } {
 set dg-do-what-default run
 } else {


Re: [patch] make default linker --hash-style configurable option

2011-05-09 Thread Joseph S. Myers
On Mon, 9 May 2011, Paolo Bonzini wrote:

> On 05/09/2011 05:59 PM, Paul Pluzhnikov wrote:
> > Ping? Ping? Ping? Ping? Ping?
> > 
> > http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00246.html
> > 
> > CC'ing the rest of build system maintainers.
> 
> None of the build system maintainers can approve gcc.c changes.  And those can
> be approved only by either a global reviewer, or by Joseph. That's why I
> haven't replied anything up to now.

I'm thinking of it as a build-system patch with a driver bit - where build 
system maintainers need to decide the general principle of the 
desirability of the feature and what all of the implementation outside 
gcc.c should look like, before it makes sense to review the details of the 
gcc.c bit.

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


Re: [patch] make default linker --hash-style configurable option

2011-05-09 Thread Paolo Bonzini
On Mon, May 9, 2011 at 18:45, Joseph S. Myers  wrote:
> On Mon, 9 May 2011, Paolo Bonzini wrote:
>
>> On 05/09/2011 05:59 PM, Paul Pluzhnikov wrote:
>> > Ping? Ping? Ping? Ping? Ping?
>> >
>> > http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00246.html
>> >
>> > CC'ing the rest of build system maintainers.
>>
>> None of the build system maintainers can approve gcc.c changes.  And those 
>> can
>> be approved only by either a global reviewer, or by Joseph. That's why I
>> haven't replied anything up to now.
>
> I'm thinking of it as a build-system patch with a driver bit - where build
> system maintainers need to decide the general principle of the
> desirability of the feature and what all of the implementation outside
> gcc.c should look like, before it makes sense to review the details of the
> gcc.c bit.

Uhm, so we deadlocked, I thought the other way.  I cannot really
express any opinion about the desirability of the feature, but the
configure syntax is certainly okay with me, and I gather from the
thread that you are fine with that as well.

Paolo


Re: [patch] make default linker --hash-style configurable option

2011-05-09 Thread Joseph S. Myers
On Mon, 9 May 2011, Paolo Bonzini wrote:

> On Mon, May 9, 2011 at 18:45, Joseph S. Myers  wrote:
> > On Mon, 9 May 2011, Paolo Bonzini wrote:
> >
> >> On 05/09/2011 05:59 PM, Paul Pluzhnikov wrote:
> >> > Ping? Ping? Ping? Ping? Ping?
> >> >
> >> > http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00246.html
> >> >
> >> > CC'ing the rest of build system maintainers.
> >>
> >> None of the build system maintainers can approve gcc.c changes.  And those 
> >> can
> >> be approved only by either a global reviewer, or by Joseph. That's why I
> >> haven't replied anything up to now.
> >
> > I'm thinking of it as a build-system patch with a driver bit - where build
> > system maintainers need to decide the general principle of the
> > desirability of the feature and what all of the implementation outside
> > gcc.c should look like, before it makes sense to review the details of the
> > gcc.c bit.
> 
> Uhm, so we deadlocked, I thought the other way.  I cannot really
> express any opinion about the desirability of the feature, but the
> configure syntax is certainly okay with me, and I gather from the
> thread that you are fine with that as well.

Given the build system changes, the gcc.c changes are OK.

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

Re: [PATCH, ARM] Unaligned accesses for packed structures [1/2]

2011-05-09 Thread Julian Brown
On Fri, 06 May 2011 14:04:16 +0100
Richard Earnshaw  wrote:

> On Fri, 2011-05-06 at 13:34 +0100, Julian Brown wrote:
> > This is the first of two patches to add unaligned-access support to
> > the ARM backend. [...]

> The compiler should fault -munaligned-access on cores that don't
> support it.

I've implemented this as a warning (which automatically disables the
option).

> +(define_insn "unaligned_loadsi"
> +  [(set (match_operand:SI 0 "s_register_operand" "=r")
> +   (unspec:SI [(match_operand:SI 1 "memory_operand" "m")]
> +  UNSPEC_UNALIGNED_LOAD))]
> +  "unaligned_access"
> +  "ldr%?\t%0, %1\t@ unaligned"
> +  [(set_attr "predicable" "yes")
> +   (set_attr "type" "load1")])
> 
> I think the final condition should also include TARGET_32BIT, as these
> patterns aren't expected to work with Thumb-1.

Added.

> Secondly, they should be structured to get the length information
> right when a 16-bit encoding can be used in Thumb-2 (you'll keep
> Carrot happy that way :-) : just add an alternative that's only
> enabled for Thumb mode and which matches the requirements for a
> 16-bit instruction (beware however of the 16-bit write-back case).

I've done this, assuming that by "16-bit write-back case" you meant
singleton-register-list ldmia/stmia instructions masquerading as
post-increment ldr/str? I've disallowed that by adding a new
constraint. It's not entirely clear to me whether Thumb-2 (vs. Thumb-1)
will actually ever use 16-bit ldmia/stmia instead of 32-bit writeback
ldr/str though.

> Finally, I don't see anything to put out the correct build attribute
> information for unaligned access enabled (Tag_CPU_unaligned_access).
> Have I just missed it?

No you didn't miss it, it wasn't there :-). Added.

How does this look now? (Re-testing in progress.)

Thanks,

Julian

ChangeLog

gcc/
* config/arm/arm.c (arm_override_options): Add unaligned_access
support.
(arm_file_start): Emit attribute for unaligned access as
appropriate.
* config/arm/arm.md (UNSPEC_UNALIGNED_LOAD)
(UNSPEC_UNALIGNED_STORE): Add constants for unspecs.
(insv, extzv): Add unaligned-access support.
(extv): Change to expander. Likewise.
(unaligned_loadsi, unaligned_loadhis, unaligned_loadhiu)
(unaligned_storesi, unaligned_storehi): New.
(*extv_reg): New (previous extv implementation).
* config/arm/arm.opt (munaligned_access): Add option.
* config/arm/constraints.md (Uw): New constraint.
* expmed.c (store_bit_field_1): Don't tweak bitfield numbering for
memory locations if BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN.
(extract_bit_field_1): Likewise.
commit bd55df2538dd90e576dd0f69bc9c9d570c8eee08
Author: Julian Brown 
Date:   Wed May 4 10:06:25 2011 -0700

Permit regular ldr/str/ldrh/strh for packed-structure accesses etc.

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4f9c2aa..f0f1a73 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -1833,6 +1833,28 @@ arm_option_override (void)
 	fix_cm3_ldrd = 0;
 }
 
+  /* Enable -munaligned-access by default for
+ - all ARMv6 architecture-based processors
+ - ARMv7-A, ARMv7-R, and ARMv7-M architecture-based processors.
+
+ Disable -munaligned-access by default for
+ - all pre-ARMv6 architecture-based processors
+ - ARMv6-M architecture-based processors.  */
+
+  if (unaligned_access == 2)
+{
+  if (arm_arch6 && (arm_arch_notm || arm_arch7))
+	unaligned_access = 1;
+  else
+	unaligned_access = 0;
+}
+  else if (unaligned_access == 1
+	   && !(arm_arch6 && (arm_arch_notm || arm_arch7)))
+{
+  warning (0, "target CPU does not support unaligned accesses");
+  unaligned_access = 0;
+}
+
   if (TARGET_THUMB1 && flag_schedule_insns)
 {
   /* Don't warn since it's on by default in -O2.  */
@@ -21714,6 +21736,10 @@ arm_file_start (void)
 	val = 6;
   asm_fprintf (asm_out_file, "\t.eabi_attribute 30, %d\n", val);
 
+  /* Tag_CPU_unaligned_access.  */
+  asm_fprintf (asm_out_file, "\t.eabi_attribute 34, %d\n",
+		   unaligned_access);
+
   /* Tag_ABI_FP_16bit_format.  */
   if (arm_fp16_format)
 	asm_fprintf (asm_out_file, "\t.eabi_attribute 38, %d\n",
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index 40ebf35..59b9ffb 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -104,6 +104,10 @@
   UNSPEC_SYMBOL_OFFSET  ; The offset of the start of the symbol from
 ; another symbolic address.
   UNSPEC_MEMORY_BARRIER ; Represent a memory barrier.
+  UNSPEC_UNALIGNED_LOAD	; Used to represent ldr/ldrh instructions that access
+			; unaligned locations, on architectures which support
+			; that.
+  UNSPEC_UNALIGNED_STORE ; Same for str/strh.
 ])
 
 ;; UNSPEC_VOLATILE Usage:
@@ -2393,7 +2397,7 @@
 ;;; this insv pattern, so this pattern needs to be reevalutated.
 
 (define_expand "insv"
-  [(set (zero_extract:SI (match_operand:SI 0 "s_register_operand" "")
+  [(set (zero_extrac

Re: [PATCH, MELT] fix useless forcing of GCC garbage collector

2011-05-09 Thread Basile Starynkevitch
On Mon, 09 May 2011 14:15:30 +0200
Pierre Vittet  wrote:

> This patch is for the MELT branch.

The diff file was slightly wrong (diff run under gcc/). Pierre, you
should run svn diff -x -p at the top source directory to get a patch
file.

I applied the patch. The gcc/ChangeLog.MELT proposed by Pierre was
wrong, I wrote:

2011-05-09  Pierre Vittet  

* melt-runtime.c (melt_garbcoll): Don't force collection by
gcc_collect.

Committed revision 173576.


Folks, what is the procedure to get Pierre an svn+ssh write access to
GCC svn server (mostly for the MELT branch, and write after approval
for the rest). As far as I understood, all legal stuff has been
completed.

> My GCC contributor number is 634276.

This is the copyright assignment legal document reference for Pierre Vittet.

What does he (or me) have to do to get svn+ssh://gcc.melt.org/ write access?

Cheers.
-- 
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basilestarynkevitchnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


Re: [PATCH, MELT] fix useless forcing of GCC garbage collector

2011-05-09 Thread Basile Starynkevitch
On Mon, 9 May 2011 19:03:54 +0200
Basile Starynkevitch  wrote:
> I applied the patch. The gcc/ChangeLog.MELT proposed by Pierre was
> wrong, I wrote:
> 
> 2011-05-09  Pierre Vittet  
> 
>   * melt-runtime.c (melt_garbcoll): Don't force collection by
>   gcc_collect.
> 
> Committed revision 173576.

Pierre & me forgot to update the comments, and remove the ggc_force_collect 
extern declaration.
So I added the following patch

Index: gcc/melt-runtime.c
===
--- gcc/melt-runtime.c  (revision 173576)
+++ gcc/melt-runtime.c  (working copy)
@@ -82,9 +82,6 @@ along with GCC; see the file COPYING3.   If not se
 /* GCC 4.6 has it: */
 #include "gimple-pretty-print.h"
 
-/* Flag ggc_force_collect is defined in ggc-internal.h so is officially not
-   public.  */
-extern bool ggc_force_collect;
 
 #endif /*GCC 4.6*/
 
@@ -1162,8 +1159,8 @@ melt_garbcoll (size_t wanted, enum melt_gckind_en
   melt_nb_full_garbcoll++;
   debugeprintf ("melt_garbcoll #%ld fullgarbcoll #%ld",
melt_nb_garbcoll, melt_nb_full_garbcoll);
-  /* force major collection, with our callback */
   debugeprintf ("melt_garbcoll calling gcc_collect #%ld", 
melt_nb_full_garbcoll);
+  /* There is no need to force a GGC collection.  */
   ggc_collect ();
   debugeprintf ("melt_garbcoll after fullgarbcoll #%ld", 
melt_nb_full_garbcoll);
   /* Delete the unmarked specials.  */

with the following gcc/ChangeLog.MELT entry
2011-05-09  Basile Starynkevitch  

* melt-runtime.c (ggc_force_collect): Remove extern declaration.
(melt_garbcoll): Update comment.

Cheers.

-- 
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basilestarynkevitchnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


Re: [patch] make default linker --hash-style configurable option

2011-05-09 Thread Paul Pluzhnikov
On Mon, May 9, 2011 at 9:51 AM, Joseph S. Myers  wrote:
> On Mon, 9 May 2011, Paolo Bonzini wrote:
>
>> Uhm, so we deadlocked, I thought the other way.  I cannot really
>> express any opinion about the desirability of the feature, but the
>> configure syntax is certainly okay with me, and I gather from the
>> thread that you are fine with that as well.
>
> Given the build system changes, the gcc.c changes are OK.

Ok for trunk then?

I'll wait till tomorrow in case someone has additional comments on the
desirability part.

Thanks!
-- 
Paul Pluzhnikov


Re: [C++0x] contiguous bitfields race implementation

2011-05-09 Thread Jeff Law
On 05/09/11 10:24, Aldy Hernandez wrote:
> Seeing that the current C++ draft has been approved, I'd like to submit
> this for mainline, and get the proper review everyone's being quietly
> avoiding :).
> 
> To refresh everyone's memory, here is the problem:
> 
> struct
> {
> unsigned int a : 4;
> unsigned char b;
> unsigned int c: 6;
> } var;
> 
> 
> void seta(){
>   var.a = 12;
> }
> 
> 
> In the new C++ standard, stores into  cannot touch , so we can't
> store with anything wider (e.g. a 32 bit store) that will touch .
> This problem can be seen on strictly aligned targets such as ARM, where
> we store the above sequence with a 32-bit store. Or on x86-64 with 
> being volatile (PR48124).
> 
> This patch fixes both problems, but only for the C++ memory model. This
> is NOT a generic fix PR48124, only a fix when using "--param
> allow-store-data-races=0".  I will gladly change the parameter name, if
> another is preferred.
> 
> The gist of this patch is in max_field_size(), where we calculate the
> maximum number of bits we can store into. In doing this calculation I
> assume we can store into the padding without causing any races. So,
> padding between fields and at the end of the structure are included.
Well, the kernel guys would like to be able to be able to preserve the
padding bits too.  It's a long long sad story that I won't repeat...
And I don't think we should further complicate this stuff with the
desire to not clobber padding bits :-)  Though be aware the request
might come one day


> 
> Tested on x86-64 both with and without "--param
> allow-store-data-races=0", and visually inspecting the assembly on
> arm-linux and ia64-linux.
Any way to add a test to the testsuite?

General approach seems OK; I didn't dive deeply into the implementation.
 I'll leave that for rth & jason :-)

jeff



Re: [C++0x] contiguous bitfields race implementation

2011-05-09 Thread Aldy Hernandez



struct
{
 unsigned int a : 4;
 unsigned char b;
 unsigned int c: 6;
} var;




Well, the kernel guys would like to be able to be able to preserve the
padding bits too.  It's a long long sad story that I won't repeat...
And I don't think we should further complicate this stuff with the
desire to not clobber padding bits :-)  Though be aware the request
might come one day


Woah, let me see if I got this right.  If we were to store in VAR.C 
above, the default for this memory model would be NOT to clobber the 
padding bits past ?  That definitely makes my implementation simpler, 
so I won't complain, but that's just weird.



Tested on x86-64 both with and without "--param
allow-store-data-races=0", and visually inspecting the assembly on
arm-linux and ia64-linux.

Any way to add a test to the testsuite?


Arghhh... I was afraid you'd ask for one.  It was much easier with the 
test harness on cxx-memory-model.  I'll whip one up though...


Aldy


C++ PATCH for c++/34772 (warning about self-initialization without -Winit-self)

2011-05-09 Thread Jason Merrill
In this testcase -Wuninitialized was warning about 'int i = i' without 
-Winit-self because the C++ front end always uses separate code for 
non-constant initialization.  But for simple initialization, it makes 
sense to use DECL_INITIAL.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit b105bfbee01e9183e7fc100f3a33c7c109db7fae
Author: Jason Merrill 
Date:   Sat May 7 17:31:09 2011 -0400

PR c++/34772
* decl.c (initialize_local_var): Use DECL_INITIAL for simple
initialization.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index c139f3f..c255e16 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5689,21 +5689,32 @@ initialize_local_var (tree decl, tree init)
   /* Perform the initialization.  */
   if (init)
 {
-  int saved_stmts_are_full_exprs_p;
+  if (TREE_CODE (init) == INIT_EXPR
+ && !TREE_SIDE_EFFECTS (TREE_OPERAND (init, 1)))
+   {
+ /* Stick simple initializers in DECL_INITIAL so that
+-Wno-init-self works (c++/34772).  */
+ gcc_assert (TREE_OPERAND (init, 0) == decl);
+ DECL_INITIAL (decl) = TREE_OPERAND (init, 1);
+   }
+  else
+   {
+ int saved_stmts_are_full_exprs_p;
 
-  /* If we're only initializing a single object, guard the destructors
-of any temporaries used in its initializer with its destructor.
-This isn't right for arrays because each element initialization is
-a full-expression.  */
-  if (cleanup && TREE_CODE (type) != ARRAY_TYPE)
-   wrap_temporary_cleanups (init, cleanup);
+ /* If we're only initializing a single object, guard the
+destructors of any temporaries used in its initializer with
+its destructor.  This isn't right for arrays because each
+element initialization is a full-expression.  */
+ if (cleanup && TREE_CODE (type) != ARRAY_TYPE)
+   wrap_temporary_cleanups (init, cleanup);
 
-  gcc_assert (building_stmt_tree ());
-  saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
-  current_stmt_tree ()->stmts_are_full_exprs_p = 1;
-  finish_expr_stmt (init);
-  current_stmt_tree ()->stmts_are_full_exprs_p =
-   saved_stmts_are_full_exprs_p;
+ gcc_assert (building_stmt_tree ());
+ saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
+ current_stmt_tree ()->stmts_are_full_exprs_p = 1;
+ finish_expr_stmt (init);
+ current_stmt_tree ()->stmts_are_full_exprs_p =
+   saved_stmts_are_full_exprs_p;
+   }
 }
 
   /* Set this to 0 so we can tell whether an aggregate which was
diff --git a/gcc/testsuite/c-c++-common/uninit-D-O0.c 
b/gcc/testsuite/c-c++-common/uninit-D-O0.c
new file mode 100644
index 000..e63cb80
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/uninit-D-O0.c
@@ -0,0 +1,9 @@
+/* Test we do not warn about initializing variable with self. */
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+int f()
+{
+  int i = i;
+  return i;
+}
diff --git a/gcc/testsuite/c-c++-common/uninit-D.c 
b/gcc/testsuite/c-c++-common/uninit-D.c
new file mode 100644
index 000..ea957e4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/uninit-D.c
@@ -0,0 +1,9 @@
+/* Test we do not warn about initializing variable with self. */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+int f()
+{
+  int i = i;
+  return i;
+}
diff --git a/gcc/testsuite/c-c++-common/uninit-E-O0.c 
b/gcc/testsuite/c-c++-common/uninit-E-O0.c
new file mode 100644
index 000..2cc2459
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/uninit-E-O0.c
@@ -0,0 +1,9 @@
+/* Test we do warn about initializing variable with self when -Winit-self is 
supplied. */
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized -Winit-self" } */
+
+int f()
+{
+  int i = i; /* { dg-warning "i" "uninitialized variable warning" }  */
+  return i;
+}
diff --git a/gcc/testsuite/c-c++-common/uninit-E.c 
b/gcc/testsuite/c-c++-common/uninit-E.c
new file mode 100644
index 000..eb356c3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/uninit-E.c
@@ -0,0 +1,9 @@
+/* Test we do warn about initializing variable with self when -Winit-self is 
supplied. */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized -Winit-self" } */
+
+int f()
+{
+  int i = i; /* { dg-warning "i" "uninitialized variable warning" }  */
+  return i;
+}
diff --git a/gcc/testsuite/c-c++-common/uninit-F-O0.c 
b/gcc/testsuite/c-c++-common/uninit-F-O0.c
new file mode 100644
index 000..737cc65
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/uninit-F-O0.c
@@ -0,0 +1,9 @@
+/* Test we do warn about initializing variable with self in the 
initialization. */
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+int f()
+{
+  int i = i + 1; /* { dg-warning "i" "uninitialized variable warning" }  */
+  return i;
+}
diff --git a/gcc/testsuite/c-c++-common/uninit-F.c 
b/gcc/testsuite/c-c++-common/uninit-F.c
new file mode 100644
index 000..1dbb3

[PATCH, i386]: Remove unneeded predicates

2011-05-09 Thread Uros Bizjak
Hello!

2011-05-09  Uros Bizjak  

* config/i386/predicates.md (const_pow2_1_to_2_operand): Remove.
(const_pow2_1_to_8_operand): Ditto.
(const_pow2_1_to_128_operand): Ditto.
(const_pow2_1_to_32768_operand): Ditto.
* config/i386/mmx.md (*mmx_pinsrw): Use const_int_operand instead of
const_pow2_1_to_8_operand for operand 3 predicate.  Use exact_log2
in insn constraint to check integer value of operand 3.
* config/i386/sse.md (*vec_setv4sf_sse4_1): Ditto.

(PINSR_MODE): New mode iterator.
(sse2p4_1): New mode attribute.
(_pinsr): Merge insn from sse4_1_pinsrb,
sse2_pinsrw, sse4_1_pinsrd and sse4_1_pinsrq using PINSR_MODE mode
iterator.  Use const_int_operand instead of
const_pow2_1_to_{2,8,128,32768}_operand for operand 3 predicate.  Use
exact_log2 in insn constraint to check integer value of operand 3.

2011-05-09  Uros Bizjak  

* config/i386/sse.md (blendbits): Remove mode attribute.
(_blend): Use const_int_operand
instead of const_0_to__operand for operand 3 predicate.
Check integer value of operand 3 in insn constraint.

Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN.

Uros.
Index: mmx.md
===
--- mmx.md  (revision 173569)
+++ mmx.md  (working copy)
@@ -1197,8 +1197,10 @@
   (vec_duplicate:V4HI
 (match_operand:HI 2 "nonimmediate_operand" "rm"))
  (match_operand:V4HI 1 "register_operand" "0")
-  (match_operand:SI 3 "const_pow2_1_to_8_operand" "n")))]
-  "TARGET_SSE || TARGET_3DNOW_A"
+  (match_operand:SI 3 "const_int_operand" "")))]
+  "(TARGET_SSE || TARGET_3DNOW_A)
+   && ((unsigned) exact_log2 (INTVAL (operands[3]))
+   < GET_MODE_NUNITS (V4HImode))"
 {
   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
   if (MEM_P (operands[2]))
Index: predicates.md
===
--- predicates.md   (revision 173569)
+++ predicates.md   (working copy)
@@ -688,36 +688,6 @@
   (and (match_code "const_int")
(match_test "IN_RANGE (INTVAL (op), 12, 15)")))
 
-;; Match exactly one bit in 2-bit mask.
-(define_predicate "const_pow2_1_to_2_operand"
-  (and (match_code "const_int")
-   (ior (match_test "op == const1_rtx")
-   (match_test "op == const2_rtx"
-
-;; Match exactly one bit in 4-bit mask.
-(define_predicate "const_pow2_1_to_8_operand"
-  (match_code "const_int")
-{
-  unsigned int log = exact_log2 (INTVAL (op));
-  return log <= 3;
-})
-
-;; Match exactly one bit in 8-bit mask.
-(define_predicate "const_pow2_1_to_128_operand"
-  (match_code "const_int")
-{
-  unsigned int log = exact_log2 (INTVAL (op));
-  return log <= 7;
-})
-
-;; Match exactly one bit in 16-bit mask.
-(define_predicate "const_pow2_1_to_32768_operand"
-  (match_code "const_int")
-{
-  unsigned int log = exact_log2 (INTVAL (op));
-  return log <= 15;
-})
-
 ;; True if this is a constant appropriate for an increment or decrement.
 (define_predicate "incdec_operand"
   (match_code "const_int")
Index: sse.md
===
--- sse.md  (revision 173569)
+++ sse.md  (working copy)
@@ -178,10 +178,6 @@
 (define_mode_attr sserotatemax
   [(V16QI "7") (V8HI "15") (V4SI "31") (V2DI "63")])
 
-;; Mapping of immediate bits for blend instructions
-(define_mode_attr blendbits
-  [(V8SF "255") (V4SF "15") (V4DF "15") (V2DF "3")])
-
 ;; Instruction suffix for sign and zero extensions.
 (define_code_attr extsuffix [(sign_extend "sx") (zero_extend "zx")])
 
@@ -3337,7 +,7 @@
   [(set_attr "type" "sselog,ssemov,mmxcvt,mmxmov")
(set_attr "mode" "V4SF,SF,DI,DI")])
 
-(define_insn "*vec_concatv4sf_sse"
+(define_insn "*vec_concatv4sf"
   [(set (match_operand:V4SF 0 "register_operand"   "=x,x,x,x")
(vec_concat:V4SF
  (match_operand:V2SF 1 "register_operand" " 0,x,0,x")
@@ -3445,8 +3441,10 @@
  (vec_duplicate:V4SF
(match_operand:SF 2 "nonimmediate_operand" "xm,xm"))
  (match_operand:V4SF 1 "register_operand" "0,x")
- (match_operand:SI 3 "const_pow2_1_to_8_operand" "n,n")))]
-  "TARGET_SSE4_1"
+ (match_operand:SI 3 "const_int_operand" "")))]
+  "TARGET_SSE4_1
+   && ((unsigned) exact_log2 (INTVAL (operands[3]))
+   < GET_MODE_NUNITS (V4SFmode))"
 {
   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])) << 4);
   switch (which_alternative)
@@ -6055,129 +6053,72 @@
(set_attr "prefix" "orig,vex")
(set_attr "mode" "TI")])
 
-(define_insn "sse4_1_pinsrb"
-  [(set (match_operand:V16QI 0 "register_operand" "=x,x,x,x")
-   (vec_merge:V16QI
- (vec_duplicate:V16QI
-   (match_operand:QI 2 "nonimmediate_operand" "r,m,r,m"))
- (match_operand:V16QI 1 "register_operand" "0,0,x,x")
- (match_operand:SI 3 "const_pow2_1_to_3276

Re: [C++ Patch] PRs 48737 & 48744

2011-05-09 Thread Jason Merrill

OK, thanks.

Jason


Re: [PATCH, testsuite]: Add -mprefer-avx128 to DEFAULT_VECTCFLAGS

2011-05-09 Thread H.J. Lu
On Mon, May 9, 2011 at 9:44 AM, Uros Bizjak  wrote:
> Hello!
>
> Vectorizer testsuite assumes 128bit vector widths. AVX breaks this
> assumption and that results in various spurious testsuite failures.
>
> Attached patch clears all failures on AVX target.
>
> 2011-05-09  Uros Bizjak  
>
>        * lib/target-supports.exp (check_vect_support_and_set_flags)
>        : Add -mprefer-avx128 to DEFAULT_VECTCFLAGS.
>
> Uros.
>
> Index: lib/target-supports.exp
> ===
> --- lib/target-supports.exp     (revision 173569)
> +++ lib/target-supports.exp     (working copy)
> @@ -3845,6 +3845,8 @@
>         set dg-do-what-default run
>     } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
>         lappend DEFAULT_VECTCFLAGS "-msse2"
> +       # FIXME: Vectorizer testsuite assumes 128bit vector widths.
> +       lappend DEFAULT_VECTCFLAGS "-mprefer-avx128"
>         if { [check_effective_target_sse2_runtime] } {
>             set dg-do-what-default run
>         } else {
>

That means 256bit vectorizer won't be tested. I think we
should investigate each testcase and update it if needed.

Thanks.

-- 
H.J.


PING: [PATCH] Fix up typed DWARF stack support for POINTERS_EXTEND_UNSIGNED targets (PR debug/48853)

2011-05-09 Thread H.J. Lu
On Fri, May 6, 2011 at 6:11 PM, H.J. Lu  wrote:
> On Thu, May 5, 2011 at 2:20 AM, Jakub Jelinek  wrote:
>> Hi!
>>
>> My typed DWARF stack changes apparently broke ia64-hpux and H.J.'s out of
>> tree x32 target.  There are several issues:
>> 1) for SUBREG mem_loc_descriptor's 3rd argument was wrong, found by code
>>   inspection
>> 2) CONST/SYMBOL_REF/LABEL_REF when in MEM addresses on 
>> POINTERS_EXTEND_UNSIGNED
>>   targets are often Pmode, which is unfortunately larger than 
>> DWARF2_ADDR_SIZE
>>   and my conditional would just return NULL in that case instead of
>>   emitting DW_OP_addr.
>> 3) and, when mem_loc_descriptor is called from unwind code, Pmodes larger
>>   than DWARF2_ADDR_SIZE would result in the new DW_OP_GNU_*_type etc. ops
>>   which are not allowed in .eh_frame/.debug_frame
>> The following patch ought to fix that, bootstrapped/regtested on
>> x86_64-linux and i686-linux and Steve tested it on ia64-hpux and H.J. on his
>> port.  Ok for trunk?
>>
>> 2011-05-05  Jakub Jelinek  
>>
>>        PR debug/48853
>>        * dwarf2out.c (mem_loc_descriptor) : Pass mem_mode
>>        instead of mode as 3rd argument to recursive call.
>>        (mem_loc_descriptor) : If POINTERS_EXTEND_UNSIGNED, don't
>>        emit DW_OP_GNU_regval_type if mode is Pmode and mem_mode is not
>>        VOIDmode.
>>        (mem_loc_descriptor) : If POINTERS_EXTEND_UNSIGNED,
>>        don't give up if mode is Pmode and mem_mode is not VOIDmode.
>>        (mem_loc_descriptor) : If POINTERS_EXTEND_UNSIGNED,
>>        use int_loc_descriptor if mode is Pmode and mem_mode is not VOIDmode.
>>
>
> Here is the missing patch for case SUBREG.  OK for trunk if there is
> no regressions?
>
> Thanks.
>
>
> H.J.
> 
> 2011-05-06  H.J. Lu  
>
>        PR debug/48853
>        * dwarf2out.c (mem_loc_descriptor) : If
>        POINTERS_EXTEND_UNSIGNED, don't give up if mode is Pmode and
>        mem_mode is not VOIDmode.
>
> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> index 026e4a7..049ca8e 100644
> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -13892,7 +13892,11 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
>        break;
>       if (GET_MODE_CLASS (mode) == MODE_INT
>          && GET_MODE_CLASS (GET_MODE (SUBREG_REG (rtl))) == MODE_INT
> -         && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
> +         && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
> +#ifdef POINTERS_EXTEND_UNSIGNED
> +             || (mode == Pmode && mem_mode != VOIDmode)
> +#endif
> +            )
>          && GET_MODE_SIZE (GET_MODE (SUBREG_REG (rtl))) <= DWARF2_ADDR_SIZE)
>        {
>          mem_loc_result = mem_loc_descriptor (SUBREG_REG (rtl),
>

PING.

-- 
H.J.


C++ PATCH for c++/48936 (failure with static constant template variable in sizeof)

2011-05-09 Thread Jason Merrill
This issue had to do with us bailing out too soon when trying to 
mark_used a constant variable in an unevaluated context.  I fixed this 
for 4.6 as part of the constexpr work, but a subset of that patch seems 
suitable for backporting.


Tested x86_64-pc-linux-gnu, applying to 4.4 and 4.5.
commit fc071e935530d226d24e08c25e5f66b0c61f0654
Author: Jason Merrill 
Date:   Mon May 9 09:42:17 2011 -0400

PR c++/48936
* decl2.c (mark_used): Instantiate constant variables even
in unevaluated context.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index d27ed43..6c33434 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3991,8 +3991,6 @@ possibly_inlined_p (tree decl)
 void
 mark_used (tree decl)
 {
-  HOST_WIDE_INT saved_processing_template_decl = 0;
-
   /* If DECL is a BASELINK for a single function, then treat it just
  like the DECL for the function.  Otherwise, if the BASELINK is
  for an overloaded function, we don't know which function was
@@ -4029,9 +4027,6 @@ mark_used (tree decl)
   error ("used here");
   return;
 }
-  /* If we don't need a value, then we don't need to synthesize DECL.  */
-  if (cp_unevaluated_operand != 0)
-return;
 
   /* We can only check DECL_ODR_USED on variables or functions with
  DECL_LANG_SPECIFIC set, and these are also the only decls that we
@@ -4059,9 +4054,10 @@ mark_used (tree decl)
  DECL.  However, if DECL is a static data member initialized with
  a constant, we need the value right now because a reference to
  such a data member is not value-dependent.  */
-  if (TREE_CODE (decl) == VAR_DECL
-  && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)
-  && DECL_CLASS_SCOPE_P (decl))
+  if (DECL_INTEGRAL_CONSTANT_VAR_P (decl)
+  && !DECL_INITIAL (decl)
+  && DECL_LANG_SPECIFIC (decl)
+  && DECL_TEMPLATE_INSTANTIATION (decl))
 {
   /* Don't try to instantiate members of dependent types.  We
 cannot just use dependent_type_p here because this function
@@ -4071,12 +4067,14 @@ mark_used (tree decl)
   if (CLASSTYPE_TEMPLATE_INFO ((DECL_CONTEXT (decl)))
  && uses_template_parms (CLASSTYPE_TI_ARGS (DECL_CONTEXT (decl
return;
-  /* Pretend that we are not in a template, even if we are, so
-that the static data member initializer will be processed.  */
-  saved_processing_template_decl = processing_template_decl;
-  processing_template_decl = 0;
+  instantiate_decl (decl, /*defer_ok=*/false,
+   /*expl_inst_class_mem_p=*/false);
 }
 
+  /* If we don't need a value, then we don't need to synthesize DECL.  */
+  if (cp_unevaluated_operand != 0)
+return;
+
   if (processing_template_decl)
 return;
 
@@ -4149,8 +4147,6 @@ mark_used (tree decl)
need.  Therefore, we always try to defer instantiation.  */
 instantiate_decl (decl, /*defer_ok=*/true,
  /*expl_inst_class_mem_p=*/false);
-
-  processing_template_decl = saved_processing_template_decl;
 }
 
 #include "gt-cp-decl2.h"
diff --git a/gcc/testsuite/g++.dg/template/nontype23.C 
b/gcc/testsuite/g++.dg/template/nontype23.C
new file mode 100644
index 000..dfda4fe
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/nontype23.C
@@ -0,0 +1,9 @@
+// PR c++/48936
+
+template  int foo (void);
+template  struct S
+{
+  static const unsigned int a = sizeof (T);
+  enum { c = sizeof (foo <(a == 0)> ()) };
+};
+S x;


Re: [C++0x] contiguous bitfields race implementation

2011-05-09 Thread Jeff Law
On 05/09/11 11:26, Aldy Hernandez wrote:
> 
>>> struct
>>> {
>>>  unsigned int a : 4;
>>>  unsigned char b;
>>>  unsigned int c: 6;
>>> } var;
> 
> 
>> Well, the kernel guys would like to be able to be able to preserve the
>> padding bits too.  It's a long long sad story that I won't repeat...
>> And I don't think we should further complicate this stuff with the
>> desire to not clobber padding bits :-)  Though be aware the request
>> might come one day
> 
> Woah, let me see if I got this right.  If we were to store in VAR.C
> above, the default for this memory model would be NOT to clobber the
> padding bits past ?  That definitely makes my implementation simpler,
> so I won't complain, but that's just weird.
Just to be clear, it's something I've discussed with the kernel guys and
is completely separate from the C++ memory model.  I don't think we
should wrap this into your current work.

Consider if the kernel team wanted to add some information to a
structure without growing the structure.  Furthermore, assume that the
structure escapes, say into modules that aren't necessarily going to be
rebuilt, but those modules won't need to ever access this new
information.  And assume there happens to be enough padding bits to hold
this auxiliary information.

This has actually occurred and the kernel team wanted to use the padding
bits to hold the auxiliary information and maintain kernel ABI/API
compatibility.  Unfortunately, a store to a nearby bitfield can
overwrite the padding, thus if the structure escaped to a module that
still thought the bits were padding, that module would/could clobber
those padding bits, destroying the auxiliary data.

If GCC had a mode where it would preserve the padding bits (when
possible), it'd help the kernel team in these situations.



> 
> Arghhh... I was afraid you'd ask for one.  It was much easier with the
> test harness on cxx-memory-model.  I'll whip one up though...
Given others have (rightly) called me out on it a lot recently, I
figured I'd pass along the love :-)

jeff




Re: [PATCH] Fix up typed DWARF stack support for POINTERS_EXTEND_UNSIGNED targets (PR debug/48853)

2011-05-09 Thread Jason Merrill

OK.

Jason


Use expr_location_or in more cases

2011-05-09 Thread Eric Botcazou
This patch changes fold_ternary_loc to use the new expr_location_or instead of 
the manual equivalent; no functional changes.  Once this is done, grepping the 
file for UNKNOWN_LOCATION yields one occurrence (apart from expr_location_or):

  if ((lhs == 0 || rhs == 0 || operand_equal_p (lhs, rhs, 0))
  && merge_ranges (&in_p, &low, &high, in0_p, low0, high0,
   in1_p, low1, high1)
  && 0 != (tem = (build_range_check (UNKNOWN_LOCATION, type,
 lhs != 0 ? lhs
 : rhs != 0 ? rhs : integer_zero_node,
 in_p, low, high
{
  if (strict_overflow_p)
fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
  return or_op ? invert_truthvalue_loc (loc, tem) : tem;
}

It comes from the original loc-ification patch and seems to be an oversight, as 
invert_truthvalue_loc uses LOC just below.  Changed to using LOC as well.

Tested on i586-suse-linux, applied on the mainline as obvious.


2011-05-09  Eric Botcazou  

* fold-const.c (fold_range_test): Pass LOC to build_range_check.
(fold_ternary_loc): Use expr_location_or.


-- 
Eric Botcazou
Index: fold-const.c
===
--- fold-const.c	(revision 173545)
+++ fold-const.c	(working copy)
@@ -4822,7 +4822,7 @@ fold_range_test (location_t loc, enum tr
   if ((lhs == 0 || rhs == 0 || operand_equal_p (lhs, rhs, 0))
   && merge_ranges (&in_p, &low, &high, in0_p, low0, high0,
 		   in1_p, low1, high1)
-  && 0 != (tem = (build_range_check (UNKNOWN_LOCATION, type,
+  && 0 != (tem = (build_range_check (loc, type,
 	 lhs != 0 ? lhs
 	 : rhs != 0 ? rhs : integer_zero_node,
 	 in_p, low, high
@@ -13332,9 +13332,7 @@ fold_ternary_loc (location_t loc, enum t
 	 TREE_OPERAND (arg0, 1))
 	  && !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op2
 	{
-	  location_t loc0 = EXPR_LOCATION (arg0);
-	  if (loc0 == UNKNOWN_LOCATION)
-	loc0 = loc;
+	  location_t loc0 = expr_location_or (arg0, loc);
 	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem && COMPARISON_CLASS_P (tem))
 	{
@@ -13349,9 +13347,7 @@ fold_ternary_loc (location_t loc, enum t
   if (truth_value_p (TREE_CODE (arg0))
 	  && tree_swap_operands_p (op1, op2, false))
 	{
-	  location_t loc0 = EXPR_LOCATION (arg0);
-	  if (loc0 == UNKNOWN_LOCATION)
-	loc0 = loc;
+	  location_t loc0 = expr_location_or (arg0, loc);
 	  /* See if this can be inverted.  If it can't, possibly because
 	 it was a floating-point inequality comparison, don't do
 	 anything.  */
@@ -13500,9 +13496,7 @@ fold_ternary_loc (location_t loc, enum t
 	  && truth_value_p (TREE_CODE (arg0))
 	  && truth_value_p (TREE_CODE (arg1)))
 	{
-	  location_t loc0 = EXPR_LOCATION (arg0);
-	  if (loc0 == UNKNOWN_LOCATION)
-	loc0 = loc;
+	  location_t loc0 = expr_location_or (arg0, loc);
 	  /* Only perform transformation if ARG0 is easily inverted.  */
 	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem)
@@ -13516,9 +13510,7 @@ fold_ternary_loc (location_t loc, enum t
 	  && truth_value_p (TREE_CODE (arg0))
 	  && truth_value_p (TREE_CODE (op2)))
 	{
-	  location_t loc0 = EXPR_LOCATION (arg0);
-	  if (loc0 == UNKNOWN_LOCATION)
-	loc0 = loc;
+	  location_t loc0 = expr_location_or (arg0, loc);
 	  /* Only perform transformation if ARG0 is easily inverted.  */
 	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem)


Re: [C++0x] contiguous bitfields race implementation

2011-05-09 Thread Aldy Hernandez
end_bit - first_bit, first_bit,
+  lnmode = get_best_mode (end_bit - first_bit, first_bit, 0,
  TYPE_ALIGN (TREE_TYPE (ll_inner)), word_mode,
  volatilep);
   if (lnmode == VOIDmode)
@@ -5302,7 +5302,7 @@ fold_truthop (location_t loc, enum tree_
 
   first_bit = MIN (lr_bitpos, rr_bitpos);
   end_bit = MAX (lr_bitpos + lr_bitsize, rr_bitpos + rr_bitsize);
-  rnmode = get_best_mode (end_bit - first_bit, first_bit,
+  rnmode = get_best_mode (end_bit - first_bit, first_bit, 0,
  TYPE_ALIGN (TREE_TYPE (lr_inner)), word_mode,
  volatilep);
   if (rnmode == VOIDmode)
Index: params.h
===
--- params.h(revision 173263)
+++ params.h(working copy)
@@ -206,4 +206,6 @@ extern void init_param_values (int *para
   PARAM_VALUE (PARAM_MIN_NONDEBUG_INSN_UID)
 #define MAX_STORES_TO_SINK \
   PARAM_VALUE (PARAM_MAX_STORES_TO_SINK)
+#define ALLOW_STORE_DATA_RACES \
+  PARAM_VALUE (PARAM_ALLOW_STORE_DATA_RACES)
 #endif /* ! GCC_PARAMS_H */
Index: testsuite/gcc.dg/20110509.c
===
--- testsuite/gcc.dg/20110509.c (revision 0)
+++ testsuite/gcc.dg/20110509.c (revision 0)
@@ -0,0 +1,18 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 --param allow-store-data-races=0" } */
+
+/* Test that we don't store past VAR.A.  */
+
+struct S
+{
+  volatile unsigned int a : 4;
+  unsigned char b;
+  unsigned int c : 6;
+} var;
+
+void set_a()
+{
+  var.a = 12;
+}
+
+/* { dg-final { scan-assembler-not "movl.*, var" } } */
Index: ifcvt.c
===
--- ifcvt.c (revision 173263)
+++ ifcvt.c (working copy)
@@ -885,7 +885,7 @@ noce_emit_move_insn (rtx x, rtx y)
}
 
  gcc_assert (start < (MEM_P (op) ? BITS_PER_UNIT : BITS_PER_WORD));
- store_bit_field (op, size, start, GET_MODE (x), y);
+ store_bit_field (op, size, start, 0, GET_MODE (x), y);
  return;
}
 
@@ -939,7 +939,7 @@ noce_emit_move_insn (rtx x, rtx y)
   inner = XEXP (outer, 0);
   outmode = GET_MODE (outer);
   bitpos = SUBREG_BYTE (outer) * BITS_PER_UNIT;
-  store_bit_field (inner, GET_MODE_BITSIZE (outmode), bitpos, outmode, y);
+  store_bit_field (inner, GET_MODE_BITSIZE (outmode), bitpos, 0, outmode, y);
 }
 
 /* Return sequence of instructions generated by if conversion.  This
Index: expr.c
===
--- expr.c  (revision 173263)
+++ expr.c  (working copy)
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3.  
 #include "diagnostic.h"
 #include "ssaexpand.h"
 #include "target-globals.h"
+#include "params.h"
 
 /* Decide whether a function's arguments should be processed
from first to last or from last to first.
@@ -142,7 +143,8 @@ static void store_constructor_field (rtx
 HOST_WIDE_INT, enum machine_mode,
 tree, tree, int, alias_set_type);
 static void store_constructor (tree, rtx, int, HOST_WIDE_INT);
-static rtx store_field (rtx, HOST_WIDE_INT, HOST_WIDE_INT, enum machine_mode,
+static rtx store_field (rtx, HOST_WIDE_INT, HOST_WIDE_INT,
+   unsigned HOST_WIDE_INT, enum machine_mode,
tree, tree, alias_set_type, bool);
 
 static unsigned HOST_WIDE_INT highest_pow2_factor_for_target (const_tree, 
const_tree);
@@ -2063,7 +2065,7 @@ emit_group_store (rtx orig_dst, rtx src,
emit_move_insn (adjust_address (dest, mode, bytepos), tmps[i]);
   else
store_bit_field (dest, bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT,
-mode, tmps[i]);
+0, mode, tmps[i]);
 }
 
   /* Copy from the pseudo into the (probable) hard reg.  */
@@ -2157,7 +2159,7 @@ copy_blkmode_from_reg (rtx tgtblk, rtx s
 
   /* Use xbitpos for the source extraction (right justified) and
 bitpos for the destination store (left justified).  */
-  store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, copy_mode,
+  store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, 0, copy_mode,
   extract_bit_field (src, bitsize,
  xbitpos % BITS_PER_WORD, 1, false,
  NULL_RTX, copy_mode, copy_mode));
@@ -2794,7 +2796,7 @@ write_complex_part (rtx cplx, rtx val, b
gcc_assert (MEM_P (cplx) && ibitsize < BITS_PER_WORD);
 }
 
-  store_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0, imode, val);
+  store_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0, 0, imode, val);
 }
 
 /* Extract one of the components of the complex value CPLX.  Extract 

Re: PING: [PATCH] Fix up typed DWARF stack support for POINTERS_EXTEND_UNSIGNED targets (PR debug/48853)

2011-05-09 Thread Jakub Jelinek
On Mon, May 09, 2011 at 10:58:56AM -0700, H.J. Lu wrote:
> On Fri, May 6, 2011 at 6:11 PM, H.J. Lu  wrote:
> > 2011-05-06  H.J. Lu  
> >
> >        PR debug/48853
> >        * dwarf2out.c (mem_loc_descriptor) : If
> >        POINTERS_EXTEND_UNSIGNED, don't give up if mode is Pmode and
> >        mem_mode is not VOIDmode.
> >
> > diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> > index 026e4a7..049ca8e 100644
> > --- a/gcc/dwarf2out.c
> > +++ b/gcc/dwarf2out.c
> > @@ -13892,7 +13892,11 @@ mem_loc_descriptor (rtx rtl, enum machine_mode 
> > mode,
> >        break;
> >       if (GET_MODE_CLASS (mode) == MODE_INT
> >          && GET_MODE_CLASS (GET_MODE (SUBREG_REG (rtl))) == MODE_INT
> > -         && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
> > +         && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
> > +#ifdef POINTERS_EXTEND_UNSIGNED
> > +             || (mode == Pmode && mem_mode != VOIDmode)
> > +#endif
> > +            )
> >          && GET_MODE_SIZE (GET_MODE (SUBREG_REG (rtl))) <= DWARF2_ADDR_SIZE)
> >        {
> >          mem_loc_result = mem_loc_descriptor (SUBREG_REG (rtl),
> >
> 
> PING.

Can you please explain how do you get such a SUBREG in a MEM address?

Jakub


Re: [PATCH, testsuite]: Add -mprefer-avx128 to DEFAULT_VECTCFLAGS

2011-05-09 Thread Joseph S. Myers
On Mon, 9 May 2011, H.J. Lu wrote:

> > Index: lib/target-supports.exp
> > ===
> > --- lib/target-supports.exp     (revision 173569)
> > +++ lib/target-supports.exp     (working copy)
> > @@ -3845,6 +3845,8 @@
> >         set dg-do-what-default run
> >     } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
> >         lappend DEFAULT_VECTCFLAGS "-msse2"
> > +       # FIXME: Vectorizer testsuite assumes 128bit vector widths.
> > +       lappend DEFAULT_VECTCFLAGS "-mprefer-avx128"
> >         if { [check_effective_target_sse2_runtime] } {
> >             set dg-do-what-default run
> >         } else {
> >
> 
> That means 256bit vectorizer won't be tested. I think we
> should investigate each testcase and update it if needed.

I think we should work out how to get the various vectorizer testsuites to 
run multiple times, with each vector ISA variant that's available on the 
target architecture (so you'd test SSE; 128-bit AVX; 256-bit AVX; and 
maybe other variants - each variant tested with execution testing if 
there's hardware support, compile testing otherwise), like the torture 
testsuites run each test multiple times with different options.  Though 
that certainly complicates all the effective target tests for 
vectorization support, since the results may depend on the options as well 
as the target.

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

Re: [C++0x] contiguous bitfields race implementation

2011-05-09 Thread Jakub Jelinek
On Mon, May 09, 2011 at 01:41:13PM -0500, Aldy Hernandez wrote:
> Jakub also gave me a testcase which triggered a buglet in
> max_field_size.  I have now added a parameter INNERDECL which is the
> inner reference, so we can properly determine if the inner decl is
> thread visible or not.

What I meant actually was something different, if max_field_size
and get_inner_reference was called on say
COMPONENT_REF , bitfld>
then get_inner_reference returns the whole x and bitpos
is the relative bit position of bitfld within the struct plus
4 * sizeof the containing struct.  Then 
TREE_INT_CST_LOW (TYPE_SIZE (record_type)) - bitpos
might get negative (well, it is unsigned, so huge).
Maybe with MEM_REF such nested handled components shouldn't appear,
if that's the case, you should assert that somewhere.
If it appears, you should probably use TREE_OPERAND (component_ref, 2)
instead of bitpos.

BTW, shouldn't BIT_FIELD_REF also be handled similarly to the COMPONENT_REF?
And, probably some coordination with Richi is needed with his bitfield tree
lowering.

Jakub


[PATCH] Fix dfp issue with dconst{1,2,m1,half} (PR debug/48928)

2011-05-09 Thread Jakub Jelinek
Hi!

The folder/middle-end/tree passes/rtl passes apparently use
dconst{1,2,m1,half} and/or const_tiny_rtx[{1,2}][{S,D,T}Dmode]
in various places.  E.g.
  /* Convert x+x into x*2.0.  */
  if (operand_equal_p (arg0, arg1, 0)
  && SCALAR_FLOAT_TYPE_P (type))
return fold_build2_loc (loc, MULT_EXPR, type, arg0,
build_real (type, dconst2));
Unfortunately, dconst{1,2,m1,half} are binary REAL_FORMATs, not decimal.
In most places real.c or dfp.c just converts constants to decimal,
but when doing decimal_to_decnumber on such constants it fails with an
assertion failure.
While we perhaps could add code to handle decimal stuff in all places
where dconst{1,2,m1,half} is mentioned, say create dconstdfp{1,2,m1,half},
I think it would just make all the code harder to maintain, so instead
of that this patch just magically converts those binary tiny predefined
constants to decimal.  Instead of calling decimal_from_binary
which converts it to string and then from string back to dn the patch
just converts strings to dn.

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

2011-05-09  Jakub Jelinek  

PR debug/48928
* dfp.c (decimal_to_decnumber): Handle conversion from
dconst{1,2,m1,half}.

* gcc.dg/dfp/pr48928.c: New test.

--- gcc/dfp.c.jj2010-12-02 11:51:32.0 +0100
+++ gcc/dfp.c   2011-05-09 11:08:43.0 +0200
@@ -110,7 +110,33 @@ decimal_to_decnumber (const REAL_VALUE_T
 decNumberFromString (dn, "nan", &set);
   break;
 case rvc_normal:
-  gcc_assert (r->decimal);
+  if (!r->decimal)
+   {
+ /* dconst{1,2,m1,half} are used in various places in
+the middle-end and optimizers, allow them here
+as an exception by converting them to decimal.  */
+ if (memcmp (r, &dconst1, sizeof (*r)) == 0)
+   {
+ decNumberFromString (dn, "1", &set);
+ break;
+   }
+ if (memcmp (r, &dconst2, sizeof (*r)) == 0)
+   {
+ decNumberFromString (dn, "2", &set);
+ break;
+   }
+ if (memcmp (r, &dconstm1, sizeof (*r)) == 0)
+   {
+ decNumberFromString (dn, "-1", &set);
+ break;
+   }
+ if (memcmp (r, &dconsthalf, sizeof (*r)) == 0)
+   {
+ decNumberFromString (dn, "0.5", &set);
+ break;
+   }
+ gcc_unreachable ();
+   }
   decimal128ToNumber ((const decimal128 *) r->sig, dn);
   break;
 default:
--- gcc/testsuite/gcc.dg/dfp/pr48928.c.jj   2011-05-09 11:23:59.0 
+0200
+++ gcc/testsuite/gcc.dg/dfp/pr48928.c  2011-05-09 11:23:24.0 +0200
@@ -0,0 +1,10 @@
+/* PR debug/48928 */
+/* { dg-do compile } */
+/* { dg-options "-g -O2" } */
+
+_Decimal32
+foo (_Decimal32 x)
+{
+  _Decimal32 y = (x + x) / (9.DF * x);
+  return y;
+}

Jakub


[PATCH] Fix remove_unreachable_handlers (PR tree-optimization/48794, tree-optimization/48611)

2011-05-09 Thread Jakub Jelinek
Hi!

As the new testcase shows, while my PR48611 patch stopped the problem from
triggering on that testcase, it wasn't a real fix, just (IMHO) right thing
to do to get better code.

The real problem seems to be that if for whatever reason some optimizations
don't happen or don't happen fully (in the testcase because of a series
of -fno-* options), we might end up with an EH region where nothing inside
of the region might throw, but there are RESX or EH_DISPATCH stmts
referencing that region.  If the region is removed as unreachable, but the
RESX or EH_DISPATCH stays, it references a removed region and it will ICE
during inlining or afterwards.

The following patch fixes it by just keeping such regions around, I think it
shouldn't happen if people don't turn optimizations off or at least
shouldn't happen often.  Other alternative would be to modify
RESX/EH_HANDLER referencing the unreachable regions, the question is
what to put there instead or if it can be e.g. removed altogether or
replaced with __builtin_trap.

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

2011-05-09  Jakub Jelinek  

PR tree-optimization/48611
PR tree-optimization/48794
* tree-eh.c (remove_unreachable_handlers): Don't remove regions
referenced from RESX or EH_DISPATCH arguments.

* gfortran.dg/gomp/pr48611.f90: New test.
* gfortran.dg/gomp/pr48794.f90: New test.

--- gcc/tree-eh.c.jj2011-05-02 18:39:28.0 +0200
+++ gcc/tree-eh.c   2011-05-09 17:31:12.0 +0200
@@ -3317,6 +3317,19 @@ remove_unreachable_handlers (void)
  SET_BIT (r_reachable, region->index);
  SET_BIT (lp_reachable, lp_nr);
}
+
+ /* Avoid removing regions referenced from RESX/EH_DISPATCH.  */
+ switch (gimple_code (stmt))
+   {
+   case GIMPLE_RESX:
+ SET_BIT (r_reachable, gimple_resx_region (stmt));
+ break;
+   case GIMPLE_EH_DISPATCH:
+ SET_BIT (r_reachable, gimple_eh_dispatch_region (stmt));
+ break;
+   default:
+ break;
+   }
}
 }
 
--- gcc/testsuite/gfortran.dg/gomp/pr48611.f90.jj   2011-05-09 
17:33:15.0 +0200
+++ gcc/testsuite/gfortran.dg/gomp/pr48611.f90  2011-05-09 17:32:10.0 
+0200
@@ -0,0 +1,12 @@
+! PR tree-optimization/48611
+! { dg-do compile }
+! { dg-options "-Os -fopenmp -fexceptions -fno-tree-ccp -fno-tree-copy-prop" }
+
+  integer, allocatable :: a(:)
+  logical :: l
+!$omp parallel private (a) reduction (.or.:l)
+  do i = 1, 7
+a(:) = i
+  end do
+!$omp end parallel
+end
--- gcc/testsuite/gfortran.dg/gomp/pr48794.f90.jj   2011-05-09 
17:33:19.0 +0200
+++ gcc/testsuite/gfortran.dg/gomp/pr48794.f90  2011-05-09 17:33:35.0 
+0200
@@ -0,0 +1,12 @@
+! PR tree-optimization/48794
+! { dg-do compile }
+! { dg-options "-Os -fopenmp -fexceptions -fno-tree-ccp -fno-tree-copy-prop" }
+
+  integer, allocatable :: a(:)
+  logical :: l
+  if (allocated (a)) call abort
+!$omp parallel private (a) reduction (.or.:l)
+  do i = 1, 7
+  end do
+!$omp end parallel
+end

Jakub


Re: [C++0x] contiguous bitfields race implementation

2011-05-09 Thread Jason Merrill
From a quick look it seems that this patch considers bitfields 
following the one we're deliberately touching, but not previous 
bitfields in the same memory location; we need to include those as well. 
 With your struct foo, the bits touched are the same regardless of 
whether we name .a or .b.


Jason


[Patch] testcase for c++/20039

2011-05-09 Thread Fabien Chêne
Hi,

PR c++/20039 was closed without providing a testcase, here's one.
tested x86_64-unknown-linux-gnu.

OK for trunk ?

gcc/testsuite/ChangeLog:

2011-05-09  Fabien Chêne  
PR c++/20039
* g++.dg/init/pr20039.C: New.

-- 
Fabien


pr20039.patch
Description: Binary data


Re: [Patch] testcase for c++/20039

2011-05-09 Thread Jason Merrill

OK.

Jason


Re: Fix problem with guality tests

2011-05-09 Thread Mike Stump
On Mar 17, 2011, at 1:33 PM, Jeff Law wrote:
> The guality tests can randomly fail due to expect buffering issues.

> OK for trunk?

Generally, I really would prefer the people that create and maintain an area to 
review and approve these sorts of changes...  The narrower the reviewer, the 
better.  Failing that...

Ok.


Re: [PATCH, MELT] fix useless forcing of GCC garbage collector

2011-05-09 Thread Pierre Vittet

Thanks you for the correction, I will take care next time.

Pierre
On 09/05/2011 19:03, Basile Starynkevitch wrote:

On Mon, 09 May 2011 14:15:30 +0200
Pierre Vittet  wrote:

   

This patch is for the MELT branch.
 

The diff file was slightly wrong (diff run under gcc/). Pierre, you
should run svn diff -x -p at the top source directory to get a patch
file.

I applied the patch. The gcc/ChangeLog.MELT proposed by Pierre was
wrong, I wrote:

2011-05-09  Pierre Vittet

* melt-runtime.c (melt_garbcoll): Don't force collection by
gcc_collect.

Committed revision 173576.


Folks, what is the procedure to get Pierre an svn+ssh write access to
GCC svn server (mostly for the MELT branch, and write after approval
for the rest). As far as I understood, all legal stuff has been
completed.

   

My GCC contributor number is 634276.
 

This is the copyright assignment legal document reference for Pierre Vittet.

What does he (or me) have to do to get svn+ssh://gcc.melt.org/ write access?

Cheers.
   




Re: Fix thinko in var-tracking.c

2011-05-09 Thread Mike Stump
On May 9, 2011, at 6:05 AM, Joseph S. Myers wrote:
> The guality tests have random results.  I don't know if that's the issue 
> here, but perhaps someone can review Jeff's patch 
>  to make them 
> more predictable.  Without that, I generally just ignore them in 
> comparisons of test results.

:-(  Thanks for the heads up.  I've approved it.  If people find those 
testcases useful, please, ensure they are deterministic and test something 
useful.  If they aren't up to standards as a whole, I'd entertain just adding a 
return 0 near the top of the .exp file to prompt people that would like them in 
the tree to address outstanding issues.


Re: PING: [PATCH] Fix up typed DWARF stack support for POINTERS_EXTEND_UNSIGNED targets (PR debug/48853)

2011-05-09 Thread H.J. Lu
On Mon, May 9, 2011 at 11:43 AM, Jakub Jelinek  wrote:
> On Mon, May 09, 2011 at 10:58:56AM -0700, H.J. Lu wrote:
>> On Fri, May 6, 2011 at 6:11 PM, H.J. Lu  wrote:
>> > 2011-05-06  H.J. Lu  
>> >
>> >        PR debug/48853
>> >        * dwarf2out.c (mem_loc_descriptor) : If
>> >        POINTERS_EXTEND_UNSIGNED, don't give up if mode is Pmode and
>> >        mem_mode is not VOIDmode.
>> >
>> > diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
>> > index 026e4a7..049ca8e 100644
>> > --- a/gcc/dwarf2out.c
>> > +++ b/gcc/dwarf2out.c
>> > @@ -13892,7 +13892,11 @@ mem_loc_descriptor (rtx rtl, enum machine_mode 
>> > mode,
>> >        break;
>> >       if (GET_MODE_CLASS (mode) == MODE_INT
>> >          && GET_MODE_CLASS (GET_MODE (SUBREG_REG (rtl))) == MODE_INT
>> > -         && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
>> > +         && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
>> > +#ifdef POINTERS_EXTEND_UNSIGNED
>> > +             || (mode == Pmode && mem_mode != VOIDmode)
>> > +#endif
>> > +            )
>> >          && GET_MODE_SIZE (GET_MODE (SUBREG_REG (rtl))) <= 
>> > DWARF2_ADDR_SIZE)
>> >        {
>> >          mem_loc_result = mem_loc_descriptor (SUBREG_REG (rtl),
>> >
>>
>> PING.
>
> Can you please explain how do you get such a SUBREG in a MEM address?


For

extern void abort (void);
int a[1024];
volatile short int v;

int
foo (int i, int j)
{
  int b = i;
  int c = i + 4;
  int d = a[i];
  int e = a[i + 6];
  ++v;
  return ++j;
}

I got

Breakpoint 5, mem_loc_descriptor (rtl=0x70655378, mode=DImode,
mem_mode=SImode, initialized=VAR_INIT_STATUS_INITIALIZED)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:13890
13890 mem_loc_result = mem_loc_descriptor (SUBREG_REG (rtl),
(gdb) bt
#0  mem_loc_descriptor (rtl=0x70655378, mode=DImode, mem_mode=SImode,
initialized=VAR_INIT_STATUS_INITIALIZED)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:13890
#1  0x006d853e in mem_loc_descriptor (rtl=0x70655348, mode=DImode,
mem_mode=SImode, initialized=VAR_INIT_STATUS_INITIALIZED)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:14187
#2  0x006dace1 in loc_descriptor (rtl=0x70655330, mode=SImode,
initialized=VAR_INIT_STATUS_INITIALIZED)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:15038
#3  0x006dadfb in loc_descriptor (rtl=0x705eff00, mode=SImode,
initialized=VAR_INIT_STATUS_INITIALIZED)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:15066
#4  0x006dbc3a in dw_loc_list_1 (loc=0x70606280,
varloc=0x705eff00, want_address=2,
initialized=VAR_INIT_STATUS_INITIALIZED)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:15341
#5  0x006dc583 in dw_loc_list (loc_list=0x70656060,
decl=0x70606280, want_address=2)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:15597
#6  0x006dd8f1 in loc_list_from_tree (loc=0x70606280,
want_address=2) at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:15985
#7  0x006e3d52 in add_location_or_const_value_attribute (
die=0x706506e0, decl=0x70606280, cache_p=0 '\000',
---Type  to continue, or q  to quit---q
attr=DW_AT_locatiQuit
(gdb) call debug_rtx (rtl)
(subreg:DI (ashift:SI (entry_value:SI (reg:SI 5 di [ i ]))
(const_int 2 [0x2])) 0)
(gdb) f 1
#1  0x006d853e in mem_loc_descriptor (rtl=0x70655348, mode=DImode,
mem_mode=SImode, initialized=VAR_INIT_STATUS_INITIALIZED)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:14187
14187 mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode, 
mem_mode,
(gdb) call debug_rtx (rtl)
(plus:DI (subreg:DI (ashift:SI (entry_value:SI (reg:SI 5 di [ i ]))
(const_int 2 [0x2])) 0)
(symbol_ref:DI ("a") ))
(gdb) f 2
#2  0x006dace1 in loc_descriptor (rtl=0x70655330, mode=SImode,
initialized=VAR_INIT_STATUS_INITIALIZED)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:15038
15038 loc_result = mem_loc_descriptor (XEXP (rtl, 0),
get_address_mode (rtl),
(gdb) call debug_rtx (rtl)
(mem/s/j:SI (plus:DI (subreg:DI (ashift:SI (entry_value:SI (reg:SI 5 di [ i ]))
(const_int 2 [0x2])) 0)
(symbol_ref:DI ("a") )) [0 a S4 A32])
(gdb) f 3
#3  0x006dadfb in loc_descriptor (rtl=0x705eff00, mode=SImode,
initialized=VAR_INIT_STATUS_INITIALIZED)
at /export/gnu/import/git/gcc-x32/gcc/dwarf2out.c:15066
15066 loc_result = loc_descriptor (loc, mode, initialized);
(gdb) call debug_rtx (rtl)
(var_location d (mem/s/j:SI (plus:DI (subreg:DI (ashift:SI
(entry_value:SI (reg:SI 5 di [ i ]))
(const_int 2 [0x2])) 0)
(symbol_ref:DI ("a") )) [0 a S4 A32]))
(gdb)


-- 
H.J.


Re: [patch] Add new -gmlt option for min. debug info with line tables (issue4440072)

2011-05-09 Thread Jim Wilson
On Tue, 2011-05-03 at 16:24 -0400, Jason Merrill wrote:
> That makes sense to me; it seems appropriate for -g1 to have information 
> that makes a backtrace more informative, but not information for 
> interactive debugging.  Jim, do you have an opinion?

I'm not aware of any significant use of -g1.  It is very rare for anyone
to mention it in a bug report for instance.  Once upon a time (before
2002-03-19), it was used for compiling libgcc, but that was just to
ensure that it got tested somewhere.  From my Cisco experience, I would
agree that backtraces without line numbers are not very useful.  It
would be OK with me if these changes were added to -g1 instead of
creating a new -gmlt option.

Jim




[PATCH, i386]: Handle flag_prefer_avx128 in ix86_autovectorize_vector_sizes

2011-05-09 Thread Uros Bizjak
Hello!

There is no point in trying to vectorize with 256bit vector sizes when
we prefer 128bit vectors. Also, cleanup ix86_preferred_simd_mode and
return word_mode for DFmode without SSE2.

2011-05-09  Uros Bizjak  

* config/i386/i386.c (ix86_autovectorize_vector_sizes): Return 0
for !flag_prefer_avx128.
(ix86_preferred_simd_mode): Return word_mode for DFmode without SSE2.

Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN.

Uros.
Index: i386.c
===
--- i386.c  (revision 173590)
+++ i386.c  (working copy)
@@ -35118,32 +35118,38 @@ has_dispatch (rtx insn, int action)
 static enum machine_mode
 ix86_preferred_simd_mode (enum machine_mode mode)
 {
-  /* Disable double precision vectorizer if needed.  */
-  if (mode == DFmode && !TARGET_VECTORIZE_DOUBLE)
-return word_mode;
-
-  if (!TARGET_AVX && !TARGET_SSE)
+  if (!TARGET_SSE)
 return word_mode;
 
   switch (mode)
 {
-case SFmode:
-  return (TARGET_AVX && !flag_prefer_avx128) ? V8SFmode : V4SFmode;
-case DFmode:
-  return (TARGET_AVX && !flag_prefer_avx128) ? V4DFmode : V2DFmode;
-case DImode:
-  return V2DImode;
-case SImode:
-  return V4SImode;
-case HImode:
-  return V8HImode;
 case QImode:
   return V16QImode;
+case HImode:
+  return V8HImode;
+case SImode:
+  return V4SImode;
+case DImode:
+  return V2DImode;
 
-default:;
-}
+case SFmode:
+  if (TARGET_AVX && !flag_prefer_avx128)
+   return V8SFmode;
+  else
+   return V4SFmode;
 
-  return word_mode;
+case DFmode:
+  if (!TARGET_VECTORIZE_DOUBLE)
+   return word_mode;
+  else if (TARGET_AVX && !flag_prefer_avx128)
+   return V4DFmode;
+  else if (TARGET_SSE2)
+   return V2DFmode;
+  /* FALLTHRU */
+
+default:
+  return word_mode;
+}
 }
 
 /* If AVX is enabled then try vectorizing with both 256bit and 128bit
@@ -35152,7 +35158,7 @@ ix86_preferred_simd_mode (enum machine_m
 static unsigned int
 ix86_autovectorize_vector_sizes (void)
 {
-  return TARGET_AVX ? 32 | 16 : 0;
+  return (TARGET_AVX && !flag_prefer_avx128) ? 32 | 16 : 0;
 }
 
 /* Initialize the GCC target structure.  */


[patch][gimplefe] Preliminary variable declaration support

2011-05-09 Thread Sandeep Soni
This patch is just a slight modification to an earlier patch that I
submitted which was non-working. This is working. It just recognizes
variable declarations and might be helpful for ketaki to start with
things. It is now more or less up to date with the information on the
wiki although not exactly analogous. I am going to fix it.

diff --git a/gcc/gimple/.parser.c.swp b/gcc/gimple/.parser.c.swp
deleted file mode 100644
index e639cd8..000
Binary files a/gcc/gimple/.parser.c.swp and /dev/null differ
diff --git a/gcc/gimple/.parser.h.swp b/gcc/gimple/.parser.h.swp
deleted file mode 100644
index 4ee1f23..000
Binary files a/gcc/gimple/.parser.h.swp and /dev/null differ
diff --git a/gcc/gimple/parser.c b/gcc/gimple/parser.c
index 41e25f5..b2929aa 100644
--- a/gcc/gimple/parser.c
+++ b/gcc/gimple/parser.c
@@ -124,6 +124,15 @@ gl_gimple_code_for_token (const gimple_token *token)
   return (enum gimple_code) code;
 }

+/* Return true if TOKEN is the start of a declaration.  */
+
+static bool
+gl_token_starts_decl (gimple_token *token)
+{
+  enum tree_code code = gl_tree_code_for_token (token);
+  return code == VAR_DECL;
+}
+

 /* Return true if TOKEN is the start of a type declaration.  */

@@ -798,6 +807,148 @@ gp_parse_type (gimple_parser *parser, const
gimple_token *token)
 }
 }

+/* The Declaration section within a .gimple file can consist of
+   a) Declaration of variables.
+   b) Declaration of functions.
+
+   The syntax of a variable declaration is as follows:
+
+   >
+
+   Following are the broad cases for which the syntax of a variable
+   declaration is described:
+
+   Example:
+
+   1. C-like declaration as,
+ int var;
+
+   The Corresponding gimple syntax,
+ VAR_DECL >
+
+   In General,any variable of an atomic data type,
+ VAR_DECL >
+
+   2. C-like declaration as,
+ int array[10];
+
+   The Corresponding gimple syntax,
+ VAR_DECL >>
+
+   In General,any variable of an array type,
+ VAR_DECL >>
+
+   3. C-like declaration as,
+ int *ptr;
+
+   The Corresponding gimple syntax,
+ VAR_DECL >>
+
+   In General,any variable of a pointer type,
+ VAR_DECL >>
+
+   Note: The Nested Type in the Pointer Type tuple is the type of
+ the element to which the variable points.
+
+   4. C-like declaration as,
+struct A a;
+
+   The Corresponding gimple syntax,
+ VAR_DECL >
+
+   In General, any variable of an aggregate type,
+ VAR_DECL >
+
+   Note: 1) Records, Unions and Enumerals are considered as Aggregates.
+2) For the aggregates we store only the name of the aggregate.
+The other properties of the aggregate will already be stored
+from the type declarations parsing and can thus be deduced.   */
+
+/* Recognizer function for variable declarations. The declaration tuple is read
+   from gimple_parser PARSER.  */
+
+static void
+gp_parse_var_decl (gimple_parser *parser)
+{
+  const gimple_token *next_token;
+  enum tree_code code ;
+
+  gl_consume_expected_token (parser->lexer, CPP_LESS);
+  gl_consume_expected_token (parser->lexer, CPP_NAME);
+  gl_consume_expected_token (parser->lexer, CPP_COMMA);
+
+  next_token = gl_consume_token (parser->lexer);
+  code = gl_tree_code_for_token (next_token);
+  switch (code)
+{
+case INTEGER_TYPE:
+  gl_consume_expected_token (parser->lexer, CPP_NUMBER);
+  gl_consume_expected_token (parser->lexer, CPP_RSHIFT);
+  break;
+
+case ARRAY_TYPE:
+  gl_consume_expected_token (parser->lexer, CPP_LESS);
+  gl_consume_expected_token (parser->lexer, CPP_NUMBER);
+  gl_consume_expected_token (parser->lexer, CPP_COMMA);
+  gl_consume_expected_token (parser->lexer, CPP_NUMBER);
+  gl_consume_expected_token (parser->lexer, CPP_COMMA);
+
+  /*TODO The tree code that we recognize below can be processed further.
+No action is taken for now.  */
+
+  gl_consume_expected_token (parser->lexer, CPP_NAME);
+  gl_consume_expected_token (parser->lexer, CPP_LESS);
+  gl_consume_expected_token (parser->lexer, CPP_NUMBER);
+  gl_consume_expected_token (parser->lexer, CPP_RSHIFT);
+  gl_consume_expected_token (parser->lexer, CPP_GREATER);
+  break;
+
+case POINTER_TYPE:
+  gl_consume_expected_token (parser->lexer, CPP_LESS);
+
+  /*TODO The tree code that we recognize below can be processed further.
+No action is taken for now.  */
+
+  gl_consume_expected_token (parser->lexer, CPP_NAME);
+  gl_consume_expected_token (parser->lexer, CPP_LESS);
+  gl_consume_expected_token (parser->lexer, CPP_NUMBER);
+  gl_consume_expected_token (parser->lexer, CPP_RSHIFT);
+  gl_consume_expected_token (parser->lexer, CPP_GREATER);
+  break;
+
+case RECORD_TYPE:
+case UNION_TYPE:
+case ENUMERAL_TYPE:
+  gl_consume_expected_token (parser->lexer, CPP_LESS);
+  gl_consume_expected_token (parser->lexer, CPP_NAME);
+  gl_consume_expected_token (parser->lexer, CPP_RSHIFT)

Re: [PATCH] Fix remove_unreachable_handlers (PR tree-optimization/48794, tree-optimization/48611)

2011-05-09 Thread Richard Henderson
On 05/09/2011 12:19 PM, Jakub Jelinek wrote:
>   PR tree-optimization/48611
>   PR tree-optimization/48794
>   * tree-eh.c (remove_unreachable_handlers): Don't remove regions
>   referenced from RESX or EH_DISPATCH arguments.
> 
>   * gfortran.dg/gomp/pr48611.f90: New test.
>   * gfortran.dg/gomp/pr48794.f90: New test.

Ok.


r~


[google]Implement an optimization based on reuse distance profiling (issue4517049)

2011-05-09 Thread Easwaran Raman
This patch by Silvius Rus replaces calls to  certain functions with a 
specialized version that uses non-temporal stores based on memory reuse 
distance profiling. Bootstraps, no test regressions and the profiling works for 
a small test case. Ok for google/main.?

-Easwaran

2011-05-09  Silvius Rus 

* value-prof.c (interesting_stringop_to_profile_p): Disbale
stringop profiling if reuse distance profiling is turned on.
* value-prof.h (gimple_gen_reusedist, optimize_reusedist): Declare.
* gcov-io.h: (GCOV_COUNTER_REUSE_DIST): New counter.
(GCOV_COUNTERS): Update.
(GCOV_COUNTER_NAMES): Add reuse_distance.
(GCOV_MERGE_FUNCTIONS): Add __gcov_merge_reusedist.
(__gcov_merge_reusedist): New declaration.
* profile.c (branch_prob): Enable reuse distance profiling and
optimization.
* common.opt (fprofile-reusedist, foptimize-locality): New options.
* tree-profile.c: Include params.h.
(stringop_subst, reusedist_t): New structures.
(stringop_subst_t, reusedist_t): New typedefs.
(stringop_decl): New global array.
(RD_NUM_COUNTERS): New constant.
(get_stringop_subst, reusedist_is_interesting_call)
(reusedist_instr_func_name, reusedist_get_instr_decl)
(reusedist_make_instr_call, reusedist_from_counters)
(gimple_gen_reusedist, nt_op_name, reusedist_get_size_threshold)
(reusedist_get_distance_large_threshold)
(reusedist_get_distance_small_threshold)
(reusedist_get_count_threshold, reusedist_nt_is_worth_it)
(reusedist_get_nt_decl, maybe_issue_profile_use_note)
(reusedist_maybe_replace_with_nt_version, optimize_reusedist): New
functions.
(gate_tree_profile_ipa): Return true if reuse distance instrumentation
or use is turned on.
* Makefile.in (LIBGCOV): Add _gcov_merge_reusedist.
* libgcov.c (__gcov_weighted_mean2, __gcov_merge_reusedist): New
functions.
* params.def (PARAM_REUSEDIST_MEAN_DIST_LARGE_THRESH)
(PARAM_REUSEDIST_MEAN_DIST_SMALL_THRESH)
(PARAM_REUSEDIST_CALL_COUNT_THRESH, PARAM_REUSEDIST_MEMCPY_SIZE_THRESH)
(PARAM_REUSEDIST_MEMSET_SIZE_THRESH): New params.



Index: gcc/value-prof.c
===
--- gcc/value-prof.c(revision 173496)
+++ gcc/value-prof.c(working copy)
@@ -1708,6 +1708,14 @@ interesting_stringop_to_profile_p (tree fndecl, gi
 {
   enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
 
+  /* Disable stringop collection with reuse distance instrumentation
+ or optimization.  Otherwise we end up with hard to correct profile
+ mismatches for functions where reuse distance-based transformation are
+ made.  We see a number of "memcpy" at instrumentation time and a different
+ number of "memcpy" at profile use time.  */
+  if (flag_profile_reusedist || flag_optimize_locality)
+return false;
+
   if (fcode != BUILT_IN_MEMCPY && fcode != BUILT_IN_MEMPCPY
   && fcode != BUILT_IN_MEMSET && fcode != BUILT_IN_BZERO)
 return false;
Index: gcc/value-prof.h
===
--- gcc/value-prof.h(revision 173496)
+++ gcc/value-prof.h(working copy)
@@ -103,6 +103,8 @@ extern void gimple_gen_const_delta_profiler (histo
 unsigned, unsigned);
 extern void gimple_gen_average_profiler (histogram_value, unsigned, unsigned);
 extern void gimple_gen_ior_profiler (histogram_value, unsigned, unsigned);
+extern void gimple_gen_reusedist (void);
+extern void optimize_reusedist (void);
 
 /* In profile.c.  */
 extern void init_branch_prob (void);
Index: gcc/gcov-io.h
===
--- gcc/gcov-io.h   (revision 173496)
+++ gcc/gcov-io.h   (working copy)
@@ -374,7 +374,8 @@ typedef HOST_WIDEST_INT gcov_type;
 #define GCOV_LAST_VALUE_COUNTER 8  /* The last of counters used for value
  profiling.  */
 #define GCOV_COUNTER_DIRECT_CALL 9 /* Direct call counts.  */
-#define GCOV_COUNTERS  10
+#define GCOV_COUNTER_REUSE_DIST 10 /* Reuse distance measure.  */
+#define GCOV_COUNTERS  11
 
 /* Number of counters used for value profiling.  */
 #define GCOV_N_VALUE_COUNTERS \
@@ -383,7 +384,8 @@ typedef HOST_WIDEST_INT gcov_type;
   /* A list of human readable names of the counters */
 #define GCOV_COUNTER_NAMES {"arcs", "interval", "pow2", "single", \
 "delta","indirect_call", "average", "ior", \
-"indirect_call_topn", "direct_call"}
+"indirect_call_topn", "direct_call", \
+ "reuse_distance"}
 
 #define GCOV_ICALL_TOPN_VAL  2   /* Track two hottest callees */
 #define GCOV_ICALL_TOPN_NCOUNTS  9 /* The number of counter entries pe

[PATCH] C++0x, fixes for override/final

2011-05-09 Thread Ville Voutilainen

Diagnose final on non-virtuals properly, diagnose override on
virtuals that don't actually override properly. Amend these
cases to the tests. Tested on Linux/X86-32.

2011-05-10 Ville Voutilainen  

   Fixes for override/final.
   * class.c (check_for_override): Diagnose final on a nonvirtual 
member function, diagnose override for a virtual with no matching override. 
Don't fiddle around with DECL_VINDEX.
   * virtual9.C: add tests that cover the aforementioned cases, add a 
test for a definition of a member function outside its class definition, add a 
test where cv-qualifiers don't match.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 12db2bc..24184d2 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2453,16 +2453,18 @@ get_basefndecls (tree name, tree t)
 void
 check_for_override (tree decl, tree ctype)
 {
+  int overrides_found = 0;
   if (TREE_CODE (decl) == TEMPLATE_DECL)
 /* In [temp.mem] we have:
 
 A specialization of a member function template does not
 override a virtual function from a base class.  */
 return;
+  overrides_found = look_for_overrides (ctype, decl);
   if ((DECL_DESTRUCTOR_P (decl)
|| IDENTIFIER_VIRTUAL_P (DECL_NAME (decl))
|| DECL_CONV_FN_P (decl))
-  && look_for_overrides (ctype, decl)
+  && overrides_found
   && !DECL_STATIC_FUNCTION_P (decl))
 /* Set DECL_VINDEX to a value that is neither an INTEGER_CST nor
the error_mark_node so that we know it is an overriding
@@ -2477,11 +2479,11 @@ check_for_override (tree decl, tree ctype)
   if (DECL_DESTRUCTOR_P (decl))
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (ctype) = true;
 }
-  else if (DECL_OVERRIDE_P (decl))
-{
-  DECL_VINDEX (decl) = error_mark_node;
-  error ("%q+#D marked override, but does not override", decl);
-}
+  else if (DECL_FINAL_P (decl))
+error ("%q+#D marked final, but is not virtual", decl);
+  if (DECL_OVERRIDE_P (decl)
+  && !overrides_found)
+error ("%q+#D marked override, but does not override", decl);
 }
 
 /* Warn about hidden virtual functions that are not overridden in t.
diff --git a/gcc/testsuite/g++.dg/inherit/virtual9.C 
b/gcc/testsuite/g++.dg/inherit/virtual9.C
index d3175e1..83e0479 100644
--- a/gcc/testsuite/g++.dg/inherit/virtual9.C
+++ b/gcc/testsuite/g++.dg/inherit/virtual9.C
@@ -3,6 +3,7 @@ struct B
 {
   virtual void f() final {}
   virtual void g() {}
+  virtual void x() const {}
 };
 
 struct B2
@@ -20,7 +21,12 @@ template  struct D2 : T
   void h() override {} // { dg-error "marked override, but does not override" }
 };
 
-struct D3 : D
+template  struct D3 : T
+{
+  void h() override {}
+};
+
+struct D4 : D
 {
   void g() {} // { dg-error "virtual function" }
 };
@@ -30,10 +36,25 @@ struct B3
   virtual void f() final final {} // { dg-error "duplicate virt-specifier" }
 };
 
-void g() override {} // { dg-error "virt-specifiers" }
+struct B4
+{
+  void f() final {} // { dg-error "marked final, but is not virtual" }
+};
+
+struct D5 : B
+{
+  void ff() override {} // { dg-error "marked override, but does not override" 
}
+  virtual void fff() override {} // { dg-error "marked override, but does not 
override" }
+  virtual void x() override {} // { dg-error "marked override, but does not 
override" }
+  void g() override;
+};
+
+void D5::g() override {} // { dg-error "not allowed outside a class 
definition" }
+void g() override {} // { dg-error "not allowed outside a class definition" }
 
 int main()
 {
-  D2 d2;
-  D2 d3;
+  D2 d;
+  D2 d2;
+  D3 d3;
 }



Re: [google]Implement an optimization based on reuse distance profiling (issue4517049)

2011-05-09 Thread Xinliang David Li
Ok.

The instrumentation and optimization runtime has not been open sourced
yet -- will need to be done later at some point.

(For reference, see Silvius's CGO2011 paper).

Thanks,

David

On Mon, May 9, 2011 at 2:49 PM, Easwaran Raman  wrote:
> This patch by Silvius Rus replaces calls to  certain functions with a 
> specialized version that uses non-temporal stores based on memory reuse 
> distance profiling. Bootstraps, no test regressions and the profiling works 
> for a small test case. Ok for google/main.?
>
> -Easwaran
>
> 2011-05-09  Silvius Rus 
>
>        * value-prof.c (interesting_stringop_to_profile_p): Disbale
>        stringop profiling if reuse distance profiling is turned on.
>        * value-prof.h (gimple_gen_reusedist, optimize_reusedist): Declare.
>        * gcov-io.h: (GCOV_COUNTER_REUSE_DIST): New counter.
>        (GCOV_COUNTERS): Update.
>        (GCOV_COUNTER_NAMES): Add reuse_distance.
>        (GCOV_MERGE_FUNCTIONS): Add __gcov_merge_reusedist.
>        (__gcov_merge_reusedist): New declaration.
>        * profile.c (branch_prob): Enable reuse distance profiling and
>        optimization.
>        * common.opt (fprofile-reusedist, foptimize-locality): New options.
>        * tree-profile.c: Include params.h.
>        (stringop_subst, reusedist_t): New structures.
>        (stringop_subst_t, reusedist_t): New typedefs.
>        (stringop_decl): New global array.
>        (RD_NUM_COUNTERS): New constant.
>        (get_stringop_subst, reusedist_is_interesting_call)
>        (reusedist_instr_func_name, reusedist_get_instr_decl)
>        (reusedist_make_instr_call, reusedist_from_counters)
>        (gimple_gen_reusedist, nt_op_name, reusedist_get_size_threshold)
>        (reusedist_get_distance_large_threshold)
>        (reusedist_get_distance_small_threshold)
>        (reusedist_get_count_threshold, reusedist_nt_is_worth_it)
>        (reusedist_get_nt_decl, maybe_issue_profile_use_note)
>        (reusedist_maybe_replace_with_nt_version, optimize_reusedist): New
>        functions.
>        (gate_tree_profile_ipa): Return true if reuse distance instrumentation
>        or use is turned on.
>        * Makefile.in (LIBGCOV): Add _gcov_merge_reusedist.
>        * libgcov.c (__gcov_weighted_mean2, __gcov_merge_reusedist): New
>        functions.
>        * params.def (PARAM_REUSEDIST_MEAN_DIST_LARGE_THRESH)
>        (PARAM_REUSEDIST_MEAN_DIST_SMALL_THRESH)
>        (PARAM_REUSEDIST_CALL_COUNT_THRESH, PARAM_REUSEDIST_MEMCPY_SIZE_THRESH)
>        (PARAM_REUSEDIST_MEMSET_SIZE_THRESH): New params.
>
>
>
> Index: gcc/value-prof.c
> ===
> --- gcc/value-prof.c    (revision 173496)
> +++ gcc/value-prof.c    (working copy)
> @@ -1708,6 +1708,14 @@ interesting_stringop_to_profile_p (tree fndecl, gi
>  {
>   enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
>
> +  /* Disable stringop collection with reuse distance instrumentation
> +     or optimization.  Otherwise we end up with hard to correct profile
> +     mismatches for functions where reuse distance-based transformation are
> +     made.  We see a number of "memcpy" at instrumentation time and a 
> different
> +     number of "memcpy" at profile use time.  */
> +  if (flag_profile_reusedist || flag_optimize_locality)
> +    return false;
> +
>   if (fcode != BUILT_IN_MEMCPY && fcode != BUILT_IN_MEMPCPY
>       && fcode != BUILT_IN_MEMSET && fcode != BUILT_IN_BZERO)
>     return false;
> Index: gcc/value-prof.h
> ===
> --- gcc/value-prof.h    (revision 173496)
> +++ gcc/value-prof.h    (working copy)
> @@ -103,6 +103,8 @@ extern void gimple_gen_const_delta_profiler (histo
>                                             unsigned, unsigned);
>  extern void gimple_gen_average_profiler (histogram_value, unsigned, 
> unsigned);
>  extern void gimple_gen_ior_profiler (histogram_value, unsigned, unsigned);
> +extern void gimple_gen_reusedist (void);
> +extern void optimize_reusedist (void);
>
>  /* In profile.c.  */
>  extern void init_branch_prob (void);
> Index: gcc/gcov-io.h
> ===
> --- gcc/gcov-io.h       (revision 173496)
> +++ gcc/gcov-io.h       (working copy)
> @@ -374,7 +374,8 @@ typedef HOST_WIDEST_INT gcov_type;
>  #define GCOV_LAST_VALUE_COUNTER 8  /* The last of counters used for value
>                                      profiling.  */
>  #define GCOV_COUNTER_DIRECT_CALL 9 /* Direct call counts.  */
> -#define GCOV_COUNTERS          10
> +#define GCOV_COUNTER_REUSE_DIST 10 /* Reuse distance measure.  */
> +#define GCOV_COUNTERS          11
>
>  /* Number of counters used for value profiling.  */
>  #define GCOV_N_VALUE_COUNTERS \
> @@ -383,7 +384,8 @@ typedef HOST_WIDEST_INT gcov_type;
>   /* A list of human readable names of the counters */
>  #define GCOV_COUNTER_NAMES     {"arcs", "interval", "pow2", "single", \
>                      

Use Enum for rs6000 -mcpu=, -mtune= options

2011-05-09 Thread Joseph S. Myers
This patch makes the handling of the rs6000 -mcpu= and -mtune= options
use Enum, completing the conversion of rs6000_handle_option - and so
of all target option handlers - to avoid using modifiable global
state.

As with various other targets, a generated rs6000-tables.opt is used.
This target had an rs6000_select array, similar to the sparc_select
removed by a previous patch, which is removed here; the code in this
port for handling CPU selection still seems rather overly complicated,
though I don't plan to attempt further simplifiation.

Tested building cc1 and xgcc for crosses to: powerpc-darwin
powerpc-eabispe powerpc-linux-gnuspe powerpc64-linux-gnu.  Will commit
to trunk in the absence of target maintainer objections.

contrib:
2011-05-09  Joseph Myers  

* gcc_update (gcc/config/rs6000/rs6000-tables.opt): New
dependencies.

gcc:
2011-05-09  Joseph Myers  

* config/rs6000/genopt.sh, config/rs6000/rs6000-cpus.def: New
files.
* config/rs6000/rs6000-tables.opt: New file (generated).
* config.gcc (powerpc*-*-*, rs6000*-*-*): Add
rs6000/rs6000-tables.opt to extra_options.
* config/rs6000/rs6000-opts.h (RS6000_CPU_OPTION_NATIVE): Define.
* config/rs6000/rs6000.c (rs6000_select): Remove.
(processor_target_table): Move contents to rs6000-cpus.def.
(darwin_rs6000_override_options): Check
global_options_set.x_rs6000_cpu_index instead of
rs6000_select[1].string.
(rs6000_option_override_internal): Likewise.
(rs6000_handle_option): Don't assert that global structures are in
use.  Don't handle OPT_mcpu_ and OPT_mtune_ here.
(rs6000_default_cpu): New variable.
(rs6000_file_start): Set it instead of local default_cpu.  Check
rs6000_default_cpu, global_options_set.x_rs6000_cpu_index and
global_options_set.x_rs6000_tune_index instead of rs6000_select.
(rs6000_darwin_file_start): Check rs6000_default_cpu and
global_options_set.x_rs6000_cpu_index instead of rs6000_select.
* config/rs6000/rs6000.h (struct rs6000_cpu_select,
rs6000_select): Remove.
* config/rs6000/rs6000.opt (rs6000_cpu_index, rs6000_tune_index):
Remove.
(mcpu=, mtune=): Use Var, Init, Enum and Save.
* config/rs6000/t-rs6000
($(srcdir)/config/rs6000/rs6000-tables.opt): New.
* config/rs6000/eabispe.h (SUBSUBTARGET_OVERRIDE_OPTIONS): Check
global_options_set.x_rs6000_cpu_index instead of
rs6000_select[1].string.
* config/rs6000/linuxspe.h (SUBSUBTARGET_OVERRIDE_OPTIONS): Check
global_options_set.x_rs6000_cpu_index instead of
rs6000_select[1].string.

Index: contrib/gcc_update
===
--- contrib/gcc_update  (revision 173561)
+++ contrib/gcc_update  (working copy)
@@ -83,6 +83,7 @@ gcc/config/arm/arm-tune.md: gcc/config/a
 gcc/config/arm/arm-tables.opt: gcc/config/arm/arm-arches.def 
gcc/config/arm/arm-cores.def gcc/config/arm/genopt.sh
 gcc/config/m68k/m68k-tables.opt: gcc/config/m68k/m68k-devices.def 
gcc/config/m68k/m68k-isas.def gcc/config/m68k/m68k-microarchs.def 
gcc/config/m68k/genopt.sh
 gcc/config/mips/mips-tables.opt: gcc/config/mips/mips-cpus.def 
gcc/config/mips/genopt.sh
+gcc/config/rs6000/rs6000-tables.opt: gcc/config/rs6000/rs6000-cpus.def 
gcc/config/rs6000/genopt.sh
 # And then, language-specific files
 gcc/cp/cfns.h: gcc/cp/cfns.gperf
 gcc/java/keyword.h: gcc/java/keyword.gperf
Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 173561)
+++ gcc/config.gcc  (working copy)
@@ -385,11 +385,11 @@ powerpc*-*-*)
cpu_is_64bit=yes
;;
esac
-   extra_options="${extra_options} g.opt fused-madd.opt"
+   extra_options="${extra_options} g.opt fused-madd.opt 
rs6000/rs6000-tables.opt"
;;
 rs6000*-*-*)
need_64bit_hwint=yes
-   extra_options="${extra_options} g.opt fused-madd.opt"
+   extra_options="${extra_options} g.opt fused-madd.opt 
rs6000/rs6000-tables.opt"
;;
 score*-*-*)
cpu_type=score
Index: gcc/config/rs6000/linuxspe.h
===
--- gcc/config/rs6000/linuxspe.h(revision 173561)
+++ gcc/config/rs6000/linuxspe.h(working copy)
@@ -26,7 +26,7 @@
 
 #undef  SUBSUBTARGET_OVERRIDE_OPTIONS
 #define SUBSUBTARGET_OVERRIDE_OPTIONS \
-  if (rs6000_select[1].string == NULL) \
+  if (!global_options_set.x_rs6000_cpu_index) \
 rs6000_cpu = PROCESSOR_PPC8540; \
   if (!global_options_set.x_rs6000_spe_abi) \
 rs6000_spe_abi = 1; \
Index: gcc/config/rs6000/rs6000-tables.opt
===
--- gcc/config/rs6000/rs6000-tables.opt (revision 0)
+++ gcc/config/rs6000/rs6000-tables.opt (revision 0)
@@ -0,0 +1,205 @@
+; -*- buffer-read-only: t 

Re: [PATCH] Fix dfp issue with dconst{1,2,m1,half} (PR debug/48928)

2011-05-09 Thread Ben Elliston
On Mon, May 09, 2011 at 09:11:59PM +0200, Jakub Jelinek wrote:

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

OK, thanks!

Cheers,
Ben

-- 
"These man-made problems have man-made solutions. Unfortunately, the
 men and women needed to solve them are all politicians." -- Peter Hartcher


signature.asc
Description: Digital signature


[C++, committed] Add c++/48735 testcase

2011-05-09 Thread Paolo Carlini

Hi,

I committed the testcase provided by Daniel in c++/48735 and closed the 
PR as already fixed. Also took the occasion to move my recent c++0x 
testcases to the proper cpp0x directory.


Tested x86_64-linux.

Paolo.


2011-05-09  Paolo Carlini  

PR c++/48735
* g++.dg/cpp0x/sfinae21.C: New.

2011-05-09  Paolo Carlini  

* g++.dg/template/sfinae28.C: Rename to...
* g++.dg/cpp0x/sfinae19.C: ... this.
* g++.dg/template/sfinae29.C: Rename to...
* g++.dg/cpp0x/sfinae20.C: ... this.
Index: g++.dg/cpp0x/sfinae21.C
===
--- g++.dg/cpp0x/sfinae21.C (revision 0)
+++ g++.dg/cpp0x/sfinae21.C (revision 0)
@@ -0,0 +1,14 @@
+// PR c++/48735
+// { dg-options "-std=c++0x" }
+
+template
+char f(int);
+
+template
+char (&f(...))[2];
+
+struct ND { ND() = delete; };
+
+static_assert(sizeof(f(0)) != 1, "Error");
Index: g++.dg/template/sfinae28.C
===
--- g++.dg/template/sfinae28.C  (revision 173596)
+++ g++.dg/template/sfinae28.C  (working copy)
@@ -1,13 +0,0 @@
-// PR c++/48737
-// { dg-options "-std=c++0x" }
-
-template
-T&& create();
-
-template
-decltype(T{create()...}, char()) f(int);
-
-template
-char (&f(...))[2];
-
-static_assert(sizeof(f(0)) != 1, "Error");
Index: g++.dg/template/sfinae29.C
===
--- g++.dg/template/sfinae29.C  (revision 173596)
+++ g++.dg/template/sfinae29.C  (working copy)
@@ -1,23 +0,0 @@
-// PR c++/48744
-// { dg-options "-std=c++0x" }
-
-template
-struct add_rval_ref {
-  typedef T&& type;
-};
-
-template<>
-struct add_rval_ref {
-  typedef void type;
-};
-
-template
-typename add_rval_ref::type create();
-
-template
-decltype(T{create()}, char()) f(int);
-
-template
-char (&f(...))[2];
-
-static_assert(sizeof(f(0)) != 1, "Error");


[C++, committed] Add c++/48522 testcase

2011-05-09 Thread Paolo Carlini

Hi,

I committed the testcase to mainline and 4_6-branch and closed the PR as 
already fixed.


Tested x86_64-linux.

Paolo.



2011-05-09  Paolo Carlini  

PR c++/48522
* g++.dg/cpp0x/pr48522.C: New.

Index: g++.dg/cpp0x/pr48522.C
===
--- g++.dg/cpp0x/pr48522.C  (revision 0)
+++ g++.dg/cpp0x/pr48522.C  (revision 0)
@@ -0,0 +1,24 @@
+// { dg-options "-std=c++0x" }
+
+template 
+struct Handle
+{
+Handle(T& t);
+};
+
+template
+struct Class {
+struct Struct {} data;
+void f();
+void g();
+};
+
+template
+void Class::f() {
+Handle< decltype((data)) > handle(data);
+}
+
+template
+void Class::g() {
+Handle< decltype((data)) > handle(data);
+}


[PATCH,c++] mark EXPR_PACK_EXPANSION as typed only, v2

2011-05-09 Thread Nathan Froyd
Following on:

http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00563.html

and the review received in:

http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00651.html

I present the patch below.  We have a new function,
cp_tree_operand_length, and the code has been retrofitted to use it in
various places.

Tested on x86_64-unknown-linux-gnu.  OK to commit?

-Nathan

gcc/cp/
* cp-tree.def (EXPR_PACK_EXPANSION): Add an operand.
* cp-objcp-common.c (cp_common_init_ts): Mark it as TS_TYPED.
* cp-tree.h (PACK_EXPANSION_PARAMETER_PACKS): Use the new
operand of EXPR_PACK_EXPANSION.
(cp_tree_operand_length): Declare.
* tree.c (cp_tree_operand_length): Define.
(cp_tree_equal): Call it.
* pt.c (value_dependent_expr_P): Likewise.
* mangle.c (write_expression): Likewise.

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index d15aed0..00f525b 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -241,11 +241,11 @@ cp_common_init_ts (void)
   MARK_TS_COMMON (UNDERLYING_TYPE);
   MARK_TS_COMMON (BASELINK);
   MARK_TS_COMMON (TYPE_PACK_EXPANSION);
-  MARK_TS_COMMON (EXPR_PACK_EXPANSION);
   MARK_TS_COMMON (DECLTYPE_TYPE);
   MARK_TS_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
   MARK_TS_COMMON (UNBOUND_CLASS_TEMPLATE);
 
+  MARK_TS_TYPED (EXPR_PACK_EXPANSION);
   MARK_TS_TYPED (SWITCH_STMT);
   MARK_TS_TYPED (IF_STMT);
   MARK_TS_TYPED (FOR_STMT);
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 7bd35e0..001ef10 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -413,7 +413,7 @@ DEFTREECODE (TYPE_PACK_EXPANSION, "type_pack_expansion", 
tcc_type, 0)
 
EXPR_PACK_EXPANSION plays precisely the same role as TYPE_PACK_EXPANSION,
but will be used for expressions.  */
-DEFTREECODE (EXPR_PACK_EXPANSION, "expr_pack_expansion", tcc_expression, 1)
+DEFTREECODE (EXPR_PACK_EXPANSION, "expr_pack_expansion", tcc_expression, 2)
 
 /* Selects the Ith parameter out of an argument pack. This node will
be used when instantiating pack expansions; see
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 53092ff..efcdeef 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2734,7 +2734,10 @@ extern void decl_shadowed_for_var_insert (tree, tree);
 
 /* The list of parameter packs used in the PACK_EXPANSION_* node. The
TREE_VALUE of each TREE_LIST contains the parameter packs.  */
-#define PACK_EXPANSION_PARAMETER_PACKS(NODE) TREE_CHAIN (NODE)
+#define PACK_EXPANSION_PARAMETER_PACKS(NODE)   \
+  *(TREE_CODE (NODE) == EXPR_PACK_EXPANSION\
+? &TREE_OPERAND (NODE, 1)  \
+: &TREE_CHAIN (TYPE_PACK_EXPANSION_CHECK (NODE)))
 
 /* Determine if this is an argument pack.  */
 #define ARGUMENT_PACK_P(NODE)  \
@@ -5430,6 +5433,7 @@ extern tree nonlambda_method_basetype (void);
 extern void maybe_add_lambda_conv_op(tree);
 
 /* in tree.c */
+extern int cp_tree_operand_length  (const_tree);
 void cp_free_lang_data (tree t);
 extern tree force_target_expr  (tree, tree, tsubst_flags_t);
 extern tree build_target_expr_with_type(tree, tree, 
tsubst_flags_t);
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index c72e6d2..c1f3b44 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -2701,23 +2701,7 @@ write_expression (tree expr)
default:
  /* In the middle-end, some expressions have more operands than
 they do in templates (and mangling).  */
- switch (code)
-   {
-   case PREINCREMENT_EXPR:
-   case PREDECREMENT_EXPR:
-   case POSTINCREMENT_EXPR:
-   case POSTDECREMENT_EXPR:
- len = 1;
- break;
-
-   case ARRAY_REF:
- len = 2;
- break;
-
-   default:
- len = TREE_OPERAND_LENGTH (expr);
- break;
-   }
+ len = cp_tree_operand_length (expr);
 
  for (i = 0; i < len; ++i)
{
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 76fc69b..8ffac49 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18279,35 +18279,31 @@ value_dependent_expression_p (tree expression)
{
case tcc_reference:
case tcc_unary:
- return (value_dependent_expression_p
- (TREE_OPERAND (expression, 0)));
-
case tcc_comparison:
case tcc_binary:
- return ((value_dependent_expression_p
-  (TREE_OPERAND (expression, 0)))
- || (value_dependent_expression_p
- (TREE_OPERAND (expression, 1;
-
case tcc_expression:
case tcc_vl_exp:
  {
-   int i;
-   for (i = 0; i < TREE_OPERAND_LENGTH (expression); ++i)
- /* In some cases, some of the operands may be missing.
-(For example, in the case of PREDECREMENT_EXPR, the
-amou

Re: [build] Define HAVE_GAS_HIDDEN on Darwin

2011-05-09 Thread Mike Stump
On May 4, 2011, at 5:08 AM, Rainer Orth wrote:
> The following patch is a prerequisite for making
> 
>   [lto, testsuite] Don't use visibility on targets that don't support it 
> (PR lto/47334)
>http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00295.html

> -# define USE_LINKONCE_INDIRECT (SUPPORTS_ONE_ONLY)
> +# define USE_LINKONCE_INDIRECT (SUPPORTS_ONE_ONLY) && !TARGET_MACHO

Generally speaking, we don't litter the backend with things like this.  We 
consider this trashy, and we limit the trash to config/...

Now, if you invent a feature (bug) for which this is really testing, and used 
it instead here, and then put that into the darwin.h file or into an as 
autoconf test, I think it would be fine.  Ok with that version.  If a 
build/configure/visibility person wants to object or insist on a better way to 
do what you want to do, I'd defer to them.


Re: [PATCH] C++0x, fixes for override/final

2011-05-09 Thread Jason Merrill

On 05/09/2011 05:55 PM, Ville Voutilainen wrote:

+  overrides_found = look_for_overrides (ctype, decl);
if ((DECL_DESTRUCTOR_P (decl)
 || IDENTIFIER_VIRTUAL_P (DECL_NAME (decl))
 || DECL_CONV_FN_P (decl))
-&&  look_for_overrides (ctype, decl)
+&&  overrides_found
&&  !DECL_STATIC_FUNCTION_P (decl))


This is breaking an optimization: before this change we don't bother 
looking for overrides if we've never seen a virtual function with the 
same name.  Just set overrides_found as well as DECL_VINDEX.


Jason


Re: [PATCH,c++] mark EXPR_PACK_EXPANSION as typed only, v2

2011-05-09 Thread Jason Merrill

OK.

Jason


[ping] 5 unreviewed patches

2011-05-09 Thread Eric Botcazou
Fix annoying gcov filename handling: (2 lines)
  http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01380.html

Introduce -Wstack-usage:
  http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01992.html

Extend TYPE_DECL_IS_STUB trick in dwarf2out.c: (1 line)
  http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00683.html

Emit DW_AT_artificial for types:
  http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00700.html

Fix PR lto/48492 (bis): (1 line)
  http://gcc.gnu.org/ml/gcc-patches/2011-04/msg01461.html

Thanks in advance.

-- 
Eric Botcazou


Re: [PATCH] C++0x, fixes for override/final

2011-05-09 Thread Ville Voutilainen
At Tue, 10 May 2011 00:46:54 -0400,
Jason Merrill wrote:
> This is breaking an optimization: before this change we don't bother 
> looking for overrides if we've never seen a virtual function with the 
> same name.  Just set overrides_found as well as DECL_VINDEX.

Ok. Tests still pass.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 12db2bc..ba4378b 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2453,6 +2453,7 @@ get_basefndecls (tree name, tree t)
 void
 check_for_override (tree decl, tree ctype)
 {
+  int overrides_found = 0;
   if (TREE_CODE (decl) == TEMPLATE_DECL)
 /* In [temp.mem] we have:
 
@@ -2467,7 +2468,10 @@ check_for_override (tree decl, tree ctype)
 /* Set DECL_VINDEX to a value that is neither an INTEGER_CST nor
the error_mark_node so that we know it is an overriding
function.  */
-DECL_VINDEX (decl) = decl;
+{
+  DECL_VINDEX (decl) = decl;
+  overrides_found = 1;
+}
 
   if (DECL_VIRTUAL_P (decl))
 {
@@ -2477,11 +2481,11 @@ check_for_override (tree decl, tree ctype)
   if (DECL_DESTRUCTOR_P (decl))
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (ctype) = true;
 }
-  else if (DECL_OVERRIDE_P (decl))
-{
-  DECL_VINDEX (decl) = error_mark_node;
-  error ("%q+#D marked override, but does not override", decl);
-}
+  else if (DECL_FINAL_P (decl))
+error ("%q+#D marked final, but is not virtual", decl);
+  if (DECL_OVERRIDE_P (decl)
+  && !overrides_found)
+error ("%q+#D marked override, but does not override", decl);
 }
 
 /* Warn about hidden virtual functions that are not overridden in t.
diff --git a/gcc/testsuite/g++.dg/inherit/virtual9.C 
b/gcc/testsuite/g++.dg/inherit/virtual9.C
index d3175e1..83e0479 100644
--- a/gcc/testsuite/g++.dg/inherit/virtual9.C
+++ b/gcc/testsuite/g++.dg/inherit/virtual9.C
@@ -3,6 +3,7 @@ struct B
 {
   virtual void f() final {}
   virtual void g() {}
+  virtual void x() const {}
 };
 
 struct B2
@@ -20,7 +21,12 @@ template  struct D2 : T
   void h() override {} // { dg-error "marked override, but does not override" }
 };
 
-struct D3 : D
+template  struct D3 : T
+{
+  void h() override {}
+};
+
+struct D4 : D
 {
   void g() {} // { dg-error "virtual function" }
 };
@@ -30,10 +36,25 @@ struct B3
   virtual void f() final final {} // { dg-error "duplicate virt-specifier" }
 };
 
-void g() override {} // { dg-error "virt-specifiers" }
+struct B4
+{
+  void f() final {} // { dg-error "marked final, but is not virtual" }
+};
+
+struct D5 : B
+{
+  void ff() override {} // { dg-error "marked override, but does not override" 
}
+  virtual void fff() override {} // { dg-error "marked override, but does not 
override" }
+  virtual void x() override {} // { dg-error "marked override, but does not 
override" }
+  void g() override;
+};
+
+void D5::g() override {} // { dg-error "not allowed outside a class 
definition" }
+void g() override {} // { dg-error "not allowed outside a class definition" }
 
 int main()
 {
-  D2 d2;
-  D2 d3;
+  D2 d;
+  D2 d2;
+  D3 d3;
 }


Re: [PATCH] C++0x, fixes for override/final

2011-05-09 Thread Jakub Jelinek
Hi!

Just small style nits:

On Tue, May 10, 2011 at 09:35:42AM +0300, Ville Voutilainen wrote:
> --- a/gcc/cp/class.c
> +++ b/gcc/cp/class.c
> @@ -2453,6 +2453,7 @@ get_basefndecls (tree name, tree t)
>  void
>  check_for_override (tree decl, tree ctype)
>  {
> +  int overrides_found = 0;

s/int/bool/;s/0/false/;s/1/true/
IMHO.

>if (TREE_CODE (decl) == TEMPLATE_DECL)
>  /* In [temp.mem] we have:
>  
> @@ -2467,7 +2468,10 @@ check_for_override (tree decl, tree ctype)
>  /* Set DECL_VINDEX to a value that is neither an INTEGER_CST nor
> the error_mark_node so that we know it is an overriding
> function.  */
> -DECL_VINDEX (decl) = decl;
> +{
> +  DECL_VINDEX (decl) = decl;
> +  overrides_found = 1;
> +}
>  
>if (DECL_VIRTUAL_P (decl))
>  {

> +  else if (DECL_FINAL_P (decl))
> +error ("%q+#D marked final, but is not virtual", decl);
> +  if (DECL_OVERRIDE_P (decl)
> +  && !overrides_found)

And the above condition is short enough that it could be on one line.

> +error ("%q+#D marked override, but does not override", decl);
>  }
>  

Jakub


[ARM] TLS Descriptor support

2011-05-09 Thread Nathan Sidwell
This patch implements TLS descriptor support in GCC.  TLS descriptors are 
described at http://www.codesourcery.com/publications/RFC-TLSDESC-ARM.txt and 
blessed by ARM, who have reserved the relocation numbers.


Binutils and GLIBC patches are already committed (there is an orthogonal glibc 
patch to do with make dependencies that I need to post though).


This patch adds a --with-tls={arm|gnu} configuration option, to specify the 
default scheme.  It can be overridden with a -mtls-dialect={arm|gnu} option 
(this is the name used by the x86 backend, which also has tlsdescriptor 
support).  I have not added --with-tls support to the x86 bits of config.gcc 
etc, but it would be simple to do so.


The arm.{c,h,md} changes are fairly mechanical -- a new tls pattern and smarts 
to emit it appropriately.


This patch has been tested for both default arm and default gnu tls schemes 
using the gcc and glibc testsuites for an arm-linux-gnueabi target.


ok?

nathan

--
Nathan Sidwell::   http://www.codesourcery.com   :: CodeSourcery

2011-05-10  Nathan Sidwell  

	* doc/invoke.texi (ARM Options): Document -mtls-dialect option.
	* doc/install.texi (Configuration): Document --with-tls.
	* config.gcc (arm*-*-linux*): Default to arm-style tls.
	(arm*-*-*): Add --with-tls option.
	(all_defaults): Add 'tls'.
	* config/arm/arm.c (target_tls_dialect): New.
	(enum tls_reloc): Add TLS_DESCSEQ.
	(arm_override_options): Process target_tls_dialect_switch value.
	(arm_call_tls_get_addr): Clean up. Assert not tls descriptor.
	(arm_tls_descseq_addr): New.
	(legitimize_tls_address): Add tlsdesc support.
	(arm_cannot_copy_insn_p): Check for tlscall.
	(arm_emit_tls_decoration): Likewise.
	* config/arm/arm.h (TARGET_ARM_TLS, TARGET_GNU_TLS): New.
	(OPTION_DEFAULT_SPECS): Add with-tls support.
	(enum arm_tls_type): New.
	(target_tls_dialect): New.
	* config/arm/arm.opt (mtls-dialect): New switch.
	* config/arm/arm.md (tlscall): New.

	testsuite/
	* gcc.target/arm/tlscall.c: New.

Index: doc/invoke.texi
===
--- doc/invoke.texi	(revision 172962)
+++ doc/invoke.texi	(working copy)
@@ -469,7 +469,7 @@ Objective-C and Objective-C++ Dialects}.
 -mthumb  -marm @gol
 -mtpcs-frame  -mtpcs-leaf-frame @gol
 -mcaller-super-interworking  -mcallee-super-interworking @gol
--mtp=@var{name} @gol
+-mtp=@var{name} -mtls-dialect=@var{dialect} @gol
 -mword-relocations @gol
 -mfix-cortex-m3-ldrd}
 
@@ -10332,6 +10332,17 @@ models are @option{soft}, which generate
 best available method for the selected processor.  The default setting is
 @option{auto}.
 
+@item -mtls-dialect=@var{dialect}
+@opindex mtls-dialect
+Specify the dialect to use for accessing thread local storage.  Two
+dialects are supported - @option{arm} and @option{gnu}.  The
+@option{arm} dialect selects the ARM EABI scheme for supporting local
+and global dynamic tls models.  The @option{gnu} dialect selects the
+experimental GNU scheme.  The GNU scheme is compatible with the ARM
+scheme, but does require new assembler, linker and library
+support.  Initial and local exec TLS models are unaffected by this
+option and use the ARM EABI scheme.
+
 @item -mword-relocations
 @opindex mword-relocations
 Only generate absolute relocations on word sized values (i.e. R_ARM_ABS32).
Index: doc/install.texi
===
--- doc/install.texi	(revision 172962)
+++ doc/install.texi	(working copy)
@@ -1003,6 +1003,12 @@ information normally used on 386 SVR4 pl
 workable alternative.  This requires gas and gdb, as the normal SVR4
 tools can not generate or interpret stabs.
 
+@item --with-tls=@var{dialect}
+Specify the default tls dialect, for systems were there is a choice.
+For ARM targets, possible values for @var{dialect} are @code{arm} or
+@code{gnu}, which select between the ARM EABI dialect and the GNU TLS
+descriptor-based dialect.
+
 @item --disable-multilib
 Specify that multiple target
 libraries to support different target variants, calling
Index: testsuite/gcc.target/arm/tlscall.c
===
--- testsuite/gcc.target/arm/tlscall.c	(revision 0)
+++ testsuite/gcc.target/arm/tlscall.c	(revision 0)
@@ -0,0 +1,31 @@
+/* Test non-duplication of tlscall insn */
+
+/* { dg-do assemble } */
+/* { dg-options "-O2 -fPIC -mtls-dialect=gnu" } */
+
+typedef struct _IO_FILE FILE;
+
+extern int foo(void);
+extern int bar(void);
+
+void uuid__generate_time()
+{
+ static int has_init = 0;
+ static __thread int state_fd = -2;
+ static __thread FILE *state_f;
+
+ if (!has_init) {
+   foo();
+   has_init = 1;
+ }
+
+ if (state_fd == -2) {
+  if (!state_f) {
+   state_fd = -1;
+  }
+ }
+ if (state_fd >= 0) {
+  while (bar() < 0) {}
+ }
+
+}
Index: config.gcc
===
--- config.gcc	(revision 172962)
+++ config.gcc	(working copy)
@@ -813,6 +813,7 @@ arm*-*-linux*)			# ARM GNU