Re: [Patch, fortran] Use memcmp for string comparisons a bit more

2013-03-30 Thread Thomas Koenig

Hi Tobias,



Somehow the commas and parentheses look odd. Shouldn't that be, e.g.,
or (for kind=4 strings) the ...?


I committed as rev 197261 and 197262, with a slightly better worded
ChangeLog entry :-)

The wording is now

If the strings
compared have constant and equal lengths and
the strings are kind=1, or, for kind=4 strings,
the test is for (in)equality, use memcmp().

Thomas


Re: [ping] Re: [patch] [libffi] do not install libffi library, headers and documentation

2013-03-30 Thread Matthias Klose
Am 26.03.2013 21:48, schrieb Anthony Green:
 For what it's worth, this patch is fine by me.  I had originally
 proposed that GCC not install these bits.

now applied on trunk and the 4.8 branch.

 As far as maintainers go, I thought that I was once listed in the
 MAINTAINERS file.  Feel free to add Andrew Haley and/or myself.

I didn't hear back form Andrew.  Could you do this yourself, maybe updating
libffi on trunk to the 3.0.13 release? ;)

  Matthias



Re: [RTL] Canonicalize commutative operations more

2013-03-30 Thread Marc Glisse

On Wed, 27 Mar 2013, Eric Botcazou wrote:


This patch passes bootstrap+testsuite on x86_64-linux-gnu. Using the
opposite arbitrary order in compare_commutative_operands_precedence
(exchange x and y in the line with GET_CODE) passes as well. The
simplify-rtx bit is because I get an infinite recursion otherwise.
Surprisingly, that infinite recursion occurs only in var-tracking, and
only for a single file in bootstrap+testsuite (not the same one depending
on the arbitrary order). I am not sure that is the best place to break the
recursion, but it seems to work.

I don't really expect the patch to be accepted as is, but it seems good
enough to start the conversation.


I'm rather with Jakub here, I think that arbitrary canonicalization as the one
proposed here will probably be worse than no canonicalization in practice,
because it will generate much shuffling.  If you need more canonicalization,
then why not propose new, precise canonicalization rules?


Well, the goal was to have arbitrary canonicalization for all cases where 
precise rules are not already provided. In (a8)|(b24), there is no 
obvious reason why lshift should have higher or lower priority than 
rshift, but we don't want to have to write patterns with both orders in 
the target .md files. In v[0]+v[1] (v is a V2DF), it is likewise 
preferable if we know in which order the operands will appear, but I don't 
care what that order is (note that ordering this one requires a refinement 
that I didn't include in this first version of the patch). And this way we 
don't have to refine the order all the time, we just check what order this 
arbitrary rule generates and write the pattern accordingly.


I am not sure about adding just a few rules. If I just say that lshift is 
stronger than rshift, the relation is not an order (transitive) anymore. 
And it might already have some of the drawbacks you and Jakub fear (I 
don't have a good understanding of those, I may be wrong).


If there is a nice way to instead try permutations (note that for a 
pattern involving k commutative operations, there are 2^k versions), I am 
just as happy with that.


By the way, even if we don't take the canonicalization (just ignore the 
line comparing GET_CODEs), do we still want the refactoring that this 
patch brings, or is the current interface better?


--
Marc Glisse


[wwwdocs] Remove i960 from readings.html

2013-03-30 Thread Gerald Pfeifer
So, on the plus side, Intel's webmaster added a redirect from the old
http://edc.intel.com/Platforms/Previous/Processors/i960/ to a new
address.

On the funny side, that new address is bizzarely long:

http://www.intel.com/content/www/us/en/intelligent-systems/previous-generation/intel-i960-high-performance-32-bit-embedded-risc-processors.html

Either way, i960 was removed from GCC in 2004, so we can safely remove
this section on readings.html.

Applied.

Gerald

Index: readings.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/readings.html,v
retrieving revision 1.223
diff -u -3 -p -r1.223 readings.html
--- readings.html   28 Mar 2013 14:21:34 -  1.223
+++ readings.html   30 Mar 2013 12:51:50 -
@@ -716,12 +716,6 @@ Below is the list of ports that GCC used
   br /Manufacturer: ATamp;T
   /li
  
-  lii960
-  br /Manufacturer: Intel
-  br /a 
href=http://edc.intel.com/Platforms/Previous/Processors/i960/;i960 home 
page/a
-  br /GDB includes a simulator.
-  /li
- 
   lim88k
   br /Manufacturer: Motorola
   /li


Re: [patch] Stop using JUMP_INSN for jump table data

2013-03-30 Thread Jeff Law

On 03/29/2013 05:15 PM, Steven Bosscher wrote:

Hello,

GCC uses fake JUMP_INSNs as placeholders for jump table data. These
JUMP_INSNs have an ADDR_VEC or ADDR_DIFF_VEC as PATTERN, but they are
not real instructions and they are not inside basic blocks. This
results in special-casing JUMP_P insns in various places throughout
the compiler.

The attached patch adds a new object, JUMP_TABLE_DATA, to hold jump
table data. All remaining JUMP_P insns will be real insns, which helps
simplify things a bit -- or at least make things more intuitive.

A number of back ends, and probably some code in the middle end (not
sure), uses the *active_insn* family of functions while traversing
the insn chain (instead of the CFG) and expect jump table data to be
considered an active insn. Therefore, JUMP_TABLE_DATA is an RTX_INSN
for the moment, but I intend to make it an RTX_EXTRA before stage1
ends.

Bootstrapped and tested on powerpc64-unknown-linux-gnu and on
x86_64-unknown-linux-gnu.
OK for trunk?

OK.

Note that on at least one target, the jump table data is actual code 
(PA).  I don't think it makes a difference at this stage, but please 
keep that in mind as you continue this work.


Jeff



[wwwdocs] projects/tree-ssa/index.html -- remove broken link

2013-03-30 Thread Gerald Pfeifer
This now redirects to the linux.com main page (which shows the
relevance of even adjust permanent redirects).

Refer to the proceedings on gcc.gnu.org instead.

Gerald

Index: index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/tree-ssa/index.html,v
retrieving revision 1.42
diff -u -3 -p -r1.42 index.html
--- index.html  29 Dec 2012 00:24:56 -  1.42
+++ index.html  30 Mar 2013 13:02:23 -
@@ -64,9 +64,8 @@ href=#cytron.ea-911/a].  The implem
 h3a name=documentationDocumentation/a/h3
 
 pA high-level overview of GENERIC/GIMPLE and the SSA implementation may
-be found in the a
-href=http://www.linux.org.uk/~ajh/gcc/gccsummit-2003-proceedings.pdf;
-Proceedings of the 2003 GCC Developers Summit/a (pages 171-193)./p
+be found in the a href=ftp://gcc.gnu.org/pub/gcc/summit/2003/;Proceedings
+of the 2003 GCC Developers Summit/a (pages 171-193)./p
 
 pInternal design documentation is also available in the texinfo
 documentation (codedoc/gccint.info/code in GCC's build directory)./p


Re: [patch] Stop using JUMP_INSN for jump table data

2013-03-30 Thread Steven Bosscher
On Sat, Mar 30, 2013 at 2:02 PM, Jeff Law wrote:

 OK.

Thanks for the quick review!

 Note that on at least one target, the jump table data is actual code (PA).
 I don't think it makes a difference at this stage, but please keep that in
 mind as you continue this work.

Right, the PA explodes table jumps to individual jumps in
pa_reorg(). I actually tested on PA too (on my US$15 bargain HP
visualize J5600 workstation :-) and things work just fine. I'm more
concerned about some of the back ends that use
{next,prev}_{real,active}_insn to find jump table data after a
JUMP_INSN instead of using tablejump_p, but we'll see and I'll
obviously be on the hook to fix any fall-out.

Ciao!
Steven


[wwwdocs] comeaucomputing.com is gone

2013-03-30 Thread Gerald Pfeifer
...and this adjust the gcc.gnu.org site accordingly.  Applied.

Jonathan, you have another link at
http://gcc.gnu.org/onlinedocs/libstdc++/manual/appendix_contributing.html
How about reducing that section in size and refer to 
http://gcc.gnu.org/contribute.html ?

Gerald

Index: faq.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/faq.html,v
retrieving revision 1.216
diff -u -3 -p -r1.216 faq.html
--- faq.html26 Aug 2012 10:40:09 -  1.216
+++ faq.html30 Mar 2013 13:12:22 -
@@ -14,8 +14,7 @@
 pThis FAQ tries to answer specific questions concerning GCC. For
 general information regarding C, C++, resp. Fortran please check the 
 a href=http://c-faq.com/;comp.lang.c FAQ/a,
-a href=http://www.comeaucomputing.com/csc/faq.html;comp.std.c++
-FAQ/a,
+a href=http://www.parashift.com/c++-faq/;C++ FAQ/a,
 and the a href=http://www.fortran.com/fortran/info.html;Fortran
 Information page/a./p
 
Index: readings.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/readings.html,v
retrieving revision 1.224
diff -u -3 -p -r1.224 readings.html
--- readings.html   30 Mar 2013 12:53:50 -  1.224
+++ readings.html   30 Mar 2013 13:12:22 -
@@ -366,7 +366,6 @@ Intelreg;64 and IA-32 Architectures Sof
 ul
   lia href=http://www.open-std.org/jtc1/sc22/wg21/;ISO Committee homepage
   (defects list, etc)/a/li
-  lia href=http://www.comeaucomputing.com/iso/;Comeau reflector/a/li
 /ul
 
 ul


Re: [patch] Stop using JUMP_INSN for jump table data

2013-03-30 Thread Jeff Law

On 03/30/2013 07:10 AM, Steven Bosscher wrote:


Right, the PA explodes table jumps to individual jumps in
pa_reorg().
Yup.  One of the many things I'd like to forget.  Unlike other jumps on 
the PA, we can't nullify the delay slot to save space.  The jump must 
always be 2 instructions.  So we have to have a separate pattern, even 
though it looks like the normal jump.  Ugh.




I'm more
concerned about some of the back ends that use
{next,prev}_{real,active}_insn to find jump table data after a
JUMP_INSN instead of using tablejump_p, but we'll see and I'll
obviously be on the hook to fix any fall-out.
I won't be surprised if we find this stuff, but I don't think there'll 
be anything inherently difficult about fixing it.


jeff




Re: [rtl, i386] vec_merge simplification

2013-03-30 Thread Marc Glisse

On Wed, 27 Mar 2013, Eric Botcazou wrote:


OK, modulo a few nits:


Thanks, here is a version taking into account all your comments, and which 
still passes bootstrap+testsuite on x86_64-linux-gnu. I am not completely 
sure if there is a point checking !side_effects_p (op1) after rtx_equal_p 
(op0, op1), but I am still doing it as it seems safe.


Uros, are you ok with the testsuite part?


2013-03-30  Marc Glisse  marc.gli...@inria.fr

gcc/
* simplify-rtx.c (simplify_binary_operation_1) VEC_SELECT:
Handle VEC_MERGE.
(simplify_ternary_operation) VEC_MERGE: Use unsigned HOST_WIDE_INT
for masks. Test for side effects. Handle nested VEC_MERGE. Handle
equal arguments.

gcc/testsuite/
* gcc.target/i386/merge-1.c: New testcase.
* gcc.target/i386/avx2-vpblendd128-1.c: Make it non-trivial.

--
Marc GlisseIndex: simplify-rtx.c
===
--- simplify-rtx.c  (revision 197265)
+++ simplify-rtx.c  (working copy)
@@ -3553,20 +3553,45 @@ simplify_binary_operation_1 (enum rtx_co
  offset -= vec_size;
  vec = XEXP (vec, 1);
}
  vec = avoid_constant_pool_reference (vec);
}
 
  if (GET_MODE (vec) == mode)
return vec;
}
 
+  /* If we select elements in a vec_merge that all come from the same
+operand, select from that operand directly.  */
+  if (GET_CODE (op0) == VEC_MERGE)
+   {
+ rtx trueop02 = avoid_constant_pool_reference (XEXP (op0, 2));
+ if (CONST_INT_P (trueop02))
+   {
+ unsigned HOST_WIDE_INT sel = UINTVAL (trueop02);
+ bool all_operand0 = true;
+ bool all_operand1 = true;
+ for (int i = 0; i  XVECLEN (trueop1, 0); i++)
+   {
+ rtx j = XVECEXP (trueop1, 0, i);
+ if (sel  (1  UINTVAL (j)))
+   all_operand1 = false;
+ else
+   all_operand0 = false;
+   }
+ if (all_operand0  !side_effects_p (XEXP (op0, 1)))
+   return simplify_gen_binary (VEC_SELECT, mode, XEXP (op0, 0), 
op1);
+ if (all_operand1  !side_effects_p (XEXP (op0, 0)))
+   return simplify_gen_binary (VEC_SELECT, mode, XEXP (op0, 1), 
op1);
+   }
+   }
+
   return 0;
 case VEC_CONCAT:
   {
enum machine_mode op0_mode = (GET_MODE (trueop0) != VOIDmode
  ? GET_MODE (trueop0)
  : GET_MODE_INNER (mode));
enum machine_mode op1_mode = (GET_MODE (trueop1) != VOIDmode
  ? GET_MODE (trueop1)
  : GET_MODE_INNER (mode));
 
@@ -5217,21 +5242,21 @@ simplify_const_relational_operation (enu
OP0, OP1, and OP2.  OP0_MODE was the mode of OP0 before it became
a constant.  Return 0 if no simplifications is possible.  */
 
 rtx
 simplify_ternary_operation (enum rtx_code code, enum machine_mode mode,
enum machine_mode op0_mode, rtx op0, rtx op1,
rtx op2)
 {
   unsigned int width = GET_MODE_PRECISION (mode);
   bool any_change = false;
-  rtx tem;
+  rtx tem, trueop2;
 
   /* VOIDmode means infinite precision.  */
   if (width == 0)
 width = HOST_BITS_PER_WIDE_INT;
 
   switch (code)
 {
 case FMA:
   /* Simplify negations around the multiplication.  */
   /* -a * -b + c  =  a * b + c.  */
@@ -5363,47 +5388,85 @@ simplify_ternary_operation (enum rtx_cod
  else if (temp)
return gen_rtx_IF_THEN_ELSE (mode, temp, op1, op2);
}
}
   break;
 
 case VEC_MERGE:
   gcc_assert (GET_MODE (op0) == mode);
   gcc_assert (GET_MODE (op1) == mode);
   gcc_assert (VECTOR_MODE_P (mode));
-  op2 = avoid_constant_pool_reference (op2);
-  if (CONST_INT_P (op2))
+  trueop2 = avoid_constant_pool_reference (op2);
+  if (CONST_INT_P (trueop2))
{
-  int elt_size = GET_MODE_SIZE (GET_MODE_INNER (mode));
+ int elt_size = GET_MODE_SIZE (GET_MODE_INNER (mode));
  unsigned n_elts = (GET_MODE_SIZE (mode) / elt_size);
- int mask = (1  n_elts) - 1;
+ unsigned HOST_WIDE_INT mask = ((unsigned HOST_WIDE_INT) 1  n_elts)
+   - 1;
+ unsigned HOST_WIDE_INT sel = UINTVAL (trueop2);
 
- if (!(INTVAL (op2)  mask))
+ if (!(sel  mask)  !side_effects_p (op0))
return op1;
- if ((INTVAL (op2)  mask) == mask)
+ if ((sel  mask) == mask  !side_effects_p (op1))
return op0;
 
- op0 = avoid_constant_pool_reference (op0);
- op1 = avoid_constant_pool_reference (op1);
- if (GET_CODE (op0) == CONST_VECTOR
-  GET_CODE (op1) == CONST_VECTOR)
+ rtx 

[PATCH] Add script to contrib to format email body and patch for submission

2013-03-30 Thread Tom de Vries
Ian,

this patch adds a script to contrib that formats an email body and a patch for
submission to gcc-patches.

This email was generated using the script, in the following way:
...
#!/bin/bash

cat compose-body-patch.header \
(./contrib/compose-body-patch.py \
(cat compose-body-patch.body
  echo
  cat compose-body-patch.log) \
compose-body-patch.patch) \
 message.txt
...

OK for trunk?

Thanks,
- Tom

2013-03-30  Tom de Vries  t...@codesourcery.com

* compose-body-patch.py: New script.
Index: contrib/compose-body-patch.py
===
--- /dev/null (new file)
+++ contrib/compose-body-patch.py (revision 0)
@@ -0,0 +1,68 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2013 Free Software Foundation, Inc.
+#
+# This script 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 script combines an email body and one or more patches into a MIME
+# multipart email, adhering to the style required by
+# http://gcc.gnu.org/contribute.html#patches
+#
+# The email can be sent by adding some more header fields and running sendmail.
+# F.i.:
+#   rm -f header.txt
+#   for f in From To Subject; do
+#   read -p $f:   line
+#   echo $f: $line  header.txt
+#   done
+#   compose-body-patch.py improvement.txt improvement.patch  email.txt
+#   cat header.txt email.txt | unix2dos | sendmail -t -oi
+# 
+# The unix2dos for email.txt may be necessary because there's a bug in some
+# versions of python that causes the result of msg.as_string() below not to have
+# the CRLF EOL format required by MIME
+# ( discussed at http://stackoverflow.com/questions/3086860
+#   how-do-i-generate-a-multipart-mime-message-with-correct-crlf-in-python ).
+# But since all parts are text-based, we can work around that bug using
+# unix2dos.
+# Note that if email.txt has the right CRLF EOL format, the unix2dos for
+# header.txt is still necessary because sending emails with mixed EOL style may
+# not work.
+#
+# FWIW, if both header.txt and email.txt are in unix EOL format, this may also
+# work:
+#   cat header.txt email.txt | sendmail -t -oi
+# but YMMV.
+
+from email.mime.text import MIMEText
+from email.mime.multipart import MIMEMultipart
+import sys
+import os
+
+if len(sys.argv)  3:
+print Usage: %s body patch+ % os.path.basename(sys.argv[0])
+sys.exit (1)
+
+msg = MIMEMultipart('multipart')
+
+for x in range(1, len(sys.argv)):
+
+filename = sys.argv[x]
+
+fp = open(filename, 'r')
+txt = fp.read()
+fp.close()
+
+if x == 1:
+part = MIMEText(txt, 'plain')
+else:
+part = MIMEText(txt, 'x-patch')
+part.set_param(name, filename)
+part.add_header('Content-Disposition', 'inline; filename=%s' % filename)
+
+msg.attach(part)
+
+print msg.as_string()

Property changes on: contrib/compose-body-patch.py
___
Added: svn:executable
   + *



[patch][doc] document JUMP_TABLE_DATA

2013-03-30 Thread Steven Bosscher
Hello,

Where necessary, replace jump_insn with jump_table_data or add
jump_table_data to lists documenting insns flags. Add documentation
for the jump_table_data object.

Committed as obvious.

Ciao!
Steven


JUMP_TABLE_DATA_doc.diff
Description: Binary data


Re: [PATCH][IRA] Analysis of register usage of functions for usage by IRA.

2013-03-30 Thread Tom de Vries
On 29/03/13 13:54, Tom de Vries wrote:
 I split the patch up into 10 patches, to facilitate further review:
 ...
 0001-Add-command-line-option.patch
 0002-Add-new-reg-note-REG_CALL_DECL.patch
 0003-Add-implicit-parameter-to-find_all_hard_reg_sets.patch
 0004-Add-TARGET_FN_OTHER_HARD_REG_USAGE-hook.patch
 0005-Implement-TARGET_FN_OTHER_HARD_REG_USAGE-hook-for-ARM.patch
 0006-Collect-register-usage-information.patch
 0007-Use-collected-register-usage-information.patch
 0008-Enable-by-default-at-O2-and-higher.patch
 0009-Add-documentation.patch
 0010-Add-test-case.patch
 ...
 I'll post these in reply to this email.
 

Something went wrong with those emails, which were generated.

I tested the emails by sending them to my work email, where they looked fine.
I managed to reproduce the problem by sending them to my private email.
It seems the problem was inconsistent EOL format.

I've written a python script to handle composing the email, and posted it here
using that script: http://gcc.gnu.org/ml/gcc-patches/2013-03/msg01311.html.
Given that that email looks ok, I think I've addressed the problems now.

I'll repost the patches. Sorry about the noise.

Thanks,
- Tom



Re: SLP for vectors

2013-03-30 Thread Marc Glisse

On Tue, 29 Jan 2013, Richard Biener wrote:


So yes, handling BIT_FIELD_REF in the vectorizer looks like the correct
way to do - but mind that you should constrain the BIT_FIELD_REFs you
allow (I suppose in the end that's properly done by other part of the analysis).


Does that mean adding something like this to vectorizable_store? (and 
similarly to *_load)


if (VECTOR_TYPE_P (TREE_TYPE (scalar_dest)))
  return false;

Or maybe this?

if (TREE_CODE (scalar_dest) == BIT_FIELD_REF
 !VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (scalar_dest, 0)))
  return false;

Or checking that the type of the BIT_FIELD_REF is the element type of the 
vector type it accesses?


I am not sure what restrictions are needed.


I suppose the data-ref analysis parts are not strictly required,


I removed the dr_analyze_indices part, which was indeed not necessary. The 
tree-vect-data-refs.c part is useless (the base object is not computed for 
SLP) but shouldn't hurt.


The current patch is attached (passed bootstrap+testsuite a week ago).
Are there some parts of this that could go in?


2013-03-30  Marc Glisse  marc.gli...@inria.fr

* tree-vect-stmts.c (vectorizable_store): Accept BIT_FIELD_REF.
(vectorizable_load): Likewise.
* tree-vect-slp.c (vect_build_slp_tree): Likewise.
* tree-vect-data-refs.c (vect_create_data_ref_ptr): Handle VECTOR_TYPE.
* tree-flow-inline.h (get_addr_base_and_unit_offset_1): Handle
BIT_FIELD_REF.

testsuite/
* gcc.dg/vect/bb-slp-31.c: New file.

--
Marc GlisseIndex: tree-vect-data-refs.c
===
--- tree-vect-data-refs.c   (revision 197265)
+++ tree-vect-data-refs.c   (working copy)
@@ -3565,20 +3565,22 @@ vect_create_data_ref_ptr (gimple stmt, t
 
   if (dump_enabled_p ())
 {
   tree dr_base_type = TREE_TYPE (DR_BASE_OBJECT (dr));
   dump_printf_loc (MSG_NOTE, vect_location,
create %s-pointer variable to type: ,
tree_code_name[(int) TREE_CODE (aggr_type)]);
   dump_generic_expr (MSG_NOTE, TDF_SLIM, aggr_type);
   if (TREE_CODE (dr_base_type) == ARRAY_TYPE)
 dump_printf (MSG_NOTE,   vectorizing an array ref: );
+  else if (TREE_CODE (dr_base_type) == VECTOR_TYPE)
+dump_printf (MSG_NOTE,   vectorizing a vector ref: );
   else if (TREE_CODE (dr_base_type) == RECORD_TYPE)
 dump_printf (MSG_NOTE,   vectorizing a record based array ref: );
   else
 dump_printf (MSG_NOTE,   vectorizing a pointer ref: );
   dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_BASE_OBJECT (dr));
 }
 
   /* (1) Create the new aggregate-pointer variable.
  Vector and array types inherit the alias set of their component
  type by default so we need to use a ref-all pointer if the data
Index: tree-vect-stmts.c
===
--- tree-vect-stmts.c   (revision 197265)
+++ tree-vect-stmts.c   (working copy)
@@ -3844,20 +3844,21 @@ vectorizable_store (gimple stmt, gimple_
   /* Is vectorizable store? */
 
   if (!is_gimple_assign (stmt))
 return false;
 
   scalar_dest = gimple_assign_lhs (stmt);
   if (TREE_CODE (scalar_dest) == VIEW_CONVERT_EXPR
is_pattern_stmt_p (stmt_info))
 scalar_dest = TREE_OPERAND (scalar_dest, 0);
   if (TREE_CODE (scalar_dest) != ARRAY_REF
+   TREE_CODE (scalar_dest) != BIT_FIELD_REF
TREE_CODE (scalar_dest) != INDIRECT_REF
TREE_CODE (scalar_dest) != COMPONENT_REF
TREE_CODE (scalar_dest) != IMAGPART_EXPR
TREE_CODE (scalar_dest) != REALPART_EXPR
TREE_CODE (scalar_dest) != MEM_REF)
 return false;
 
   gcc_assert (gimple_assign_single_p (stmt));
   op = gimple_assign_rhs1 (stmt);
   if (!vect_is_simple_use (op, stmt, loop_vinfo, bb_vinfo, def_stmt,
@@ -4378,20 +4379,21 @@ vectorizable_load (gimple stmt, gimple_s
   /* Is vectorizable load? */
   if (!is_gimple_assign (stmt))
 return false;
 
   scalar_dest = gimple_assign_lhs (stmt);
   if (TREE_CODE (scalar_dest) != SSA_NAME)
 return false;
 
   code = gimple_assign_rhs_code (stmt);
   if (code != ARRAY_REF
+   code != BIT_FIELD_REF
code != INDIRECT_REF
code != COMPONENT_REF
code != IMAGPART_EXPR
code != REALPART_EXPR
code != MEM_REF
TREE_CODE_CLASS (code) != tcc_declaration)
 return false;
 
   if (!STMT_VINFO_DATA_REF (stmt_info))
 return false;
Index: tree-vect-slp.c
===
--- tree-vect-slp.c (revision 197265)
+++ tree-vect-slp.c (working copy)
@@ -660,20 +660,21 @@ vect_build_slp_tree (loop_vec_info loop_
}
   else
{
  if (first_stmt_code != rhs_code
   (first_stmt_code != IMAGPART_EXPR
  || rhs_code != REALPART_EXPR)
   (first_stmt_code != REALPART_EXPR
  || rhs_code != IMAGPART_EXPR)

[PATCH][01/10] -fuse-caller-save - Add command line option

2013-03-30 Thread Tom de Vries
Vladimir,

This patch adds the -fuse-caller-save command line option.

Thanks,
  -Tom

2013-03-30  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* common.opt (fuse-caller-save): New option.
diff --git a/gcc/common.opt b/gcc/common.opt
index bdbd3b6..d29b0a0 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2549,4 +2549,8 @@ Create a position independent executable
 z
 Driver Joined Separate
 
+fuse-caller-save
+Common Report Var(flag_use_caller_save) Optimization
+Use caller save register across calls if possible
+
 ; This comment is to ensure we retain the blank line above.


[PATCH][03/10] -fuse-caller-save - Add implicit parameter to find_all_hard_reg_sets

2013-03-30 Thread Tom de Vries
Vladimir,

This patch adds an implicit parameter to find_all_hard_reg_sets.

Thanks,
  -Tom

2013-03-30  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* rtlanal.c (find_all_hard_reg_sets): Add bool implicit parameter and
handle.
* rtl.h (find_all_hard_reg_sets): Add bool parameter.
* haifa-sched.c (recompute_todo_spec, check_clobbered_conditions): Add
new argument to find_all_hard_reg_sets call.
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index c4591bfe..fe24d43 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -1271,7 +1271,7 @@ recompute_todo_spec (rtx next, bool for_backtrack)
 	  {
 	HARD_REG_SET t;
 
-	find_all_hard_reg_sets (prev, t);
+	find_all_hard_reg_sets (prev, t, true);
 	if (TEST_HARD_REG_BIT (t, regno))
 	  return HARD_DEP;
 	if (prev == pro)
@@ -3041,7 +3041,7 @@ check_clobbered_conditions (rtx insn)
   if ((current_sched_info-flags  DO_PREDICATION) == 0)
 return;
 
-  find_all_hard_reg_sets (insn, t);
+  find_all_hard_reg_sets (insn, t, true);
 
  restart:
   for (i = 0; i  ready.n_ready; i++)
diff --git a/gcc/rtl.h b/gcc/rtl.h
index b9defcc..6486f20 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2038,7 +2038,7 @@ extern const_rtx set_of (const_rtx, const_rtx);
 extern void record_hard_reg_sets (rtx, const_rtx, void *);
 extern void record_hard_reg_uses (rtx *, void *);
 #ifdef HARD_CONST
-extern void find_all_hard_reg_sets (const_rtx, HARD_REG_SET *);
+extern void find_all_hard_reg_sets (const_rtx, HARD_REG_SET *, bool);
 #endif
 extern void note_stores (const_rtx, void (*) (rtx, const_rtx, void *), void *);
 extern void note_uses (rtx *, void (*) (rtx *, void *), void *);
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index b198685..27c1974 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -1028,13 +1028,13 @@ record_hard_reg_sets (rtx x, const_rtx pat ATTRIBUTE_UNUSED, void *data)
 /* Examine INSN, and compute the set of hard registers written by it.
Store it in *PSET.  Should only be called after reload.  */
 void
-find_all_hard_reg_sets (const_rtx insn, HARD_REG_SET *pset)
+find_all_hard_reg_sets (const_rtx insn, HARD_REG_SET *pset, bool implicit)
 {
   rtx link;
 
   CLEAR_HARD_REG_SET (*pset);
   note_stores (PATTERN (insn), record_hard_reg_sets, pset);
-  if (CALL_P (insn))
+  if (implicit  CALL_P (insn))
 IOR_HARD_REG_SET (*pset, call_used_reg_set);
   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
 if (REG_NOTE_KIND (link) == REG_INC)


[PATCH][04/10] -fuse-caller-save - Add TARGET_FN_OTHER_HARD_REG_USAGE hook

2013-03-30 Thread Tom de Vries
Vladimir,

This patch adds a TARGET_FN_OTHER_HARD_REG_USAGE hook.  The hook is used to
list hard registers that are set or clobbered by a call to a function, but are
not listed as such in the function body, such as f.i. registers clobbered by
veneers inserted by the linker.

Thanks,
  -Tom

2013-03-30  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* hooks.c (hook_void_hard_reg_set_containerp): New function.
* hooks.h (hook_void_hard_reg_set_containerp): Declare.
* target.def (fn_other_hard_reg_usage): New DEFHOOK.
* doc/tm.texi.in (@node Stack and Calling): Add Miscellaneous Register
Hooks to @menu.
(@node Miscellaneous Register Hooks): New node.
(@hook TARGET_FN_OTHER_HARD_REG_USAGE): New hook.
* doc/tm.texi: Regenerate.
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index cbbc82d..3bf7abe 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -3074,6 +3074,7 @@ This describes the stack layout and calling conventions.
 * Profiling::
 * Tail Calls::
 * Stack Smashing Protection::
+* Miscellaneous Register Hooks::
 @end menu
 
 @node Frame Layout
@@ -4999,6 +5000,14 @@ normally defined in @file{libgcc2.c}.
 Whether this target supports splitting the stack when the options described in @var{opts} have been passed.  This is called after options have been parsed, so the target may reject splitting the stack in some configurations.  The default version of this hook returns false.  If @var{report} is true, this function may issue a warning or error; if @var{report} is false, it must simply return a value
 @end deftypefn
 
+@node Miscellaneous Register Hooks
+@subsection Miscellaneous register hooks
+@cindex miscellaneous register hooks
+
+@deftypefn {Target Hook} void TARGET_FN_OTHER_HARD_REG_USAGE (struct hard_reg_set_container *@var{regs})
+Add any hard registers to @var{regs} that are set or clobbered by a call to the function.  This hook only needs to be defined to provide registers that cannot be found by examination of the final RTL representation of a function.
+@end deftypefn
+
 @node Varargs
 @section Implementing the Varargs Macros
 @cindex varargs implementation
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index dfba947..4dfd8aa 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3042,6 +3042,7 @@ This describes the stack layout and calling conventions.
 * Profiling::
 * Tail Calls::
 * Stack Smashing Protection::
+* Miscellaneous Register Hooks::
 @end menu
 
 @node Frame Layout
@@ -4922,6 +4923,12 @@ normally defined in @file{libgcc2.c}.
 
 @hook TARGET_SUPPORTS_SPLIT_STACK
 
+@node Miscellaneous Register Hooks
+@subsection Miscellaneous register hooks
+@cindex miscellaneous register hooks
+
+@hook TARGET_FN_OTHER_HARD_REG_USAGE
+
 @node Varargs
 @section Implementing the Varargs Macros
 @cindex varargs implementation
diff --git a/gcc/hooks.c b/gcc/hooks.c
index 3b54dfa..e038a95 100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -446,3 +446,11 @@ void
 hook_void_gcc_optionsp (struct gcc_options *opts ATTRIBUTE_UNUSED)
 {
 }
+
+/* Generic hook that takes a struct hard_reg_set_container * and returns
+   void.  */
+
+void
+hook_void_hard_reg_set_containerp (struct hard_reg_set_container *regs ATTRIBUTE_UNUSED)
+{
+}
diff --git a/gcc/hooks.h b/gcc/hooks.h
index 50bcc6a..44decdf 100644
--- a/gcc/hooks.h
+++ b/gcc/hooks.h
@@ -69,6 +69,7 @@ extern void hook_void_tree (tree);
 extern void hook_void_tree_treeptr (tree, tree *);
 extern void hook_void_int_int (int, int);
 extern void hook_void_gcc_optionsp (struct gcc_options *);
+extern void hook_void_hard_reg_set_containerp (struct hard_reg_set_container *);
 
 extern int hook_int_uint_mode_1 (unsigned int, enum machine_mode);
 extern int hook_int_const_tree_0 (const_tree);
diff --git a/gcc/target.def b/gcc/target.def
index 831cad8..e8f7c4a 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -2850,6 +2850,17 @@ DEFHOOK
  void, (bitmap regs),
  hook_void_bitmap)
 
+/* For targets that need to mark extra registers as clobbered on entry to
+   the function, they should define this target hook and set their
+   bits in the struct hard_reg_set_container passed in.  */
+DEFHOOK
+(fn_other_hard_reg_usage,
+ Add any hard registers to @var{regs} that are set or clobbered by a call to\
+ the function.  This hook only needs to be defined to provide registers that\
+ cannot be found by examination of the final RTL representation of a function.,
+ void, (struct hard_reg_set_container *regs),
+ hook_void_hard_reg_set_containerp)
+
 /* Fill in additional registers set up by prologue into a regset.  */
 DEFHOOK
 (set_up_by_prologue,


[PATCH][05/10] -fuse-caller-save - Implement TARGET_FN_OTHER_HARD_REG_USAGE hook for ARM

2013-03-30 Thread Tom de Vries
Richard,

This patch series adds analysis of register usage of functions for usage by IRA.
The original post is here
( http://gcc.gnu.org/ml/gcc-patches/2013-01/msg01234.html ).

This patch implements the target hook TARGET_FN_OTHER_HARD_REG_USAGE for ARM.
The target hook TARGET_FN_OTHER_HARD_REG_USAGE was introduced in the previous
patch in this patch series.

Build and reg-tested on ARM.

OK for trunk?

Thanks,
  -Tom

2013-03-30  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* config/arm/arm.c (TARGET_FN_OTHER_HARD_REG_USAGE): Redefine as
arm_fn_other_hard_reg_usage.
(arm_fn_other_hard_reg_usage): New function.
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 5f63a2e..341fa86 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -280,6 +280,7 @@ static unsigned arm_add_stmt_cost (void *data, int count,
 
 static void arm_canonicalize_comparison (int *code, rtx *op0, rtx *op1,
 	 bool op0_preserve_value);
+static void arm_fn_other_hard_reg_usage (struct hard_reg_set_container *);
 
 /* Table of machine attributes.  */
 static const struct attribute_spec arm_attribute_table[] =
@@ -649,6 +650,10 @@ static const struct attribute_spec arm_attribute_table[] =
 #define TARGET_CANONICALIZE_COMPARISON \
   arm_canonicalize_comparison
 
+#undef TARGET_FN_OTHER_HARD_REG_USAGE
+#define TARGET_FN_OTHER_HARD_REG_USAGE \
+  arm_fn_other_hard_reg_usage
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Obstack for minipool constant handling.  */
@@ -3762,6 +3767,19 @@ arm_canonicalize_comparison (int *code, rtx *op0, rtx *op1,
 }
 }
 
+/* Implement TARGET_FN_OTHER_HARD_REG_USAGE.  */
+
+static void
+arm_fn_other_hard_reg_usage (struct hard_reg_set_container *regs)
+{
+  if (TARGET_AAPCS_BASED)
+{
+  /* For AAPCS, IP and CC can be clobbered by veneers inserted by the
+	 linker.  */
+  SET_HARD_REG_BIT (regs-set, IP_REGNUM);
+  SET_HARD_REG_BIT (regs-set, CC_REGNUM);
+}
+}
 
 /* Define how to find the value returned by a function.  */
 


[PATCH][06/10] -fuse-caller-save - Collect register usage information

2013-03-30 Thread Tom de Vries
Vladimir,

This patch adds analysis in pass_final to track which hard registers are set or
clobbered by the function body, and stores that information in a
struct cgraph_node.

Thanks,
  -Tom

2013-03-30  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* cgraph.h (struct cgraph_node): Add function_used_regs,
function_used_regs_initialized and function_used_regs_valid fields.
* final.c: Move include of hard-reg-set.h to before rtl.h to declare
find_all_hard_reg_sets.
(collect_fn_hard_reg_usage, get_call_fndecl, get_call_cgraph_node)
(get_call_reg_set_usage): New function.
(rest_of_handle_final): Use collect_fn_hard_reg_usage.
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 8ab7ae1..2132d91 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -251,6 +251,15 @@ struct GTY(()) cgraph_node {
   /* Unique id of the node.  */
   int uid;
 
+  /* Call unsaved hard registers really used by the corresponding
+ function (including ones used by functions called by the
+ function).  */
+  HARD_REG_SET function_used_regs;
+  /* Set if function_used_regs is initialized.  */
+  unsigned function_used_regs_initialized: 1;
+  /* Set if function_used_regs is valid.  */
+  unsigned function_used_regs_valid: 1;
+
   /* Set when decl is an abstract function pointed to by the
  ABSTRACT_DECL_ORIGIN of a reachable function.  */
   unsigned abstract_and_needed : 1;
diff --git a/gcc/final.c b/gcc/final.c
index d25b8e0..4e0fd01 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.  If not see
 #include tm.h
 
 #include tree.h
+#include hard-reg-set.h
 #include rtl.h
 #include tm_p.h
 #include regs.h
@@ -56,7 +57,6 @@ along with GCC; see the file COPYING3.  If not see
 #include recog.h
 #include conditions.h
 #include flags.h
-#include hard-reg-set.h
 #include output.h
 #include except.h
 #include function.h
@@ -222,6 +222,7 @@ static int alter_cond (rtx);
 static int final_addr_vec_align (rtx);
 #endif
 static int align_fuzz (rtx, rtx, int, unsigned);
+static void collect_fn_hard_reg_usage (void);
 
 /* Initialize data in final at the beginning of a compilation.  */
 
@@ -4328,6 +4329,8 @@ rest_of_handle_final (void)
   rtx x;
   const char *fnname;
 
+  collect_fn_hard_reg_usage ();
+
   /* Get the function's name, as described by its RTL.  This may be
  different from the DECL_NAME name used in the source file.  */
 
@@ -4584,3 +4587,121 @@ struct rtl_opt_pass pass_clean_state =
   0 /* todo_flags_finish */
  }
 };
+
+/* Collect hard register usage for the current function.  */
+
+static void
+collect_fn_hard_reg_usage (void)
+{
+  rtx insn;
+  int i;
+  struct cgraph_node *node;
+  struct hard_reg_set_container other_usage;
+
+  if (!flag_use_caller_save)
+return;
+
+  node = cgraph_get_node (current_function_decl);
+  gcc_assert (node != NULL);
+
+  gcc_assert (!node-function_used_regs_initialized);
+  node-function_used_regs_initialized = 1;
+
+  for (insn = get_insns (); insn != NULL_RTX; insn = next_insn (insn))
+{
+  HARD_REG_SET insn_used_regs;
+
+  if (!NONDEBUG_INSN_P (insn))
+	continue;
+
+  find_all_hard_reg_sets (insn, insn_used_regs, false);
+
+  if (CALL_P (insn)
+	   !get_call_reg_set_usage (insn, insn_used_regs, call_used_reg_set))
+	{
+	  CLEAR_HARD_REG_SET (node-function_used_regs);
+	  return;
+	}
+
+  IOR_HARD_REG_SET (node-function_used_regs, insn_used_regs);
+}
+
+  /* Be conservative - mark fixed and global registers as used.  */
+  IOR_HARD_REG_SET (node-function_used_regs, fixed_reg_set);
+  for (i = 0; i  FIRST_PSEUDO_REGISTER; i++)
+if (global_regs[i])
+  SET_HARD_REG_BIT (node-function_used_regs, i);
+
+#ifdef STACK_REGS
+  /* Handle STACK_REGS conservatively, since the df-framework does not
+ provide accurate information for them.  */
+
+  for (i = FIRST_STACK_REG; i = LAST_STACK_REG; i++)
+SET_HARD_REG_BIT (node-function_used_regs, i);
+#endif
+
+  CLEAR_HARD_REG_SET (other_usage.set);
+  targetm.fn_other_hard_reg_usage (other_usage);
+  IOR_HARD_REG_SET (node-function_used_regs, other_usage.set);
+
+  node-function_used_regs_valid = 1;
+}
+
+/* Get the declaration of the function called by INSN.  */
+
+static tree
+get_call_fndecl (rtx insn)
+{
+  rtx note, datum;
+
+  if (!flag_use_caller_save)
+return NULL_TREE;
+
+  note = find_reg_note (insn, REG_CALL_DECL, NULL_RTX);
+  if (note == NULL_RTX)
+return NULL_TREE;
+
+  datum = XEXP (note, 0);
+  if (datum != NULL_RTX)
+return SYMBOL_REF_DECL (datum);
+
+  return NULL_TREE;
+}
+
+static struct cgraph_node *
+get_call_cgraph_node (rtx insn)
+{
+  tree fndecl;
+
+  if (insn == NULL_RTX)
+return NULL;
+
+  fndecl = get_call_fndecl (insn);
+  if (fndecl == NULL_TREE
+  || !targetm.binds_local_p (fndecl))
+return NULL;
+
+  return cgraph_get_node (fndecl);
+}
+
+/* Find hard registers used by 

[PATCH][07/10] -fuse-caller-save - Use collected register usage information

2013-03-30 Thread Tom de Vries
Paolo,

This patch series adds analysis of register usage of functions for usage by IRA.
The original post is here
( http://gcc.gnu.org/ml/gcc-patches/2013-01/msg01234.html ).

This patch uses the information of which registers are clobbered by a call
in IRA and df-scan.

Bootstrapped and reg-tested on x86_64, Ada inclusive. Build and reg-tested on
mips, arm, ppc and sh.

Can you approve the df-scan part for trunk?

Thanks,
  -Tom

2013-03-30  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* df-scan.c (df_get_call_refs): Use get_call_reg_set_usage.
* caller-save.c (setup_save_areas, save_call_clobbered_regs): Use
get_call_reg_set_usage.
* resource.c (mark_set_resources, mark_target_live_regs): Use
get_call_reg_set_usage.
* ira-int.h (struct ira_allocno): Add crossed_calls_clobbered_regs
field.
(ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS): Define.
* ira-lives.c (process_bb_node_lives): Use get_call_reg_set_usage.
Calculate ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS.
* ira-build.c (ira_create_allocno): Init
ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS.
(create_cap_allocno, propagate_allocno_info)
(propagate_some_info_from_allocno)
(copy_info_to_removed_store_destinations): Handle
ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS.
* ira-costs.c (ira_tune_allocno_costs): Use
ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS to adjust costs.
diff --git a/gcc/caller-save.c b/gcc/caller-save.c
index 5e65294..39d75ad 100644
--- a/gcc/caller-save.c
+++ b/gcc/caller-save.c
@@ -441,7 +441,7 @@ setup_save_areas (void)
   freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn));
   REG_SET_TO_HARD_REG_SET (hard_regs_to_save,
 			   chain-live_throughout);
-  COPY_HARD_REG_SET (used_regs, call_used_reg_set);
+  get_call_reg_set_usage (insn, used_regs, call_used_reg_set);
 
   /* Record all registers set in this call insn.  These don't
 	 need to be saved.  N.B. the call insn might set a subreg
@@ -525,7 +525,7 @@ setup_save_areas (void)
 
 	  REG_SET_TO_HARD_REG_SET (hard_regs_to_save,
    chain-live_throughout);
-	  COPY_HARD_REG_SET (used_regs, call_used_reg_set);
+	  get_call_reg_set_usage (insn, used_regs, call_used_reg_set);
 
 	  /* Record all registers set in this call insn.  These don't
 	 need to be saved.  N.B. the call insn might set a subreg
@@ -804,6 +804,7 @@ save_call_clobbered_regs (void)
 	{
 	  unsigned regno;
 	  HARD_REG_SET hard_regs_to_save;
+	  HARD_REG_SET call_def_reg_set;
 	  reg_set_iterator rsi;
 	  rtx cheap;
 
@@ -854,7 +855,9 @@ save_call_clobbered_regs (void)
 	  AND_COMPL_HARD_REG_SET (hard_regs_to_save, call_fixed_reg_set);
 	  AND_COMPL_HARD_REG_SET (hard_regs_to_save, this_insn_sets);
 	  AND_COMPL_HARD_REG_SET (hard_regs_to_save, hard_regs_saved);
-	  AND_HARD_REG_SET (hard_regs_to_save, call_used_reg_set);
+	  get_call_reg_set_usage (insn, call_def_reg_set,
+  call_used_reg_set);
+	  AND_HARD_REG_SET (hard_regs_to_save, call_def_reg_set);
 
 	  for (regno = 0; regno  FIRST_PSEUDO_REGISTER; regno++)
 		if (TEST_HARD_REG_BIT (hard_regs_to_save, regno))
diff --git a/gcc/df-scan.c b/gcc/df-scan.c
index fdfa931..898454c 100644
--- a/gcc/df-scan.c
+++ b/gcc/df-scan.c
@@ -3398,10 +3398,13 @@ df_get_call_refs (struct df_collection_rec *collection_rec,
   bool is_sibling_call;
   unsigned int i;
   HARD_REG_SET defs_generated;
+  HARD_REG_SET fn_reg_set_usage;
 
   CLEAR_HARD_REG_SET (defs_generated);
   df_find_hard_reg_defs (PATTERN (insn_info-insn), defs_generated);
   is_sibling_call = SIBLING_CALL_P (insn_info-insn);
+  get_call_reg_set_usage (insn_info-insn, fn_reg_set_usage,
+			  regs_invalidated_by_call);
 
   for (i = 0; i  FIRST_PSEUDO_REGISTER; i++)
 {
@@ -3425,7 +3428,7 @@ df_get_call_refs (struct df_collection_rec *collection_rec,
 			   NULL, bb, insn_info, DF_REF_REG_DEF, flags);
 	}
 	}
-  else if (TEST_HARD_REG_BIT (regs_invalidated_by_call, i)
+  else if (TEST_HARD_REG_BIT (fn_reg_set_usage, i)
 	   /* no clobbers for regs that are the result of the call */
 	!TEST_HARD_REG_BIT (defs_generated, i)
 	(!is_sibling_call
diff --git a/gcc/ira-build.c b/gcc/ira-build.c
index b1e481b..054139a 100644
--- a/gcc/ira-build.c
+++ b/gcc/ira-build.c
@@ -507,6 +507,7 @@ ira_create_allocno (int regno, bool cap_p,
   ALLOCNO_CALL_FREQ (a) = 0;
   ALLOCNO_CALLS_CROSSED_NUM (a) = 0;
   ALLOCNO_CHEAP_CALLS_CROSSED_NUM (a) = 0;
+  CLEAR_HARD_REG_SET (ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS (a));
 #ifdef STACK_REGS
   ALLOCNO_NO_STACK_REG_P (a) = false;
   ALLOCNO_TOTAL_NO_STACK_REG_P (a) = false;
@@ -904,6 +905,8 @@ create_cap_allocno (ira_allocno_t a)
 
   ALLOCNO_CALLS_CROSSED_NUM (cap) = ALLOCNO_CALLS_CROSSED_NUM (a);
   ALLOCNO_CHEAP_CALLS_CROSSED_NUM (cap) = ALLOCNO_CHEAP_CALLS_CROSSED_NUM (a);
+  IOR_HARD_REG_SET 

[PATCH][08/10] -fuse-caller-save - Enable by default at O2 and higher

2013-03-30 Thread Tom de Vries
Vladimir,

This patch enables the -fuse-caller-save optimization by default.

Thanks,
  -Tom

2013-03-30  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* opts.c (default_options_table): Add OPT_LEVELS_2_PLUS entry with
OPT_fuse_caller_save.
diff --git a/gcc/opts.c b/gcc/opts.c
index 45b12fe..52a42b9 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -486,6 +486,7 @@ static const struct default_options default_options_table[] =
 { OPT_LEVELS_2_PLUS, OPT_ftree_tail_merge, NULL, 1 },
 { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_foptimize_strlen, NULL, 1 },
 { OPT_LEVELS_2_PLUS, OPT_fhoist_adjacent_loads, NULL, 1 },
+{ OPT_LEVELS_2_PLUS, OPT_fuse_caller_save, NULL, 1 },
 
 /* -O3 optimizations.  */
 { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },


[PATCH][09/10] -fuse-caller-save - Add documentation

2013-03-30 Thread Tom de Vries
Vladimir,

This patch adds the documentation of -fuse-caller-save.

Thanks,
  -Tom

2013-03-30  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* doc/invoke.texi (@item Optimization Options): Add -fuse-caller-save to
gccoptlist.
(@item -fuse-caller-save): New item.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 475dcf0..efb8a1a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -421,8 +421,8 @@ Objective-C and Objective-C++ Dialects}.
 -ftree-ter -ftree-vect-loop-version -ftree-vectorize -ftree-vrp @gol
 -funit-at-a-time -funroll-all-loops -funroll-loops @gol
 -funsafe-loop-optimizations -funsafe-math-optimizations -funswitch-loops @gol
--fvariable-expansion-in-unroller -fvect-cost-model -fvpt -fweb @gol
--fwhole-program -fwpa -fuse-ld=@var{linker} -fuse-linker-plugin @gol
+-fuse-caller-save -fvariable-expansion-in-unroller -fvect-cost-model -fvpt @gol
+-fweb -fwhole-program -fwpa -fuse-ld=@var{linker} -fuse-linker-plugin @gol
 --param @var{name}=@var{value}
 -O  -O0  -O1  -O2  -O3  -Os -Ofast -Og}
 
@@ -7382,6 +7382,14 @@ and then tries to find ways to combine them.
 
 Enabled by default at @option{-O1} and higher.
 
+@item -fuse-caller-save
+Use caller save registers for allocation if those registers are not used by
+any called function.  In that case it is not necessary to save and restore
+them around calls.  This is only possible if called functions are part of
+same compilation unit as current function and they are compiled before it.
+
+Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
+
 @item -fconserve-stack
 @opindex fconserve-stack
 Attempt to minimize stack usage.  The compiler attempts to use less


[PATCH][10/10] -fuse-caller-save - Add test-case

2013-03-30 Thread Tom de Vries
Richard,

This patch series adds analysis of register usage of functions for usage by IRA.
The original post is here
( http://gcc.gnu.org/ml/gcc-patches/2013-01/msg01234.html ).

This patch adds a test-case for -fuse-caller-save.  Since the test-case has
different output for mips16 and micromips, new effective targets are introduced.

Build and reg-tested on mips.

OK for trunk?

Thanks,
  -Tom

2013-03-30  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* lib/target-supports.exp (check_effective_target_mips16)
(check_effective_target_micromips): New proc.
* gcc.target/mips/mips.exp: Add use-caller-save to -ffoo/-fno-foo
options.  Add -save-temps to mips_option_groups.
* gcc.target/mips/aru-1.c: New test.
diff --git a/gcc/testsuite/gcc.target/mips/aru-1.c b/gcc/testsuite/gcc.target/mips/aru-1.c
new file mode 100644
index 000..71515a9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/aru-1.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options -fuse-caller-save -save-temps } */
+/* { dg-skip-if  { *-*-* }  { * } { -Os } } */
+/* Testing -fuse-caller-save optimization option.  */
+
+static int __attribute__((noinline))
+bar (int x)
+{
+  return x + 3;
+}
+
+int __attribute__((noinline))
+foo (int y)
+{
+  return y + bar (y);
+}
+
+int
+main (void)
+{
+  return !(foo (5) == 13);
+}
+
+/* Check that there are only 2 stack-saves: r31 in main and foo.  */
+
+/* Variant not mips16.  Check that there only 2 sw/sd.  */
+/* { dg-final { scan-assembler-times (?n)s\[wd\]\t\\\$.*,.*\\(\\\$sp\\) 2 { target { ! mips16 } } } } */
+
+/* Variant not mips16, Subvariant micromips.  Additionally check there's no
+   swm.  */
+/* { dg-final { scan-assembler-times (?n)swm\t\\\$.*,.*\\(\\\$sp\\) 0 {target micromips } } } */
+
+/* Variant mips16.  The save can save 1 or more registers, check that only 1 is
+   saved, twice in total.  */
+/* { dg-final { scan-assembler-times (?n)save\t\[0-9\]*,\\\$\[^,\]*\$ 2 { target mips16 } } } */
+
+/* Check that the first caller-save register is unused.  */
+/* { dg-final { scan-assembler-not (\\\$16) } } */
diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp
index 15b1386..63570bd 100644
--- a/gcc/testsuite/gcc.target/mips/mips.exp
+++ b/gcc/testsuite/gcc.target/mips/mips.exp
@@ -246,6 +246,7 @@ set mips_option_groups {
 small-data -G[0-9]+
 warnings -w
 dump -fdump-.*
+save_temps -save-temps
 }
 
 # Add -mfoo/-mno-foo options to mips_option_groups.
@@ -302,6 +303,7 @@ foreach option {
 tree-vectorize
 unroll-all-loops
 unroll-loops
+use-caller-save
 } {
 lappend mips_option_groups $option -f(no-|)$option
 }
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index a146f17..dbd0037 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -918,6 +918,26 @@ proc check_effective_target_mips16_attribute { } {
 } [add_options_for_mips16_attribute ]]
 }
 
+# Return 1 if the target generates mips16 code by default.
+
+proc check_effective_target_mips16 { } {
+return [check_no_compiler_messages mips16 assembly {
+	#if !(defined __mips16)
+	#error FOO
+	#endif
+} ]
+}
+
+# Return 1 if the target generates micromips code by default.
+
+proc check_effective_target_micromips { } {
+return [check_no_compiler_messages micromips assembly {
+	#if !(defined __mips_micromips)
+	#error FOO
+	#endif
+} ]
+}
+
 # Return 1 if the target supports long double larger than double when
 # using the new ABI, 0 otherwise.
 


[wwwdocs] Two more broken links in readings.html

2013-03-30 Thread Gerald Pfeifer
For these two, I could not identify a natural replacement, so just
removed them for now.

Gerald

Index: readings.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/readings.html,v
retrieving revision 1.225
retrieving revision 1.226
diff -u -3 -p -r1.225 -r1.226
--- readings.html   30 Mar 2013 13:21:03 -  1.225
+++ readings.html   30 Mar 2013 18:04:28 -  1.226
@@ -93,13 +93,11 @@ names.
  lic4x
br /Manufacturer: Texas Instruments
br /Exact chip name: TMS320C4X
-   br /a href=http://www.ti.com/sc/docs/psheets/man_dsp.htm;DSP 
Manuals/a
  /li
 
  liC6X
br /Manufacturer: Texas Instruments
br /Exact chip name: TMS320C6X
-   br /a href=http://www.ti.com/sc/docs/psheets/man_dsp.htm;DSP 
Manuals/a
br /a href=http://linux-c6x.org/;Site for the Linux on C6X project/a
  /li
 


Re: [wwwdocs] Two more broken links in readings.html

2013-03-30 Thread minux
Hi,

the link for CompactRISC CR16CP Architecture on that page is also broken.
As TI says document for CR16 is only available to existing customers, i'm
afraid we have to remove that link.


[wwwdocs] x86-64.org seems/is gone

2013-03-30 Thread Gerald Pfeifer
...remove the link we still have there.  Applied.

Gerald

Index: news.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/news.html,v
retrieving revision 1.135
diff -u -3 -p -r1.135 news.html
--- news.html   17 Feb 2013 12:47:44 -  1.135
+++ news.html   30 Mar 2013 18:21:04 -
@@ -776,9 +776,7 @@ implementations.
 dtbJanuary 8, 2002/b/dt
 dd
 SuSE Labs developers Jan Hubicka, Bo Thorsen and Andreas Jaeger have
-contributed a port to the AMD x86-64 architecture.  For more
-information on x86-64 see a
-href=http://www.x86-64.org;http://www.x86-64.org/a.
+contributed a port to the AMD x86-64 architecture.
 /dd
 
 dtbDecember 20, 2001/b/dt


Re: [Fortran, RFC patch] Document naming and argument passing convention

2013-03-30 Thread Janne Blomqvist
On Fri, Mar 29, 2013 at 8:42 PM, Tobias Burnus bur...@net-b.de wrote:
 Ups - I attached the wrong patch (same file name, wrong directory).
 Hopefully, this one is the correct one.

 Tobias

 Am 29.03.2013 19:40, schrieb Tobias Burnus:

 Dear all,

 the attached patch attempts to document gfortran's naming and argument
 passing convention when Bind(C) is not used.

 While Bind(C) is the recommended way for interoperation with other Fortran
 compilers and other languages, there are situations where this is not
 possible; for instance, legacy code. Or in case of the MPI standard, the MPI
 implementation might need this information and MPI performance tool
 developers (PMPI) have to know how the different Fortran compilers pass the
 arguments.

 The attached patch does not (yet) state how array descriptors are handled
 internally. (I was thinking of deferring this until the new array descriptor
 becomes available.) I also believe there are other omissions as well and the
 wording could be improved. Suggestions are welcome.

 The patch was motivated by Walter's comment** to my VALUE+OPTIONAL patch.*
 It takes his comments into account and, that part, only reflects gfortran's
 implementation after the VALUE+OPTIONAL patch has been committed with his
 suggested change.

 What do you think?

 Tobias

 * http://gcc.gnu.org/ml/fortran/2013-03/msg00102.html
 ** http://gcc.gnu.org/ml/fortran/2013-03/msg00173.html

Thanks for the patch! Comments below:

+For logical types, please note that the Fortran standard only guarantees
+interoperability between C99's @code{_Bool} and Fortran's @code{C_Bool}-kind
+logicals and C99 defines that @code{true} has the value 1 and @code{false}
+the value 0.  In GCC, Boolean variables (Fortran @code{logicals} with and
+without C binding [and for all @code{kind} values], C99's @code{_Bool},
+C++'s @code{bool}, Ada's @code{Boolean}, etc.) all expect that only the
+value 0 and 1 are used; using other values might lead to wrong results.
+Therefore, using @code{logical(kind=c_int)} to interoperate with C99's
+@code{int} is discouraged and should be replaced either by
+@code{integer(kind=c_int)} on the Fortran side (which can then be
+converted to @code{logical}) -- or to use @code{_Bool} and
+@code{logical(kind=c_bool)}. Note that some other (Fortran) compilers
+use a different value for @code{.true.} (e.g. @math{-1}), even with C binding.

This seems to partly repeat what is already said at

http://gcc.gnu.org/onlinedocs/gfortran/Internal-representation-of-LOGICAL-variables.html

IMHO we shouldn't repeat stuff like that; that part might be better
suited as part of the mixed-language programming chapter, if you think
so, please delete the above existing chapter. Or just replace the text
with a short reference to the (updated?) description in the other
chapter, or something like that.

+For procedures and variables declared in the specification space of a
+module, the name is formed by @code{__}, followed by the lower-cased
+module name, @code{_MOD_}, and the lower-cased Fortran name.  Note that
+no underscore is appended.

Would it be worth shortly mentioning the various compiler-generated
symbols (e.g. vtables)? BTW, did the patch that changes all those to
use the _F prefix go in, or are we still doing something else?

+Arguments are passed according to the platform ABI. In particular,
+complex arguments may not be compatible to a struct with two real
+components for the real and imaginary part; and complex values are
+returned as result and not by reference.

Here it might be worth mentioning that Fortran complex arguments are
ABI-wise handled like C99 _Complex types.

+For @code{OPTIONAL} dummy arguments, an absent argument is denoted
+by a NUL pointer, except for scalar dummy arguments of type

s/NUL/NULL/




-- 
Janne Blomqvist


Re: [Fortran, RFC patch] Document naming and argument passing convention

2013-03-30 Thread Tobias Burnus

Janne Blomqvist wrote:

Thanks for the patch! Comments below:

+For logical types, please note that the Fortran standard only guarantees
+interoperability between C99's @code{_Bool} and Fortran's @code{C_Bool}-kind
+logicals and C99 defines that @code{true} has the value 1 and @code{false}
+the value 0.  In GCC, Boolean variables (Fortran @code{logicals} with and
+without C binding [and for all @code{kind} values], C99's @code{_Bool},
+C++'s @code{bool}, Ada's @code{Boolean}, etc.) all expect that only the
+value 0 and 1 are used; using other values might lead to wrong results.
+Therefore, using @code{logical(kind=c_int)} to interoperate with C99's
+@code{int} is discouraged and should be replaced either by
+@code{integer(kind=c_int)} on the Fortran side (which can then be
+converted to @code{logical}) -- or to use @code{_Bool} and
+@code{logical(kind=c_bool)}. Note that some other (Fortran) compilers
+use a different value for @code{.true.} (e.g. @math{-1}), even with C binding.

This seems to partly repeat what is already said at
http://gcc.gnu.org/onlinedocs/gfortran/Internal-representation-of-LOGICAL-variables.html

IMHO we shouldn't repeat stuff like that; that part might be better
suited as part of the mixed-language programming chapter, if you think
so, please delete the above existing chapter. Or just replace the text
with a short reference to the (updated?) description in the other
chapter, or something like that.


I will try to improve this.


+For procedures and variables declared in the specification space of a
+module, the name is formed by @code{__}, followed by the lower-cased
+module name, @code{_MOD_}, and the lower-cased Fortran name.  Note that
+no underscore is appended.

Would it be worth shortly mentioning the various compiler-generated
symbols (e.g. vtables)? BTW, did the patch that changes all those to
use the _F prefix go in, or are we still doing something else?


I was thinking of not mentioning the handling of special things like 
ENTRY, alt-returns, compiler-generated virtual tables etc. However, if 
you think that it fits into this chapter, I can add it.


Regarding the _F prefix: Yes, the patch for GFC_PREFIX (_F. or _F$ or 
_F_) went in, but it is (currently) only used to mangle the 
hidden-length variable for the length of deferred-length characters. 
Actually, we should document that one as well.



+Arguments are passed according to the platform ABI. In particular,
+complex arguments may not be compatible to a struct with two real
+components for the real and imaginary part; and complex values are
+returned as result and not by reference.

Here it might be worth mentioning that Fortran complex arguments are
ABI-wise handled like C99 _Complex types.


That was what I tried to imply by the platform ABI: The Fortran complex 
is handled like Ada's Complex and C's _Complex, which (at least on 
Alpha) is different to the struct version. However, if it helps, I can 
mention C (and/or Ada and/or Java and/or C++).



+For @code{OPTIONAL} dummy arguments, an absent argument is denoted
+by a NUL pointer, except for scalar dummy arguments of type

s/NUL/NULL/


I never now how to write that value. Fortran has null(), C and C++ 
define NULL, C++11 has nullptr, ObjC has nil, ASCII has NUL. And 
internally, the value (void*) 0 is used, i.e. zero.


Tobias


[wwwdocs] Remove mirrors-us.seosue.com from mirrors.html

2013-03-30 Thread Gerald Pfeifer
It looks like this site does not mirror gcc.gnu.org any more, so I
am thusly removing it from the GCC mirrors list.

Gerald

Index: mirrors.html 
===
RCS file: /cvs/gcc/wwwdocs/htdocs/mirrors.html,v
retrieving revision 1.219
diff -u -3 -p -r1.219 mirrors.html
--- mirrors.html1 Nov 2012 21:46:24 -   1.219
+++ mirrors.html30 Mar 2013 20:34:27 -
@@ -36,7 +36,6 @@ mirrors/a.  The following sites mirror
 liUK, London: a 
href=http://gcc-uk.internet.bs;http://gcc-uk.internet.bs/a, thanks to 
Internet.bs (info at internet.bs)/li
 liUS, Saint Louis: a 
href=http://gcc.petsads.us;http://gcc.petsads.us/a, thanks to Sergey 
Kutserey (s.kutserey at gmail.com)/li
 liUS, San Jose: a 
href=http://www.netgull.com/gcc/;http://www.netgull.com/a, thanks to admin 
at netgull.com/li
-liUS, Tampa: a 
href=http://mirrors-us.seosue.com/gcc/;http://mirrors-us.seosue.com/gcc//a, 
thanks to Peter Vrzak (petervrzak at gmail.com)/li
 /ul
 
 pThe archives there will be signed by one of the following GnuPG keys:/p


*ping* Re: [Patch, Fortran, 4.9] Minor FINAL preparation patch

2013-03-30 Thread Tobias Burnus

*** PING ***
The patch is rather simple and almost three weeks old ... Even if it is 
mostly a no-op patch (as long as FINAL is disabled), I'd like to get it 
out of my tree.


Tobias

On March 27, 2013 10:53, Tobias Burnus wrote:

** PING **

And an updated patch. Changes:
- Updated isym handling due to the ISO_C_BINDING patch
- Fixed some bugs in the generated code for finalizing arrays (mainly 
missing gfc_copy_expr)


Build and tested on x86-64-gnu-linux.
OK for the trunk?

Tobias

PS: Regarding true FINAL support: The current draft patch* mostly 
works, except for: Polymorphic arrays aren't deallocated at the end of 
the scope (old bug), allocatables are wrongly finalized at the end of 
the main program, and for allocatable,intent(out), no finalization is 
done. After those issues are fixed and some code cleanup has be done, 
the patch should be ready.

*https://userpage.physik.fu-berlin.de/~tburnus/final/


On March 13, 2013 11:26 a.m., Tobias Burnus wrote:

Dear all,

this small patch fixes some small issues with the current FINAL 
implementation, which is still disabled. Namely:


(a) class.c: TRANSFER has an optional size= argument; if one doesn't 
has an actual-argument (which can be expr == NULL), it segfaults.
(b) class.c: SIZE needs to return an index-size-kind integer not a 
default-kind integer (tree checking error, but potentially also wrong 
code)
(c) trans.c: Scalar coarrays (with -fcoarray=lib) were mishandled - 
they also use an array descriptor


Build and regtested on x86-64-gnu-linux.
OK?

(I target 4.9 with this patch; in principle, it could also be applied 
to 4.8: The code is not used, yet, and thus it shouldn't harm on 4.8 
but there is also no benefit.)



The full patch, which enables finalization and regtests is available 
at: https://userpage.physik.fu-berlin.de/~tburnus/final/ – The patch 
still requires some clean up. In addition, finalization (with a user 
FINAL subroutine) is mishandled for allocatable INTENT(OUT) as 
gfortran handles it (at least partially) in the caller 
(trans-expr.c's gfc_conv_procedure_call) and not in the callee 
(trans-decl.c). That will lead to not finalizing and segfaults at run 
time. There are more issues, but for an experimental implementation, 
fixing this issue should be enough. (Note: the .mod version should be 
bumped to force recompilation, which is required due to the ABI 
change of the vtable.)


Tobias




Re: [Fortran, RFC patch] Document naming and argument passing convention

2013-03-30 Thread Janne Blomqvist
On Sat, Mar 30, 2013 at 9:50 PM, Tobias Burnus bur...@net-b.de wrote:
 Janne Blomqvist wrote:
 +For procedures and variables declared in the specification space of a
 +module, the name is formed by @code{__}, followed by the lower-cased
 +module name, @code{_MOD_}, and the lower-cased Fortran name.  Note that
 +no underscore is appended.

 Would it be worth shortly mentioning the various compiler-generated
 symbols (e.g. vtables)? BTW, did the patch that changes all those to
 use the _F prefix go in, or are we still doing something else?


 I was thinking of not mentioning the handling of special things like ENTRY,
 alt-returns, compiler-generated virtual tables etc. However, if you think
 that it fits into this chapter, I can add it.

 Regarding the _F prefix: Yes, the patch for GFC_PREFIX (_F. or _F$ or _F_)
 went in, but it is (currently) only used to mangle the hidden-length
 variable for the length of deferred-length characters. Actually, we should
 document that one as well.

Hmm, if it's a long laundry list of special cases (ugh.. :( ), then
maybe it's not worth doing..?

 +Arguments are passed according to the platform ABI. In particular,
 +complex arguments may not be compatible to a struct with two real
 +components for the real and imaginary part; and complex values are
 +returned as result and not by reference.

 Here it might be worth mentioning that Fortran complex arguments are
 ABI-wise handled like C99 _Complex types.


 That was what I tried to imply by the platform ABI: The Fortran complex is
 handled like Ada's Complex and C's _Complex, which (at least on Alpha) is
 different to the struct version. However, if it helps, I can mention C
 (and/or Ada and/or Java and/or C++).

Ah, well, I at least didn't understand that implication, so it might
be useful to clarify it by explicitly mentioning _Complex.

Thanks,

-- 
Janne Blomqvist


[Fortran-dev] Merged trunk into the branch

2013-03-30 Thread Tobias Burnus
I have merged the trunk into Fortran-dev merge. I have not yet 
regtested, but I hope that there are not too many (new) failures.


Committed as Rev., merging r189741 (from July) to r197268.

The Fortran-dev branch contains the array-descriptor update work. The 
first part of the update is almost done (ubound - extend, 
stride-stride multiplier), except for a handful remaing issues. The 
next big step is - as just mentioned - the removal of the offset field.


Tobias

PS: This merge is *not* a commitment that I will do substantial work on 
the branch any time soon.


Re: [PATCH] PR55033: Fix

2013-03-30 Thread David Edelsohn
Alan,

How can we make progress to get this patch committed on trunk, 4.8 and 4.7?

Thanks, David


Re: *ping* Re: [Patch, Fortran, 4.9] Minor FINAL preparation patch

2013-03-30 Thread Thomas Koenig

Hi Tobias,


*** PING ***
The patch is rather simple and almost three weeks old ... Even if it is
mostly a no-op patch (as long as FINAL is disabled), I'd like to get it
out of my tree.


The patch is fine, as far as I can see.

OK for trunk.

Thomas



Re: [patch] Remove unused code from dse.c.

2013-03-30 Thread Lawrence Crowl
On 3/29/13, Jeff Law l...@redhat.com wrote:
 More correctly, it's been dead since an Oct 2008 patch from
 Richard Henderson which introduced set_mem_attrs_for_spill which
 effectively provides the alias analysis code with the information
 it needs to disambiguate stack slots from everything else without
 the callback.

 Lawrence, that's the critical bit of information you failed
 to provide.

Sorry.

 Patch approved, please install.

Committed.

-- 
Lawrence Crowl


[Patch, libgfortran] [4.6/4.7/4.8/4.9 Regression] Namelist read fails with designators containing embedded spaces

2013-03-30 Thread Jerry DeLisle
Hi all,

The attached patch fixes this PR by removing a spurious call to next_char which
threw off the parsing sequence.  In addition, I audited the file for other tests
of EOF and corrected the error handling.  This eliminated some wrong error
messages or undefined error messages when an EOF is encountered during a
namelist read.

Also needed to modify hit_eof to not set the file position status for namelist
mode to AFTER_ENDFILE to assure we get the correct EOF error.

Also attached is the original test case from the PR, modified to include some
reads cut short by EOF.

Regression tested on x86-64.

OK for trunk?

Regards,

Jerry

2013-03-29  Jerry DeLisle  jvdeli...@gcc.gnu.org

PR libfortran/56786
* io/list_read.c (nml_parse_qualifier): Remove spurious next_char call
when checking for EOF. Use error return mechanism when EOF detected.
Do not return false unless parse_err_msg and parse_err_msg_size have
been set. Use hit_eof.
(nml_get_obj_data): Likewise use the correct error mechanism.
* io/transfer.c (hit_eof): Do not set AFTER_ENDFILE if in namelist
mode.




Index: list_read.c
===
--- list_read.c	(revision 197268)
+++ list_read.c	(working copy)
@@ -2078,7 +2078,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip
   /* The next character in the stream should be the '('.  */
 
   if ((c = next_char (dtp)) == EOF)
-return false;
+goto err_ret;
 
   /* Process the qualifier, by dimension and triplet.  */
 
@@ -2092,7 +2092,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip
 
 	  /* Process a potential sign.  */
 	  if ((c = next_char (dtp)) == EOF)
-	return false;
+	goto err_ret;
 	  switch (c)
 	{
 	case '-':
@@ -2110,11 +2110,12 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip
 	  /* Process characters up to the next ':' , ',' or ')'.  */
 	  for (;;)
 	{
-	  if ((c = next_char (dtp)) == EOF)
-		return false;
-
+	  c = next_char (dtp);
 	  switch (c)
 		{
+		case EOF:
+		  goto err_ret;
+
 		case ':':
   is_array_section = 1;
 		  break;
@@ -2137,10 +2138,8 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip
 		  push_char (dtp, c);
 		  continue;
 
-		case ' ': case '\t':
+		case ' ': case '\t': case '\r': case '\n':
 		  eat_spaces (dtp);
-		  if ((c = next_char (dtp) == EOF))
-		return false;
 		  break;
 
 		default:
@@ -2282,6 +2281,14 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip
 
 err_ret:
 
+  /* Do not return false unless parse_err_msg and parse_err_msg_size have
+ been set.  */
+  if (c == EOF)
+{
+  hit_eof (dtp);
+  dtp-u.p.input_complete = 1;
+  return true;
+}
   return false;
 }
 
@@ -2751,12 +2758,12 @@ nml_get_obj_data (st_parameter_dt *dtp, namelist_i
 return true;
 
   if ((c = next_char (dtp)) == EOF)
-return false;
+goto nml_err_ret;
   switch (c)
 {
 case '=':
   if ((c = next_char (dtp)) == EOF)
-	return false;
+	goto nml_err_ret;
   if (c != '?')
 	{
 	  snprintf (nml_err_msg, nml_err_msg_size, 
@@ -2806,8 +2813,9 @@ get_name:
   if (!is_separator (c))
 	push_char (dtp, tolower(c));
   if ((c = next_char (dtp)) == EOF)
-	return false;
-} while (!( c=='=' || c==' ' || c=='\t' || c =='(' || c =='%' ));
+	goto nml_err_ret;
+}
+  while (!( c=='=' || c==' ' || c=='\t' || c =='(' || c =='%' ));
 
   unget_char (dtp, c);
 
@@ -2882,7 +2890,7 @@ get_name:
   qualifier_flag = 1;
 
   if ((c = next_char (dtp)) == EOF)
-	return false;
+	goto nml_err_ret;
   unget_char (dtp, c);
 }
   else if (nl-var_rank  0)
@@ -2909,7 +2917,7 @@ get_name:
 
   component_flag = 1;
   if ((c = next_char (dtp)) == EOF)
-	return false;
+	goto nml_err_ret;
   goto get_name;
 }
 
@@ -2946,7 +2954,7 @@ get_name:
 	}
 
   if ((c = next_char (dtp)) == EOF)
-	return false;
+	goto nml_err_ret;
   unget_char (dtp, c);
 }
 
@@ -2986,7 +2994,7 @@ get_name:
 return true;
 
   if ((c = next_char (dtp)) == EOF)
-return false;
+goto nml_err_ret;
 
   if (c != '=')
 {
@@ -3021,6 +3029,15 @@ get_name:
 
 nml_err_ret:
 
+  /* Do not return false unless nml_err_msg and nml_err_msg_size have
+ been set.  */
+  if (c == EOF)
+{
+  dtp-u.p.input_complete = 1;
+  unget_char (dtp, c);
+  hit_eof (dtp);
+  return true;
+}
   return false;
 }
 
Index: transfer.c
===
--- transfer.c	(revision 197268)
+++ transfer.c	(working copy)
@@ -3840,7 +3840,7 @@ hit_eof (st_parameter_dt * dtp)
   case NO_ENDFILE:
   case AT_ENDFILE:
 generate_error (dtp-common, LIBERROR_END, NULL);
-	if (!is_internal_unit (dtp))
+	if (!is_internal_unit (dtp)  !dtp-u.p.namelist_mode)
 	  {
 	dtp-u.p.current_unit-endfile = AFTER_ENDFILE;
 	dtp-u.p.current_unit-current_record = 0;

! { dg-do run }
! PR56786 

Re: [var-template] Accept variable template declaration

2013-03-30 Thread Jason Merrill

On 03/29/2013 10:56 PM, Gabriel Dos Reis wrote:

   int wanted = num_template_headers_for_class (ctx);


I think you want to add one to wanted if decl is a primary template.

Jason