[PATCH, libgcc]: Prototype __enable_execute_stack

2011-06-22 Thread Uros Bizjak
Hello!

This patch avoids a bunch of:

enable-execute-stack.c:5:1: warning: no previous prototype for
‘__enable_execute_stack’ [-Wmissing-prototypes]

warnings during gcc bootstrap.

2011-06-22  Uros Bizjak  

* enable-execute-stack-empty.c (__enable_execute_stack): Add prototype.

Bootstrapped on x86_64-pc-linux-gnu.

OK for mainline/4.6?

Uros.

Index: enable-execute-stack-empty.c
===
--- enable-execute-stack-empty.c(revision 175285)
+++ enable-execute-stack-empty.c(working copy)
@@ -1,6 +1,9 @@
 /* Dummy implementation of __enable_execute_stack.  */

+extern void __enable_execute_stack (void *);
+
 /* Attempt to turn on execute permission for the stack.  */
+
 void
 __enable_execute_stack (void *addr __attribute__((__unused__)))
 {


Re: [PATCH, libgcc]: Prototype __enable_execute_stack

2011-06-22 Thread Rainer Orth
Hi Uros,

> This patch avoids a bunch of:
>
> enable-execute-stack.c:5:1: warning: no previous prototype for
> ‘__enable_execute_stack’ [-Wmissing-prototypes]
>
> warnings during gcc bootstrap.

I'd say this is obvious.

> 2011-06-22  Uros Bizjak  
>
>   * enable-execute-stack-empty.c (__enable_execute_stack): Add prototype.
>
> Bootstrapped on x86_64-pc-linux-gnu.
>
> OK for mainline/4.6?

This code only lives on mainline, not 4.6.

Rainer

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


Re: [testsuite] ARM: adjust skips for Xscale test

2011-06-22 Thread Richard Earnshaw
On 21/06/11 22:03, Janis Johnson wrote:
> This patch allows an Xscale-specific test to run if multilib flags
> include -march=xscale and to be skipped if -mcpu= is used with
> anything besides xscale.
> 
> OK for trunk, and later for 4.6?
> 
> 
> gcc-20110621-2
> 
> 
> 2011-06-21  Janis Johnson  
> 
>   * gcc.target/arm/scd42-3.c: Allow -march-xscale; skip if -mcpu
>   is not xscale.
> 

OK.

R.



Re: [testsuite] ARM: require arm_thumb1_ok, drop -march

2011-06-22 Thread Richard Earnshaw
On 21/06/11 22:05, Janis Johnson wrote:
> This test requires thumb1, so skip it for targets that don't support
> that instead of specifying an arch value that might be overridden by
> multilib flags.
> 
> OK for trunk, and later for 4.6?
> 
> 
> gcc-20110621-4
> 
> 
> 2011-06-21  Janis Johnson  
> 
>   * gcc.target/arm/thumb-bitfld1.c: Don't specify -march, require thumb1.
> 

OK.

R.



Re: [PATCH, ARM] VSHL, VSHR, VLSHR immediate values support

2011-06-22 Thread Richard Earnshaw
On 22/06/11 00:25, Ramana Radhakrishnan wrote:
>>
>> Please get approval for the target independent parts (changes to
>> optabs.c) separately from a middle-end maintainer.  I cannot approve
>> those bits.
> 
> 
> Can a global reviewer take a look at the non-target specific changes
> 
> http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00191.html
> 
> 
> cheers
> Ramana
> 


optabs.c changes are OK.

R.



Re: [PATCH] Handle __builtin*chk and other builtins in various spots

2011-06-22 Thread Richard Guenther
On Tue, Jun 21, 2011 at 6:31 PM, Jakub Jelinek  wrote:
> Hi!
>
> While working on __builtin_assume_aligned support, I've noticed
> a bunch of places which handle some builtins specially in CCP/DCE/aliasing,
> but don't handle other similar calls.  Additionally
> in CCP for stringops that just return its first argument we can use
> first arguments properties for the return value and e.g. reasoning
> about alignment of malloc/calloc/alloca etc. is useful even if likely_value
> for the call doesn't return CONSTANT, as it doesn't depend on the arguments.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2011-06-21  Jakub Jelinek  
>
>        * tree-ssa-ccp.c (evaluate_stmt): Try bitwise tracking for
>        builtin calls even if likelyvalue is not CONSTANT.
>        Handle BUILT_IN_STRDUP and BUILT_IN_STRNDUP like BUILT_IN_MALLOC.
>        Return get_value_for_expr of first operand
>        for BUILT_IN_{MEM{CPY,MOVE,SET},STR{,N}CPY}{,_CHK}.
>        * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Handle
>        BUILT_IN_{MEM{{,P}CPY,MOVE,SET},STR{,N}C{PY,AT},STPCPY}_CHK like
>        their non-checking counterparts.
>        (call_may_clobber_ref_p_1): Likewise.
>        (stmt_kills_ref_p_1): Handle BUILT_IN_MEM{{,P}CPY,MOVE,SET}_CHK
>        like their non-checking counterparts.
>        * tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
>        Handle BUILT_IN_{MEM{{,P}CPY,MOVE,SET},STR{,N}C{PY,AT},STPCPY}_CHK
>        like their non-checking counterparts.
>        (find_func_clobbers): Likewise.
>        * tree-ssa-dce.c (propagate_necessity): Handle BUILT_IN_MEMSET_CHK
>        like BUILT_IN_MEMSET and BUILT_IN_CALLOC like BUILT_IN_MALLOC.
>
> --- gcc/tree-ssa-ccp.c.jj       2011-06-17 11:02:19.0 +0200
> +++ gcc/tree-ssa-ccp.c  2011-06-21 14:14:37.0 +0200
> @@ -1556,7 +1556,7 @@ evaluate_stmt (gimple stmt)
>
>   /* Resort to simplification for bitwise tracking.  */
>   if (flag_tree_bit_ccp
> -      && likelyvalue == CONSTANT
> +      && (likelyvalue == CONSTANT || is_gimple_call (stmt))
>       && !is_constant)
>     {
>       enum gimple_code code = gimple_code (stmt);
> @@ -1616,6 +1616,8 @@ evaluate_stmt (gimple stmt)
>            case BUILT_IN_MALLOC:
>            case BUILT_IN_REALLOC:
>            case BUILT_IN_CALLOC:
> +           case BUILT_IN_STRDUP:
> +           case BUILT_IN_STRNDUP:
>              val.lattice_val = CONSTANT;
>              val.value = build_int_cst (TREE_TYPE (gimple_get_lhs (stmt)), 0);
>              val.mask = shwi_to_double_int
> @@ -1631,6 +1633,20 @@ evaluate_stmt (gimple stmt)
>                              / BITS_PER_UNIT - 1));
>              break;
>
> +           /* These builtins return their first argument, unmodified.  */
> +           case BUILT_IN_MEMCPY:
> +           case BUILT_IN_MEMMOVE:
> +           case BUILT_IN_MEMSET:
> +           case BUILT_IN_STRCPY:
> +           case BUILT_IN_STRNCPY:
> +           case BUILT_IN_MEMCPY_CHK:
> +           case BUILT_IN_MEMMOVE_CHK:
> +           case BUILT_IN_MEMSET_CHK:
> +           case BUILT_IN_STRCPY_CHK:
> +           case BUILT_IN_STRNCPY_CHK:
> +             val = get_value_for_expr (gimple_call_arg (stmt, 0), true);
> +             break;
> +
>            default:;
>            }
>        }
> --- gcc/tree-ssa-alias.c.jj     2011-06-17 11:01:22.0 +0200
> +++ gcc/tree-ssa-alias.c        2011-06-21 14:15:42.0 +0200
> @@ -1,5 +1,5 @@
>  /* Alias analysis for trees.
> -   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
> +   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
>    Free Software Foundation, Inc.
>    Contributed by Diego Novillo 
>
> @@ -1199,6 +1199,24 @@ ref_maybe_used_by_call_p_1 (gimple call,
>                                           size);
>            return refs_may_alias_p_1 (&dref, ref, false);
>          }
> +       case BUILT_IN_STRCPY_CHK:
> +       case BUILT_IN_STRNCPY_CHK:
> +       case BUILT_IN_MEMCPY_CHK:
> +       case BUILT_IN_MEMMOVE_CHK:
> +       case BUILT_IN_MEMPCPY_CHK:
> +       case BUILT_IN_STPCPY_CHK:
> +       case BUILT_IN_STRCAT_CHK:
> +       case BUILT_IN_STRNCAT_CHK:
> +         {
> +           ao_ref dref;
> +           tree size = NULL_TREE;
> +           if (gimple_call_num_args (call) == 4)
> +             size = gimple_call_arg (call, 2);
> +           ao_ref_init_from_ptr_and_size (&dref,
> +                                          gimple_call_arg (call, 1),
> +                                          size);
> +           return refs_may_alias_p_1 (&dref, ref, false);
> +         }
>        case BUILT_IN_BCOPY:
>          {
>            ao_ref dref;
> @@ -1216,6 +1234,7 @@ ref_maybe_used_by_call_p_1 (gimple call,
>        case BUILT_IN_STACK_SAVE:
>        case BUILT_IN_STACK_RESTORE:
>        case BUILT_IN_MEMSET:
> +       case BUILT_IN_MEMSET_CHK:
>        case BUILT_IN_FREXP:
>        case BUILT_IN_FREXPF:
>        case BUILT_IN_FRE

Re: Patch: speed up compiler a little bit by optimizing lookup_attribute() and is_attribute_p()

2011-06-22 Thread Richard Guenther
On Wed, Jun 22, 2011 at 2:17 AM, Nicola Pero
 wrote:
> Ok, here's a revised patch (contextual diff, as requested).
>
> The inline code is now minimized to the "hot" stuff, as discussed.  In 
> benchmarks
> this arrangement performs a tiny bit slightly better than the previous patch, 
> so
> that's great news. :-)
>
> Bootstrapped on GNU/Linux i686, regression tested.  Benchmarked.
>
> OK to commit ?

Ok.

Thanks,
Richard.

> Thanks
>
> Index: attribs.c
> ===
> *** attribs.c   (revision 175269)
> --- attribs.c   (working copy)
> ***
> *** 198,203 
> --- 198,208 
>
>    str.str = attr->name;
>    str.length = strlen (str.str);
> +
> +   /* Attribute names in the table must be in the form 'text' and not
> +      in the form '__text__'.  */
> +   gcc_assert (str.length > 0 && str.str[0] != '_');
> +
>    slot = htab_find_slot_with_hash (attribute_hash, &str,
>                                   substring_hash (str.str, str.length),
>                                   INSERT);
> ***
> *** 279,284 
> --- 284,290 
>    /* A "naked" function attribute implies "noinline" and "noclone" for
>       those targets that support it.  */
>    if (TREE_CODE (*node) == FUNCTION_DECL
> +       && attributes
>        && lookup_attribute_spec (get_identifier ("naked"))
>        && lookup_attribute ("naked", attributes) != NULL)
>      {
> Index: tree.c
> ===
> *** tree.c      (revision 175269)
> --- tree.c      (working copy)
> ***
> *** 5218,5299 
>   }
>  };
>
> ! /* Return nonzero if IDENT is a valid name for attribute ATTR,
> !    or zero if not.
> !
> !    We try both `text' and `__text__', ATTR may be either one.  */
> ! /* ??? It might be a reasonable simplification to require ATTR to be only
> !    `text'.  One might then also require attribute lists to be stored in
> !    their canonicalized form.  */
> !
> ! static int
> ! is_attribute_with_length_p (const char *attr, int attr_len, const_tree 
> ident)
>  {
> !   int ident_len;
> !   const char *p;
> !
> !   if (TREE_CODE (ident) != IDENTIFIER_NODE)
> !     return 0;
> !
> !   p = IDENTIFIER_POINTER (ident);
> !   ident_len = IDENTIFIER_LENGTH (ident);
>
> !   if (ident_len == attr_len
> !       && strcmp (attr, p) == 0)
> !     return 1;
> !
> !   /* If ATTR is `__text__', IDENT must be `text'; and vice versa.  */
> !   if (attr[0] == '_')
>      {
> !       gcc_assert (attr[1] == '_');
> !       gcc_assert (attr[attr_len - 2] == '_');
> !       gcc_assert (attr[attr_len - 1] == '_');
> !       if (ident_len == attr_len - 4
> !         && strncmp (attr + 2, p, attr_len - 4) == 0)
> !       return 1;
>      }
> !   else
>      {
> !       if (ident_len == attr_len + 4
> !         && p[0] == '_' && p[1] == '_'
>          && p[ident_len - 2] == '_' && p[ident_len - 1] == '_'
> !         && strncmp (attr, p + 2, attr_len) == 0)
> !       return 1;
>      }
>
> !   return 0;
>  }
>
> ! /* Return nonzero if IDENT is a valid name for attribute ATTR,
> !    or zero if not.
>
> !    We try both `text' and `__text__', ATTR may be either one.  */
>
> ! int
> ! is_attribute_p (const char *attr, const_tree ident)
> ! {
> !   return is_attribute_with_length_p (attr, strlen (attr), ident);
>  }
>
> ! /* Given an attribute name and a list of attributes, return a pointer to the
> !    attribute's list element if the attribute is part of the list, or 
> NULL_TREE
> !    if not found.  If the attribute appears more than once, this only
> !    returns the first occurrence; the TREE_CHAIN of the return value should
> !    be passed back in if further occurrences are wanted.  */
> !
> ! tree
> ! lookup_attribute (const char *attr_name, tree list)
>  {
> !   tree l;
> !   size_t attr_len = strlen (attr_name);
>
> !   for (l = list; l; l = TREE_CHAIN (l))
>      {
> !       gcc_assert (TREE_CODE (TREE_PURPOSE (l)) == IDENTIFIER_NODE);
> !       if (is_attribute_with_length_p (attr_name, attr_len, TREE_PURPOSE 
> (l)))
> !       return l;
>      }
> !   return NULL_TREE;
>  }
>
>  /* Remove any instances of attribute ATTR_NAME in LIST and return the
> --- 5218,5336 
>   }
>  };
>
> ! /* The backbone of is_attribute_p().  ATTR_LEN is the string length of
> !    ATTR_NAME.  Also used internally by remove_attribute().  */
> ! bool
> ! private_is_attribute_p (const char *attr_name, size_t attr_len, const_tree 
> ident)
>  {
> !   size_t ident_len = IDENTIFIER_LENGTH (ident);
>
> !   if (ident_len == attr_len)
>      {
> !       if (strcmp (attr_name, IDENTIFIER_POINTER (ident)) == 0)
> !       return true;
>      }
> !   else if (ident_len == attr_len + 4)
>      {
> !       /* There is the possibility that ATTR is 'text' and IDENT is
> !        '__text__'.  */
> !       const char *p = IDENTIFIER_POINTER (ident);
> !       if (p[0] == '_' && p[1] == '_'
>          && p[ident_len - 2] == '_' && p[ident_len - 1]

[PATCH, alpha]: Skip some TLS -pie tests

2011-06-22 Thread Uros Bizjak
Hello!

Some -pie TLS tests are unsupported due to "TLS local exec code cannot
be linked into shared objects".

2011-06-22  Uros Bizjak  

* gcc.dg/torture/tls/run-le.c: Skip for -pie on alpha*-*-linux*.
* gcc.dg/torture/tls/tls-test.c: Ditto.
* gcc.dg/torture/tls/thr-init-1.c: Ditto.
* gcc.dg/torture/tls/thr-init-2.c: Ditto.

Tested on alphaev68-pc-linux-gnu, committed to mainline SVN.

Uros.
Index: gcc.dg/torture/tls/tls-test.c
===
--- gcc.dg/torture/tls/tls-test.c   (revision 175285)
+++ gcc.dg/torture/tls/tls-test.c   (working copy)
@@ -2,6 +2,7 @@
 /* { dg-require-effective-target tls  }  */
 /* { dg-require-effective-target pthread } */
 /* { dg-options "-pthread" } */
+/* { dg-skip-if "TLS local exec code cannot be linked into shared objects" { 
alpha*-*-linux* } { "-pie" } { "" } } */
 
 #include 
 extern int printf (char *,...);
Index: gcc.dg/torture/tls/run-le.c
===
--- gcc.dg/torture/tls/run-le.c (revision 175285)
+++ gcc.dg/torture/tls/run-le.c (working copy)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target tls_runtime } */
 /* { dg-add-options tls } */
+/* { dg-skip-if "TLS local exec code cannot be linked into shared objects" { 
alpha*-*-linux* } { "-pie" } { "" } } */
 
 extern void abort (void);
 
Index: gcc.dg/torture/tls/thr-init-1.c
===
--- gcc.dg/torture/tls/thr-init-1.c (revision 175285)
+++ gcc.dg/torture/tls/thr-init-1.c (working copy)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target tls_runtime } */
 /* { dg-add-options tls } */
+/* { dg-skip-if "TLS local exec code cannot be linked into shared objects" { 
alpha*-*-linux* } { "-pie" } { "" } } */
 
 extern int printf (char *,...);
 extern void abort() ;
Index: gcc.dg/torture/tls/thr-init-2.c
===
--- gcc.dg/torture/tls/thr-init-2.c (revision 175285)
+++ gcc.dg/torture/tls/thr-init-2.c (working copy)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target tls_runtime } */
 /* { dg-add-options tls } */
+/* { dg-skip-if "TLS local exec code cannot be linked into shared objects" { 
alpha*-*-linux* } { "-pie" } { "" } } */
 
 extern int printf (char *,...);
 extern void abort() ;


Re: [PATCH, libgcc]: Prototype __enable_execute_stack

2011-06-22 Thread Uros Bizjak
On Wed, Jun 22, 2011 at 10:23 AM, Rainer Orth
 wrote:

>> This patch avoids a bunch of:
>>
>> enable-execute-stack.c:5:1: warning: no previous prototype for
>> ‘__enable_execute_stack’ [-Wmissing-prototypes]
>>
>> warnings during gcc bootstrap.
>
> I'd say this is obvious.

Agreed.  Committed to mainline SVN.

Uros.


Re: [PATCH] Middle-end arrays, forward-ported to trunk (again)

2011-06-22 Thread Michael Matz
Hi,

On Tue, 21 Jun 2011, Richard Guenther wrote:

> I failed to see where the scalarizer inserts the temporary vars it 
> creates into the scope blocks (thus the gimplify.c hunk ...).  Any help 
> here is welcome.

The scoping of the scalarizer is a bit funny.  gfc_start_scalarized_body 
sets up scopes for all dimensions and leaves with the 'body' scope open.  
The bound expressions are inserted (for your testcase) into the 'block' 
scope.  In between there are the loop->code[n] scopes.

You can't decide to not go into gfc_start_scalarized_body early, because 
lse.expr will only be set later, so you have to 
properly finish_block all these in-between blocks and wire them into 
loop.pre and then block, like gfc_trans_scalarizing_loops would do.  Of 
course you don't want to actually generate loops, which 
gfc_trans_scalarizing_loops does.  So you have to manually unwind the 
blocks.  If you do that, then you also don't need the ??? marked 
gfc_add_block_to_block (&block, &loop.pre).

So, the code in the VLA_VIEW_EXPR case should be roughly this:

  else if (TREE_CODE (lse.expr) == VLA_VIEW_EXPR)
{
  int dim;
  stmtblock_t *pblock;

  pblock = &body;
  for (dim = 0; dim < loop.dimen + loop.codimen; dim++)
{
  n = loop.order[dim];
  tmp = gfc_finish_block (pblock);
  gfc_add_expr_to_block (&loop.code[n], tmp);
  loop.loopvar[n] = NULL_TREE;
  pblock = &loop.code[n];
}

  tmp = gfc_finish_block (pblock);
  gfc_add_expr_to_block (&loop.pre, tmp);
  gfc_add_block_to_block (&block, &loop.pre);
  gfc_add_block_to_block (&block, &loop.post);
  gfc_cleanup_loop (&loop);
}

Sorry, no real patch, my quilt queue is busted somehow.


Ciao,
Michael.


Re: [PATCH, alpha]: Skip some TLS -pie tests

2011-06-22 Thread Joseph S. Myers
On Wed, 22 Jun 2011, Uros Bizjak wrote:

> Hello!
> 
> Some -pie TLS tests are unsupported due to "TLS local exec code cannot
> be linked into shared objects".

Is there something about the Alpha ABI that makes it impossible to support 
for PIEs (which are different from shared libraries)?  The conclusion for 
ARM was that this was a linker bug 
.

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


Re: [PATCH] Middle-end arrays, forward-ported to trunk (again)

2011-06-22 Thread Richard Guenther
On Wed, 22 Jun 2011, Michael Matz wrote:

> Hi,
> 
> On Tue, 21 Jun 2011, Richard Guenther wrote:
> 
> > I failed to see where the scalarizer inserts the temporary vars it 
> > creates into the scope blocks (thus the gimplify.c hunk ...).  Any help 
> > here is welcome.
> 
> The scoping of the scalarizer is a bit funny.  gfc_start_scalarized_body 
> sets up scopes for all dimensions and leaves with the 'body' scope open.  
> The bound expressions are inserted (for your testcase) into the 'block' 
> scope.  In between there are the loop->code[n] scopes.
> 
> You can't decide to not go into gfc_start_scalarized_body early, because 
> lse.expr will only be set later, so you have to 
> properly finish_block all these in-between blocks and wire them into 
> loop.pre and then block, like gfc_trans_scalarizing_loops would do.  Of 
> course you don't want to actually generate loops, which 
> gfc_trans_scalarizing_loops does.  So you have to manually unwind the 
> blocks.  If you do that, then you also don't need the ??? marked 
> gfc_add_block_to_block (&block, &loop.pre).
> 
> So, the code in the VLA_VIEW_EXPR case should be roughly this:
> 
>   else if (TREE_CODE (lse.expr) == VLA_VIEW_EXPR)
> {
>   int dim;
>   stmtblock_t *pblock;
> 
>   pblock = &body;
>   for (dim = 0; dim < loop.dimen + loop.codimen; dim++)
> {
>   n = loop.order[dim];
>   tmp = gfc_finish_block (pblock);
>   gfc_add_expr_to_block (&loop.code[n], tmp);
>   loop.loopvar[n] = NULL_TREE;
>   pblock = &loop.code[n];
> }
> 
>   tmp = gfc_finish_block (pblock);
>   gfc_add_expr_to_block (&loop.pre, tmp);
>   gfc_add_block_to_block (&block, &loop.pre);
>   gfc_add_block_to_block (&block, &loop.post);
>   gfc_cleanup_loop (&loop);
> }
> 
> Sorry, no real patch, my quilt queue is busted somehow.

Thanks, that seems to work.

The following is an updated Fortran patch (requiring an updated
middle-end patch as well) which also adds code to handle
intrinsic ALL/ANY (in the hope more runtime tests get coverage
that way).

Richard.

Index: trunk/gcc/fortran/trans-array.c
===
*** trunk.orig/gcc/fortran/trans-array.c2011-06-22 14:28:27.0 
+0200
--- trunk/gcc/fortran/trans-array.c 2011-06-22 14:39:40.0 +0200
*** gfc_conv_scalarized_array_ref (gfc_se *
*** 2570,2575 
--- 2570,2637 
int n;
  
info = &se->ss->data.info;
+ 
+ {
+   tree vv = build_vl_exp (VLA_VIEW_EXPR, 2 + 2 * info->dimen);
+   tree vi = build_vl_exp (VLA_IDX_EXPR, 2 + info->dimen);
+   tree offset = NULL_TREE;
+   tree elt_type;
+   tree type;
+   tree tem;
+   elt_type = TREE_TYPE (se->expr);
+   if (POINTER_TYPE_P (elt_type))
+   elt_type = TREE_TYPE (elt_type);
+   while (TREE_CODE (elt_type) == ARRAY_TYPE)
+   elt_type = TREE_TYPE (elt_type);
+   type = elt_type;
+   for (n = 0; n < info->dimen; ++n)
+   {
+ TREE_OPERAND (vv, 2 + 2 * n)  /* extent */
+   = build2 (MINUS_EXPR, TREE_TYPE (info->end[n]),
+ info->end[n], info->start[n]);
+ TREE_OPERAND (vv, 3 + 2 * n)  /* stride */
+   = info->stride[n];
+ /* Accumulate start offset.  */
+ if (offset)
+   offset = fold_build2_loc (input_location,
+ PLUS_EXPR, TREE_TYPE (offset),
+ offset,
+ fold_build2_loc (input_location,
+  MULT_EXPR, TREE_TYPE 
(offset),
+  info->start[n],
+  info->stride[n]));
+ else
+   offset = fold_build2_loc (input_location,
+ MULT_EXPR, TREE_TYPE (info->start[n]),
+ info->start[n],
+ info->stride[n]);
+ type = build_array_type (type, build_index_type
+  (TREE_OPERAND (vv, 2 + 2 * n)));
+   }
+   /* Start address.  */
+   tem = info->descriptor;
+   if (!POINTER_TYPE_P (TREE_TYPE (tem)))
+   tem = build_fold_addr_expr (tem);
+   TREE_OPERAND (vv, 1)
+   = fold_build2 (MEM_REF, type,
+  fold_build2_loc (input_location,
+   POINTER_PLUS_EXPR,
+   TREE_TYPE (tem), tem,
+   fold_convert (sizetype, offset)),
+  build_int_cst (build_pointer_type (elt_type), 0));
+   /* Type.  */
+   TREE_TYPE (vv) = type;
+   TREE_OPERAND (vi, 1) = vv;
+   for (n = 0; n < info->dimen; ++n)
+   {
+ TREE_OPERAND (vi, 2 + n) /* Index placeholder.  */
+   = se-

Re: Mark variables addressable if they are copied using libcall in RTL expander

2011-06-22 Thread Eric Botcazou
> I fear this isn't enough considering pass-by-value aggregates that
> are callee copied.  And I guess there are other cases.  Eric, what
> do you suggest here?

I agree that there are probably other cases, but this seems to be the best way 
out for now.  There is still similar code in the expander for asm operands 
(dominated by the same code in the gimplifier) so calling mark_addressable 
this late is presumably acceptable.

-- 
Eric Botcazou


[patch tree-ssa-forwprop]: Improve binary and/or/xor folding

2011-06-22 Thread Kai Tietz
Hello,

This patch improves via type-sinking folding of binary and, or, and
xor operations.
First we do sinking also for compatible types with same precision, as
those don't need to be preserved for these operations.
Additional try to fold patterns (TYPE) X bin-op (Y CMP Z) and (TYPE) X
bin-op !Y, if type of X is
compatible to Y.

ChangeLog gcc

2011-06-22  Kai Tietz  

* tree-ssa-forwprop.c (simplify_bitwise_binary):
Improve binary folding regarding casts.


ChangeLog gcc/testsuite

2011-06-22  Kai Tietz  

* gcc.dg/binop-notand1a.c: New test.
* gcc.dg/binop-notand2a.c: New test.
* gcc.dg/binop-notand3a.c: New test.
* gcc.dg/binop-notand4a.c: New test.
* gcc.dg/binop-notand5a.c: New test.
* gcc.dg/binop-notand6a.c: New test.

Bootstrapped and regression tested for all standard languages, Ada,
and Obj-C++. Ok for apply?

Regards,
Kai
Index: gcc/gcc/tree-ssa-forwprop.c
===
--- gcc.orig/gcc/tree-ssa-forwprop.c2011-06-17 11:52:51.0 +0200
+++ gcc/gcc/tree-ssa-forwprop.c 2011-06-22 12:36:49.432774100 +0200
@@ -1682,10 +1682,11 @@ simplify_bitwise_binary (gimple_stmt_ite
   if (CONVERT_EXPR_CODE_P (def1_code)
   && CONVERT_EXPR_CODE_P (def2_code)
   && types_compatible_p (TREE_TYPE (def1_arg1), TREE_TYPE (def2_arg1))
-  /* Make sure that the conversion widens the operands or that it
-changes the operation to a bitfield precision.  */
+  /* Make sure that the conversion widens the operands, or has same
+precision,  or that it changes the operation to a bitfield
+precision.  */
   && ((TYPE_PRECISION (TREE_TYPE (def1_arg1))
-  < TYPE_PRECISION (TREE_TYPE (arg1)))
+  <= TYPE_PRECISION (TREE_TYPE (arg1)))
  || (GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (arg1)))
  != MODE_INT)
  || (TYPE_PRECISION (TREE_TYPE (arg1))
@@ -1704,6 +1705,88 @@ simplify_bitwise_binary (gimple_stmt_ite
   return true;
 }
 
+  /* Try to fold (TYPE) X op (Y CMP Z), or (TYPE) X op !Y, if type
+ of X is compatible to type of Y.  */
+  if (CONVERT_EXPR_CODE_P (def1_code)
+  && (TREE_CODE_CLASS (def2_code) == tcc_comparison
+ || def2_code == TRUTH_NOT_EXPR)
+  && types_compatible_p (TREE_TYPE (def1_arg1), TREE_TYPE (def2_arg1)))
+{
+  tree t;
+  if (def2_code == TRUTH_NOT_EXPR)
+   t = fold_build1_loc (gimple_location (def2), def2_code,
+TREE_TYPE (def1_arg1), def2_arg1);
+  else
+   t = fold_build2_loc (gimple_location (def2), def2_code,
+TREE_TYPE (def1_arg1), def2_arg1,
+  gimple_assign_rhs2 (def2));
+  t = fold_binary_loc (gimple_location (stmt), code,
+  TREE_TYPE (def1_arg1), def1_arg1, t);
+  if (t && TREE_CODE (t) == INTEGER_CST)
+   {
+ t = fold_convert (TREE_TYPE (arg1), t);
+ gimple_assign_set_rhs_from_tree (gsi, t);
+ update_stmt (gsi_stmt (*gsi));
+ return true;
+}
+  else if (t && TREE_CODE_CLASS (TREE_CODE (t)) == tcc_comparison)
+   {
+ gimple newop;
+ tree tem = create_tmp_reg (boolean_type_node, NULL);
+ newop = gimple_build_assign_with_ops (TREE_CODE (t), tem,
+   TREE_OPERAND (t, 0),
+   TREE_OPERAND (t, 1));
+ tem = make_ssa_name (tem, newop);
+ gimple_assign_set_lhs (newop, tem);
+ gsi_insert_before (gsi, newop, GSI_SAME_STMT);
+ gimple_assign_set_rhs_with_ops_1 (gsi, NOP_EXPR,
+   tem, NULL_TREE, NULL_TREE);
+ update_stmt (gsi_stmt (*gsi));
+ return true;
+   }
+}
+
+  /* Try to fold (Y CMP Z) op (TYPE) X, or !Y op (TYPE) X, if type
+ of X is compatible to type of Y.  */
+  if (CONVERT_EXPR_CODE_P (def2_code)
+  && (TREE_CODE_CLASS (def1_code) == tcc_comparison
+ || def1_code == TRUTH_NOT_EXPR)
+  && types_compatible_p (TREE_TYPE (def2_arg1), TREE_TYPE (def1_arg1)))
+{
+  tree t;
+  if (def1_code == TRUTH_NOT_EXPR)
+   t = fold_build1_loc (gimple_location (def1), def1_code,
+TREE_TYPE (def2_arg1), def1_arg1);
+  else
+   t = fold_build2_loc (gimple_location (def1), def1_code,
+TREE_TYPE (def2_arg1), def1_arg1,
+  gimple_assign_rhs2 (def1));
+  t = fold_binary_loc (gimple_location (stmt), code,
+  TREE_TYPE (def2_arg1), t, def2_arg1);
+  if (t && TREE_CODE (t) == INTEGER_CST)
+   {
+ t = fold_convert (TREE_TYPE (arg2), t);
+ gimple_assign_set_rhs_from_tree (gsi, t);
+ update_stmt (gsi_stmt (*gsi));
+ return true;
+}
+  else if (t && TREE_CODE_CLASS (TREE_CODE (t)) == tcc_comparison)

Re: Mark variables addressable if they are copied using libcall in RTL expander

2011-06-22 Thread Jakub Jelinek
On Wed, Jun 22, 2011 at 03:08:21PM +0200, Eric Botcazou wrote:
> > I fear this isn't enough considering pass-by-value aggregates that
> > are callee copied.  And I guess there are other cases.  Eric, what
> > do you suggest here?
> 
> I agree that there are probably other cases, but this seems to be the best 
> way 
> out for now.  There is still similar code in the expander for asm operands 
> (dominated by the same code in the gimplifier) so calling mark_addressable 
> this late is presumably acceptable.

Won't that cause problems later on during expansion of the same function?
The decl won't suddenly be a gimple reg anymore.  I mean, shouldn't the
marking be postponed until expansion finishes?

Jakub


Re: Mark variables addressable if they are copied using libcall in RTL expander

2011-06-22 Thread Richard Guenther
On Wed, Jun 22, 2011 at 3:14 PM, Jakub Jelinek  wrote:
> On Wed, Jun 22, 2011 at 03:08:21PM +0200, Eric Botcazou wrote:
>> > I fear this isn't enough considering pass-by-value aggregates that
>> > are callee copied.  And I guess there are other cases.  Eric, what
>> > do you suggest here?
>>
>> I agree that there are probably other cases, but this seems to be the best 
>> way
>> out for now.  There is still similar code in the expander for asm operands
>> (dominated by the same code in the gimplifier) so calling mark_addressable
>> this late is presumably acceptable.
>
> Won't that cause problems later on during expansion of the same function?
> The decl won't suddenly be a gimple reg anymore.  I mean, shouldn't the
> marking be postponed until expansion finishes?

It's not a register anyway as we've seen a MEM_EXPR with it.

Richard.

>        Jakub
>


Re: [PATCH] parallelize gcc, gfortran and libstdc++ testing some more

2011-06-22 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 06/20/11 15:04, Jakub Jelinek wrote:
> On Mon, Jun 20, 2011 at 03:54:59PM +0200, Jakub Jelinek wrote:
>> On Mon, Jun 20, 2011 at 09:28:56AM -0400, Jason Merrill wrote:
>>> On 06/17/2011 08:20 PM, Mike Stump wrote:
 On Jun 17, 2011, at 10:47 AM, Nathan Froyd wrote:
> I've done a lot of g++-only testsuite runs lately

 I think it is reasonable to have even more of them, say, if you have 16 
 cores and just test c++...  I wonder what the scaling is like as we 
 approach larger N.  :-)
>>>
>>> In my test runs, one of the libstdc++ batches (normal3) takes longer
>>> than any of the g++ batches, so breaking that up would be more
>>> effective for me.  :)
>>
>> Yeah, certainly, libstdc++ needs more parallelization most.
>> But, as I wrote already to Rainer in Autumn, the methodology
>> for splitting things up should be on a fast box look at
>> the time spent in each of the parts as reported by dejagnu
>> in the log files, and split it to make the jobs roughly even
>> sized with not overcomplicated patterns.
> 
> So, here is a patch that parallelizes the longest test chunks
> on x86_64-linux some more.
> 
> libstdc++ testing is now split into 10 jobs, roughly equally sized
> (used to be 4), check-gcc testing is now split into 10 jobs too (used to
> be 7, but the new division attempts to be more balanced, fastest
> job takes for me 8 minutes and longest job takes 11), and check-gfortran
> is now run in 7 jobs instead of 4.  This should make these more comparable
> e.g. to check-g++ chunks etc.
> 
> Regtested on x86_64-linux, verified the merged *.sum files are identical.
> Ok for trunk?
> 
> 2011-06-20  Jakub Jelinek  
> 
>   * Makefile.in (dg_target_exps): Set.
>   (check_gcc_parallelize): Parallelize gcc testing into 10 jobs
>   instead of 7, try to divide it more evenly.
> 
>   * Make-lang.in (check_gfortran_parallelize): Parallelize dg.exp
>   into 6 jobs instead of 3.
> 
>   * testsuite/Makefile.am (check_DEJAGNU_normal_targets): Add
>   check-DEJAGNUnormal[4-9].
>   (check-DEJAGNU): Split into 10 jobs for parallel testing instead of 4.
>   * testsuite/Makefile.in: Regenerated.
OK.
jeff
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOAfOYAAoJEBRtltQi2kC7fh4H/0ku6F+8rZEb0iy0zyr+KHUd
2qvA4BsXPcNs3xjwdqgrpvg9pM+6qXsEB8oEuaCBu7ndT8kCMPfnjaRP3otnl5ju
Maceyf0rZMDOUVYiYXYEstLMH+gljpraBU/n6UrvrXLLtZzna5yU6ZLwmPs1ngt/
+QQXWe34gRraEsLo4A9y5pcU69WnsVMdmrVKsRn/EnsLqSxClvmyWSaFrX0i5X4C
+NfQC3YQqiG0bjC6acCyfccHGJ+7tlyiafsyR0TDZPfGQLCwnRWNhm+A/GrTjYpY
nHbwhZ7sJef3gz9pLRm4qJ0OyMKqZo6c07Z43KdYIaIMQdjsh0CA3xfnd/vHSYQ=
=wO5+
-END PGP SIGNATURE-


Re: SRA generates uninitialized var use

2011-06-22 Thread Martin Jambor
Hi,

On Tue, Jun 21, 2011 at 06:08:27PM +0200, Richard Guenther wrote:
> On Tue, Jun 21, 2011 at 5:51 PM, Xinliang David Li  wrote:
> > On Tue, Jun 21, 2011 at 1:42 AM, Richard Guenther
> >  wrote:
> >> On Tue, Jun 21, 2011 at 1:28 AM, Xinliang David Li  
> >> wrote:
> >>> Good point -- but why does SRA have to be so complicated? If it just
> >>> do structure expansion and let subsequent phases to clean it up, would
> >>> it be simpler? Anyway this is off the topic.
> >>
> >> Well, it's certainly non-optimal to insert new memory backed variables
> >> to get rid of memory backed variables ...
> >>
> >
> > Yes, in the current way it is not optimal.
> >
> > Before that problem is resolved, is the simple patch ok for trunk? The
> > non-optimal code issue can be tracked with a different bug.
> 
> No, it's not a proper fix.

Just for the record, I am aware of this, have managed to reproduce it
and it is a high priority task for me.  I'm just still overwhelmed by
email and other backlog from the GCC Gathering (extended) weekend and
so a bit less responsive than usual.

Martin


> 
> Richard.
> 
> > Thanks,
> >
> > David
> >
> >> Richard.
> >>
> >>> Thanks,
> >>>
> >>> David
> >>>
> >>>
> >>> On Mon, Jun 20, 2011 at 1:47 PM, Richard Guenther
> >>>  wrote:
>  On Mon, Jun 20, 2011 at 6:15 PM, Xinliang David Li  
>  wrote:
> > It is used to indicate the fact the var decl needs to have a memory
> > home (addressable) -- is there another way to do this? this is to
> > avoid the following situation:
> >
> > 1) after SRA before update SSA, the IR looks like:
> >
> >   MEM[ &SR_123] = ...
> >
> >   other_var = SR_123;   < (x)
> >
> >
> > In this case, SR_123 is not of aggregate type, and it is not
> > addressable, update_ssa won't assign a VUSE for (x), leading to
> 
>  The point is, SRA should never have created the above
> 
>   MEM[ &SR_123] = ...
> 
>  Martin, why would it even create new _memory_ backed decls?
> 
>  Richard.
> 
> > 2) final IR after SRA:
> >
> >   MEM[..., &SR_123] = ..
> >   other_var = SR_123_yyy(D);
> >
> >
> > David
> >
> > On Mon, Jun 20, 2011 at 4:13 AM, Richard Guenther
> >  wrote:
> >> On Sat, Jun 18, 2011 at 10:56 AM, Xinliang David Li 
> >>  wrote:
> >>> Compiling the test case in the patch with -O2 -m32 without the fix,
> >>> the program will abort. The problem is a var decl whose address is
> >>> taken is not marked as addressable leading to bad SSA update (missing
> >>> VUSE).  (the triaging used the the .after and .after_cleanup dump diff
> >>> and found the problem).
> >>>
> >>> the test is on going. Ok after testing?
> >>
> >> That doesn't make sense.  SRA shouldn't generate anything that has
> >> its address taken.  So, where do we take its address?
> >>
> >> Richard.
> >>
> >>> Thanks,
> >>>
> >>> David
> >>>
> >>
> >
> 
> >>>
> >>
> >


Re: Improve jump threading #5 of N

2011-06-22 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 06/21/11 21:28, Hans-Peter Nilsson wrote:
> On Wed, 15 Jun 2011, Jeff Law wrote:
>> So as I've mentioned previously, I've been working on a relatively small
>> change to the jump threading code which would allow it to duplicate a
>> join block when doing so allows us to thread through a successor of the
>> join block.  This is expected to be the last extension to the existing
>> jump threading code.
> 
>> Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
> 
> It seems this caused a warning regression, PR49498, for some
> but not all targets, see the PR.
I never would have expected that kind of regression; obviously I'll have
a looksie.  Thanks for the heads-up.

jeff
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOAfQzAAoJEBRtltQi2kC7MNIH/0W5gcnheIkcWo5z+D1rYjSc
mEHZB9vyzBGLgZHQTXfPSM0MuEIgafz5J17gvkEfTQ768iGCrpWleMkchrhhaip1
oTgCRPLwuYouoPrNuYOMi17Zm8QfoPUFbyKbSxIvvk7v/eRolWyL6bqGWlWeFMID
6MKDv6GGbJRYNR0pyQiUQZ6cz2C6irNI4cLwlu7pbfKZ9pc5wte6dDkZ2jEaFs3b
bISpo4kE/bX5vDkyr2sWmkBLq0SGP981uNkjorO2tRplrEuA2BA85ZyUaCl3VMIz
voRCL+L7cW9zhx2FBL+x2haEwRyxsmLruR3T4equZcCxTpTBHgawWdqWA1g7F9s=
=8Yla
-END PGP SIGNATURE-


Re: [PATCH] middle-end only piece of middle-end array expressions

2011-06-22 Thread Richard Guenther
On Tue, 21 Jun 2011, Richard Guenther wrote:

> On Tue, 21 Jun 2011, Richard Guenther wrote:
> 
> > 
> > This is the middle-end pieces, without the C/C++ frontend changes.
> > Enough to work on the Fortran parts.
> > 
> > Doesn't even break bootstrap.
> 
> And here is a variant that doesn't need the tree-cfg.c hunk for
> the Fortran patch (thus all type problems fixed) and also does not
> suffer from the -O2 miscompilation.  -O0 still doesn't work.

Here is one that also works with -O0 and has multiple issues fixed
that were seen from running the Fortran testsuite.  It also adds
support for different reduction operators as needed for Fortran
ANY/ALL handling.

That's all for this week.

Richard.

2011-06-21  Richard Guenther  

* gimplify.c (internal_get_tmp_var): Mark array temporaries
as gimple register.
(gimple_add_tmp_var): Do not require constant size for array
temporaries.
(maybe_with_size_expr): Do not wrap VLA_VIEW_EXPR or VLA_RIDX_EXPR
inside WITH_SIZE_EXPR.
(is_gimple_reg_or_invariant_rhs): New predicate.
(rhs_predicate_for): Adjust.
(gimplify_modify_expr): Do not wrap copies of array temporaries
inside WITH_SIZE_EXPR.  Do not lower copies of array temporaries
to memcpy calls.
(gimplify_expr): Handle VLA_VIEW_EXPR, VLA_IDX_EXPR, VLA_RIDX_EXPR
and VLA_DELTA_EXPR.
* gimple.c (gimple_rhs_class_table): Add VLA_VIEW_EXPR, VLA_IDX_EXPR,
VLA_RIDX_EXPR and VLA_DELTA_EXPR.
(is_gimple_lvalue): Allow VLA_VIEW_EXPR.
(is_gimple_reg): Likewise.
(get_base_address): Handle VLA_VIEW_EXPR.
(get_base_loadstore): Likewise.
* tree-ssa-alias.c (refs_may_alias_p_1): Allow VLA_VIEW_EXPR.
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle
VLA_VIEW_EXPR, VLA_IDX_EXPR, VLA_RIDX_EXPR and VLA_DELTA_EXPR.
* cfgexpand.c (expand_debug_expr): Likewise.
(estimated_stack_frame_size): Gimple registers do not consume
stack space.
* tree-cfg.c (verify_gimple_assign_signle): Handle
VLA_VIEW_EXPR, VLA_IDX_EXPR, VLA_RIDX_EXPR and VLA_DELTA_EXPR.
* tree-pretty-print.c (dump_generic_node): Handle VLA_VIEW_EXPR,
VLA_IDX_EXPR, VLA_RIDX_EXPR and VLA_DELTA_EXPR.
* tree.def (VLA_VIEW_EXPR): New tree code.
(VLA_IDX_EXPR): Likewise.
(VLA_RIDX_EXPR): Likewise.
(VLA_DELTA_EXPR): Likewise.
* tree-ssa-operands.c (get_expr_operands): Handle them all.
* tree-ssa-sink.c (is_hidden_global_store): VLA_VIEW_EXPR is one.

* Makefile.in (OBJS-common): Add tree-lower-arrays.o.
(tree-lower-arrays.o): New target.
* tree-lower-arrays.c: New file.
* passes.c (init_optimization_passes): Schedule pass_arrlower
before loop header copying, pass_arrlower_O0 before expansion.
* timevar.def (TV_TREE_ARRLOWER): Add.
* tree-pass.h (pass_arrlower): Declare.
(pass_arrlower_O0): Likewise.
(PROP_gimple_larr): Add property.

Index: trunk/gcc/gimplify.c
===
*** trunk.orig/gcc/gimplify.c   2011-06-21 14:15:33.0 +0200
--- trunk/gcc/gimplify.c2011-06-22 15:36:47.0 +0200
*** internal_get_tmp_var (tree val, gimple_s
*** 583,589 
  
if (is_formal
&& (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE
! || TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE))
  DECL_GIMPLE_REG_P (t) = 1;
  
mod = build2 (INIT_EXPR, TREE_TYPE (t), t, unshare_expr (val));
--- 583,591 
  
if (is_formal
&& (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE
! || TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE
! || TREE_CODE (val) == VLA_RIDX_EXPR
! || TREE_CODE (val) == VLA_VIEW_EXPR))
  DECL_GIMPLE_REG_P (t) = 1;
  
mod = build2 (INIT_EXPR, TREE_TYPE (t), t, unshare_expr (val));
*** gimple_add_tmp_var (tree tmp)
*** 706,712 
/* Later processing assumes that the object size is constant, which might
   not be true at this point.  Force the use of a constant upper bound in
   this case.  */
!   if (!host_integerp (DECL_SIZE_UNIT (tmp), 1))
  force_constant_size (tmp);
  
DECL_CONTEXT (tmp) = current_function_decl;
--- 708,715 
/* Later processing assumes that the object size is constant, which might
   not be true at this point.  Force the use of a constant upper bound in
   this case.  */
!   if (!host_integerp (DECL_SIZE_UNIT (tmp), 1)
!   && TREE_CODE (TREE_TYPE (tmp)) != ARRAY_TYPE)
  force_constant_size (tmp);
  
DECL_CONTEXT (tmp) = current_function_decl;
*** maybe_with_size_expr (tree *expr_p)
*** 2227,2232 
--- 2230,2241 
|| type == error_mark_node)
  return;
  
+   /* If this is already wrapped in a VLA_VIEW_EXPR, we don't need another
+  WITH_SIZE_EXPR here.  */
+   if (TREE_CODE (expr) == VLA_VIEW_EXPR
+ 

[PATCH] Fix PR49365

2011-06-22 Thread Richard Guenther

This fixes the prefetching regression caused by rev. 166552 by
adjusting the default min-insn-to-prefetch-ratio.  I benchmarked
SPEC2006 with this change on AMD hardware (where prefetching
is on by default) and apart from recovering the 436.cactusADM
regression there is no other change in performance.

Also bootstrapped and tested on x86_64-unknown-linux-gnu.

I'll wait for comments before committing.

Richard.

2011-06-22  Richard Guenther  

PR tree-optimization/49365
* params.def (min-insn-to-prefetch-ratio): Reduce from 10 to 9.

Index: gcc/params.def
===
--- gcc/params.def  (revision 175293)
+++ gcc/params.def  (working copy)
@@ -825,7 +825,7 @@ DEFPARAM (PARAM_MIN_INSN_TO_PREFETCH_RAT
  "min-insn-to-prefetch-ratio",
  "Min. ratio of insns to prefetches to enable prefetching for "
   "a loop with an unknown trip count",
- 10, 0, 0)
+ 9, 0, 0)
 
 DEFPARAM (PARAM_PREFETCH_MIN_INSN_TO_MEM_RATIO,
  "prefetch-min-insn-to-mem-ratio",


Re: Mark variables addressable if they are copied using libcall in RTL expander

2011-06-22 Thread Eric Botcazou
> I fear this isn't enough considering pass-by-value aggregates that
> are callee copied.

It's indeed not sufficient for arguments passed by reference but callee-copied.

This is PR target/49454.  For gcc.c-torture/execute/2717-1.c:

typedef struct trio { int a, b, c; } trio;

int
foo (trio t, int i)
{
  return bar (i, t);
}

yiedls in the .optimized dump:

foo (struct trio t, int i)
{
  int D.1968;
  struct trio t.0;

:
  t.0 = t;
  D.1968_2 = bar (i_1(D), t.0);
  return D.1968_2;
}

and the aggregate copy is elided by DSE because t.0 isn't may_be_aliased.  This 
seems to be a pre-existing bug though: its address is passed to bar in RTL.

-- 
Eric Botcazou


PATCH: PR target/49497: Incorrect lea peephole

2011-06-22 Thread H.J. Lu
Hi,

We should check !TARGET_PARTIAL_REG_STALL for imul to lea peepholes.
Also there is no partial register stall for SImode.  I also added
const359_operand as suggestd by Uros.

OK for trunk?

Thanks.


H.J.
---
2011-06-22  H.J. Lu  

PR target/49497
* config/i386/i386.md (*lea_general_2): Always allow SImode.
(*lea_general_2_zext): Likewise.
(imul to lea peepholes): Use const359_operand and check
TARGET_PARTIAL_REG_STALL.

* config/i386/predicates.md (const359_operand): New.

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 0bbf55a..e4b96bc 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -6287,7 +6287,9 @@
  (match_operand 3 "nonmemory_operand" "ri")))]
   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
 || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
-   && (!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
+   && (!TARGET_PARTIAL_REG_STALL
+   || GET_MODE (operands[0]) == SImode
+   || optimize_function_for_size_p (cfun))
&& GET_MODE (operands[0]) == GET_MODE (operands[1])
&& (GET_MODE (operands[0]) == GET_MODE (operands[3])
|| GET_MODE (operands[3]) == VOIDmode)"
@@ -6338,7 +6340,9 @@
  (match_operand 4 "immediate_operand" "i")))]
   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
 || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
-   && (!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
+   && (!TARGET_PARTIAL_REG_STALL
+   || GET_MODE (operands[0]) == SImode
+   || optimize_function_for_size_p (cfun))
&& GET_MODE (operands[0]) == GET_MODE (operands[1])
&& GET_MODE (operands[0]) == GET_MODE (operands[3])"
   "#"
@@ -17207,11 +17211,11 @@
   [(parallel
 [(set (match_operand:SWI48 0 "register_operand" "")
  (mult:SWI48 (match_operand:SWI48 1 "register_operand" "")
- (match_operand:SWI48 2 "const_int_operand" "")))
+ (match_operand:SWI48 2 "const359_operand" "")))
  (clobber (reg:CC FLAGS_REG))])]
-  "INTVAL (operands[2]) == 3
-   || INTVAL (operands[2]) == 5
-   || INTVAL (operands[2]) == 9"
+  "!TARGET_PARTIAL_REG_STALL
+   || mode == SImode
+   || optimize_function_for_size_p (cfun)"
   [(set (match_dup 0)
(plus:SWI48 (mult:SWI48 (match_dup 1) (match_dup 2))
(match_dup 1)))]
@@ -17221,12 +17225,10 @@
   [(parallel
 [(set (match_operand:SWI48 0 "register_operand" "")
  (mult:SWI48 (match_operand:SWI48 1 "nonimmediate_operand" "")
- (match_operand:SWI48 2 "const_int_operand" "")))
+ (match_operand:SWI48 2 "const359_operand" "")))
  (clobber (reg:CC FLAGS_REG))])]
   "optimize_insn_for_speed_p ()
-   && (INTVAL (operands[2]) == 3
-   || INTVAL (operands[2]) == 5
-   || INTVAL (operands[2]) == 9)"
+   && (!TARGET_PARTIAL_REG_STALL || mode == SImode)"
   [(set (match_dup 0) (match_dup 1))
(set (match_dup 0)
(plus:SWI48 (mult:SWI48 (match_dup 0) (match_dup 2))
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 358d04f6..2c75147 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -606,6 +606,14 @@
   return i == 2 || i == 4 || i == 8;
 })
 
+;; Match 3, 5, or 9.  Used for leal multiplicands.
+(define_predicate "const359_operand"
+  (match_code "const_int")
+{
+  HOST_WIDE_INT i = INTVAL (op);
+  return i == 3 || i == 5 || i == 9;
+})
+
 ;; Match 0 or 1.
 (define_predicate "const_0_to_1_operand"
   (and (match_code "const_int")


Re: RFA PR middle-end/48770

2011-06-22 Thread Bernd Schmidt
On 06/14/2011 05:32 PM, Jeff Law wrote:
> 
> This version incorporates suggestions from Bernd.  Basically we have
> reload1.c set reload_completed internally rather than deferring it into
> ira.c.  That allows the call to reload() to return whether or not a DCE
> pass is desirable at the end of reload.
> 
> That in turn allows us to avoid the DF clumsiness of the previous version.
> 
> Bootstrapped and regression tested on x86_64-unknown-linux-gnu.

This is OK, although I'm slightly confused - wasn't your original
problem caused by the other delete_dead_insn call?


Bernd


Re: PATCH: PR target/49497: Incorrect lea peephole

2011-06-22 Thread Uros Bizjak
On Wed, Jun 22, 2011 at 4:17 PM, H.J. Lu  wrote:

> We should check !TARGET_PARTIAL_REG_STALL for imul to lea peepholes.
> Also there is no partial register stall for SImode.  I also added
> const359_operand as suggestd by Uros.
>
> OK for trunk?
>
> Thanks.
>
>
> H.J.
> ---
> 2011-06-22  H.J. Lu  
>
>        PR target/49497
>        * config/i386/i386.md (*lea_general_2): Always allow SImode.
>        (*lea_general_2_zext): Likewise.
>        (imul to lea peepholes): Use const359_operand and check
>        TARGET_PARTIAL_REG_STALL.
>
>        * config/i386/predicates.md (const359_operand): New.

OK.

Thanks,
Uros.


Re: [PATCH, alpha]: Skip some TLS -pie tests

2011-06-22 Thread Uros Bizjak
On Wed, Jun 22, 2011 at 3:04 PM, Joseph S. Myers
 wrote:

>> Some -pie TLS tests are unsupported due to "TLS local exec code cannot
>> be linked into shared objects".
>
> Is there something about the Alpha ABI that makes it impossible to support
> for PIEs (which are different from shared libraries)?  The conclusion for
> ARM was that this was a linker bug
> .

Let's ask rth about this...

Uros.


Re: [Patch] PR c++/26256

2011-06-22 Thread Jason Merrill

On 06/15/2011 01:58 PM, Fabien Chêne wrote:

Otherwise, perhaps that it would be better if the second declaration
of E1 does not rely on supplement_binding_1.
What do you think ?


I agree.  We should be using xref_tag for this like we do with classes, 
so we don't try to push the same tag more than once.


Jason


C++ PATCH for c++/49260 (lambda-eh2.C failure on several targets)

2011-06-22 Thread Jason Merrill
This failure was happening on all targets that don't use either CFI 
assembler directives or asynchronous unwind tables: we were mistakenly 
deciding that the _FUN thunk for returning from the lambda function 
pointer conversion operator couldn't throw because build_call_a wasn't 
setting cp_function_chain->can_throw.  There seems to be no reason to 
set that flag in build_cxx_call rather than build_call_a, so I've moved it.


Tested x86_64-pc-linux-gnu, applying to trunk.  Will also apply to 4.6.2 
once branch unfreezes.
commit 2d89beb80fa4656166d68c004d38b1087e8f12d5
Author: Jason Merrill 
Date:   Wed Jun 22 10:48:16 2011 -0400

	PR c++/49260
	* call.c (build_call_a): Set cp_function_chain->can_throw here.
	(build_cxx_call): Not here.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index dd4dced..cfaef7d 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -352,6 +352,9 @@ build_call_a (tree function, int n, tree *argarray)
   nothrow = ((decl && TREE_NOTHROW (decl))
 	 || TYPE_NOTHROW_P (TREE_TYPE (TREE_TYPE (function;
 
+  if (!nothrow && cfun && cp_function_chain)
+cp_function_chain->can_throw = 1;
+
   if (decl && TREE_THIS_VOLATILE (decl) && cfun && cp_function_chain)
 current_function_returns_abnormally = 1;
 
@@ -6710,11 +6713,6 @@ build_cxx_call (tree fn, int nargs, tree *argarray)
 
   /* If this call might throw an exception, note that fact.  */
   fndecl = get_callee_fndecl (fn);
-  if ((!fndecl || !TREE_NOTHROW (fndecl))
-  && at_function_scope_p ()
-  && cfun
-  && cp_function_chain)
-cp_function_chain->can_throw = 1;
 
   /* Check that arguments to builtin functions match the expectations.  */
   if (fndecl
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C
index 1490a25..0c94b55 100644
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C
@@ -1,5 +1,6 @@
 // PR c++/47263
-// { dg-options -std=c++0x }
+// PR c++/49260
+// { dg-options "-std=c++0x -fno-asynchronous-unwind-tables -fno-dwarf2-cfi-asm" }
 // { dg-do run }
 
 #include 


Re: [PATCH, alpha]: Skip some TLS -pie tests

2011-06-22 Thread Richard Henderson
On 06/22/2011 08:32 AM, Uros Bizjak wrote:
> On Wed, Jun 22, 2011 at 3:04 PM, Joseph S. Myers
>  wrote:
> 
>>> Some -pie TLS tests are unsupported due to "TLS local exec code cannot
>>> be linked into shared objects".
>>
>> Is there something about the Alpha ABI that makes it impossible to support
>> for PIEs (which are different from shared libraries)?  The conclusion for
>> ARM was that this was a linker bug
>> .
> 
> Let's ask rth about this...

Yep, alpha has the same bug that arm did.


r~


Re: [PATCH, alpha]: Skip some TLS -pie tests

2011-06-22 Thread Uros Bizjak
On Wed, Jun 22, 2011 at 5:56 PM, Richard Henderson  wrote:

 Some -pie TLS tests are unsupported due to "TLS local exec code cannot
 be linked into shared objects".
>>>
>>> Is there something about the Alpha ABI that makes it impossible to support
>>> for PIEs (which are different from shared libraries)?  The conclusion for
>>> ARM was that this was a linker bug
>>> .
>>
>> Let's ask rth about this...
>
> Yep, alpha has the same bug that arm did.

OK, will revert the patch.  Sorry for being impatient, but the patch
looked so obvious, considering the error... :-|

Uros.


Re: [PATCH] middle-end only piece of middle-end array expressions

2011-06-22 Thread Martin Jambor
Hi,

On Tue, Jun 21, 2011 at 05:12:40PM +0200, Richard Guenther wrote:
> 
> This is the middle-end pieces, without the C/C++ frontend changes.
> Enough to work on the Fortran parts.
> 
> Doesn't even break bootstrap.
> 
> Richard.
> 
> 2008-04-11  Richard Guenther  
> 
>   * builtin-attrs.def (ATTR_COVARIANTRETURN): Add.
>   (ATTR_NOTHROW_TYPEGENERIC): Likewise.
>   (ATTR_NOTHROW_TYPEGENERIC_COVARIANTRETURN): Likewise.
>   * builtins.def (BUILT_IN_ARRAY_SELECT): New builtin function.
>   (BUILT_IN_ARRAY_STORE): Likewise.
>   (BUILT_IN_ARRAY_IDX): Likewise.
>   (BUILT_IN_ARRAY_RIDX): Likewise.
>   (BUILT_IN_ARRAY_DELTA): Likewise.
>   * gimplify.c (internal_get_tmp_var): Mark array temporaries
>   as gimple register.
>   (gimple_add_tmp_var): Do not require constant size for array
>   temporaries.
>   (maybe_with_size_expr): Do not wrap VLA_VIEW_EXPR or VLA_RIDX_EXPR
>   inside WITH_SIZE_EXPR.
>   (get_array_arg_type): New helper function.
>   (vla_to_vla_view_expr): Likewise.
>   (lower_builtin_array_expr): Helper for gimplifying array builtins
>   to VLA tree expressions.
>   (gimplify_call_expr): Call it.
>   (gimplify_modify_expr): Do not wrap copies of array temporaries
>   inside WITH_SIZE_EXPR.  Do not lower copies of array temporaries
>   to memcpy calls.
>   (gimplify_expr): Handle VLA_VIEW_EXPR, VLA_IDX_EXPR, VLA_RIDX_EXPR
>   and VLA_DELTA_EXPR.
>   * tree-gimple.c (is_gimple_formal_tmp_rhs): Allow VLA_IDX_EXPR,
>   VLA_RIDX_EXPR and VLA_DELTA_EXPR.
>   (is_gimple_lvalue): Allow VLA_VIEW_EXPR.
>   (is_gimple_reg_type): Allow arrays.
>   (is_gimple_reg): Likewise.
>   * cfgexpand.c (estimated_stack_frame_size): Gimple registers do
>   not consume stack space.
>   * tree-cfg.c (verify_gimple_expr): Handle WITH_SIZE_EXPR,
>   VLA_VIEW_EXPR, VLA_IDX_EXPR, VLA_RIDX_EXPR and VLA_DELTA_EXPR.
>   * tree-inline.c (estimate_num_insns_1): Handle VLA_IDX_EXPR
>   and VLA_RIDX_EXPR.  Treat VLA_VIEW_EXPR and VLA_DELTA_EXPR
>   as expensive as OMP stuff.
>   * tree-pretty-print.c (dump_generic_node): Handle VLA_VIEW_EXPR,
>   VLA_IDX_EXPR, VLA_RIDX_EXPR and VLA_DELTA_EXPR.
>   * tree.def (VLA_VIEW_EXPR): New tree code.
>   (VLA_IDX_EXPR): Likewise.
>   (VLA_RIDX_EXPR): Likewise.
>   (VLA_DELTA_EXPR): Likewise.
>   * tree-ssa-operands.c (get_expr_operands): Handle them all.
>   * tree-ssa-sccvn.c (visit_use): Handle only calls like calls.
>   * tree-ssa-sink.c (is_hidden_global_store): VLA_VIEW_EXPR is one.
>   * ipa-pure-const.c (check_tree): Look int VLA_VIEW_EXPRs VLA
>   argument.
>   * tree-dfa.c (refs_may_alias_p): Allow VLA_VIEW_EXPR.
>   * tree-sra.c (maybe_lookup_element_for_expr): Make sure to
>   not scalarize arrays used in VLA_VIEW_EXPR.
>   (sra_walk_expr): Likewise.

It probably does not matter but the tree-sra hunks were not included
in the patch.

Martin



[Patch, AVR]: FIX PR43746 (merge progmem strings)

2011-06-22 Thread Georg-Johann Lay
This patch will put progmem strings into a mergeable strings section.

progmem_section is globally renamed to progmem_sw_table_section as
it's only used for switch_case jumptables.

The code that attached the explicit section name ".progmem" in
avr_insert_attributes is removed.

Instead, avr_init_sections sets up two new sections progmem_section
and progmem_string_section which are selected in new hook
avr_asm_select_section if appropriate, i.e. if progmem attribute is
specified.

The classic implementation of progmem always chose .progmem section
regardless of -fdata-sections.  The new code behaves similar: If
attribute "progmem" is on, avr_asm_named_section will put data in
.progmem resp. .progmem.string.

Note that .progmem.string coincides with .progmem if -fmerge-constants
if off, e.g. if optimization is off.

As Eric recently reopened PR43746, there is obviously need for such
tweak to save flash.

Tested without regressions and lightly tested with own code.

Johann


PR target/43746
* config/avr/avr.h (progmem_section): Rename progmem_section to
progmem_sw_table_section.
(ASM_OUTPUT_CASE_LABEL): Ditto.
* config/avr/avr.c (avr_output_addr_vec_elt): Ditto.
(avr_output_bld): Ditto.
(progmem_string_section): New variable.
(progmem_sw_table_section): New variable.
(TARGET_ASM_SELECT_SECTION): Define to...
(avr_asm_select_section): ...this new function.
(avr_progmem_string_p): New function.
(avr_insert_attributes): Don't attach explicit section names to
'progmem' variables.
(avr_output_progmem_section_asm_op): Remove.
(avr_asm_init_sections): Setup progmem_section,
progmem_string_section, progmem_sw_table_section.
(avr_asm_named_section): Put 'progmem' data into .progmem resp.
.progmem.string section.
(avr_section_type_flags): Setup flags for these sections.


Index: config/avr/avr.c
===
--- config/avr/avr.c	(revision 175201)
+++ config/avr/avr.c	(working copy)
@@ -83,6 +83,7 @@ static bool avr_function_value_regno_p (
 static void avr_insert_attributes (tree, tree *);
 static void avr_asm_init_sections (void);
 static unsigned int avr_section_type_flags (tree, const char *, int);
+static section * avr_asm_select_section (tree, int, unsigned HOST_WIDE_INT);
 
 static void avr_reorg (void);
 static void avr_asm_out_ctor (rtx, int);
@@ -131,7 +132,9 @@ const struct base_arch_s *avr_current_ar
 /* Current device.  */
 const struct mcu_type_s *avr_current_device;
 
-section *progmem_section;
+static GTY(()) section *progmem_section;
+static GTY(()) section *progmem_string_section;
+section *progmem_sw_table_section;
 
 /* To track if code will use .bss and/or .data.  */
 bool avr_need_clear_bss_p = false;
@@ -195,6 +198,8 @@ static const struct attribute_spec avr_a
 #define TARGET_INSERT_ATTRIBUTES avr_insert_attributes
 #undef TARGET_SECTION_TYPE_FLAGS
 #define TARGET_SECTION_TYPE_FLAGS avr_section_type_flags
+#undef TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION avr_asm_select_section
 
 /* `TARGET_ASM_NAMED_SECTION' must be defined in avr.h.  */
 
@@ -5170,42 +5175,63 @@ avr_progmem_p (tree decl, tree attribute
   return 0;
 }
 
-/* Add the section attribute if the variable is in progmem.  */
+
+/* Return true if DECL is a string to be put into
+   .progmem.string section, false otherwise.  */
+
+static bool
+avr_progmem_string_p (tree decl)
+{
+  if (decl && DECL_P (decl)
+  && avr_progmem_p (decl, DECL_ATTRIBUTES (decl)))
+{
+  tree array = TREE_TYPE (decl);
+  
+  return (ARRAY_TYPE == TREE_CODE (array)
+  && TYPE_STRING_FLAG (TREE_TYPE (array))
+  && 1 == tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (array)), 1));
+}
+
+  return false;
+}
+
+
+/* Implement `TARGET_INSERT_ATTRIBUTES'.  */
 
 static void
 avr_insert_attributes (tree node, tree *attributes)
 {
   if (TREE_CODE (node) == VAR_DECL
   && (TREE_STATIC (node) || DECL_EXTERNAL (node))
-  && avr_progmem_p (node, *attributes))
+  && avr_progmem_p (node, *attributes)
+  && !TREE_READONLY (node))
 {
-  if (TREE_READONLY (node)) 
-{
-  static const char dsec[] = ".progmem.data";
+  /* Just allow const data to get into .progmem section.  */
 
-  *attributes = tree_cons (get_identifier ("section"),
-   build_tree_list (NULL, build_string (strlen (dsec), dsec)),
-   *attributes);
-}
-  else
-{
-  error ("variable %q+D must be const in order to be put into"
- " read-only section by means of %<__attribute__((progmem))%>",
- node);
-}
+  error ("variable %q+D must be const in order to be put into"
+ " read-only section by means of %<__attribute__((progmem))%>",
+ node);
 }
 }

Re: [Patch, AVR]: Fix PR46779

2011-06-22 Thread Georg-Johann Lay
Hans-Peter Nilsson schrieb:
> On Mon, 13 Jun 2011, Georg-Johann Lay wrote:
>> [In CCing Richard Henderson]
>> Denis Chertykov schrieb:
>>> 2011/6/10 Georg-Johann Lay :
> 
 Then I observed trouble with DI patterns during libgcc build and had
 to remove

 * "zero_extendqidi2"
 * "zero_extendhidi2"
 * "zero_extendsidi2"

 These are "orphan" insns: they deal with DI without having movdi
 support so I removed them.
>>> This seems strange for me.
>> As far as I know, to support a mode a respective mov insn is needed,
> 
> For the record, not in general, just if you have patterns
> operating on DImode.  I.e. if you always have to call into
> libgcc for every operation, you're fine with just SImode, as the
> access will be split into SImode accesses.  (That reload can't
> split the access is arguably a wart.)

For avr it's actually split in QImode (word_mode), SImode would be
more efficient.

> It's even documented, "node Standard Names" for mov@var{m}:
> "If there are patterns accepting operands in larger modes,
> @samp{mov@var{m}} must be defined for integer modes of those
> sizes."

Thanks for pointing that out.

For avr that means:  There is movsf pattern that is implemented less
efficient than movsi.  So removing movsf could improve code a bit.
Besides efficiency, code for movsi and movsf can be the same on avr.

>> which is
>> not the case for DI. I don't know the exact rationale behind that
>> (reloading?),
> 
> Yes.  (I ran into problems with this myself long ago.)

So the zero_extend*di2 pattern are bogus because there is no movdi.

>> just read is on gcc list by Ian Taylor (and also that it is
>> stronly discouraged to have more than one mov insn per mode).
> 
> That is correct.
> 
>> So if the requirement to have mov insn is dropped and without the burden to
>> implement movdi, it would be rather easy to implement adddi3 and subdi3 for
>> avr...
> 
> Resist the temptation... I see you did. :)

The preferred handling is still that optabs cared for calling __adddi3
if there is no adddi3 pattern... The target would have to care for
implementing __adddi3 so generic libgcc need not to be changed and IMO
changing libgcc for that would not be adequate.

Johann

> brgds, H-P


[PATCH] Fix a -fcompare-debug bug in the vectorizer (PR debug/49496)

2011-06-22 Thread Jakub Jelinek
Hi!

This bug has been introduced recently, we shouldn't take debug uses into
account when deciding whether to optimize.

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

2011-06-22  Jakub Jelinek  

PR debug/49496
* tree-vect-patterns.c (vect_recog_widen_mult_pattern): Ignore debug
uses.

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

--- gcc/tree-vect-patterns.c.jj 2011-06-17 11:02:19.0 +0200
+++ gcc/tree-vect-patterns.c2011-06-22 11:23:08.0 +0200
@@ -557,6 +557,8 @@ vect_recog_widen_mult_pattern (VEC (gimp
 
   FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
 {
+ if (is_gimple_debug (USE_STMT (use_p)))
+   continue;
   use_stmt = USE_STMT (use_p);
   nuses++;
 }
--- gcc/testsuite/gcc.dg/pr49496.c.jj   2011-06-22 11:24:30.0 +0200
+++ gcc/testsuite/gcc.dg/pr49496.c  2011-06-22 11:28:33.0 +0200
@@ -0,0 +1,20 @@
+/* PR debug/49496 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fcompare-debug" } */
+
+unsigned short u[8], s1[8], s2[8];
+
+void bar (unsigned short *);
+
+void
+foo (void)
+{
+  unsigned short e[8];
+  int i;
+  for (i = 0; i < 8; i++)
+{
+  int tmp = s1[i] * s2[i];
+  e[i] = (tmp & 0x) >> 16;
+}
+  bar (e);
+}

Jakub


Re: [ARM] TLS Descriptor support

2011-06-22 Thread Nathan Sidwell

On 06/21/11 18:24, Ramana Radhakrishnan wrote:

revalidated with defaults to both gnu and gnu2 style. ok?


This is OK .


sigh, in backporting the relevant bits, I noticed a problem with the 
OPTION_DEFAULT_SPECS string, fixed thusly, committed as obvious.  And then I 
noticed I'd failed to commit the config.gcc fragment.


Back of the class for me today :(

nathan

--
Nathan Sidwell

2011-06-22  Nathan Sidwell  

* config/arm/arm.h (OPTION_DEFAULT_SPECS): Fix -mtls-dialect
typo.
* config.gcc (arm*-*-linux*): Default to gnu tls.
(arm*-*-*): Add --with-tls option.
(all_defaults): Add 'tls'.

Index: config.gcc
===
--- config.gcc  (revision 175297)
+++ config.gcc  (working copy)
@@ -863,6 +863,7 @@
tmake_file="$tmake_file arm/t-linux"
;;
esac
+   with_tls=${with_tls:-gnu}
tm_file="$tm_file arm/aout.h arm/arm.h"
tmake_file="${tmake_file} arm/t-arm-softfp soft-fp/t-softfp"
;;
@@ -3039,7 +3040,7 @@
;;
 
arm*-*-*)
-   supported_defaults="arch cpu float tune fpu abi mode"
+   supported_defaults="arch cpu float tune fpu abi mode tls"
for which in cpu tune; do
# See if it matches any of the entries in arm-cores.def
eval "val=\$with_$which"
@@ -3122,6 +3123,17 @@
;;
esac
 
+   case "$with_tls" in
+   "" \
+   | gnu | gnu2)
+   # OK
+   ;;
+   *)
+   echo "Unknown TLS method used in --with-tls=$with_tls" 
1>&2
+   exit 1
+   ;;
+   esac
+
if test "x$with_arch" != x && test "x$with_cpu" != x; then
echo "Warning: --with-arch overrides 
--with-cpu=$with_cpu" 1>&2
fi
@@ -3601,7 +3613,7 @@
 esac
 
 t=
-all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 
schedule float mode fpu divide llsc mips-plt synci"
+all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 
schedule float mode fpu divide llsc mips-plt synci tls"
 for option in $all_defaults
 do
eval "val=\$with_"`echo $option | sed s/-/_/g`
Index: config/arm/arm.h
===
--- config/arm/arm.h(revision 175297)
+++ config/arm/arm.h(working copy)
@@ -324,7 +324,7 @@
   {"fpu", "%{!mfpu=*:-mfpu=%(VALUE)}"}, \
   {"abi", "%{!mabi=*:-mabi=%(VALUE)}"}, \
   {"mode", "%{!marm:%{!mthumb:-m%(VALUE)}}"}, \
-  {"tls", "%{!mtls-dialect:-mtls-dialect=%(VALUE)}"},
+  {"tls", "%{!mtls-dialect=*:-mtls-dialect=%(VALUE)}"},
 
 /* Which floating point model to use.  */
 enum arm_fp_model


Rename attribs.c to attributes.c

2011-06-22 Thread Nicola Pero
This patch renames attribs.c to attributes.c.

I can only imagine the short "attribs.c" name was picked many years ago
due to filename restrictions on certain systems ?  Nowadays, it seems
that we already have plenty of long filenames inside GCC, so there is
no reason to use cryptic, newbie-unfriendly, shortened names for files. ;-)

Bootstrapped with c,c++,objc,obj-c++,lto,java,fortran,ada,go on Linux i686.

OK to commit ?

Thanks

In gcc/:
2011-06-22  Nicola Pero  

* attribs.c: Renamed to attributes.c.
* Makefile.in: Changed all occurrences of attribs.c and attribs.o
to attributes.c and attributes.o.
* langhooks.h: Updated comments to refer to attributes.c instead
of attribs.c.
* plugin.h: Likewise.
* tree.h: Likewise.

In gcc/ada/:
2011-06-22  Nicola Pero  

* gcc-interface/Make-lang.in (ADA_BACKEND): Renamed attribs.o to
attributes.o.

In gcc/cp/:
2011-06-22  Nicola Pero  

* Make-lang.in (CXX_C_OBJS): Renamed attribs.o to attributes.o.

In gcc/fortran/:
2011-06-22  Nicola Pero  

* Make-lang.in (f951$(exeext)): Replaced attribs.o with
attributes.o.

In gcc/go/:
2011-06-22  Nicola Pero  

* Make-lang.in (go1$(exeext)): Rename attribs.o to attributes.o.

In gcc/java/:
2011-06-22  Nicola Pero  

* Make-lang.in (jc1$(exeext)): Renamed attribs.o to attributes.o.

In gcc/lto/:
2011-06-22  Nicola Pero  

* Make-lang.in (LTO_OBJS): Renamed attribs.o to attributes.o
Index: gcc/attribs.c
===
--- gcc/attribs.c   (revision 175285)
+++ gcc/attribs.c   (working copy)
@@ -1,485 +0,0 @@
-/* Functions dealing with attribute handling, used by most front ends.
-   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 3, or (at your option) any later
-version.
-
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-.  */
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "tree.h"
-#include "flags.h"
-#include "diagnostic-core.h"
-#include "ggc.h"
-#include "tm_p.h"
-#include "cpplib.h"
-#include "target.h"
-#include "langhooks.h"
-#include "hashtab.h"
-#include "plugin.h"
-
-static void init_attributes (void);
-
-/* Table of the tables of attributes (common, language, format, machine)
-   searched.  */
-static const struct attribute_spec *attribute_tables[4];
-
-/* Hashtable mapping names (represented as substrings) to attribute specs. */
-static htab_t attribute_hash;
-
-/* Substring representation.  */
-
-struct substring
-{
-  const char *str;
-  int length;
-};
-
-static bool attributes_initialized = false;
-
-/* Default empty table of attributes.  */
-
-static const struct attribute_spec empty_attribute_table[] =
-{
-  { NULL, 0, 0, false, false, false, NULL, false }
-};
-
-/* Return base name of the attribute.  Ie '__attr__' is turned into 'attr'.
-   To avoid need for copying, we simply return length of the string.  */
-
-static void
-extract_attribute_substring (struct substring *str)
-{
-  if (str->length > 4 && str->str[0] == '_' && str->str[1] == '_'
-  && str->str[str->length - 1] == '_' && str->str[str->length - 2] == '_')
-{
-  str->length -= 4;
-  str->str += 2;
-}
-}
-
-/* Simple hash function to avoid need to scan whole string.  */
-
-static inline hashval_t
-substring_hash (const char *str, int l)
-{
-  return str[0] + str[l - 1] * 256 + l * 65536;
-}
-
-/* Used for attribute_hash.  */
-
-static hashval_t
-hash_attr (const void *p)
-{
-  const struct attribute_spec *const spec = (const struct attribute_spec *) p;
-  const int l = strlen (spec->name);
-
-  return substring_hash (spec->name, l);
-}
-
-/* Used for attribute_hash.  */
-
-static int
-eq_attr (const void *p, const void *q)
-{
-  const struct attribute_spec *const spec = (const struct attribute_spec *) p;
-  const struct substring *const str = (const struct substring *) q;
-
-  return (!strncmp (spec->name, str->str, str->length) && 
!spec->name[str->length]);
-}
-
-/* Initialize attribute tables, and make some sanity checks
-   if --enable-checking.  */
-
-static void
-init_attributes (void)
-{
-  size_t i;
-  int k;
-
-  attribute_tables[0] = lang_hooks.common_attribute_table;
-  attribute_tables[1] = lang_hooks.attribute_table;
-  attribute_tables[2] = lang_ho

[boehm-gc] Use __rld_obj_head for IRIX GC_register_dynamic_libraries (PR libgcj/49451)

2011-06-22 Thread Rainer Orth
As reported in PR libgcj/49451, the FileHandleGcTest test fails on IRIX
since boehm-gc tries to open /proc/ when the process is already out
of file descriptors.  Looking around, I've found a way for boehm-gc to
determine the list of shared libraries without using /proc, just as
Solaris and Tru64 UNIX do.

It uses __rld_obj_head, which provides the same info as _DYNAMIC on
Solaris, though in a slightly different way.  Fortunately, the current
Solaris code can be made to work on IRIX with very few changes.

The initial version allowed make check in boehm-gc to work without
problems, but failed when running any libjava test, which SEGVed in a
way that gdb couldn't catch ;-(  After some digging around, it turned
out that the addresses in the loaded shared objects may need an offset
added similar to the Solaris case, to take into account that the actual
virtual address and the quickstart one in the object don't match, if I
read the  comment correctly.  The gdb sources provided an
important clue in gdb/solib-irix.c (fetch_lm_info).

The version below passes both make check on mips-sgi-irix6.5 for both
N32 and N64 multilibs, the previously failing FileHandleGcTest test now
passes as expected, and a couple of other libjava tests work, too.  A
full make check for libjava is currently running, ok for mainline if
that passes?

Please note that the O32 code is currently untested since support for
that ABI has been removed in GCC 4.6.  This is harmless for the in-tree
copy, but might be an issue upstream.  I'll probably give it a try on
the 4.5 branch.

Thanks.
Rainer


2011-06-17  Rainer Orth  

PR libgcj/49451
* include/private/gcconfig.h [IRIX5 && _MIPS_SZPTR == 64]
(ELF_CLASS): Define.
* dyn_load.c [IRIX5]: Include .
Include  for O32,  for N32, N64.
[SUNOS5DL && USE_PROC_FOR_LIBRARIES] (obj_offset): Define.
[SUNOS4 && USE_PROC_FOR_LIBRARIES] (obj_offset): Define.
[IRIX5 && !USE_PROC_FOR_LIBRARIES] (struct link_map): Define.
(__rld_obj_head): Declare.
(l_next, l_addr, obj_offset): Define.
(GC_FirstDLOpenedLinkMap): New function.
[SUNOS4 || SUNOS5DL] (GC_register_dynamic_libraries): Also use on
IRIX5.
Use obj_offset.
[IRIX5 || (USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Don't use /proc version on IRIX5.

diff --git a/boehm-gc/dyn_load.c b/boehm-gc/dyn_load.c
--- a/boehm-gc/dyn_load.c
+++ b/boehm-gc/dyn_load.c
@@ -82,6 +82,15 @@
 #   define l_addr  lm_addr
 #   define l_name  lm_name
 #endif
+#ifdef IRIX5
+#   include 
+#   if _MIPS_SIM == _MIPS_SIM_ABI32 /* O32 ABI */
+ /* Don't include  here. */
+# include 
+#   else /* N32 or N64 ABIs */
+# include 
+#   endif
+#endif
 
 #if defined(NETBSD)
 #   include 
@@ -139,6 +148,8 @@ GC_register_has_static_roots_callback
 Elf32_Dyn _DYNAMIC;
 #endif
 
+#define obj_offset(lm) ((unsigned long)(lm->l_addr))
+
 static struct link_map *
 GC_FirstDLOpenedLinkMap()
 {
@@ -192,6 +203,8 @@ GC_FirstDLOpenedLinkMap()
 struct link_dynamic _DYNAMIC;
 #endif
 
+#define obj_offset(lm) ((unsigned long)(lm->l_addr))
+
 static struct link_map *
 GC_FirstDLOpenedLinkMap()
 {
@@ -226,9 +239,59 @@ static ptr_t GC_first_common()
 
 #endif  /* SUNOS4 ... */
 
-# if defined(SUNOS4) || defined(SUNOS5DL)
+#if defined(IRIX5) && !defined(USE_PROC_FOR_LIBRARIES)
+
+/* Provide struct link map. */
+#  if _MIPS_SIM == _MIPS_SIM_ABI32 /* O32 ABI */
+/* Provide our own version of struct obj_list in  with
+   correctly typed data member.  */
+struct obj_list {
+struct obj *data;
+struct obj_list *next;
+struct obj_list *prev;
+} objList;
+
+struct link_map {
+objList l_ol;
+};
+
+extern objList *__rld_obj_head;
+
+/* Map field names */
+#define l_next l_ol.next
+#define l_addr l_ol.data->o_pelfhdr
+
+#define obj_offset(lm) \
+   ((unsigned long)(lm->l_ol.o_praw - (char *)lm->l_ol.o_base_address))
+#  else /* N32 or N64 ABIs */
+struct link_map {
+ElfW(Obj_Info) l_oi;
+};
+
+extern ElfW(Obj_Info) *__rld_obj_head;
+
+/* Map field names */
+#define l_next l_oi.oi_next
+#define l_addr l_oi.oi_ehdr
+
+/* See gdb/solib-irix.c (fetch_lm_info).  */
+#define obj_offset(lm) \
+((unsigned long)(lm->l_oi.oi_ehdr - lm->l_oi.oi_orig_ehdr))
+#  endif
+
+static struct link_map *
+GC_FirstDLOpenedLinkMap()
+{
+return (struct link_map *)__rld_obj_head;
+}
+
+#endif /* IRIX5 ... */
+
+# if defined(SUNOS4) || defined(SUNOS5DL) || defined(IRIX5)
 /* Add dynamic library data sections to the root set.  */
-# if !defined(PCR) && !defined(GC_SOLARIS_PTHREADS) && defined(THREADS)
+# if !defined(PCR) \
+ && !defined(GC_SOLARIS_PTHREADS) && !defined(GC_IRIX_THREADS) \
+ && defined(THREADS)
 #   ifndef SRC_M3
--> fix mutual exclusion with dlopen
 #   endif  /* We assume M3 programs don't call dlopen for now */
@@ -241,7 +304,7 @@ void GC_register_dyna

Re: [PATCH] Fix a -fcompare-debug bug in the vectorizer (PR debug/49496)

2011-06-22 Thread Richard Guenther
On Wed, Jun 22, 2011 at 7:02 PM, Jakub Jelinek  wrote:
> Hi!
>
> This bug has been introduced recently, we shouldn't take debug uses into
> account when deciding whether to optimize.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2011-06-22  Jakub Jelinek  
>
>        PR debug/49496
>        * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Ignore debug
>        uses.
>
>        * gcc.dg/pr49496.c: New test.
>
> --- gcc/tree-vect-patterns.c.jj 2011-06-17 11:02:19.0 +0200
> +++ gcc/tree-vect-patterns.c    2011-06-22 11:23:08.0 +0200
> @@ -557,6 +557,8 @@ vect_recog_widen_mult_pattern (VEC (gimp
>
>       FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
>         {
> +         if (is_gimple_debug (USE_STMT (use_p)))
> +           continue;
>           use_stmt = USE_STMT (use_p);
>           nuses++;
>         }
> --- gcc/testsuite/gcc.dg/pr49496.c.jj   2011-06-22 11:24:30.0 +0200
> +++ gcc/testsuite/gcc.dg/pr49496.c      2011-06-22 11:28:33.0 +0200
> @@ -0,0 +1,20 @@
> +/* PR debug/49496 */
> +/* { dg-do compile } */
> +/* { dg-options "-O3 -fcompare-debug" } */
> +
> +unsigned short u[8], s1[8], s2[8];
> +
> +void bar (unsigned short *);
> +
> +void
> +foo (void)
> +{
> +  unsigned short e[8];
> +  int i;
> +  for (i = 0; i < 8; i++)
> +    {
> +      int tmp = s1[i] * s2[i];
> +      e[i] = (tmp & 0x) >> 16;
> +    }
> +  bar (e);
> +}
>
>        Jakub
>


[PATCH] Fix PR49493

2011-06-22 Thread Richard Guenther

This fixes PR49493.

Bootstrapped and tested on x86_64-unknown-linx-gnu, committed.

Richard.

2011-06-22  Richard Guenther  

PR tree-optimization/49493
* tree-ssa-structalias.c (get_constraint_for_ssa_var):
Refer to the alias target of variables.
(associate_varinfo_to_alias_1): Remove.
(ipa_pta_execute): Do not associate aliases with anything.
* cgraph.h (varpool_alias_aliased_node): Fix cut&paste errors.
(cgraph_function_node): Likewise.
(cgraph_function_or_thunk_node): Likewise.
(varpool_variable_node): Likewise.

* gcc.dg/ipa/ipa-pta-17.c: New testcase.

Index: gcc/tree-ssa-structalias.c
===
--- gcc/tree-ssa-structalias.c  (revision 175294)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -2746,6 +2746,18 @@ get_constraint_for_ssa_var (tree t, VEC(
   return;
 }
 
+  /* For global variables resort to the alias target.  */
+  if (TREE_CODE (t) == VAR_DECL
+  && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
+{
+  struct varpool_node *node = varpool_get_node (t);
+  if (node && node->alias)
+   {
+ node = varpool_variable_node (node, NULL);
+ t = node->decl;
+   }
+}
+
   vi = get_vi_for_tree (t);
   cexpr.var = vi->id;
   cexpr.type = SCALAR;
@@ -6703,16 +6751,6 @@ associate_varinfo_to_alias (struct cgrap
   return false;
 }
 
-/* Associate node with varinfo DATA. Worker for
-   varpool_for_node_and_aliases.  */
-static bool
-associate_varinfo_to_alias_1 (struct varpool_node *node, void *data)
-{
-  if (node->alias)
-insert_vi_for_tree (node->decl, (varinfo_t)data);
-  return false;
-}
-
 /* Execute the driver for IPA PTA.  */
 static unsigned int
 ipa_pta_execute (void)
@@ -6744,12 +6788,10 @@ ipa_pta_execute (void)
   /* Create constraints for global variables and their initializers.  */
   for (var = varpool_nodes; var; var = var->next)
 {
-  varinfo_t vi;
   if (var->alias)
continue;
 
-  vi = get_vi_for_tree (var->decl);
-  varpool_for_node_and_aliases (var, associate_varinfo_to_alias_1, vi, 
true);
+  get_vi_for_tree (var->decl);
 }
 
   if (dump_file)
Index: gcc/cgraph.h
===
--- gcc/cgraph.h(revision 175294)
+++ gcc/cgraph.h(working copy)
@@ -981,7 +981,7 @@ varpool_alias_aliased_node (struct varpo
 
   ipa_ref_list_reference_iterate (&n->ref_list, 0, ref);
   gcc_checking_assert (ref->use == IPA_REF_ALIAS);
-  if (ref->refered_type == IPA_REF_CGRAPH)
+  if (ref->refered_type == IPA_REF_VARPOOL)
 return ipa_ref_varpool_node (ref);
   return NULL;
 }
@@ -1011,7 +1011,7 @@ cgraph_function_node (struct cgraph_node
*availability = a;
}
 }
-  if (*availability)
+  if (availability)
 *availability = AVAIL_NOT_AVAILABLE;
   return NULL;
 }
@@ -1039,7 +1039,7 @@ cgraph_function_or_thunk_node (struct cg
*availability = a;
}
 }
-  if (*availability)
+  if (availability)
 *availability = AVAIL_NOT_AVAILABLE;
   return NULL;
 }
@@ -1067,7 +1067,7 @@ varpool_variable_node (struct varpool_no
*availability = a;
}
 }
-  if (*availability)
+  if (availability)
 *availability = AVAIL_NOT_AVAILABLE;
   return NULL;
 }
Index: gcc/testsuite/gcc.dg/ipa/ipa-pta-17.c
===
--- gcc/testsuite/gcc.dg/ipa/ipa-pta-17.c   (revision 0)
+++ gcc/testsuite/gcc.dg/ipa/ipa-pta-17.c   (revision 0)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fipa-pta" } */
+
+static int i;
+extern int j __attribute__ ((alias ("i")));
+int *p = &j;


Re: Rename attribs.c to attributes.c

2011-06-22 Thread Richard Guenther
On Wed, Jun 22, 2011 at 7:18 PM, Nicola Pero
 wrote:
> This patch renames attribs.c to attributes.c.
>
> I can only imagine the short "attribs.c" name was picked many years ago
> due to filename restrictions on certain systems ?  Nowadays, it seems
> that we already have plenty of long filenames inside GCC, so there is
> no reason to use cryptic, newbie-unfriendly, shortened names for files. ;-)
>
> Bootstrapped with c,c++,objc,obj-c++,lto,java,fortran,ada,go on Linux i686.
>
> OK to commit ?

Huh, I see no reason for this rename.  It'll just make patches across
releases harder.

Richard.

> Thanks
>
> In gcc/:
> 2011-06-22  Nicola Pero  
>
>        * attribs.c: Renamed to attributes.c.
>        * Makefile.in: Changed all occurrences of attribs.c and attribs.o
>        to attributes.c and attributes.o.
>        * langhooks.h: Updated comments to refer to attributes.c instead
>        of attribs.c.
>        * plugin.h: Likewise.
>        * tree.h: Likewise.
>
> In gcc/ada/:
> 2011-06-22  Nicola Pero  
>
>        * gcc-interface/Make-lang.in (ADA_BACKEND): Renamed attribs.o to
>        attributes.o.
>
> In gcc/cp/:
> 2011-06-22  Nicola Pero  
>
>        * Make-lang.in (CXX_C_OBJS): Renamed attribs.o to attributes.o.
>
> In gcc/fortran/:
> 2011-06-22  Nicola Pero  
>
>        * Make-lang.in (f951$(exeext)): Replaced attribs.o with
>        attributes.o.
>
> In gcc/go/:
> 2011-06-22  Nicola Pero  
>
>        * Make-lang.in (go1$(exeext)): Rename attribs.o to attributes.o.
>
> In gcc/java/:
> 2011-06-22  Nicola Pero  
>
>        * Make-lang.in (jc1$(exeext)): Renamed attribs.o to attributes.o.
>
> In gcc/lto/:
> 2011-06-22  Nicola Pero  
>
>        * Make-lang.in (LTO_OBJS): Renamed attribs.o to attributes.o
>


[PATCH] Change omp for static non-chunk computation (PR libgomp/49490)

2011-06-22 Thread Jakub Jelinek
Hi!

As has been reported, we don't divide the work for schedule(static)
loops very well.  E.g. for 33 iterations with 8 threads, we give
5 iterations to the first 6 threads, 3 iterations to the 7th thread
and 0 iterations to the last thread in the team.
The reason for that is the 
   q = n / nthreads;
   q += (q * nthreads != n);
   s0 = q * i;
   e0 = s0 + q;
   if (e0 > n)
 e0 = n; 
the computation of the start (s0)/end (e0), there i is the 0 based
thread id, n is number of iterations that need to be divided in between the
threads and nthreads number of threads in the team.

The following patch instead implements:
   q = n / nthreads;
   t = n % nthreads;
   if (i < t)
{
  t = 0;
  q++;
}
   s0 = q * i + t;
   e0 = s0 + q;
At least on x86_64/i686 using
   q = n / nthreads;
   t = n % nthreads;
instead of
   q = n / nthreads;
   t = n - (q * nthreads);
results in much better generated code, because the division
computes both division and modulus, while the second form
isn't optimized that way (missed optimization)?
Anyway, couldn't figure out how to implement this without a
conditional jump (I'd say the likely case is that n % nthreads
is zero).  With this for 33 iterations and 8 threads
we divide it as 5 in the first thread and 4 in all other threads.

Richard, do you agree with this?

Bootstrapped/regtested on x86_64-linux and i686-linux.

2011-06-22  Jakub Jelinek  

PR libgomp/49490
* omp-low.c (expand_omp_for_static_nochunk): Only
use n ceil/ nthreads size for the first
n % nthreads threads in the team instead of
all threads except for the last few ones which
get less work or none at all.

* iter.c (gomp_iter_static_next): For chunk size 0
only use n ceil/ nthreads size for the first
n % nthreads threads in the team instead of
all threads except for the last few ones which
get less work or none at all.
* iter_ull.c (gomp_iter_ull_static_next): Likewise.
* env.c (parse_schedule): If OMP_SCHEDULE doesn't have
chunk argument, set run_sched_modifier to 0 for static
resp. 1 for other kinds.  If chunk argument is 0
and not static, set value to 1.

--- gcc/omp-low.c.jj2011-06-22 10:16:56.0 +0200
+++ gcc/omp-low.c   2011-06-22 15:56:14.0 +0200
@@ -3,7 +3,7 @@
marshalling to implement data sharing and copying clauses.
Contributed by Diego Novillo 
 
-   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -4108,9 +4108,14 @@ expand_omp_for_generic (struct omp_regio
else
  n = (adj + N2 - N1) / STEP;
q = n / nthreads;
-   q += (q * nthreads != n);
-   s0 = q * threadid;
-   e0 = min(s0 + q, n);
+   tt = n % nthreads;
+   if (threadid < tt) goto L3; else goto L4;
+L3:
+   tt = 0;
+   q = q + 1;
+L4:
+   s0 = q * threadid + tt;
+   e0 = s0 + q;
V = s0 * STEP + N1;
if (s0 >= e0) goto L2; else goto L0;
 L0:
@@ -4126,12 +4131,14 @@ static void
 expand_omp_for_static_nochunk (struct omp_region *region,
   struct omp_for_data *fd)
 {
-  tree n, q, s0, e0, e, t, nthreads, threadid;
+  tree n, q, s0, e0, e, t, tt, nthreads, threadid;
   tree type, itype, vmain, vback;
-  basic_block entry_bb, exit_bb, seq_start_bb, body_bb, cont_bb;
+  basic_block entry_bb, second_bb, third_bb, exit_bb, seq_start_bb;
+  basic_block body_bb, cont_bb;
   basic_block fin_bb;
   gimple_stmt_iterator gsi;
   gimple stmt;
+  edge ep;
 
   itype = type = TREE_TYPE (fd->loop.v);
   if (POINTER_TYPE_P (type))
@@ -4185,19 +4192,39 @@ expand_omp_for_static_nochunk (struct om
   t = fold_convert (itype, t);
   n = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true, GSI_SAME_STMT);
 
+  q = create_tmp_var (itype, "q");
   t = fold_build2 (TRUNC_DIV_EXPR, itype, n, nthreads);
-  q = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true, GSI_SAME_STMT);
+  t = force_gimple_operand_gsi (&gsi, t, false, NULL_TREE, true, 
GSI_SAME_STMT);
+  gsi_insert_before (&gsi, gimple_build_assign (q, t), GSI_SAME_STMT);
+
+  tt = create_tmp_var (itype, "tt");
+  t = fold_build2 (TRUNC_MOD_EXPR, itype, n, nthreads);
+  t = force_gimple_operand_gsi (&gsi, t, false, NULL_TREE, true, 
GSI_SAME_STMT);
+  gsi_insert_before (&gsi, gimple_build_assign (tt, t), GSI_SAME_STMT);
 
-  t = fold_build2 (MULT_EXPR, itype, q, nthreads);
-  t = fold_build2 (NE_EXPR, itype, t, n);
-  t = fold_build2 (PLUS_EXPR, itype, q, t);
-  q = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true, GSI_SAME_STMT);
+  t = build2 (LT_EXPR, boolean_type_node, threadid, tt);
+  stmt = gimple_build_cond_empty (t);
+  gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+
+  second_bb = split_block (entry_bb, 

Re: [pph] Fix binding_level's names_size streaming (issue4634071)

2011-06-22 Thread Diego Novillo
On Mon, Jun 20, 2011 at 21:12, Gabriel Charette  wrote:

> It appears names_size is not even used anywhere in the code
> (or at least I couldn't find any use of it with `grep "names_size" -R gcc/`.
> Should we just remove it?

Yes, we should remove it.

Jason, the field cp_binding_level.names_size is essentially write-only:

$ grep -r '\' .
./ChangeLog-2002:   names_size and vtables.
./ChangeLog-2002:   (wrapup_globals_for_namespace): Use names_size instead
./cp/ChangeLog-2002:names_size and vtables.
./cp/ChangeLog-2002:(wrapup_globals_for_namespace): Use names_size instead
./cp/name-lookup.h:size_t names_size;
./cp/name-lookup.c:  b->names_size++;

I suppose it's OK to remove it, right?


Diego.


Re: Removing target-libiberty (was: Re: Libiberty: POSIXify psignal definition)

2011-06-22 Thread Hans-Peter Nilsson
> Date: Mon, 20 Jun 2011 16:58:41 + (UTC)
> From: "Joseph S. Myers" 

> On Mon, 20 Jun 2011, Hans-Peter Nilsson wrote:
> 
> > It seems none in approval capacity have any objection to
> > (figuratively) s/target-libiberty//g in toplevel/configure.ac on
> > all branches.  Is an --enable-target-libiberty or
> > --with-target-libiberty needed?  (I'd just rather not.)
> 
> There should be no such option.  It should just be a matter of removing 
> "target_modules = { module= libiberty; };" and everything that references 
> target-libiberty.

Here we go, pretty straightforward.  For lack of other
suggestions, tested as I suggested: native
x86_64-unknown-linux-gnu, cross to cris-axis-elf, both with old
and new ("breaking") newlib.  Note that I didn't (have to)
change libiberty; after this patch there'll be dead code for
target-libiberty ripe for cleanup.  There's a rationale in
 for
where Joseph mentions some of the bogus dependencies; Looking at
winsup ISTM it's the same (not a *target* dependency, but a
*host* dependency; like a cross-compiler it's built using host
tools and libraries, not using the newly built target tools and
libraries).

Ok for trunk?  Patch for branches will look slightly different;
the code in configure.ac was a single chunk thanks to Joseph
breaking it out earlier.  (Pre-approvals welcome. :)

PR47836
PR23656
PR47733
PR49247
* configure.ac (target_libraries): Remove target-libiberty.
Remove case-statement setting skipdirs=target-libiberty for
multiple targets.  Remove checking target_configdirs and
removing target-libiberty but keeping target-libgcc if
otherwise empty.
* Makefile.def (target_modules): Don't add libiberty.
(dependencies): Remove all traces of target-libiberty.
* configure, Makefile.in: Regenerate.

Index: configure.ac
===
--- configure.ac(revision 175272)
+++ configure.ac(working copy)
@@ -149,9 +149,8 @@ libgcj="target-libffi \
 
 # these libraries are built for the target environment, and are built after
 # the host libraries and the host tools (which may be a cross compiler)
-#
+# Note that libiberty is not a target library.
 target_libraries="target-libgcc \
-   target-libiberty \
target-libgloss \
target-newlib \
target-libgomp \
@@ -490,51 +489,6 @@ case "${target}" in
 ;;
 esac
 
-# Disable target libiberty for some systems.
-case "${target}" in
-  *-*-kaos*)
-# Remove unsupported stuff on all kaOS configurations.
-skipdirs="target-libiberty"
-;;
-  *-*-netbsd*)
-# Skip some stuff on all NetBSD configurations.
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-  *-*-netware*)
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-  *-*-rtems*)
-skipdirs="${skipdirs} target-libiberty"
-;;
-  *-*-tpf*)
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-  *-*-vxworks*)
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-  sh*-*-pe|mips*-*-pe|*arm-wince-pe)
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-  arm*-*-symbianelf*|arm*-*-linux-androideabi)
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-  avr-*-*)
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-  m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-  picochip-*-*)
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-  mips*-sde-elf*)
-skipdirs="$skipdirs target-libiberty"
-;;
-  ip2k-*-*)
-noconfigdirs="$noconfigdirs target-libiberty"
-;;
-esac
-
 # Disable libstdc++-v3 for some systems.
 case "${target}" in
   *-*-vxworks*)
@@ -1965,27 +1919,6 @@ for dir in . $skipdirs $noconfigdirs ; d
   fi
 done
 
-# Sometimes the tools are distributed with libiberty but with no other
-# libraries.  In that case, we don't want to build target-libiberty.
-# Don't let libgcc imply libiberty either.
-if test -n "${target_configdirs}" ; then
-  libgcc=
-  others=
-  for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do
-if test "$i" = "libgcc"; then
-  libgcc=target-libgcc
-elif test "$i" != "libiberty" ; then
-  if test -r $srcdir/$i/configure ; then
-   others=yes;
-   break;
-  fi
-fi
-  done
-  if test -z "${others}" ; then
-target_configdirs=$libgcc
-  fi
-fi
-
 # Quietly strip out all directories which aren't configurable in this tree.
 # This relies on all configurable subdirectories being autoconfiscated, which
 # is now the case.
Index: Makefile.def
===
--- Makefile.def(revision 175272)
+++ Makefile.def(working copy)
@@ -131,7 +131,6 @@ target_modules = { module= libtermcap; n
missing=maintainer-clean; };
 target_mod

Re: Rename attribs.c to attributes.c

2011-06-22 Thread Nicola Pero
> Huh, I see no reason for this rename.  It'll just make patches across
> releases harder.

Sure.  But any change will make "patches across releases harder" ... does
it mean we can't make any changes - not even in phase 1 ? :-(

The reason I'd like to change the name is that "attribs.c" is meaningless.
I never realized it contained code to deal with attributes until I opened
the file and read the code inside.  I always thought it contained some
sort of mysterious internal GCC data structure or pass.  Isn't that a good
enough reason to rename it ? :-)

Anyhow, if you want to keep the ugly name as it is, let's keep it that way.

My next step was going to be to add an "attributes.h" file, moving into it
the attributes functions (lookup_attribute(), is_attribute_p(), 
merge_attributes(),
etc) from tree.h (and moving the corresponding implementations into 
attributes.c).

The idea was to eventually have all the code dealing with attribute lists
in these two files, so that it's easy to change the internal representation.

And, there are few files actually accessing or manipulating attributes; only 
these
files would include attributes.h, while the other ones - which include tree.h - 
wouldn't
include or depend on the attribute functions.

Can I go ahead with this or is it a waste of time as the patch will be rejected 
?

Presumably the new header file would need to be named "attribs.h", and I can't 
name it
"attributes.h" ?  Ouch.

Thanks



Re: Rename attribs.c to attributes.c

2011-06-22 Thread Richard Guenther
On Wed, Jun 22, 2011 at 8:36 PM, Nicola Pero
 wrote:
>> Huh, I see no reason for this rename.  It'll just make patches across
>> releases harder.
>
> Sure.  But any change will make "patches across releases harder" ... does
> it mean we can't make any changes - not even in phase 1 ? :-(

No, not in general.

> The reason I'd like to change the name is that "attribs.c" is meaningless.
> I never realized it contained code to deal with attributes until I opened
> the file and read the code inside.  I always thought it contained some
> sort of mysterious internal GCC data structure or pass.  Isn't that a good
> enough reason to rename it ? :-)

Hmm, attribs.c to me is a perfect abbreviation to attributes.c, so it isn't
unclear (to me) ... there are more confusing file names, like tree-dfa.c
or tree-flow*.[ch].

> Anyhow, if you want to keep the ugly name as it is, let's keep it that way.
>
> My next step was going to be to add an "attributes.h" file, moving into it
> the attributes functions (lookup_attribute(), is_attribute_p(), 
> merge_attributes(),
> etc) from tree.h (and moving the corresponding implementations into 
> attributes.c).

That sounds fine (then with the name attribs.h).

> The idea was to eventually have all the code dealing with attribute lists
> in these two files, so that it's easy to change the internal representation.
>
> And, there are few files actually accessing or manipulating attributes; only 
> these
> files would include attributes.h, while the other ones - which include tree.h 
> - wouldn't
> include or depend on the attribute functions.
>
> Can I go ahead with this or is it a waste of time as the patch will be 
> rejected ?

No, that sounds good and is welcome.

> Presumably the new header file would need to be named "attribs.h", and I 
> can't name it
> "attributes.h" ?  Ouch.

;)

Another maintainer may feel free to override my initial reaction.

Thanks,
Richard.

> Thanks
>
>


Re: [pph] Rename two pph_start_record functions adding in/out. (issue4629049)

2011-06-22 Thread dnovillo

On 2011/06/17 23:18:21, Gabriel Charette wrote:


2011-06-17  Gabriel Charette  



* gcc/cp/pph-streamer-in.c (pph_in_start_record):
Rename from pph_start_record. Update all users.
* gcc/cp/pph-streamer-out.c (pph_out_start_record):
Rename from pph_start_record. Update all users.


OK.  Applied to branch.


Diego.

http://codereview.appspot.com/4629049/


Re: [pph] Reorganize pph read/write file into their respective streamers (issue4657042)

2011-06-22 Thread dnovillo

On 2011/06/21 18:56:24, Gabriel Charette wrote:


2011-06-21  Gabriel Charette  



* gcc/cp/pph-streamer-in.c (pph_in_tree_vec): Make static.
(pph_add_names_to_namespace): Moved from pph.c.
(wrap_macro_def): Moved from pph.c.
(report_validation_error): Moved from pph.c.
(pth_load_identifiers): Moved from pph.c.
(pph_read_file_contents): Moved from pph.c.
(pph_read_file): Moved from pph.c
* gcc/cp/pph-streamer-out.c (pph_out_tree_vec): Make static.
(pph_out_chain_filtered): Make static.
(pth_save_identifiers): Moved from pph.c.
(pph_write_file_contents): Moved from pph.c.
(pph_write_file): Moved from pph.c.
* gcc/cp/pph-streamer.h (pph_out_tree_vec): Now static, removed.
(pph_out_chain_filtered): Now static, removed.
(pph_write_file): Now public, added.
(pph_in_tree_vec): Now static, removed.
(pph_read_file): Now public, added.
* gcc/cp/pph.h (pph_dump_namespace): Exposed.


OK.  Applied to branch.


Diego.

http://codereview.appspot.com/4657042/


Re: [pph] Initialize cache_ix in all paths in pph_start_record (issue4642045)

2011-06-22 Thread dnovillo

On 2011/06/18 01:29:31, Gabriel Charette wrote:


2011-06-17  Gabriel Charette  



* gcc/cp/pph-streamer-in.c (pph_start_record):
Initialize cache_ix in all paths.


OK.  Applied to branch.


Diego.

http://codereview.appspot.com/4642045/


Move params code and hook to libcommon-target

2011-06-22 Thread Joseph S. Myers
This patch continues preparing for the driver to use the
option-handling hooks from cc1 by moving the definitions of --param
arguments and associated target-specific defaults to common code.  The
params themselves go in params.c along with the initialization code
formerly in toplev.c; the hook TARGET_OPTION_DEFAULT_PARAMS moves to
the common hooks structure.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu, and
tested building cc1 and xgcc for crosses to: ia64-elf powerpc-eabi
sh-elf spu-elf.  Will commit to trunk in the absence of objections
from more specific maintainers.

2011-06-22  Joseph Myers  

* params.c: Include common/common-target.h.  Don't include tm.h.
(lang_independent_params): Move from toplev.c.
(global_init_params): New.
* params.h (global_init_params): Declare.
* target.def (default_params): Move to common-target.def.
* toplev.c (lang_independent_options): Remove.
(lang_independent_params): Move to params.c.
(general_init): Use global_init_params.
* common/common-target.def (option_default_params): Move from
target.def.
* common/config/ia64/ia64-common.c: Include params.h.
(ia64_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move
from ia64.c.
* common/config/rs6000/rs6000-common.c: Include params.h.
(rs6000_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move
from rs6000.c.
* common/config/sh/sh-common.c: Include params.h.
(sh_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move
from sh.c.
* common/config/spu/spu-common.c: Include params.h.
(spu_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move
from spu.c.
* config/ia64/ia64.c (ia64_option_default_params,
TARGET_OPTION_DEFAULT_PARAMS): Move to ia64-common.c.
* config/rs6000/rs6000.c (rs6000_option_default_params,
TARGET_OPTION_DEFAULT_PARAMS): Move to rs6000-common.c.
* config/sh/sh.c (sh_option_default_params,
TARGET_OPTION_DEFAULT_PARAMS): Move to sh-common.c.
* config/spu/spu.c (spu_option_default_params,
TARGET_OPTION_DEFAULT_PARAMS): Move to spu-common.c.
* Makefile.in (OBJS): Remove params.o.
(OBJS-libcommon-target): Add params.o.
(params.o, $(common_out_object_file)): Update dependencies.
* doc/tm.texi: Regenerate.

Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi (revision 175248)
+++ gcc/doc/tm.texi (working copy)
@@ -762,7 +762,7 @@ options are changed via @code{#pragma GC
 Set target-dependent initial values of fields in @var{opts}.
 @end deftypefn
 
-@deftypefn {Target Hook} void TARGET_OPTION_DEFAULT_PARAMS (void)
+@deftypefn {Common Target Hook} void TARGET_OPTION_DEFAULT_PARAMS (void)
 Set target-dependent default values for @option{--param} settings, using calls 
to @code{set_default_param_value}.
 @end deftypefn
 
Index: gcc/target.def
===
--- gcc/target.def  (revision 175248)
+++ gcc/target.def  (working copy)
@@ -2545,13 +2545,6 @@ DEFHOOK
  void, (void),
  hook_void_void)
 
-DEFHOOK
-(default_params,
-"Set target-dependent default values for @option{--param} settings, using\
- calls to @code{set_default_param_value}.",
- void, (void),
- hook_void_void)
-
 /* Function to determine if one function can inline another function.  */
 #undef HOOK_PREFIX
 #define HOOK_PREFIX "TARGET_"
Index: gcc/params.c
===
--- gcc/params.c(revision 175248)
+++ gcc/params.c(working copy)
@@ -1,5 +1,5 @@
 /* params.c - Run-time parameters.
-   Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+   Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Written by Mark Mitchell .
 
@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3.  
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tm.h"
+#include "common/common-target.h"
 #include "params.h"
 #include "diagnostic-core.h"
 
@@ -38,6 +38,14 @@ static size_t num_compiler_params;
default values determined.  */
 static bool params_finished;
 
+static const param_info lang_independent_params[] = {
+#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
+  { OPTION, DEFAULT, MIN, MAX, HELP },
+#include "params.def"
+#undef DEFPARAM
+  { NULL, 0, 0, 0, NULL }
+};
+
 /* Add the N PARAMS to the current list of compiler parameters.  */
 
 void
@@ -56,6 +64,16 @@ add_params (const param_info params[], s
   num_compiler_params += n;
 }
 
+/* Add all parameters and default values that can be set in both the
+   driver and the compiler proper.  */
+
+void
+global_init_params (void)
+{
+  add_params (lang_independent_params, LAST_PARAM);
+  targetm_common.option_default_params ();
+}

Re: Rename attribs.c to attributes.c

2011-06-22 Thread Andrew MacLeod



Hmm, attribs.c to me is a perfect abbreviation to attributes.c, so it isn't
unclear (to me) ... there are more confusing file names, like tree-dfa.c
or tree-flow*.[ch].


I also can't imagine what else attrib.c would be other than attributes...


Re: Rename attribs.c to attributes.c

2011-06-22 Thread Joseph S. Myers
On Wed, 22 Jun 2011, Nicola Pero wrote:

> > Huh, I see no reason for this rename.  It'll just make patches across
> > releases harder.
> 
> Sure.  But any change will make "patches across releases harder" ... does
> it mean we can't make any changes - not even in phase 1 ? :-(

I think moving files only makes sense where it makes the modular structure 
clearer - for example, the past move of C-family code to the c-family/ 
directory, or moving libgcc sources to the toplevel libgcc/ directory, or 
moving common code (see 
 for my remarks 
on what to consider common) to the common/ directory.

That your patch needed to change so many places does show up a confusion 
about what sort of an object attribs.o is; it looks like it should go in 
the main OBJS list in Makefile.in and not in any of the other lists it's 
presently in.

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


Re: Removing target-libiberty (was: Re: Libiberty: POSIXify psignal definition)

2011-06-22 Thread DJ Delorie

> Ok for trunk?

Ok with me.  I'll let the branch maintainers decide if they want it
for their branches.


Re: Mark variables addressable if they are copied using libcall in RTL expander

2011-06-22 Thread Easwaran Raman
On Wed, Jun 22, 2011 at 7:13 AM, Eric Botcazou  wrote:
>> I fear this isn't enough considering pass-by-value aggregates that
>> are callee copied.
>
> It's indeed not sufficient for arguments passed by reference but 
> callee-copied.
>
> This is PR target/49454.  For gcc.c-torture/execute/2717-1.c:
>
> typedef struct trio { int a, b, c; } trio;
>
> int
> foo (trio t, int i)
> {
>  return bar (i, t);
> }
>
> yiedls in the .optimized dump:
>
> foo (struct trio t, int i)
> {
>  int D.1968;
>  struct trio t.0;
>
> :
>  t.0 = t;
>  D.1968_2 = bar (i_1(D), t.0);
>  return D.1968_2;
> }
>
> and the aggregate copy is elided by DSE because t.0 isn't may_be_aliased.  
> This
> seems to be a pre-existing bug though: its address is passed to bar in RTL.
>
> --
> Eric Botcazou
>

Is the following patch a reasonable fix for this case?  I assume I
should add similar code inside emit_library_call_value_1.

-Easwaran


--- gcc/calls.c (revision 175081)
+++ gcc/calls.c (working copy)
@@ -1073,6 +1073,8 @@ initialize_argument_information (int num_actuals A
  callee_copies
= reference_callee_copied (args_so_far, TYPE_MODE (type),
   type, argpos < n_named_args);
+  if (callee_copies)
+mark_addressable (args[i].tree_value);

  /* If we're compiling a thunk, pass through invisible references
 instead of making a copy.  */


PATCH: PR rtl-optimization/49504: Invalid optimization for Pmode != ptr_mode

2011-06-22 Thread H.J. Lu
Hi,

I just don't see how nonzero_bits1 can assume if pointers extend unsigned
and this is an addition or subtraction to a pointer in Pmode, all the bits
bove ptr_mode are known to be zero.  We never run into it before x32
since x32 is the first such target.

This patch deletes it.  OK to install the nonzero_bits1 part for trunk?

Thanks.


H.J.
---
diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 564e123..9bbb05b 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,9 @@
+2011-06-22  H.J. Lu  
+
+   PR rtl-optimization/49504
+   * rtlanal.c (nonzero_bits1): Properly handle addition or
+   subtraction a pointer in Pmode if pointers extend unsigned.
+
 2011-06-15  H.J. Lu  
 
PR middle-end/48016
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index b52957d..e5c045d 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -4134,20 +4134,6 @@ nonzero_bits1 (const_rtx x, enum machine_mode mode, 
const_rtx known_x,
 
if (result_low > 0)
  nonzero &= ~(((unsigned HOST_WIDE_INT) 1 << result_low) - 1);
-
-#ifdef POINTERS_EXTEND_UNSIGNED
-   /* If pointers extend unsigned and this is an addition or subtraction
-  to a pointer in Pmode, all the bits above ptr_mode are known to be
-  zero.  */
-   /* As we do not know which address space the pointer is refering to,
-  we can do this only if the target does not support different pointer
-  or address modes depending on the address space.  */
-   if (target_default_pointer_address_modes_p ()
-   && POINTERS_EXTEND_UNSIGNED > 0 && GET_MODE (x) == Pmode
-   && (code == PLUS || code == MINUS)
-   && REG_P (XEXP (x, 0)) && REG_POINTER (XEXP (x, 0)))
- nonzero &= GET_MODE_MASK (ptr_mode);
-#endif
   }
   break;
 
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index ab8dd76..6581a45 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,3 +1,8 @@
+2011-06-22  H.J. Lu  
+
+   PR rtl-optimization/49504
+   * gcc.target/i386/pr49504.c: New.
+
 2011-06-15  H.J. Lu  
 
* gcc.dg/pr44194-1.c: Also allow x32.
diff --git a/gcc/testsuite/gcc.target/i386/pr49504.c 
b/gcc/testsuite/gcc.target/i386/pr49504.c
new file mode 100644
index 000..9128196
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr49504.c
@@ -0,0 +1,18 @@
+/* PR target/49504 */
+/* { dg-do run { target { x32 } } } */
+/* { dg-options "-O" } */
+
+unsigned long long 
+foo (const void* p, unsigned long long q)
+{
+  unsigned long long a = (((unsigned long long) ((unsigned long) p)) + q) >> 
32;
+  return a;
+}
+
+int
+main ()
+{
+  if (foo ((const void*) 0x100, 0x1ULL) == 0)
+__builtin_abort ();
+  return 0;
+}


Re: Rename attribs.c to attributes.c

2011-06-22 Thread Basile Starynkevitch
On Wed, 22 Jun 2011 15:09:33 -0400
Andrew MacLeod  wrote:

> 
> > Hmm, attribs.c to me is a perfect abbreviation to attributes.c, so it isn't
> > unclear (to me) ... there are more confusing file names, like tree-dfa.c
> > or tree-flow*.[ch].
> >
> I also can't imagine what else attrib.c would be other than attributes...

To me, who is not a native English speaker, it could also suggest
attributions, attributives, or even attraction or attrition or "at
tribe". (& it reminds me of "attrister" which mean "to sadden" in
French). And some people starting to hack in GCC don't even know of
attributes (which are a GCC extension that other C compilers might not
have.). So I do favor using long words in identifiers in file names. I
would like most of GCC major public identifiers & filenames made of
long English words (perhaps with a prefix for their module). Gtk naming
conventions is IMHO easier for newbies than GCC ones. 

I also agree that tree-dfa.c is more confusing than attribs.c, but I
still welcome the patch proposed by Nicola Pero.

Regards.
-- 
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: Rename attribs.c to attributes.c

2011-06-22 Thread Basile Starynkevitch
On Wed, 22 Jun 2011 20:36:21 +0200 (CEST)
"Nicola Pero"  wrote:

> > Huh, I see no reason for this rename.  It'll just make patches across
> > releases harder.
> 
> Sure.  But any change will make "patches across releases harder" ... does
> it mean we can't make any changes - not even in phase 1 ? :-(
> 
> The reason I'd like to change the name is that "attribs.c" is meaningless.
> I never realized it contained code to deal with attributes until I opened
> the file and read the code inside.  I always thought it contained some
> sort of mysterious internal GCC data structure or pass.  Isn't that a good
> enough reason to rename it ? :-)


I agree with such renames and clean-ups, but I also sadly think there
are very difficult in the GCC community (because old-timers who could
approve that don't care, and don't like such patches).

In an ideal world, I would like many patches like this. In particular,
I would like some consistent naming conventions (that would contribute
to define what modules are in GCC - so far, we do have "modularity
efforts", but I still believe that we don't have yet modules: we cannot
name them, and we cannot even count them, so in my view they don't
exist yet; some nice old-timers have been upset because I told that GCC
is not modular, but since GCC modules are not counted nor named yet, I
still believe that GCC is not made of well defined modules - and that
is what I mean by "modularity"; for many GCC gurus, it is only a
relative qualification -unrelated to any set of modules-, and GCC is
indeed slowly improving in that aspect.).

An example of patches I dream about but would never dare submitting is
a patch consistently renaming every GCC optimization pass (of struct
opt_pass type, or its subtype). I feel that it would help a lot new
people (and even me) if consistently every pass whose name field is
"FOO" is named FOO_pass (or pass_FOO, I don't care about what
convention we use provided we use it consistently & systematically).
And for the same reasons your patch renaming "attribs.c" to
"attributes.c" is rejected, I believe such a patch (renaming
consistently passes) would also be rejected. It is very sad.

Many GCC gurus don't see the point to make GCC code easier to read to
newcomers (since such a change would temporarily make GCC code harder
to read & to patch for them). This is sad, but won't change. 

As a counter example, I do find GTK (& related libraries) a lot more
modular and more readable than GCC code - both coded in C; naming
conventions, separation of modules as different libraries, usability as
a library, documentation generated from code, younger age explain a
lot.

But GCC is too big and too important (and probably working well enough)
to change a lot. So while I do welcome a lot patches like the changing
of attribs.c to attributes.c advocated by Nicola Pero (and I admire his
courage), I sadly believe they won't happen (unless proposed by a very
select & closed circle of people).

Perhaps the long term goal of progressively rewrite GCC in C++ might
help (but I am a bit skeptical here too, I don't see lot of code on
this point.). I don't like C++, but I believe that it could perhaps
push such a rewrite (but I am pessimistic on the short run).

There is an economical explanation for this: no corporation (not even
the richest ones like Google, IBM, ...) is willing to spend money
paying GCC developers to re-factor or rewrite parts of GCC. And such a
massive effort won't happen freely (i.e. without investment). Besides,
some organizations or people knowing very well GCC have no interest in
such changes.  And indeed, few people could promise that such a
rewriting would improve GCC by a significant, predictable, & measurable
amount.  Sadly, GCC is almost nearly good enough for most corporations
investing in it (so they can invest only in "marginal" improvements,
even if "marginal" may mean several person-years to them!).

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} ***


[pph] Stream scope_chain->bindings instead of global namespace (issue4661045)

2011-06-22 Thread Gabriel Charette
We were streaming out the whole global namespace tree and only using its
bindings on the way in. These bindings (defined by NAMESPACE_LEVEL 
(global_namespace))
are the same as scope_chain->bindings.

Stream those bindings only instead.

This also allows us to append the global_namespace itself to the lto cache
early so that anything pointing to global namespace in the underlying
structure of the bindings (and anything else potentially?!) will point to the
actual global namespace when streamed back in (as opposed to the stale version
we were streaming in).

Can someone confirm that we really didn't need to stream anything but the
bindings from the global_namespace?

This patch also changes the behaviour of the dumper (used for debug only) in
that it dumps the global namespace on read AFTER the bindings were merged with
the current global namespace; as opposed to the prior behaviour which was
to dump the namespace READ in.
This is actually a good thing, because I just realized some of the bindings
are read, but not merged correctly (working on that next), and this exposes
it.

2011-06-22  Gabriel Charette  

* gcc/cp/pph-streamer-in.c (pph_add_names_to_namespace): Replaced by
pph_add_bindings_to_namespace.
(pph_add_bindings_to_namespace): New.
(pph_in_scope_chain): New.
(pph_read_file_contents): Remove unused variable file_ns.
(pph_read_file_contents): Call pph_in_scope_chain.
* gcc/cp/pph-streamer-out.c (pph_out_scope_chain): New.
(pph_write_file_contents): Call pph_out_scope_chain.
* gcc/cp/pph-streamer.c (pph_preload_common_nodes):
Call lto_streamer_cache_append.

diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index e71f744..2e3545a 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -976,15 +976,14 @@ pph_in_lang_type (pph_stream *stream)
 }
 
 
-/* Add all the new names declared in NEW_NS to NS.  */
+/* Add all bindings declared in BL to NS.  */
 
 static void
-pph_add_names_to_namespace (tree ns, tree new_ns)
+pph_add_bindings_to_namespace (struct cp_binding_level *bl, tree ns)
 {
   tree t, chain;
-  struct cp_binding_level *level = NAMESPACE_LEVEL (new_ns);
 
-  for (t = level->names; t; t = chain)
+  for (t = bl->names; t; t = chain)
 {
   /* Pushing a decl into a scope clobbers its DECL_CHAIN.
 Preserve it.  */
@@ -992,18 +991,35 @@ pph_add_names_to_namespace (tree ns, tree new_ns)
   pushdecl_into_namespace (t, ns);
 }
 
-  for (t = level->namespaces; t; t = chain)
+  for (t = bl->namespaces; t; t = chain)
 {
   /* Pushing a decl into a scope clobbers its DECL_CHAIN.
 Preserve it.  */
   /* FIXME pph: we should first check to see if it isn't already there.  */
   chain = DECL_CHAIN (t);
   pushdecl_into_namespace (t, ns);
-  pph_add_names_to_namespace (t, t);
+  /* FIXME pph: this carried over from pph_add_names_to_namespace,
+it only makes sense to use this when merging names in an existing
+namespace.
+  pph_add_bindings_to_namespace (NAMESPACE_LEVEL (t), t);  */
 }
 }
 
 
+/* Merge scope_chain bindings from the stream into SS. */
+
+static void
+pph_in_scope_chain (pph_stream *stream)
+{
+  struct cp_binding_level *pph_bindings;
+
+  pph_bindings = pph_in_binding_level (stream);
+
+  /* Merge the bindings obtained from STREAM in the global namespace.  */
+  pph_add_bindings_to_namespace (pph_bindings, global_namespace);
+}
+
+
 /* Wrap a macro DEFINITION for printing in an error.  */
 
 static char *
@@ -1128,7 +1144,6 @@ pph_read_file_contents (pph_stream *stream)
   cpp_ident_use *bad_use;
   const char *cur_def;
   cpp_idents_used idents_used;
-  tree file_ns;
 
   pth_load_identifiers (&idents_used, stream);
 
@@ -1141,12 +1156,12 @@ pph_read_file_contents (pph_stream *stream)
   /* Re-instantiate all the pre-processor symbols defined by STREAM.  */
   cpp_lt_replay (parse_in, &idents_used);
 
-  /* Read global_namespace from STREAM and add all the names defined
- there to the current global_namespace.  */
-  file_ns = pph_in_tree (stream);
+  /* Read the bindings from STREAM and merge them with the current bindings.  
*/
+  pph_in_scope_chain (stream);
+
   if (flag_pph_dump_tree)
-pph_dump_namespace (pph_logfile, file_ns);
-  pph_add_names_to_namespace (global_namespace, file_ns);
+pph_dump_namespace (pph_logfile, global_namespace);
+
   keyed_classes = pph_in_tree (stream);
   unemitted_tinfo_decls = pph_in_tree_vec (stream);
   /* FIXME pph: This call replaces the tinfo, we should merge instead.
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index 3187338..691cfdd 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -935,6 +935,33 @@ pph_out_lang_type (pph_stream *stream, tree type, bool 
ref_p)
 }
 
 
+/* Write saved_scope information stored in SS, does NOT output all fields,
+   meant to be used for the global variable "scope_chain" 

Re: RFC: __gnu_cxx::__alloc_traits extension

2011-06-22 Thread Jonathan Wakely
On 11 June 2011 16:41, Jonathan Wakely wrote:
>
> 2011-06-11  Jonathan Wakely  
>
>        * include/Makefile.am: Add alloc_traits.h headers.
>        * include/Makefile.in: Regenerate.
>        * include/std/memory: Include uses_allocator.h explicitly.
>        * include/bits/allocator.h (allocator_traits): Move to ...
>        * include/bits/alloc_traits.h: New header.
>        * include/ext/alloc_traits.h (__alloc_traits): Extension to provide
>        a common allocator interface for C++98 and C++0x.
>        * include/bits/stl_construct.h: Use __alloc_traits.
>        * include/bits/stl_uninitialized.h: Likewise.
>

Re-tested on x86_64-linux and committed as attached (the same as the
patch I sent 11 days ago but with one additional doxygen comment in
the new ext/alloc_traits.h header)


patch
Description: Binary data


Re: [PATCH] Change omp for static non-chunk computation (PR libgomp/49490)

2011-06-22 Thread Richard Henderson
On 06/22/2011 11:13 AM, Jakub Jelinek wrote:
> Richard, do you agree with this?
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux.
> 
> 2011-06-22  Jakub Jelinek  
> 
>   PR libgomp/49490
>   * omp-low.c (expand_omp_for_static_nochunk): Only
>   use n ceil/ nthreads size for the first
>   n % nthreads threads in the team instead of
>   all threads except for the last few ones which
>   get less work or none at all.
> 
>   * iter.c (gomp_iter_static_next): For chunk size 0
>   only use n ceil/ nthreads size for the first
>   n % nthreads threads in the team instead of
>   all threads except for the last few ones which
>   get less work or none at all.
>   * iter_ull.c (gomp_iter_ull_static_next): Likewise.
>   * env.c (parse_schedule): If OMP_SCHEDULE doesn't have
>   chunk argument, set run_sched_modifier to 0 for static
>   resp. 1 for other kinds.  If chunk argument is 0
>   and not static, set value to 1.

Looks good.


r~


[PATCH] [annotalysis] Support IPA-SRA cloned functions (issue 4591066)

2011-06-22 Thread Delesley Hutchins
Hi,

This patch is merely a port of an earlier patch, made by Le-Chun Wu,
from google/main
to annotalysis.  It extends Annotalysis to support cloned
functions/methods (especially
created by IPA-SRA).

Bootstrapped and passed GCC regression testsuite on x86_64-unknown-linux-gnu.

Okay for branches/annotalysis?

  -DeLesley


2011-06-22  Le-Chun Wu  ,  DeLesley Hutchins

        * tree-threadsafe-analyze.c (build_fully_qualified_lock): Handle
        IPA-SRA cloned methods.
        (get_canonical_lock_expr): Fold expressions that are INDIRECT_REF on
        top of ADDR_EXPR.
        (check_lock_required): Handle IPA-SRA cloned methods.
        (check_func_lock_excluded): Likewise.
        (process_function_attrs): Likewise.


Index: gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-78.C
===
--- gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-78.C  (revision 0)
+++ gcc/testsuite/g++.dg/thread-ann/thread_annot_lock-78.C  (revision 
175062)
@@ -0,0 +1,28 @@
+// Test the support to handle cloned methods.
+// { dg-do compile }
+// { dg-options "-O2 -Wthread-safety -fipa-sra" }
+
+#include "thread_annot_common.h"
+
+struct A {
+  int *data_ PT_GUARDED_BY(mu_);
+  mutable Mutex mu_;
+  void Reset(void) EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+delete data_;
+  }
+};
+
+struct B {
+  A a_;
+  void TestFunc1();
+  void TestFunc2();
+};
+
+void B::TestFunc1() {
+  MutexLock l(&a_.mu_);
+  a_.Reset();  // This call is an IPA-SRA clone candidate.
+}
+
+void B::TestFunc2() {
+  a_.Reset();  // { dg-warning "Calling function 'Reset' requires lock" }
+}
Index: gcc/tree-threadsafe-analyze.c
===
--- gcc/tree-threadsafe-analyze.c   (revision 175061)
+++ gcc/tree-threadsafe-analyze.c   (working copy)
@@ -696,9 +696,13 @@
  rid of the ADDR_EXPR operator before we form the new lock expression.  */
   if (TREE_CODE (canon_base) != ADDR_EXPR)
 {
-  gcc_assert (POINTER_TYPE_P (TREE_TYPE (canon_base)));
-  canon_base = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (canon_base)),
-   canon_base);
+  /* Note that if the base object is neither an ADDR_EXPR, nor a pointer,
+ most likely we have done IPA-SRA optimization and the DECL is a
+ cloned method, where reference parameters are changed to be passed
+ by value. So in this case, we don't need to do anything.  */
+  if (POINTER_TYPE_P (TREE_TYPE (canon_base)))
+canon_base = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (canon_base)),
+ canon_base);
 }
   else
 canon_base = TREE_OPERAND (canon_base, 0);
@@ -956,8 +960,18 @@
  true /* is_temp_expr */,
  new_leftmost_base_var);
   if (base != canon_base)
-lock = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (canon_base)),
-   canon_base);
+{
+  /* If CANON_BASE is an ADDR_EXPR (e.g. &a), doing an indirect or
+ memory reference on top of it is equivalent to accessing the
+ variable itself. That is, *(&a) == a. So if that's the case,
+ simply return the variable. Otherwise, build an indirect ref
+ expression.  */
+  if (TREE_CODE (canon_base) == ADDR_EXPR)
+lock = TREE_OPERAND (canon_base, 0);
+  else
+lock = build1 (INDIRECT_REF,
+   TREE_TYPE (TREE_TYPE (canon_base)), canon_base);
+}
   break;
 }
   default:
@@ -1135,10 +1149,18 @@
  NULL_TREE);
   if (TREE_CODE (canon_base) != ADDR_EXPR)
 {
-  gcc_assert (POINTER_TYPE_P (TREE_TYPE (canon_base)));
-  base_obj = build1 (INDIRECT_REF,
- TREE_TYPE (TREE_TYPE (canon_base)),
- canon_base);
+  if (POINTER_TYPE_P (TREE_TYPE (canon_base)))
+base_obj = build1 (INDIRECT_REF,
+   TREE_TYPE (TREE_TYPE (canon_base)),
+   canon_base);
+  /* If the base object is neither an ADDR_EXPR, nor a pointer,
+ and DECL is a cloned method, most likely we have done IPA-SRA
+ optimization, where reference parameters are changed to be
+ passed by value. So in this case, just use the CANON_BASE.  */
+  else if (DECL_ABSTRACT_ORIGIN (decl))
+base_obj = canon_base;
+  else
+gcc_unreachable ();
 }
   else
 base_obj = TREE_OPERAND (canon_base, 0);
@@ -1154,9 +1176,9 @@

   /* We want to use fully-qualified expressions (i.e. including bas

Re: [cxx-mem-model] sync_mem_exchange implementation with memory model parameters

2011-06-22 Thread Richard Henderson
On 06/21/2011 03:27 PM, Andrew MacLeod wrote:
>   * doc/extend.texi (__sync_mem_exchange): Document.
>   * cppbuiltin.c (define__GNUC__): Define __SYNC_MEM*.
>   * c-family/c-common.c (BUILT_IN_SYNC_MEM_EXCHANGE_N): Add case.
>   * optabs.c (expand_sync_mem_exchange): New.
>   * optabs.h (enum direct_optab_index): Add DOI_sync_mem_exchange entry.
>   (sync_mem_exchange_optab): Define.
>   * genopinit.c: Add entry for sync_mem_exchange.
>   * builtins.c (get_memmodel): New.
>   (expand_builtin_sync_mem_exchange): New.
>   (expand_builtin_sync_synchronize): Remove static.
>   (expand_builtin): Add cases for BUILT_IN_SYNC_MEM_EXCHANGE_*.
>   * sync-builtins.def: Add entries for BUILT_IN_SYNC_MEM_EXCHANGE_*.
>   * testsuite/gcc.dg/x86-sync-1.c: New test.
>   * builtin-types.def (BT_FN_I{1,2,4,8,16}_VPTR_I{1,2,4,8,16}_INT): New.
>   * expr.h (expand_sync_mem_exchange): Declare.
>   (expand_builtin_sync_synchronize): Declare.
>   * fortran/types.def (BT_FN_I{1,2,4,8,16}_VPTR_I{1,2,4,8,16}_INT): New.
>   * coretypes.h (enum memmodel): New.
>   * Makefile.in (cppbuiltin.o) Add missing dependency on $(TREE_H)
>   * config/i386/sync.md (sync_mem_exchange): New pattern.
> 

Looks good.


r~


Re: [PATCH][RFC][2/2] Bitfield lowering

2011-06-22 Thread Hans-Peter Nilsson
On Thu, 16 Jun 2011, Richard Guenther wrote:

> This implements lowering a subset of COMPONENT_REFs with DECL_BIT_FIELD
> FIELD_DECLs and BIT_FIELD_REFs - thus bitfield operations in general.
> It lowers those to memory loads/stores that the (non-strict-align) target
> is able to carry out, adjusting for the bit-field-ness by inserting
> proper shifting and masking operations (just like expand does).

>
> Comments welcome - I wanted to post this before London to get
> some input from people that won't attend.

What does it do to code for targets with some kind of bitfield
access insns?  (insv, extv, various test insns taking a
zero_extract or sign_extract argument)

>From the above "just like expand" I guess it's expected to be a
no change, right?

brgds, H-P


[lra] a patch to speed up LRA

2011-06-22 Thread Vladimir Makarov
The following patch speeds up LRA mostly for architectures with moderate 
or large register files.


The patch was successfully bootstrapped on x86-64, ia64, and ppc64.

2011-06-22  Vladimir Makarov 

* lra-assign.c (live_range_hard_reg_pseudos): Make it a sparseset.
(live_range_hard_reg_pseudos, live_range_reload_pseudos): Ditto.
(init_live_reload_pseudos, finish_live_reload_pseudos): Work with
the above variables as sparsesets.
(find_hard_regno_for, spill_for): Ditto.
(setup_live_pseudos_and_spill_after_equiv_moves): Ditto.

* Makefile.in (lra-assign.o): Add missed sparseset.h.


Index: lra-assigns.c
===
--- lra-assigns.c   (revision 175083)
+++ lra-assigns.c   (working copy)
@@ -136,13 +136,13 @@
live_pseudos_reg_renumber always reflects the info.  */
 static int *live_pseudos_reg_renumber;
 
-/* Bitmap used to calculate living hard reg pseudos for some program
+/* Sparseset used to calculate living hard reg pseudos for some program
point range.  */
-static bitmap_head live_range_hard_reg_pseudos;
+static sparseset live_range_hard_reg_pseudos;
 
-/* Bitmap used to calculate living reload pseudos for some program
+/* Sparseset used to calculate living reload pseudos for some program
point range.  */
-static bitmap_head live_range_reload_pseudos;
+static sparseset live_range_reload_pseudos;
 
 /* Allocate and initialize the data about living pseudos at program
points.  */
@@ -151,8 +151,8 @@
 {
   int i;
 
-  bitmap_initialize (&live_range_hard_reg_pseudos, ®_obstack);
-  bitmap_initialize (&live_range_reload_pseudos, ®_obstack);
+  live_range_hard_reg_pseudos = sparseset_alloc (max_reg_num ());
+  live_range_reload_pseudos = sparseset_alloc (max_reg_num ());
   live_hard_reg_pseudos = (bitmap_head *) xmalloc (sizeof (bitmap_head)
   * lra_live_max_point);
   for (i = 0; i < lra_live_max_point; i++)
@@ -169,8 +169,8 @@
 {
   int i;
 
-  bitmap_clear (&live_range_hard_reg_pseudos);
-  bitmap_clear (&live_range_reload_pseudos);
+  sparseset_free (live_range_hard_reg_pseudos);
+  sparseset_free (live_range_reload_pseudos);
   for (i = 0; i < lra_live_max_point; i++)
 bitmap_clear (&live_hard_reg_pseudos[i]);
   free (live_hard_reg_pseudos);
@@ -206,10 +206,10 @@
 }
 }
 
-/* Bitmap used to calculate reload pseudos conflicting with a given
+/* Sparseset used to calculate reload pseudos conflicting with a given
pseudo when we are trying to find a hard register for the given
pseudo.  */
-static bitmap_head conflict_reload_pseudos;
+static sparseset conflict_reload_pseudos;
 
 /* Map: program point -> bitmap of all reload pseudos living at the
point.  */
@@ -223,7 +223,7 @@
   int i, p;
   lra_live_range_t r;
   
-  bitmap_initialize (&conflict_reload_pseudos, ®_obstack);
+  conflict_reload_pseudos = sparseset_alloc (max_reg_num ());
   live_reload_pseudos
 = (bitmap_head *) xmalloc (sizeof (bitmap_head) * lra_live_max_point);
   for (p = 0; p < lra_live_max_point; p++)
@@ -241,7 +241,7 @@
 {
   int p;
 
-  bitmap_clear (&conflict_reload_pseudos);
+  sparseset_free (conflict_reload_pseudos);
   for (p = 0; p < lra_live_max_point; p++)
 bitmap_clear (&live_reload_pseudos[p]);
   free (live_reload_pseudos);
@@ -286,7 +286,7 @@
   lra_live_range_t r;
   int p, i, j, rclass_size, best_hard_regno, bank;
   int curr_regno, hard_regno;
-  unsigned int conflict_regno, original_regno;
+  unsigned int k, conflict_regno, original_regno;
   enum reg_class rclass;
   bitmap_iterator bi;
   bool all_p;
@@ -294,8 +294,8 @@
   COPY_HARD_REG_SET (conflict_set, lra_no_alloc_regs);
   rclass = lra_get_preferred_class (regno);
   curr_hard_regno_costs_check++;
-  bitmap_clear (&conflict_reload_pseudos);
-  bitmap_clear (&live_range_hard_reg_pseudos);
+  sparseset_clear (conflict_reload_pseudos);
+  sparseset_clear (live_range_hard_reg_pseudos);
   for (curr_regno = lra_reg_info[regno].first;
curr_regno >= 0;
curr_regno = lra_reg_info[curr_regno].next)
@@ -306,10 +306,10 @@
   r != NULL;
   r = r->next)
{
- bitmap_ior_into (&live_range_hard_reg_pseudos,
-  &live_hard_reg_pseudos[r->start]);
- bitmap_ior_into (&conflict_reload_pseudos,
-  &live_reload_pseudos[r->start]);
+ EXECUTE_IF_SET_IN_BITMAP (&live_hard_reg_pseudos[r->start], 0, k, bi)
+   sparseset_set_bit (live_range_hard_reg_pseudos, k);
+ EXECUTE_IF_SET_IN_BITMAP (&live_reload_pseudos[r->start], 0, k, bi)
+   sparseset_set_bit (conflict_reload_pseudos, k);
  for (p = r->start + 1; p <= r->finish; p++)
{
  lra_live_range_t r2;
@@ -317,9 +317,9 @@
  for (r2 = lra_start_point_ranges[p]; r2 != NULL; r2 = 
r2->start_next)
{
  if (r2->regno >= lra_constrain

Re: Rename attribs.c to attributes.c

2011-06-22 Thread Diego Novillo
On Wed, Jun 22, 2011 at 15:03, Basile Starynkevitch
 wrote:
> On Wed, 22 Jun 2011 20:36:21 +0200 (CEST)
> "Nicola Pero"  wrote:
>
>> > Huh, I see no reason for this rename.  It'll just make patches across
>> > releases harder.
>>
>> Sure.  But any change will make "patches across releases harder" ... does
>> it mean we can't make any changes - not even in phase 1 ? :-(
>>
>> The reason I'd like to change the name is that "attribs.c" is meaningless.
>> I never realized it contained code to deal with attributes until I opened
>> the file and read the code inside.  I always thought it contained some
>> sort of mysterious internal GCC data structure or pass.  Isn't that a good
>> enough reason to rename it ? :-)
>
>
> I agree with such renames and clean-ups, but I also sadly think there
> are very difficult in the GCC community (because old-timers who could
> approve that don't care, and don't like such patches).

You keep overgeneralizing and I think it is misleading.

Existing reviewers will object to certain renames and/or cleanups when
they do not see a compelling value proposition.  If you think that
your change brings value, but the maintainer does not see it, it may
be a sign that you have not described the change properly.  Or it may
be simply a sign that your change is not as valuable as a cleanup as
you think it is.

In the end, some cleanups are a judgment call.  Different reviewers
will have different opinions.

> In an ideal world, I would like many patches like this. In particular,
> I would like some consistent naming conventions (that would contribute
> to define what modules are in GCC - so far, we do have "modularity
> efforts", but I still believe that we don't have yet modules: we cannot
> name them, and we cannot even count them, so in my view they don't
> exist yet; some nice old-timers have been upset because I told that GCC
> is not modular, but since GCC modules are not counted nor named yet, I
> still believe that GCC is not made of well defined modules - and that
> is what I mean by "modularity"; for many GCC gurus, it is only a
> relative qualification -unrelated to any set of modules-, and GCC is
> indeed slowly improving in that aspect.).

Do not expect these changes to show up in a sudden rush of modernity.
It will take time.  Some may never materialize (diminishing returns,
though we are still far from that point).


Diego.


Re: [pph] Stream scope_chain->bindings instead of global namespace (issue4661045)

2011-06-22 Thread dnovillo


http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-in.c
File gcc/cp/pph-streamer-in.c (right):

http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-in.c#newcode1003
gcc/cp/pph-streamer-in.c:1003: namespace.
 1001   /* FIXME pph: this carried over from
pph_add_names_to_namespace,
 1002 »it only makes sense to use this when merging names in an
existing
 1003 »namespace.

pph_add_names_to_namespace does not exist anymore.  I don't understand
this comment.

http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-out.c
File gcc/cp/pph-streamer-out.c (right):

http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-out.c#newcode947
gcc/cp/pph-streamer-out.c:947: gcc_assert ( ss->old_namespace ==
global_namespace
  945   /* old_namespace should be global_namespace and all entries
listed below
  946  should be NULL or 0; otherwise the header parsed was
incomplete.  */
  947   gcc_assert ( ss->old_namespace == global_namespace

No space after '('.

http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-out.c#newcode949
gcc/cp/pph-streamer-out.c:949: || ss->function_decl ||
ss->template_parms || ss->x_saved_tree
  948   && !(ss->class_name || ss->class_type ||
ss->access_specifier
  949|| ss->function_decl || ss->template_parms ||
ss->x_saved_tree

Align '&&' vertically with the open brace.

http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer.c
File gcc/cp/pph-streamer.c (right):

http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer.c#newcode34
gcc/cp/pph-streamer.c:34: #include "name-lookup.h"
  33 #include "cppbuiltin.h"
+ 34 #include "name-lookup.h"

You also need to add cp/name-lookup.h to the list of dependencies for
cp/pph.o in cp/Make-lang.in.

http://codereview.appspot.com/4661045/


Re: Removing target-libiberty (was: Re: Libiberty: POSIXify psignal definition)

2011-06-22 Thread Hans-Peter Nilsson
> Date: Wed, 22 Jun 2011 20:16:48 +0200
> From: Hans-Peter Nilsson 

> 
>   PR47836
>   PR23656
>   PR47733
>   PR49247
>   * configure.ac (target_libraries): Remove target-libiberty.
...

JFTR, that's not proper PR annotation.  I changed it as obvious
to the following, which ends up as intended in bugzilla.

PR regression/47836
PR bootstrap/23656
PR other/47733
PR bootstrap/49247
* configure.ac (target_libraries): Remove target-libiberty.
...

brgds, H-P


Re: Rename attribs.c to attributes.c

2011-06-22 Thread Basile Starynkevitch
On Wed, 22 Jun 2011 16:41:36 -0400
Diego Novillo  wrote:
> 
> You keep overgeneralizing and I think it is misleading.
> 
> Existing reviewers will object to certain renames and/or cleanups when
> they do not see a compelling value proposition.  If you think that
> your change brings value, but the maintainer does not see it, it may
> be a sign that you have not described the change properly. 


I tend to agree, with an important caveat. Cosmetic changes (like
renaming attribs.c to attributes.c) have much more subjective value to
newcomers or GCC newbies than to GCC gurus.

Any person working for several years on GCC (and that includes even me)
don't care that much about attribs.c vs attributes.c, but a newbie will
care a big lot. For us, the change don't bring much, we all have read
the start of attribs.c files. For a newbie, the change will bring
value. This is subjective!

I am more near to "newbie" state that Richie or you Diego are. So I
probably understand more their particular feelings and not being a
native English speaker also helps a big lot :-)

BTW, GCC development favors small patches, and that is a big bias.

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: Cgraph alias reorg 15/14 (New infrastructure for same body aliases)

2011-06-22 Thread Hans-Peter Nilsson
On Sun, 19 Jun 2011, Jan Hubicka wrote:
> > > On Sat, 11 Jun 2011, Jan Hubicka wrote:
> > >
> > > > Hi,
> > > > this patch complettes the same body alias rework by removing the old 
> > > > same body
> > > > alias code and adding new representation.  Same body aliases are now 
> > > > separate
> > > > function nodes that have IPA_REF_ALIAS reference to the node they are 
> > > > alias of.
> > > >
> > > > I am still getting one failure:
> > > > FAIL: g++.dg/torture/pr43879-1_1.C
> > > >
> > > > It tests IPA PTA in presence of same body aliases.  I honestly have no 
> > > > idea
> > > > what is wrong there.  I decided to go ahead with the patch anyway, 
> > > > given the
> > > > current state of affair of aliases and IPA-PTA. Hope Richard will help 
> > > > me
> > > > fixing this on Monday.
> > >
> > > Still there, see again PR49373.  Anything better than a xfail in the 
> > > works?
> >
> > Yes, we discussed the problem with Richi and the issue is that ipa-pta gets
> > confused by inliner redirecting edge from alias to the real inline clone.
> > The proper fix is to teach passmanager to do small ipa passes before final
> > compilation.  I am currently at the GCC gathering, so I plan to implement
> > this day after tomorrow after returning.
> But for sure we can xfail it.

Ok, done:

PR middle-end/49373
* g++.dg/torture/pr43879-1_1.C: Xfail for -O1 and above, except -flto.

Index: g++.dg/torture/pr43879-1_1.C
===
--- g++.dg/torture/pr43879-1_1.C(revision 174961)
+++ g++.dg/torture/pr43879-1_1.C(working copy)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-options "-fipa-pta" } */
 /* { dg-additional-sources "pr43879-1_0.C" } */
+/* { dg-xfail-run-if "PR49373" { *-*-* } { -O1 -O2 -O3 -Os } { -flto } } */

 struct A {
 int *i;

brgds, H-P


[v3] Avoid -Wall warnings in the testsuite

2011-06-22 Thread Paolo Carlini

... all, besides that corresponding to c++/49508.

Committed to mainline.

Thanks,
Paolo.

//
2011-06-22  Paolo Carlini  

* testsuite/20_util/reference_wrapper/invoke.cc: Avoid -Wall warnings.
* testsuite/20_util/reference_wrapper/typedefs-3.cc: Likewise.
* testsuite/20_util/reference_wrapper/invoke-2.cc: Likewise.
* testsuite/20_util/allocator_traits/members/allocate_hint.cc:
Likewise.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.
* testsuite/20_util/bind/socket.cc: Likewise.
* testsuite/20_util/pointer_traits/pointer_to.cc: Likewise.
* testsuite/util/testsuite_random.h: Likewise.

Index: testsuite/util/testsuite_random.h
===
--- testsuite/util/testsuite_random.h   (revision 175315)
+++ testsuite/util/testsuite_random.h   (working copy)
@@ -48,7 +48,7 @@
   for (unsigned long i = 0; i < N; i++)
{
  auto r = f();
- if (r >= 0 && r < BINS)
+ if (r >= 0 && (unsigned long)r < BINS)
count[r]++;
}
 
@@ -116,7 +116,7 @@
 if (!wl.size())
   wl = { 1.0 };
 
-if (k < 0 || k >= wl.size())
+if (k < 0 || (std::size_t)k >= wl.size())
   return 0.0;
 else
   {
Index: testsuite/20_util/reference_wrapper/invoke.cc
===
--- testsuite/20_util/reference_wrapper/invoke.cc   (revision 175315)
+++ testsuite/20_util/reference_wrapper/invoke.cc   (working copy)
@@ -75,7 +75,8 @@
   int (::X::* p_foo_c)(float) const = &::X::foo_c;
   int (::X::* p_foo_v)(float) volatile = &::X::foo_v;
   int (::X::* p_foo_cv)(float) const volatile = &::X::foo_cv;
-  int (::X::* p_foo_varargs)(float, ...) = &::X::foo_varargs;
+  int (::X::* p_foo_varargs)(float, ...) __attribute__((unused))
+= &::X::foo_varargs;
   int ::X::* p_bar = &::X::bar;
 
   const float pi = 3.14;
Index: testsuite/20_util/reference_wrapper/typedefs-3.cc
===
--- testsuite/20_util/reference_wrapper/typedefs-3.cc   (revision 175315)
+++ testsuite/20_util/reference_wrapper/typedefs-3.cc   (working copy)
@@ -124,14 +124,14 @@
 template
   void test()
   {
-test_arg_type t;
-test_arg_type tc;
-test_arg_type tv;
-test_arg_type tcv;
-test_1st_2nd_arg_types t12;
-test_1st_2nd_arg_types t12c;
-test_1st_2nd_arg_types t12v;
-test_1st_2nd_arg_types t12cv;
+test_arg_type t __attribute__((unused));
+test_arg_type tc __attribute__((unused));
+test_arg_type tv __attribute__((unused));
+test_arg_type tcv __attribute__((unused));
+test_1st_2nd_arg_types t12 __attribute__((unused));
+test_1st_2nd_arg_types t12c __attribute__((unused));
+test_1st_2nd_arg_types t12v __attribute__((unused));
+test_1st_2nd_arg_types t12cv __attribute__((unused));
   }
 
 int main()
Index: testsuite/20_util/reference_wrapper/invoke-2.cc
===
--- testsuite/20_util/reference_wrapper/invoke-2.cc (revision 175315)
+++ testsuite/20_util/reference_wrapper/invoke-2.cc (working copy)
@@ -36,8 +36,8 @@
   X x = { };
   std::ref(m)(x, 1);
   std::ref(m)(&x, 1);
-  int& i1 = std::ref(m2)(x);
-  int& i2 = std::ref(m2)(&x);
+  int& i1 __attribute__((unused)) = std::ref(m2)(x);
+  int& i2 __attribute__((unused)) = std::ref(m2)(&x);
 }
 
 int main()
Index: testsuite/20_util/allocator_traits/members/allocate_hint.cc
===
--- testsuite/20_util/allocator_traits/members/allocate_hint.cc (revision 
175315)
+++ testsuite/20_util/allocator_traits/members/allocate_hint.cc (working copy)
@@ -51,7 +51,7 @@
   typedef std::allocator_traits> traits_type;
   traits_type::allocator_type a;
   traits_type::const_void_pointer v;
-  X* p = traits_type::allocate(a, 1, v);
+  X* p __attribute__((unused)) = traits_type::allocate(a, 1, v);
   VERIFY( a.called );
 }
 
@@ -79,7 +79,7 @@
   typedef std::allocator_traits> traits_type;
   traits_type::allocator_type a;
   traits_type::const_void_pointer v;
-  X* p = traits_type::allocate(a, 1, v);
+  X* p __attribute__((unused)) = traits_type::allocate(a, 1, v);
   VERIFY( a.called );
 }
 
Index: testsuite/20_util/ratio/operations/ops_overflow_neg.cc
===
--- testsuite/20_util/ratio/operations/ops_overflow_neg.cc  (revision 
175315)
+++ testsuite/20_util/ratio/operations/ops_overflow_neg.cc  (working copy)
@@ -26,19 +26,22 @@
 void
 test01()
 {
-  std::ratio_add, std::ratio<1>>::type r1;
+  std::ratio_add, std::ratio<1>>::type r1
+__attribute__((unused));
 }
 
 void
 test02()
 {  
-  std::ratio_multiply, std::ratio<3, 2>>::type r1;
-  std::ratio_multiply, std::ratio>::type r2;
+  std::ratio_multiply, std::ratio<3, 2>>::type r1
+__attribute__(

[cxx-mem-model] sync_mem_exchange tests

2011-06-22 Thread Andrew MacLeod
And I propose this for the basic functionality tests. (I'm not using the 
one Aldy had in the original patch anymore)


'sync-mem.h' provides the bits required to test the existence and basic 
functionality of a sync_mem_exchange with all the valid memory models.  
All it is missing is a declaration of the type.


sync-mem[1-5].c define a type and then include sync-mem.h to test each 
of 1, 2, 4, 8, and 16 byte variations.  I did it this way since there 
are different dejagnu options and stuff for each of the different sizes, 
especially the 16 byte variation.


sync-mem-invalid.c tests for compiler generated errors when invalid 
memory models are specified.



As new sync memory model built-ins are defined, they just need to add a 
routine to sync-mem.h to test the valid memory models, and

add an entry to sync-mem-invalid for each invalid mode.

I'll properly fill in the supported hardware for 
'check_effective_target_sync_int_128' and 
'check_effective_target_sync_long_long' once I get around to figuring 
them out.


Seem reasonable?   May shuffle stuff around later, but this is a start.

Andrew


* lib/target-support.exp (check_effective_target_sync_int_128,
check_effective_target_sync_long_long): Check whether the target
supports 64 and 128 bit __sync builtins.
* gcc.dg/sync-mem.h: New. Common code to check memory model __syncs.
* gcc.dg/sync-mem-1.c: New. Check char size.
* gcc.dg/sync-mem-2.c: New. Check short size.
* gcc.dg/sync-mem-3.c: New. Check int size.
* gcc.dg/sync-mem-4.c: New. Check long long.
* gcc.dg/sync-mem-5.c: New. Check 128 bit.
* gcc.dg/sync-mem-invalid.c: New. Check invalid memory modes.

Index: lib/target-supports.exp
===
*** lib/target-supports.exp (revision 175229)
--- lib/target-supports.exp (working copy)
*** proc check_effective_target_section_anch
*** 3272,3277 
--- 3272,3313 
  return $et_section_anchors_saved
  }
  
+ # Return 1 if the target supports atomic operations on "int_128" values.
+ 
+ proc check_effective_target_sync_int_128 { } {
+ global et_sync_int_128_saved
+ 
+ if [info exists et_sync_int_128_saved] {
+ verbose "check_effective_target_sync_int_128: using cached result" 2
+ } else {
+ set et_sync_int_128_saved 0
+ if { [istarget x86_64-*-*] } {
+set et_sync_int_128_saved 1
+ }
+ }
+ 
+ verbose "check_effective_target_sync_int_128: returning 
$et_sync_int_128_saved" 2
+ return $et_sync_int_128_saved
+ }
+ 
+ # Return 1 if the target supports atomic operations on "long long".
+ 
+ proc check_effective_target_sync_long_long { } {
+ global et_sync_long_long_saved
+ 
+ if [info exists et_sync_long_long_saved] {
+ verbose "check_effective_target_sync_long_long: using cached result" 2
+ } else {
+ set et_sync_long_long_saved 0
+ if { [istarget x86_64-*-*] } {
+set et_sync_long_long_saved 1
+ }
+ }
+ 
+ verbose "check_effective_target_sync_long_long: returning 
$et_sync_long_long_saved" 2
+ return $et_sync_long_long_saved
+ }
+ 
  # Return 1 if the target supports atomic operations on "int" and "long".
  
  proc check_effective_target_sync_int_long { } {
Index: gcc.dg/sync-mem.h
===
*** gcc.dg/sync-mem.h   (revision 0)
--- gcc.dg/sync-mem.h   (revision 0)
***
*** 0 
--- 1,27 
+ /* Define all the __sync verifications here.  Each size variation to be tested
+will define 'TYPE' and then include this file.  */
+ 
+ extern void abort(void);
+ 
+ TYPE v, count;
+ 
+ #define EXCHANGE(VAR, MODE)  if (__sync_mem_exchange (&VAR, count + 1, MODE)  
\
+!=  count++) abort()
+ void test_exchange()
+ {
+   v = 0;
+   count = 0;
+   EXCHANGE (v, __SYNC_MEM_RELAXED);
+   EXCHANGE (v, __SYNC_MEM_ACQUIRE);
+   EXCHANGE (v, __SYNC_MEM_RELEASE);
+   EXCHANGE (v, __SYNC_MEM_ACQ_REL);
+   EXCHANGE (v, __SYNC_MEM_SEQ_CST);
+ }
+ 
+ 
+ 
+ main ()
+ {
+   test_exchange();
+   return 0;
+ }
Index: gcc.dg/sync-mem-1.c
===
*** gcc.dg/sync-mem-1.c (revision 0)
--- gcc.dg/sync-mem-1.c (revision 0)
***
*** 0 
--- 1,8 
+ /* Test __sync_mem routines for existence and proper execution on 1 byte 
+values with each valid memory model.  */
+ /* { dg-do run } */
+ /* { dg-require-effective-target sync_char_short } */
+ 
+ #define TYPE char
+ 
+ #include "sync-mem.h"
Index: gcc.dg/sync-mem-2.c
===
*** gcc.dg/sync-mem-2.c (revision 0)
--- gcc.dg/sync-mem-2.c (revision 0)
***
*** 0 
--- 1,9 
+ /* Test __sync_mem routines for existence and proper execution on 2 byte 
+values with each valid memory model.  */
+ /

Re: [v3] Avoid -Wall warnings in the testsuite

2011-06-22 Thread Paolo Carlini
... actually, there are also bogus "statement has no effect" warnings 
for line 1321 of ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp which also 
seem bogus:


PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
get_begin_pos() const
{
  size_type i = 0;
  for (i; i < arr_size && m_a_p_children[i] == 0; ++i) // here
;
  return i;
}

Paolo.




Re: [v3] Avoid -Wall warnings in the testsuite

2011-06-22 Thread Andrew Pinski
On Wed, Jun 22, 2011 at 3:02 PM, Paolo Carlini  wrote:
> ... actually, there are also bogus "statement has no effect" warnings for
> line 1321 of ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp which also seem
> bogus:
>
>    PB_DS_CLASS_T_DEC
>    typename PB_DS_CLASS_C_DEC::size_type
>    PB_DS_CLASS_C_DEC::
>    get_begin_pos() const
>    {
>      size_type i = 0;
>      for (i; i < arr_size && m_a_p_children[i] == 0; ++i) // here
>    ;

No I think that warning is correct "for (i;" the statement i; has no effect.

Thanks,
Andrew Pinski


Re: [v3] Avoid -Wall warnings in the testsuite

2011-06-22 Thread Paolo Carlini

On 06/23/2011 12:04 AM, Andrew Pinski wrote:

No I think that warning is correct "for (i;" the statement i; has no effect.

Thanks, now I see, let's remove that i.

Paolo.


[pph] Stream scope_chain->bindings instead of global namespace (issue4661045)

2011-06-22 Thread Gabriel Charette
gcc/cp/pph-streamer-in.c:1003: namespace.
 1001   /* FIXME pph: this carried over from pph_add_names_to_namespace,
 1002 »it only makes sense to use this when merging names in an 
existing
 1003 »namespace.

pph_add_names_to_namespace does not exist anymore.  I don't understand this
comment.

What I meant is that pph_add_bindings_to_namespace is just a modified version of
the old pph_add_names_to_namespace in which this recursive call was made (and 
was
already useless before, i.e. commenting it out wouldn't introduce any changes 
in the
test results...).

I changed the comment, adding it to the FIXME just above it which mentions we 
should
check if this namespace already exists (i.e. it only makes sense to add bindings
in the "streamed in" namespace to the actual namespace IF they are NOT the same 
object
(otherwise the bindings are already part of the "streamed in" namespace so this 
call is useless).

##
gcc/cp/pph-streamer-out.c:947: gcc_assert ( ss->old_namespace ==
global_namespace
  945   /* old_namespace should be global_namespace and all entries listed below
  946  should be NULL or 0; otherwise the header parsed was incomplete.  */
  947   gcc_assert ( ss->old_namespace == global_namespace

No space after '('.

FIXED.

##
gcc/cp/pph-streamer-out.c:949: || ss->function_decl || ss->template_parms ||
ss->x_saved_tree
  948   && !(ss->class_name || ss->class_type || ss->access_specifier
  949|| ss->function_decl || ss->template_parms || ss->x_saved_tree

Align '&&' vertically with the open brace.

FIXED.

##
gcc/cp/pph-streamer.c:34: #include "name-lookup.h"
  33 #include "cppbuiltin.h"
+ 34 #include "name-lookup.h"

You also need to add cp/name-lookup.h to the list of dependencies for cp/pph.o
in cp/Make-lang.in.

I simply removed the include, I originally added it because it holds 
global_namespace, but it
compiles without it (which I guess is fine if we don't try to stick to "include 
what you use").

2011-06-22  Gabriel Charette  

* gcc/cp/pph-streamer-in.c (pph_add_names_to_namespace): Replaced by
pph_add_bindings_to_namespace.
(pph_add_bindings_to_namespace): New.
(pph_in_scope_chain): New.
(pph_read_file_contents): Remove unused variable file_ns.
(pph_read_file_contents): Call pph_in_scope_chain.
* gcc/cp/pph-streamer-out.c (pph_out_scope_chain): New.
(pph_write_file_contents): Call pph_out_scope_chain.
* gcc/cp/pph-streamer.c (pph_preload_common_nodes):
Call lto_streamer_cache_append.

diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index e71f744..c16b88d 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -976,15 +976,14 @@ pph_in_lang_type (pph_stream *stream)
 }
 
 
-/* Add all the new names declared in NEW_NS to NS.  */
+/* Add all bindings declared in BL to NS.  */
 
 static void
-pph_add_names_to_namespace (tree ns, tree new_ns)
+pph_add_bindings_to_namespace (struct cp_binding_level *bl, tree ns)
 {
   tree t, chain;
-  struct cp_binding_level *level = NAMESPACE_LEVEL (new_ns);
 
-  for (t = level->names; t; t = chain)
+  for (t = bl->names; t; t = chain)
 {
   /* Pushing a decl into a scope clobbers its DECL_CHAIN.
 Preserve it.  */
@@ -992,18 +991,33 @@ pph_add_names_to_namespace (tree ns, tree new_ns)
   pushdecl_into_namespace (t, ns);
 }
 
-  for (t = level->namespaces; t; t = chain)
+  for (t = bl->namespaces; t; t = chain)
 {
   /* Pushing a decl into a scope clobbers its DECL_CHAIN.
 Preserve it.  */
-  /* FIXME pph: we should first check to see if it isn't already there.  */
+  /* FIXME pph: we should first check to see if it isn't already there.  
+   If it is, we should use this function recursively to merge
+   the bindings in T in the corresponding namespace.  */
   chain = DECL_CHAIN (t);
   pushdecl_into_namespace (t, ns);
-  pph_add_names_to_namespace (t, t);
 }
 }
 
 
+/* Merge scope_chain bindings from the stream into SS. */
+
+static void
+pph_in_scope_chain (pph_stream *stream)
+{
+  struct cp_binding_level *pph_bindings;
+
+  pph_bindings = pph_in_binding_level (stream);
+
+  /* Merge the bindings obtained from STREAM in the global namespace.  */
+  pph_add_bindings_to_namespace (pph_bindings, global_namespace);
+}
+
+
 /* Wrap a macro DEFINITION for printing in an error.  */
 
 static char *
@@ -1128,7 +1142,6 @@ pph_read_file_contents (pph_stream *stream)
   cpp_ident_use *bad_use;
   const char *cur_def;
   cpp_idents_used idents_used;
-  tree file_ns;
 
   pth_load_identifiers (&idents_used, stream);
 
@@ -1141,12 +1154,12 @@ pph_read_file_contents (pph_stream *stream)
   /* Re-instantiate all the pre-processor symbols defined by STREAM.  */
   cpp_lt_replay (parse_in, &idents_used);
 
-  /* Read global_

Re: [pph] Stream scope_chain->bindings instead of global namespace (issue4661045)

2011-06-22 Thread gchare

So it looks like my mail using the upload script didn't make it out...
let me retype it...

On 2011/06/22 20:51:58, Diego Novillo wrote:

http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-in.c
File gcc/cp/pph-streamer-in.c (right):



http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-in.c#newcode1003

gcc/cp/pph-streamer-in.c:1003: namespace.
  1001   /* FIXME pph: this carried over from

pph_add_names_to_namespace,

  1002 »it only makes sense to use this when merging names in

an existing

  1003 »namespace.



pph_add_names_to_namespace does not exist anymore.  I don't understand

this

comment.


What I meant is that pph_add_bindings_to_namespace is essentially just a
modified version
of pph_add_names_to_namespace which used to do this recursive call
(which was useless as it
only makes sense to add the bindings from the "streamed in" namespace if
we found a corresponding
existing namespace, adding the bindings streamed in to itself makes no
sense (as they're already there)... and commenting out that line in the
old code wouldn't change anything in the test results, proving my
point.)

I fixed the comment: removing it and elaborating on the FIXME above it
mentioning that
we need to look if the namespace already exists.



http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-out.c
File gcc/cp/pph-streamer-out.c (right):



http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-out.c#newcode947

gcc/cp/pph-streamer-out.c:947: gcc_assert ( ss->old_namespace ==
global_namespace
   945   /* old_namespace should be global_namespace and all entries

listed below

   946  should be NULL or 0; otherwise the header parsed was

incomplete.  */

   947   gcc_assert ( ss->old_namespace == global_namespace



No space after '('.


FIXED.



http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer-out.c#newcode949

gcc/cp/pph-streamer-out.c:949: || ss->function_decl ||

ss->template_parms ||

ss->x_saved_tree
   948   && !(ss->class_name || ss->class_type ||

ss->access_specifier

   949|| ss->function_decl || ss->template_parms ||

ss->x_saved_tree


Align '&&' vertically with the open brace.


FIXED.



http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer.c
File gcc/cp/pph-streamer.c (right):



http://codereview.appspot.com/4661045/diff/1/gcc/cp/pph-streamer.c#newcode34

gcc/cp/pph-streamer.c:34: #include "name-lookup.h"
   33 #include "cppbuiltin.h"
+ 34 #include "name-lookup.h"



You also need to add cp/name-lookup.h to the list of dependencies for

cp/pph.o

in cp/Make-lang.in.


I removed the include, I originally included it because that's where
global_namespace is defined, but it compiles without it (which I guess
is fine if we don't need to stick to "include what you use").


http://codereview.appspot.com/4661045/


Re: [v3] Avoid -Wall warnings in the testsuite

2011-06-22 Thread Jonathan Wakely
On 22 June 2011 22:48, Paolo Carlini  wrote:
> ... all, besides that corresponding to c++/49508.
>
> Committed to mainline.
>
> Thanks,
> Paolo.
>
> //
>

Oops, this bit is my bad, I'll fix it:

Index: testsuite/20_util/bind/socket.cc
===
--- testsuite/20_util/bind/socket.cc(revision 175315)
+++ testsuite/20_util/bind/socket.cc(working copy)
@@ -35,7 +35,7 @@
 {
   int fd = 1;
   my_sockaddr sa;   // N.B. non-const
-  size_t len = sizeof(sa);  // N.B. size_t not socklen_t
+  size_t len __attribute__((unused)) = sizeof(sa); // N.B. size_t not socklen_t
   return bind(fd, &sa, sizeof(sa));
 }

I meant to use len, so the attribute isn't needed


Re: [v3] Avoid -Wall warnings in the testsuite

2011-06-22 Thread Jonathan Wakely
On 22 June 2011 23:38, Jonathan Wakely  wrote:
> On 22 June 2011 22:48, Paolo Carlini  wrote:
>> ... all, besides that corresponding to c++/49508.
>>
>> Committed to mainline.
>>
>> Thanks,
>> Paolo.
>>
>> //
>>
>
> Oops, this bit is my bad, I'll fix it:
>
> Index: testsuite/20_util/bind/socket.cc
> ===
> --- testsuite/20_util/bind/socket.cc    (revision 175315)
> +++ testsuite/20_util/bind/socket.cc    (working copy)
> @@ -35,7 +35,7 @@
>  {
>   int fd = 1;
>   my_sockaddr sa;           // N.B. non-const
> -  size_t len = sizeof(sa);  // N.B. size_t not socklen_t
> +  size_t len __attribute__((unused)) = sizeof(sa); // N.B. size_t not 
> socklen_t
>   return bind(fd, &sa, sizeof(sa));
>  }
>
> I meant to use len, so the attribute isn't needed


2011-06-22  Jonathan Wakely  

* testsuite/20_util/bind/socket.cc: Use variable and remove attribute.

Tested (this test only) on x86_64-linux and committed to trunk.

Index: testsuite/20_util/bind/socket.cc
===
--- testsuite/20_util/bind/socket.cc(revision 175321)
+++ testsuite/20_util/bind/socket.cc(working copy)
@@ -35,7 +35,7 @@
 {
   int fd = 1;
   my_sockaddr sa;   // N.B. non-const
-  size_t len __attribute__((unused)) = sizeof(sa); // N.B. size_t not socklen_t
-  return bind(fd, &sa, sizeof(sa));
+  size_t len = sizeof(sa);  // N.B. size_t not my_socklen_t
+  return bind(fd, &sa, len);
 }


Re: Rename attribs.c to attributes.c

2011-06-22 Thread Joseph S. Myers
On Wed, 22 Jun 2011, Andrew MacLeod wrote:

> > Hmm, attribs.c to me is a perfect abbreviation to attributes.c, so it isn't
> > unclear (to me) ... there are more confusing file names, like tree-dfa.c
> > or tree-flow*.[ch].
> > 
> I also can't imagine what else attrib.c would be other than attributes...

The *real* issue of ambiguity is that the term "attribute" means more than 
one thing in GCC - in this case it relates to __attribute__, but there are 
insn attributes as well.

There have been suggestions of putting GCC source files in many more 
subdirectories to reflect the logical modules, and if that were done then 
maybe renaming at the same time, so the file becomes tree/attributes.c or 
generic/attributes.c, would make sense - and the choice of directory would 
make clearer what sort of attributes are being referred to.  But creating 
such subdirectories requires a clear overall understanding of what the 
logical divisions of source files are - a design rather than just moving 
one file on its own.  (I've previously discussed what should go in common/ 
and common/config/, driver/ and driver/config/, and it's well-established 
that files built only for the target and associated build support should 
go in the toplevel libgcc/ directory.)

I don't think achieving a rearrangement of the host-side and build-side 
files in gcc/ would be particular hard - the changes would be mostly 
mechanical - but it does require careful thought about what we want the 
modules and their dependencies to be, and there would be plenty of 
followup changes later to try to reduce the undesired dependencies between 
the modules.

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


[pph] Fixed extra space typos in pph-streamer-out.c (issue4663041)

2011-06-22 Thread Gabriel Charette
I've had these two small changes around for a while after making a search and 
replace
for extra spaces in my own added code last week.

Tested with bootstrap and pph regression testing, you never know ;)

2011-06-22  Gabriel Charette  

* gcc/cp/pph-streamer-out.c (pph_out_lang_specific): 
Removed extra space.
(pph_write_tree): Removed extra space.

diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index 32851a4..f219cef 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -714,7 +714,7 @@ pph_out_lang_specific (pph_stream *stream, tree decl, bool 
ref_p)
   ld = DECL_LANG_SPECIFIC (decl);
   if (!pph_out_start_record (stream, ld))
 return;
-
+
   /* Write all the fields in lang_decl_base.  */
   ldb = &ld->u.base;
   pph_out_ld_base (stream, ldb);
@@ -1166,7 +1166,7 @@ pph_write_tree (struct output_block *ob, tree expr, bool 
ref_p)
   TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr), ref_p);
   break;
 
-case TEMPLATE_PARM_INDEX: 
+case TEMPLATE_PARM_INDEX:
   {
 template_parm_index *p = TEMPLATE_PARM_INDEX_CAST (expr);
 pph_out_tree_common (stream, expr, ref_p);

--
This patch is available for review at http://codereview.appspot.com/4663041


PR tree-optimize/49373 (IPA-PTA regression)

2011-06-22 Thread Jan Hubicka
Hi,
this patch moves ipa-pta into new ipa pass queue of simple IPA passes executed
after regular IPA passes. The reason is that IPA-PTA is really implemented as
simple IPA pass (i.e. it looks into function bodies at its propagate stage and
does not support WHOPR mode) and I planned having place for such passes for a
while.  Until now, there has not been a reason however.

The patch fixes regression I introduced by my alias reorg that triggered latent
problem in IPA-PTA not really expecting to see cgraph with redirected edges.
In longer term we want full IPA IPA-PTA, but we are simply not there, yet.
Having place for late small IPA passes is however convenient for other reasons:
we can remove functions whose references are optimized out or we can re-do
some of early optimizations, inlcluding ipa-sra, late that might be interesting
for LTO.

The change needed quite a bit more unentaging of the old code than I would like
and I was not fully succesful on it.  The reason is that until now we
executed the transform stage of IPA passes all just before the first local
pass of late copmilation (i.e. all_passes) is done.

With this patch the ipa-transforms can take place either at beggining of 
all_passes
(when all late IPA passes are disabled) or just before first late IPA pass.

Original motivation for applying the transforms all at the time of late
compilation was the "half-WHOPR" compilation model I developed originally
cgraph for in 2003-2006.  The idea was that IPA passes will have function body
summaries, just like in our curent WHOPR implementation, but I did not intended
to implement the second streamping (WPA->LTRANS). Parallel compilation
was not that much of concern at that time. I simply expected the compiler to
produce final assembly in the same process as running WPA, but preventing a
need to load all function bodies into memory at once.  The late copilation
was expected to load function bodies one by one, optimize them and output to
assembly (modulo preloading of inlined functions).

With WHOPR this is not really so important (while it is theoretically possible
with -flto -flto-partition=none, just not implemented this way: lto.c 
proactively
loads all function bodies at early stages of LTO compilation).

This "half-WHOPR" makes such late optimization passes impossible. WHOPR solves
the problem by restricting late optimization passes to a parttions and thus 
makes
late IPA passes resonable.

Note that the trick reduces memory usage even w/o LTO because program after 
inline
decisions are applied is bigger then before.  Currently we do not apply inline
decisions "unit at a time".  This growth is however more or less bounded, since
inliner should not expand unit more then by inline-unit-growth limit.

For these reasons I don't really want to move applying of ipa transforms into
"unit at a time" by default, until we have compelling reasons to do so (i.e.
by default enabled late ipa pass that pays back for itself).

As a result I have bit of problem with cfg fixup:  cfg fixup is needed after
IPA passes because ipa-pure-const can turn functions to non-throwing pure or
const and those needs compensation at caller side that can't be done by proper
IPA pass.  We also need it at the beggining of all_passes because RTL code and
local-pure-const can do the same (i.e. turn functions to non-EH/pure/const).

Because we run cfg verifiers in between ipa transforms, we now need to run fixup
one extra time: once after inlining and once at beggining of all_passes.

I guess this is passmanager job to bookkeep this, but the passmanager is 
currently
bit too inflexible since all its properties are static.

There are laternatives, like fixing up cfg from the late pure const and RTL EH
code, but they seem just as ugly as one extra pass through the statements.

The patch also arranged cgraph to be valid after ipa transforms in the case some
late IPA pass is run.  This is done by simply rebuilding cgraph edges since we
do not preserve them through inline transform (it does cleanup_cfg and also we 
do
not really maintain ipa references). 

Finally we also now can disable ipa-inline at -O0.

I've bootstrapped/regtested x86_64-linux and verified that it fixed the 
regression.
I've also bootstrapped with ipa-pta enabled by default with c,c++ and fortran.
Libjava copmiles forever with ipa-pta.  There are some units needing about 3 
hours
to complete.

OK?
Honza

PR tree-optimize/49373
* tree-pass.h (all_late_ipa_passes): Declare.
* cgraphunit.c (init_lowered_empty_function): Fix properties.
(cgraph_optimize): Execute late passes; remove unreachable funcions 
after
materialization.
* ipa-inline.c (gate_ipa_inline): Enable only when optimizing or LTOing.
* passes.c (all_late_ipa_passes): Declare.
(dump_passes, register_pass): Handle late ipa passes.
(init_optimization_passes): Move ipa_pta to late passes; schedule 
fixup_cfg
at beggining of all_passes.
 

[pph] Fix binding_level's names_size streaming (issue4634071)

2011-06-22 Thread Gabriel Charette
Here is the patch removing names_size.

We found out it was write-only and that we could remove it.

I tested it with a full bootstrap build as well as a full regression test (make 
check-g++).

(actually one of the pph test fails, but that's because of a line number issue 
in where
we expect the ICE... I'll have to re-upload the patch as the script already 
submitted the files...)

2011-06-22  Gabriel Charette  

* gcc/cp/name-lookup.h (cp_binding_level): Removed unused
member names_size. Update all users.

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 54977ce..297c57e 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -544,7 +544,6 @@ add_decl_to_level (tree decl, cxx_scope *b)
 necessary.  */
   TREE_CHAIN (decl) = b->names;
   b->names = decl;
-  b->names_size++;
 
   /* If appropriate, add decl to separate list of statics.  We
 include extern variables because they might turn out to be
diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
index 009b5d9..5f266eb 100644
--- a/gcc/cp/name-lookup.h
+++ b/gcc/cp/name-lookup.h
@@ -191,9 +191,6 @@ struct GTY(()) cp_binding_level {
are wrapped in TREE_LISTs; the TREE_VALUE is the OVERLOAD.  */
 tree names;
 
-/* Count of elements in names chain.  */
-size_t names_size;
-
 /* A chain of NAMESPACE_DECL nodes.  */
 tree namespaces;
 
diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index 0e8c6bf..a535cab 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -442,7 +442,6 @@ pph_in_binding_level (pph_stream *stream)
   ALLOC_AND_REGISTER (stream, ix, bl, ggc_alloc_cleared_cp_binding_level ());
 
   bl->names = pph_in_chain (stream);
-  bl->names_size = pph_in_uint (stream);
   bl->namespaces = pph_in_chain (stream);
 
   bl->static_decls = pph_in_tree_vec (stream);
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index f219cef..7a6c516 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -448,7 +448,6 @@ pph_out_binding_level (pph_stream *stream, struct 
cp_binding_level *bl,
 return;
 
   pph_out_chain_filtered (stream, bl->names, ref_p, NO_BUILTINS);
-  pph_out_uint (stream, bl->names_size);
   pph_out_chain_filtered (stream, bl->namespaces, ref_p, NO_BUILTINS);
 
   pph_out_tree_vec (stream, bl->static_decls, ref_p);

--
This patch is available for review at http://codereview.appspot.com/4634071


[pph] Fix binding_level's names_size streaming (issue4634071)

2011-06-22 Thread Gabriel Charette
See previous message. This patch only adds the fix to the dg-bogus comment for 
the failing pph test.

2011-06-22  Gabriel Charette  

* gcc/cp/name-lookup.h (cp_binding_level): Removed unused
member names_size. Update all users.

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 54977ce..297c57e 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -544,7 +544,6 @@ add_decl_to_level (tree decl, cxx_scope *b)
 necessary.  */
   TREE_CHAIN (decl) = b->names;
   b->names = decl;
-  b->names_size++;
 
   /* If appropriate, add decl to separate list of statics.  We
 include extern variables because they might turn out to be
diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
index 009b5d9..5f266eb 100644
--- a/gcc/cp/name-lookup.h
+++ b/gcc/cp/name-lookup.h
@@ -191,9 +191,6 @@ struct GTY(()) cp_binding_level {
are wrapped in TREE_LISTs; the TREE_VALUE is the OVERLOAD.  */
 tree names;
 
-/* Count of elements in names chain.  */
-size_t names_size;
-
 /* A chain of NAMESPACE_DECL nodes.  */
 tree namespaces;
 
diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index 0e8c6bf..a535cab 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -442,7 +442,6 @@ pph_in_binding_level (pph_stream *stream)
   ALLOC_AND_REGISTER (stream, ix, bl, ggc_alloc_cleared_cp_binding_level ());
 
   bl->names = pph_in_chain (stream);
-  bl->names_size = pph_in_uint (stream);
   bl->namespaces = pph_in_chain (stream);
 
   bl->static_decls = pph_in_tree_vec (stream);
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index f219cef..7a6c516 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -448,7 +448,6 @@ pph_out_binding_level (pph_stream *stream, struct 
cp_binding_level *bl,
 return;
 
   pph_out_chain_filtered (stream, bl->names, ref_p, NO_BUILTINS);
-  pph_out_uint (stream, bl->names_size);
   pph_out_chain_filtered (stream, bl->namespaces, ref_p, NO_BUILTINS);
 
   pph_out_tree_vec (stream, bl->static_decls, ref_p);
diff --git a/gcc/testsuite/g++.dg/pph/x1template.cc 
b/gcc/testsuite/g++.dg/pph/x1template.cc
index 5b1e980..cecefd7 100644
--- a/gcc/testsuite/g++.dg/pph/x1template.cc
+++ b/gcc/testsuite/g++.dg/pph/x1template.cc
@@ -1,5 +1,5 @@
 // { dg-xfail-if "ICE" { "*-*-*" } { "-fpph-map=pph.map" } }
-// { dg-bogus "x1template.h:18:13: internal compiler error: in resume_scope, 
at cp/name-lookup.c:1569" "" { xfail *-*-* } 0 }
+// { dg-bogus "x1template.h:18:13: internal compiler error: in resume_scope, 
at cp/name-lookup.c:1568" "" { xfail *-*-* } 0 }
 // { dg-prune-output "In file included from " }
 
 #include "x1template.h"

--
This patch is available for review at http://codereview.appspot.com/4634071


Re: [pph] Fix binding_level's names_size streaming (issue4634071)

2011-06-22 Thread Gabriel Charette
And it looks like this wasn't sent to anyone directly...
Adding back dnovillo and crowl (Diego I don't think Jason was ever
added to the original message...?)

Gab

On Wed, Jun 22, 2011 at 5:02 PM, Gabriel Charette  wrote:
>
> See previous message. This patch only adds the fix to the dg-bogus comment 
> for the failing pph test.
>
> 2011-06-22  Gabriel Charette  
>
>        * gcc/cp/name-lookup.h (cp_binding_level): Removed unused
>        member names_size. Update all users.
>
> diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
> index 54977ce..297c57e 100644
> --- a/gcc/cp/name-lookup.c
> +++ b/gcc/cp/name-lookup.c
> @@ -544,7 +544,6 @@ add_decl_to_level (tree decl, cxx_scope *b)
>         necessary.  */
>       TREE_CHAIN (decl) = b->names;
>       b->names = decl;
> -      b->names_size++;
>
>       /* If appropriate, add decl to separate list of statics.  We
>         include extern variables because they might turn out to be
> diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
> index 009b5d9..5f266eb 100644
> --- a/gcc/cp/name-lookup.h
> +++ b/gcc/cp/name-lookup.h
> @@ -191,9 +191,6 @@ struct GTY(()) cp_binding_level {
>        are wrapped in TREE_LISTs; the TREE_VALUE is the OVERLOAD.  */
>     tree names;
>
> -    /* Count of elements in names chain.  */
> -    size_t names_size;
> -
>     /* A chain of NAMESPACE_DECL nodes.  */
>     tree namespaces;
>
> diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
> index 0e8c6bf..a535cab 100644
> --- a/gcc/cp/pph-streamer-in.c
> +++ b/gcc/cp/pph-streamer-in.c
> @@ -442,7 +442,6 @@ pph_in_binding_level (pph_stream *stream)
>   ALLOC_AND_REGISTER (stream, ix, bl, ggc_alloc_cleared_cp_binding_level ());
>
>   bl->names = pph_in_chain (stream);
> -  bl->names_size = pph_in_uint (stream);
>   bl->namespaces = pph_in_chain (stream);
>
>   bl->static_decls = pph_in_tree_vec (stream);
> diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
> index f219cef..7a6c516 100644
> --- a/gcc/cp/pph-streamer-out.c
> +++ b/gcc/cp/pph-streamer-out.c
> @@ -448,7 +448,6 @@ pph_out_binding_level (pph_stream *stream, struct 
> cp_binding_level *bl,
>     return;
>
>   pph_out_chain_filtered (stream, bl->names, ref_p, NO_BUILTINS);
> -  pph_out_uint (stream, bl->names_size);
>   pph_out_chain_filtered (stream, bl->namespaces, ref_p, NO_BUILTINS);
>
>   pph_out_tree_vec (stream, bl->static_decls, ref_p);
> diff --git a/gcc/testsuite/g++.dg/pph/x1template.cc 
> b/gcc/testsuite/g++.dg/pph/x1template.cc
> index 5b1e980..cecefd7 100644
> --- a/gcc/testsuite/g++.dg/pph/x1template.cc
> +++ b/gcc/testsuite/g++.dg/pph/x1template.cc
> @@ -1,5 +1,5 @@
>  // { dg-xfail-if "ICE" { "*-*-*" } { "-fpph-map=pph.map" } }
> -// { dg-bogus "x1template.h:18:13: internal compiler error: in resume_scope, 
> at cp/name-lookup.c:1569" "" { xfail *-*-* } 0 }
> +// { dg-bogus "x1template.h:18:13: internal compiler error: in resume_scope, 
> at cp/name-lookup.c:1568" "" { xfail *-*-* } 0 }
>  // { dg-prune-output "In file included from " }
>
>  #include "x1template.h"
>
> --
> This patch is available for review at http://codereview.appspot.com/4634071


Re: [pph] Fix binding_level's names_size streaming (issue4634071)

2011-06-22 Thread Gabriel Dos Reis
On Wed, Jun 22, 2011 at 7:05 PM, Gabriel Charette  wrote:
> And it looks like this wasn't sent to anyone directly...
> Adding back dnovillo and crowl (Diego I don't think Jason was ever
> added to the original message...?)

should not this go to mainline too?


-- Gaby


fix powerpc bootstrap failure

2011-06-22 Thread Alan Modra
I'm applying this with David's blessing to fix the powerpc bootstrap
failure that's been around for two weeks now.  This is Jan's suggested
fix, tweaked to avoid an overly long line.

PR bootstrap/49383
* config/rs6000/rs6000.c (call_ABI_of_interest): Adjust cgraph
invocation for 2011-06-09 changes.

Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 175327)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -7430,6 +7430,7 @@ call_ABI_of_interest (tree fndecl)
 
   /* Interesting functions that we are emitting in this object file.  */
   c_node = cgraph_get_node (fndecl);
+  c_node = cgraph_function_or_thunk_node (c_node, NULL);
   return !cgraph_only_called_directly_p (c_node);
 }
   return false;

-- 
Alan Modra
Australia Development Lab, IBM


[PATCH] Improve dump files for SRA early candidate check

2011-06-22 Thread Andi Kleen
From: Andi Kleen 

I wanted to figure out why some structures of mine don't get SRAed.
Unfortunately the dump files were not very helpful because the variables
got rejected early without any comments. This patch reports the
actual reasons in the dump file.

Passes test suite on x86-64 linux. Ok to commit?

gcc/:
2011-06-22  Andi Kleen  

* tree-sra.c (type_internals_preclude_sra_p): Add msg
parameter. Split up ifs and report reason in *msg.
(reject): Add.
(find_var_candiate): Add msg variable.
Split up ifs and report reason to reject.
(find_param_candidates): Add msg variable.
Pass msg to type_internals_preclude_sra_p.
---
 gcc/tree-sra.c |  117 +--
 1 files changed, 95 insertions(+), 22 deletions(-)

diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 322abb5..9545f85 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -648,7 +648,7 @@ disqualify_candidate (tree decl, const char *reason)
scalarization.  */
 
 static bool
-type_internals_preclude_sra_p (tree type)
+type_internals_preclude_sra_p (tree type, const char **msg)
 {
   tree fld;
   tree et;
@@ -663,15 +663,39 @@ type_internals_preclude_sra_p (tree type)
  {
tree ft = TREE_TYPE (fld);
 
-   if (TREE_THIS_VOLATILE (fld)
-   || !DECL_FIELD_OFFSET (fld) || !DECL_SIZE (fld)
-   || !host_integerp (DECL_FIELD_OFFSET (fld), 1)
-   || !host_integerp (DECL_SIZE (fld), 1)
-   || (AGGREGATE_TYPE_P (ft)
-   && int_bit_position (fld) % BITS_PER_UNIT != 0))
- return true;
+   if (TREE_THIS_VOLATILE (fld))
+ {
+   *msg = "volatile structure field";
+   return true;
+ }
+   if (!DECL_FIELD_OFFSET (fld))
+ {
+   *msg = "no structure field offset";
+   return true;
+ }
+   if (!DECL_SIZE (fld))
+ {
+   *msg = "zero structure field size";
+   return true;
+ }
+   if (!host_integerp (DECL_FIELD_OFFSET (fld), 1))
+ {
+   *msg = "structure field offset not host integer"; /* ??? */
+   return true;
+ }
+   if (!host_integerp (DECL_SIZE (fld), 1))
+ {
+   *msg = "structure field size not host integer";
+   return true;
+ }   
+   if (AGGREGATE_TYPE_P (ft)
+   && int_bit_position (fld) % BITS_PER_UNIT != 0)
+ {
+   *msg = "structure field is bit field";
+   return true;
+ }
 
-   if (AGGREGATE_TYPE_P (ft) && type_internals_preclude_sra_p (ft))
+   if (AGGREGATE_TYPE_P (ft) && type_internals_preclude_sra_p (ft, 
msg))
  return true;
  }
 
@@ -681,9 +705,12 @@ type_internals_preclude_sra_p (tree type)
   et = TREE_TYPE (type);
 
   if (TYPE_VOLATILE (et))
-   return true;
+   {
+ *msg = "array type is volatile";
+ return true;
+   }
 
-  if (AGGREGATE_TYPE_P (et) && type_internals_preclude_sra_p (et))
+  if (AGGREGATE_TYPE_P (et) && type_internals_preclude_sra_p (et, msg))
return true;
 
   return false;
@@ -1538,6 +1565,19 @@ is_va_list_type (tree type)
   return TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (va_list_type_node);
 }
 
+/* Print message to dump file why a variable was rejected. */
+
+static void
+reject (tree var, const char *msg)
+{
+  if (dump_file && (dump_flags & TDF_DETAILS))
+{
+  fprintf (dump_file, "Rejected (%d): %s: ", DECL_UID (var), msg);
+  print_generic_expr (dump_file, var, 0);
+  fprintf (dump_file, "\n");
+}
+}
+
 /* The very first phase of intraprocedural SRA.  It marks in candidate_bitmap
those with type which is suitable for scalarization.  */
 
@@ -1547,6 +1587,7 @@ find_var_candidates (void)
   tree var, type;
   referenced_var_iterator rvi;
   bool ret = false;
+  const char *msg;
 
   FOR_EACH_REFERENCED_VAR (cfun, var, rvi)
 {
@@ -1554,19 +1595,50 @@ find_var_candidates (void)
 continue;
   type = TREE_TYPE (var);
 
-  if (!AGGREGATE_TYPE_P (type)
- || needs_to_live_in_memory (var)
- || TREE_THIS_VOLATILE (var)
- || !COMPLETE_TYPE_P (type)
- || !host_integerp (TYPE_SIZE (type), 1)
-  || tree_low_cst (TYPE_SIZE (type), 1) == 0
- || type_internals_preclude_sra_p (type)
- /* Fix for PR 41089.  tree-stdarg.c needs to have va_lists intact but
+  if (!AGGREGATE_TYPE_P (type)) 
+{
+  reject (var, "not aggregate");
+  continue;
+   }
+  if (needs_to_live_in_memory (var))
+{
+  reject (var, "needs to live in memory");
+  continue;
+}
+  if (TREE_THIS_VOLATILE (var))
+{
+  reject (var, "is volatile");
+ 

Re: Add __builtin_clrsb, similar to clz/ctz

2011-06-22 Thread H.J. Lu
On Mon, Jun 20, 2011 at 12:38 PM, Bernd Schmidt  wrote:
> On 06/16/2011 06:25 PM, Richard Henderson wrote:
>> On 06/16/2011 05:44 AM, Bernd Schmidt wrote:
>>> +@deftypefn {Built-in Function} int __builtin_clrsb (unsigned int x)
>>> +Returns the number of leading redundant sign bits in @var{x}, starting
>>> +at the most significant bit position.
>>> +@end deftypefn
>>
>> Do we want a signed argument, since we're talking about signs?
>
> Err, yes. It's signed everywhere else (builtins.def etc.).
>
>> It would seem that unlike clz, this function is not undefined for zero.
>> What about INT_MIN?  Do all cpus handle those edge cases the same way?
>
> -1 and zero should both produce the same value, 31 (for a 32 bit
> integer). I don't see why INT_MIN should be special - the return value
> is zero. This is true for C6X and Blackfin; ARM documentation suggests
> it's also true for their VCLS instruction. I've not found proper
> picochip documentation but some other documents that suggest it's also
> implemented this way.
>
>> Do you get smaller code in general from
>>
>>   if (x < 0)
>>     x = ~x;
>>   if (x == 0)
>>     return W_TYPE_SIZE - 1;
>>   count_leading_zeros(ret, x);
>>   return ret - 1;
>
> Probably.
>
>>> -(define_insn "signbitssi2"
>>> +(define_insn "clrsbsi2"
>>>    [(set (match_operand:HI 0 "register_operand" "=d")
>>>      (if_then_else:HI
>>>       (lt (match_operand:SI 1 "register_operand" "d") (const_int 0))
>>
>> No use of the new rtx code?
>
> D'oh. Blackfin has a (clrsb:HI (operand:SI)) instruction, so adding this
> showed a problem with some of the existing simplify_const_unop cases:
> for ffs/clz/ctz/clrsb/parity/popcount, we should look at the mode of the
> operand, rather than the mode of the operation. This limits what we can
> do in that function, since op_mode is sometimes VOIDmode - we really
> should add builtin folders for these at some point.
>
> New patch below. Retested on i686 and bfin.

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49512


-- 
H.J.


Re: [PATCH] Improve dump files for SRA early candidate check

2011-06-22 Thread Eric Botcazou
> + if (!host_integerp (DECL_FIELD_OFFSET (fld), 1))
> +   {
> + *msg = "structure field offset not host integer"; /* ??? */
> + return true;
> +   }

Offsets can be variable, like sizes, in Ada for example.

>if (TYPE_VOLATILE (et))
> - return true;
> + {
> +   *msg = "array type is volatile";
> +   return true;
> + }

"element type is volatile"

> +  if (!COMPLETE_TYPE_P (type))
> +{
> +  reject (var, "is not complete");
> +   continue;
> +}

"has incomplete type" is better I think

> +  if (!host_integerp (TYPE_SIZE (type), 1))
> +{
> +  reject (var, "not host integer");
> +   continue;
> +}

missing "type size"

> +  if (tree_low_cst (TYPE_SIZE (type), 1) == 0)
> +{
> +  reject (var, "tree_low_cst is zero"); /* what is that? */
> +  continue;
> +}

This is equivalent to saying that the type size is zero.

-- 
Eric Botcazou


[google] fix kernel fdo booting issue (issue4627057)

2011-06-22 Thread Rong Xu
This change removes the define of TARGET_VTABLE_USES_DESCRIPTORS in 
kernel fdo which causes kernel panic in indirect-call-profiling.

Tested with 2.6.34 kernel. This change only affects kernel code.

This is for google_main only.

-Rong

2011-06-22   Rong Xu  

* gcc/libgcov.c: (TARGET_VTABLE_USES_DESCRIPTORS): Remove.

Index: gcc/libgcov.c
===
--- gcc/libgcov.c   (revision 175328)
+++ gcc/libgcov.c   (working copy)
@@ -36,7 +36,6 @@
 # define L_gcov_average_profiler
 # define L_gcov_ior_profiler
 
-# define TARGET_VTABLE_USES_DESCRIPTORS 0
 # define HAVE_CC_TLS 0
 # define __GCOV_KERNEL__
 

--
This patch is available for review at http://codereview.appspot.com/4627057


Re: [PATCH 0/4] Docs: extend.texi

2011-06-22 Thread Michael Witten
On Thu, Apr 28, 2011 at 01:20, Michael Witten  wrote:

> See the following emails for a few inlined patches
> to /trunk/gcc/doc/extend.texi (revision 172911):
>
>  [1] Docs: extend.texi: Add missing semicolon for consistency
>  [2] Docs: extend.texi: Remove trailing blanks from lines
>  [3] Docs: extend.texi: Rearrange nodes; no text was removed or added
>  [4] Docs: extend.texi: Reword and rearrange attribute node introductions
>
>  trunk/gcc/doc/extend.texi | 5449 
> +++--
>  1 files changed, 2730 insertions(+), 2719 deletions(-)
>
> CHANGELOG
>
> Essentially, I think it would be easiest to squash all of these patches
> together into one revision; here is a ChangeLog entry for such a revision:
>
> 2011-04-27  Michael Witten 
>
>* gcc/doc/extend.texi: Add a `;', remove trailing whitespace,
>and reorganize nodes to group the discussion of attributes more
>logically.
>
> --
> 1.7.4.18.g68fe8

Please commit these patches, starting here:

 http://gcc.gnu.org/ml/gcc-patches/2011-04/msg02175.html
 Message-ID: <378e16b9-5d40-427c-8b4e-00700b2ad30c-mfwit...@gmail.com

Sincerely,
Michael Witten


Re: [google] fix kernel fdo booting issue (issue4627057)

2011-06-22 Thread शरद सिंघई
Okay for google/main.

Sharad

On Wed, Jun 22, 2011 at 11:22 PM, Rong Xu  wrote:
>
> This change removes the define of TARGET_VTABLE_USES_DESCRIPTORS in
> kernel fdo which causes kernel panic in indirect-call-profiling.
>
> Tested with 2.6.34 kernel. This change only affects kernel code.
>
> This is for google_main only.
>
> -Rong
>
> 2011-06-22   Rong Xu  
>
>        * gcc/libgcov.c: (TARGET_VTABLE_USES_DESCRIPTORS): Remove.
>
> Index: gcc/libgcov.c
> ===
> --- gcc/libgcov.c       (revision 175328)
> +++ gcc/libgcov.c       (working copy)
> @@ -36,7 +36,6 @@
>  # define L_gcov_average_profiler
>  # define L_gcov_ior_profiler
>
> -# define TARGET_VTABLE_USES_DESCRIPTORS 0
>  # define HAVE_CC_TLS 0
>  # define __GCOV_KERNEL__
>
>
> --
> This patch is available for review at http://codereview.appspot.com/4627057