Re: [patch] Support vectorization of widening shifts

2011-10-02 Thread Ira Rosen
On 29 September 2011 17:30, Ramana Radhakrishnan
 wrote:
> On 19 September 2011 08:54, Ira Rosen  wrote:
>
>>
>> Bootstrapped on powerpc64-suse-linux, tested on powerpc64-suse-linux
>> and arm-linux-gnueabi
>> OK for mainline?
>
> Sorry I missed this patch. Is there any reason why we need unspecs in
> this case ? Can't this be represented by subregs and zero/ sign
> extensions in RTL without the UNSPECs ?

Like this:

Index: config/arm/neon.md
===
--- config/arm/neon.md  (revision 178942)
+++ config/arm/neon.md  (working copy)
@@ -5550,6 +5550,46 @@
  }
 )

+(define_insn "neon_vec_shiftl_"
+ [(set (match_operand: 0 "register_operand" "=w")
+   (SE: (match_operand:VW 1 "register_operand" "w")))
+   (match_operand:SI 2 "immediate_operand" "i")]
+  "TARGET_NEON"
+{
+  /* The boundaries are: 0 < imm <= size.  */
+  neon_const_bounds (operands[2], 0, neon_element_bits (mode) + 1);
+  return "vshll. %q0, %P1, %2";
+}
+  [(set_attr "neon_type" "neon_shift_1")]
+)
+
+(define_expand "vec_widen_shiftl_lo_"
+  [(match_operand: 0 "register_operand" "")
+   (SE: (match_operand:VU 1 "register_operand" ""))
+   (match_operand:SI 2 "immediate_operand" "i")]
+ "TARGET_NEON && !BYTES_BIG_ENDIAN"
+ {
+  emit_insn (gen_neon_vec_shiftl_ (operands[0],
+   simplify_gen_subreg (mode, operands[1], mode, 0),
+   operands[2]));
+   DONE;
+ }
+)
+
+(define_expand "vec_widen_shiftl_hi_"
+  [(match_operand: 0 "register_operand" "")
+   (SE: (match_operand:VU 1 "register_operand" ""))
+   (match_operand:SI 2 "immediate_operand" "i")]
+ "TARGET_NEON && !BYTES_BIG_ENDIAN"
+ {
+  emit_insn (gen_neon_vec_shiftl_ (operands[0],
+simplify_gen_subreg (mode, operands[1], mode,
+GET_MODE_SIZE (mode)),
+operands[2]));
+   DONE;
+ }
+)
+
 ;; Vectorize for non-neon-quad case
 (define_insn "neon_unpack_"
  [(set (match_operand: 0 "register_operand" "=w")
@@ -5626,6 +5666,34 @@
  }
 )

+(define_expand "vec_widen_shiftl_hi_"
+ [(match_operand: 0 "register_operand" "")
+   (SE: (match_operand:VDI 1 "register_operand" ""))
+   (match_operand:SI 2 "immediate_operand" "i")]
+ "TARGET_NEON"
+ {
+   rtx tmpreg = gen_reg_rtx (mode);
+   emit_insn (gen_neon_vec_shiftl_ (tmpreg, operands[1],
operands[2]));
+   emit_insn (gen_neon_vget_high (operands[0], tmpreg));
+
+   DONE;
+ }
+)
+
+(define_expand "vec_widen_shiftl_lo_"
+  [(match_operand: 0 "register_operand" "")
+   (SE: (match_operand:VDI 1 "register_operand" ""))
+   (match_operand:SI 2 "immediate_operand" "i")]
+ "TARGET_NEON"
+ {
+   rtx tmpreg = gen_reg_rtx (mode);
+   emit_insn (gen_neon_vec_shiftl_ (tmpreg, operands[1],
operands[2]));
+   emit_insn (gen_neon_vget_low (operands[0], tmpreg));
+
+   DONE;
+ }
+)
+
 ; FIXME: These instruction patterns can't be used safely in big-endian mode
 ; because the ordering of vector elements in Q registers is different from what
 ; the semantics of the instructions require.

?

Thanks,
Ira


>
> cheers
> Ramana
>
>>
>> Thanks,
>> Ira
>>
>> ChangeLog:
>>
>>        * doc/md.texi (vec_widen_ushiftl_hi, vec_widen_ushiftl_lo,
>> vec_widen_sshiftl_hi,
>>        vec_widen_sshiftl_lo): Document.
>>        * tree-pretty-print.c (dump_generic_node): Handle 
>> WIDEN_SHIFT_LEFT_EXPR,
>>        VEC_WIDEN_SHIFT_LEFT_HI_EXPR and VEC_WIDEN_SHIFT_LEFT_LO_EXPR.
>>        (op_code_prio): Likewise.
>>        (op_symbol_code): Handle WIDEN_SHIFT_LEFT_EXPR.
>>        * optabs.c (optab_for_tree_code): Handle
>>        VEC_WIDEN_SHIFT_LEFT_HI_EXPR and VEC_WIDEN_SHIFT_LEFT_LO_EXPR.
>>        (init-optabs): Initialize optab codes for vec_widen_u/sshiftl_hi/lo.
>>        * optabs.h (enum optab_index): Add OTI_vec_widen_u/sshiftl_hi/lo.
>>        * genopinit.c (optabs): Initialize the new optabs.
>>        * expr.c (expand_expr_real_2): Handle
>>        VEC_WIDEN_SHIFT_LEFT_HI_EXPR and VEC_WIDEN_SHIFT_LEFT_LO_EXPR.
>>        * gimple-pretty-print.c (dump_binary_rhs): Likewise.
>>        * tree-vectorizer.h (NUM_PATTERNS): Increase to 6.
>>        * tree.def (WIDEN_SHIFT_LEFT_EXPR, VEC_WIDEN_SHIFT_LEFT_HI_EXPR,
>>        VEC_WIDEN_SHIFT_LEFT_LO_EXPR): New.
>>        * cfgexpand.c (expand_debug_expr):  Handle new tree codes.
>>        * tree-vect-patterns.c (vect_vect_recog_func_ptrs): Add
>>        vect_recog_widen_shift_pattern.
>>        (vect_handle_widen_mult_by_const): Rename...
>>        (vect_handle_widen_op_by_const): ...to this.  Handle shifts.
>>        Add a new argument, update documentation.
>>        (vect_recog_widen_mult_pattern): Assume that only second
>>        operand can be constant.  Update call to
>>        vect_handle_widen_op_by_const.
>>        (vect_operation_fits_smaller_type): Add the already existing
>>        def stmt to the list of pattern statements.
>>        (vect_recog_widen_shift_pattern): New.
>>        * tree-vect-stmts.c (vectorizable_type_promotion): Handle
>>        widening shifts.
>>   

Re: Disable early inlining while compiling for coverage (issue5173042)

2011-10-02 Thread Jan Hubicka
> 
> Early inline can be important for FDO performance reasons -- as inline
> instances get 'context' sensitive profile data.

Yep, early inlining combine well with FDO.
> >  Inlining alone does not mess up the line info, but most
> > optimizations we have in early optimization queue do.
> 
> Inlining can do some damage too but to a less extent. For instance,
> the exit block of the callee instance merged with caller's bb causing
> confusion.

This is still the cfgcleanup run after inlining, right?
But anyway, doing coverage instrumentation before inlining (just after going to 
SSA)
seems fine to me.

We used to have cfgcleanup mode that is safe WRT line number info, not sure if 
it still
in there.
> 
> >
> > We discussed it back when Richi implemented SSA profiling but we didn't do 
> > that
> > basically due to lack of testcases.  Would be possible to take one you have
> > and fill in some PRs? Those are regressions WRT pre-SSA profiling releases 
> > (I think 4.5?)
> 
> Yes.
> 
> Sharad, I did not see the test case attached? Please file a bug about
> this. In the meantime, you can checkin the workaround to google
> banches.

I believe Richi opent PR back when he introduced the SSA profiling, but I don;t 
seem
to be able to find it now.

Honza


Re: Disable early inlining while compiling for coverage (issue5173042)

2011-10-02 Thread Jan Hubicka
> 
> I believe Richi opent PR back when he introduced the SSA profiling, but I 
> don;t seem
> to be able to find it now.
Ha, you found it. It is PR gcov-profile/45890.

Given outcome of this dicussion I think it would make most sense to make 
coverage just after into-SSA
(and perhaps arrange cfgcleanups run before to be sensitive WRT line number 
infos).
Path is welcome, otherwise I will try to put this on my TODO for 4.7

Thanks!
Honza
> 
> Honza


Re: PR preprocessor/36819

2011-10-02 Thread Joseph S. Myers
On Sun, 2 Oct 2011, Paolo Carlini wrote:

> Hi,
> 
> this minor issue remained open and miscategorized as C++ for many years. I
> changed it tentatively to preprocessor and I think we can easily resolve it as
> suggested by submitter: apparently there is a small memory leak happening at
> beginning of incpath.c:split_quote_chain, and the below seems the obvious way
> to plug it. Is it Ok for mainline?

OK.

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


gcc-patches@gcc.gnu.org

2011-10-02 Thread Jason Merrill

On 10/01/2011 08:05 PM, Gabriel Dos Reis wrote:

It is weird though that GCC does not maintain a properly typed
internal representation.


Huh?  Different typedefs need to be compared with same_type_p rather 
than ==.  I don't see how that makes the representation not properly typed.


Jason



Fix recomputation of inline summaries

2011-10-02 Thread Jan Hubicka
Hi,
the inline analysis is called several times and thus it is needed to rest
all the data instead of cumulating them.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

Index: ChangeLog
===
--- ChangeLog   (revision 179426)
+++ ChangeLog   (working copy)
@@ -1,3 +1,12 @@
+2011-10-02  Jan Hubicka  
+
+   * ipa-inline-analysis.c (reset_inline_edge_summary): New function.
+   (reset_inline_summary): New function.
+   (compute_inline_parameters, inline_node_removal_hook,
+   inline_edge_removal_hook): Use it.
+   (inline_free_summary): Reset holders correctly.
+   (inline_generate_summary): Free summary before computing it.
+
 2011-10-02  Paolo Carlini  
 
PR preprocessor/36819
Index: ipa-inline-analysis.c
===
--- ipa-inline-analysis.c   (revision 179423)
+++ ipa-inline-analysis.c   (working copy)
@@ -789,6 +789,44 @@ inline_summary_alloc (void)
 10);
 }
 
+/* We are called multiple time for given function; clear
+   data from previous run so they are not cumulated.  */
+
+static void
+reset_inline_edge_summary (struct cgraph_edge *e)
+{
+  struct inline_edge_summary *es = inline_edge_summary (e);
+
+  es->call_stmt_size = es->call_stmt_time =0;
+  if (es->predicate)
+pool_free (edge_predicate_pool, es->predicate);
+  es->predicate = NULL;
+  VEC_free (inline_param_summary_t, heap, es->param);
+}
+
+/* We are called multiple time for given function; clear
+   data from previous run so they are not cumulated.  */
+
+static void
+reset_inline_summary (struct cgraph_node *node)
+{
+  struct inline_summary *info = inline_summary (node);
+  struct cgraph_edge *e;
+
+  info->self_size = info->self_time = 0;
+  info->estimated_stack_size = 0;
+  info->estimated_self_stack_size = 0;
+  info->stack_frame_offset = 0;
+  info->size = 0;
+  info->time = 0;
+  VEC_free (condition, gc, info->conds);
+  VEC_free (size_time_entry,gc, info->entry);
+  for (e = node->callees; e; e = e->next_callee)
+reset_inline_edge_summary (e);
+  for (e = node->indirect_calls; e; e = e->next_callee)
+reset_inline_edge_summary (e);
+}
+
 /* Hook that is called by cgraph.c when a node is removed.  */
 
 static void
@@ -799,11 +837,7 @@ inline_node_removal_hook (struct cgraph_
   <= (unsigned)node->uid)
 return;
   info = inline_summary (node);
-  reset_node_growth_cache (node);
-  VEC_free (condition, gc, info->conds);
-  VEC_free (size_time_entry, gc, info->entry);
-  info->conds = NULL;
-  info->entry = NULL;
+  reset_inline_summary (node);
   memset (info, 0, sizeof (inline_summary_t));
 }
 
@@ -1012,13 +1046,7 @@ inline_edge_removal_hook (struct cgraph_
 reset_edge_growth_cache (edge);
   if (edge->uid
   < (int)VEC_length (inline_edge_summary_t, inline_edge_summary_vec))
-{
-  edge_set_predicate (edge, NULL);
-  VEC_free (inline_param_summary_t, heap,
-   inline_edge_summary (edge)->param);
-  memset (inline_edge_summary (edge), 0,
- sizeof (struct inline_edge_summary));
-}
+reset_inline_edge_summary (edge);
 }
 
 
@@ -2041,6 +2069,7 @@ compute_inline_parameters (struct cgraph
   inline_summary_alloc ();
 
   info = inline_summary (node);
+  reset_inline_summary (node);
 
   /* FIXME: Thunks are inlinable, but tree-inline don't know how to do that.
  Once this happen, we will need to more curefully predict call
@@ -2827,6 +2856,7 @@ inline_generate_summary (void)
   cgraph_add_function_insertion_hook (&add_new_function, NULL);
 
   ipa_register_cgraph_hooks ();
+  inline_free_summary ();
 
   FOR_EACH_DEFINED_FUNCTION (node)
 if (!node->alias)
@@ -3109,19 +3139,24 @@ inline_write_summary (cgraph_node_set se
 void
 inline_free_summary (void)
 {
+  struct cgraph_node *node;
+  FOR_EACH_DEFINED_FUNCTION (node)
+reset_inline_summary (node);
   if (function_insertion_hook_holder)
 cgraph_remove_function_insertion_hook (function_insertion_hook_holder);
   function_insertion_hook_holder = NULL;
   if (node_removal_hook_holder)
 cgraph_remove_node_removal_hook (node_removal_hook_holder);
+  node_removal_hook_holder = NULL;
   if (edge_removal_hook_holder)
 cgraph_remove_edge_removal_hook (edge_removal_hook_holder);
-  node_removal_hook_holder = NULL;
+  edge_removal_hook_holder = NULL;
   if (node_duplication_hook_holder)
 cgraph_remove_node_duplication_hook (node_duplication_hook_holder);
+  node_duplication_hook_holder = NULL;
   if (edge_duplication_hook_holder)
 cgraph_remove_edge_duplication_hook (edge_duplication_hook_holder);
-  node_duplication_hook_holder = NULL;
+  edge_duplication_hook_holder = NULL;
   VEC_free (inline_summary_t, gc, inline_summary_vec);
   inline_summary_vec = NULL;
   VEC_free (inline_edge_summary_t, heap, inline_edge_summary_vec);


Avoid optimized out references to appear in lto symbol table

2011-10-02 Thread Jan Hubicka
Hi,
GNU LD has bug about reporting references to hidden symbol sthat has been 
optimized out.
This however made me notice that we do output into LTO symbol tables things 
that do
not belong there. In partiuclar we often output extern inline functions that 
has been
fully inlined by early opts.
This patch solves the problem by running cgraph unreachable function rmeoval 
before
IPA (currently it is done only before early opts, not after).
There is also hunk in ipa.c that hsould have been removed afte ipa-ref has been 
introduced
and finally we keep around virtual functions for possible type based 
devirutalization. These
are also not real references in the ymbol table sense.

Bootstrapped/regtested x86_64-linux, tested on Mozilla build and comitted.

Honza

* cgraphunit.c (ipa_passes): Remove unrechable nodes.
* lto-streamer-out.c (produce_symtab): Skip unused extern declarations.
* ipa.c (cgraph_remove_unreachable_nodes): Do not assume that external
functions are reachable when address is taken.
* ipa-inline-analysis.c (reset_inline_edge_summary): New

* gcc.dg/ipa/ctor-empty-1.c: Update dump file.
Index: cgraphunit.c
===
*** cgraphunit.c(revision 179423)
--- cgraphunit.c(working copy)
*** ipa_passes (void)
*** 2011,2016 
--- 2011,2022 
return;
  }
  
+   /* We never run removal of unreachable nodes after early passes.  This is
+  because TODO is run before the subpasses.  It is important to remove
+  the unreachable functions to save works at IPA level and to get LTO
+  symbol tables right.  */
+   cgraph_remove_unreachable_nodes (true, cgraph_dump_file);
+ 
/* If pass_all_early_optimizations was not scheduled, the state of
   the cgraph will not be properly updated.  Update it now.  */
if (cgraph_state < CGRAPH_STATE_IPA_SSA)
Index: testsuite/gcc.dg/ipa/ctor-empty-1.c
===
*** testsuite/gcc.dg/ipa/ctor-empty-1.c (revision 179423)
--- testsuite/gcc.dg/ipa/ctor-empty-1.c (working copy)
***
*** 1,8 
  /* { dg-do compile } */
! /* { dg-options "-O3 -c -fdump-ipa-whole-program"  } */
  static __attribute__((constructor))
  void empty_constructor()
  {
  }
! /* { dg-final { scan-ipa-dump "Reclaiming functions: empty_constructor"  
"whole-program"  } } */
! /* { dg-final { cleanup-ipa-dump "whole-program" } } */
--- 1,8 
  /* { dg-do compile } */
! /* { dg-options "-O3 -c -fdump-ipa-cgraph"  } */
  static __attribute__((constructor))
  void empty_constructor()
  {
  }
! /* { dg-final { scan-ipa-dump "Reclaiming functions: empty_constructor"  
"cgraph"  } } */
! /* { dg-final { cleanup-ipa-dump "cgraph" } } */
Index: lto-streamer-out.c
===
*** lto-streamer-out.c  (revision 179423)
--- lto-streamer-out.c  (working copy)
*** produce_symtab (struct output_block *ob,
*** 1407,1412 
--- 1407,1421 
node = lto_cgraph_encoder_deref (encoder, i);
if (!DECL_EXTERNAL (node->decl))
continue;
+   /* We keep around unused extern inlines in order to be able to inline
+them indirectly or via vtables.  Do not output them to symbol
+table: they end up being undefined and just consume space.  */
+   if (!node->address_taken && !node->callers)
+   {
+ gcc_assert (node->analyzed);
+ gcc_assert (DECL_DECLARED_INLINE_P (node->decl));
+ continue;
+   }
if (DECL_COMDAT (node->decl)
  && cgraph_comdat_can_be_unshared_p (node))
continue;
Index: ipa.c
===
*** ipa.c   (revision 179424)
--- ipa.c   (working copy)
*** cgraph_remove_unreachable_nodes (bool be
*** 196,207 
/* Keep around virtual functions for possible devirtualization.  */
|| (before_inlining_p
&& DECL_VIRTUAL_P (node->decl)
!   && (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl)))
!   /* Also external functions with address taken are better to stay
!  for indirect inlining.  */
!   || (before_inlining_p
!   && DECL_EXTERNAL (node->decl)
!   && node->address_taken)))
{
  gcc_assert (!node->global.inlined_to);
enqueue_cgraph_node (node, &first);
--- 196,202 
/* Keep around virtual functions for possible devirtualization.  */
|| (before_inlining_p
&& DECL_VIRTUAL_P (node->decl)
!   && (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl)
{
  gcc_assert (!node->global.inlined_to);
enqueue_cgraph_node (node, &first);
Index: tree-sra.c
===
*** tree-sra.c  (revision 17942

Re: Avoid optimized out references to appear in lto symbol table

2011-10-02 Thread Steven Bosscher
On Sun, Oct 2, 2011 at 4:33 PM, Jan Hubicka  wrote:
>        * cgraphunit.c (ipa_passes): Remove unrechable nodes.
>        * lto-streamer-out.c (produce_symtab): Skip unused extern declarations.
>        * ipa.c (cgraph_remove_unreachable_nodes): Do not assume that external
>        functions are reachable when address is taken.
>        * ipa-inline-analysis.c (reset_inline_edge_summary): New
>
>        * gcc.dg/ipa/ctor-empty-1.c: Update dump file.

> Index: tree-sra.c
> ===
> *** tree-sra.c  (revision 179423)
> --- tree-sra.c  (working copy)
> *** modify_function (struct cgraph_node *nod
> *** 4622,4627 
> --- 4622,4628 
>    VEC (cgraph_edge_p, heap) * redirect_callers = collect_callers_of_node 
> (node);
>
>    rebuild_cgraph_edges ();
> +   free_dominance_info (CDI_DOMINATORS);
>    pop_cfun ();
>    current_function_decl = NULL_TREE;


Extra change to tree-sra, not in ChangeLog. Is this hunk needed? Or
unrelated fix for something else?

Ciao!
Steven


Re: Avoid optimized out references to appear in lto symbol table

2011-10-02 Thread Jan Hubicka
> > Index: tree-sra.c
> > ===
> > *** tree-sra.c  (revision 179423)
> > --- tree-sra.c  (working copy)
> > *** modify_function (struct cgraph_node *nod
> > *** 4622,4627 
> > --- 4622,4628 
> >    VEC (cgraph_edge_p, heap) * redirect_callers = collect_callers_of_node 
> > (node);
> >
> >    rebuild_cgraph_edges ();
> > +   free_dominance_info (CDI_DOMINATORS);
> >    pop_cfun ();
> >    current_function_decl = NULL_TREE;
> 
> 
> Extra change to tree-sra, not in ChangeLog. Is this hunk needed? Or
> unrelated fix for something else?

It is needed - cgraph_remove_function sanity check that dminance info is clear 
and it is leaking here.
In the version I comitted there is changelog entry, so this must've been 
next-to-last diff. Sorry
for confussion.

Honza

> 
> Ciao!
> Steven


Re: [PATCH] Fix stack red zone bug (PR38644)

2011-10-02 Thread Steven Bosscher
On Wed, Sep 28, 2011 at 11:10 AM, Jiangning Liu  wrote:
> 4) There are over 300 TARGET HOOKS being defined in target.def. I don't
> think adding this interface is hurting GCC.

The reason why there are so many, is because everyone thinks what you
state here ;-)

Ciao!
Steven


gcc-patches@gcc.gnu.org

2011-10-02 Thread Gabriel Dos Reis
On Sun, Oct 2, 2011 at 7:37 AM, Jason Merrill  wrote:
> On 10/01/2011 08:05 PM, Gabriel Dos Reis wrote:
>>
>> It is weird though that GCC does not maintain a properly typed
>> internal representation.
>
> Huh?  Different typedefs need to be compared with same_type_p rather than
> ==.  I don't see how that makes the representation not properly typed.
>

The comment wasn't about comparison of typedefs -- the patch did not compare
typedefs.

*Value* representations should not change just because a type name was
introduced
via a typedef.  In particular, in my opinion comparing for "true" or
"false" should just be
an equality test to boolean_true_node or boolean_false_nore, not a
comparison of their
 integer representation.

-- Gaby


Re: [Patch, fortran] [06/21] Remove coarray support in the scalarizer: Request coarray for an actual arg associed with a coarray dummy

2011-10-02 Thread Tobias Burnus

On 16.09.2011 01:08, Mikael Morin wrote:

How are cobounds passed to a coarray dummy?


For explicit shape, assumed-size and assumed shape coarrays: The value 
is not passed but is set for the dummy argument. While that's not 
surprising for explicit shape/assumed shape arrays, e.g.

  integer :: A(5,7,n)[1:4, 4:*]
  integer :: B(2:*)[*]
it might be slightly surprising for assumed-shape coarrays. However, 
also for normal assumed-shape arrays, only the rank and not the lower 
bound is preserved (default lbound value: 1). For coarrays, also the 
upper bound needs to be given:

  integer :: B(1:, 5:)[4,*]
Note: In all those cases, the corank can differ between actual and dummy 
argument.


The only case where the the cobounds are passed are deferred-shape 
coarrays, i.e. allocatable ones, e.g.

  integer, allocatable :: A(:)[:,:]
here, the corank needs to agree and the lower/upper bounds are kept.

For deferred-shape coarrays, the array descriptor contains behind the 
array dimension triplets, additional triplets for the cobounds.


Except for the small difference for deferred-shape coarrays, with 
-fcoarray=single the normal data as with noncoarrays is transferred. For 
-fcoarray=lib one transfers in all cases additional information: A token 
identifying the coarray and the offset between the first coarray memory 
location and the one one passes (e.g., for a coarray "A(5)[*]", the 
element A(3) is also a coarray and the offset would be the one between 
A(1) and A(3)). For deferred-shape coarrays, the token is part of the 
array descriptor and no offset exists. For all other cases, there is a 
hidden additional argument for offset and token. See CoarrayLib in the 
wiki for details.



However, what comes up from testing is that neither is needed.
I'm not submiting this patch for approval, I'm submitting it to understand why
it is not necessary.


I do not immediately see whether it is needed or not. However, as this 
is about the scalarizer: You cannot pass an allocatable array (coarray) 
to an (impure) elemental function which has a scalar *allocatable* dummy 
argument.* You can only do so if the dummy argument is not allocatable. 
However, in that case the cobounds are not taken from the actual 
argument but are constructed in the called procedure.


(* Separately allocating an single argument does not make sense. I have 
not checked the standard, but I don't think it can be valid.)


Does this answer the question?

Tobias


gcc-patches@gcc.gnu.org

2011-10-02 Thread Jason Merrill

On 10/02/2011 12:10 PM, Gabriel Dos Reis wrote:

The comment wasn't about comparison of typedefs -- the patch did not compare
typedefs.



*Value* representations should not change just because a type name was
introduced via a typedef.


Values (and expressions in general) have types.  If the types aren't ==, 
then neither are two equal values with those types.  Are you suggesting 
we strip typedefs for constant values?


Jason


gcc-patches@gcc.gnu.org

2011-10-02 Thread Gabriel Dos Reis
On Sun, Oct 2, 2011 at 11:51 AM, Jason Merrill  wrote:
> On 10/02/2011 12:10 PM, Gabriel Dos Reis wrote:
>>
>> The comment wasn't about comparison of typedefs -- the patch did not
>> compare
>> typedefs.
>
>> *Value* representations should not change just because a type name was
>> introduced via a typedef.
>
> Values (and expressions in general) have types.

Yes, values have types.  A value has exactly one type, not two, or three, etc,
typedef notwithstanding.  So a value representation should be unique too.

> If the types aren't ==,  then neither are two equal values with those types.

Hmm, I do not think that follows.  A value is unique.  We do not have
zillion boolean
values "true".  We only have one.  So, when we reduce a well-formed
 boolean expression to a value, it should be either the boolean "true" or the
"boolean "false".  In my opinion, we should not be looking at the
integer representation,
we should just compare it (with ==) against one of the  canonical boolean nodes.

> Are you suggesting we strip typedefs for constant values?

I guess it amounts to that, yes.  For a given type, we should have only one
node for a given value, without having to compare representations.

-- Gaby


[CRIS] Hookize OUTPUT_ADDR_CONST_EXTRA

2011-10-02 Thread Anatoly Sokolov
  Hi.

  This patch removes obsolete OUTPUT_ADDR_CONST_EXTRA macro from the CRIS 
back end in the GCC and introduces equivalent TARGET_OUTPUT_ADDR_CONST_EXTRA 
target hook.

  Regression tested on cris-axis-elf.

  OK to install?

* config/cris/m32c.c (cris_output_addr_const_extra): Make static.
(TARGET_OUTPUT_ADDR_CONST_EXTRA): Define.
* config/cris/cris.h (OUTPUT_ADDR_CONST_EXTRA): Remove.
* config/cris/cris-protos.h (cris_output_addr_const_extra): Remove.


Index: gcc/config/cris/cris.c
===
--- gcc/config/cris/cris.c  (revision 179412)
+++ gcc/config/cris/cris.c  (working copy)
@@ -113,6 +113,8 @@
 
 static bool cris_print_operand_punct_valid_p (unsigned char code);
 
+static bool cris_output_addr_const_extra (FILE *, rtx);
+
 static void cris_conditional_register_usage (void);
 
 static void cris_asm_output_mi_thunk
@@ -179,6 +181,8 @@
 #define TARGET_PRINT_OPERAND_ADDRESS cris_print_operand_address
 #undef TARGET_PRINT_OPERAND_PUNCT_VALID_P
 #define TARGET_PRINT_OPERAND_PUNCT_VALID_P cris_print_operand_punct_valid_p
+#undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
+#define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA cris_output_addr_const_extra
 
 #undef TARGET_CONDITIONAL_REGISTER_USAGE
 #define TARGET_CONDITIONAL_REGISTER_USAGE cris_conditional_register_usage
@@ -3608,9 +3614,9 @@
 assemble_name (file, buf);
 }
 
-/* Worker function for OUTPUT_ADDR_CONST_EXTRA.  */
+/* Worker function for TARGET_OUTPUT_ADDR_CONST_EXTRA.  */
 
-bool
+static bool
 cris_output_addr_const_extra (FILE *file, rtx xconst)
 {
   switch (GET_CODE (xconst))
Index: gcc/config/cris/cris.h
===
--- gcc/config/cris/cris.h  (revision 179412)
+++ gcc/config/cris/cris.h  (working copy)
@@ -1097,9 +1097,6 @@
 
 /* Node: Data Output */
 
-#define OUTPUT_ADDR_CONST_EXTRA(STREAM, X, FAIL) \
-  do { if (!cris_output_addr_const_extra (STREAM, X)) goto FAIL; } while (0)
-
 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) (C) == '@'
 
 /* Node: Uninitialized Data */
Index: gcc/config/cris/cris-protos.h
===
--- gcc/config/cris/cris-protos.h   (revision 179412)
+++ gcc/config/cris/cris-protos.h   (working copy)
@@ -38,7 +38,6 @@
 extern bool cris_store_multiple_op_p (rtx);
 extern bool cris_movem_load_rest_p (rtx, int);
 extern void cris_asm_output_symbol_ref (FILE *, rtx);
-extern bool cris_output_addr_const_extra (FILE *, rtx);
 extern int cris_cfun_uses_pic_table (void);
 extern void cris_asm_output_case_end (FILE *, int, rtx);
 extern rtx cris_gen_movem_load (rtx, rtx, int);


Anatoly.



[committed, MIPS] Fix PR 49696

2011-10-02 Thread Richard Sandiford
PR 49969 showed a mismatch between the short sync expanders and their
associated insns: the former allowed zero operands but the predicates
in the latter didn't.

Tested on mips64-linux-gnu and applied.

Richard


gcc/
PR target/49696
* config/mips/sync.md (sync__12): Allow zero operands.
(sync_old__12, sync_new__12, sync_nand_12): Likewise.
(sync_old_nand_12, sync_new_nand_12, test_and_set_12): Likewise.

gcc/testsuite/
* gcc.dg/pr49696.c: New test.

Index: gcc/config/mips/sync.md
===
--- gcc/config/mips/sync.md 2011-10-02 18:40:01.0 +0100
+++ gcc/config/mips/sync.md 2011-10-02 18:42:25.0 +0100
@@ -136,7 +136,7 @@ (define_insn "sync__12"
   [(match_operand:SI 1 "register_operand" "d")
   (match_operand:SI 2 "register_operand" "d")
   (atomic_hiqi_op:SI (match_dup 0)
- (match_operand:SI 3 "register_operand" "dJ"))]
+ (match_operand:SI 3 "reg_or_0_operand" "dJ"))]
  UNSPEC_SYNC_OLD_OP_12))
(clobber (match_scratch:SI 4 "=&d"))]
   "GENERATE_LL_SC"
@@ -177,7 +177,7 @@ (define_insn "sync_old__12"
   [(match_operand:SI 2 "register_operand" "d")
   (match_operand:SI 3 "register_operand" "d")
   (atomic_hiqi_op:SI (match_dup 0)
- (match_operand:SI 4 "register_operand" "dJ"))]
+ (match_operand:SI 4 "reg_or_0_operand" "dJ"))]
  UNSPEC_SYNC_OLD_OP_12))
(clobber (match_scratch:SI 5 "=&d"))]
   "GENERATE_LL_SC"
@@ -218,7 +218,7 @@ (define_insn "sync_new__12"
   (match_operand:SI 2 "register_operand" "d")
   (match_operand:SI 3 "register_operand" "d")
   (atomic_hiqi_op:SI (match_dup 0)
- (match_operand:SI 4 "register_operand" "dJ"))]
+ (match_operand:SI 4 "reg_or_0_operand" "dJ"))]
  UNSPEC_SYNC_NEW_OP_12))
(set (match_dup 1)
(unspec_volatile:SI
@@ -259,7 +259,7 @@ (define_insn "sync_nand_12"
   [(match_operand:SI 1 "register_operand" "d")
   (match_operand:SI 2 "register_operand" "d")
   (match_dup 0)
-  (match_operand:SI 3 "register_operand" "dJ")]
+  (match_operand:SI 3 "reg_or_0_operand" "dJ")]
  UNSPEC_SYNC_OLD_OP_12))
(clobber (match_scratch:SI 4 "=&d"))]
   "GENERATE_LL_SC"
@@ -298,7 +298,7 @@ (define_insn "sync_old_nand_12"
(unspec_volatile:SI
   [(match_operand:SI 2 "register_operand" "d")
   (match_operand:SI 3 "register_operand" "d")
-  (match_operand:SI 4 "register_operand" "dJ")]
+  (match_operand:SI 4 "reg_or_0_operand" "dJ")]
  UNSPEC_SYNC_OLD_OP_12))
(clobber (match_scratch:SI 5 "=&d"))]
   "GENERATE_LL_SC"
@@ -337,7 +337,7 @@ (define_insn "sync_new_nand_12"
   [(match_operand:SI 1 "memory_operand" "+R")
   (match_operand:SI 2 "register_operand" "d")
   (match_operand:SI 3 "register_operand" "d")
-  (match_operand:SI 4 "register_operand" "dJ")]
+  (match_operand:SI 4 "reg_or_0_operand" "dJ")]
  UNSPEC_SYNC_NEW_OP_12))
(set (match_dup 1)
(unspec_volatile:SI
@@ -546,7 +546,7 @@ (define_insn "test_and_set_12"
(set (match_dup 1)
(unspec_volatile:SI [(match_operand:SI 2 "register_operand" "d")
 (match_operand:SI 3 "register_operand" "d")
-(match_operand:SI 4 "arith_operand" "dJ")]
+(match_operand:SI 4 "reg_or_0_operand" "dJ")]
  UNSPEC_SYNC_EXCHANGE_12))]
   "GENERATE_LL_SC"
   { return mips_output_sync_loop (insn, operands); }
Index: gcc/testsuite/gcc.dg/pr49696.c
===
--- /dev/null   2011-10-02 10:31:49.966695399 +0100
+++ gcc/testsuite/gcc.dg/pr49696.c  2011-10-02 18:42:25.0 +0100
@@ -0,0 +1,29 @@
+/* { dg-require-effective-target sync_char_short } */
+
+/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" 
"" { target *-*-* } 0 } */
+
+void
+foo (short *x)
+{
+  __sync_val_compare_and_swap (x, 1, 0);
+  __sync_bool_compare_and_swap (x, 1, 0);
+  __sync_lock_test_and_set (x, 0);
+
+  __sync_fetch_and_add (x, 0);
+  __sync_fetch_and_add (x, 0);
+  __sync_fetch_and_add (x, 0);
+  __sync_fetch_and_sub (x, 0);
+  __sync_fetch_and_and (x, 0);
+  __sync_fetch_and_or (x, 0);
+  __sync_fetch_and_xor (x, 0);
+  __sync_fetch_and_nand (x, 0);
+
+  __sync_add_and_fetch (x, 0);
+  __sync_add_and_fetch (x, 0);
+  __sync_add_and_fetch (x, 0);
+  __sync_sub_and_fetch (x, 0);
+  __sync_and_and_fetch (x, 0);
+  __sync_or_and_fetch (x, 0);
+  __sync_xor_and_fetch (x, 0);
+  __sync_nand_and_fetch (x, 0);
+}


[committed, MIPS] Emit stack barriers

2011-10-02 Thread Richard Sandiford
As discussed recently, this patch adds the stack barriers that are
missing from MIPS' prologue and epilogue patterns.  The attached
testcase failed before but passes afterwards.

Tested on mips64-linux-gnu and applied.  Thanks to Jiangning
for highlighting the problem.

Richard


gcc/
* config/mips/mips.c (mips_frame_barrier): New function.
(mips_expand_prologue): Call it after allocating stack space.
(mips_deallocate_stack): New function.
(mips_expand_epilogue): Call mips_frame_barrier and
mips_deallocate_stack.

gcc/testsuite/
* gcc.target/mips/stack-1.c: New test.

Index: gcc/config/mips/mips.c
===
--- gcc/config/mips/mips.c  2011-10-01 10:59:15.0 +0100
+++ gcc/config/mips/mips.c  2011-10-02 10:50:15.0 +0100
@@ -9892,6 +9892,14 @@ mips_output_function_epilogue (FILE *fil
   mips_end_function_definition (fnname);
 }
 
+/* Emit an optimisation barrier for accesses to the current frame.  */
+
+static void
+mips_frame_barrier (void)
+{
+  emit_clobber (gen_frame_mem (BLKmode, stack_pointer_rtx));
+}
+
 /* Save register REG to MEM.  Make the instruction frame-related.  */
 
 static void
@@ -10035,6 +10043,7 @@ mips_expand_prologue (void)
  insn = mips16e_build_save_restore (false, &mask, &offset,
 nargs, step1);
  RTX_FRAME_RELATED_P (emit_insn (insn)) = 1;
+ mips_frame_barrier ();
  size -= step1;
 
  /* Check if we need to save other registers.  */
@@ -10075,6 +10084,7 @@ mips_expand_prologue (void)
  insn = gen_add3_insn (stack_pointer_rtx, stack_pointer_rtx,
GEN_INT (-step1));
  RTX_FRAME_RELATED_P (emit_insn (insn)) = 1;
+ mips_frame_barrier ();
  size -= step1;
 
  /* Start at the uppermost location for saving.  */
@@ -10135,6 +10145,7 @@ mips_expand_prologue (void)
stack_pointer_rtx,
GEN_INT (-step1));
  RTX_FRAME_RELATED_P (emit_insn (insn)) = 1;
+ mips_frame_barrier ();
  size -= step1;
}
  mips_for_each_saved_acc (size, mips_save_reg);
@@ -10175,6 +10186,7 @@ mips_expand_prologue (void)
(gen_rtx_SET (VOIDmode, stack_pointer_rtx,
  plus_constant (stack_pointer_rtx, -size)));
}
+  mips_frame_barrier ();
 }
 
   /* Set up the frame pointer, if we're using one.  */
@@ -10315,6 +10327,35 @@ mips_restore_reg (rtx reg, rtx mem)
   mips_epilogue.cfa_restore_sp_offset);
 }
 
+/* Emit code to set the stack pointer to BASE + OFFSET, given that
+   BASE + OFFSET is NEW_FRAME_SIZE bytes below the top of the frame.
+   BASE, if not the stack pointer, is available as a temporary.  */
+
+static void
+mips_deallocate_stack (rtx base, rtx offset, HOST_WIDE_INT new_frame_size)
+{
+  if (base == stack_pointer_rtx && offset == const0_rtx)
+return;
+
+  mips_frame_barrier ();
+  if (offset == const0_rtx)
+{
+  emit_move_insn (stack_pointer_rtx, base);
+  mips_epilogue_set_cfa (stack_pointer_rtx, new_frame_size);
+}
+  else if (TARGET_MIPS16 && base != stack_pointer_rtx)
+{
+  emit_insn (gen_add3_insn (base, base, offset));
+  mips_epilogue_set_cfa (base, new_frame_size);
+  emit_move_insn (stack_pointer_rtx, base);
+}
+  else
+{
+  emit_insn (gen_add3_insn (stack_pointer_rtx, base, offset));
+  mips_epilogue_set_cfa (stack_pointer_rtx, new_frame_size);
+}
+}
+
 /* Emit any instructions needed before a return.  */
 
 void
@@ -10341,7 +10382,7 @@ mips_expand_epilogue (bool sibcall_p)
 {
   const struct mips_frame_info *frame;
   HOST_WIDE_INT step1, step2;
-  rtx base, target, insn;
+  rtx base, adjust, insn;
 
   if (!sibcall_p && mips_can_use_return_insn ())
 {
@@ -10384,31 +10425,14 @@ mips_expand_epilogue (bool sibcall_p)
   step1 -= step2;
 }
 
-  /* Set TARGET to BASE + STEP1.  */
-  target = base;
-  if (step1 > 0)
-{
-  rtx adjust;
-
-  /* Get an rtx for STEP1 that we can add to BASE.  */
-  adjust = GEN_INT (step1);
-  if (!SMALL_OPERAND (step1))
-   {
- mips_emit_move (MIPS_EPILOGUE_TEMP (Pmode), adjust);
- adjust = MIPS_EPILOGUE_TEMP (Pmode);
-   }
-
-  /* Normal mode code can copy the result straight into $sp.  */
-  if (!TARGET_MIPS16)
-   target = stack_pointer_rtx;
-
-  emit_insn (gen_add3_insn (target, base, adjust));
-  mips_epilogue_set_cfa (target, step2);
+  /* Get an rtx for STEP1 that we can add to BASE.  */
+  adjust = GEN_INT (step1);
+  if (!SMALL_OPERAND (step1))
+{
+  mips_emit_move (MIPS_EPILOGUE_TEMP (Pmode), adjust);
+  adjust = MIPS_EPILOGUE_TEMP (Pmode);
 }
-
-  /* Copy TARGET into the stack pointer.  */
-  if (target != stack_pointer

[M68K] Hookize OUTPUT_ADDR_CONST_EXTRA

2011-10-02 Thread Anatoly Sokolov
  Hi.

  This patch removes obsolete OUTPUT_ADDR_CONST_EXTRA macro from the M68K 
back end in the GCC and introduces equivalent TARGET_OUTPUT_ADDR_CONST_EXTRA 
target hook.

  Compiled without error.  Not tested.

  OK to install?

* config/m68k/m68k.c (m68k_output_addr_const_extra): Make static.
(TARGET_OUTPUT_ADDR_CONST_EXTRA): Define.
* config/m68k/m68k.h (OUTPUT_ADDR_CONST_EXTRA): Remove.
* config/m68k/m68k-protos.h (m68k_output_addr_const_extra): Remove.

Index: gcc/config/m68k/m68k-protos.h
===
--- gcc/config/m68k/m68k-protos.h   (revision 179412)
+++ gcc/config/m68k/m68k-protos.h   (working copy)
@@ -51,7 +51,6 @@
 extern int standard_68881_constant_p (rtx);
 extern void print_operand_address (FILE *, rtx);
 extern void print_operand (FILE *, rtx, int);
-extern bool m68k_output_addr_const_extra (FILE *, rtx);
 extern void notice_update_cc (rtx, rtx);
 extern bool m68k_legitimate_base_reg_p (rtx, bool);
 extern bool m68k_legitimate_index_reg_p (rtx, bool);
Index: gcc/config/m68k/m68k.c
===
--- gcc/config/m68k/m68k.c  (revision 179412)
+++ gcc/config/m68k/m68k.c  (working copy)
@@ -163,6 +163,7 @@
 static rtx m68k_function_arg (cumulative_args_t, enum machine_mode,
  const_tree, bool);
 static bool m68k_cannot_force_const_mem (enum machine_mode mode, rtx x);
+static bool m68k_output_addr_const_extra (FILE *, rtx);
 
 /* Initialize the GCC target structure.  */
 
@@ -297,6 +298,9 @@
 #undef TARGET_LEGITIMATE_CONSTANT_P
 #define TARGET_LEGITIMATE_CONSTANT_P m68k_legitimate_constant_p
 
+#undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
+#define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA m68k_output_addr_const_extra
+
 static const struct attribute_spec m68k_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
@@ -4540,9 +4544,9 @@
 }
 }
 
-/* m68k implementation of OUTPUT_ADDR_CONST_EXTRA.  */
+/* m68k implementation of TARGET_OUTPUT_ADDR_CONST_EXTRA.  */
 
-bool
+static bool
 m68k_output_addr_const_extra (FILE *file, rtx x)
 {
   if (GET_CODE (x) == UNSPEC)
Index: gcc/config/m68k/m68k.h
===
--- gcc/config/m68k/m68k.h  (revision 179412)
+++ gcc/config/m68k/m68k.h  (working copy)
@@ -935,12 +935,6 @@
 
 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
 
-#define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL) \
-do {   \
-  if (! m68k_output_addr_const_extra (FILE, (X)))  \
-goto FAIL; \
-} while (0);
-
 #include "config/m68k/m68k-opts.h"
 
 enum fpu_type


Anatoly.



[commited, MIPS] Fix PR50579

2011-10-02 Thread Richard Sandiford
This patch fixes a testsuite problem after my recent patch to be
more picky about -mlong* options.

Tested on mips64-linux-gnu and applied.

Richard



gcc/testsuite/
PR target/50579
* gcc.target/mips/mips.exp (mips_long32_abi_p, mips_long64_abi_p):
New procedures.
(mips-dg-options): Force an ABI option if the current ABI is
incompatible with the required -mlong setting.  Likewise force
a long setting if the current one is incompatible with the
chosen ABI.  Keep abi_test_option_p, abi and eabi_p updated
throughout procedure.
* gcc.target/mips/abi-o64-long64.c: Require -mno-abicalls
instead of addressing=absolute.

Index: gcc/testsuite/gcc.target/mips/mips.exp
===
--- gcc/testsuite/gcc.target/mips/mips.exp  2011-10-02 18:59:22.0 
+0100
+++ gcc/testsuite/gcc.target/mips/mips.exp  2011-10-02 19:21:37.0 
+0100
@@ -588,6 +588,30 @@ proc mips_64bit_abi_p { option } {
 return 0
 }
 
+# Return true if the given abi-group option implicitly requires -mlong32.
+# o64 requires this for -mabicalls, but not otherwise; pick the conservative
+# case for simplicity.
+proc mips_long32_abi_p { option } {
+switch -glob -- $option {
+   -mabi=o64 -
+   -mabi=n32 -
+   -mabi=32 {
+   return 1
+   }
+}
+return 0
+}
+
+# Return true if the given abi-group option implicitly requires -mlong64.
+proc mips_long64_abi_p { option } {
+switch -glob -- $option {
+   -mabi=64 {
+   return 1
+   }
+}
+return 0
+}
+
 # Check whether the current target supports all the options that the
 # current test requires.  Return "" if so, otherwise return one of
 # the incompatible options.  UPSTATUS describes the option status.
@@ -1029,24 +1053,41 @@ proc mips-dg-options { args } {
# -mips16 -mhard-float requires o32 or o64.
# -mips16 PIC requires o32 or o64.
set force_abi 1
+   } elseif { [mips_have_test_option_p options "-mlong32"]
+  && [mips_long64_abi_p $abi] } {
+   set force_abi 1
+   } elseif { [mips_have_test_option_p options "-mlong64"]
+  && [mips_long32_abi_p $abi] } {
+   set force_abi 1
} else {
set force_abi 0
}
if { $gp_size == 32 } {
if { $force_abi || [mips_64bit_abi_p $abi] } {
-   mips_make_test_option options "-mabi=32"
+   if { [mips_have_test_option_p options "-mlong64"] } {
+   mips_make_test_option options "-mabi=eabi"
+   mips_make_test_option options "-mgp32"
+   } else {
+   mips_make_test_option options "-mabi=32"
+   }
}
} else {
if { $force_abi || [mips_32bit_abi_p $abi] } {
-   # All configurations should have an assembler that
-   # supports o64, since it requires the same BFD target
-   # vector as o32.  In contrast, many assembler
-   # configurations do not have n32 or n64 support.
-   mips_make_test_option options "-mabi=o64"
+   if { [mips_have_test_option_p options "-mlong64"] } {
+   mips_make_test_option options "-mabi=eabi"
+   mips_make_test_option options "-mgp64"
+   } else {
+   # All configurations should have an assembler that
+   # supports o64, since it requires the same BFD target
+   # vector as o32.  In contrast, many assembler
+   # configurations do not have n32 or n64 support.
+   mips_make_test_option options "-mabi=o64"
+   }
}
}
-   unset abi
-   unset eabi_p
+   set abi_test_option_p [mips_test_option_p options abi]
+   set abi [mips_option options abi]
+   set eabi_p [mips_same_option_p $abi "-mabi=eabi"]
 }
 
 # Handle dependencies between the abi options and the post-abi options.
@@ -1070,8 +,11 @@ proc mips-dg-options { args } {
mips_make_test_option options "-mno-mips16"
}
}
-   unset abi
-   unset eabi_p
+   if { [mips_long32_abi_p $abi] } {
+   mips_make_test_option options "-mlong32"
+   } elseif { [mips_long64_abi_p $abi] } {
+   mips_make_test_option options "-mlong64"
+   }
 }
 
 # Handle dependencies between the arch option and the post-arch options.
Index: gcc/testsuite/gcc.target/mips/abi-o64-long64.c
===
--- gcc/testsuite/gcc.target/mips/abi-o64-long64.c  2011-10-02 
19:25:08.0 +0100
+++ gcc/testsuite/gcc.target/mips/abi-o64-long64.c  2011-10-02 
19:25:13.0 +0100
@@ -1,2 +1,2 @@
-/* { dg-options "-mabi=o64 -mlong64 addressing=absolute -O2" } */
+/* { dg-options 

Re: [PATCH] Support -m{cpu,tune}=native on Linux/Sparc

2011-10-02 Thread Gerald Pfeifer
On Mon, 5 Sep 2011, David Miller wrote:
>> Should we use GNU/Linux in those three cases per the standing request
>> from RMS?  I can make the change if so.
> I'm completely ambivalent, feel free to make the change.

Okay, so I went ahead (with some delay, ahem) and applied the patch
below.

Thanks,
Gerald


2011-10-02  Gerald Pfeifer  

* invoke.texi (SPARC Options): Refer to GNU/Linux.

Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 179433)
+++ doc/invoke.texi (working copy)
@@ -17345,7 +17345,7 @@
 @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
 and @samp{niagara4}.
 
-Native Solaris and Linux toolchains also support the value @samp{native},
+Native Solaris and GNU/Linux toolchains also support the value @samp{native},
 which selects the best architecture option for the host processor.
 @option{-mcpu=native} has no effect if GCC does not recognize
 the processor.
@@ -17418,7 +17418,7 @@
 @samp{supersparc}, @samp{hypersparc}, @samp{leon}, @samp{f930}, @samp{f934},
 @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, @samp{ultrasparc3},
 @samp{niagara}, @samp{niagara2}, @samp{niagara3} and @samp{niagara4}.  With
-native Solaris and Linux toolchains, @samp{native} can also be used.
+native Solaris and GNU/Linux toolchains, @samp{native} can also be used.
 
 @item -mv8plus
 @itemx -mno-v8plus


Re: [PATCH] Support -m{cpu,tune}=native on Linux/Sparc

2011-10-02 Thread Gerald Pfeifer
Hi David,

On Sun, 4 Sep 2011, David Miller wrote:
>   * config/sparc/driver-sparc.c: Correct Linux strings.

would a patch like the one below be appropriate (with a ChangeLog entry), 
or is the Linux kernel (or GNU/Linux userland) really using Sparc instead 
of SPARC in those places?

Gerald

Index: config/sparc/driver-sparc.c
===
--- config/sparc/driver-sparc.c (revision 179430)
+++ config/sparc/driver-sparc.c (working copy)
@@ -59,7 +59,7 @@
   { "SPARC-T4","niagara4" },
 #else
   { "SuperSPARC",  "supersparc" },
-  { "HyperSparc",  "hypersparc" },
+  { "HyperSPARC",  "hypersparc" },
   { "SpitFire","ultrasparc" },
   { "BlackBird",   "ultrasparc" },
   { "Sabre",   "ultrasparc" },
@@ -69,10 +69,10 @@
   { "Jaguar",  "ultrasparc3" },
   { "Panther", "ultrasparc3" },
   { "Serrano", "ultrasparc3" },
-  { "UltraSparc T1",   "niagara" },
-  { "UltraSparc T2",   "niagara2" },
-  { "UltraSparc T3",   "niagara3" },
-  { "UltraSparc T4",   "niagara4" },
+  { "UltraSPARC T1",   "niagara" },
+  { "UltraSPARC T2",   "niagara2" },
+  { "UltraSPARC T3",   "niagara3" },
+  { "UltraSPARC T4",   "niagara4" },
 #endif
   { NULL,  NULL }
   };


Re: [M68K] Hookize OUTPUT_ADDR_CONST_EXTRA

2011-10-02 Thread Andreas Schwab
Anatoly Sokolov  writes:

> * config/m68k/m68k.c (m68k_output_addr_const_extra): Make static.
> (TARGET_OUTPUT_ADDR_CONST_EXTRA): Define.
> * config/m68k/m68k.h (OUTPUT_ADDR_CONST_EXTRA): Remove.
> * config/m68k/m68k-protos.h (m68k_output_addr_const_extra): Remove.

Ok.

> @@ -4540,9 +4544,9 @@
>  }
>  }
>  
> -/* m68k implementation of OUTPUT_ADDR_CONST_EXTRA.  */
> +/* m68k implementation of TARGET_OUTPUT_ADDR_CONST_EXTRA.  */
   _ASM


Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


C++ PATCH for c++/35722 (N2555 variadic pack expansion to fixed template parameter set)

2011-10-02 Thread Jason Merrill
This patch implements the extension voted in with paper N2555, after the 
initial implementation of variadic templates in GCC.  Under this 
extension, a template argument list can contain a pack expansion even if 
the template has a fixed parameter list.  For example,


template struct foo {};
template struct bar : foo {};
int main() {
  bar f;
}

Here the template argument pack specified for bar has two elements, so 
it ends up matching the parameter list for foo and all is good.


My implementation approach was as follows:

1) Don't try to do anything with an unknown or incomplete argument pack, 
just leave it alone until we know all the arguments.
2) Since we aren't substituting partial packs anymore, when deducing a 
function parameter pack, plug in explicit template arguments as we go.
3) If we see a template parameter pack used in a function parameter pack 
not at the end of the parameter list, we can't deduce it, so just plug 
in the explicit template arguments (if any).


This last point is an open area of discussion in the committee, but it 
gets the job done and seems like a reasonable approach to me.


The first patch here is the substantive changes; the second patch is 
just factoring out common code in type_unification_real and 
unify_pack_expansion into a separate function.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit dca90afa40bc6dae2198c18e60bc07334772564d
Author: Jason Merrill 
Date:   Tue Sep 27 01:38:51 2011 -0400

	PR c++/35722
	Implement N2555 (expanding pack expansion to fixed parm list)
	* pt.c (coerce_template_parms): Allow expanding a pack expansion
	to a fixed-length argument list.
	(unify_pack_expansion): Handle explicit args properly.
	(unify) [TREE_VEC]: Handle pack expansions here.
	[TYPE_ARGUMENT_PACK]: Not here.
	(tsubst_pack_expansion): Don't try to do partial substitution.
	(pack_deducible_p): New.
	(fn_type_unification): Use it.
	(find_parameter_packs_r): Take the TYPE_MAIN_VARIANT
	of a type parameter.
	(check_non_deducible_conversion): Split out from fn_type_unification.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4d57f94..1b7337e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2961,6 +2961,7 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
   break;
 
 case TEMPLATE_TYPE_PARM:
+  t = TYPE_MAIN_VARIANT (t);
 case TEMPLATE_TEMPLATE_PARM:
   if (TEMPLATE_TYPE_PARAMETER_PACK (t))
 parameter_pack_p = true;
@@ -6741,22 +6742,10 @@ coerce_template_parms (tree parms,
 	{
   if (PACK_EXPANSION_P (arg))
 {
-	  if (complain & tf_error)
-		{
-		  /* FIXME this restriction was removed by N2555; see
-		 bug 35722.  */
-		  /* If ARG is a pack expansion, but PARM is not a
-		 template parameter pack (if it were, we would have
-		 handled it above), we're trying to expand into a
-		 fixed-length argument list.  */
-		  if (TREE_CODE (arg) == EXPR_PACK_EXPANSION)
-		sorry ("cannot expand %<%E%> into a fixed-length "
-			   "argument list", arg);
-		  else
-		sorry ("cannot expand %<%T%> into a fixed-length "
-			   "argument list", arg);
-		}
-	  ++lost;
+  /* We don't know how many args we have yet, just
+ use the unconverted ones for now.  */
+  new_inner_args = args;
+  break;
 }
 }
   else if (require_all_args)
@@ -9116,7 +9105,6 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
   tree pack, packs = NULL_TREE, unsubstituted_packs = NULL_TREE;
   int i, len = -1;
   tree result;
-  int incomplete = 0;
   htab_t saved_local_specializations = NULL;
 
   gcc_assert (PACK_EXPANSION_P (t));
@@ -9189,21 +9177,15 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
   int my_len = 
 TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg_pack));
 
-  /* It's all-or-nothing with incomplete argument packs.  */
-  if (incomplete && !ARGUMENT_PACK_INCOMPLETE_P (arg_pack))
-return error_mark_node;
-  
+	  /* Don't bother trying to do a partial substitution with
+	 incomplete packs; we'll try again after deduction.  */
   if (ARGUMENT_PACK_INCOMPLETE_P (arg_pack))
-incomplete = 1;
+return t;
 
   if (len < 0)
 	len = my_len;
   else if (len != my_len)
 {
-	  if (incomplete)
-		/* We got explicit args for some packs but not others;
-		   do nothing now and try again after deduction.  */
-		return t;
   if (TREE_CODE (t) == TYPE_PACK_EXPANSION)
 error ("mismatched argument pack lengths while expanding "
"%<%T%>",
@@ -9261,8 +9243,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
 
   /* For each argument in each argument pack, substitute into the
  pattern.  */
-  result = make_tree_vec (len + incomplete);
-  for (i = 0; i < len + incomp

C++ PATCH for some NSDMI bugs

2011-10-02 Thread Jason Merrill
The template and non-template versions of this test run into different 
bugs: the template version crashes in noexcept checking because the 
initializer hasn't been instantiated, and the non-template version 
crashes in fixed_type_or_null because current_function_decl is null.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 990d1177f59f12fbf8bf73a215b6e43bf4b27583
Author: Jason Merrill 
Date:   Sun Oct 2 17:02:44 2011 -0400

	* class.c (fixed_type_or_null): Handle NSDMI.
	* method.c (walk_field_subobs): Disable NSDMI noexcept checking
	for now.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index a7d8218..2df9177 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -6062,10 +6062,13 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp)
 	  if (nonnull)
 	*nonnull = 1;
 
-	  /* if we're in a ctor or dtor, we know our type.  */
-	  if (DECL_LANG_SPECIFIC (current_function_decl)
-	  && (DECL_CONSTRUCTOR_P (current_function_decl)
-		  || DECL_DESTRUCTOR_P (current_function_decl)))
+	  /* if we're in a ctor or dtor, we know our type.  If
+	 current_class_ptr is set but we aren't in a function, we're in
+	 an NSDMI (and therefore a constructor).  */
+	  if (current_scope () != current_function_decl
+	  || (DECL_LANG_SPECIFIC (current_function_decl)
+		  && (DECL_CONSTRUCTOR_P (current_function_decl)
+		  || DECL_DESTRUCTOR_P (current_function_decl
 	{
 	  if (cdtorp)
 		*cdtorp = 1;
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 1316dfb..f4a3ea6 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1042,12 +1042,16 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
 		inform (0, "initializer for %q+#D is invalid", field);
 	  if (trivial_p)
 		*trivial_p = false;
+#if 0
 	  /* Core 1351: If the field has an NSDMI that could throw, the
 		 default constructor is noexcept(false).  FIXME this is
-	 broken by deferred parsing and 1360 saying we can't
-		 lazily declare a non-trivial default constructor.  */
+		 broken by deferred parsing and 1360 saying we can't lazily
+		 declare a non-trivial default constructor.  Also this
+		 needs to do deferred instantiation.  Disable until the
+		 conflict between 1351 and 1360 is resolved.  */
 	  if (spec_p && !expr_noexcept_p (DECL_INITIAL (field), complain))
 		*spec_p = noexcept_false_spec;
+#endif
 
 	  /* Don't do the normal processing.  */
 	  continue;
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi5.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi5.C
new file mode 100644
index 000..62803b0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi5.C
@@ -0,0 +1,20 @@
+// { dg-options -std=c++0x }
+
+struct X
+{
+  int x = 5;
+  int f() { return x; }
+};
+struct Y : X
+{
+  int y = this->x;
+};
+template  struct Z : T
+{
+  int y = this->f();
+};
+int main()
+{
+  Y foo;
+  Z bar;
+}


Re: [PATCH] C++11, implement delegating constructors

2011-10-02 Thread Ville Voutilainen
At Wed, 21 Sep 2011 02:34:22 +0300,
Ville Voutilainen wrote:
> 
> On 21 September 2011 02:18, Ville Voutilainen
>  wrote:
> > Ok, a new patch:
> I just noticed that I have tabs disabled. You may want to tabify the patch.

Tabified and rebased on top of the nsdmi changes. Changelog
unchanged.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index a52ec29..9ab957b 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6952,8 +6952,10 @@ build_special_member_call (tree instance, tree name, 
VEC(tree,gc) **args,
current_in_charge_parm, integer_zero_node),
current_vtt_parm,
vtt);
-  gcc_assert (BINFO_SUBVTT_INDEX (binfo));
-  sub_vtt = fold_build_pointer_plus (vtt, BINFO_SUBVTT_INDEX (binfo));
+  if (BINFO_SUBVTT_INDEX (binfo))
+   sub_vtt = fold_build_pointer_plus (vtt, BINFO_SUBVTT_INDEX (binfo));
+  else
+   sub_vtt = vtt;
 
   if (args == NULL)
{
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 0f7deb6..558d433 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -396,7 +396,9 @@ typedef enum cpp0x_warn_str
   /* override controls, override/final */
   CPP0X_OVERRIDE_CONTROLS,
   /* non-static data member initializers */
-  CPP0X_NSDMI
+  CPP0X_NSDMI,
+  /* delegating constructors */
+  CPP0X_DELEGATING_CTORS
 } cpp0x_warn_str;
   
 /* The various kinds of operation used by composite_pointer_type. */
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 4d12a0d..cc01718 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -3242,6 +3242,11 @@ maybe_warn_cpp0x (cpp0x_warn_str str)
 "non-static data member initializers "
 "only available with -std=c++0x or -std=gnu++0x");
 break;
+  case CPP0X_DELEGATING_CTORS:
+   pedwarn (input_location, 0,
+"delegating constructors "
+"only available with -std=c++0x or -std=gnu++0x");
+break;
   default:
gcc_unreachable();
   }
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index f246286..7771a30 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -483,6 +483,30 @@ build_value_init_noctor (tree type, tsubst_flags_t 
complain)
   return build_zero_init (type, NULL_TREE, /*static_storage_p=*/false);
 }
 
+/* Initialize current class with INIT, a TREE_LIST of
+   arguments for a target constructor. If TREE_LIST is void_type_node,
+   an empty initializer list was given.  */
+
+static void
+perform_target_ctor (tree init)
+{
+  tree decl = current_class_ref;
+  tree type = current_class_type;
+  
+  finish_expr_stmt (build_aggr_init (decl, init, LOOKUP_NORMAL,
+ tf_warning_or_error));
+  if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
+{
+  tree expr = build_delete (type, decl, sfk_complete_destructor,
+   LOOKUP_NORMAL
+   |LOOKUP_NONVIRTUAL
+   |LOOKUP_DESTRUCTOR,
+   0, tf_warning_or_error);
+  if (expr != error_mark_node)
+   finish_eh_cleanup (expr);
+}
+}
+
 /* Initialize MEMBER, a FIELD_DECL, with INIT, a TREE_LIST of
arguments.  If TREE_LIST is void_type_node, an empty initializer
list was given; if NULL_TREE no initializer was given.  */
@@ -940,6 +964,16 @@ emit_mem_initializers (tree mem_inits)
   if (!COMPLETE_TYPE_P (current_class_type))
 return;
 
+  if (mem_inits
+  && TYPE_P (TREE_PURPOSE (mem_inits))
+  && same_type_p (TREE_PURPOSE (mem_inits), current_class_type))
+{
+  /* Delegating constructor. */
+  gcc_assert (TREE_CHAIN (mem_inits) == NULL_TREE);
+  perform_target_ctor (TREE_VALUE (mem_inits));
+  return;
+}
+
   if (DECL_DEFAULTED_FN (current_function_decl))
 flags |= LOOKUP_DEFAULTED;
 
@@ -1270,8 +1304,9 @@ expand_member_init (tree name)
   tree virtual_binfo;
   int i;
 
-  if (current_template_parms)
-   return basetype;
+  if (same_type_p (basetype, current_class_type)
+ || current_template_parms)
+ return basetype;
 
   class_binfo = TYPE_BINFO (current_class_type);
   direct_binfo = NULL_TREE;
@@ -1510,13 +1545,33 @@ expand_default_init (tree binfo, tree true_exp, tree 
exp, tree init, int flags,
   else
 parms = make_tree_vector_single (init);
 
-  if (true_exp == exp)
-ctor_name = complete_ctor_identifier;
-  else
-ctor_name = base_ctor_identifier;
-
-  rval = build_special_member_call (exp, ctor_name, &parms, binfo, flags,
-complain);
+  if (exp == current_class_ref && current_function_decl
+  && DECL_HAS_IN_CHARGE_PARM_P (current_function_decl))
+{
+  /* Delegating constructor. */
+  tree complete;
+  tree base;
+  complete = build_special_member_call (exp, complete_ctor_identifier,
+   &parms, binfo, flags,
+   complain);
+  base = build_special_member_

Re: [PATCH] Support -m{cpu,tune}=native on Linux/Sparc

2011-10-02 Thread David Miller
From: Gerald Pfeifer 
Date: Sun, 2 Oct 2011 23:11:14 +0200 (CEST)

> On Sun, 4 Sep 2011, David Miller wrote:
>>  * config/sparc/driver-sparc.c: Correct Linux strings.
> 
> would a patch like the one below be appropriate (with a ChangeLog entry), 
> or is the Linux kernel (or GNU/Linux userland) really using Sparc instead 
> of SPARC in those places?

No, it would not be appropriate.

We always use "Sparc" instead of "SPARC" for the cpu names output
by the kernel in /proc/cpuinfo.


[PATCH] Add missing sparc shift zero extensions, and fix shift attributes.

2011-10-02 Thread David Miller

This is a patch Richard came up with earlier this year when I had him
look into some excessive sign/zero extensions the compiler was making
on sparc 64-bit.

I finally got around to validating this patch and while doing so noticed
that we've had the instruction attributes screwed up on shifts for quite
some time.

A very long time ago, we used to amit "add x, x, y" for a constant
shift left of one.  But that hack got removed a long time, but when
it got removed the conditional attribute setting was left around.

Committed to trunk.

gcc/

* config/sparc/sparc.md (ashlsi3, *ashldi3_sp64): Remove
conditional insn type setting, we always emit a shift.
(*ashlsi3_extend, *lshrsi3_extend0): New patterns.
(*lshrsi3_extend): Rename to *lshrsi3_extend1.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179441 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog  |8 
 gcc/config/sparc/predicates.md |5 -
 gcc/config/sparc/sparc.md  |   36 +---
 3 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0f32049..fbc0b20 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2011-10-02  Richard Henderson  
+   David S. Miller  
+
+   * config/sparc/sparc.md (ashlsi3, *ashldi3_sp64): Remove
+   conditional insn type setting, we always emit a shift.
+   (*ashlsi3_extend, *lshrsi3_extend0): New patterns.
+   (*lshrsi3_extend): Rename to *lshrsi3_extend1.
+
 2011-10-02  Gerald Pfeifer  
 
* invoke.texi (SPARC Options): Refer to GNU/Linux.
diff --git a/gcc/config/sparc/predicates.md b/gcc/config/sparc/predicates.md
index 21399b5..f0be149 100644
--- a/gcc/config/sparc/predicates.md
+++ b/gcc/config/sparc/predicates.md
@@ -24,11 +24,6 @@
   (and (match_code "const_int,const_double,const_vector")
(match_test "op == CONST0_RTX (mode)")))
 
-;; Return true if OP is the one constant for MODE.
-(define_predicate "const_one_operand"
-  (and (match_code "const_int,const_double,const_vector")
-   (match_test "op == CONST1_RTX (mode)")))
-
 ;; Return true if the integer representation of OP is
 ;; all-ones.
 (define_predicate "const_all_ones_operand"
diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md
index 03158c7..6990746 100644
--- a/gcc/config/sparc/sparc.md
+++ b/gcc/config/sparc/sparc.md
@@ -5814,9 +5814,20 @@
 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
   return "sll\t%1, %2, %0";
 }
-  [(set (attr "type")
-   (if_then_else (match_operand 2 "const_one_operand" "")
- (const_string "ialu") (const_string "shift")))])
+  [(set_attr "type" "shift")])
+
+(define_insn "*ashlsi3_extend"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+   (zero_extend:DI
+ (ashift:SI (match_operand:SI 1 "register_operand" "r")
+(match_operand:SI 2 "arith_operand" "rI"]
+  "TARGET_ARCH64"
+{
+  if (GET_CODE (operands[2]) == CONST_INT)
+operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
+  return "sll\t%1, %2, %0";
+}
+  [(set_attr "type" "shift")])
 
 (define_expand "ashldi3"
   [(set (match_operand:DI 0 "register_operand" "=r")
@@ -5843,9 +5854,7 @@
 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
   return "sllx\t%1, %2, %0";
 }
-  [(set (attr "type")
-   (if_then_else (match_operand 2 "const_one_operand" "")
- (const_string "ialu") (const_string "shift")))])
+  [(set_attr "type" "shift")])
 
 ;; XXX UGH!
 (define_insn "ashldi3_v8plus"
@@ -5980,10 +5989,23 @@
   }
   [(set_attr "type" "shift")])
 
+(define_insn "*lshrsi3_extend0"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+   (zero_extend:DI
+ (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
+  (match_operand:SI 2 "arith_operand" "rI"]
+  "TARGET_ARCH64"
+  {
+if (GET_CODE (operands[2]) == CONST_INT)
+  operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
+return "srl\t%1, %2, %0";
+  }
+  [(set_attr "type" "shift")])
+
 ;; This handles the case where
 ;; (zero_extend:DI (lshiftrt:SI (match_operand:SI) (match_operand:SI))),
 ;; but combiner "simplifies" it for us.
-(define_insn "*lshrsi3_extend"
+(define_insn "*lshrsi3_extend1"
   [(set (match_operand:DI 0 "register_operand" "=r")
(and:DI (subreg:DI (lshiftrt:SI (match_operand:SI 1 "register_operand" 
"r")
   (match_operand:SI 2 "arith_operand" "r")) 0)
-- 
1.7.6.401.g6a319



Re: [PATCH] Add missing sparc shift zero extensions, and fix shift attributes.

2011-10-02 Thread David Miller
From: David Miller 
Date: Sun, 02 Oct 2011 20:50:22 -0400 (EDT)

>   * config/sparc/sparc.md (ashlsi3, *ashldi3_sp64): Remove
>   conditional insn type setting, we always emit a shift.
>   (*ashlsi3_extend, *lshrsi3_extend0): New patterns.
>   (*lshrsi3_extend): Rename to *lshrsi3_extend1.

Right after posting this I noticed that I left out the predicates.md
change from the ChangeLog, which I've fixed up as follows:

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179442 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fbc0b20..b4fab73 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -5,6 +5,7 @@
conditional insn type setting, we always emit a shift.
(*ashlsi3_extend, *lshrsi3_extend0): New patterns.
(*lshrsi3_extend): Rename to *lshrsi3_extend1.
+   * config/sparc/predicates.md (const_one_operand): Delete.
 
 2011-10-02  Gerald Pfeifer  
 
-- 
1.7.6.401.g6a319



RE: Intrinsics for N2965: Type traits and base classes

2011-10-02 Thread Michael Spertus
OK. Here is a new diff that hopefully takes into account all of Jason's and 
Benjamin's comments. Benjamin's TR2 build patch is not repeated (or tested!) 
here. Benjamin, I'd really appreciate if you wouldn't mind confirming I handled 
that correctly in tr2/type_traits (Including the inclusion of std/type_traits).

Thanks,

Mike


Index: libstdc++-v3/include/tr2/type_traits
===
--- libstdc++-v3/include/tr2/type_traits(revision 0)
+++ libstdc++-v3/include/tr2/type_traits(revision 0)
@@ -0,0 +1,96 @@
+// TR2 type_traits -*- C++ -*-
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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.
+
+// This library 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file tr2/type_traits
+ *  This is a TR2 C++ Library header. 
+ */
+
+#ifndef _GLIBCXX_TR2_TYPE_TRAITS
+#define _GLIBCXX_TR2_TYPE_TRAITS 1
+
+#pragma GCC system_header
+#include 
+#include 
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace tr2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  /**
+   * @defgroup metaprogramming Type Traits
+   * @ingroup utilities
+   *
+   * Compile time type transformation and information.
+   * @{
+   */
+
+  template struct typelist;
+  template<>
+struct typelist<>
+{
+  typedef std::true_type empty;
+};
+
+  template
+struct typelist<_First, _Rest...>
+{
+  struct first
+  {
+typedef _First type;
+  };
+
+  struct rest
+  {
+typedef typelist<_Rest...> type;
+  };
+
+  typedef std::false_type empty;
+};
+
+  // Sequence abstraction metafunctions default to looking in the type
+  template struct first : public T::first {};
+  template struct rest : public T::rest {};
+  template struct empty : public T::empty {};
+
+
+  template
+struct bases
+{
+ typedef typelist<__bases(T)...> type;
+};
+
+  template
+struct direct_bases
+{
+  typedef typelist<__direct_bases(T)...> type;
+};
+   
+_GLIBCXX_END_NAMESPACE_VERSION
+}
+}
+
+#endif // _GLIBCXX_TR2_TYPE_TRAITS
Index: gcc/c-family/c-common.c
===
--- gcc/c-family/c-common.c (revision 178892)
+++ gcc/c-family/c-common.c (working copy)
@@ -423,6 +423,7 @@
   { "__asm__", RID_ASM,0 },
   { "__attribute", RID_ATTRIBUTE,  0 },
   { "__attribute__",   RID_ATTRIBUTE,  0 },
+  { "__bases",  RID_BASES, D_CXXONLY },
   { "__builtin_choose_expr", RID_CHOOSE_EXPR, D_CONLY },
   { "__builtin_complex", RID_BUILTIN_COMPLEX, D_CONLY },
   { "__builtin_offsetof", RID_OFFSETOF, 0 },
@@ -433,6 +434,7 @@
   { "__const", RID_CONST,  0 },
   { "__const__",   RID_CONST,  0 },
   { "__decltype",   RID_DECLTYPE,   D_CXXONLY },
+  { "__direct_bases",   RID_DIRECT_BASES, D_CXXONLY },
   { "__extension__",   RID_EXTENSION,  0 },
   { "__func__",RID_C99_FUNCTION_NAME, 0 },
   { "__has_nothrow_assign", RID_HAS_NOTHROW_ASSIGN, D_CXXONLY },
Index: gcc/c-family/c-common.h
===
--- gcc/c-family/c-common.h (revision 178892)
+++ gcc/c-family/c-common.h (working copy)
@@ -139,7 +139,8 @@
   RID_IS_LITERAL_TYPE, RID_IS_POD,
   RID_IS_POLYMORPHIC,  RID_IS_STD_LAYOUT,
   RID_IS_TRIVIAL,  RID_IS_UNION,
-  RID_UNDERLYING_TYPE,
+  RID_UNDERLYING_TYPE, RID_BASES,
+  RID_DIRECT_BASES,
 
   /* C++0x */
   RID_CONSTEXPR, RID_DECLTYPE, RID_NOEXCEPT, RID_NULLPTR, RID_STATIC_ASSERT,
Index: gcc/cp/pt.c
===
--- gcc/cp/pt.c (revision 178892)
+++ gcc/cp/pt.c (working copy)
@@ -2976,6 +2976,9 @@
 }
   break;
 
+case BASES:
+  parameter_pack_p = true;
+  break;
 default:
   /* Not a parameter pack.  */
   break;
@@ -9123,6 +9126,15 @@
   tree arg_pack = NULL_TREE;
   tree orig_arg = NULL_TREE;
 
+  if (TREE_CODE (parm_pack)

Re: [CRIS] Hookize OUTPUT_ADDR_CONST_EXTRA

2011-10-02 Thread Hans-Peter Nilsson
> Date: Sun, 2 Oct 2011 21:36:50 +0400
> From: Anatoly Sokolov 

>   OK to install?
> 
> * config/cris/m32c.c (cris_output_addr_const_extra): Make static.


> (TARGET_OUTPUT_ADDR_CONST_EXTRA): Define.
> * config/cris/cris.h (OUTPUT_ADDR_CONST_EXTRA): Remove.
> * config/cris/cris-protos.h (cris_output_addr_const_extra): Remove.

Ok with the ChangeLog entry fixed, thanks.

brgds, H-P


C++ PATCH for rejects-valid with C++11 range for

2011-10-02 Thread Jason Merrill
The range for code tries to do type deduction for the range for 
variables when the initializer isn't type dependent, but we don't do 
auto deduction from an initializer-list, so we shouldn't try to do that 
for range for, either; if we do we end up complaining about an 
incomplete type.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit f65c4d83c5cdd2bff213e4a7cd90258a2e0f4969
Author: Jason Merrill 
Date:   Sun Oct 2 22:53:54 2011 -0400

	* parser.c (cp_parser_range_for): Don't try to deduce from {}
	in a template.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 83d7b71..cabe9aa 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -8688,7 +8688,9 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl)
 {
   stmt = begin_range_for_stmt (scope, init);
   finish_range_for_decl (stmt, range_decl, range_expr);
-  if (!type_dependent_expression_p (range_expr))
+  if (!type_dependent_expression_p (range_expr)
+	  /* do_auto_deduction doesn't mess with template init-lists.  */
+	  && !BRACE_ENCLOSED_INITIALIZER_P (range_expr))
 	do_range_for_auto_deduction (range_decl, range_expr);
 }
   else
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for22.C b/gcc/testsuite/g++.dg/cpp0x/range-for22.C
new file mode 100644
index 000..5fef5e6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/range-for22.C
@@ -0,0 +1,5 @@
+// { dg-options -std=c++0x }
+
+template void f() {
+  for (auto i: {I} );
+}


C++ PATCH for variadic pack expansion memory use

2011-10-02 Thread Jason Merrill
Someone sent me a variadic templates testcase that was using an 
unreasonable amount of memory; -fmem-report showed that half of the 
garbage was from ARGUMENT_PACK_SELECT nodes.  There's no reason why we 
should allocate a new node for each pack on each iteration of the 
expansion; we can just allocate them for the first node and then update 
the index as we go along.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 13dd4a100ef26121960b3fd1552c6c96c4309838
Author: Jason Merrill 
Date:   Sun Oct 2 23:06:40 2011 -0400

	* pt.c (tsubst_pack_expansion): Re-use ARGUMENT_PACK_SELECTs.
	Change unsubstituted_packs to bool.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 015ee37..051c89a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9102,7 +9102,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
 		   tree in_decl)
 {
   tree pattern;
-  tree pack, packs = NULL_TREE, unsubstituted_packs = NULL_TREE;
+  tree pack, packs = NULL_TREE;
+  bool unsubstituted_packs = false;
   int i, len = -1;
   tree result;
   htab_t saved_local_specializations = NULL;
@@ -9203,10 +9204,11 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
   TREE_TYPE (packs) = orig_arg;
 }
   else
-/* We can't substitute for this parameter pack.  */
-unsubstituted_packs = tree_cons (TREE_PURPOSE (pack),
- TREE_VALUE (pack),
- unsubstituted_packs);
+	{
+	  /* We can't substitute for this parameter pack.  */
+	  unsubstituted_packs = true;
+	  break;
+	}
 }
 
   /* We cannot expand this expansion expression, because we don't have
@@ -9252,33 +9254,38 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
   for (pack = packs; pack; pack = TREE_CHAIN (pack))
 {
   tree parm = TREE_PURPOSE (pack);
+	  tree arg;
 
+	  /* Select the Ith argument from the pack.  */
   if (TREE_CODE (parm) == PARM_DECL)
 {
-	  /* Select the Ith argument from the pack.  */
-	  tree arg = make_node (ARGUMENT_PACK_SELECT);
-	  ARGUMENT_PACK_SELECT_FROM_PACK (arg) = TREE_VALUE (pack);
-	  ARGUMENT_PACK_SELECT_INDEX (arg) = i;
-  mark_used (parm);
-  register_local_specialization (arg, parm);
+	  if (i == 0)
+		{
+		  arg = make_node (ARGUMENT_PACK_SELECT);
+		  ARGUMENT_PACK_SELECT_FROM_PACK (arg) = TREE_VALUE (pack);
+		  mark_used (parm);
+		  register_local_specialization (arg, parm);
+		}
+	  else
+		arg = retrieve_local_specialization (parm);
 }
   else
 {
-  tree value = parm;
   int idx, level;
   template_parm_level_and_index (parm, &level, &idx);
-  
-	  if (i < len) 
+
+	  if (i == 0)
 		{
-		  /* Select the Ith argument from the pack. */
-		  value = make_node (ARGUMENT_PACK_SELECT);
-		  ARGUMENT_PACK_SELECT_FROM_PACK (value) = TREE_VALUE (pack);
-		  ARGUMENT_PACK_SELECT_INDEX (value) = i;
+		  arg = make_node (ARGUMENT_PACK_SELECT);
+		  ARGUMENT_PACK_SELECT_FROM_PACK (arg) = TREE_VALUE (pack);
+		  /* Update the corresponding argument.  */
+		  TMPL_ARG (args, level, idx) = arg;
 		}
-
-  /* Update the corresponding argument.  */
-  TMPL_ARG (args, level, idx) = value;
+	  else
+		/* Re-use the ARGUMENT_PACK_SELECT.  */
+		arg = TMPL_ARG (args, level, idx);
 }
+	  ARGUMENT_PACK_SELECT_INDEX (arg) = i;
 }
 
   /* Substitute into the PATTERN with the altered arguments.  */


gcc-patches专业PPT与Excel的使用

2011-10-02 Thread 请转有关人事
企业白领核心办公技能(PPT+Excel)

时间地点:2011年10月20-21日 北京
时间地点:2011年10月22-23日 深圳
时间地点:2011年10月28-29日 上海
费用:2600元/人(提供讲义、午餐、发票、茶点等)
授课对象:总经理,各部门主管,财务部、市场部、营销部等相关部门工作人员

咨询电话:020-80560638;020-85917945 谢小姐(不需要此类信件请回复电邮至chinammc2...@126.com退信)
---
PPT课程赠送数十个精美PPT模板及数百个各类精美图示。
所有课程均可获赠BladeOffice工具箱,工具箱的部分介绍见本文末尾。
陈剑老师每个季度更新一次Excle-PPT课程大纲,与之配套的BladeOffice工具也将同步升级,今后的课程将采
用BladeOffice的版本号作为课程编号以体现更新的情况。
课程大纲:
第一天专业幻灯片制作技术
一、从案例看幻灯片制作理念
1.幻灯片案例一:为什么这个幻灯片有图片有动画还是很难看?
2.幻灯片案例二:看看某世界500强企业的副总裁的幻灯片是怎么做的
3.幻灯片案例三:出自联合国某机构的幻灯片,看看他们是如何表现严肃话题的
4.幻灯片案例四:曾经是某政府要员的幻灯片,看看他是怎么打动观众的
二、打好基础是第一步!
1.通过一个小测试,看看你的制作水平如何 
2.来几个简单的例子,让你触类旁通,学会150多个形状的使用方法
3.再演练几个精彩的案例,反射、辉光、柔化边缘、扭曲、棱台和 3-D 旋转*,都可以学到
4.艺术字、彩虹字、图案文字样样精通
三、玩转素材,增强画面表现力
1.快速剪裁照片,获取所需要的素材
2.如何给照片/图片增加华丽的镜框效果
3.精确的素材剪辑技巧,你也可以变超人
4.压缩图片尺寸,使40M的文件变成6M
5.图片叠加的组合效果
四、图示的魅力,SmartArt应用技巧
1.从枯燥文字到精美图示的伟大跨越
2.SmartART效果的初体验
3.从效果到配色,SmartART面面观
4.教你玩转SmartART,原来SmartArt还可以这样变,快来创建属于你自己的SmartArt
五、关注整体效果,了解排版的要点
1.什么是版式,对幻灯片的制作有什么帮助?
2.为什么需要参考线?
3.版式设计的一个中心,5个基本点 
4.母板的功能及范例演示 
5.幻灯片制作的加法原则和减法原则
6.大家来找茬,看看如何改进这些幻灯片 
六、观众的眼球你做主,今天你动画了没?
1.瞧瞧四种动画类型的对比
2.看看动画是如何使一个复杂的画面变得简单
3.让优美的文字似水流淌
4.我家的图表会跳舞 
5.动画也会过山车 
6.音乐响起来
7.把网站首页动画搬到PPT里
8.很好很强大的一个动画实例
七、给观众点color see see,颜色的应用要点
1.三基色原理和Powerpoint的颜色体系
2.与公司CI设计配套的颜色设计
3.配色的三项基本原则
4.配色方案及应用技巧
5.系统配色盘、第三方配色盘的应用
6.如何模仿媒体的配色方案
   
第二天Excel函数和统计特训
一、数据输入的技巧
1.什么样的表格更容易分析和统计?
2.如何简化输入重复性的文字
3.如何设计有自验证功能的表格模板
二、公式基础
1.如何使用Bladeoffice工具快速浏览和查找函数
2.灵活引用单元格
3.插入函数的时候如何查看参数功能
4.为什么微软说掌握数组公式才能成为Excel高手
5.如何使公式更优美并且易于理解
三、逻辑函数是业务建模的基础
1.使用IF函数实现逻辑判断的案例
2.灵活使用与、或、非逻辑解决多条件判断
3.如何分层实现复杂的逻辑
四、文本函数
1.随意抽取文本的一部分
2.随意组合文本
3.将文本转换成所需其他类型的数据
4.利用文本函数实现数据可视化
五、使表格变得优美
1.为什么表格中会出现#DIV、#NAME、#N/A
2.如何避免出现#错误,是表格变得干净
六、应用查找函数简化工作
1.如何根据关键字在另一个表中查找数据
2.如何根据多个关键字在另一个表中查找匹配项
3.如何利用公式自动处理绩效考核评定
4.不用学习编程也可以写一个数据查询程序
5.利用查找函数实现数据自动录入
七、时间函数应用
1.由日期数据中抽取年月日时间数据
2.根据入职时间自动计算工龄
3.根据身份证自动计算年龄
4.计算两个日期之间有多少工作日
5.设置时间的显示格式
八、财务函数
1.等额本金和等额本息贷款方式的本金和利息计算
2.固定资产折旧的计算方法
3.如何计算内部收益率
4.如何计算投资回报的边际数据
九、常用统计函数和统计方法
1.计算符合条件的记录数量
2.如何实现多条件分类汇总
3.Excel2007新增统计函数
4.利用数组公式实现快速的频数分析
5.利用数组公式实现快速多条件汇总
十、数据透视表应用大全
1.如何制作层叠表
2.如何制作交叉表
3.多级分类汇总
4.动态数据过滤
5.数据在年、季度、月、日不同时间级别上的汇总
6.自动计算各种统计指标
a)平均销售额
b)销售差异度
c)百分比
d)自定义指标
7.数据可视化分段和频数统计
8.如何将透视表根据某分类字段自动分割成多个工作表
9.如何生成数据透视图,并进行动态分析
十一、数据表的安全性
1.如何保护公式不被误修改
2.如何设置可编辑区域和不可编辑区域
3.如何设置文档访问密码
设置工作表隐藏

讲师介绍: 陈剑老师: 信息化专家、IPMA认证项目经理、MCSE、MCDBA、经济分析师,从业经验丰富,
曾主持开发大型政府业务系统、银行办公系统、电信业务系统、工业自动化控制系统等,负责过OA、
ERP、BI系统的集成与实施。历任项目经理,技术总监,副总经理等职务、熟悉整公司营运管理,财
务管理、信息化管理、人事行政管理工作。
陈剑老师擅长的课程有:
《实用企业数据统计和分析技术》
《专业幻灯片和图表制作技术》
《现代项目管理》
《Excel、Access和POWERPOINT在管理中的实战运用》
陈老师近期培训企业:东方航空、攀岭鞋业、福田医疗、银雁金融、哈尔滨移动、大连商品交易所、
泉林包装、卓志物流、佛山移动、东风置业、金域医疗检验、交银施罗德、中钞特种防伪、金茂集
团、海烟物流、中国测试技术研究院、东风汽车、雅芳、贝亲婴儿用品、奇正藏药、达丰电脑、瑞
立远东、中新图锐、喜莱德六晖橡胶金属、嘉驰国际贸易、嘉兴福茂、蓓嘉日东时装、立顺实业、
敦朴光电、苏州万通、海立(集团)、上海轮胎橡胶、伟尔沃曼机械、宝馨科技精密机械、亚洲纸
业、亿道电子、纳贝斯克食品、南京广厦置业(集团)、天津嘉驰、上海汽轮机、伟巴斯特车顶供
暖系统等企业。
 ---
《企业白领核心办公技能(PPT+Excel)高级应用》报名回执表(请传真020-62351156)

参 会 单 位 名 称:___

参 加 地 点: 口上海  口深圳口北京

联系人:__电话:传真:

邮件:__ 参 会 人 数:_人 费 用 ¥:_元 

参 会 人:___所 任 职 务:移 动 电 话:_ 

参 会 人:___所 任 职 务:移 动 电 话:_ 

参 会 人:___所 任 职 务:移 动 电 话:_ 

参 会 人:___所 任 职 务:移 动 电 话:_ 

付款方式(请选择打“√”): □1、现金 □2、转帐 □3、电汇 

备注:请您把报名回执回传我司,为确保您报名无误,请您再次电话(020-80560638)确认!


Re: [PATCH] Add sparc VIS 2.0 builtins, intrinsics, and option to control them.

2011-10-02 Thread David Miller
From: Richard Henderson 
Date: Fri, 30 Sep 2011 14:03:52 -0700

> On 09/30/2011 12:59 AM, David Miller wrote:
>> 
>>[ VIS 2.0 bmask patterns ]
>
> I think this is wrong.  I think you want to model this as
> 
>   [(set (match_operand:DI 0 "register_operand" "=r")
> (plus:DI (match_operand:DI 1 "register_or_zero_operand" "rJ")
>  (match_operand:DI 2 "register_or_zero_operand" "rJ")))
>(set (zero_extract:DI
> (reg:DI GSR_REG)
> (const_int 32)
> (const_int 32))
> (plus:DI (match_dup 1) (match_dup 2)))]

Yep, perfect for 64-bit.

> (3) I realize this version makes things difficult for 32-bit mode.
> There, I think you may have to settle for an unspec.  And perhaps
> the possible benefit of Properly representing the GSR change isn't
> that helpful.  In which case:
> 
> (set (reg:DI GSR_REG)
>(unspec:DI [(match_dup 1) (match_dup 2) (reg:DI GSR_REG)]
>   UNSPEC_BMASK))

Actually, can't we just use a (zero_extend:DI (plus:SI ...)) for the
32-bit case?  It seems to work fine.

>> +(define_insn "bshuffle_vis"
>> +  [(set (match_operand:V64I 0 "register_operand" "=e")
>> +(unspec:V64I [(match_operand:V64I 1 "register_operand" "e")
>> +  (match_operand:V64I 2 "register_operand" "e")]
>> + UNSPEC_BSHUFFLE))
>> +   (use (reg:SI GSR_REG))]
> 
> Better to push the use of the GSR_REG into the unspec, and not leave
> it separate in the parallel.

This is actually just a non-constant vec_merge, and even though the internals
documentation says that the 'items' operand has to be a const_int, the compiler
actually doesn't care.

The only two places vec_merge is even inspected semantically by the
compiler is in the RTX simplifier where it already checks explicitly
for const_int, and in dwarf2out.c where it just ignores the vec_merge
construct entirely since it can't be represented.

So if we just code this as:

(set (match_operand:V64I 0 "register_operand" "=e")
 (vec_merge:V64I (match_operand:V64I 2 "register_operand" "e")
 (match_operand:V64I 1 "register_operand" "e")
 (zero_extract:DI (reg:DI GSR_REG)
  (const_int 32)
  (const_int 32

it would mostly work.  The only problem with this is that we provide
the bshuffle builtin for DI mode just as we do for the faligndata
instruction.  simplify-rtx.c isn't happy seeing a non-vector mode
and VECTOR_MODES () in a foo-modes.def file won't generate modes
like V1DI and V1SI.

I guess I could explicitly generate those single entry vector modes
like i386 does.

But, as-is, the above pattern does work for all the "actual" vector
modes.

More generally, rtl.def is non-specific about what operand 2 of a
vec_merge has to be, it just says a bitmask, it doesn't say that it
has to be a const_int.

I think we should explicitly allow non-const_int objects here, and state
so in the internals documentation.


[PATCH] Maintain order of LTO sections

2011-10-02 Thread Andi Kleen
From: Andi Kleen 

Currently when reading in LTO sections from ld -r files they can
get randomly reordered based on hash tables and random IDs.
This causes reordering later when the final code is generated and
also makes crashes harder to reproduce.

This patch maintains explicit lists based on the input order and uses
those lists to preserve that order when starting the rest of the
LTO passes.

This is the first step to working -fno-toplevel-reorder for
LTO. But this needs more changes because the LTO partitioner
can still reorder.

This add two lists: one for the section and another one for
the file_decl_datas. This is needed because the sections are
walked twice through different data structures.

In addition some code becomes slightly cleaner because we don't need
to pass state through abstract callbacks anymore, but
can just use direct type safe calls.

Passes LTO bootstrap and testsuite on x86_64-linux. Ok?

gcc/lto/:

2011-10-02   Andi Kleen 

* lto-object.c (lto_obj_add_section_data): Add list.
(lto_obj_add_section): Fill in list.
(ltoobj_build_section_table): Pass through list.
* lto.c (file_data_list): Declare.
(create_subid_section_table): Pass arguments directly.
Fill in list of file_datas.
(lwstate): Delete.
(lto_create_files_from_ids): Pass in direct arguments.
Don't maintain list.
(lto_file_read): Use explicit section and file data lists.
(lto_read_all_file_options): Pass in section_list.
* lto.h (lto_obj_build_section_table): Add list.
(lto_section_slot): Add next.
(lto_section_list): Declare.

diff --git a/gcc/lto/lto-object.c b/gcc/lto/lto-object.c
index 3be58de..daf3bd0 100644
--- a/gcc/lto/lto-object.c
+++ b/gcc/lto/lto-object.c
@@ -204,6 +204,8 @@ struct lto_obj_add_section_data
   htab_t section_hash_table;
   /* The offset of this file.  */
   off_t base_offset;
+  /* List in linker order */
+  struct lto_section_list *list;
 };
 
 /* This is called for each section in the file.  */
@@ -218,6 +220,7 @@ lto_obj_add_section (void *data, const char *name, off_t 
offset,
   char *new_name;
   struct lto_section_slot s_slot;
   void **slot;
+  struct lto_section_list *list = loasd->list;
 
   if (strncmp (name, LTO_SECTION_NAME_PREFIX,
   strlen (LTO_SECTION_NAME_PREFIX)) != 0)
@@ -228,12 +231,21 @@ lto_obj_add_section (void *data, const char *name, off_t 
offset,
   slot = htab_find_slot (section_hash_table, &s_slot, INSERT);
   if (*slot == NULL)
 {
-  struct lto_section_slot *new_slot = XNEW (struct lto_section_slot);
+  struct lto_section_slot *new_slot = XCNEW (struct lto_section_slot);
 
   new_slot->name = new_name;
   new_slot->start = loasd->base_offset + offset;
   new_slot->len = length;
   *slot = new_slot;
+
+  if (list != NULL)
+{
+  if (!list->first)
+list->first = new_slot;
+  if (list->last)
+list->last->next = new_slot;
+  list->last = new_slot;
+}
 }
   else
 {
@@ -248,7 +260,7 @@ lto_obj_add_section (void *data, const char *name, off_t 
offset,
the start and size of each section in the .o file.  */
 
 htab_t
-lto_obj_build_section_table (lto_file *lto_file)
+lto_obj_build_section_table (lto_file *lto_file, struct lto_section_list *list)
 {
   struct lto_simple_object *lo = (struct lto_simple_object *) lto_file;
   htab_t section_hash_table;
@@ -261,6 +273,7 @@ lto_obj_build_section_table (lto_file *lto_file)
   gcc_assert (lo->sobj_r != NULL && lo->sobj_w == NULL);
   loasd.section_hash_table = section_hash_table;
   loasd.base_offset = lo->base.offset;
+  loasd.list = list;
   errmsg = simple_object_find_sections (lo->sobj_r, lto_obj_add_section,
&loasd, &err);
   if (errmsg != NULL)
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 778e33e..a77eeb4 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -1052,6 +1052,12 @@ lto_resolution_read (splay_tree file_ids, FILE 
*resolution, lto_file *file)
 }
 }
 
+/* List of file_decl_datas */
+struct file_data_list
+  {
+struct lto_file_decl_data *first, *last;
+  };
+
 /* Is the name for a id'ed LTO section? */
 
 static int 
@@ -1068,11 +1074,10 @@ lto_section_with_id (const char *name, unsigned 
HOST_WIDE_INT *id)
 /* Create file_data of each sub file id */
 
 static int 
-create_subid_section_table (void **slot, void *data)
+create_subid_section_table (struct lto_section_slot *ls, splay_tree file_ids,
+struct file_data_list *list)
 {
   struct lto_section_slot s_slot, *new_slot;
-  struct lto_section_slot *ls = *(struct lto_section_slot **)slot;
-  splay_tree file_ids = (splay_tree)data;
   unsigned HOST_WIDE_INT id;
   splay_tree_node nd;
   void **hash_slot;
@@ -1095,6 +1100,13 @@ create_subid_section_table (void **slot, void *data)
   file_data->id = id;
   file_data->section_hash_table = lto_obj_create_section_h