[google] Use R_ARM_GOT_PREL to simplify global address loading from GOT (issue4433079)

2011-04-27 Thread Guozhi Wei
Hi

This patch is for google/main.

The bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43129 describes
how arm backend generates ineffecient code to load global variable's
address in terms of both code size and performance when option -fpic
is specified. It also describes how it can be improved by relocation
R_ARM_GOT_PREL.

This patch contains a new pass simplify-got to implement the suggested
optimization and the hooks for arm.

This new pass can also be applied to different targets when they satisfy

1. There should be at least 2 methods to load a global variable's
   address from GOT. Usually it means using different relocation types.

2. By default all global variable's address loading use the same
   method: first load the base address of GOT into a register pic_reg,
   then the real global variable's address is loaded as
   (SET offset_reg )
   (SET address_reg (MEM (PLUS pic_reg offset_reg)))

3. When considering the given number of global variable accesses and
   the number of accessed variables there is a target dependent
   situation that the alternative method may be better.

4. The alternative method doesn't use the base of GOT (pic_reg).

This patch depends on the arm relocation R_ARM_GOT_PREL which is
implemented in binutils 2.21.

This patch has been tested on arm qemu. It also bootstraped and regression
tested on x86_64.

thanks
Carrot


2011-04-28  Guozhi Wei  

PR target/43129
* gcc/hooks.c (hook_rtx_void_null): New function.
* gcc/hooks.h (hook_rtx_void_null): New prototype.
* gcc/target.def (got_access): New hook vector declaration.
* gcc/tree-pass.h (pass_simplify_got): New pass.
* gcc/timevar.def (TV_SIMPLIFY_GOT): New TV id.
* gcc/simplify-got.c: New source file.
* gcc/Makefile.in (simplify-got.o): Add a new file.
* gcc/passes.c (init_optimization_passes): Add a new pass.
* gcc/config/arm/arm.c (arm_output_addr_const_extra): Output GOT_PREL
relocation.
(arm_get_pic_reg): New function.
(arm_clear_pic_reg): New function.
(arm_can_simplify_got_access): New function.
(arm_loaded_global_var): New function.
(arm_load_global_address): New function.
* gcc/config/arm/arm.md (UNSPEC_GOT_PREL_SYM): New UNSPEC symbol.

2011-04-28  Guozhi Wei  

PR target/43129
* gcc/testsuite/gcc.target/arm/got1.c: New testcase.
* gcc/testsuite/gcc.target/arm/got2.c: New testcase.

Index: gcc/hooks.c
===
--- gcc/hooks.c (revision 172951)
+++ gcc/hooks.c (working copy)
@@ -280,6 +280,13 @@ hook_rtx_tree_int_null (tree a ATTRIBUTE
   return NULL;
 }
 
+/* Generic hook that returns NULL_RTX. */
+rtx
+hook_rtx_void_null (void)
+{
+  return NULL;
+}
+
 /* Generic hook that takes three trees and returns the last one as is.  */
 tree
 hook_tree_tree_tree_tree_3rd_identity (tree a ATTRIBUTE_UNUSED,
Index: gcc/hooks.h
===
--- gcc/hooks.h (revision 172951)
+++ gcc/hooks.h (working copy)
@@ -84,6 +84,7 @@ extern bool default_can_output_mi_thunk_
 extern rtx hook_rtx_rtx_identity (rtx);
 extern rtx hook_rtx_rtx_null (rtx);
 extern rtx hook_rtx_tree_int_null (tree, int);
+extern rtx hook_rtx_void_null (void);
 
 extern const char *hook_constcharptr_const_tree_null (const_tree);
 extern const char *hook_constcharptr_const_rtx_null (const_rtx);
Index: gcc/target.def
===
--- gcc/target.def  (revision 172951)
+++ gcc/target.def  (working copy)
@@ -2615,6 +2615,68 @@ DEFHOOK
 
 HOOK_VECTOR_END (target_option)
 
+/* Functions used to simplify GOT access.  */
+#undef HOOK_PREFIX
+#define HOOK_PREFIX "TARGET_"
+HOOK_VECTOR (TARGET_SIMPLIFY_GOT_ACCESS, simplify_got_access)
+
+/* Function to get the pic_reg which holds the base address of GOT.  */
+DEFHOOK
+(get_pic_reg,
+"Return the pic_reg pseudo register which holds the base address of GOT.\
+ It is only required by the simplify-got optimization.",
+ rtx, (void),
+ hook_rtx_void_null)
+
+/* Function to clear the pic_reg which is useless now.  */
+DEFHOOK
+(clear_pic_reg,
+"After successful simplify-got optimization, the pic_reg is useless. So a\
+ target can use this hook to clear pic_reg.",
+ void, (void),
+ NULL)
+
+/* Function to detect if the specified insn loads a global variable's
+   address from GOT. If so returns that symbol.  */
+DEFHOOK
+(loaded_global_var,
+"This hook is used to detect if the given @var{insn} loads a global\
+ variable's address from GOT with the form of\
+ @smallexample\
+ (set @var{address_reg} (mem (plus pic_reg @var{offset_reg})))\
+ @end smallexample\
+ If so return the global variable whose address will be loaded and fill in\
+ @var{offset_insn} and @var{offset_reg}. @var{offset_reg} is set at\
+ @var{offset_insn} to hold the offset from GOT base to the GOT entry of the\
+ global vari

Re: Toplevel cleanup: disable Java when libffi not supported

2011-04-27 Thread Paolo Bonzini

On 04/27/2011 06:33 PM, Joseph S. Myers wrote:

This patch, relative to a tree with
  applied,
continues the cleanup of toplevel cases relating to disabling Java or
Java libraries by arranging for Java to be disabled (via
unsupported_languages) on targets not supporting libffi, and removing
many cases in the Java-disabling case statement that are no longer
needed, either because they relate to targets not supporting libffi or
because they relate to targets no longer supported in GCC so it
doesn't matter what the Java configuration is for them.

The ideal would be for information about libffi-supported targets to
come from a configure fragment in the libffi/ directory, as per item 4
in.  Given that at
present there is some divergence between the libffi repository and the
GCC copy of libffi, however, now may not be the best time to add such
a fragment in GCC; instead, I put a minimal case statement (covering
only targets supported by both libffi and GCC) at toplevel.

Where Java-disabling-related cases did more than just disabling Java
or ${libgcj} (for example, explicitly disabling target-boehm-gc or
target-libffi) I left them in for now even if not strictly needed with
the separate libffi case statement.

This patch is intended to be safe, in that the only way it should
change behavior for targets supported by GCC is to disable Java in
some cases where the libraries would not build because of lack of
libffi support (whether or not the libraries and front end were
previously enabled in such cases).

OK to commit?

2011-04-27  Joseph Myers

* configure.ac: Disable Java for targets not supporting libffi.
(*-*-kaos*, am33_2.0-*-linux*, sh*-*-pe|mips*-*-pe): Remove cases
in Java-disabling statement.
(*arm-wince-pe): Change to arm-wince-pe.
(arc-*-*, arm-*-coff, arm-*-pe*, arm-*-riscix*, avr-*-*): Remove
cases in Java-disabling statement.
(bfin-*-*): Don't disable Java again.
(c4x-*-* | tic4x-*-*, tic54x-*-*, cr16-*-*, d10v-*-*, d30v-*-*,
fr30-*-elf*, moxie-*-*, h8300*-*-*, h8500-*-*, hppa1.1-*-osf* |
hppa1.1-*-bsd*, hppa*-*-*elf*  | hppa*-*-lites* | hppa*-*-openbsd*,
hppa*-*-pro*, i960-*-*, i[[3456789]]86-*-coff,
i[[3456789]]86-*-pe, i[[3456789]]86-*-sco3.2v5*,
i[[3456789]]86-*-sco*, i[[3456789]]86-*-sysv4*,
i[[3456789]]86-*-beos*, i[[3456789]]86-*-rdos*,
m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*): Remove cases in
Java-disabling statement.
(mmix-*-*): Don't disable Java again.
(mt-*-*, powerpc*-*-winnt* | powerpc*-*-pe*, powerpcle-*-solaris*,
powerpc-*-beos*, rs6000-*-lynxos*, rs6000-*-*, m68k-apollo-*,
microblaze*, mips*-sde-elf*, mips*-*-irix5*, mips*-*-bsd*,
sparclet-*-aout* | sparc86x-*-*, sparclite-*-*, sparc-*-sunos4*,
tic6x-*-*, v810-*-*, vax-*-*): Remove cases in Java-disabling
statement.
* configure: Regenerate.



Ok.

Do you plan to finish the switch to unsupported_languages instead of 
noconfigdirs soon )for Java)?


Paolo


Re: Toplevel cleanup: split out libgcj disabling

2011-04-27 Thread Paolo Bonzini

On 04/27/2011 05:50 PM, Joseph S. Myers wrote:

Continuing the toplevel cleanups separating the cases disabling
different subdirectories - on the basis that eventually this
information should come from the subdirectories, and that as
previously discussed much of the default disabling of ${libgcj}
doesn't actually make sense - this patch separates the
Java-and-${libgcj}-disabling cases out from the rest of the
directory-disabling cases.

This patch deliberately keeps the case structure the same to make it
clear it does not change the set of disabled directories at all - thus
there are now empty cases in both the old and the new case statements.
These are intended to be cleaned up in subsequent patches.  (Removing
an empty case is not automatically obvious, since it may cause a later
case such as *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu |
*-*-kopensolaris*-gnu or *-*-* to be active instead.  In many cases
they can be removed, because the combination that would activate the
other case is not meaningful or because it doesn't matter what the
Java configuration is for targets that have been removed from or never
supported in GCC - but I prefer to keep such removals separate.)

OK to commit?

2011-04-27  Joseph Myers

* configure.ac: Separate cases disabling Java and Java libraries
from general case over targets.
* configure: Regenerate.


Ok.

Paolo


Re: [C++ Patch] PR 48771

2011-04-27 Thread Jason Merrill

On 04/27/2011 04:50 AM, Paolo Carlini wrote:

Tested x86_64-linux. Ok for mainline?


Yes.


(not sure if it qualifies for the
branch or we want to reconsider it in a couple of weeks?!?)


The latter, I think.

Jason


Re: C++ PATCH for libstdc++/48760 (list-initialization of complex)

2011-04-27 Thread Lawrence Crowl
On 4/27/11, Jason Merrill  wrote:
> On 04/27/2011 09:36 PM, Jason Merrill wrote:
>> A a = { 1, 2 };
>>
>> a.c is initialized to 1+0i rather than 1+2i as it has been previously,
>
> This should have said "a.c is initialized to 1+0i, as it has been
> previously, rather than 1+2i, as it would be if it were an aggregate".

This looks right to me.  It's more in line with C99.

-- 
Lawrence Crowl


[patch, ARM] Fix PR42017, LR not used in leaf functions

2011-04-27 Thread Chung-Lin Tang
Hi, this patch tries to solve the problem of the LR register not
being used in leaf functions on ARM.

Looking at the dumps, it shows that register 14 (lr) conflicts with all
allocnos throughout the entire leaf procedure. A little digging shows
that lr is present in the OBJECT_CONFLICT_HARD_REGS() set of all
allocnos, which suggests that this may manifest from a convention of
some sort the code is currently following.

It turns out that, during the IRA liveness computations, the DF initing
of live hard regs, starting from the bottom end of the function, adds
EPILOGUE_USES right from the start. With no call sites to kill its
liveness, the entire procedure is prohibited from using LR at all.

This problem may also be more serious than just leaf functions.
Theoretically, this may affect all allocnos that happen to completely
lie on paths that reach the end of function without a call site, even in
non-leaf functions. All these are deprived of LR as an usable register.

My fix here simply adds 'reload_completed' as an additional condition
for EPILOGUE_USES to return true for LR_REGNUM. I think this should be
valid, as correct LR save/restoring is handled by the epilogue/prologue
code; it should be safe for IRA to treat it as a normal call-used register.

I did a cross-test on QEMU with clean results, plus a successful native
bootstrap on a Pandaboard. Is this okay for trunk?

Thanks,
Chung-Lin

2011-04-28  Chung-Lin Tang  

PR target/42017
* config/arm/arm.h (EPILOGUE_USES): Only return true
for LR_REGNUM after reload_completed.

Index: config/arm/arm.h
===
--- config/arm/arm.h(revision 173046)
+++ config/arm/arm.h(working copy)
@@ -1627,7 +1627,7 @@
frame.  */
 #define EXIT_IGNORE_STACK 1
 
-#define EPILOGUE_USES(REGNO) ((REGNO) == LR_REGNUM)
+#define EPILOGUE_USES(REGNO) (reload_completed && (REGNO) == LR_REGNUM)
 
 /* Determine if the epilogue should be output as RTL.
You should override this if you define FUNCTION_EXTRA_EPILOGUE.  */



Re: restore bootstrap with a C++ compiler

2011-04-27 Thread Gabriel Dos Reis
Andrew Pinski  writes:

| On Wed, Apr 27, 2011 at 6:48 PM, Gabriel Dos Reis  wrote:
| > A local `extern' declaration does not give the entity an external linkage
| > -- irrespective of the linkage of the function enclosing the declaration.
| > It just makes the name locally available for name lookup
| > purpose.   A variable declared const has
| >  -- external linkage by default in C
| >  -- internal linkage by default in C++
| >
| > So before the patch: the variables had external linkage in C, but
| > internal linkage in C++.  That meant that a link will fail in C++, but
| > succeeds in C.  All my patch did was to give the external linkage
| > explicitly (both in C and in C++.)
| 
| Then I think a better fix is to do:
| Index: internal-fn.c
| ===
| --- internal-fn.c (revision 172940)
| +++ internal-fn.c (working copy)
| @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.
|  #include "gimple.h"
| 
|  /* The names of each internal function, indexed by function number.  */
| +extern const char *const internal_fn_name_array[];
|  const char *const internal_fn_name_array[] = {
|  #define DEF_INTERNAL_FN(CODE, FLAGS) #CODE,
|  #include "internal-fn.def"
| @@ -35,6 +36,7 @@ const char *const internal_fn_name_array
|  };
| 
|  /* The ECF_* flags of each internal function, indexed by function number.  */
| +extern const int internal_fn_flags_array[];
|  const int internal_fn_flags_array[] = {
|  #define DEF_INTERNAL_FN(CODE, FLAGS) FLAGS,
|  #include "internal-fn.def"
| --- CUT ---
| So nobody is tempted to use those arrays directly from the code but
| rather only use the static inline functions.

Well, anybody who can put those extern declarations anywhere and use
them directly.  The real issue is that the array variables have external
linkage.

So, I think the patch is largely stylistic but equivalent; I'll defer to
you which one should "prevail".

-- Gaby


Here is an updated patch. (issue4438079)

2011-04-27 Thread Sharad Singhai
Hi Diego,

Thanks for the quick feedback. Here is a an updated version of the patch.

2011-04-27  Sharad Singhai  

ChangeLog.google-main
* params.def: Add new parameters to control peeling.
* tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Use
different peeling parameters when profile feedback is available.
* loop-unroll.c (decide_peel_once_rolling): Ditto.
(decide_peel_completely): Ditto.
* doc/invoke.texi: Document new peeling parameters.

testsuite/ChangeLog.google-main
* gcc.dg/vect/O3-vect-pr34223.c: Add new peeling
parameters.
* gcc.dg/vect/vect.exp: Allow reading flags in individual
tests.

Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 172904)
+++ doc/invoke.texi (working copy)
@@ -8523,11 +8523,28 @@
 The maximum number of peelings of a single loop.
 
 @item max-completely-peeled-insns
+@item max-completely-peeled-insns-feedback
 The maximum number of insns of a completely peeled loop.
 
+The @option{max-completely-peeled-insns-feedback} is used only when profile
+feedback is available and the loop is hot. Because of the real profiles, this
+value may set to be larger for hot loops.
+
+@item max-once-peeled-insns
+@item max-once-peeled-insns-feedback
+The maximum number of insns of a peeled loop that rolls only once.
+The @option{max-once-peeled-insns-feedback}  is used only when profile feedback
+is available and the loop is hot. Because of the real profiles, this value
+may set to be larger for hot loops.
+
 @item max-completely-peel-times
+@item max-completely-peel-times-feedback
 The maximum number of iterations of a loop to be suitable for complete peeling.
 
+The @option{max-completely-peel-times-feedback} is used only when profile 
feedback
+is available and the loop is hot. Because of the real profiles, this value may
+set to be larger for hot loops.
+
 @item max-completely-peel-loop-nest-depth
 The maximum depth of a loop nest suitable for complete peeling.
 
Index: testsuite/gcc.dg/vect/O3-vect-pr34223.c
===
--- testsuite/gcc.dg/vect/O3-vect-pr34223.c (revision 172904)
+++ testsuite/gcc.dg/vect/O3-vect-pr34223.c (working copy)
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target vect_int } */
+/* { dg-options "[vect_cflags] --param max-completely-peel-times=16" } */
 
 #include "tree-vect.h"
 
Index: testsuite/gcc.dg/vect/vect.exp
===
--- testsuite/gcc.dg/vect/vect.exp  (revision 172904)
+++ testsuite/gcc.dg/vect/vect.exp  (working copy)
@@ -24,6 +24,12 @@
 global DEFAULT_VECTCFLAGS
 set DEFAULT_VECTCFLAGS ""
 
+# So that we can read flags in individual tests.
+proc vect_cflags { } {
+  global DEFAULT_VECTCFLAGS
+  return $DEFAULT_VECTCFLAGS
+}
+
 # If the target system supports vector instructions, the default action
 # for a test is 'run', otherwise it's 'compile'.  Save current default.
 # Executing vector instructions on a system without hardware vector support
Index: tree-ssa-loop-ivcanon.c
===
--- tree-ssa-loop-ivcanon.c (revision 172904)
+++ tree-ssa-loop-ivcanon.c (working copy)
@@ -326,6 +326,7 @@
enum unroll_level ul)
 {
   unsigned HOST_WIDE_INT n_unroll, ninsns, max_unroll, unr_insns;
+  unsigned HOST_WIDE_INT max_peeled_insns;
   gimple cond;
   struct loop_size size;
 
@@ -336,9 +337,23 @@
 return false;
   n_unroll = tree_low_cst (niter, 1);
 
-  max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES);
+  if (profile_info
+  && flag_branch_probabilities
+  && optimize_loop_for_speed_p (loop))
+max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES_FEEDBACK);
+  else
+max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES);
+
   if (n_unroll > max_unroll)
+{
+  if (dump_file && (dump_flags & TDF_DETAILS))
+   {
+ fprintf (dump_file, "  Not unrolling loop %d limited by max unroll"
+   " (%d > %d)\n",
+   loop->num, (int) n_unroll, (int) max_unroll);
+}
 return false;
+  }
 
   if (n_unroll)
 {
@@ -356,14 +371,21 @@
   (int) unr_insns);
}
 
-  if (unr_insns > ninsns
- && (unr_insns
- > (unsigned) PARAM_VALUE (PARAM_MAX_COMPLETELY_PEELED_INSNS)))
+  if (profile_info
+  && flag_branch_probabilities
+  && optimize_loop_for_speed_p (loop))
+max_peeled_insns =
+  PARAM_VALUE (PARAM_MAX_COMPLETELY_PEELED_INSNS_FEEDBACK);
+  else
+max_peeled_insns = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEELED_INSNS);
+
+  if (unr_insns > max_peeled_insns)
{
  if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Not unrolling loop %d "
-   

Re: restore bootstrap with a C++ compiler

2011-04-27 Thread Andrew Pinski
On Wed, Apr 27, 2011 at 6:48 PM, Gabriel Dos Reis  wrote:
> A local `extern' declaration does not give the entity an external linkage
> -- irrespective of the linkage of the function enclosing the declaration.
> It just makes the name locally available for name lookup
> purpose.   A variable declared const has
>  -- external linkage by default in C
>  -- internal linkage by default in C++
>
> So before the patch: the variables had external linkage in C, but
> internal linkage in C++.  That meant that a link will fail in C++, but
> succeeds in C.  All my patch did was to give the external linkage
> explicitly (both in C and in C++.)

Then I think a better fix is to do:
Index: internal-fn.c
===
--- internal-fn.c   (revision 172940)
+++ internal-fn.c   (working copy)
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.
 #include "gimple.h"

 /* The names of each internal function, indexed by function number.  */
+extern const char *const internal_fn_name_array[];
 const char *const internal_fn_name_array[] = {
 #define DEF_INTERNAL_FN(CODE, FLAGS) #CODE,
 #include "internal-fn.def"
@@ -35,6 +36,7 @@ const char *const internal_fn_name_array
 };

 /* The ECF_* flags of each internal function, indexed by function number.  */
+extern const int internal_fn_flags_array[];
 const int internal_fn_flags_array[] = {
 #define DEF_INTERNAL_FN(CODE, FLAGS) FLAGS,
 #include "internal-fn.def"
--- CUT ---
So nobody is tempted to use those arrays directly from the code but
rather only use the static inline functions.

Thanks,
Andrew Pinski


Re: C++ PATCH for libstdc++/48760 (list-initialization of complex)

2011-04-27 Thread Jason Merrill

On 04/27/2011 09:36 PM, Jason Merrill wrote:

A a = { 1, 2 };

a.c is initialized to 1+0i rather than 1+2i as it has been previously,


This should have said "a.c is initialized to 1+0i, as it has been 
previously, rather than 1+2i, as it would be if it were an aggregate".


Jason


Re: C++ PATCH for libstdc++/48760 (list-initialization of complex)

2011-04-27 Thread Gabriel Dos Reis
Jason Merrill  writes:

| In the discussion of 48760, Gaby suggested that we allow
| list-initialization of built-in complex numbers.  This made a lot of
| sense to me, so I've gone ahead and implemented it.
| 
| Basically it works as though complex were an aggregate except for one
| thing: for backwards compatibility, we never assume elided braces when
| initializing a complex number.  So given
| 
| struct A
| {
|   _Complex int c;
|   int i;
| };
| 
| A a = { 1, 2 };
| 
| a.c is initialized to 1+0i rather than 1+2i as it has been previously,
| and a.i is initialized to 2.

Many thanks, Jason.

-- Gaby


Re: restore bootstrap with a C++ compiler

2011-04-27 Thread Gabriel Dos Reis
Andrew Pinski  writes:

| On Wed, Apr 27, 2011 at 6:30 PM, Gabriel Dos Reis  wrote:
| >
| > Richard,
| >
| > Your recent patch broke --enable-build-with-cxx because internal-fn.h
| > was using good 'ol C-style name lookup trick that behaves badly with
| > C++ linkage rules.  Fixed thusly.  Applied as obvious.
| 
| Can you explain some more?  Does it have do with the fact those
| functions are static?

The issue has nothing to do with the fact that the functions are static.

A local `extern' declaration does not give the entity an external linkage
-- irrespective of the linkage of the function enclosing the declaration.
It just makes the name locally available for name lookup
purpose.   A variable declared const has
 -- external linkage by default in C
 -- internal linkage by default in C++

So before the patch: the variables had external linkage in C, but
internal linkage in C++.  That meant that a link will fail in C++, but
succeeds in C.  All my patch did was to give the external linkage
explicitly (both in C and in C++.)

|  If so I think we should move away from static
| functions for compiling with C++ and move to using anonymous
| namespaces.

I suspect that is a separate issue.

BTW, in my own codes I still use "static" for non-member functions
because the compiler will tell me when a function becomes unused.
GCC at the moment is unable to tell when a function in an unnamed
namespace is unused (that is surely a bug.)  For that reason alone, I
would recommend that we keep "static" for functions.

-- Gaby


C++ PATCH for c++/40975 (ICE with new in default arg)

2011-04-27 Thread Jason Merrill
When we expand a default argument, we need to rebuild any TARGET_EXPRs 
so that we don't run into issues with invalid tree sharing.  But 
copy_tree_r isn't prepared to deal with the STATEMENT_LIST created by 
array initialization.


Since I already introduced VEC_INIT_EXPR in the constexpr work, it seems 
to make sense to extend it to be usable for array new as well.  So this 
patch does that.


Tested x86_64-pc-linux-gnu, applying to trunk.  I'm also applying a tiny 
tweak I made while looking at this; it was bizarre that we were deciding 
whether or not to delete the array pointer based on whether the value 
was sfk_base_destructor.
commit 9262255ba31a1623bcb63df6104d56d0558bdc8c
Author: Jason Merrill 
Date:   Wed Apr 27 12:56:16 2011 -0400

PR c++/40975
* cp-tree.def (VEC_INIT_EXPR): Add third operand.
* cp-tree.h (VEC_INIT_EXPR_NELTS): New.
* cp-gimplify.c (cp_gimplify_expr) [VEC_INIT_EXPR]: Handle it.
* tree.c (build_vec_init_expr): Handle getting pointer/nelts.
(build_vec_init_elt): Don't expect an array type.
(build_array_copy): Adjust.
* init.c (perform_member_init): Adjust.
(build_new_1): Use build_vec_init_expr.

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 63277ca..802040d 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -9580,6 +9580,17 @@ make_tree_vector_single (tree t)
   return ret;
 }
 
+/* Get a new tree vector of the TREE_VALUEs of a TREE_LIST chain.  */
+
+VEC(tree,gc) *
+make_tree_vector_from_list (tree list)
+{
+  VEC(tree,gc) *ret = make_tree_vector ();
+  for (; list; list = TREE_CHAIN (list))
+VEC_safe_push (tree, gc, ret, TREE_VALUE (list));
+  return ret;
+}
+
 /* Get a new tree vector which is a copy of an existing one.  */
 
 VEC(tree,gc) *
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 09aa600..ad6da6b 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -959,6 +959,7 @@ extern void set_underlying_type (tree x);
 extern VEC(tree,gc) *make_tree_vector (void);
 extern void release_tree_vector (VEC(tree,gc) *);
 extern VEC(tree,gc) *make_tree_vector_single (tree);
+extern VEC(tree,gc) *make_tree_vector_from_list (tree);
 extern VEC(tree,gc) *make_tree_vector_copy (const VEC(tree,gc) *);
 
 /* In c-gimplify.c  */
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index ca62df3..dc2e0fb 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -530,10 +530,12 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, 
gimple_seq *post_p)
   {
location_t loc = input_location;
tree init = VEC_INIT_EXPR_INIT (*expr_p);
-   int from_array = (init && TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE);
+   int from_array = (init && TREE_TYPE (init)
+ && TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE);
gcc_assert (EXPR_HAS_LOCATION (*expr_p));
input_location = EXPR_LOCATION (*expr_p);
-   *expr_p = build_vec_init (VEC_INIT_EXPR_SLOT (*expr_p), NULL_TREE,
+   *expr_p = build_vec_init (VEC_INIT_EXPR_SLOT (*expr_p),
+ VEC_INIT_EXPR_NELTS (*expr_p),
  init, VEC_INIT_EXPR_VALUE_INIT (*expr_p),
  from_array,
  tf_warning_or_error);
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 7bd35e0..c9fc970 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -83,8 +83,8 @@ DEFTREECODE (AGGR_INIT_EXPR, "aggr_init_expr", tcc_vl_exp, 3)
 
 /* Initialization of an array from another array, expressed at a high level
so that it works with TARGET_EXPR.  Operand 0 is the target, operand 1
-   is the initializer.  */
-DEFTREECODE (VEC_INIT_EXPR, "vec_init_expr", tcc_expression, 2)
+   is the initializer, operand 2 is the number of elements or NULL_TREE.  */
+DEFTREECODE (VEC_INIT_EXPR, "vec_init_expr", tcc_expression, 3)
 
 /* A throw expression.  operand 0 is the expression, if there was one,
else it is NULL_TREE.  */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 26da4b3..a65998d 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2896,8 +2896,9 @@ more_aggr_init_expr_args_p (const 
aggr_init_expr_arg_iterator *iter)
(arg) = next_aggr_init_expr_arg (&(iter)))
 
 /* VEC_INIT_EXPR accessors.  */
-#define VEC_INIT_EXPR_SLOT(NODE) TREE_OPERAND (NODE, 0)
-#define VEC_INIT_EXPR_INIT(NODE) TREE_OPERAND (NODE, 1)
+#define VEC_INIT_EXPR_SLOT(NODE) TREE_OPERAND (VEC_INIT_EXPR_CHECK (NODE), 0)
+#define VEC_INIT_EXPR_INIT(NODE) TREE_OPERAND (VEC_INIT_EXPR_CHECK (NODE), 1)
+#define VEC_INIT_EXPR_NELTS(NODE) TREE_OPERAND (VEC_INIT_EXPR_CHECK (NODE), 2)
 
 /* Indicates that a VEC_INIT_EXPR is a potential constant expression.
Only set when the current function is constexpr.  */
@@ -5022,6 +5023,7 @@ extern tree get_copy_ctor (tree);
 extern tree get_copy_assign(tree);
 extern tree get_defa

[PATCH][libstdc++] Also install cxxabi_tweaks.h in freestanding mode.

2011-04-27 Thread 關振德
Hi,

   This patch causes cxxabi_tweaks.h to be installed in freestanding
mode.  We need this because libsupc++ installs cxxabi.h, which
includes cxx_tweaks.h.

-Doug


2011-04-27  Doug Kwan  

* include/Makefile.am (install-freestanding-headers): Also install
cxxabi_tweaks.h.
* include/Makefile.in: Regnerate.
Index: libstdc++-v3/include/Makefile.in
===
--- libstdc++-v3/include/Makefile.in(revision 173055)
+++ libstdc++-v3/include/Makefile.in(working copy)
@@ -1584,6 +1584,7 @@ install-freestanding-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}
$(mkinstalldirs) $(DESTDIR)${host_installdir}
for file in ${host_srcdir}/os_defines.h ${host_builddir}/c++config.h \
+ ${glibcxx_srcdir}/$(ABI_TWEAKS_SRCDIR)/cxxabi_tweaks.h \
  ${glibcxx_srcdir}/$(CPU_DEFINES_SRCDIR)/cpu_defines.h; do \
  $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir}
Index: libstdc++-v3/include/Makefile.am
===
--- libstdc++-v3/include/Makefile.am(revision 173055)
+++ libstdc++-v3/include/Makefile.am(working copy)
@@ -1200,6 +1200,7 @@ install-freestanding-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}
$(mkinstalldirs) $(DESTDIR)${host_installdir}
for file in ${host_srcdir}/os_defines.h ${host_builddir}/c++config.h \
+ ${glibcxx_srcdir}/$(ABI_TWEAKS_SRCDIR)/cxxabi_tweaks.h \
  ${glibcxx_srcdir}/$(CPU_DEFINES_SRCDIR)/cpu_defines.h; do \
  $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir}


C++ PATCH for libstdc++/48760 (list-initialization of complex)

2011-04-27 Thread Jason Merrill
In the discussion of 48760, Gaby suggested that we allow 
list-initialization of built-in complex numbers.  This made a lot of 
sense to me, so I've gone ahead and implemented it.


Basically it works as though complex were an aggregate except for one 
thing: for backwards compatibility, we never assume elided braces when 
initializing a complex number.  So given


struct A
{
  _Complex int c;
  int i;
};

A a = { 1, 2 };

a.c is initialized to 1+0i rather than 1+2i as it has been previously, 
and a.i is initialized to 2.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 0131da0c5a789fc9f952a05d9d06262b2c72b980
Author: Jason Merrill 
Date:   Wed Apr 27 20:25:50 2011 -0400

PR libstdc++/48760
Implement list-initialization of _Complex.
* decl.c (reshape_init_r): Allow {real,imag} for _Complex.
(check_initializer): Likewise.
* call.c (build_complex_conv): New.
(implicit_conversion): Call it.
(convert_like_real): Handle it.
* typeck2.c (check_narrowing): Handle it.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 10efd1c..dcc3859 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -847,6 +847,49 @@ build_array_conv (tree type, tree ctor, int flags)
   return c;
 }
 
+/* Represent a conversion from CTOR, a braced-init-list, to TYPE, a
+   complex type, if such a conversion is possible.  */
+
+static conversion *
+build_complex_conv (tree type, tree ctor, int flags)
+{
+  conversion *c;
+  unsigned HOST_WIDE_INT len = CONSTRUCTOR_NELTS (ctor);
+  tree elttype = TREE_TYPE (type);
+  unsigned i;
+  tree val;
+  bool bad = false;
+  bool user = false;
+  enum conversion_rank rank = cr_exact;
+
+  if (len != 2)
+return NULL;
+
+  FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), i, val)
+{
+  conversion *sub
+   = implicit_conversion (elttype, TREE_TYPE (val), val,
+  false, flags);
+  if (sub == NULL)
+   return NULL;
+
+  if (sub->rank > rank)
+   rank = sub->rank;
+  if (sub->user_conv_p)
+   user = true;
+  if (sub->bad_p)
+   bad = true;
+}
+
+  c = alloc_conversion (ck_aggr);
+  c->type = type;
+  c->rank = rank;
+  c->user_conv_p = user;
+  c->bad_p = bad;
+  c->u.next = NULL;
+  return c;
+}
+
 /* Build a representation of the identity conversion from EXPR to
itself.  The TYPE should match the type of EXPR, if EXPR is non-NULL.  */
 
@@ -1646,6 +1689,14 @@ implicit_conversion (tree to, tree from, tree expr, bool 
c_cast_p,
   if (is_std_init_list (to))
return build_list_conv (to, expr, flags);
 
+  /* As an extension, allow list-initialization of _Complex.  */
+  if (TREE_CODE (to) == COMPLEX_TYPE)
+   {
+ conv = build_complex_conv (to, expr, flags);
+ if (conv)
+   return conv;
+   }
+
   /* Allow conversion from an initializer-list with one element to a
 scalar type.  */
   if (SCALAR_TYPE_P (to))
@@ -5516,6 +5567,17 @@ convert_like_real (conversion *convs, tree expr, tree 
fn, int argnum,
   }
 
 case ck_aggr:
+  if (TREE_CODE (totype) == COMPLEX_TYPE)
+   {
+ tree real = CONSTRUCTOR_ELT (expr, 0)->value;
+ tree imag = CONSTRUCTOR_ELT (expr, 1)->value;
+ real = perform_implicit_conversion (TREE_TYPE (totype),
+ real, complain);
+ imag = perform_implicit_conversion (TREE_TYPE (totype),
+ imag, complain);
+ expr = build2 (COMPLEX_EXPR, totype, real, imag);
+ return fold_if_not_in_template (expr);
+   }
   return get_target_expr (digest_init (totype, expr));
 
 default:
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index ccc5fd0..5bf637e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5058,6 +5058,27 @@ reshape_init_r (tree type, reshape_iter *d, bool 
first_initializer_p)
   if (error_operand_p (init))
 return error_mark_node;
 
+  if (TREE_CODE (type) == COMPLEX_TYPE)
+{
+  /* A complex type can be initialized from one or two initializers,
+but braces are not elided.  */
+  d->cur++;
+  if (BRACE_ENCLOSED_INITIALIZER_P (init))
+   {
+ if (CONSTRUCTOR_NELTS (init) > 2)
+   error ("too many initializers for %qT", type);
+   }
+  else if (first_initializer_p && d->cur != d->end)
+   {
+ VEC(constructor_elt, gc) *v = 0;
+ CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init);
+ CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, d->cur->value);
+ d->cur++;
+ init = build_constructor (init_list_type_node, v);
+   }
+  return init;
+}
+
   /* A non-aggregate type is always initialized with a single
  initializer.  */
   if (!CP_AGGREGATE_TYPE_P (type))
@@ -5325,7 +5346,7 @@ check_initializer (tree decl, tree init, int flags, tree 
*cleanup)
  maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
  init = build_zero_init (type, 

Re: restore bootstrap with a C++ compiler

2011-04-27 Thread Andrew Pinski
On Wed, Apr 27, 2011 at 6:30 PM, Gabriel Dos Reis  wrote:
>
> Richard,
>
> Your recent patch broke --enable-build-with-cxx because internal-fn.h
> was using good 'ol C-style name lookup trick that behaves badly with
> C++ linkage rules.  Fixed thusly.  Applied as obvious.

Can you explain some more?  Does it have do with the fact those
functions are static?  If so I think we should move away from static
functions for compiling with C++ and move to using anonymous
namespaces.

Thanks,
Andrew Pinski


restore bootstrap with a C++ compiler

2011-04-27 Thread Gabriel Dos Reis

Richard,

Your recent patch broke --enable-build-with-cxx because internal-fn.h
was using good 'ol C-style name lookup trick that behaves badly with
C++ linkage rules.  Fixed thusly.  Applied as obvious.

-- Gaby

2011-04-27  Gabriel Dos Reis  

* internal-fn.h (internal_fn_name_array): Declare.
(internal_fn_flags_array): Likewise.

*** internal-fn.h   (revision 173070)
--- internal-fn.h   (local)
*** enum internal_fn {
*** 30,48 
  /* Return the name of internal function FN.  The name is only meaningful
 for dumps; it has no linkage.  */
  
  static inline const char *
  internal_fn_name (enum internal_fn fn)
  {
-   extern const char *const internal_fn_name_array[];
return internal_fn_name_array[(int) fn];
  }
  
  /* Return the ECF_* flags for function FN.  */
  
  static inline int
  internal_fn_flags (enum internal_fn fn)
  {
-   extern const int internal_fn_flags_array[];
return internal_fn_flags_array[(int) fn];
  }
  
--- 30,50 
  /* Return the name of internal function FN.  The name is only meaningful
 for dumps; it has no linkage.  */
  
+ extern const char *const internal_fn_name_array[];
+ 
  static inline const char *
  internal_fn_name (enum internal_fn fn)
  {
return internal_fn_name_array[(int) fn];
  }
  
  /* Return the ECF_* flags for function FN.  */
  
+ extern const int internal_fn_flags_array[];
+ 
  static inline int
  internal_fn_flags (enum internal_fn fn)
  {
return internal_fn_flags_array[(int) fn];
  }
  



[PATCH 4/4] Docs: extend.texi: Reword and rearrange attribute node introductions

2011-04-27 Thread Michael Witten
The rearrangement performed in the previous patch left the text in
somewhat of an inconsistent state in terms of the flow of concepts;
this patch improves the flow of concepts to something more sane by
editing the introductions to these nodes:

  Attribute Syntax
  Type Attributes
  Variable Attributes
  Function Attributes

---
 trunk/gcc/doc/extend.texi |   53 +++-
 1 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/trunk/gcc/doc/extend.texi b/trunk/gcc/doc/extend.texi
index 3b453e5..a9611de 100644
--- a/trunk/gcc/doc/extend.texi
+++ b/trunk/gcc/doc/extend.texi
@@ -1962,10 +1962,22 @@
 @cindex attribute syntax
 
 This section describes the syntax with which @code{__attribute__} may be
-used, and the constructs to which attribute specifiers bind, for the C
+used, and the constructs to which attribute specifiers bind for the C
-language.  Some details may vary for C++ and Objective-C@.  Because of
+language and (to a limited degree) some of its descendants.
+
+The keyword @code{__attribute__} allows you to specify special
+attributes when making a declaration.  This keyword is followed by an
+attribute specification inside double parentheses.
+
+You may also specify attributes with @samp{__} preceding and following
+each keyword.  This allows you to use them in header files without
+being concerned about a possible macro of the same name.  For example,
+you may use @code{__noreturn__} instead of @code{noreturn}.
+
+GCC plugins may provide their own attributes.
+
-infelicities in the grammar for attributes, some forms described here
-may not be successfully parsed in all cases.
+Because of infelicities in the grammar for attributes, some forms
+described here may not be successfully parsed in all cases.
 
 There are some problems with the semantics of attributes in C++.  For
 example, there are no manglings for attributes, although they may affect
@@ -2191,6 +2203,9 @@
 @cindex attribute of types
 @cindex type attributes
 
+@xref{Attribute Syntax}, for details of the exact syntax for using
+attributes.
+
 The keyword @code{__attribute__} allows you to specify special
 attributes of @code{struct} and @code{union} types when you define
 such types.  This keyword is followed by an attribute specification
@@ -2583,6 +2598,9 @@
 @cindex attribute of variables
 @cindex variable attributes
 
+@xref{Attribute Syntax}, for details of the exact syntax for using
+attributes.
+
 The keyword @code{__attribute__} allows you to specify special
 attributes of variables or structure fields.  This keyword is followed
 by an attribute specification inside double parentheses.  Some
@@ -3214,14 +3232,17 @@
 @cindex functions that have different optimization options
 @cindex functions that are dynamically resolved
 
-In GNU C, you declare certain things about functions called in your program
-which help the compiler optimize function calls and check your code more
-carefully.
+@xref{Attribute Syntax}, for details of the exact syntax for using
+attributes.
 
-The keyword @code{__attribute__} allows you to specify special
-attributes when making a declaration.  This keyword is followed by an
-attribute specification inside double parentheses.  The following
-attributes are currently defined for functions on all targets:
+The keyword @code{__attribute__} allows you to specify special attributes
+of function declarations in order to help the compiler optimize function
+calls and check your code more carefully. This keyword is followed by
+an attribute specification inside double parentheses. Other attributes
+are available for types (@pxref{Type Attributes}) and for variables
+(@pxref{Variable Attributes}).
+
+The following attributes are currently defined for functions on all targets:
 @code{aligned}, @code{alloc_size}, @code{noreturn},
 @code{returns_twice}, @code{noinline}, @code{noclone},
 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
@@ -3237,16 +3258,6 @@
 including @code{section} are supported for variables declarations
 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
 
-GCC plugins may provide their own attributes.
-
-You may also specify attributes with @samp{__} preceding and following
-each keyword.  This allows you to use them in header files without
-being concerned about a possible macro of the same name.  For example,
-you may use @code{__noreturn__} instead of @code{noreturn}.
-
-@xref{Attribute Syntax}, for details of the exact syntax for using
-attributes.
-
 @table @code
 @c Keep this table alphabetized by attribute name.  Treat _ as space.
 
-- 
1.7.4.18.g68fe8



[PATCH 2/4] Docs: extend.texi: Remove trailing blanks from lines

2011-04-27 Thread Michael Witten
sed -i "s/[ $(printf '\t')]\{1,\}\$//" trunk/gcc/doc/extend.texi

---

 trunk/gcc/doc/extend.texi |   82 ++--
 1 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/trunk/gcc/doc/extend.texi b/trunk/gcc/doc/extend.texi
index c154958..cdbf69f 100644
--- a/trunk/gcc/doc/extend.texi
+++ b/trunk/gcc/doc/extend.texi
@@ -37,7 +37,7 @@
 * Complex:: Data types for complex numbers.
 * Floating Types::  Additional Floating Types.
 * Half-Precision::  Half-Precision Floating Point.
-* Decimal Float::   Decimal Floating Types. 
+* Decimal Float::   Decimal Floating Types.
 * Hex Floats::  Hexadecimal floating-point constants.
 * Fixed-Point:: Fixed-Point Types.
 * Named Address Spaces::Named address spaces.
@@ -455,7 +455,7 @@
 safe.
 
 GCC implements taking the address of a nested function using a technique
-called @dfn{trampolines}.  This technique was described in 
+called @dfn{trampolines}.  This technique was described in
 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
 C++ Conference Proceedings, October 17-21, 1988).
 
@@ -619,7 +619,7 @@
 @}
   return open (path, oflag, __builtin_va_arg_pack ());
 @}
-
+
   if (__builtin_va_arg_pack_len () < 1)
 return __open_2 (path, oflag);
 
@@ -942,7 +942,7 @@
 @cindex @code{__fp16} data type
 
 On ARM targets, GCC supports half-precision (16-bit) floating point via
-the @code{__fp16} type.  You must enable this type explicitly 
+the @code{__fp16} type.  You must enable this type explicitly
 with the @option{-mfp16-format} command-line option in order to use it.
 
 ARM supports two incompatible representations for half-precision
@@ -963,7 +963,7 @@
 The @code{__fp16} type is a storage format only.  For purposes
 of arithmetic and other operations, @code{__fp16} values in C or C++
 expressions are automatically promoted to @code{float}.  In addition,
-you cannot declare a function with a return value or parameters 
+you cannot declare a function with a return value or parameters
 of type @code{__fp16}.
 
 Note that conversions from @code{double} to @code{__fp16}
@@ -971,14 +971,14 @@
 of rounding, this can sometimes produce a different result than a
 direct conversion.
 
-ARM provides hardware support for conversions between 
+ARM provides hardware support for conversions between
 @code{__fp16} and @code{float} values
 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
 code using these hardware instructions if you compile with
-options to select an FPU that provides them; 
+options to select an FPU that provides them;
 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
 in addition to the @option{-mfp16-format} option to select
-a half-precision format.  
+a half-precision format.
 
 Language-level support for the @code{__fp16} data type is
 independent of whether GCC generates code using hardware floating-point
@@ -1995,7 +1995,7 @@
 @cindex @code{alloc_size} attribute
 The @code{alloc_size} attribute is used to tell the compiler that the
 function return value points to memory, where the size is given by
-one or two of the functions parameters.  GCC uses this 
+one or two of the functions parameters.  GCC uses this
 information to improve the correctness of @code{__builtin_object_size}.
 
 The function parameter(s) denoting the allocated size are specified by
@@ -2004,7 +2004,7 @@
 of the two function arguments specified.  Argument numbering starts at
 one.
 
-For instance, 
+For instance,
 
 @smallexample
 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
@@ -2213,7 +2213,7 @@
 attribute also implies ``default'' visibility.  It is an error to
 explicitly specify any other visibility.
 
-In previous versions of GCC, the @code{dllexport} attribute was ignored 
+In previous versions of GCC, the @code{dllexport} attribute was ignored
 for inlined functions, unless the @option{-fkeep-inline-functions} flag
 had been used.  The default behaviour now is to emit all dllexported
 inline functions; however, this can cause object file-size bloat, in
@@ -2424,10 +2424,10 @@
 are @code{printf_unlocked} and @code{fprintf_unlocked}.
 @xref{C Dialect Options,,Options Controlling C Dialect}.
 
-For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is 
+For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
 recognized in the same context.  Declarations including these format attributes
 will be parsed for correct syntax, however the result of checking of such 
format
-strings is not yet defined, and will not be carried out by this version of the 
+strings is not yet defined, and will not be carried out by this version of the
 compiler.
 
 The target may also provide additional types of format checks.
@@ -2752,7 +2752,7 @@
 synonyms, and cause the compiler to always call
 the function by first loading its address into a register, and then using
 the contents of that register.  The @code{near} attri

[PATCH 1/4] Docs: extend.texi: Add missing semicolon for consistency

2011-04-27 Thread Michael Witten
---
 trunk/gcc/doc/extend.texi |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/trunk/gcc/doc/extend.texi b/trunk/gcc/doc/extend.texi
index eddff95..c154958 100644
--- a/trunk/gcc/doc/extend.texi
+++ b/trunk/gcc/doc/extend.texi
@@ -3997,7 +3997,7 @@
 @smallexample
 __attribute__((noreturn)) void d0 (void),
 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
- d2 (void)
+ d2 (void);
 @end smallexample
 
 @noindent
-- 
1.7.4.18.g68fe8



[PATCH 0/4] Docs: extend.texi

2011-04-27 Thread Michael Witten
See the following emails for a few inlined patches
to /trunk/gcc/doc/extend.texi (revision 172911):

  [1] Docs: extend.texi: Add missing semicolon for consistency
  [2] Docs: extend.texi: Remove trailing blanks from lines
  [3] Docs: extend.texi: Rearrange nodes; no text was removed or added
  [4] Docs: extend.texi: Reword and rearrange attribute node introductions

  trunk/gcc/doc/extend.texi | 5449 +++--
  1 files changed, 2730 insertions(+), 2719 deletions(-)

 CHANGELOG

Essentially, I think it would be easiest to squash all of these patches
together into one revision; here is a ChangeLog entry for such a revision:

2011-04-27  Michael Witten 

* gcc/doc/extend.texi: Add a `;', remove trailing whitespace,
and reorganize nodes to group the discussion of attributes more
logically.

-- 
1.7.4.18.g68fe8



Re: [google] Use different peeling parameters with available profile (issue4438079)

2011-04-27 Thread Diego Novillo
On Wed, Apr 27, 2011 at 20:52, Sharad Singhai  wrote:
> This patch adds new parameters to control peeling when profile
> feedback information is available.
>
> For google/main.
>
> Tested:
>  bootstrapped on x86_64.
>

Looks OK with a couple of minor nits below.

> 2011-04-27  Sharad Singhai  
>
>        * gcc/params.def: Add new parameters to control peeling.
>        * gcc/tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Use
>        different peeling parameters when profile feedback is available.
>        * gcc/loop-unroll.c (decide_peel_once_rolling): Ditto.
>        (decide_peel_completely): Ditto.
>        * gcc/doc/invoke.texi: Document new peeling parameters.

No need to include 'gcc/'  as this will go in gcc/ChangeLog.google-main

>        * gcc/testsuite/gcc.dg/vect/O3-vect-pr34223.c: Add new peeling
>        parameters.
>        * gcc/testsuite/gcc.dg/vect/vect.exp: Allow reading flags in individual
>        tests.

Likewise.  No need to have 'gcc/testsuite'.  These entries should go
in testsuite/ChangeLog.google-main.

(this looks like it was generated with mklog.  It's not a very smart script :)

>
>
> Index: gcc/doc/invoke.texi
> ===
> --- gcc/doc/invoke.texi (revision 172904)
> +++ gcc/doc/invoke.texi (working copy)
> @@ -8523,11 +8523,28 @@
>  The maximum number of peelings of a single loop.
>
>  @item max-completely-peeled-insns
> +@item max-completely-peeled-insns-feedback
>  The maximum number of insns of a completely peeled loop.
>
> +The @option{max-completely-peeled-insns-feedback} is used only when profile
> +feedback is available and the loop is hot. Because of the real profiles, this
> +value may set to be larger for hot loops.
> +
> +@item max-once-peeled-insns
> +@item max-once-peeled-insns-feedback
> +The maximum number of insns of a peeled loop that rolls only once.
> +The @option{max-once-peeled-insns-feedback}  is used only when profile 
> feedback
> +is available and the loop is hot. Because of the real profiles, this value
> +may set to be larger for hot loops.
> +
>  @item max-completely-peel-times
> +@item max-completely-peel-times-feedback
>  The maximum number of iterations of a loop to be suitable for complete 
> peeling.
>
> +The @option{max-completely-peel-times-feedback} is used only when profile 
> feedback
> +is available and the loop is hot. Because of the real profiles, this value 
> may
> +set to be larger for hot loops.
> +
>  @item max-completely-peel-loop-nest-depth
>  The maximum depth of a loop nest suitable for complete peeling.
>
> Index: gcc/testsuite/gcc.dg/vect/O3-vect-pr34223.c
> ===
> --- gcc/testsuite/gcc.dg/vect/O3-vect-pr34223.c (revision 172904)
> +++ gcc/testsuite/gcc.dg/vect/O3-vect-pr34223.c (working copy)
> @@ -1,4 +1,5 @@
>  /* { dg-require-effective-target vect_int } */
> +/* { dg-options "[vect_cflags] --param max-completely-peel-times=16" } */
>
>  #include "tree-vect.h"
>
> Index: gcc/testsuite/gcc.dg/vect/vect.exp
> ===
> --- gcc/testsuite/gcc.dg/vect/vect.exp  (revision 172904)
> +++ gcc/testsuite/gcc.dg/vect/vect.exp  (working copy)
> @@ -24,6 +24,12 @@
>  global DEFAULT_VECTCFLAGS
>  set DEFAULT_VECTCFLAGS ""
>
> +# So that we can read flags in individual tests.
> +proc vect_cflags { } {
> +  global DEFAULT_VECTCFLAGS
> +  return $DEFAULT_VECTCFLAGS
> +}
> +
>  # If the target system supports vector instructions, the default action
>  # for a test is 'run', otherwise it's 'compile'.  Save current default.
>  # Executing vector instructions on a system without hardware vector support
> Index: gcc/tree-ssa-loop-ivcanon.c
> ===
> --- gcc/tree-ssa-loop-ivcanon.c (revision 172904)
> +++ gcc/tree-ssa-loop-ivcanon.c (working copy)
> @@ -326,6 +326,7 @@
>                            enum unroll_level ul)
>  {
>   unsigned HOST_WIDE_INT n_unroll, ninsns, max_unroll, unr_insns;
> +  unsigned HOST_WIDE_INT max_peeled_insns;
>   gimple cond;
>   struct loop_size size;
>
> @@ -336,9 +337,21 @@
>     return false;
>   n_unroll = tree_low_cst (niter, 1);
>
> -  max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES);
> -  if (n_unroll > max_unroll)
> +  if (profile_info && flag_branch_probabilities &&
> +      optimize_loop_for_speed_p (loop))

Align predicates vertically.  '&&' should be at the start of the line.
 Something like this:

if (profile_info
&& flag_branch_probabilities
&& ...

> +    max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES_FEEDBACK);
> +  else
> +    max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES);
> +
> +  if (n_unroll > max_unroll) {

Brace should be on the next line.

> +    if (dump_file && (dump_flags & TDF_DETAILS))
> +       {
> +         fprintf (dump_file, "  Not unrolling loop %d limited by max unroll"
> +                   " (%d 

[google] Use different peeling parameters with available profile (issue4438079)

2011-04-27 Thread Sharad Singhai
This patch adds new parameters to control peeling when profile
feedback information is available.

For google/main.

Tested:
  bootstrapped on x86_64.

2011-04-27  Sharad Singhai  

* gcc/params.def: Add new parameters to control peeling.
* gcc/tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Use
different peeling parameters when profile feedback is available.
* gcc/loop-unroll.c (decide_peel_once_rolling): Ditto.
(decide_peel_completely): Ditto.
* gcc/doc/invoke.texi: Document new peeling parameters.
* gcc/testsuite/gcc.dg/vect/O3-vect-pr34223.c: Add new peeling
parameters.
* gcc/testsuite/gcc.dg/vect/vect.exp: Allow reading flags in individual
tests.


Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi (revision 172904)
+++ gcc/doc/invoke.texi (working copy)
@@ -8523,11 +8523,28 @@
 The maximum number of peelings of a single loop.
 
 @item max-completely-peeled-insns
+@item max-completely-peeled-insns-feedback
 The maximum number of insns of a completely peeled loop.
 
+The @option{max-completely-peeled-insns-feedback} is used only when profile
+feedback is available and the loop is hot. Because of the real profiles, this
+value may set to be larger for hot loops.
+
+@item max-once-peeled-insns
+@item max-once-peeled-insns-feedback
+The maximum number of insns of a peeled loop that rolls only once.
+The @option{max-once-peeled-insns-feedback}  is used only when profile feedback
+is available and the loop is hot. Because of the real profiles, this value
+may set to be larger for hot loops.
+
 @item max-completely-peel-times
+@item max-completely-peel-times-feedback
 The maximum number of iterations of a loop to be suitable for complete peeling.
 
+The @option{max-completely-peel-times-feedback} is used only when profile 
feedback
+is available and the loop is hot. Because of the real profiles, this value may
+set to be larger for hot loops.
+
 @item max-completely-peel-loop-nest-depth
 The maximum depth of a loop nest suitable for complete peeling.
 
Index: gcc/testsuite/gcc.dg/vect/O3-vect-pr34223.c
===
--- gcc/testsuite/gcc.dg/vect/O3-vect-pr34223.c (revision 172904)
+++ gcc/testsuite/gcc.dg/vect/O3-vect-pr34223.c (working copy)
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target vect_int } */
+/* { dg-options "[vect_cflags] --param max-completely-peel-times=16" } */
 
 #include "tree-vect.h"
 
Index: gcc/testsuite/gcc.dg/vect/vect.exp
===
--- gcc/testsuite/gcc.dg/vect/vect.exp  (revision 172904)
+++ gcc/testsuite/gcc.dg/vect/vect.exp  (working copy)
@@ -24,6 +24,12 @@
 global DEFAULT_VECTCFLAGS
 set DEFAULT_VECTCFLAGS ""
 
+# So that we can read flags in individual tests.
+proc vect_cflags { } {
+  global DEFAULT_VECTCFLAGS
+  return $DEFAULT_VECTCFLAGS
+}
+
 # If the target system supports vector instructions, the default action
 # for a test is 'run', otherwise it's 'compile'.  Save current default.
 # Executing vector instructions on a system without hardware vector support
Index: gcc/tree-ssa-loop-ivcanon.c
===
--- gcc/tree-ssa-loop-ivcanon.c (revision 172904)
+++ gcc/tree-ssa-loop-ivcanon.c (working copy)
@@ -326,6 +326,7 @@
enum unroll_level ul)
 {
   unsigned HOST_WIDE_INT n_unroll, ninsns, max_unroll, unr_insns;
+  unsigned HOST_WIDE_INT max_peeled_insns;
   gimple cond;
   struct loop_size size;
 
@@ -336,9 +337,21 @@
 return false;
   n_unroll = tree_low_cst (niter, 1);
 
-  max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES);
-  if (n_unroll > max_unroll)
+  if (profile_info && flag_branch_probabilities &&
+  optimize_loop_for_speed_p (loop))
+max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES_FEEDBACK);
+  else
+max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES);
+
+  if (n_unroll > max_unroll) {
+if (dump_file && (dump_flags & TDF_DETAILS))
+   {
+ fprintf (dump_file, "  Not unrolling loop %d limited by max unroll"
+   " (%d > %d)\n",
+   loop->num, (int) n_unroll, (int) max_unroll);
+}
 return false;
+  }
 
   if (n_unroll)
 {
@@ -356,14 +369,20 @@
   (int) unr_insns);
}
 
-  if (unr_insns > ninsns
- && (unr_insns
- > (unsigned) PARAM_VALUE (PARAM_MAX_COMPLETELY_PEELED_INSNS)))
+  if (profile_info && flag_branch_probabilities &&
+  optimize_loop_for_speed_p (loop))
+max_peeled_insns =
+  PARAM_VALUE (PARAM_MAX_COMPLETELY_PEELED_INSNS_FEEDBACK);
+  else
+max_peeled_insns = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEELED_INSNS);
+
+  if (unr_insns > max_peeled_insns)
{
  if (dump_file && (dump_flags & TDF_DETAILS))

Re: trial fix to null pointer free

2011-04-27 Thread Xinliang David Li
Ok -- false alarm ...

David

On Wed, Apr 27, 2011 at 5:30 PM, Nathan Froyd  wrote:
> On Wed, Apr 27, 2011 at 04:23:42PM -0700, Xinliang David Li wrote:
>> This can happen when the module does not have function bodies.
>>
>> -   VEC_free (cgraph_node_ptr, heap, cgraph_node_map);
>> -   cgraph_node_map = NULL;
>> +  if (cgraph_node_map)
>> +    VEC_free (cgraph_node_ptr, heap, cgraph_node_map);
>> +  cgraph_node_map = NULL;
>
> Why are you doing this?  This is exactly what VEC_free already does.
>
> -Nathan
>


Re: trial fix to null pointer free

2011-04-27 Thread Diego Novillo
On Wed, Apr 27, 2011 at 19:23, Xinliang David Li  wrote:
> This can happen when the module does not have function bodies.
>
>
> Ok after testing?
>
> Thanks,
>
> David
>
>
> 2011-04-27  Xinliang David Li  
>
>        * value-prof.c (del_node_map): Do not free
>        null pointer.
>

Index: value-prof.c
===
--- value-prof.c(revision 172977)
+++ value-prof.c(working copy)
@@ -1086,8 +1086,9 @@ init_node_map (void)
 void
 del_node_map (void)
 {
-   VEC_free (cgraph_node_ptr, heap, cgraph_node_map);
-   cgraph_node_map = NULL;
+  if (cgraph_node_map)
+VEC_free (cgraph_node_ptr, heap, cgraph_node_map);
+  cgraph_node_map = NULL;
 }

This is not necessary.  Freeing a NULL VEC has no effect.  You could
remove the assignment 'cgraph_node_map = NULL' since VEC_free already
clears it.


Diego.


Re: trial fix to null pointer free

2011-04-27 Thread Nathan Froyd
On Wed, Apr 27, 2011 at 04:23:42PM -0700, Xinliang David Li wrote:
> This can happen when the module does not have function bodies.
>
> -   VEC_free (cgraph_node_ptr, heap, cgraph_node_map);
> -   cgraph_node_map = NULL;
> +  if (cgraph_node_map)
> +VEC_free (cgraph_node_ptr, heap, cgraph_node_map);
> +  cgraph_node_map = NULL;

Why are you doing this?  This is exactly what VEC_free already does.

-Nathan


[google] Disable node map creation for lipo mode

2011-04-27 Thread Xinliang David Li
Committed the trial change r173049 that disables cgraph node map
creation for lipo -- the latter uses Global id map.

David


trial fix to null pointer free

2011-04-27 Thread Xinliang David Li
This can happen when the module does not have function bodies.


Ok after testing?

Thanks,

David


2011-04-27  Xinliang David Li  

* value-prof.c (del_node_map): Do not free
null pointer.
Index: value-prof.c
===
--- value-prof.c	(revision 172977)
+++ value-prof.c	(working copy)
@@ -1086,8 +1086,9 @@ init_node_map (void)
 void
 del_node_map (void)
 {
-   VEC_free (cgraph_node_ptr, heap, cgraph_node_map);
-   cgraph_node_map = NULL;
+  if (cgraph_node_map)
+VEC_free (cgraph_node_ptr, heap, cgraph_node_map);
+  cgraph_node_map = NULL;
 }
 
 /* Return cgraph node for function with pid */


Re: [PATCH,Fortran] Handle 'q' exponent-letter in real-literal-constant

2011-04-27 Thread Mikael Morin
On Wednesday 27 April 2011 23:10:14 Steve Kargl wrote:
> On Wed, Apr 27, 2011 at 10:54:37PM +0200, Mikael Morin wrote:
> > On Wednesday 27 April 2011 01:06:26 Steve Kargl wrote:
> > > It's an 'if -- else if' construct.  If gfc_notify_std == FAILURE, then
> > > the error message is issues and the function returns.   If it is TRUE,
> > > then there should be no messages and else if() is tested.
> > 
> > My concern is that gfc_notify_std seems to return SUCCESS on warnings (I
> > can't test right now as make has decided to rebuild the whole middle-end
> > :-(). Then, I expect double warnings with -pedantic -Wreal-q-constant as
> > -pedantic is a (the only one ?) case outputing warnings for GNU
> > extensions.
> > 
> > Mikael
> 
> laptop:kargl[220] gfc4x -pedantic -Wreal-q-constant -o z ui.f90
> ui.f90:3.12:
> 
>q = 1.23q45
> 1
> Warning: Extension: exponent-letter 'q' in real-literal-constant at (1)
> laptop:kargl[221] gfc4x -pedantic -o z ui.f90
> ui.f90:3.12:
> 
>q = 1.23q45
> 1
> Warning: Extension: exponent-letter 'q' in real-literal-constant at (1)
> laptop:kargl[222] gfc4x -Wreal-q-constant -o z ui.f90
> ui.f90:3.12:
> 
>q = 1.23q45
> 1
> Warning: Extension: exponent-letter 'q' in real-literal-constant at (1)
Well, that's something odd that I don't want to investigate further. 
As it is clean from a user point of view, let's move on.

Mikael



Re: [PATCH] Add FRE pass to the early optimization pipeline

2011-04-27 Thread H.J. Lu
On Wed, Mar 23, 2011 at 7:17 AM, Richard Guenther  wrote:
>
> For quite some releases we'd wanted some (memory) CSE optimization
> during early opts.  Currently we rely heavily on SRA which doesn't
> always fulfill the "make code only smaller" promises which is
> what early opts should do to improve precision of function size
> estimates and to improve abstraction removal by early inlining.
>
> Thus, this patch finally adds an early FRE pass at a suitable place.
>
> The patch was sitting on pretty-ipa branch for some while now
> and there were no noticeable issues with it there.
>
> The patch disables FRE for the matrix-reorg testsuite - the
> matrix reorg implementation is incredibly fragile with respect
> to IL matching.  It also isn't useful anymore as it relies on
> -fwhole-program but isn't prepared to work together with LTO,
> so it at most works on single translation-unit units.  There is
> no sign of anyone maintaining this code, but eventual removal
> similar to struct-reorg should be handled separately from this patch.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu (with the stdarg
> patch applied).
>
> Richard.
>
> 2011-02-23  Richard Guenther  
>
>        * passes.c (init_optimization_passes): Add FRE pass after
>        early SRA.
>
>        * gcc.dg/matrix/matrix.exp: Disable FRE.
>

This patch triggered:

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


-- 
H.J.


Re: [PATCH] C++0x, teach the parser to parse virt-specifier-seq for member functions

2011-04-27 Thread Gabriel Dos Reis
On Wed, Apr 27, 2011 at 4:58 PM, Ville Voutilainen
 wrote:
> On 28 April 2011 00:56, Gabriel Dos Reis  
> wrote:
>>> Seems to fall over itself in a bunch of places. C++ bootstrap smells
>>> like a red herring
>>> to me at this point.
>> Hmm, do you mean GCC fails to bootstrap with C++ a compiler before your mods?
>
> I did make distclean, followed by
> CC=g++ GCC=g++ CFLAGS=-fpermissive ../configure --prefix=/usr
> --enable-languages=c,c++
> and then make. Before my mods. And it doesn't seem to get very far.
>

My configuration command line is:

 /home/gdr/src/gcc.svn/configure --enable-languages=c,c++
--enable-build-with-cxx --disable-multilib --disable-nls

and the builds is progressing quite very well with "g++".
There is no need for manual setting of -fpermissive.

-- Gaby


Re: [PATCH] C++0x, teach the parser to parse virt-specifier-seq for member functions

2011-04-27 Thread Ville Voutilainen
On 28 April 2011 00:56, Gabriel Dos Reis  wrote:
>> Seems to fall over itself in a bunch of places. C++ bootstrap smells
>> like a red herring
>> to me at this point.
> Hmm, do you mean GCC fails to bootstrap with C++ a compiler before your mods?

I did make distclean, followed by
CC=g++ GCC=g++ CFLAGS=-fpermissive ../configure --prefix=/usr
--enable-languages=c,c++
and then make. Before my mods. And it doesn't seem to get very far.


Re: [PATCH] C++0x, teach the parser to parse virt-specifier-seq for member functions

2011-04-27 Thread Gabriel Dos Reis
On Wed, Apr 27, 2011 at 4:05 PM, Ville Voutilainen
 wrote:
> On 27 April 2011 10:14, Ville Voutilainen  wrote:
>> The -fpermissive because there are conversions from literals to char*,
>> and c++ nowadays doesn't like that. I'm not at the build machine right
>> now, so I'll check
>> later how it fared.
>
> Seems to fall over itself in a bunch of places. C++ bootstrap smells
> like a red herring
> to me at this point.
>

Hmm, do you mean GCC fails to bootstrap with C++ a compiler before your mods?


-- Gaby


Re: [Patch, Fortran] PRs 48112/48279 - fix interface related regressions

2011-04-27 Thread Mikael Morin
On Tuesday 26 April 2011 23:41:17 Tobias Burnus wrote:
> This patch fixes three issues, (a) and (b) are 4.6/4.7 regressions.
> 
> a) PR48112: Due to incomplete resolution, there was an ICE when writing
> the module file. Solution: Back-out the patch which introduced the
> incomplete resolution - and add a similar patch later to avoid printing
> errors multiple times.
Bah! A pity we need voodoo incantations such as this.

> 
> b) PR48279: The patch adding supporting functions calls as actual
> argument to intent-in dummies had problems with generics, which lead to
> an ICE. Solution: Use the expr's specific procedure (esym) instead.
> 
> c) PR48279 comment 8: gfortran was accepting internal procedures in
> INTERFACE; solution: Reject it with -std=f2008, but accept it with
> -std=gnu. Reasoning: Except of NAG all other tested compilers also
> accept it.
> 
> Build and currently regtesting on x86-64.
> OK for the trunk - and for 4.6?
Yes (The three of them).
Thanks

Mikael




Re: [PATCH,Fortran] Handle 'q' exponent-letter in real-literal-constant

2011-04-27 Thread Steve Kargl
On Wed, Apr 27, 2011 at 10:54:37PM +0200, Mikael Morin wrote:
> On Wednesday 27 April 2011 01:06:26 Steve Kargl wrote:
> > 
> > It's an 'if -- else if' construct.  If gfc_notify_std == FAILURE, then
> > the error message is issues and the function returns.   If it is TRUE,
> > then there should be no messages and else if() is tested.
> My concern is that gfc_notify_std seems to return SUCCESS on warnings (I 
> can't 
> test right now as make has decided to rebuild the whole middle-end :-(). 
> Then, 
> I expect double warnings with -pedantic -Wreal-q-constant as -pedantic is a 
> (the only one ?) case outputing warnings for GNU extensions.
> 
> Mikael

laptop:kargl[220] gfc4x -pedantic -Wreal-q-constant -o z ui.f90
ui.f90:3.12:

   q = 1.23q45
1
Warning: Extension: exponent-letter 'q' in real-literal-constant at (1)
laptop:kargl[221] gfc4x -pedantic -o z ui.f90
ui.f90:3.12:

   q = 1.23q45
1
Warning: Extension: exponent-letter 'q' in real-literal-constant at (1)
laptop:kargl[222] gfc4x -Wreal-q-constant -o z ui.f90
ui.f90:3.12:

   q = 1.23q45
1
Warning: Extension: exponent-letter 'q' in real-literal-constant at (1)

PS: People should not use -pedantic, anyway.  It doesn't do what
people think it does.

-- 
Steve


Re: [PATCH,Fortran] Handle 'q' exponent-letter in real-literal-constant

2011-04-27 Thread Mikael Morin
On Wednesday 27 April 2011 01:06:26 Steve Kargl wrote:
> > > Index: primary.c
> > > ===
> > > --- primary.c   (revision 172974)
> > > +++ primary.c   (working copy)
> > > @@ -541,6 +541,17 @@ match_real_constant (gfc_expr **result,
> > > 
> > >  goto done;
> > >
> > >exp_char = c;
> > > 
> > > +
> > > +  if (c == 'q')
> > > +{
> > > +  if (gfc_notify_std (GFC_STD_GNU, "Extension: exponent-letter 'q'
> > > in " +"real-literal-constant at %C") ==
> > > FAILURE) +   return MATCH_ERROR;
> > > +  else if (gfc_option.warn_real_q_constant)
> > > +   gfc_warning("Extension: exponent-letter 'q' in
> > > real-literal-constant
> > 
> > "
> > 
> > > +   "at %C");
> > > +}
> > 
> > I think the above could generate double warnings. With -pedantic for
> > example (but I didn't check).
> 
> It's an 'if -- else if' construct.  If gfc_notify_std == FAILURE, then
> the error message is issues and the function returns.   If it is TRUE,
> then there should be no messages and else if() is tested.
My concern is that gfc_notify_std seems to return SUCCESS on warnings (I can't 
test right now as make has decided to rebuild the whole middle-end :-(). Then, 
I expect double warnings with -pedantic -Wreal-q-constant as -pedantic is a 
(the only one ?) case outputing warnings for GNU extensions.

Mikael



[google] Moved ChangeLog entries to their proper place (issue4453047)

2011-04-27 Thread Diego Novillo

I moved some of your ChangeLog entries to different ChangeLog files.
In general, each sub-directory has its own ChangeLog file, so please
use those.

This is not completely standard, unfortunately.  The rule of thumb is
to check whether the directory you are modifying has a ChangeLog file.
If so, you need to use a ChangeLog.google-main in that directory (will
make it easier to port the patch to trunk later).

I will commit this to google/main shortly.


Thanks.  Diego.


diff --git a/gcc/ChangeLog.google-main b/gcc/ChangeLog.google-main
index 838c257..0b0c096 100644
--- a/gcc/ChangeLog.google-main
+++ b/gcc/ChangeLog.google-main
@@ -12,8 +12,6 @@
 
* tree-ssa-uninit.c (warn_uninitialized_phi): Pass
 warning code.
-   * c-family/c-opts.c (c_common_handle_option): Set
-   warn_maybe_uninitialized.
* opts.c (common_handle_option): Ditto.
* common.opt:  New option.
* tree-ssa.c (warn_uninit): Add one more parameter.
@@ -44,11 +42,6 @@
 
 2011-04-26  Le-Chun Wu  
 
-   * c-family/c-common.c (check_for_self_assign): New function.
-   * c-family/c-common.h: New function declaration.
-   * c-family/c.opt: New option.
-   * c-parser.c (c_parser_declaration_or_fndef): Check for self-assign.
-   (c_parser_expr_no_commas): Check for self-assign.
* common.opt: New option.
* doc/invoke.texi: Documentation for new options.
* fold-const.c (operand_equal_p): Allow operands without typres to
@@ -61,28 +54,6 @@
(fold_ternary_loc): New wrapper function.
* tree.h (struct tree_base): New flag for folded expr.
(enum operand_equal_flag): New flags.
-   * cp/init.c (perform_member_init): Check for self-assign.
-   * cp/parser.c (expr_is_pod): New function.
-   (cp_parser_assignment_expression): Check for self-assign.
-   (cp_parser_init_declarator): Check for self-assign.
-   * testsuite/g++.dg/plugin/selfassign.c (check_self_assign): Renamed
-   from warn_self_assign.
-   (execute_warn_self_assign): Call a function by its new name.
-   * testsuite/g++.dg/warn/Wself-assign-1.C: New test case.
-   * testsuite/g++.dg/warn/Wself-assign-2.C: Likewise.
-   * testsuite/g++.dg/warn/Wself-assign-3.C: Likewise.
-   * testsuite/g++.dg/warn/Wself-assign-4.C: Likewise.
-   * testsuite/g++.dg/warn/Wself-assign-5.C: Likewise.
-   * testsuite/g++.dg/warn/Wself-assign-non-pod-1.C: Likewise.
-   * testsuite/g++.dg/warn/Wself-assign-non-pod-2.C: Likewise.
-   * testsuite/g++.dg/warn/Wself-assign-non-pod-3.C: Likewise.
-   * testsuite/g++.dg/warn/Wself-assign-non-pod-4.C: Likewise.
-   * testsuite/g++.dg/warn/Wself-assign-non-pod-5.C: Likewise.
-   * testsuite/gcc.dg/plugin/selfassign.c (check_self_assign): Renamed
-   from warn_self_assign.
-   (execute_warn_self_assign): Call a function by its new name.:
-   * testsuite/gcc.dg/wself-assign-1.c: New test case.
-   * testsuite/gcc.dg/wself-assign-2.c: Likewise.
 
 2011-04-25  David Li  
 
@@ -90,9 +61,6 @@
using resolved nodes in LIPO mode after ipa_tree_profiling.
* dyn-ipa.c:  New file.
* dbgcnt.def: New debug counters.
-   * c-family/c-opts.c (c_common_post_options): New option.
-   (c_common_parse_file): LIPO mode driver change.
-   (push_command_line_include): New function.
* cgraph.c (cgraph_mark_reachable_node): Handle aux module nodes.
(cgraph_clone_node): New field initialization.
(cgraph_create_virtual_clone): New field initialization.
@@ -113,25 +81,6 @@
(cgraph_copy_node_for_versioning): Ditto.
(cgraph_materialize_clone): Ditto.
(cgraph_redirect_edge_call_stmt_to_callee): Ditto.
-   * cp/decl.c (walk_namespaces): Ditto.
-   (duplicate_decls): Ditto.
-   (make_rtl_for_nonlocal_decl): Ditto.
-   * cp/rtti.c (get_tinfo_decl): Ditto.
-   (create_pseudo_type_info): Ditto.
-   (create_tinfo_types): Ditto.
-   * cp/cp-lang.c (cp_classify_record): Ditto.
-   * cp/pt.c (instantiate_decl): Ditto.
-   * cp/semantics.c (emit_associated_thunks): Ditto.
-   * cp/decl2.c (start_static_storage_duration_function): Ditto.
-   (prune_vars_needing_no_initialization):  Ditto.
-   (cxx_callgraph_analyze_expr): Ditto.
-   (no_linkage_error): Ditto.
-   (collect_all_refs): Ditto.
-   (cp_write_global_declarations): Ditto.
-   * cp/parser.c (pragma_lex): Ditto.
-   * cp/cp-objcp-common.c (cp_function_decl_explicit_p): Ditto.
-   * cp/mangle.c (mangle_conv_op_name_for_type): Ditto.
-   * cp/name-lookup.c (add_decl_to_level): Ditto.
* gcov-io.c (gcov_read_summary): Ditto.
* tree-ssa-alias.c (same_type_for_tbaa): Ditto.
(refs_may_alias_p_1): Ditto.
@@ -240,13 +189,13 @@
 
 2011-04-19  Guozhi Wei  
 
-   * gcc/config/arm/arm.c (SHORTEST_FAR_JUMP_LENGTH): New constant.
+   * config/arm/arm.c (SHORTEST_FAR_JUMP_LENGTH): New cons

[Patch, Fortran, committed] PR 48788 - Avoid segfault after gfc_error for whole-file diagnostic

2011-04-27 Thread Tobias Burnus
First, I'd be glad if someone could review my patch at 
http://gcc.gnu.org/ml/fortran/2011-04/msg00271.html


 * * *

Secondly, the attached patch fixes a segfault after printing an error 
about the invalid function-return type. It has been committed as Rev. 
173048. As it is a 4.6/4.7 regression, I will backport it to 4.6 in the 
next days.


Tobias
Index: gcc/testsuite/gfortran.dg/whole_file_34.f90
===
--- gcc/testsuite/gfortran.dg/whole_file_34.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/whole_file_34.f90	(Revision 0)
@@ -0,0 +1,12 @@
+! { dg-do compile }
+!
+! PR fortran/48788
+!
+! Contributed by Zdenek Sojka
+!
+function foo ()
+end function foo
+  character(4), external :: foo ! { dg-error "Return type mismatch of function" }
+  character(4) :: x
+  x = foo ()
+END
Index: gcc/testsuite/ChangeLog
===
--- gcc/testsuite/ChangeLog	(Revision 173047)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@
+2011-04-27  Tobias Burnus  
+
+	PR fortran/48788
+	* gfortran.dg/whole_file_34.f90: New.
+
 2011-04-27  Jan Hubicka  
 
 	* gcc.dg/tree-ssa/inline-9.c: New testcase.
Index: gcc/fortran/ChangeLog
===
--- gcc/fortran/ChangeLog	(Revision 173047)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,9 @@
+2011-04-27  Tobias Burnus  
+
+	PR fortran/48788
+	* resolve.c (resolve_global_procedure): Error recovery -
+	avoid segfault for (non)character-returning functions.
+
 2011-04-26  Thomas Koenig  
 
 	* decl.c (gfc_match_end):  Check that the block name starts
Index: gcc/fortran/resolve.c
===
--- gcc/fortran/resolve.c	(Revision 173047)
+++ gcc/fortran/resolve.c	(Arbeitskopie)
@@ -2187,7 +2187,7 @@
 
 	  /* F2003, 12.3.1.1 (3c); F2008, 12.4.2.2 (3c)  */
 	  if (sym->ts.type == BT_CHARACTER && sym->attr.if_source != IFSRC_IFBODY
-	  && def_sym->ts.u.cl->length != NULL)
+	  && def_sym->ts.type == BT_CHARACTER && def_sym->ts.u.cl->length != NULL)
 	{
 	  gfc_charlen *cl = sym->ts.u.cl;
 


Re: [patch gimplifier]: Do folding on truth and/or trees

2011-04-27 Thread Richard Guenther
On Wed, Apr 27, 2011 at 10:26 PM, Richard Guenther
 wrote:
> On Wed, Apr 27, 2011 at 10:03 PM, Kai Tietz  wrote:
>> Hello,
>>
>> this patch adds the ability to gimple-fold to operate for truth and/or
>> operations
>> on folded binary-and/or optimized truth trees - as done by fold-const.  As 
>> fold
>> converts trivial operations like (A && B) to (A & B) != 0, in most cases 
>> further
>> folding of truth and/or trees wasn't done.
>> folding will be again detected.
>>
>> ChangeLog gcc/
>>
>> 2011-04-27  Kai Tietz
>>
>>        * gimple-fold.c (is_bit_ior_and): New helper function.
>>        (fold_equal_and_or): New helper function for truth &&
>>        and || logic folding with treating binary optimization.
>>        (maybe_fold_and_comparisons): Folding for and.
>>        (maybe_fold_or_comparisons): Folding for or.
>>
>> ChangeLog gcc/testsuite/
>>
>> 2011-04-27  Kai Tietz
>>
>>        * gcc.dg/binop-tand1.c: New.
>>        * gcc.dg/binop-tand2.c: New.
>>        * gcc.dg/binop-tor1.c: New.
>>        * gcc.dg/binop-tor2.c: New.
>>
>> Tested for x86_64-pc-linux-gnu and x86_64-w64-mingw32. Ok for apply?
>
> No.  This is certainly the wrong place to do tree combining.

Either look into extending tree-ssa-forwprop.c or work on
http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01099.html, thus fold
to piecewise gimple expressions so that the machinery can also
be used from value-numbering.

Richard.


Re: [patch gimplifier]: Do folding on truth and/or trees

2011-04-27 Thread Richard Guenther
On Wed, Apr 27, 2011 at 10:03 PM, Kai Tietz  wrote:
> Hello,
>
> this patch adds the ability to gimple-fold to operate for truth and/or
> operations
> on folded binary-and/or optimized truth trees - as done by fold-const.  As 
> fold
> converts trivial operations like (A && B) to (A & B) != 0, in most cases 
> further
> folding of truth and/or trees wasn't done.
> folding will be again detected.
>
> ChangeLog gcc/
>
> 2011-04-27  Kai Tietz
>
>        * gimple-fold.c (is_bit_ior_and): New helper function.
>        (fold_equal_and_or): New helper function for truth &&
>        and || logic folding with treating binary optimization.
>        (maybe_fold_and_comparisons): Folding for and.
>        (maybe_fold_or_comparisons): Folding for or.
>
> ChangeLog gcc/testsuite/
>
> 2011-04-27  Kai Tietz
>
>        * gcc.dg/binop-tand1.c: New.
>        * gcc.dg/binop-tand2.c: New.
>        * gcc.dg/binop-tor1.c: New.
>        * gcc.dg/binop-tor2.c: New.
>
> Tested for x86_64-pc-linux-gnu and x86_64-w64-mingw32. Ok for apply?

No.  This is certainly the wrong place to do tree combining.

Richard.

> Regards,
> Kai
>


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

2011-04-27 Thread Cary Coutant
>> set_debug_level should not use global state; this needs to check
>> opts->x_debug_info_level (not the global debug_info_level) and set
>> opts->x_generate_debug_line_table.
>
> Oops, missed that. Thanks!

I've uploaded the revised patch to
http://codereview.appspot.com/4440072 -- should I also post it here?

Here's the incremental diff...

-cary

diff --git a/gcc/opts.c b/gcc/opts.c
index 72f4d51..ee8c2b0 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1872,7 +1872,8 @@ set_debug_level (enum debug_info_type type, int
extended, const char *arg,
opts->x_debug_info_level = (enum debug_info_levels) argval;
 }

-  generate_debug_line_table = debug_info_level >= DINFO_LEVEL_NORMAL;
+  opts->x_generate_debug_line_table = (opts->x_debug_info_level
+  >= DINFO_LEVEL_NORMAL);
 }

 /* Arrange to dump core on error for diagnostic context DC.  (The


Re: [patch gimplifier]: Do folding on truth and/or trees

2011-04-27 Thread Jakub Jelinek
On Wed, Apr 27, 2011 at 10:03:34PM +0200, Kai Tietz wrote:
> --- /dev/null 1970-01-01 00:00:00.0 +
> +++ gcc/gcc/testsuite/gcc.dg/binop-tand1.c2011-04-27 21:31:19.276726900 
> +0200
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-optimized" } */
> +
> +int
> +foo (int a, int b, int c)
> +{
> +  return ((!a && !b) && c && b && c && a);

For testing of gimple-fold folding (rather than fold-const), it would be
nice if you could also test those expressions from multiple
source statements with some temporaries.  Otherwise, fold-const
will see everything together already when invoked from the FEs.

> +/* We expect to see ""; confirm that, so that we know to count
> +   it in the real test.  */
> +/* { dg-final { scan-tree-dump-times "\]*>" 1 "optimized" } } */

Why do you test number of bb's?  I don't see how is that relevant to
whether it has been optimized or not.
On the other side, it would be nice if you could test your testcases with
a cross compiler on a couple of other targets (e.g. powerpc64-linux
-m32,-m64, and/or arm, s390 or something similar).  BRANCH_COST etc.
affect a lot how is this gimplified, and I believe there was a PR about
some of your recent testcases failing on powerpc.

You don't need to build cross binutils, all that is needed is
configure the cross and build just cc1, don't mind that the build
fails afterwards and just run it on your testcases by hand to see
what is in the dumps.

Jakub


[patch gimplifier]: Do folding on truth and/or trees

2011-04-27 Thread Kai Tietz
Hello,

this patch adds the ability to gimple-fold to operate for truth and/or
operations
on folded binary-and/or optimized truth trees - as done by fold-const.  As fold
converts trivial operations like (A && B) to (A & B) != 0, in most cases further
folding of truth and/or trees wasn't done.
folding will be again detected.

ChangeLog gcc/

2011-04-27  Kai Tietz

* gimple-fold.c (is_bit_ior_and): New helper function.
(fold_equal_and_or): New helper function for truth &&
and || logic folding with treating binary optimization.
(maybe_fold_and_comparisons): Folding for and.
(maybe_fold_or_comparisons): Folding for or.

ChangeLog gcc/testsuite/

2011-04-27  Kai Tietz

* gcc.dg/binop-tand1.c: New.
* gcc.dg/binop-tand2.c: New.
* gcc.dg/binop-tor1.c: New.
* gcc.dg/binop-tor2.c: New.

Tested for x86_64-pc-linux-gnu and x86_64-w64-mingw32. Ok for apply?

Regards,
Kai
Index: gcc/gcc/gimple-fold.c
===
--- gcc.orig/gcc/gimple-fold.c  2011-04-26 13:25:59.0 +0200
+++ gcc/gcc/gimple-fold.c   2011-04-27 20:08:50.276783700 +0200
@@ -2300,6 +2300,85 @@ and_comparisons_1 (enum tree_code code1,
   return NULL_TREE;
 }
 
+/* Checks if the binary logic can be expand for truth logic specified by the
+   IS_AND flag.  We assume that C is EQ_EXPR or NE_EXPR.  If we see a binary
+   or the variable IS_IOR is set to true, otherwise it is set to zero.  */
+
+static bool
+is_bit_ior_and (tree op, enum tree_code c, bool *is_ior, bool is_and)
+{
+  enum tree_code code;
+  gimple s;
+
+  gcc_assert (c == EQ_EXPR || c == NE_EXPR);
+
+  if (TREE_CODE (op) != SSA_NAME
+  || !is_gimple_assign ((s = SSA_NAME_DEF_STMT (op
+return false;
+  code = gimple_assign_rhs_code (s);
+  if (code != BIT_IOR_EXPR && code != BIT_AND_EXPR)
+return false;
+  if (is_and)
+{
+  if ((code == BIT_IOR_EXPR && c == NE_EXPR)
+  || (code != BIT_IOR_EXPR && c == EQ_EXPR))
+return false;
+}
+  else
+{
+  if ((code == BIT_IOR_EXPR && c != NE_EXPR)
+  || (code != BIT_IOR_EXPR && c != EQ_EXPR))
+return false;
+}
+  *is_ior = (code == BIT_IOR_EXPR);
+  return true;
+}
+
+/* Try to unfold truth and/or logic by watching into binary and/or optimized
+   truth logic.  */
+static tree
+fold_equal_and_or (tree l, bool l_true, int l_and, tree r, bool r_true, int 
is_and)
+{
+  gimple s;
+  if (operand_equal_p (l, r, 0))
+{
+  if (l_true == r_true)
+return l;
+  return (is_and ? boolean_false_node : boolean_true_node);
+}
+  if (TREE_CODE (l) == SSA_NAME && is_gimple_assign ((s = SSA_NAME_DEF_STMT 
(l)))
+  && gimple_assign_rhs_code (s) == (l_and ? BIT_AND_EXPR : BIT_IOR_EXPR))
+{
+  tree l1, l2, t1, t2;
+  gimple_stmt_iterator gsi;
+  l1 = gimple_assign_rhs1 (s);
+  l2 = gimple_assign_rhs1 (s);
+  t1 = fold_equal_and_or (l1, l_true, l_and, r, r_true, is_and);
+  if (t1 && ((is_and && integer_zerop (t1)) || (!is_and && integer_onep 
(t1
+return t1;
+  if (t1 && ((is_and && integer_zerop (t1)) || (!is_and && integer_zerop 
(t1
+return l2;
+
+  t2 = fold_equal_and_or (l2, l_true, l_and, r, r_true, is_and);
+  if (!t1 && !t2)
+return NULL_TREE;
+  if (t2 && ((is_and && integer_zerop (t2)) || (!is_and && integer_onep 
(t2
+return t2;
+  if (t2 && ((is_and && integer_zerop (t2)) || (!is_and && integer_zerop 
(t2
+return l1;
+  if (t1)
+t2 = l2;
+  else if (t2)
+t1 = l1;
+  t1 = fold_build2 ((l_and ? BIT_AND_EXPR : BIT_IOR_EXPR), TREE_TYPE 
(gimple_assign_lhs (s)),
+t1, t2);
+  gsi = gsi_for_stmt (s);
+  gimple_assign_set_rhs_from_tree (&gsi, t1);
+  return gimple_assign_lhs (s);
+}
+  return NULL;
+}
+
 /* Try to simplify the AND of two comparisons, specified by
(OP1A CODE1 OP1B) and (OP2B CODE2 OP2B), respectively.
If this can be simplified to a single expression (without requiring
@@ -2311,11 +2390,43 @@ tree
 maybe_fold_and_comparisons (enum tree_code code1, tree op1a, tree op1b,
enum tree_code code2, tree op2a, tree op2b)
 {
-  tree t = and_comparisons_1 (code1, op1a, op1b, code2, op2a, op2b);
+  tree t;
+  bool is_ior;
+
+  t = and_comparisons_1 (code1, op1a, op1b, code2, op2a, op2b);
   if (t)
 return t;
-  else
-return and_comparisons_1 (code2, op2a, op2b, code1, op1a, op1b);
+  t = and_comparisons_1 (code2, op2a, op2b, code1, op1a, op1b);
+  if (t)
+return t;
+
+  if ((code1 != NE_EXPR && code1 != EQ_EXPR)
+  || (code2 != NE_EXPR && code2 != EQ_EXPR)
+  || !integer_zerop (op1b) || !integer_zerop (op2b))
+return NULL_TREE;
+
+  if (is_bit_ior_and (op1a, code1, &is_ior, true))
+{
+  t = fold_equal_and_or (op1a, (code1 == NE_EXPR), !is_ior, op2a, (code2 
== NE_EXPR), 1);
+  if (t)
+   {
+ if (integer_

Re: [patch, libgfortran] Fix numerous formatting bugs

2011-04-27 Thread Janne Blomqvist
On Wed, Apr 27, 2011 at 08:53, Janne Blomqvist
 wrote:
> On Wed, Apr 27, 2011 at 07:09, Jerry DeLisle  wrote:
>> On 04/25/2011 07:36 AM, Janne Blomqvist wrote:
>>>
>>> On Mon, Apr 25, 2011 at 14:44, Jerry DeLisle
>>>  wrote:

 On 04/25/2011 03:48 AM, Janne Blomqvist wrote:
>
> Now, for one of the testcase changes:
>
> --- gcc/testsuite/gfortran.dg/char4_iunit_1.f03 (revision 172909)
> +++ gcc/testsuite/gfortran.dg/char4_iunit_1.f03 (working copy)
> @@ -24,11 +24,11 @@ program char4_iunit_1
>    write(string, *) .true., .false. , .true.
>    if (string .ne. 4_" T F T                                    ") call
> abort
>    write(string, *) 1.2345e-06, 4.2846e+10_8
> -  if (string .ne. 4_"  1.23450002E-06   4284600.00     ") call
> abort
> +  if (string .ne. 4_"  1.234500019E-06   4284600.00    ") call
> abort
>
> This looks wrong. For correctly rounded REAL(4) output, we need 9
> significant digits, but here we print 10.
>

 Well, I bumped it up for defaults based on pr48488 comment #2 shown
 below.
>>>
>>> Yes, that comment in the PR is correct; to guarantee that a
>>> binary->ascii->binary roundtrip preserves the original binary value
>>> (with the default "round to nearest, break on even" rounding mode),
>>> one must output at least {9, 17, 21, 36} significant digits for real
>>> kinds 4, 8, 10, and 16, respectively (yes, I double-checked IEEE
>>> 754-2008 that this is indeed correct).
>>>
>>> Since for the G edit descriptor d is equivalent to the number of
>>> significant digits, AFAICS the write.c patch below is correct and the
>>> bug must be elsewhere, no?
>>>
>>
>> No.
>>
>> Look at this example:
>>
>> program t4
>>  implicit none
>>  character(len=44) :: string
>>  write(*,*) 1.2345e-06, 4.2846e+10_8
>>  write(*,'(1x,1pG16.9e2,1x,1pG25.17e3)') 1.2345e-06, 4.2846e+10_8
>>  write(*,'(1x,1pG15.8e2,1x,1pG25.17e3)') 1.2345e-06, 4.2846e+10_8
>> end program t4
>>
>> This gives with the patch:
>>
>>  1.234500019E-06   4284600.00
>>  1.234500019E-06   4284600.00
>>  1.23450002E-06   4284600.00
>>
>> And without the patch:
>>
>>  1.23450002E-06   4284600.00
>>  1.234500019E-06   4284600.00
>>  1.23450002E-06   4284600.00
>>
>> d is the number of digits after the decimal point, not the number of
>> significant digits.
>
> I stand corrected. Or well, I still stand by my previous statement
> that with the G edit descriptor d corresponds to the number of
> significant digits. However, only when not using the scale factor.
>
> Since we use a scale factor of 1, when the magnitude of the number is
> such that the E edit descriptor is used, according to F2008 10.7.2.3.3
> paragraph 6 for 0 < k < d+2 we must print k significant digits to the
> left of the decimal point and d-k+1 to the right. That is, with k=1 we
> print one digit to the left of the decimal point and d-1+1=d to the
> right which has the effect of increasing the number of significant
> digits by one!
>
> However, when the magnitude of the value is such that F editing is
> used, the scale factor has no effect and we thus print d significant
> digits.
>
> So in order to guarantee an exact binary<->ascii roundtrip we must
> accept an extra digit in some cases. Or then do something which would
> make list formatted (and perhaps G0 as well?) write differ from 1PGw.d
> (effectively, reduce d by one when the magnitude is such that E
> editing is used)?

That is, what about something like the attached patch on top of your
patch. With the patch, the test program

program t4
 implicit none
 character(len=44) :: string
 write(*,*) 1.2345e-06, 4.2846e+10_8, 1.1
 write(*,'(1x,1pG16.9e2,1x,1pG25.17e3)') 1.2345e-06, 4.2846e+10_8
 write(*,'(1x,1pG15.8e2,1x,1pG25.17e3)') 1.2345e-06, 4.2846e+10_8
 write(*,'(1x,1pG0,1x,1pG0)') 1.2345e-06, 1.1
 write(*,'(1x,1pG0.9,1x,1pG0.9)') 1.2345e-06, 1.1
end program t4

outputs

   1.23450002E-06   4284600.001.1002
  1.234500019E-06   4284600.00
  1.23450002E-06   4284600.00
 1.23450002E-06 1.1002
 1.234500019E-06 1.1002

So the change is that now it prints the same number of significant
digits in E and F mode, both for list formatted output and kPG0 when
k>=0. For list formatted we can do pretty much what we want, and for
G0 the standard only says the processor can choose appropriate values
for w, d, and e. So far we have chosen d and e only based on the kind,
but AFAICS nothing prevents taking into account the magnitude as well.

I haven't modified any of the testcases so I expect some number of
regressions due to that, but I'm asking for opinions on the approach
itself before doing that.

-- 
Janne Blomqvist
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 548f9f5..bf02ad8 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1155,35 +1155,35 @@ write_z (st_parameter_dt *dtp, const fnode *f, const char

Re: [google] GRTE static link spec (issue4426065)

2011-04-27 Thread Diego Novillo
On Wed, Apr 27, 2011 at 15:13, Ollie Wild  wrote:

> ChangeLog:
> 2011-04-27  Ollie Wild  
>
>        * config.gcc: Add GRTE detection.
>        * config/i386/linux.h (LINUX_GRTE_EXTRA_SPECS): New macro.
>        (SUBTARGET_EXTRA_SPECS): Add LINUX_GRTE_EXTRA_SPECS.
>        * config/i386/linux64.h (LINUX_GRTE_EXTRA_SPECS): New macro.
>        (SUBTARGET_EXTRA_SPECS): New macro with LINUX_GRTE_EXTRA_SPECS.
>        * config/linux-grtev2.h: New file.

OK.


Diego.


Ping^2 Re: Don't use linux.h for non-Linux targets

2011-04-27 Thread Joseph S. Myers
Ping^2.  This patch 
 is still pending 
review (except insofar as it relates to GNU Hurd).

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


[google] GRTE static link spec (issue4426065)

2011-04-27 Thread Ollie Wild
commit 44417f1103b0823f950f539a38a5539b8ff74330
Author: Ollie Wild 
Date:   Mon Apr 25 21:55:44 2011 -0400

When using GRTE (libc) and linking statically, instead of just -lc add:

  -lc -lnss_borg -lnss_cache -lnss_dns -lnss_files -lresolv

to the link by modifying LIB_SPEC to redirect to several new specs
which are GRTE-specific.

To be applied to google/integration branch.


M   gcc/config.gcc
M   gcc/config/i386/linux.h
M   gcc/config/i386/linux64.h
A   gcc/config/linux-grtev2.h

Tested:
  Tested via buildit bootstrap and tests and by executing gcc with -v to
  validate supplied link options.

ChangeLog:
2011-04-27  Ollie Wild  

* config.gcc: Add GRTE detection.
* config/i386/linux.h (LINUX_GRTE_EXTRA_SPECS): New macro.
(SUBTARGET_EXTRA_SPECS): Add LINUX_GRTE_EXTRA_SPECS.
* config/i386/linux64.h (LINUX_GRTE_EXTRA_SPECS): New macro.
(SUBTARGET_EXTRA_SPECS): New macro with LINUX_GRTE_EXTRA_SPECS.
* config/linux-grtev2.h: New file.

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 58f6787..dc7524f 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1286,6 +1286,9 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | 
i[34567]86-*-knetbsd*-gnu | i
i[34567]86-*-gnu*) tm_file="$tm_file i386/linux.h gnu.h i386/gnu.h";;
esac
tmake_file="${tmake_file} i386/t-crtstuff i386/t-crtpc i386/t-crtfm 
t-dfprules"
+   if [ "$with_sysroot" = "/usr/grte/v2" ]; then
+ tm_file="${tm_file} linux-grtev2.h"
+   fi
;;
 x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h gnu-user.h 
linux.h glibc-stdint.h \
@@ -1297,6 +1300,9 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | 
x86_64-*-knetbsd*-gnu)
x86_64-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h" ;;
esac
tmake_file="${tmake_file} i386/t-linux64 i386/t-crtstuff i386/t-crtpc 
i386/t-crtfm t-dfprules"
+   if [ "$with_sysroot" = "/usr/grte/v2" ]; then
+ tm_file="${tm_file} linux-grtev2.h"
+   fi
;;
 i[34567]86-pc-msdosdjgpp*)
xm_file=i386/xm-djgpp.h
diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index 1d2a548..019cea9 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -101,8 +101,14 @@ along with GCC; see the file COPYING3.  If not see
 #define ASM_SPEC \
   "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
 
+/* These may be provided by config/linux-grtev2.h.  */
+#ifndef LINUX_GRTE_EXTRA_SPECS
+#define LINUX_GRTE_EXTRA_SPECS
+#endif
+
 #undef  SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
+  LINUX_GRTE_EXTRA_SPECS \
   { "link_emulation", LINK_EMULATION },\
   { "dynamic_linker", LINUX_DYNAMIC_LINKER }
 
diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index 118e795..429c273 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -90,6 +90,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
   %{" SPEC_64 ":-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}} \
 %{static:-static}}"
 
+/* These may be provided by config/linux-grtev2.h.  */
+#ifndef LINUX_GRTE_EXTRA_SPECS
+#define LINUX_GRTE_EXTRA_SPECS
+#endif
+
+#undef  SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS \
+  LINUX_GRTE_EXTRA_SPECS
+
 /* Similar to standard Linux, but adding -ffast-math support.  */
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
diff --git a/gcc/config/linux-grtev2.h b/gcc/config/linux-grtev2.h
new file mode 100644
index 000..29268fc
--- /dev/null
+++ b/gcc/config/linux-grtev2.h
@@ -0,0 +1,43 @@
+/* Definitions for Linux-based GRTE (Google RunTime Environment) version 2.
+   Copyright (C) 2009,2010,2011 Free Software Foundation, Inc.
+   Contributed by Chris Demetriou and Ollie Wild.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+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
+.  */
+
+/* Overrides LIB_SPEC from linux.h.  */
+#undef LIB_SPEC
+#define LIB_SPEC \
+  "%{pthread:-lpthread} \
+   %{shared:-lc} \
+   %{!shared:%{mieee-fp:-lieee} %{profile:%(libc_p)}%{!profile:%(li

Re: [patch, 4.5] Fix PR middle-end/43085 (make profiledbootstrap crashes due to dataflow bug)

2011-04-27 Thread Richard Guenther
On Wed, Apr 27, 2011 at 6:27 PM, Ulrich Weigand  wrote:
> Hello,
>
> PR middle-end/43085 is a crash of cc1plus when building libstdc++ during
> make profiledbootstrap on the 4.5 branch.  The crash is caused by a
> mis-compile of the add_method routine with -fprofile-use due to a
> dataflow bug during the final if-conversion pass.  For more detailed
> analysis see the PR.
>
> The dataflow bug was fixed on mainline (already for 4.6) by a series of
> patches by Bernd Schmidt, who noticed the bug in a different context.
>
> The patch below is a backport of those fixes to the 4.5 branch, which
> fixes the profiled-bootstrap failure for me.  (Note that on current
> mainling, the ifcvt.c dead_or_predictable routine has been significantly
> rewritten beyond what was done by those patches.  These additional
> changes do not appear to be necessary to fix the PR ...)
>
> Tested on 4.5 on i386-linux with no regression; make profiledbootstrap
> works again (and the resulting compiler also passes the testsuite with
> no regressions).
>
> OK for the 4.5 branch?

Looks ok to me from a RM perspective, once the branch is unfrozen again.

Richard.

> Bye,
> Ulrich
>
>
> 2011-04-27  Ulrich Weigand  
>
>        PR middle-end/43085
>        Backport from mainline:
>
>        2010-04-29  Bernd Schmidt  
>
>        From Dominique d'Humieres 
>        PR bootstrap/43858
>        * ifcvt.c (dead_or_predicable): Use df_simulate_find_defs to compute
>        test_set.
>
>        2010-04-26  Bernd Schmidt  
>
>        * df-problems.c (df_simulate_initialize_forwards): Set, don't clear,
>        bits for artificial defs at the top of the block.
>        * fwprop.c (single_def_use_enter_block): Don't call it.
>
>        2010-04-22  Bernd Schmidt  
>
>        * ifcvt.c (dead_or_predicable): Use df_simulate_find_defs and
>        df_simulate_find_noclobber_defs as appropriate.  Keep track of an
>        extra set merge_set_noclobber, and use it to relax the final test
>        slightly.
>        * df.h (df_simulate_find_noclobber_defs): Declare.
>        * df-problems.c (df_simulate_find_defs): Don't ignore partial or
>        conditional defs.
>        (df_simulate_find_noclobber_defs): New function.
>
>
> Index: gcc/fwprop.c
> ===
> --- gcc/fwprop.c        (revision 172641)
> +++ gcc/fwprop.c        (working copy)
> @@ -228,8 +228,11 @@
>
>   process_uses (df_get_artificial_uses (bb_index), DF_REF_AT_TOP);
>   process_defs (df_get_artificial_defs (bb_index), DF_REF_AT_TOP);
> -  df_simulate_initialize_forwards (bb, local_lr);
>
> +  /* We don't call df_simulate_initialize_forwards, as it may overestimate
> +     the live registers if there are unused artificial defs.  We prefer
> +     liveness to be underestimated.  */
> +
>   FOR_BB_INSNS (bb, insn)
>     if (INSN_P (insn))
>       {
> Index: gcc/ifcvt.c
> ===
> --- gcc/ifcvt.c (revision 172641)
> +++ gcc/ifcvt.c (working copy)
> @@ -3818,7 +3818,7 @@
>                    basic_block other_bb, basic_block new_dest, int reversep)
>  {
>   rtx head, end, jump, earliest = NULL_RTX, old_dest, new_label = NULL_RTX;
> -  bitmap merge_set = NULL;
> +  bitmap merge_set = NULL, merge_set_noclobber = NULL;
>   /* Number of pending changes.  */
>   int n_validated_changes = 0;
>
> @@ -3951,11 +3951,14 @@
>
>       /* Collect:
>           MERGE_SET = set of registers set in MERGE_BB
> +          MERGE_SET_NOCLOBBER = like MERGE_SET, but only includes registers
> +            that are really set, not just clobbered.
>           TEST_LIVE = set of registers live at EARLIEST
> -          TEST_SET  = set of registers set between EARLIEST and the
> -                      end of the block.  */
> +          TEST_SET = set of registers set between EARLIEST and the
> +            end of the block.  */
>
>       merge_set = BITMAP_ALLOC (®_obstack);
> +      merge_set_noclobber = BITMAP_ALLOC (®_obstack);
>
>       /* If we allocated new pseudos (e.g. in the conditional move
>         expander called from noce_emit_cmove), we must resize the
> @@ -3967,13 +3970,8 @@
>        {
>          if (NONDEBUG_INSN_P (insn))
>            {
> -             unsigned int uid = INSN_UID (insn);
> -             df_ref *def_rec;
> -             for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
> -               {
> -                 df_ref def = *def_rec;
> -                 bitmap_set_bit (merge_set, DF_REF_REGNO (def));
> -               }
> +             df_simulate_find_defs (insn, merge_set);
> +             df_simulate_find_noclobber_defs (insn, merge_set_noclobber);
>            }
>        }
>
> @@ -3984,7 +3982,7 @@
>          unsigned i;
>          bitmap_iterator bi;
>
> -          EXECUTE_IF_SET_IN_BITMAP (merge_set, 0, i, bi)
> +          EXECUTE_IF_SET_IN_BITMAP (merge_set_noclobber, 0, i, bi)
>            {
>              if (i < FIRST_PSEUDO_REGISTER
>                  &&

Re: [patch] Split Parse Timevar (issue4378056)

2011-04-27 Thread Lawrence Crowl
This discussion continues in the thread
"[patch] Split Parse Timevar (rev 2) (issue4433076)"
which has a new uploaded patch.

On 4/23/11, Jason Merrill  wrote:
> On 04/22/2011 06:41 PM, Lawrence Crowl wrote:
>> On 4/21/11, Jason Merrill  wrote:
>>> On 04/21/2011 07:17 PM, Lawrence Crowl wrote:
>
>>> That makes sense.  Inlines in the class aren't significantly different
>>> from inlines outside the class, but inlines are significantly different
>>> from non-inlines for our purposes.
>>
>> Do you have a quick hint for how to make that distinction?
>
> Check DECL_DECLARED_INLINE_P after we've parsed the declarator.
>
>> -DEFTIMEVAR (TV_TEMPLATE_INSTANTIATION, "template instantiation")
>> +DEFTIMEVAR (TV_INSTANTIATE_TEMPLATE  , "instantiate template")
>
> Why these changes?

 Just to shorten the names.
>>>
>>> I'd prefer to keep it in the noun form.
>>
>> Okay.  This on in particular was making the output wide.
>
> I wouldn't mind shortening it to TV_TEMPLATE_INST, I just object to the
> change from noun (instantiation) to verb (instantiate).
>
>>> The code is cleaner the way you have it, but not as correct, as there's
>>> some initialization being charged to parsing.
>>
>> Would you prefer moving that initialization out or placing the
>> start/stop into different routines?
>
> I think moving the initialization out would be better.
>
> Jason
>


-- 
Lawrence Crowl


[v3] Add move_if_noexcept

2011-04-27 Thread Paolo Carlini

Hi,

tested x86_64-linux, committed to mainline.

Thanks,
Paolo.

///
2011-04-27  Paolo Carlini  

* include/bits/move.h (move_if_noexcept): Add.
* testsuite/20_util/move_if_noexcept/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/move_if_noexcept/1.cc: Likewise.

Index: include/bits/move.h
===
--- include/bits/move.h (revision 173043)
+++ include/bits/move.h (working copy)
@@ -1,6 +1,6 @@
 // Move, forward and identity for C++0x + swap -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 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
@@ -73,7 +73,7 @@
 
   /**
*  @brief Move a value.
-   *  @ingroup mutating_algorithms
+   *  @ingroup utilities
*  @param  __t  A thing of arbitrary type.
*  @return Same, moved.
   */
@@ -82,12 +82,27 @@
 move(_Tp&& __t)
 { return static_cast::type&&>(__t); }
 
+  /**
+   *  @brief Move unless it could throw and the type is copyable.
+   *  @ingroup utilities
+   *  @param  __x  A thing of arbitrary type.
+   *  @return Same, possibly moved.
+   */
+  template
+inline typename
+conditional<(!is_nothrow_move_constructible<_Tp>::value
+&& is_copy_constructible<_Tp>::value),
+const _Tp&, _Tp&&>::type
+move_if_noexcept(_Tp& __x) noexcept
+{ return std::move(__x); }
+
   /// declval, from type_traits.
 
   /**
*  @brief Returns the actual address of the object or function
* referenced by r, even in the presence of an overloaded
* operator&.
+   *  @ingroup utilities
*  @param  __r  Reference to an object or function.
*  @return   The actual address.
   */
@@ -112,7 +127,7 @@
 
   /**
*  @brief Swaps two values.
-   *  @ingroup mutating_algorithms
+   *  @ingroup utilities
*  @param  __a  A thing of arbitrary type.
*  @param  __b  Another thing of arbitrary type.
*  @return   Nothing.
Index: testsuite/20_util/move_if_noexcept/requirements/explicit_instantiation.cc
===
--- testsuite/20_util/move_if_noexcept/requirements/explicit_instantiation.cc   
(revision 0)
+++ testsuite/20_util/move_if_noexcept/requirements/explicit_instantiation.cc   
(revision 0)
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2011-04-27  Paolo Carlini  
+
+// Copyright (C) 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.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+// NB: This file is for testing utility with NO OTHER INCLUDES.
+
+#include 
+
+namespace std
+{
+  typedef short test_type;
+  
+  template
+  std::conditional<(!std::is_nothrow_move_constructible::value
+   && std::is_copy_constructible::value),
+  const test_type&, test_type&&>::type
+  move_if_noexcept(test_type&);
+}
Index: testsuite/20_util/move_if_noexcept/1.cc
===
--- testsuite/20_util/move_if_noexcept/1.cc (revision 0)
+++ testsuite/20_util/move_if_noexcept/1.cc (revision 0)
@@ -0,0 +1,119 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2011-04-27  Paolo Carlini  
+//
+// Copyright (C) 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+#include 
+#include 
+
+struct noexcept_move_copy
+{
+  noexcept_move_copy()
+  : status(true)
+  { };
+
+  noexcep

[PATCH, i386]: Merge and rename SSE/AVX mode attributes

2011-04-27 Thread Uros Bizjak
Hello!

Several mode SSE/AVX mode attributes can be merged, most notably
various SSE insn suffixes for various modes. Attached patch also
renames several mode attributes.

2011-04-27  Uros Bizjak  

* config/i386/i386.md (ssemodesuffix):  Merge with ssevecsize,
ssemodefsuffix, ssescalarmodesuffix and avxmodesuffixp.
Move from sse.md.
(ssemodefsuffix): Remove.
(ssevecmodesuffix): New mode attribute.
(fix_truncdi_sse, fix_truncsi_sse,
*float2_mixed_interunit,
*float2_mixed_nointerunit,
*float2_sse_interunit,
*float2_sse_nointerunit, setcc__sse,
*sqrt2_sse, sse4_1_round2, 3,
*ieee_smin3, *ieee_smax3): Adjust assembler templates for
ssemodesuffix mode attribute.
(float splitters): Use ssevecmodesuffix mode attribute.
* config/i386/sse.md (ssescalarmode): Merge with avxscalarmode.
(sseinsmode): Rename from avxvecmode.
(avxsizesuffix): Rename from avxmodesuffix.
(sseintvecmode): Rename from avxpermvecmode.
(ssedoublevecmode): Rename from ssedoublesizemode.
(ssehalfvecmode): Rename from avxhalfvecmode.
(ssescalarmode): Rename from avxscalarmode.
(_comi, _ucomi, sse4a_movnt): Adjust assembler
templates for ssemodesuffix mode attribute.
(*andnot3, *3): Use ssevecmodesuffix
mode attribute.

Adjust RTX patterns globally for renamed mode attributes.

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

Uros.
Index: i386.md
===
--- i386.md (revision 173023)
+++ i386.md (working copy)
@@ -934,9 +934,17 @@
 ;; All integer modes handled by SSE cvtts?2si* operators.
 (define_mode_iterator SSEMODEI24 [SI DI])
 
-;; SSE asm suffix for floating point modes
-(define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
+;; SSE instruction suffix for various modes
+(define_mode_attr ssemodesuffix
+  [(SF "ss") (DF "sd")
+   (V8SF "ps") (V4DF "pd")
+   (V4SF "ps") (V2DF "pd")
+   (V16QI "b") (V8HI "w") (V4SI "d") (V2DI "q")
+   (V8SI "si")])
 
+;; SSE vector suffix for floating point modes
+(define_mode_attr ssevecmodesuffix [(SF "ps") (DF "pd")])
+
 ;; SSE vector mode corresponding to a scalar mode
 (define_mode_attr ssevecmode
   [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
@@ -4610,7 +4618,7 @@
(fix:DI (match_operand:MODEF 1 "nonimmediate_operand" "x,m")))]
   "TARGET_64BIT && SSE_FLOAT_MODE_P (mode)
&& (!TARGET_FISTTP || TARGET_SSE_MATH)"
-  "%vcvtts2si{q}\t{%1, %0|%0, %1}"
+  "%vcvtt2si{q}\t{%1, %0|%0, %1}"
   [(set_attr "type" "sseicvt")
(set_attr "prefix" "maybe_vex")
(set_attr "prefix_rex" "1")
@@ -4624,7 +4632,7 @@
(fix:SI (match_operand:MODEF 1 "nonimmediate_operand" "x,m")))]
   "SSE_FLOAT_MODE_P (mode)
&& (!TARGET_FISTTP || TARGET_SSE_MATH)"
-  "%vcvtts2si\t{%1, %0|%0, %1}"
+  "%vcvtt2si\t{%1, %0|%0, %1}"
   [(set_attr "type" "sseicvt")
(set_attr "prefix" "maybe_vex")
(set_attr "mode" "")
@@ -5124,8 +5132,8 @@
&& (TARGET_INTER_UNIT_CONVERSIONS || optimize_function_for_size_p (cfun))"
   "@
fild%Z1\t%1
-   %vcvtsi2s\t{%1, %d0|%d0, %1}
-   %vcvtsi2s\t{%1, %d0|%d0, %1}"
+   %vcvtsi2\t{%1, %d0|%d0, %1}
+   %vcvtsi2\t{%1, %d0|%d0, %1}"
   [(set_attr "type" "fmov,sseicvt,sseicvt")
(set_attr "prefix" "orig,maybe_vex,maybe_vex")
(set_attr "mode" "")
@@ -5150,7 +5158,7 @@
&& !(TARGET_INTER_UNIT_CONVERSIONS || optimize_function_for_size_p (cfun))"
   "@
fild%Z1\t%1
-   %vcvtsi2s\t{%1, %d0|%d0, %1}"
+   %vcvtsi2\t{%1, %d0|%d0, %1}"
   [(set_attr "type" "fmov,sseicvt")
(set_attr "prefix" "orig,maybe_vex")
(set_attr "mode" "")
@@ -5230,7 +5238,7 @@
  CONST0_RTX (V4SImode), operands[2]));
 }
   emit_insn
-(gen_sse2_cvtdq2p (operands[3], operands[4]));
+(gen_sse2_cvtdq2 (operands[3], operands[4]));
   DONE;
 })
 
@@ -5253,7 +5261,7 @@
   emit_insn (gen_sse2_loadld (operands[4],
  CONST0_RTX (V4SImode), operands[1]));
   emit_insn
-(gen_sse2_cvtdq2p (operands[3], operands[4]));
+(gen_sse2_cvtdq2 (operands[3], operands[4]));
   DONE;
 })
 
@@ -5288,7 +5296,7 @@
   else
 gcc_unreachable ();
   emit_insn
-(gen_sse2_cvtdq2p (operands[3], operands[4]));
+(gen_sse2_cvtdq2 (operands[3], operands[4]));
   DONE;
 })
 
@@ -5310,7 +5318,7 @@
   emit_insn (gen_sse2_loadld (operands[4],
  CONST0_RTX (V4SImode), operands[1]));
   emit_insn
-(gen_sse2_cvtdq2p (operands[3], operands[4]));
+(gen_sse2_cvtdq2 (operands[3], operands[4]));
   DONE;
 })
 
@@ -5336,7 +5344,7 @@
   "(mode != DImode || TARGET_64BIT)
&& SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH
&& (TARGET_INTER_UNIT_CONVERSIONS || optimize_function_for_size_p (cfun))"
-  "%vcvtsi2s\t{%1, %d0|%d0, %1}"
+  "%vcvtsi2\t{%1, %d0|%d0, %1}"
   [(set_attr "type" "sseicvt")

[PING][PATCH] Change rclass argument type in memory_move_cost function from enum reg_class to reg_class_t.

2011-04-27 Thread Anatoly Sokolov
Hello.

Patch ping.

>   This patch change memory_move_cost function to stop using back end specific 
> type 'enum reg_class' in favor to reg_class_t. Also this allow do small 
> cleanup in ia64_register_move_cost function.

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

Anatoly.



[SPARC] Hookize PRINT_OPERAND, PRINT_OPERAND_ADDRESS and PRINT_OPERAND_PUNCT_VALID_P

2011-04-27 Thread Anatoly Sokolov
 Hello.

  This patch removes obsolete PRINT_OPERAND, PRINT_OPERAND_ADDRESS and
PRINT_OPERAND_PUNCT_VALID_P macros from SPARC back end in the GCC and 
introduces equivalent TARGET_PRINT_OPERAND, TARGET_PRINT_OPERAND_ADDRESS and 
TARGET_PRINT_OPERAND_PUNCT_VALID_P target hooks. 


   Bootstrapped and regression tested on sparc64-unknown-linux-gnu.

  OK to install?

* config/sparc/sparc.h (PRINT_OPERAND, PRINT_OPERAND_ADDRESS,
PRINT_OPERAND_PUNCT_VALID_P): Remove.
* config/sparc/sparc-protos.h (print_operand): Remove declaration.
* config/sparc/sparc.c (TARGET_PRINT_OPERAND_PUNCT_VALID_P,
TARGET_PRINT_OPERAND, TARGET_PRINT_OPERAND_ADDRESS): Define.
(print_operand): Rename to...
(sparc_print_operand): ...this. Make static. Adjust
sparc_print_operand function call.
(sparc_print_operand_punct_valid_p, sparc_print_operand_address): New
functions.

Index: gcc/config/sparc/sparc-protos.h
===
--- gcc/config/sparc/sparc-protos.h (revision 172733)
+++ gcc/config/sparc/sparc-protos.h (working copy)
@@ -76,7 +76,6 @@
 extern const char *output_probe_stack_range (rtx, rtx);
 extern bool emit_scc_insn (rtx []);
 extern void emit_conditional_branch_insn (rtx []);
-extern void print_operand (FILE *, rtx, int);
 extern int mems_ok_for_ldd_peep (rtx, rtx, rtx);
 extern int arith_double_4096_operand (rtx, enum machine_mode);
 extern int arith_4096_operand (rtx, enum machine_mode);
Index: gcc/config/sparc/sparc.c
===
--- gcc/config/sparc/sparc.c(revision 172733)
+++ gcc/config/sparc/sparc.c(working copy)
@@ -468,6 +468,9 @@
 static void sparc_trampoline_init (rtx, tree, rtx);
 static enum machine_mode sparc_preferred_simd_mode (enum machine_mode);
 static reg_class_t sparc_preferred_reload_class (rtx x, reg_class_t rclass);
+static bool sparc_print_operand_punct_valid_p (unsigned char);
+static void sparc_print_operand (FILE *, rtx, int);
+static void sparc_print_operand_address (FILE *, rtx);
 
 #ifdef SUBTARGET_ATTRIBUTE_TABLE
 /* Table of valid machine attributes.  */
@@ -663,6 +666,13 @@
 #undef TARGET_TRAMPOLINE_INIT
 #define TARGET_TRAMPOLINE_INIT sparc_trampoline_init
 
+#undef TARGET_PRINT_OPERAND_PUNCT_VALID_P
+#define TARGET_PRINT_OPERAND_PUNCT_VALID_P sparc_print_operand_punct_valid_p
+#undef TARGET_PRINT_OPERAND
+#define TARGET_PRINT_OPERAND sparc_print_operand
+#undef TARGET_PRINT_OPERAND_ADDRESS
+#define TARGET_PRINT_OPERAND_ADDRESS sparc_print_operand_address
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Validate and override various options, and do some machine dependent
@@ -7326,12 +7336,29 @@
   return 1;
 }
 
-/* Print operand X (an rtx) in assembler syntax to file FILE.
+/* Implement TARGET_PRINT_OPERAND_PUNCT_VALID_P.  */
+
+static bool
+sparc_print_operand_punct_valid_p (unsigned char code)
+{
+  if(code == '#'
+ || code == '*'
+ || code == '('
+ || code == ')'
+ || code == '_'
+ || code == '&')
+return true;
+
+  return false;
+}
+
+/* Implement TARGET_PRINT_OPERAND.
+   Print operand X (an rtx) in assembler syntax to file FILE.
CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
For `%' followed by punctuation, CODE is the punctuation and X is null.  */
 
-void
-print_operand (FILE *file, rtx x, int code)
+static void
+sparc_print_operand (FILE *file, rtx x, int code)
 {
   switch (code)
 {
@@ -7609,7 +7636,7 @@
 }
   else if (GET_CODE (x) == LO_SUM)
 {
-  print_operand (file, XEXP (x, 0), 0);
+  sparc_print_operand (file, XEXP (x, 0), 0);
   if (TARGET_CM_MEDMID)
fputs ("+%l44(", file);
   else
@@ -7633,6 +7660,89 @@
 output_operand_lossage ("floating point constant not a valid immediate 
operand");
   else { output_addr_const (file, x); }
 }
+
+/* Implement TARGET_PRINT_OPERAND_ADDRESS.  */
+
+static void
+sparc_print_operand_address (FILE *file, rtx x)
+{
+  register rtx base, index = 0;
+  int offset = 0;
+  register rtx addr = x;
+
+  if (REG_P (addr))
+fputs (reg_names[REGNO (addr)], file);
+  else if (GET_CODE (addr) == PLUS)
+{
+  if (CONST_INT_P (XEXP (addr, 0)))
+   offset = INTVAL (XEXP (addr, 0)), base = XEXP (addr, 1);
+  else if (CONST_INT_P (XEXP (addr, 1)))
+   offset = INTVAL (XEXP (addr, 1)), base = XEXP (addr, 0);
+  else
+   base = XEXP (addr, 0), index = XEXP (addr, 1);
+  if (GET_CODE (base) == LO_SUM)
+   {
+ gcc_assert (USE_AS_OFFSETABLE_LO10
+ && TARGET_ARCH64
+ && ! TARGET_CM_MEDMID);
+ output_operand (XEXP (base, 0), 0);
+ fputs ("+%lo(", file);
+ output_address (XEXP (base, 1));
+ fprintf (file, ")+%d", offset);
+   }
+  else
+   {
+ fputs (reg_names[REGNO (base)], file);
+ if (index == 0)
+   fprin

Re: Add inline-analysis predicates to edges

2011-04-27 Thread Michael Matz
Hi,

On Wed, 27 Apr 2011, Jan Hubicka wrote:

> *** false_predicate (void)
> *** 163,168 
> --- 166,195 
>   }
>   
>   
> + /* Return true if P is (false).  */
> + 
> + static inline bool
> + true_predicate_p (struct predicate *p)

Comment doesn't match function.

> + {
> +   return !p->clause[0];
> + }
> + 
> *** add_clause (struct predicate *p, clause_
> *** 207,222 
>   {
> int i;
> int insert_here = -1;
> /* True clause.  */
> if (!clause)
>   return;
>   
> /* Flase clause makes the whole predicate false.  Kill the other 
> variants.  */

s/Flase/False/

> --- 688,719 
>  Indent by INDENT.  */
>   
>   static void
> ! dump_inline_edge_summary (FILE * f, int indent, struct cgraph_node *node,
> !   struct inline_summary *info)
>   {

New arguments have to be documented.

> ! estimate_calls_size_and_time (struct cgraph_node *node, int *size, int 
> *time,
> !   clause_t possible_truths)

Same.

> ! /* Translate all conditions from callee representation into caller 
> representation and
> !symbolically evaluate predicate P into new predicate.
> ! 
> !INFO is inline_summary of function we are adding predicate into, 
> CALLEE_INFO is summary
> !of function predicate P is from. OPERAND_MAP is array giving callee 
> formal IDs the
> !caller formal IDs.

Some word is missing in the last sentence.


>  POSSSIBLE_TRUTHS is clausule of all callee conditions that

"POSSIBLE_TRUTHS" and "a/the clause"


Ciao,
Michael.


[pph] Enable nested namespaces (issue4431071)

2011-04-27 Thread Lawrence Crowl


Add a flag -fpph-dump-tree to dump the namespace trees read and written by PPH.
This dump could use some clarification, but it can wait for another day.

Replace PPH calls to pushdecl_with_scope with pushdecl_into_namespace.  It
turns out that pushdecl_with_scope always inserts into the current namespace,
not the given namespace.  Enable recursive call for nested namespace.

The pushdecl_into_namespace function works by saving and restoring
the current namespace around calls to pushdecl_with_scope, There may
be a better way, such as the disabled call to pushdecl_maybe_friend,
available at the time of cleanup.  There are subsequent segfaults still.

Fix formatting of a conditional in pph-streamer.c.

In libcpp/directives.c, make the too_many_directives_for_bitfield
static assert into an extern to avoid allocating storage.

Index: gcc/c-family/ChangeLog.pph

2011-04-20  Lawrence Crowl  

* c.opt (fpph-dump-tree): Add.

Index: gcc/cp/ChangeLog.pph

2011-04-26  Lawrence Crowl 

* cp-tree.h (pushdecl_into_namespace): Add.
* name-lookup.c (pushdecl_into_namespace): Add.
* pph.c: Add include of tree-dump.h.
(pph_dump_tree_name): Add.
(pph_dump_namespace): Add.
(pph_write_file_contents): Call pph_dump_namespace when appropriate.
(pph_read_file_contents): Call pph_dump_namespace when appropriate.
(pph_add_names_to_namespace): Use pushdecl_into_namespace rather than
pushdecl_with_scope.  Make associated changes.  Enable recursive call
for nested namespace.
* pph-streamer.c (pph_stream_trace): Reformat conditionals.

Index: libcpp/ChangeLog.pph

2011-04-17  Lawrence Crowl  

* directives.c (too_many_directives_for_bitfield): Make static assert
extern to avoid allocating any storage.


Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 172998)
+++ gcc/c-family/c.opt  (working copy)
@@ -937,6 +937,10 @@ fpph-decls-debug=
 C++ Joined RejectNegative UInteger Var(flag_pph_decls_debug)
 -fpph-decls=N   Enable declaration identifier output at level N from PPH 
support
 
+fpph-dump-tree
+C++ Var(flag_pph_dump_tree)
+-fpph-dump-treeDump global namespace tree around PPH reads/writes.
+
 fpph-hdr=
 C++ ObjC++ Joined MissingArgError(missing filename after %qs)
 -fpph-hdr=   A mapping from .h to .pph
Index: gcc/cp/pph.c
===
--- gcc/cp/pph.c(revision 172998)
+++ gcc/cp/pph.c(working copy)
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3.  
 #include "fixed-value.h"
 #include "md5.h"
 #include "tree-pass.h"
+#include "tree-dump.h"
 #include "tree-inline.h"
 #include "tree-pretty-print.h"
 #include "parser.h"
@@ -1863,12 +1864,65 @@ pth_file_change (cpp_reader *reader, con
 }
 
 
+/* Dump a complicated name for tree T to FILE using FLAGS.
+   See TDF_* in tree-pass.h for flags.  */
+
+static void
+pph_dump_tree_name (FILE *file, tree t, int flags)
+{
+  enum tree_code code = TREE_CODE (t);
+  fprintf (file, "%s\t", tree_code_name[code]);
+  if (code == FUNCTION_TYPE || code == METHOD_TYPE)
+{
+  dump_function_to_file (t, file, flags);
+}
+  else
+{
+  print_generic_expr (file, TREE_TYPE (t), flags);
+  /* FIXME pph: fprintf (file, " ", cxx_printable_name (t, 0)); */
+  fprintf (file, " " );
+  print_generic_expr (file, t, flags);
+}
+  fprintf (file, "\n");
+}
+
+
+/* Dump namespace NS for PPH.  */
+
+static void
+pph_dump_namespace (FILE *file, tree ns)
+{
+  struct cp_binding_level *level;
+  tree t, chain;
+  level = NAMESPACE_LEVEL (ns);
+
+  fprintf (file, "namespace ");
+  print_generic_expr (file, ns, 0);
+  fprintf (file, " {\n");
+  for (t = level->names; t; t = chain)
+{
+  chain = DECL_CHAIN (t);
+  if (!DECL_IS_BUILTIN (t))
+pph_dump_tree_name (file, t, 0);
+}
+  for (t = level->namespaces; t; t = chain)
+{
+  chain = DECL_CHAIN (t);
+  if (!DECL_IS_BUILTIN (t))
+pph_dump_namespace (file, t);
+}
+  fprintf (file, "}\n");
+}
+
+
 /* Write PPH output symbols and IDENTS_USED to STREAM as an object.  */
 
 static void
 pph_write_file_contents (pph_stream *stream, cpp_idents_used *idents_used)
 { 
   pth_save_identifiers (idents_used, stream);
+  if (flag_pph_dump_tree)
+pph_dump_namespace (pph_logfile, global_namespace);
   pph_output_tree (stream, global_namespace, false);
 }
 
@@ -1943,34 +1997,26 @@ report_validation_error (const char *fil
 static void
 pph_add_names_to_namespace (tree ns, tree new_ns)
 {
-  struct cp_binding_level *new_level, *level;
   tree t, chain;
+  struct cp_binding_level *level = NAMESPACE_LEVEL (new_ns);
 
-  level = NAMESPACE_LEVEL (ns);
-  new_level = NAMESPACE_LEVEL (new_ns);
-
-  for (t = new_level->names; t; t = chain)
+  for (t = level->names; t; t = chain)
 {
   /* Pushing a decl into a scope clobbers its DECL_CHAI

FDO patch -- make ic related vars TLS if target allows

2011-04-27 Thread Xinliang David Li
Hi please review the trivial patch below. It reduces race conditions
in value profiling. Another trivial change (to initialize
function_list struct) is also included.

Bootstrapped and regression tested on x86-64/linux.

Thanks,

David


2011-04-27  Xinliang David Li  

* tree-profile.c (init_ic_make_global_vars): Set
tls attribute on ic vars.
* coverage.c (coverage_end_function): Initialize
function_list with zero.
Index: coverage.c
===
--- coverage.c	(revision 172977)
+++ coverage.c	(working copy)
@@ -608,7 +608,7 @@ coverage_end_function (void)
 {
   struct function_list *item;
 
-  item = XNEW (struct function_list);
+  item = XCNEW (struct function_list);
 
   *functions_tail = item;
   functions_tail = &item->next;
Index: tree-profile.c
===
--- tree-profile.c	(revision 172977)
+++ tree-profile.c	(working copy)
@@ -44,6 +44,8 @@ along with GCC; see the file COPYING3.  
 #include "value-prof.h"
 #include "cgraph.h"
 #include "profile.h"
+#include "target.h"
+#include "output.h"
 
 static GTY(()) tree gcov_type_node;
 static GTY(()) tree gcov_type_tmp_var;
@@ -80,6 +82,10 @@ init_ic_make_global_vars (void)
   TREE_PUBLIC (ic_void_ptr_var) = 0;
   DECL_ARTIFICIAL (ic_void_ptr_var) = 1;
   DECL_INITIAL (ic_void_ptr_var) = NULL;
+  if (targetm.have_tls)
+DECL_TLS_MODEL (ic_void_ptr_var) =
+  decl_default_tls_model (ic_void_ptr_var);
+
   varpool_finalize_decl (ic_void_ptr_var);
   varpool_mark_needed_node (varpool_node (ic_void_ptr_var));
 
@@ -92,6 +98,10 @@ init_ic_make_global_vars (void)
   TREE_PUBLIC (ic_gcov_type_ptr_var) = 0;
   DECL_ARTIFICIAL (ic_gcov_type_ptr_var) = 1;
   DECL_INITIAL (ic_gcov_type_ptr_var) = NULL;
+  if (targetm.have_tls)
+DECL_TLS_MODEL (ic_gcov_type_ptr_var) =
+  decl_default_tls_model (ic_gcov_type_ptr_var);
+
   varpool_finalize_decl (ic_gcov_type_ptr_var);
   varpool_mark_needed_node (varpool_node (ic_gcov_type_ptr_var));
 }


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

2011-04-27 Thread Cary Coutant
>> +  generate_debug_line_table = debug_info_level >= DINFO_LEVEL_NORMAL;
>
> set_debug_level should not use global state; this needs to check
> opts->x_debug_info_level (not the global debug_info_level) and set
> opts->x_generate_debug_line_table.

Oops, missed that. Thanks!

-cary


Re: Toplevel cleanup: split out libgcj disabling

2011-04-27 Thread Mike Stump
On Apr 27, 2011, at 8:50 AM, Joseph S. Myers wrote:
> Continuing the toplevel cleanups separating the cases disabling
> different subdirectories

I've audited the two patches for darwin and they seem safe.  Took me a second 
to figure out why though.


Re: FDO usability patch -- cfg and lineno checksum

2011-04-27 Thread Xinliang David Li
On Wed, Apr 27, 2011 at 10:03 AM, Jan Hubicka  wrote:
>> >> -       else if (entry->checksum != checksum)
>> >> +       else if (entry->lineno_checksum != lineno_checksum
>> >> +                || entry->cfg_checksum != cfg_checksum)
>> >>           {
>> >>             error ("coverage mismatch for function %u while reading 
>> >> execution counters",
>> >>                    fn_ident);
>> >> -           error ("checksum is %x instead of %x", entry->checksum, 
>> >> checksum);
>> >> +           error ("checksum is (%x,%x) instead of (%x,%x)",
>> >> +                  entry->lineno_checksum, entry->cfg_checksum,
>> >> +                  lineno_checksum, cfg_checksum);
>> >
>> > Can't we give more informative message whether code changes or it seems to 
>> > be
>> > optimization options disprepancy?
>>
>> Good idea -- but to change the warning not the error here. For the
>> warning (which is promoted to error by default) currently it is:
>>
>> error: coverage mismatch for function  while reading counter yyy.
>>  note: control flow checksum is aaa instead of bbb
>>
>> Could be:
>> error: function xxx's control flow does match its profile data (counter yyy).
>>   note: use -Wno-error=coverage-mismatch to tolerate the mismatch but
>> performance may drop if the function is hot.
>
> Well, I had more in mind giving diffent message for lineno checksum 
> difference than cfg checksum.
> But I agree that we probably don't want to output checksum numbers, those are 
> useless even for debugging.
> Probably could follow same warning/error rules as the main loading routine 
> whatever you converged
> to.
>

Sure.

Thanks,

David

> Honza
>


Re: FDO usability patch -- cfg and lineno checksum

2011-04-27 Thread Jan Hubicka
> >> -       else if (entry->checksum != checksum)
> >> +       else if (entry->lineno_checksum != lineno_checksum
> >> +                || entry->cfg_checksum != cfg_checksum)
> >>           {
> >>             error ("coverage mismatch for function %u while reading 
> >> execution counters",
> >>                    fn_ident);
> >> -           error ("checksum is %x instead of %x", entry->checksum, 
> >> checksum);
> >> +           error ("checksum is (%x,%x) instead of (%x,%x)",
> >> +                  entry->lineno_checksum, entry->cfg_checksum,
> >> +                  lineno_checksum, cfg_checksum);
> >
> > Can't we give more informative message whether code changes or it seems to 
> > be
> > optimization options disprepancy?
> 
> Good idea -- but to change the warning not the error here. For the
> warning (which is promoted to error by default) currently it is:
> 
> error: coverage mismatch for function  while reading counter yyy.
>  note: control flow checksum is aaa instead of bbb
> 
> Could be:
> error: function xxx's control flow does match its profile data (counter yyy).
>   note: use -Wno-error=coverage-mismatch to tolerate the mismatch but
> performance may drop if the function is hot.

Well, I had more in mind giving diffent message for lineno checksum difference 
than cfg checksum.
But I agree that we probably don't want to output checksum numbers, those are 
useless even for debugging.
Probably could follow same warning/error rules as the main loading routine 
whatever you converged
to.

Honza


Re: FDO usability patch -- cfg and lineno checksum

2011-04-27 Thread Xinliang David Li
On Wed, Apr 27, 2011 at 8:54 AM, Jan Hubicka  wrote:
> Please don't forget about changelogs..
>> Index: tree.c
>> ===
>> --- tree.c    (revision 172802)
>> +++ tree.c    (working copy)
>> @@ -8513,14 +8513,12 @@ dump_tree_statistics (void)
>
> The crc bits was already reviewed, right?

Yes.

>> -       else if (entry->checksum != checksum)
>> +       else if (entry->lineno_checksum != lineno_checksum
>> +                || entry->cfg_checksum != cfg_checksum)
>>           {
>>             error ("coverage mismatch for function %u while reading 
>> execution counters",
>>                    fn_ident);
>> -           error ("checksum is %x instead of %x", entry->checksum, 
>> checksum);
>> +           error ("checksum is (%x,%x) instead of (%x,%x)",
>> +                  entry->lineno_checksum, entry->cfg_checksum,
>> +                  lineno_checksum, cfg_checksum);
>
> Can't we give more informative message whether code changes or it seems to be
> optimization options disprepancy?

Good idea -- but to change the warning not the error here. For the
warning (which is promoted to error by default) currently it is:

error: coverage mismatch for function  while reading counter yyy.
 note: control flow checksum is aaa instead of bbb

Could be:
error: function xxx's control flow does match its profile data (counter yyy).
  note: use -Wno-error=coverage-mismatch to tolerate the mismatch but
performance may drop if the function is hot.

>> +unsigned
>> +coverage_compute_cfg_checksum (void)
>> +{
>> +  basic_block bb;
>> +  unsigned chksum = n_basic_blocks;
>> +
>> +  FOR_EACH_BB (bb)
>> +    {
>> +      edge e;
>> +      edge_iterator ei;
> Perhaps also
> chksum = crc32_byte (chksum, bb->index)
> for cases where destination stays the same, but source of edge moves (i.e. 
> with forwarder
> blocks)

Yes.

Thanks,

David

>
> Patch is OK, thanks
> Honza
>


[wwwdocs] Remove three obsolete icons

2011-04-27 Thread Gerald Pfeifer
...for a validator never implemented.  Andrea Bocci did some work
around this in 2003, but we never completed the effort.

validate-empty.png, validate-error.png, and validate-ok.png are
the three images.

Gerald



Toplevel cleanup: disable Java when libffi not supported

2011-04-27 Thread Joseph S. Myers
This patch, relative to a tree with
 applied,
continues the cleanup of toplevel cases relating to disabling Java or
Java libraries by arranging for Java to be disabled (via
unsupported_languages) on targets not supporting libffi, and removing
many cases in the Java-disabling case statement that are no longer
needed, either because they relate to targets not supporting libffi or
because they relate to targets no longer supported in GCC so it
doesn't matter what the Java configuration is for them.

The ideal would be for information about libffi-supported targets to
come from a configure fragment in the libffi/ directory, as per item 4
in .  Given that at
present there is some divergence between the libffi repository and the
GCC copy of libffi, however, now may not be the best time to add such
a fragment in GCC; instead, I put a minimal case statement (covering
only targets supported by both libffi and GCC) at toplevel.

Where Java-disabling-related cases did more than just disabling Java
or ${libgcj} (for example, explicitly disabling target-boehm-gc or
target-libffi) I left them in for now even if not strictly needed with
the separate libffi case statement.

This patch is intended to be safe, in that the only way it should
change behavior for targets supported by GCC is to disable Java in
some cases where the libraries would not build because of lack of
libffi support (whether or not the libraries and front end were
previously enabled in such cases).

OK to commit?

2011-04-27  Joseph Myers  

* configure.ac: Disable Java for targets not supporting libffi.
(*-*-kaos*, am33_2.0-*-linux*, sh*-*-pe|mips*-*-pe): Remove cases
in Java-disabling statement.
(*arm-wince-pe): Change to arm-wince-pe.
(arc-*-*, arm-*-coff, arm-*-pe*, arm-*-riscix*, avr-*-*): Remove
cases in Java-disabling statement.
(bfin-*-*): Don't disable Java again.
(c4x-*-* | tic4x-*-*, tic54x-*-*, cr16-*-*, d10v-*-*, d30v-*-*,
fr30-*-elf*, moxie-*-*, h8300*-*-*, h8500-*-*, hppa1.1-*-osf* |
hppa1.1-*-bsd*, hppa*-*-*elf* | hppa*-*-lites* | hppa*-*-openbsd*,
hppa*-*-pro*, i960-*-*, i[[3456789]]86-*-coff,
i[[3456789]]86-*-pe, i[[3456789]]86-*-sco3.2v5*,
i[[3456789]]86-*-sco*, i[[3456789]]86-*-sysv4*,
i[[3456789]]86-*-beos*, i[[3456789]]86-*-rdos*,
m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*): Remove cases in
Java-disabling statement.
(mmix-*-*): Don't disable Java again.
(mt-*-*, powerpc*-*-winnt* | powerpc*-*-pe*, powerpcle-*-solaris*,
powerpc-*-beos*, rs6000-*-lynxos*, rs6000-*-*, m68k-apollo-*,
microblaze*, mips*-sde-elf*, mips*-*-irix5*, mips*-*-bsd*,
sparclet-*-aout* | sparc86x-*-*, sparclite-*-*, sparc-*-sunos4*,
tic6x-*-*, v810-*-*, vax-*-*): Remove cases in Java-disabling
statement.
* configure: Regenerate.

--- configure.ac2011-04-27 15:22:59.0 +
+++ configure.ac.new2011-04-27 16:12:46.0 +
@@ -558,10 +558,61 @@
 ;;
 esac
 
-# Disable Java, libgcj or related libraries for some systems.
+# Disable Java if libffi is not supported.
 case "${target}" in
-  *-*-chorusos)
+  alpha*-*-*)
+;;
+  arm*-*-*)
+;;
+  cris-*-*)
+;;
+  frv-*-*)
+;;
+  hppa*-*-linux*)
+;;
+  hppa*-*-hpux*)
+;;
+  i?86-*-*)
+;;
+  ia64*-*-*)
+;;
+  m32r*-*-*)
+;;
+  m68k-*-*)
+;;
+  mips-sgi-irix6.* | mips*-*-rtems*)
+;;
+  mips*-*-linux*)
+;;
+  powerpc*-*-linux*)
+;;
+  powerpc-*-darwin*)
+;;
+  powerpc-*-aix* | rs6000-*-aix*)
+;;
+  powerpc-*-freebsd*)
+;;
+  powerpc64-*-freebsd*)
+;;
+  powerpc*-*-rtems*)
 ;;
+  s390-*-* | s390x-*-*)
+;;
+  sh-*-* | sh[[34]]*-*-*)
+;;
+  sh64-*-* | sh5*-*-*)
+;;
+  sparc*-*-*)
+;;
+  x86_64-*-*)
+;;
+  *-*-*)
+unsupported_languages="$unsupported_languages java"
+;;
+esac
+
+# Disable Java, libgcj or related libraries for some systems.
+case "${target}" in
   powerpc-*-darwin*)
 ;;
   i[[3456789]]86-*-darwin*)
@@ -584,8 +635,6 @@
;;
 esac
 ;;
-  *-*-kaos*)
-;;
   *-*-netbsd*)
 # Skip some stuff that's unsupported on some NetBSD configurations.
 case "${target}" in
@@ -621,19 +670,12 @@
   alpha*-*-*)
 noconfigdirs="$noconfigdirs ${libgcj}"
 ;;
-  am33_2.0-*-linux*)
-noconfigdirs="$noconfigdirs ${libgcj}"
-;;
   sh-*-linux*)
 noconfigdirs="$noconfigdirs ${libgcj}"
 ;;
-  sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+  arm-wince-pe)
 noconfigdirs="$noconfigdirs ${libgcj}"
 ;;
-  arc-*-*)
-;;
-  arm-*-coff)
-;;
   arm-*-elf* | arm*-*-eabi* )
 noconfigdirs="$noconfigdirs target-libffi"
 ;;
@@ -642,25 +684,9 @@
   arm*-*-symbianelf*)
 noconfigdirs="$noconfigdirs ${libgcj}"
 ;;
-  arm-*-pe*)
-noconfigdirs="$noconfigdirs ${libgcj}"

[patch, 4.5] Fix PR middle-end/43085 (make profiledbootstrap crashes due to dataflow bug)

2011-04-27 Thread Ulrich Weigand
Hello,

PR middle-end/43085 is a crash of cc1plus when building libstdc++ during
make profiledbootstrap on the 4.5 branch.  The crash is caused by a
mis-compile of the add_method routine with -fprofile-use due to a
dataflow bug during the final if-conversion pass.  For more detailed
analysis see the PR.

The dataflow bug was fixed on mainline (already for 4.6) by a series of
patches by Bernd Schmidt, who noticed the bug in a different context.

The patch below is a backport of those fixes to the 4.5 branch, which
fixes the profiled-bootstrap failure for me.  (Note that on current
mainling, the ifcvt.c dead_or_predictable routine has been significantly
rewritten beyond what was done by those patches.  These additional
changes do not appear to be necessary to fix the PR ...)

Tested on 4.5 on i386-linux with no regression; make profiledbootstrap
works again (and the resulting compiler also passes the testsuite with
no regressions).

OK for the 4.5 branch?

Bye,
Ulrich


2011-04-27  Ulrich Weigand  

PR middle-end/43085
Backport from mainline:

2010-04-29  Bernd Schmidt  

From Dominique d'Humieres 
PR bootstrap/43858
* ifcvt.c (dead_or_predicable): Use df_simulate_find_defs to compute
test_set.

2010-04-26  Bernd Schmidt  

* df-problems.c (df_simulate_initialize_forwards): Set, don't clear,
bits for artificial defs at the top of the block.
* fwprop.c (single_def_use_enter_block): Don't call it.

2010-04-22  Bernd Schmidt  

* ifcvt.c (dead_or_predicable): Use df_simulate_find_defs and
df_simulate_find_noclobber_defs as appropriate.  Keep track of an
extra set merge_set_noclobber, and use it to relax the final test
slightly.
* df.h (df_simulate_find_noclobber_defs): Declare.
* df-problems.c (df_simulate_find_defs): Don't ignore partial or
conditional defs.
(df_simulate_find_noclobber_defs): New function.


Index: gcc/fwprop.c
===
--- gcc/fwprop.c(revision 172641)
+++ gcc/fwprop.c(working copy)
@@ -228,8 +228,11 @@
 
   process_uses (df_get_artificial_uses (bb_index), DF_REF_AT_TOP);
   process_defs (df_get_artificial_defs (bb_index), DF_REF_AT_TOP);
-  df_simulate_initialize_forwards (bb, local_lr);
 
+  /* We don't call df_simulate_initialize_forwards, as it may overestimate
+ the live registers if there are unused artificial defs.  We prefer
+ liveness to be underestimated.  */
+
   FOR_BB_INSNS (bb, insn)
 if (INSN_P (insn))
   {
Index: gcc/ifcvt.c
===
--- gcc/ifcvt.c (revision 172641)
+++ gcc/ifcvt.c (working copy)
@@ -3818,7 +3818,7 @@
basic_block other_bb, basic_block new_dest, int reversep)
 {
   rtx head, end, jump, earliest = NULL_RTX, old_dest, new_label = NULL_RTX;
-  bitmap merge_set = NULL;
+  bitmap merge_set = NULL, merge_set_noclobber = NULL;
   /* Number of pending changes.  */
   int n_validated_changes = 0;
 
@@ -3951,11 +3951,14 @@
 
   /* Collect:
   MERGE_SET = set of registers set in MERGE_BB
+  MERGE_SET_NOCLOBBER = like MERGE_SET, but only includes registers
+that are really set, not just clobbered.
   TEST_LIVE = set of registers live at EARLIEST
-  TEST_SET  = set of registers set between EARLIEST and the
-  end of the block.  */
+  TEST_SET = set of registers set between EARLIEST and the
+end of the block.  */
 
   merge_set = BITMAP_ALLOC (®_obstack);
+  merge_set_noclobber = BITMAP_ALLOC (®_obstack);
 
   /* If we allocated new pseudos (e.g. in the conditional move
 expander called from noce_emit_cmove), we must resize the
@@ -3967,13 +3970,8 @@
{
  if (NONDEBUG_INSN_P (insn))
{
- unsigned int uid = INSN_UID (insn);
- df_ref *def_rec;
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
-   {
- df_ref def = *def_rec;
- bitmap_set_bit (merge_set, DF_REF_REGNO (def));
-   }
+ df_simulate_find_defs (insn, merge_set);
+ df_simulate_find_noclobber_defs (insn, merge_set_noclobber);
}
}
 
@@ -3984,7 +3982,7 @@
  unsigned i;
  bitmap_iterator bi;
 
-  EXECUTE_IF_SET_IN_BITMAP (merge_set, 0, i, bi)
+  EXECUTE_IF_SET_IN_BITMAP (merge_set_noclobber, 0, i, bi)
{
  if (i < FIRST_PSEUDO_REGISTER
  && ! fixed_regs[i]
@@ -4015,12 +4013,14 @@
}
 
   /* We can perform the transformation if
-  MERGE_SET & (TEST_SET | TEST_LIVE)
+  MERGE_SET_NOCLOBBER & TEST_SET
 and
+  MERGE_SET & TEST_LIVE
+and
   TEST_SET & DF_LIVE_IN (merge_bb)
 are empty.  */
 
- 

Re: [PATCH][ARM] RTABI half-precision conversion functions

2011-04-27 Thread Andrew Stubbs

On 21/04/11 16:58, Joseph S. Myers wrote:

You need to add

%inherit GCC_4.7.0 GCC_4.6.0
GCC_4.7.0 {
}


Ok, done. Is this OK now?

Andrew
2011-04-27  Andrew Stubbs  

	gcc/
	* config/arm/arm.c (arm_init_libfuncs): Change __gnu_f2h_ieee to
	__aeabi_f2h, __gnu_f2h_alternative to __aeabi_f2h_alt, __gnu_h2f_ieee
	to __aeabi_h2f, and __gnu_h2f_alternative to __aeabi_h2f_alt.
	* config/arm/fp16.c (__gnu_f2h_internal): Change return type to
	unsigned int. Change 'sign' variable likewise.
	(__gnu_h2f_internal): Set to static inline.
	Change return type to unsigned int. Change 'sign' variable likewise.
	(ALIAS): New define.
	(__gnu_f2h_ieee): Change unsigned short to unsigned int.
	(__gnu_h2f_ieee): Likewise.
	(__gnu_f2h_alternative): Likewise.
	(__gnu_h2f_alternative): Likewise.
	(__aeabi_f2h, __aeabi_h2f): New aliases.
	(__aeabi_f2h_alt, __aeabi_h2f_alt): Likewise.
	* config/arm/sfp-machine.h (__extendhfsf2): Set to __aeabi_h2f.
	(__truncsfhf2): Set to __aeabi_f2h.
	* config/arm/t-bpabi (LIB2FUNCS_STATIC_EXTRA): Move fp16.c ...
	(LIB2FUNCS_EXTRA): ... to here.
	* config/arm/t-symbian (LIB2FUNCS_STATIC_EXTRA): Move fp16.c ...
	(LIB2FUNCS_EXTRA): ... to here.
	* libgcc-std.ver (GCC_4.7.0): New version.

	gcc/testsuite/
	* g++.dg/ext/arm-fp16/arm-fp16-ops-5.C: Check for __aeabi_h2f
	and __aeabi_f2h.
	* g++.dg/ext/arm-fp16/arm-fp16-ops-6.C: Likewise.
	* gcc.dg/torture/arm-fp16-ops-5.c: Likewise.
	* gcc.dg/torture/arm-fp16-ops-6.c: Likewise.

--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -1181,12 +1181,12 @@ arm_init_libfuncs (void)
   /* Conversions.  */
   set_conv_libfunc (trunc_optab, HFmode, SFmode,
 			(arm_fp16_format == ARM_FP16_FORMAT_IEEE
-			 ? "__gnu_f2h_ieee"
-			 : "__gnu_f2h_alternative"));
+			 ? "__aeabi_f2h"
+			 : "__aeabi_f2h_alt"));
   set_conv_libfunc (sext_optab, SFmode, HFmode, 
 			(arm_fp16_format == ARM_FP16_FORMAT_IEEE
-			 ? "__gnu_h2f_ieee"
-			 : "__gnu_h2f_alternative"));
+			 ? "__aeabi_h2f"
+			 : "__aeabi_h2f_alt"));
   
   /* Arithmetic.  */
   set_optab_libfunc (add_optab, HFmode, NULL);
--- a/gcc/config/arm/fp16.c
+++ b/gcc/config/arm/fp16.c
@@ -22,10 +22,10 @@
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
.  */
 
-static inline unsigned short
+static inline unsigned int
 __gnu_f2h_internal(unsigned int a, int ieee)
 {
-  unsigned short sign = (a >> 16) & 0x8000;
+  unsigned int sign = (a >> 16) & 0x8000;
   int aexp = (a >> 23) & 0xff;
   unsigned int mantissa = a & 0x007f;
   unsigned int mask;
@@ -95,10 +95,10 @@ __gnu_f2h_internal(unsigned int a, int ieee)
   return sign | (((aexp + 14) << 10) + (mantissa >> 13));
 }
 
-unsigned int
-__gnu_h2f_internal(unsigned short a, int ieee)
+static inline unsigned int
+__gnu_h2f_internal(unsigned int a, int ieee)
 {
-  unsigned int sign = (unsigned int)(a & 0x8000) << 16;
+  unsigned int sign = (a & 0x8000) << 16;
   int aexp = (a >> 10) & 0x1f;
   unsigned int mantissa = a & 0x3ff;
 
@@ -120,26 +120,33 @@ __gnu_h2f_internal(unsigned short a, int ieee)
   return sign | (((aexp + 0x70) << 23) + (mantissa << 13));
 }
 
-unsigned short
+#define ALIAS(src, dst) \
+  typeof (src) dst __attribute__ ((alias (#src)));
+
+unsigned int
 __gnu_f2h_ieee(unsigned int a)
 {
   return __gnu_f2h_internal(a, 1);
 }
+ALIAS (__gnu_f2h_ieee, __aeabi_f2h)
 
 unsigned int
-__gnu_h2f_ieee(unsigned short a)
+__gnu_h2f_ieee(unsigned int a)
 {
   return __gnu_h2f_internal(a, 1);
 }
+ALIAS (__gnu_h2f_ieee, __aeabi_h2f)
 
-unsigned short
+unsigned int
 __gnu_f2h_alternative(unsigned int x)
 {
   return __gnu_f2h_internal(x, 0);
 }
+ALIAS (__gnu_f2h_alternative, __aeabi_f2h_alt)
 
 unsigned int
-__gnu_h2f_alternative(unsigned short a)
+__gnu_h2f_alternative(unsigned int a)
 {
   return __gnu_h2f_internal(a, 0);
 }
+ALIAS (__gnu_h2f_alternative, __aeabi_h2f_alt)
--- a/gcc/config/arm/libgcc-bpabi.ver
+++ b/gcc/config/arm/libgcc-bpabi.ver
@@ -106,3 +106,10 @@ GCC_3.5 {
 GCC_4.3.0 {
   _Unwind_Backtrace
 }
+
+GCC_4.7.0 {
+  __aeabi_f2h
+  __aeabi_f2h_alt
+  __aeabi_h2f
+  __aeabi_h2f_alt
+}
--- a/gcc/config/arm/sfp-machine.h
+++ b/gcc/config/arm/sfp-machine.h
@@ -99,7 +99,7 @@ typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
 #define __fixdfdi	__aeabi_d2lz
 #define __fixunsdfdi	__aeabi_d2ulz
 #define __floatdidf	__aeabi_l2d
-#define __extendhfsf2	__gnu_h2f_ieee
-#define __truncsfhf2	__gnu_f2h_ieee
+#define __extendhfsf2	__aeabi_h2f
+#define __truncsfhf2	__aeabi_f2h
 
 #endif /* __ARM_EABI__ */
--- a/gcc/config/arm/t-bpabi
+++ b/gcc/config/arm/t-bpabi
@@ -21,9 +21,8 @@ LIB1ASMFUNCS += _aeabi_lcmp _aeabi_ulcmp _aeabi_ldivmod _aeabi_uldivmod
 
 # Add the BPABI C functions.
 LIB2FUNCS_EXTRA = $(srcdir)/config/arm/bpabi.c \
-		  $(srcdir)/config/arm/unaligned-funcs.c
-
-LIB2FUNCS_STATIC_EXTRA = $(srcdir)/config/arm/fp16.c
+		  $(srcdir)/config/arm/unaligned-funcs.c \
+		  $(srcdir)/config/arm/fp16.c
 
 UNWIND_H = $(srcdir)/config/arm/unwind-arm.

Re: [gomp3.1] Update libgomp.texi

2011-04-27 Thread Jakub Jelinek
On Wed, Apr 27, 2011 at 06:22:16PM +0200, Tobias Burnus wrote:
> Jakub, is the patch OK for the GOMP-3_1-branch?

With a suitable ChangeLog entry yes.

Jakub


[gomp3.1] Update libgomp.texi

2011-04-27 Thread Tobias Burnus
Hi Jakub, hello all,

the attached patch updates GOMP-3_1-branch's libgomp.texi for
OpenMP 3.1 (current draft).

Changes:
- Change 3.0 to 3.1, including checking/updating the section numbers
- Add omp_in_final
- Add OMP_PROC_BIND
- Update OMP_NUM_THREADS (now that a list is allowed)
- Fix a few small issues like wrong prototypes

(It think the section "The libgomp ABI" still needs to be updated, but I
 leave that to Jakub :-)

Jakub, is the patch OK for the GOMP-3_1-branch?

Tobias
--- libgomp/libgomp.texi.orig	2011-04-27 11:11:38.312345435 +0200
+++ libgomp/libgomp.texi	2011-04-27 11:55:30.054575590 +0200
@@ -116,7 +116,7 @@
 
 A complete description of all OpenMP directives accepted may be found in 
 the @uref{http://www.openmp.org, OpenMP Application Program Interface} manual,
-version 3.0.
+version 3.1.
 
 
 @c -
@@ -127,7 +127,7 @@
 @chapter Runtime Library Routines
 
 The runtime routines described here are defined by section 3 of the OpenMP 
-specifications in version 3.0. The routines are structured in following
+specifications in version 3.1. The routines are structured in following
 three parts:
 
 Control threads, processors and the parallel environment.
@@ -147,6 +147,7 @@
 * omp_get_thread_limit::Maximum number of threads
 * omp_get_thread_num::  Current thread ID
 * omp_in_parallel:: Whether a parallel region is active
+* omp_in_final::Whether in final or included task region
 * omp_set_dynamic:: Enable/disable dynamic teams
 * omp_set_max_active_levels::   Limits the number of active parallel regions
 * omp_set_nested::  Enable/disable nested parallel regions
@@ -199,7 +200,7 @@
 @ref{omp_get_level}, @ref{omp_get_max_active_levels}, @ref{omp_set_max_active_levels}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.19.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.19.
 @end table
 
 
@@ -228,7 +229,7 @@
 @ref{omp_get_level}, @ref{omp_get_thread_num}, @ref{omp_get_team_size}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.17.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.17.
 @end table
 
 
@@ -260,7 +261,7 @@
 @ref{omp_set_dynamic}, @ref{OMP_DYNAMIC}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.8.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.8.
 @end table
 
 
@@ -286,7 +287,7 @@
 @ref{omp_get_active_level}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.16.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.16.
 @end table
 
 
@@ -311,7 +312,7 @@
 @ref{omp_set_max_active_levels}, @ref{omp_get_active_level}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.14.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.15.
 @end table
 
 
@@ -337,7 +338,7 @@
 @ref{omp_set_num_threads}, @ref{omp_set_dynamic}, @ref{omp_get_thread_limit}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.3.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.3.
 @end table
 
 
@@ -369,7 +370,7 @@
 @ref{omp_set_nested}, @ref{OMP_NESTED}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.10.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.10.
 @end table
 
 
@@ -391,7 +392,7 @@
 @end multitable
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.5.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.5.
 @end table
 
 
@@ -424,7 +425,7 @@
 @ref{omp_get_max_threads}, @ref{omp_set_num_threads}, @ref{OMP_NUM_THREADS}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.2.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.2.
 @end table
 
 
@@ -440,7 +441,7 @@
 
 @item @emph{C/C++}
 @multitable @columnfractions .20 .80
-@item @emph{Prototype}: @tab @code{omp_schedule(omp_sched_t *kind, int *modifier);}
+@item @emph{Prototype}: @tab @code{void omp_schedule(omp_sched_t *kind, int *modifier);}
 @end multitable
 
 @item @emph{Fortran}:
@@ -454,7 +455,7 @@
 @ref{omp_set_schedule}, @ref{OMP_SCHEDULE}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.12.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2.12.
 @end table
 
 
@@ -484,7 +485,7 @@
 @ref{omp_get_num_threads}, @ref{omp_get_level}, @ref{omp_get_ancestor_thread_num}
 
 @item @emph{Reference}:
-@uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.18.
+@uref{http://www.openmp.org/, OpenMP specifications v3.1}, section 3.2

Add inline-analysis predicates to edges

2011-04-27 Thread Jan Hubicka
Hi,
this patch finishes the basic predicate infrastructure of ipa-inline by adding 
predicates to edges.
The predicates are combined, so we can work out very simple cases where 
function call becmes
dead after inlining. In tramp3d we get couple hundred cases like that, so it 
seems to make
difference and I can also make quite reliable testcases for testsuite, now.

Bootstrapped/regtested x86_64-linux, will commit it later today.

Honza

* testsuite/gcc.dg/tree-ssa/inline-9.c: New testcase.
* ipa-inline.h (struct inline_edge_summary): Add predicate pointer.
* ipa-inline-analysis.c: Include alloc-pool.h.
(edge_predicate_pool): New.
(trye_predicate_p): New function
(false_predicate_p): New function.
(add_clause): Sanity check that false clauses are "optimized";
never add clauses to predicate that is already known to be false.
(and_predicate): Use flase_predicate_p.
(evaulate_predicate): Rename to ...
(evaluate_predicate): ... this one; update all callers; assert
that false is not listed among possible truths.
(dump_predicate): Use true_predicate_p.
(account_size_time): Use false_predicate_p.
(evaulate_conditions_for_edge): Rename to ...
(evaluate_conditions_for_edge) ... this one.
(edge_set_predicate): New function.
(inline_edge_duplication_hook): Duplicate edge predicates.
(inline_edge_removal_hook): Free edge predicates.
(dump_inline_edge_summary): Add INFO parameter; dump
edge predicates.
(dump_inline_summary): Update.
(estimate_function_body_sizes): Set edge predicates.
(estimate_calls_size_and_time): Handle predicates.
(estimate_callee_size_and_time): Update.
(remap_predicate): Add toplev_predicate; update comment.
(remap_edge_predicates): New function.
(inline_merge_summary): Compute toplev predicate; update.
(read_predicate): New function.
(read_inline_edge_summary): Use it.
(inline_read_section): Likewise.
(write_predicate): New function.
(write_inline_edge_summary): Use it.
(inline_write_summary): Likewise.
(inline_free_summary): Free alloc pool and edge summary vec.
Index: testsuite/gcc.dg/tree-ssa/inline-9.c
===
*** testsuite/gcc.dg/tree-ssa/inline-9.c(revision 0)
--- testsuite/gcc.dg/tree-ssa/inline-9.c(revision 0)
***
*** 0 
--- 1,24 
+ /* { dg-do compile } */
+ /* { dg-options "-Os -fdump-tree-optimized" } */
+ 
+ /* When optimizing for size, t should be inlined when it expands to one call 
only.  */
+ extern int q(int);
+ int t(int a)
+ {
+   if (a > 12)
+ {
+   q(a+5);
+   q(a+5);
+ }
+   else
+   q(a+10);
+ }
+ 
+ main()
+ {
+t(5);
+t(20);
+ }
+ /* { dg-final { scan-tree-dump-times "q (15)" 1 "optimized" } } */
+ /* { dg-final { scan-tree-dump-times "t (20)" 1 "optimized" } } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */
Index: ipa-inline.h
===
*** ipa-inline.h(revision 173018)
--- ipa-inline.h(working copy)
*** struct inline_edge_summary
*** 120,125 
--- 120,126 
int call_stmt_time;
/* Depth of loop nest, 0 means no nesting.  */
unsigned short int loop_depth;
+   struct predicate *predicate;
  };
  
  typedef struct inline_edge_summary inline_edge_summary_t;
Index: ipa-inline-analysis.c
===
*** ipa-inline-analysis.c   (revision 173018)
--- ipa-inline-analysis.c   (working copy)
*** along with GCC; see the file COPYING3.  
*** 85,90 
--- 85,91 
  #include "ipa-prop.h"
  #include "lto-streamer.h"
  #include "ipa-inline.h"
+ #include "alloc-pool.h"
  
  /* Estimate runtime of function can easilly run into huge numbers with many
 nested loops.  Be sure we can compute time * INLINE_SIZE_SCALE in integer.
*** VEC(inline_edge_summary_t,heap) *inline_
*** 129,134 
--- 130,137 
  VEC(int,heap) *node_growth_cache;
  VEC(edge_growth_cache_entry,heap) *edge_growth_cache;
  
+ /* Edge predicates goes here.  */
+ static alloc_pool edge_predicate_pool;
  
  /* Return true predicate (tautology).
 We represent it by empty list of clauses.  */
*** false_predicate (void)
*** 163,168 
--- 166,195 
  }
  
  
+ /* Return true if P is (false).  */
+ 
+ static inline bool
+ true_predicate_p (struct predicate *p)
+ {
+   return !p->clause[0];
+ }
+ 
+ 
+ /* Return true if P is (false).  */
+ 
+ static inline bool
+ false_predicate_p (struct predicate *p)
+ {
+   if (p->clause[0] == (1 << predicate_false_condition))
+ {
+   gcc_checking_assert (!p->clause[1]
+  && p->clause[0] == 1 << predicate_false_condition);
+   return

Re: FDO usability patch -- cfg and lineno checksum

2011-04-27 Thread Jan Hubicka
Please don't forget about changelogs..
> Index: tree.c
> ===
> --- tree.c(revision 172802)
> +++ tree.c(working copy)
> @@ -8513,14 +8513,12 @@ dump_tree_statistics (void)

The crc bits was already reviewed, right?
> -   else if (entry->checksum != checksum)
> +   else if (entry->lineno_checksum != lineno_checksum
> +|| entry->cfg_checksum != cfg_checksum)
>   {
> error ("coverage mismatch for function %u while reading execution 
> counters",
>fn_ident);
> -   error ("checksum is %x instead of %x", entry->checksum, checksum);
> +   error ("checksum is (%x,%x) instead of (%x,%x)",
> +  entry->lineno_checksum, entry->cfg_checksum,
> +  lineno_checksum, cfg_checksum);

Can't we give more informative message whether code changes or it seems to be
optimization options disprepancy?
> +unsigned
> +coverage_compute_cfg_checksum (void)
> +{
> +  basic_block bb;
> +  unsigned chksum = n_basic_blocks;
> +
> +  FOR_EACH_BB (bb)
> +{
> +  edge e;
> +  edge_iterator ei;
Perhaps also
chksum = crc32_byte (chksum, bb->index)
for cases where destination stays the same, but source of edge moves (i.e. with 
forwarder
blocks)

Patch is OK, thanks
Honza


C++ PATCH for c++/48046 (ambiguity diagnostic regression)

2011-04-27 Thread Jason Merrill
This regression was introduced by the fix for PR 35112, but it turns out 
that fixing it is a simple matter of moving one line up in a function so 
that we are committed to the tentative parse before we call 
cp_parser_lookup_name.


Tested x86_64-pc-linux-gnu, applying to trunk and 4.6.  Will also apply 
to 4.5 when unfrozen.
commit 7ef4903eff914d44d63762c603b82a007d38a2d1
Author: Jason Merrill 
Date:   Wed Apr 27 10:07:37 2011 -0400

PR c++/48046
* parser.c (cp_parser_diagnose_invalid_type_name): Commit
to tentative parse sooner.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 68ce052..89100aa 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -2440,6 +2440,7 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser,
  location_t location)
 {
   tree decl, old_scope;
+  cp_parser_commit_to_tentative_parse (parser);
   /* Try to lookup the identifier.  */
   old_scope = parser->scope;
   parser->scope = scope;
@@ -2533,7 +2534,6 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser,
   else
gcc_unreachable ();
 }
-  cp_parser_commit_to_tentative_parse (parser);
 }
 
 /* Check for a common situation where a type-name should be present,
diff --git a/gcc/testsuite/g++.dg/parse/ambig6.C 
b/gcc/testsuite/g++.dg/parse/ambig6.C
new file mode 100644
index 000..8f37fea
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/ambig6.C
@@ -0,0 +1,12 @@
+// PR c++/48046
+
+namespace N1 { typedef int   T; } // { dg-error "" }
+namespace N2 { typedef float T; } // { dg-error "" }
+
+int main()
+{
+  using namespace N1;
+  using namespace N2;
+
+  static T t;  // { dg-error "" }
+}
commit 6a5b4a16dbb00cbeb50ec100174f310cbd6f3e32
Author: Jason Merrill 
Date:   Wed Apr 27 10:13:34 2011 -0400

* class.c (resolve_address_of_overloaded_function): Don't
change OVERLOAD to TREE_LIST.
* pt.c (print_candidates_1): Remove nonsensical assert.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index fa5e00f..9af238b 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -6514,14 +6514,7 @@ resolve_address_of_overloaded_function (tree target_type,
 DECL_NAME (OVL_CURRENT (overload)),
 target_type);
 
- /* print_candidates expects a chain with the functions in
-TREE_VALUE slots, so we cons one up here (we're losing anyway,
-so why be clever?).  */
- for (; overload; overload = OVL_NEXT (overload))
-   matches = tree_cons (NULL_TREE, OVL_CURRENT (overload),
-matches);
-
- print_candidates (matches);
+ print_candidates (overload);
}
   return error_mark_node;
 }
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index de574a4..481306f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1706,7 +1706,6 @@ print_candidates_1 (tree fns, bool more, const char **str)
   for (fn = fns; fn; fn = OVL_NEXT (fn))
 if (TREE_CODE (fn) == TREE_LIST)
   {
-gcc_assert (!OVL_NEXT (fn) && !is_overloaded_fn (fn));
 for (fn2 = fn; fn2 != NULL_TREE; fn2 = TREE_CHAIN (fn2))
   print_candidates_1 (TREE_VALUE (fn2),
   TREE_CHAIN (fn2) || more, str);
@@ -1736,7 +1735,8 @@ print_candidates_1 (tree fns, bool more, const char **str)
 }
 }
 
-/* Print the list of candidate FNS in an error message.  */
+/* Print the list of candidate FNS in an error message.  FNS can also
+   be a TREE_LIST of non-functions in the case of an ambiguous lookup.  */
 
 void
 print_candidates (tree fns)
diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/overload1.C 
b/gcc/testsuite/g++.old-deja/g++.oliva/overload1.C
index 91b3b02..75c8723 100644
--- a/gcc/testsuite/g++.old-deja/g++.oliva/overload1.C
+++ b/gcc/testsuite/g++.old-deja/g++.oliva/overload1.C
@@ -6,7 +6,7 @@
 // Based on bug report by JDonner 
 
 struct foo {
-  static int bar(); // { dg-error "candidate" }
+  static int bar(); // { dg-error "foo::bar" }
   void bar(int); // { dg-error "foo::bar" }
 };
 


Re: FDO usability patch -- cfg and lineno checksum

2011-04-27 Thread Xinliang David Li
Honza, any more comments?

Thanks,

David

On Mon, Apr 25, 2011 at 9:35 AM, Xinliang David Li  wrote:
> Is the patch ok?
>
> Thanks,
>
> David
>
> On Fri, Apr 22, 2011 at 12:48 PM, Jan Hubicka  wrote:
>>> Please review the new patch which only implements cfg checksum.
>>>
>>> The auto version generation was introduced in 2002 before FDO support
>>> was added (so the old way never existed), so it might be better to
>>> make the change independent of this one.
>>
>> FDO support was there well before 2002, just with funny combination of flags.
>> (-fprofile-arcs and -fbranch-probabilities)
>> 2002 was about the time of GCOV format rewrite, but yes, lets change it 
>> independently
>> I will look into the patch ASAP.
>>
>> Honza
>>
>


Toplevel cleanup: split out libgcj disabling

2011-04-27 Thread Joseph S. Myers
Continuing the toplevel cleanups separating the cases disabling
different subdirectories - on the basis that eventually this
information should come from the subdirectories, and that as
previously discussed much of the default disabling of ${libgcj}
doesn't actually make sense - this patch separates the
Java-and-${libgcj}-disabling cases out from the rest of the
directory-disabling cases.

This patch deliberately keeps the case structure the same to make it
clear it does not change the set of disabled directories at all - thus
there are now empty cases in both the old and the new case statements.
These are intended to be cleaned up in subsequent patches.  (Removing
an empty case is not automatically obvious, since it may cause a later
case such as *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu |
*-*-kopensolaris*-gnu or *-*-* to be active instead.  In many cases
they can be removed, because the combination that would activate the
other case is not meaningful or because it doesn't matter what the
Java configuration is for targets that have been removed from or never
supported in GCC - but I prefer to keep such removals separate.)

OK to commit?

2011-04-27  Joseph Myers  

* configure.ac: Separate cases disabling Java and Java libraries
from general case over targets.
* configure: Regenerate.

Index: configure.ac
===
--- configure.ac(revision 173034)
+++ configure.ac(working copy)
@@ -558,6 +558,301 @@
 ;;
 esac
 
+# Disable Java, libgcj or related libraries for some systems.
+case "${target}" in
+  *-*-chorusos)
+;;
+  powerpc-*-darwin*)
+;;
+  i[[3456789]]86-*-darwin*)
+;;
+  x86_64-*-darwin[[912]]*)
+;;
+  *-*-darwin*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  *-*-dragonfly*)
+;;
+  *-*-freebsd*)
+# Skip some stuff that's unsupported on some FreeBSD configurations.
+case "${target}" in
+  i*86-*-*) ;;
+  alpha*-*-*) ;;
+  x86_64-*-*) ;;
+  *)
+   noconfigdirs="$noconfigdirs ${libgcj}"
+   ;;
+esac
+;;
+  *-*-kaos*)
+;;
+  *-*-netbsd*)
+# Skip some stuff that's unsupported on some NetBSD configurations.
+case "${target}" in
+  i*86-*-netbsdelf*) ;;
+  arm*-*-netbsdelf*) ;;
+  *)
+   noconfigdirs="$noconfigdirs ${libgcj}"
+   ;;
+esac
+;;
+  *-*-netware*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  *-*-rtems*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  *-*-tpf*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  *-*-uclinux*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  *-*-vxworks*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  alpha*-dec-osf*)
+;;
+  alpha*-*-*vms*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  alpha*-*-linux*)
+;;
+  alpha*-*-*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  am33_2.0-*-linux*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  sh-*-linux*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  sh*-*-pe|mips*-*-pe|*arm-wince-pe)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  arc-*-*)
+;;
+  arm-*-coff)
+;;
+  arm-*-elf* | arm*-*-eabi* )
+noconfigdirs="$noconfigdirs target-libffi"
+;;
+  arm*-*-linux-gnueabi)
+;;
+  arm*-*-symbianelf*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  arm-*-pe*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  arm-*-riscix*)
+;;
+  avr-*-*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  bfin-*-*)
+unsupported_languages="$unsupported_languages java"
+noconfigdirs="$noconfigdirs target-boehm-gc"
+;;
+  c4x-*-* | tic4x-*-*)
+;;
+  tic54x-*-*)
+;;
+  cr16-*-*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  cris-*-* | crisv32-*-*)
+unsupported_languages="$unsupported_languages java"
+case "${target}" in
+  *-*-linux*)
+   ;;
+  *) # See PR46792 regarding target-libffi.
+   noconfigdirs="$noconfigdirs target-libffi target-boehm-gc";;
+esac
+;;
+  d10v-*-*)
+;;
+  d30v-*-*)
+;;
+  fr30-*-elf*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  frv-*-*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  moxie-*-*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  h8300*-*-*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  h8500-*-*)
+;;
+  hppa1.1-*-osf* | hppa1.1-*-bsd* )
+;;
+  hppa*64*-*-linux*)
+# In this case, it's because the hppa64-linux target is for
+# the kernel only at this point and has no libc, and thus no
+# headers, crt*.o, etc., all of which are needed by these.
+noconfigdirs="$noconfigdirs target-zlib"
+;;
+  hppa*-*-linux*)
+;;
+  hppa*-*-*elf* | \
+  hppa*-*-lites* | \
+  hppa*-*-openbsd* | \
+  hppa*64*-*-*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
+  hppa*-hp-hpux11*)
+;;
+  hppa*-*-pro*)
+;;
+  hppa*-*-*)
+# According to Alexandre Oliva , libjava w

[gomp3.1] Fix #pragma omp atomic write

2011-04-27 Thread Jakub Jelinek
Hi!

#pragma omp atomic write RHS can be arbitrary expression (not mentioning
the LHS), so it is wrong to parse it just as unary expression.
Fixed thusly, tested on x86_64-linux, committed to gomp-3_1-branch.

2011-04-27  Jakub Jelinek  

* c-parser.c (c_parser_omp_atomic): Parse #pragma omp write
RHS using c_parser_expression instead of c_parser_unary_expression.

* parser.c (cp_parser_omp_atomic): Parse #pragma omp write
RHS using cp_parser_expression instead of cp_parser_unary_expression.

* testsuite/libgomp.c/atomic-13.c: New test.
* testsuite/libgomp.c++/atomic-6.C: New test.
* testsuite/libgomp.c++/atomic-7.C: New test.

--- gcc/c-parser.c.jj   2011-04-20 18:31:25.0 +0200
+++ gcc/c-parser.c  2011-04-27 17:02:46.0 +0200
@@ -9095,7 +9095,10 @@ c_parser_omp_atomic (location_t loc, c_p
   loc = c_parser_peek_token (parser)->location;
   if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
goto saw_error;
-  lhs = c_parser_unary_expression (parser).value;
+  if (code == NOP_EXPR)
+   lhs = c_parser_expression (parser).value;
+  else
+   lhs = c_parser_unary_expression (parser).value;
   lhs = c_fully_fold (lhs, false, NULL);
   if (lhs == error_mark_node)
goto saw_error;
--- gcc/cp/parser.c.jj  2011-04-26 18:55:38.0 +0200
+++ gcc/cp/parser.c 2011-04-27 17:25:06.0 +0200
@@ -24108,8 +24108,11 @@ cp_parser_omp_atomic (cp_parser *parser,
goto saw_error;
   if (!cp_parser_require (parser, CPP_EQ, RT_EQ))
goto saw_error;
-  lhs = cp_parser_unary_expression (parser, /*address_p=*/false,
-   /*cast_p=*/false, NULL);
+  if (code == NOP_EXPR)
+   lhs = cp_parser_expression (parser, /*cast_p=*/false, NULL);
+  else
+   lhs = cp_parser_unary_expression (parser, /*address_p=*/false,
+ /*cast_p=*/false, NULL);
   if (lhs == error_mark_node)
goto saw_error;
   if (code == NOP_EXPR)
--- libgomp/testsuite/libgomp.c/atomic-13.c.jj  2011-04-27 17:17:17.0 
+0200
+++ libgomp/testsuite/libgomp.c/atomic-13.c 2011-04-27 17:20:18.0 
+0200
@@ -0,0 +1,59 @@
+/* { dg-do run } */
+
+extern void abort (void);
+long long l, m;
+int i, j;
+
+void
+foo (void)
+{
+  #pragma omp atomic read
+i = l;
+  #pragma omp atomic read
+m = j;
+  if (i != 77 || m != 88)
+abort ();
+  #pragma omp atomic write
+l = 1 + i + 6 * 1;
+  #pragma omp atomic write
+j = 170 - 170 + m + 1 * 7;
+  #pragma omp atomic capture
+i = l += 4;
+  #pragma omp atomic capture
+m = j += 4;
+  if (i != 88 || m != 99)
+abort ();
+  #pragma omp atomic capture
+{
+  i = l;
+  l += 4;
+}
+  #pragma omp atomic capture
+{
+  m = j;
+  j += 4;
+}
+  if (i != 88 || m != 99)
+abort ();
+  #pragma omp atomic capture
+{
+  l += 4;
+  i = l;
+}
+  #pragma omp atomic capture
+{
+  j += 4;
+  m = j;
+}
+  if (i != 96 || m != 107)
+abort ();
+}
+
+int
+main ()
+{
+  l = 77;
+  j = 88;
+  foo ();
+  return 0;
+}
--- libgomp/testsuite/libgomp.c++/atomic-6.C.jj 2011-04-27 17:19:46.0 
+0200
+++ libgomp/testsuite/libgomp.c++/atomic-6.C2011-04-27 17:21:03.0 
+0200
@@ -0,0 +1,58 @@
+// { dg-do run }
+
+extern "C" void abort (void);
+long long l, m;
+int i, j;
+
+void
+foo (void)
+{
+  #pragma omp atomic read
+i = l;
+  #pragma omp atomic read
+m = j;
+  if (i != 77 || m != 88)
+abort ();
+  #pragma omp atomic write
+l = 1 + i + 6 * 1;
+  #pragma omp atomic write
+j = 170 - 170 + m + 1 * 7;
+  #pragma omp atomic capture
+i = l += 4;
+  #pragma omp atomic capture
+m = j += 4;
+  if (i != 88 || m != 99)
+abort ();
+  #pragma omp atomic capture
+{
+  i = l;
+  l += 4;
+}
+  #pragma omp atomic capture
+{
+  m = j;
+  j += 4;
+}
+  if (i != 88 || m != 99)
+abort ();
+  #pragma omp atomic capture
+{
+  l += 4;
+  i = l;
+}
+  #pragma omp atomic capture
+{
+  j += 4;
+  m = j;
+}
+  if (i != 96 || m != 107)
+abort ();
+}
+
+int
+main ()
+{
+  l = 77;
+  j = 88;
+  foo ();
+}
--- libgomp/testsuite/libgomp.c++/atomic-7.C.jj 2011-04-27 17:21:11.0 
+0200
+++ libgomp/testsuite/libgomp.c++/atomic-7.C2011-04-27 17:21:58.0 
+0200
@@ -0,0 +1,63 @@
+// { dg-do run }
+
+extern "C" void abort (void);
+
+template 
+void
+foo (void)
+{
+  extern S l, m;
+  extern T i, j;
+
+  #pragma omp atomic read
+i = l;
+  #pragma omp atomic read
+m = j;
+  if (i != 77 || m != 88)
+abort ();
+  #pragma omp atomic write
+l = 1 + i + 6 * 1;
+  #pragma omp atomic write
+j = 170 - 170 + m + 1 * 7;
+  #pragma omp atomic capture
+i = l += 4;
+  #pragma omp atomic capture
+m = j += 4;
+  if (i != 88 || m != 99)
+abort ();
+  #pragma omp atomic capture
+{
+  

[PATCH][4/n] Alias housekeeping

2011-04-27 Thread Richard Guenther

This moves PTA changed flag handling during solving from using
an sbitmap and an explicitly managed change_count to a bitmap.
Way easier to get right and also a requirement for pending work
that adds variables on-the-fly during solving (which would
require growing the sbitmap).

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Will apply once that succeeded.

Richard.

2011-04-27  Richard Guenther  

* tree-ssa-structalias.c (changed_count): Remove.
(changed): Use a bitmap.
(unify_nodes): Adjust.
(do_sd_constraint): Likewise.
(do_ds_constraint): Likewise.
(do_complex_constraint): Likewise.
(solve_graph): Likewise.

Index: trunk/gcc/tree-ssa-structalias.c
===
*** trunk.orig/gcc/tree-ssa-structalias.c   2011-02-03 16:59:37.0 
+0100
--- trunk/gcc/tree-ssa-structalias.c2011-02-03 17:04:44.0 +0100
*** build_succ_graph (void)
*** 1412,1419 
  
  
  /* Changed variables on the last iteration.  */
! static unsigned int changed_count;
! static sbitmap changed;
  
  /* Strongly Connected Component visitation info.  */
  
--- 1412,1418 
  
  
  /* Changed variables on the last iteration.  */
! static bitmap changed;
  
  /* Strongly Connected Component visitation info.  */
  
*** unify_nodes (constraint_graph_t graph, u
*** 1544,1559 
/* Mark TO as changed if FROM was changed. If TO was already marked
   as changed, decrease the changed count.  */
  
!   if (update_changed && TEST_BIT (changed, from))
  {
!   RESET_BIT (changed, from);
!   if (!TEST_BIT (changed, to))
!   SET_BIT (changed, to);
!   else
!   {
! gcc_assert (changed_count > 0);
! changed_count--;
!   }
  }
if (get_varinfo (from)->solution)
  {
--- 1543,1553 
/* Mark TO as changed if FROM was changed. If TO was already marked
   as changed, decrease the changed count.  */
  
!   if (update_changed
!   && bitmap_bit_p (changed, from))
  {
!   bitmap_clear_bit (changed, from);
!   bitmap_set_bit (changed, to);
  }
if (get_varinfo (from)->solution)
  {
*** unify_nodes (constraint_graph_t graph, u
*** 1562,1572 
if (bitmap_ior_into (get_varinfo (to)->solution,
   get_varinfo (from)->solution))
{
! if (update_changed && !TEST_BIT (changed, to))
!   {
! SET_BIT (changed, to);
! changed_count++;
!   }
}
  
BITMAP_FREE (get_varinfo (from)->solution);
--- 1556,1563 
if (bitmap_ior_into (get_varinfo (to)->solution,
   get_varinfo (from)->solution))
{
! if (update_changed)
!   bitmap_set_bit (changed, to);
}
  
BITMAP_FREE (get_varinfo (from)->solution);
*** done:
*** 1727,1737 
if (flag)
  {
get_varinfo (lhs)->solution = sol;
!   if (!TEST_BIT (changed, lhs))
!   {
! SET_BIT (changed, lhs);
! changed_count++;
!   }
  }
  }
  
--- 1718,1724 
if (flag)
  {
get_varinfo (lhs)->solution = sol;
!   bitmap_set_bit (changed, lhs);
  }
  }
  
*** do_ds_constraint (constraint_t c, bitmap
*** 1765,1777 
if (add_graph_edge (graph, t, rhs))
{
  if (bitmap_ior_into (get_varinfo (t)->solution, sol))
!   {
! if (!TEST_BIT (changed, t))
!   {
! SET_BIT (changed, t);
! changed_count++;
!   }
!   }
}
return;
  }
--- 1752,1758 
if (add_graph_edge (graph, t, rhs))
{
  if (bitmap_ior_into (get_varinfo (t)->solution, sol))
!   bitmap_set_bit (changed, t);
}
return;
  }
*** do_ds_constraint (constraint_t c, bitmap
*** 1811,1822 
{
  t = find (escaped_id);
  if (add_graph_edge (graph, t, rhs)
! && bitmap_ior_into (get_varinfo (t)->solution, sol)
! && !TEST_BIT (changed, t))
!   {
! SET_BIT (changed, t);
! changed_count++;
!   }
  /* Enough to let rhs escape once.  */
  escaped_p = true;
}
--- 1792,1799 
{
  t = find (escaped_id);
  if (add_graph_edge (graph, t, rhs)
! && bitmap_ior_into (get_varinfo (t)->solution, sol))
!   bitmap_set_bit (changed, t);
  /* Enough to let rhs escape once.  */
  escaped_p = true;
}
*** do_ds_constraint (constraint_t c, bitmap
*** 1826,1837 
  
  t = find (v->id);
  if (add_graph_edge (graph, 

Commit: RX: Fix some gcc testsuite failures

2011-04-27 Thread Nick Clifton
Hi Guys,

  I am applying the patch below to the mainline and 4.6 branch sources.
  It fixes a few GCC testsuite failures for the RX target, specifically:

 gcc.dg/20020312-2.c
 gcc.dg/pr28796-2.c
 gcc.dg/torture/builtin-cproj-1.c
 gcc.dg/torture/type-generic-1.c
 gcc.target/rx/pack.c

Cheers
  Nick

gcc/testsuite/ChangeLog
2011-04-27  Nick Clifton  

* gcc.dg/20020312-2.c: Add definition for RX.

* lib/target-supports.exp (add_options_for_ieee): Use -mnofpu
option with RX targets.

* gcc.target/rx/pack.c: Replace C++ style // comments with C style
/* */ comments.

Index: gcc/testsuite/gcc.target/rx/pack.c
===
--- gcc/testsuite/gcc.target/rx/pack.c  (revision 173012)
+++ gcc/testsuite/gcc.target/rx/pack.c  (working copy)
@@ -4,10 +4,10 @@
 
 typedef struct tst_2
 {
-  INT16U   f0; // [+0]
-  INT16U * f1; // [+2]
-  INT16U   f2; // [+6]
-  INT16U * f3; // [+8]
+  INT16U   f0; /* [+0] */
+  INT16U * f1; /* [+2] */
+  INT16U   f2; /* [+6] */
+  INT16U * f3; /* [+8] */
 } __attribute__ ((__packed__)) t2;
 
 #include 
Index: gcc/testsuite/lib/target-supports.exp
===
--- gcc/testsuite/lib/target-supports.exp   (revision 173012)
+++ gcc/testsuite/lib/target-supports.exp   (working copy)
@@ -3556,6 +3556,9 @@
  || [istarget "sh*-*-*"] } {
return "$flags -mieee"
 }
+if { [istarget "rx-*-*"] } {
+   return "$flags -mnofpu"
+}
 return $flags
 }
 
Index: gcc/testsuite/gcc.dg/20020312-2.c
===
--- gcc/testsuite/gcc.dg/20020312-2.c   (revision 173012)
+++ gcc/testsuite/gcc.dg/20020312-2.c   (working copy)
@@ -58,6 +58,8 @@
 # else
 #  define PIC_REG  "30"
 # endif
+#elif defined(__RX__)
+/* No pic register.  */
 #elif defined(__s390__)
 # define PIC_REG  "12"
 #elif defined(__sparc__)

  


[google][wwwdocs] Add google/gcc-x_y to svn.html

2011-04-27 Thread Diego Novillo
This patch adds the google release branches to the 'distribution
branches' section of svn.html.

Committed to wwwdocs.


Diego.

Index: htdocs/svn.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/svn.html,v
retrieving revision 1.160
diff -u -d -u -p -r1.160 svn.html
--- htdocs/svn.html 4 Apr 2011 13:32:33 -   1.160
+++ htdocs/svn.html 27 Apr 2011 14:46:24 -
@@ -551,6 +551,12 @@ be prefixed with the initials of the dis
   Diego Novillo mailto:dnovi...@google.com";>dnovi...@google.com.
   
 
+  google/gcc-x_y
+  Google compilers based on GCC x.y releases.  This family of
+  branches is maintained by Diego Novillo
+  mailto:dnovi...@google.com";>dnovi...@google.com.
+  
+
   ibm/gcc-4_1-branch
   This branch provides decimal float support backported to GCC 4.1.x.
   It is expected to be used primarily within IBM for PowerPC-64 GNU/Linux.


[PATCH] Fortran support for OpenMP 3.1 atomics

2011-04-27 Thread Jakub Jelinek
Hi!

This patch adds Fortran support for OpenMP 3.1 atomics.
Tested on x86_64-linux, committed to gomp-3_1-branch.

2011-04-27  Jakub Jelinek  

* gfortran.h (gfc_statement): Add ST_OMP_END_ATOMIC.
(gfc_omp_atomic_op): New enum typedef.
(struct gfc_code): Add ext.omp_atomic.
* parse.c (decode_omp_directive): Handle !$omp end atomic.
(parse_omp_atomic): Return gfc_statement instead of void.
For !$omp atomic capture parse two assignments instead of
just one and require !$omp end atomic afterwards, for
other !$omp atomic forms just allow !$omp end atomic at the
end.
(parse_omp_structured_block, parse_executable): Adjust
parse_omp_atomic callers.
* openmp.c (gfc_match_omp_atomic): Match optional
read/write/update/capture keywords after !$omp atomic.
(resolve_omp_atomic): Handle all OpenMP 3.1 atomic forms.
* trans-openmp.c (gfc_trans_omp_atomic): Likewise.

* gfortran.dg/gomp/omp_atomic2.f90: New test.

* testsuite/libgomp.fortran/omp_atomic3.f90: New test.
* testsuite/libgomp.fortran/omp_atomic4.f90: New test.

--- gcc/fortran/gfortran.h.jj   2011-02-24 14:19:08.0 +0100
+++ gcc/fortran/gfortran.h  2011-04-27 10:35:24.0 +0200
@@ -200,9 +200,9 @@ typedef enum
   ST_WRITE, ST_ASSIGNMENT, ST_POINTER_ASSIGNMENT, ST_SELECT_CASE, ST_SEQUENCE,
   ST_SIMPLE_IF, ST_STATEMENT_FUNCTION, ST_DERIVED_DECL, ST_LABEL_ASSIGNMENT,
   ST_ENUM, ST_ENUMERATOR, ST_END_ENUM, ST_SELECT_TYPE, ST_TYPE_IS, ST_CLASS_IS,
-  ST_OMP_ATOMIC, ST_OMP_BARRIER, ST_OMP_CRITICAL, ST_OMP_END_CRITICAL,
-  ST_OMP_END_DO, ST_OMP_END_MASTER, ST_OMP_END_ORDERED, ST_OMP_END_PARALLEL,
-  ST_OMP_END_PARALLEL_DO, ST_OMP_END_PARALLEL_SECTIONS,
+  ST_OMP_ATOMIC, ST_OMP_BARRIER, ST_OMP_CRITICAL, ST_OMP_END_ATOMIC,
+  ST_OMP_END_CRITICAL, ST_OMP_END_DO, ST_OMP_END_MASTER, ST_OMP_END_ORDERED,
+  ST_OMP_END_PARALLEL, ST_OMP_END_PARALLEL_DO, ST_OMP_END_PARALLEL_SECTIONS,
   ST_OMP_END_PARALLEL_WORKSHARE, ST_OMP_END_SECTIONS, ST_OMP_END_SINGLE,
   ST_OMP_END_WORKSHARE, ST_OMP_DO, ST_OMP_FLUSH, ST_OMP_MASTER, ST_OMP_ORDERED,
   ST_OMP_PARALLEL, ST_OMP_PARALLEL_DO, ST_OMP_PARALLEL_SECTIONS,
@@ -2064,6 +2064,15 @@ typedef enum
 }
 gfc_exec_op;
 
+typedef enum
+{
+  GFC_OMP_ATOMIC_UPDATE,
+  GFC_OMP_ATOMIC_READ,
+  GFC_OMP_ATOMIC_WRITE,
+  GFC_OMP_ATOMIC_CAPTURE
+}
+gfc_omp_atomic_op;
+
 typedef struct gfc_code
 {
   gfc_exec_op op;
@@ -2114,6 +2123,7 @@ typedef struct gfc_code
 const char *omp_name;
 gfc_namelist *omp_namelist;
 bool omp_bool;
+gfc_omp_atomic_op omp_atomic;
   }
   ext; /* Points to additional structures required by statement */
 
--- gcc/fortran/openmp.c.jj 2011-04-20 11:19:18.0 +0200
+++ gcc/fortran/openmp.c2011-04-27 15:42:04.0 +0200
@@ -700,13 +700,22 @@ gfc_match_omp_ordered (void)
 match
 gfc_match_omp_atomic (void)
 {
+  gfc_omp_atomic_op op = GFC_OMP_ATOMIC_UPDATE;
+  if (gfc_match ("% update") == MATCH_YES)
+op = GFC_OMP_ATOMIC_UPDATE;
+  else if (gfc_match ("% read") == MATCH_YES)
+op = GFC_OMP_ATOMIC_READ;
+  else if (gfc_match ("% write") == MATCH_YES)
+op = GFC_OMP_ATOMIC_WRITE;
+  else if (gfc_match ("% capture") == MATCH_YES)
+op = GFC_OMP_ATOMIC_CAPTURE;
   if (gfc_match_omp_eos () != MATCH_YES)
 {
   gfc_error ("Unexpected junk after $OMP ATOMIC statement at %C");
   return MATCH_ERROR;
 }
   new_st.op = EXEC_OMP_ATOMIC;
-  new_st.ext.omp_clauses = NULL;
+  new_st.ext.omp_atomic = op;
   return MATCH_YES;
 }
 
@@ -1100,12 +1109,18 @@ is_conversion (gfc_expr *expr, bool wide
 static void
 resolve_omp_atomic (gfc_code *code)
 {
+  gfc_code *atomic_code = code;
   gfc_symbol *var;
-  gfc_expr *expr2;
+  gfc_expr *expr2, *expr2_tmp;
 
   code = code->block->next;
   gcc_assert (code->op == EXEC_ASSIGN);
-  gcc_assert (code->next == NULL);
+  gcc_assert ((atomic_code->ext.omp_atomic != GFC_OMP_ATOMIC_CAPTURE
+  && code->next == NULL)
+ || (atomic_code->ext.omp_atomic == GFC_OMP_ATOMIC_CAPTURE
+ && code->next != NULL
+ && code->next->op == EXEC_ASSIGN
+ && code->next->next == NULL));
 
   if (code->expr1->expr_type != EXPR_VARIABLE
   || code->expr1->symtree == NULL
@@ -1123,7 +1138,86 @@ resolve_omp_atomic (gfc_code *code)
   var = code->expr1->symtree->n.sym;
   expr2 = is_conversion (code->expr2, false);
   if (expr2 == NULL)
-expr2 = code->expr2;
+{
+  if (atomic_code->ext.omp_atomic == GFC_OMP_ATOMIC_READ
+ || atomic_code->ext.omp_atomic == GFC_OMP_ATOMIC_WRITE)
+   expr2 = is_conversion (code->expr2, true);
+  if (expr2 == NULL)
+   expr2 = code->expr2;
+}
+
+  switch (atomic_code->ext.omp_atomic)
+{
+case GFC_OMP_ATOMIC_READ:
+  if (expr2->expr_type != EXPR_VARIABLE
+ || expr2->symtree == NULL
+ || expr2->rank != 0
+ || (expr2->ts.type != BT_INT

Re: [RFC] Context sensitive inline analysis

2011-04-27 Thread Jan Hubicka
> 
> This may have caused:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48791

Oops, yes, it is mine.  The insertion hook at expansion time is incorrectly 
called 
after function is expanded, not before.  
ipa-prop should deregister itself earlier, but that can be done incrementally.
I am testing the following and will commit if testing succeeds.

Index: cgraphunit.c
===
--- cgraphunit.c(revision 173025)
+++ cgraphunit.c(working copy)
@@ -233,6 +233,7 @@ cgraph_process_new_functions (void)
  cgraph_finalize_function (fndecl, false);
  cgraph_mark_reachable_node (node);
  output = true;
+  cgraph_call_function_insertion_hooks (node);
  break;
 
case CGRAPH_STATE_IPA:
@@ -258,12 +259,14 @@ cgraph_process_new_functions (void)
  free_dominance_info (CDI_DOMINATORS);
  pop_cfun ();
  current_function_decl = NULL;
+  cgraph_call_function_insertion_hooks (node);
  break;
 
case CGRAPH_STATE_EXPANSION:
  /* Functions created during expansion shall be compiled
 directly.  */
  node->process = 0;
+  cgraph_call_function_insertion_hooks (node);
  cgraph_expand_function (node);
  break;
 
@@ -271,7 +274,6 @@ cgraph_process_new_functions (void)
  gcc_unreachable ();
  break;
}
-  cgraph_call_function_insertion_hooks (node);
   varpool_analyze_pending_decls ();
 }
   return output;


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

2011-04-27 Thread Mike Stump
Ping?

On Apr 22, 2011, at 3:01 PM, Mike Stump wrote:
> On Apr 22, 2011, at 3:28 AM, Eric Botcazou wrote:
>>> This patch fixes up hot/cold partitioning on ports that don't have long
>>> conditional branches.  I'll note that the entire file has lots of other
>>> jump optimizations that are suspect.
>> 
>> Do you have a testcase for one of the ports in the tree?
> 
> Nope.  Found via an out of tree port with tree-prof.exp=pr34999.c.
> 
>> Note that parameters of function must be documented in the head comment.
> 
> Fixed.
> 
>> The patch contains long lines.
> 
> Didn't know we had switched over to caring that much.  Want me to fix all of 
> gcc/*.[ch]?
> 
>> The ChangeLog entry doesn't look correct (relax_delay_slots mentioned 
>> twice, no mention of the new parameter of follow_jumps, etc).
> 
> Fixed.
> 
>> How was the patch tested?
> 
> make check-gcc.
> 
>> Please generate patches with diff -p.
> 
> Done.
> 
> 
> Ok?


2011-04-21  Mike Stump  

* reorg.c (relax_delay_slots): Don't delete a jump that
crosses a section boundary.  Pass insn to follow_jumps.
(follow_jumps): Add jump parameter.  Don't replace a short
conditional jump with a long conditional jump when the port
doesn't have long conditional jumps.
(fill_slots_from_thread): Pass insn to follow_jumps.

Index: reorg.c
===
--- reorg.c (revision 1301)
+++ reorg.c (working copy)
@@ -2501,15 +2501,18 @@ fill_simple_delay_slots (int non_jumps_p
 #endif
 }
 
-/* Follow any unconditional jump at LABEL;
-   return the ultimate label reached by any such chain of jumps.
-   Return null if the chain ultimately leads to a return instruction.
-   If LABEL is not followed by a jump, return LABEL.
-   If the chain loops or we can't find end, return LABEL,
-   since that tells caller to avoid changing the insn.  */
+/* Follow any unconditional jump at LABEL; return the ultimate label
+   reached by any such chain of jumps.  Return null if the chain
+   ultimately leads to a return instruction.  If LABEL is not followed
+   by a jump, return LABEL.  If the chain loops or we can't find end,
+   return LABEL, since that tells caller to avoid changing the insn.
+   If the chain of jumps ever crosses a section boundary, and the port
+   doesn't have long condition branches and the JUMP that we are
+   performing this analysis for was a conditional branch, return the
+   first such label before any such crossing.  */
 
 static rtx
-follow_jumps (rtx label)
+follow_jumps (rtx label, rtx jump)
 {
   rtx insn;
   rtx next;
@@ -2529,6 +2532,16 @@ follow_jumps (rtx label)
 {
   rtx tem;
 
+  /* If a label crosses a section boundary and we're thinking
+about changing a conditional jump to be a conditional jump
+across that boundary, don't do it if the port doesn't have
+long conditional branches.  We can however jump to the label
+just before we cross such a boundary.  */
+  if (!HAS_LONG_COND_BRANCH
+ && find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)
+ && any_condjump_p (jump))
+   return value;
+
   /* If we have found a cycle, make the insn jump to itself.  */
   if (JUMP_LABEL (insn) == label)
return label;
@@ -2991,7 +3004,7 @@ fill_slots_from_thread (rtx insn, rtx co
  && redirect_with_delay_list_safe_p (insn,
  JUMP_LABEL (new_thread),
  delay_list))
-   new_thread = follow_jumps (JUMP_LABEL (new_thread));
+   new_thread = follow_jumps (JUMP_LABEL (new_thread), new_thread);
 
   if (new_thread == 0)
label = find_end_label ();
@@ -3342,12 +3355,14 @@ relax_delay_slots (rtx first)
  && (condjump_p (insn) || condjump_in_parallel_p (insn))
  && (target_label = JUMP_LABEL (insn)) != 0)
{
- target_label = skip_consecutive_labels (follow_jumps (target_label));
+ target_label = skip_consecutive_labels (follow_jumps (target_label,
+   insn));
  if (target_label == 0)
target_label = find_end_label ();
 
  if (target_label && next_active_insn (target_label) == next
- && ! condjump_in_parallel_p (insn))
+ && ! condjump_in_parallel_p (insn)
+ && find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX) == NULL_RTX)
{
  delete_jump (insn);
  continue;
@@ -3492,7 +3507,8 @@ relax_delay_slots (rtx first)
{
  /* If this jump goes to another unconditional jump, thread it, but
 don't convert a jump into a RETURN here.  */
- trial = skip_consecutive_labels (follow_jumps (target_label));
+ trial = skip_consecutive_labels (follow_jumps (target_label,
+delay_insn));
  if (trial

Re: (build) Patch to fix cp/cfns.gperf building issues

2011-04-27 Thread Mike Stump
On Apr 22, 2011, at 3:54 PM, Mike Stump wrote:
> On Apr 22, 2011, at 8:12 AM, Nicola Pero wrote:
>> This patch fixes a building annoyance that I had when building on a new
>> machine (an x86_64 gnu/linux box).
>> 
>> The building failed.  It was down to two problems:
>> 
>> * due to how I got a copy of the GCC source code on the machine, the 
>> timestamp
>> of each source file was the timestamp of when it was copied to the machine 
>> (ie,
>> a random timestamp from the point of view of the building system).  This 
>> caused
>> the build system to decide that $(srcdir)/cp/cfns.h needed to be rebuilt from
>> $(srcdir)/cp/cfns.gperf (it didn't, obviously; the source code was trunk with
>> no changes).

> Ok?

Ping?


2011-04-22  Mike Stump  

* Make-lang.in: Only run gperf in maintainer mode.

Index: cp/Make-lang.in
===
--- cp/Make-lang.in (revision 172670)
+++ cp/Make-lang.in (working copy)
@@ -105,7 +105,10 @@ cc1plus$(exeext): $(CXX_OBJS) cc1plus-ch
  $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
 # Special build rules.
+ifneq ($(MAINT),)
 $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
+endif
+$(srcdir)/cp/cfns.h:
gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
$(srcdir)/cp/cfns.gperf > $(srcdir)/cp/cfns.h
 


[PATCH, i386]: Remove avx_{vpermilp,vperm2f128}_*_operand predicates

2011-04-27 Thread Uros Bizjak
Hello!

Mode can't be passed to match_parallel predicates, so instead of
calling avx_{vpermilp,vperm2f128}_parallel functions via predicates,
we can call them from insn condition directly.

2011-04-27  Uros Bizjak  

* config/i386/predicates.md (avx_vpermilp_*_operand): Remove.
(avx_vperm2f128_*_operand): Ditto.
* config/i386/sse.md (*avx_vpermilp): Remove operand2 predicate.
Use avx_vpermilp_parallel in insn condition.
(*avx_vperm2f128_nozero): Remove operand3 predicate.
Use avx_vperm2f128_parallel in insn condition.

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

Uros.
Index: config/i386/predicates.md
===
--- config/i386/predicates.md   (revision 173023)
+++ config/i386/predicates.md   (working copy)
@@ -1179,41 +1179,6 @@
   return true;
 })
 
-;; Return true if OP is a parallel for a vpermilp[ds] permute.
-;; ??? It would be much easier if the PARALLEL for a VEC_SELECT
-;; had a mode, but it doesn't.  So we have 4 copies and install
-;; the mode by hand.
-
-(define_predicate "avx_vpermilp_v8sf_operand"
-  (and (match_code "parallel")
-   (match_test "avx_vpermilp_parallel (op, V8SFmode)")))
-
-(define_predicate "avx_vpermilp_v4df_operand"
-  (and (match_code "parallel")
-   (match_test "avx_vpermilp_parallel (op, V4DFmode)")))
-
-(define_predicate "avx_vpermilp_v4sf_operand"
-  (and (match_code "parallel")
-   (match_test "avx_vpermilp_parallel (op, V4SFmode)")))
-
-(define_predicate "avx_vpermilp_v2df_operand"
-  (and (match_code "parallel")
-   (match_test "avx_vpermilp_parallel (op, V2DFmode)")))
-
-;; Return true if OP is a parallel for a vperm2f128 permute.
-
-(define_predicate "avx_vperm2f128_v8sf_operand"
-  (and (match_code "parallel")
-   (match_test "avx_vperm2f128_parallel (op, V8SFmode)")))
-
-(define_predicate "avx_vperm2f128_v8si_operand"
-  (and (match_code "parallel")
-   (match_test "avx_vperm2f128_parallel (op, V8SImode)")))
-
-(define_predicate "avx_vperm2f128_v4df_operand"
-  (and (match_code "parallel")
-   (match_test "avx_vperm2f128_parallel (op, V4DFmode)")))
-
 ;; Return true if OP is a parallel for a vbroadcast permute.
 
 (define_predicate "avx_vbroadcast_operand"
Index: config/i386/sse.md
===
--- config/i386/sse.md  (revision 173023)
+++ config/i386/sse.md  (working copy)
@@ -10055,9 +10055,10 @@
   [(set (match_operand:AVXMODEF2P 0 "register_operand" "=x")
(vec_select:AVXMODEF2P
  (match_operand:AVXMODEF2P 1 "nonimmediate_operand" "xm")
- (match_parallel 2 "avx_vpermilp__operand"
+ (match_parallel 2 ""
[(match_operand 3 "const_int_operand" "")])))]
-  "TARGET_AVX"
+  "TARGET_AVX
+   && avx_vpermilp_parallel (operands[2], mode)"
 {
   int mask = avx_vpermilp_parallel (operands[2], mode) - 1;
   operands[2] = GEN_INT (mask);
@@ -10140,9 +10141,10 @@
  (vec_concat:
(match_operand:AVX256MODE2P 1 "register_operand" "x")
(match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm"))
- (match_parallel 3 "avx_vperm2f128__operand"
+ (match_parallel 3 ""
[(match_operand 4 "const_int_operand" "")])))]
-  "TARGET_AVX"
+  "TARGET_AVX
+   && avx_vperm2f128_parallel (operands[3], mode)"
 {
   int mask = avx_vperm2f128_parallel (operands[3], mode) - 1;
   operands[3] = GEN_INT (mask);


[PATCH][3/n] Alias housekeeping

2011-04-27 Thread Richard Guenther

As preparation for a fix for PR48764 this removes the need for PTA
to allocate and preserve new decls.  We still need to allocate
UIDs from the decl namespace to have something to point to from
points-to sets, but that can be done with allocating them directly.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-04-27  Richard Guenther  

* Makefile.in (tree-ssa-structalias.o): Remove
gt-tree-ssa-structalias.h dependency.
(GTFILES): Remove tree-ssa-structalias.c.
* tree.c (allocate_decl_uid): New function.
(make_node_stat): Use it.
(copy_node_stat): Likewise.
* tree.h (allocate_decl_uid): Declare.
* tree-ssa-alias.h (delete_alias_heapvars): Remove.
* tree-ssa.c (delete_tree_ssa): Do not call delete_alias_heapvars.
* tree-flow.h (struct var_ann_d): Remove is_heapvar flag.
* tree-ssa-live.c (remove_unused_locals): Do not check is_heapvar
flag.
* tree-ssa-structalias.c (heapvar_for_stmt): Remove.
(struct heapvar_map): Likewise.
(heapvar_map_eq, heapvar_map_hash, heapvar_lookup,
heapvar_insert): Likewise.
(make_heapvar_for): Rename to ...
(make_heapvar): ... this.  Simplify.
(fake_var_decl_obstack): New global var.
(build_fake_var_decl): New function.
(make_constraint_from_heapvar): Adjust.
(handle_lhs_call): Likewise.
(create_function_info_for): Likewise.
(intra_create_variable_infos): Likewise.
(init_alias_vars): Allocate fake_var_decl_obstack.
(init_alias_heapvars, delete_alias_heapvars): Remove.
(compute_points_to_sets): Do not call init_alias_heapvars.
(ipa_pta_execute): Likewise.
(delete_points_to_sets): Free fake_var_decl_obstack.

* gcc.dg/tree-ssa/pr23382.c: Remove.

Index: gcc/Makefile.in
===
*** gcc/Makefile.in (revision 173018)
--- gcc/Makefile.in (working copy)
*** tree-ssa-structalias.o: tree-ssa-structa
*** 2381,2387 
 $(DIAGNOSTIC_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) \
 $(GIMPLE_H) $(HASHTAB_H) $(FUNCTION_H) $(CGRAPH_H) \
 $(TREE_PASS_H) $(TIMEVAR_H) alloc-pool.h $(SPLAY_TREE_H) $(PARAMS_H) \
!gt-tree-ssa-structalias.h $(CGRAPH_H) $(ALIAS_H) pointer-set.h
  tree-ssa-uninit.o : tree-ssa-uninit.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
 $(TREE_H) $(TM_P_H) $(EXPR_H) output.h $(DIAGNOSTIC_H) \
 $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \
--- 2381,2387 
 $(DIAGNOSTIC_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) \
 $(GIMPLE_H) $(HASHTAB_H) $(FUNCTION_H) $(CGRAPH_H) \
 $(TREE_PASS_H) $(TIMEVAR_H) alloc-pool.h $(SPLAY_TREE_H) $(PARAMS_H) \
!$(CGRAPH_H) $(ALIAS_H) pointer-set.h
  tree-ssa-uninit.o : tree-ssa-uninit.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
 $(TREE_H) $(TM_P_H) $(EXPR_H) output.h $(DIAGNOSTIC_H) \
 $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \
*** GTFILES = $(CPP_ID_DATA_H) $(srcdir)/inp
*** 3776,3782 
$(srcdir)/targhooks.c $(out_file) $(srcdir)/passes.c $(srcdir)/cgraphunit.c 
\
$(srcdir)/tree-ssa-propagate.c \
$(srcdir)/tree-phinodes.c \
-   $(srcdir)/tree-ssa-structalias.c \
$(srcdir)/lto-symtab.c \
$(srcdir)/tree-ssa-alias.h \
$(srcdir)/ipa-prop.h \
--- 3776,3781 
Index: gcc/tree.c
===
*** gcc/tree.c  (revision 173018)
--- gcc/tree.c  (working copy)
*** record_node_allocation_statistics (enum
*** 814,819 
--- 814,827 
  #endif
  }
  
+ /* Allocate and return a new UID from the DECL_UID namespace.  */
+ 
+ int
+ allocate_decl_uid (void)
+ {
+   return next_decl_uid++;
+ }
+ 
  /* Return a newly allocated node of code CODE.  For decl and type
 nodes, some other fields are initialized.  The rest of the node is
 initialized to zero.  This function cannot be used for TREE_VEC or
*** make_node_stat (enum tree_code code MEM_
*** 857,863 
DECL_UID (t) = --next_debug_decl_uid;
else
{
! DECL_UID (t) = next_decl_uid++;
  SET_DECL_PT_UID (t, -1);
}
if (TREE_CODE (t) == LABEL_DECL)
--- 865,871 
DECL_UID (t) = --next_debug_decl_uid;
else
{
! DECL_UID (t) = allocate_decl_uid ();
  SET_DECL_PT_UID (t, -1);
}
if (TREE_CODE (t) == LABEL_DECL)
*** copy_node_stat (tree node MEM_STAT_DECL)
*** 942,948 
DECL_UID (t) = --next_debug_decl_uid;
else
{
! DECL_UID (t) = next_decl_uid++;
  if (DECL_PT_UID_SET_P (node))
SET_DECL_PT_UID (t, DECL_PT_UID (node));
}
--- 950,956 
DECL_UID (t) = --next_debug_decl_uid;
else
{
! DECL_UID (t) = allocate_decl_uid ();
  if (DECL_PT_UID_SET_P (node))
SET_

Re: [RFC] Context sensitive inline analysis

2011-04-27 Thread H.J. Lu
On Wed, Apr 27, 2011 at 5:16 AM, Jan Hubicka  wrote:
> Hi,
> I don't really have testcase for the HP nor AIX ICE, however I can reproduce 
> same ICE when I hack x86 to
> not use ctors/dtors.  This patch fixes it - the problem is that ipa-prop 
> ignore newly added functions
> (the global ctor built) while ipa-inline not and ipa-inline does use ipa-prop 
> for its analysis.
> Fixed by adding the corresponding hook to ipa-prop, regstested&bootstrapped 
> x86_64-linux with the
> hack and comitted.  Let me know if it fixes your problem or not.
>
> Honza
>
>        * ipa-prop.c (function_insertion_hook_holder): New holder.
>        (ipa_add_new_function): New function.
>        (ipa_register_cgraph_hooks, ipa_unregister_cgraph_hooks): 
> Register/deregister
>        holder.

This may have caused:

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


-- 
H.J.


Re: [build, lto] Only accept -fuse-linker-plugin if linker supports -plugin (PR lto/46944)

2011-04-27 Thread Rainer Orth
Hello Ralf,

> * Rainer Orth wrote on Tue, Apr 26, 2011 at 05:28:19PM CEST:
>> it's been a week since I answered your questions on this patch.  Could
>> you please have a look?
>
> Sorry for the delay.  I'm practically AFK until the weekend or maybe
> next weekend, whenever I have connectivity again after relocating;
> if another build maintainer could take a look that would be nice,
> otherwise I will get to it ASAP.

no worries.  I just wanted to make sure that the patch doesn't fall
through the cracks.  If another build maintainer could have a look, that
would be great, otherwise I can easily wait another week or two.

Thanks.
Rainer

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


[patch, spu] Fix sched_emit_insn after scheduler changes

2011-04-27 Thread Ulrich Weigand
Hello,

since recent changes to haifa-sched.c, the SPU back-end runs into
internal errors due to its use of the sched_emit_insn routine to
emit instruction prefetch instructions during final scheduling.

Now that scheduled instructions aren't placed into the instruction
stream directly, sched_emit_insn needs to change as well.  The
patch below emits the instruction before nonscheduled_insns_begin
(so that it isn't considered for future scheduling), and adds it
to scheduled_insns so that it will be placed into the output
instruction stream at the correct location.

The patch also adds calls to the add_remove_insn and begin_schedule_ready
callbacks to make sure the back-end accounting stays up to date.

This patch gets the SPU target back to build its run-time libraries
without internal errors.

Tested on spu-elf.   OK for mainline?

Bye,
Ulrich


ChangeLog:

* haifa-sched.c (sched_emit_insn): Emit insn before first
non-scheduled insn.  Inform back-end about new insn.  Add
new insn to scheduled_insns list.

Index: gcc/haifa-sched.c
===
*** gcc/haifa-sched.c   (revision 172953)
--- gcc/haifa-sched.c   (working copy)
*** sched_create_empty_bb_1 (basic_block aft
*** 5654,5662 
  rtx
  sched_emit_insn (rtx pat)
  {
!   rtx insn = emit_insn_after (pat, last_scheduled_insn);
!   last_scheduled_insn = insn;
haifa_init_insn (insn);
return insn;
  }
  
--- 5654,5669 
  rtx
  sched_emit_insn (rtx pat)
  {
!   rtx insn = emit_insn_before (pat, nonscheduled_insns_begin);
haifa_init_insn (insn);
+ 
+   if (current_sched_info->add_remove_insn)
+ current_sched_info->add_remove_insn (insn, 0);
+ 
+   (*current_sched_info->begin_schedule_ready) (insn);
+   VEC_safe_push (rtx, heap, scheduled_insns, insn);
+ 
+   last_scheduled_insn = insn;
return insn;
  }
  
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com


[commit, spu] Fix aliasing violation in SPU libgcc

2011-04-27 Thread Ulrich Weigand
Hello,

the SPU __multi3 and __udivmodti4 routines were using code that violates
the aliasing rules for type-punning between TImode and vector types.

This now causes errors when building those files.  The patch below
replaces this code by type-punning via unions.

Tested on spu-elf, committed to mainline.

Bye,
Ulrich


ChangeLog:

* config/spu/divmovti4.c (union qword_UTItype): New data type.
(si_from_UTItype, si_to_UTItype): New functions.
(__udivmodti4): Use them to implement type-punning.
* config/spu/multi3.c (union qword_TItype): New data type.
(si_from_TItype, si_to_TItype): New functions.
(__multi3): Use them to implement type-punning.

Index: gcc/config/spu/divmodti4.c
===
*** gcc/config/spu/divmodti4.c  (revision 172953)
--- gcc/config/spu/divmodti4.c  (working copy)
*** UTItype __udivti3 (UTItype u, UTItype v)
*** 29,34 
--- 29,56 
  UTItype __umodti3 (UTItype u, UTItype v);
  UTItype __udivmodti4 (UTItype u, UTItype v, UTItype *w);
  
+ union qword_UTItype
+   {
+ qword q;
+ UTItype t;
+   };
+   
+ inline static qword
+ si_from_UTItype (UTItype t)
+ { 
+   union qword_UTItype u;
+   u.t = t;
+   return u.q;
+ }
+ 
+ inline static UTItype
+ si_to_UTItype (qword q)
+ { 
+   union qword_UTItype u;
+   u.q = q;
+   return u.t;
+ }
+ 
  inline static unsigned int
  count_leading_zeros (UTItype x)
  {
*** __udivmodti4 (UTItype num, UTItype den, 
*** 67,74 
  {
qword shift =
  si_from_uint (count_leading_zeros (den) - count_leading_zeros (num));
!   qword n0 = *(qword *) & num;
!   qword d0 = *(qword *) & den;
qword bit = si_andi (si_fsmbi (1), 1);
qword r0 = si_il (0);
qword m1 = si_fsmbi (0x000f);
--- 89,96 
  {
qword shift =
  si_from_uint (count_leading_zeros (den) - count_leading_zeros (num));
!   qword n0 = si_from_UTItype (num);
!   qword d0 = si_from_UTItype (den);
qword bit = si_andi (si_fsmbi (1), 1);
qword r0 = si_il (0);
qword m1 = si_fsmbi (0x000f);
*** __udivmodti4 (UTItype num, UTItype den, 
*** 101,108 
  }
while (si_to_uint (si_orx (bit)));
if (rp)
! *rp = *(UTItype *) & n0;
!   return *(UTItype *) & r0;
  }
  
  UTItype
--- 123,130 
  }
while (si_to_uint (si_orx (bit)));
if (rp)
! *rp = si_to_UTItype (n0);
!   return si_to_UTItype (r0);
  }
  
  UTItype
Index: gcc/config/spu/multi3.c
===
*** gcc/config/spu/multi3.c (revision 172953)
--- gcc/config/spu/multi3.c (working copy)
***
*** 23,28 
--- 23,50 
  
  typedef int TItype __attribute__ ((mode (TI)));
  
+ union qword_TItype
+   {
+ qword q;
+ TItype t;
+   };
+   
+ inline static qword
+ si_from_TItype (TItype t)
+ { 
+   union qword_TItype u;
+   u.t = t;
+   return u.q;
+ }
+ 
+ inline static TItype
+ si_to_TItype (qword q)
+ { 
+   union qword_TItype u;
+   u.q = q;
+   return u.t;
+ }
+ 
  /* A straight forward vectorization and unrolling of
   *   short l[8], r[8];
   *   TItype total = 0;
*** typedef int TItype __attribute__ ((mode 
*** 33,40 
  TItype
  __multi3 (TItype l, TItype r)
  {
!   qword u = *(qword *) & l;
!   qword v = *(qword *) & r;
qword splat0 = si_shufb (v, v, si_ilh (0x0001));
qword splat1 = si_shufb (v, v, si_ilh (0x0203));
qword splat2 = si_shufb (v, v, si_ilh (0x0405));
--- 55,62 
  TItype
  __multi3 (TItype l, TItype r)
  {
!   qword u = si_from_TItype (l);
!   qword v = si_from_TItype (r);
qword splat0 = si_shufb (v, v, si_ilh (0x0001));
qword splat1 = si_shufb (v, v, si_ilh (0x0203));
qword splat2 = si_shufb (v, v, si_ilh (0x0405));
*** __multi3 (TItype l, TItype r)
*** 93,97 
total = si_cgx (total10, carry, total);
total = si_shlqbyi (total, 4);
total = si_addx (total10, carry, total);
!   return *(TItype *) & total;
  }
--- 115,119 
total = si_cgx (total10, carry, total);
total = si_shlqbyi (total, 4);
total = si_addx (total10, carry, total);
!   return si_to_TItype (total);
  }
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com


[commit, spu] Fix internal error due to spu_emit_epilogue

2011-04-27 Thread Ulrich Weigand
Hello,

spu_expand_epilogue used to emit a barrier after the return jump; this seems
to confuse the CFG layer after some recent changes, causing internal errors.
Since other backends don't emit a barrier here either, I've removed this
from the SPU backend as well.

Tested on spu-elf, committed to mainline.

Bye,
Ulrich


ChangeLog:

* config/spu/spu.c (spu_expand_epilogue): Do not emit barrier.

Index: gcc/config/spu/spu.c
===
*** gcc/config/spu/spu.c(revision 172953)
--- gcc/config/spu/spu.c(working copy)
*** spu_expand_epilogue (bool sibcall_p)
*** 2107,2113 
int size = get_frame_size (), offset, regno;
HOST_WIDE_INT saved_regs_size, total_size;
rtx sp_reg = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
!   rtx jump, scratch_reg_0;
  
if (spu_naked_function_p (current_function_decl))
  return;
--- 2107,2113 
int size = get_frame_size (), offset, regno;
HOST_WIDE_INT saved_regs_size, total_size;
rtx sp_reg = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
!   rtx scratch_reg_0;
  
if (spu_naked_function_p (current_function_decl))
  return;
*** spu_expand_epilogue (bool sibcall_p)
*** 2149,2158 
if (!sibcall_p)
  {
emit_use (gen_rtx_REG (SImode, LINK_REGISTER_REGNUM));
!   jump = emit_jump_insn (gen__return ());
!   emit_barrier_after (jump);
  }
- 
  }
  
  rtx
--- 2149,2156 
if (!sibcall_p)
  {
emit_use (gen_rtx_REG (SImode, LINK_REGISTER_REGNUM));
!   emit_jump_insn (gen__return ());
  }
  }
  
  rtx
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com


Re: [PATCH] make Ada runtime function building use build_function_type_list

2011-04-27 Thread Nathan Froyd
On Wed, Apr 20, 2011 at 10:08:21AM -0700, Nathan Froyd wrote:
> This patch changes most of the uses of build_function_type in the Ada to
> use build_function_type_list.  There are a handful of
> build_function_type calls left; replacing those will have to wait until
> we get a build_function_type_{n,vec} interface.
> 
> Tested on x86_64-unknown-linux-gnu.  OK to commit?

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

-Nathan


Re: IVOPT improvement patch

2011-04-27 Thread H.J. Lu
On Thu, Jul 29, 2010 at 7:14 AM, H.J. Lu  wrote:
> On Wed, Jul 28, 2010 at 8:50 PM, H.J. Lu  wrote:
>> On Wed, Jul 28, 2010 at 6:07 PM, H.J. Lu  wrote:
>>> On Tue, Jul 27, 2010 at 1:20 PM, Xinliang David Li  
>>> wrote:
 On Tue, Jul 27, 2010 at 12:57 PM, Pat Haugen  wrote:
>>
>> Thanks Sebatian for testing it out. I also asked Pat to help testing
>> the patch again on powerpc. I will first split off the unrelated
>> patches and submit them first (e.g, multiple exit loop handling etc).
>>
>
> There were 2 good improvements on PowerPC, the rest were pretty much a 
> wash
> (< +/-2%):
>
> 410.bwaves      10.0%
> 434.zeusmp      6.6%
>
> One thing I did notice however is that comparing these results to the run 
> I
> did back in May on an earlier version of the patch is that both
> improvements dropped. bwaves was 27% on that run and zeusmp was 8.4%. I
> don't have the old builds around, but could recreate if you're not aware 
> of
> anything to explain the drop.
>

 Thanks. I will check in this version first and do some triaging on the
 performance drop (with your help).  One thing to be aware is that
 r161844 was checked in during this period of time which might be
 related, but not sure until further investigation -- the two stage
 initial iv set computation introduced by the patch may not be needed
 (if this patch is in).

>>>
>>> Your checkin caused:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45119
>>>
>>
>> This also caused:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45121
>>
>
> This may also cause:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45131
>

This also caused:

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

-- 
H.J.


Re: [RFC] Context sensitive inline analysis

2011-04-27 Thread Jan Hubicka
Hi,
I don't really have testcase for the HP nor AIX ICE, however I can reproduce 
same ICE when I hack x86 to
not use ctors/dtors.  This patch fixes it - the problem is that ipa-prop ignore 
newly added functions
(the global ctor built) while ipa-inline not and ipa-inline does use ipa-prop 
for its analysis.
Fixed by adding the corresponding hook to ipa-prop, regstested&bootstrapped 
x86_64-linux with the
hack and comitted.  Let me know if it fixes your problem or not.

Honza

* ipa-prop.c (function_insertion_hook_holder): New holder.
(ipa_add_new_function): New function.
(ipa_register_cgraph_hooks, ipa_unregister_cgraph_hooks): 
Register/deregister
holder.
Index: ipa-prop.c
===
--- ipa-prop.c  (revision 172989)
+++ ipa-prop.c  (working copy)
@@ -63,6 +63,7 @@ static struct cgraph_edge_hook_list *edg
 static struct cgraph_node_hook_list *node_removal_hook_holder;
 static struct cgraph_2edge_hook_list *edge_duplication_hook_holder;
 static struct cgraph_2node_hook_list *node_duplication_hook_holder;
+static struct cgraph_node_hook_list *function_insertion_hook_holder;
 
 /* Add cgraph NODE described by INFO to the worklist WL regardless of whether
it is in one or not.  It should almost never be used directly, as opposed to
@@ -2058,6 +2059,15 @@ ipa_node_duplication_hook (struct cgraph
   new_info->node_enqueued = old_info->node_enqueued;
 }
 
+
+/* Analyze newly added function into callgraph.  */
+
+static void
+ipa_add_new_function (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
+{
+  ipa_analyze_node (node);
+}
+
 /* Register our cgraph hooks if they are not already there.  */
 
 void
@@ -2075,6 +2085,8 @@ ipa_register_cgraph_hooks (void)
   if (!node_duplication_hook_holder)
 node_duplication_hook_holder =
   cgraph_add_node_duplication_hook (&ipa_node_duplication_hook, NULL);
+  function_insertion_hook_holder =
+  cgraph_add_function_insertion_hook (&ipa_add_new_function, NULL);
 }
 
 /* Unregister our cgraph hooks if they are not already there.  */
@@ -2090,6 +2102,8 @@ ipa_unregister_cgraph_hooks (void)
   edge_duplication_hook_holder = NULL;
   cgraph_remove_node_duplication_hook (node_duplication_hook_holder);
   node_duplication_hook_holder = NULL;
+  cgraph_remove_function_insertion_hook (function_insertion_hook_holder);
+  function_insertion_hook_holder = NULL;
 }
 
 /* Allocate all necessary data structures necessary for indirect inlining.  */


Re: [PATCH Commitred] Fix PR target/48767

2011-04-27 Thread Kaz Kojima
"Joseph S. Myers"  wrote:
> Yes, that testcase looks like what I had in mind, but you don't need the 
> dg-* directives (the defaults in gcc.c-torture/compile should be fine).
> 
>> BTW, is it valid C?
> 
> I think this should be considered the same as passing a type such as 
> "short" that can never be the promoted argument type: undefined behavior 
> at runtime if the call is executed.

Thanks for the explanation.  I've committed the testcase below
on trunk.

Regards,
kaz
--
2011-04-27  Kaz Kojima  

PR target/48767
* gcc.c-torture/compile/pr48767.c: New test.

diff -uprN ORIG/trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c  
trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c
--- ORIG/trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c1970-01-01 
09:00:00.0 +0900
+++ trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c 2011-04-27 
19:28:47.0 +0900
@@ -0,0 +1,7 @@
+/* PR target/48767 */
+
+void
+foo (__builtin_va_list ap)
+{
+  __builtin_va_arg (ap, void);
+}


[PATCH] Fix PR48772

2011-04-27 Thread Richard Guenther

This fixes PR48772, we can't update stmts with virtual defs during
VN elimination as that may destroy SSA names we use in the VN lattice.
So we have to defer it, similar to removing stmts.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-04-27  Richard Guenther  

PR tree-optimization/48772
* tree-ssa-pre.c (eliminate): Update call stmts after elimination
only.

* g++.dg/pr48772.C: New testcase.

Index: gcc/tree-ssa-pre.c
===
*** gcc/tree-ssa-pre.c  (revision 172965)
--- gcc/tree-ssa-pre.c  (working copy)
*** static unsigned int
*** 4186,4191 
--- 4186,4192 
  eliminate (void)
  {
VEC (gimple, heap) *to_remove = NULL;
+   VEC (gimple, heap) *to_update = NULL;
basic_block b;
unsigned int todo = 0;
gimple_stmt_iterator gsi;
*** eliminate (void)
*** 4411,4417 
}
  
  gimple_call_set_fn (stmt, fn);
! update_stmt (stmt);
  
  /* When changing a call into a noreturn call, cfg cleanup
 is needed to fix up the noreturn call.  */
--- 4412,4418 
}
  
  gimple_call_set_fn (stmt, fn);
! VEC_safe_push (gimple, heap, to_update, stmt);
  
  /* When changing a call into a noreturn call, cfg cleanup
 is needed to fix up the noreturn call.  */
*** eliminate (void)
*** 4563,4568 
--- 4564,4576 
  }
VEC_free (gimple, heap, to_remove);
  
+   /* We cannot update call statements with virtual operands during
+  SSA walk.  This might remove them which in turn makes our
+  VN lattice invalid.  */
+   FOR_EACH_VEC_ELT (gimple, to_update, i, stmt)
+ update_stmt (stmt);
+   VEC_free (gimple, heap, to_update);
+ 
return todo;
  }
  
Index: gcc/testsuite/g++.dg/pr48772.C
===
*** gcc/testsuite/g++.dg/pr48772.C  (revision 0)
--- gcc/testsuite/g++.dg/pr48772.C  (revision 0)
***
*** 0 
--- 1,35 
+ // { dg-do compile }
+ // { dg-options "-O -fnon-call-exceptions -fno-tree-ccp -fno-tree-dce" }
+ 
+ extern "C" void abort ();
+ 
+ struct A
+ {
+   void foo ()
+   {
+ this->bar ();
+   }
+   virtual void bar ()
+   {
+ abort ();
+   }
+   ~A ()
+   {
+   }
+ };
+ 
+ struct B:A
+ {
+   virtual void bar ()
+   {
+   }
+ };
+ 
+ int
+ main ()
+ {
+   B b;
+   b.foo ();
+   return 0;
+ }
+ 


Re: [PATCH Commitred] Fix PR target/48767

2011-04-27 Thread Joseph S. Myers
On Wed, 27 Apr 2011, Kaz Kojima wrote:

> "Joseph S. Myers"  wrote:
> > I think you should add a testcase to gcc.c-torture/compile, unless there 
> > is already one that this patch fixes.
> 
> Ah, indeed.  How about the attached testcase?

Yes, that testcase looks like what I had in mind, but you don't need the 
dg-* directives (the defaults in gcc.c-torture/compile should be fine).

> BTW, is it valid C?

I think this should be considered the same as passing a type such as 
"short" that can never be the promoted argument type: undefined behavior 
at runtime if the call is executed.

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


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

2011-04-27 Thread Joseph S. Myers
On Tue, 26 Apr 2011, Cary Coutant wrote:

> @@ -1856,6 +1871,8 @@ set_debug_level (enum debug_info_type type, int 
> extended, const char *arg,
>else
>   opts->x_debug_info_level = (enum debug_info_levels) argval;
>  }
> +
> +  generate_debug_line_table = debug_info_level >= DINFO_LEVEL_NORMAL;

set_debug_level should not use global state; this needs to check 
opts->x_debug_info_level (not the global debug_info_level) and set 
opts->x_generate_debug_line_table.

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


Re: Don't use linux.h for non-Linux targets

2011-04-27 Thread Joseph S. Myers
On Wed, 27 Apr 2011, Thomas Schwinge wrote:

> One (minor) additional idea: for clarity, shouldn't it now be possible to
> remove any #undef GNU_USER_TARGET_OS_CPP_BUILTINS, #undef
> GNU_USER_DYNAMIC_LINKER, #undef GNU_USER_LINK_EMULATION, etc. from
> *gnu.h?  I don't expect you to test this; I'll have a look later on.

Yes, if those were only to undefine macros defined in linux.h.  In general 
there is no consistent rule about whether headers use #undef in cases 
where it is not needed.

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


Re: [Patch,AVR]: Solve PR42210

2011-04-27 Thread Georg-Johann Lay
Richard Henderson schrieb:

> Why are you adding "optimize" to all these insns?  None of them will
> be matched unless combine is run, which implies optimization.

Here is a patch without optimize in the insn conditions.

The optimize condition is still present in the insv expander because I
do not know what the policy about that is in the avr backend.

Johann

> 
> r~
> 

PR target/42210

* config/avr/predicates.md (const1_operand, const_0_to_7_operand):
New predicates.

* config/avr/avr.md ("insv"): New insn expander.
("*movbitqi.1-6.a", "*movbitqi.1-6.b", "*movbitqi.0", "*insv.io",
"*insv.not.io", "*insv.reg"): New insns.
Index: config/avr/predicates.md
===
--- config/avr/predicates.md	(Revision 172902)
+++ config/avr/predicates.md	(Arbeitskopie)
@@ -62,6 +62,17 @@ (define_predicate "const0_operand"
   (and (match_code "const_int,const_double")
(match_test "op == CONST0_RTX (mode)")))
 
+;; Return 1 if OP is the one constant integer for MODE.
+(define_predicate "const1_operand"
+  (and (match_code "const_int")
+   (match_test "op == CONST1_RTX (mode)")))
+
+
+;; Return 1 if OP is constant integer 0..7 for MODE.
+(define_predicate "const_0_to_7_operand"
+  (and (match_code "const_int")
+   (match_test "IN_RANGE (INTVAL (op), 0, 7)")))
+
 ;; Returns true if OP is either the constant zero or a register.
 (define_predicate "reg_or_0_operand"
   (ior (match_operand 0 "register_operand")
Index: config/avr/avr.md
===
--- config/avr/avr.md	(Revision 172902)
+++ config/avr/avr.md	(Arbeitskopie)
@@ -3388,3 +3388,116 @@ (define_insn "fmulsu"
 	clr __zero_reg__"
   [(set_attr "length" "3")
(set_attr "cc" "clobber")])
+
+
+;; Some combiner patterns dealing with bits.
+;; See PR42210
+
+;; Move bit $3.$4 into bit $0.$4
+(define_insn "*movbitqi.1-6.a"
+  [(set (match_operand:QI 0 "register_operand"   "=r")
+(ior:QI (and:QI (match_operand:QI 1 "register_operand""0")
+(match_operand:QI 2 "single_zero_operand" "n"))
+(and:QI (ashift:QI (match_operand:QI 3 "register_operand" "r")
+   (match_operand:QI 4 "const_0_to_7_operand" "n"))
+(match_operand:QI 5 "single_one_operand"  "n"]
+  "INTVAL(operands[4]) == exact_log2 (~INTVAL(operands[2]) & GET_MODE_MASK (QImode))
+   && INTVAL(operands[4]) == exact_log2 (INTVAL(operands[5]) & GET_MODE_MASK (QImode))"
+  "bst %3,0\;bld %0,%4"
+  [(set_attr "length" "2")
+   (set_attr "cc" "none")])
+
+;; Move bit $3.0 into bit $0.$4
+;; Variation of above. Unfortunately, there is no canonicalized representation
+;; of moving around bits.  So what we see here depends on how user writes down
+;; bit manipulations.
+(define_insn "*movbitqi.1-6.b"
+  [(set (match_operand:QI 0 "register_operand""=r")
+(ior:QI (and:QI (match_operand:QI 1 "register_operand" "0")
+(match_operand:QI 2 "single_zero_operand"  "n"))
+(ashift:QI (and:QI (match_operand:QI 3 "register_operand"  "r")
+   (const_int 1))
+   (match_operand:QI 4 "const_0_to_7_operand"  "n"]
+  "INTVAL(operands[4]) == exact_log2 (~INTVAL(operands[2]) & GET_MODE_MASK (QImode))"
+  "bst %3,0\;bld %0,%4"
+  [(set_attr "length" "2")
+   (set_attr "cc" "none")])
+
+;; Move bit $3.0 into bit $0.0.
+;; For bit 0, combiner generates slightly different pattern.
+(define_insn "*movbitqi.0"
+  [(set (match_operand:QI 0 "register_operand" "=r")
+(ior:QI (and:QI (match_operand:QI 1 "register_operand"  "0")
+(match_operand:QI 2 "single_zero_operand"   "n"))
+(and:QI (match_operand:QI 3 "register_operand"  "r")
+(const_int 1]
+  "0 == exact_log2 (~INTVAL(operands[2]) & GET_MODE_MASK (QImode))"
+  "bst %3,0\;bld %0,0"
+  [(set_attr "length" "2")
+   (set_attr "cc" "none")])
+
+;; Move bit $2.0 into bit $0.7.
+;; For bit 7, combiner generates slightly different pattern
+(define_insn "*movbitqi.7"
+  [(set (match_operand:QI 0 "register_operand"  "=r")
+(ior:QI (and:QI (match_operand:QI 1 "register_operand"   "0")
+(const_int 127))
+(ashift:QI (match_operand:QI 2 "register_operand""r")
+   (const_int 7]
+  ""
+  "bst %2,0\;bld %0,7"
+  [(set_attr "length" "2")
+   (set_attr "cc" "none")])
+
+;; Combiner transforms above four pattern into ZERO_EXTRACT if it sees MEM
+;; and input/output match.  We provide a special pattern for this, because
+;; in contrast to a IN/BST/BLD/OUT sequence we need less registers and the
+;; oper

Commit: FRV: Remove duplicate register classes

2011-04-27 Thread Nick Clifton
Hi Guys,

  I am applying the patch below to remove the duplicate register classes
  from the FRV backend.  This was causing problems with the IRA
  initialization code.

Cheers
  Nick

gcc/ChangeLog
2011-04-27  Nick Clifton  

* config/frv/frv.h (enum reg_class): Delete EVEN_ACC_REGS,
ACC_REGS, FEVEN_REGS, FPR_REGS, EVEN_REGS.
(REG_CLASS_NAMES): Likewise.
(REG_CLASS_CONTENTS): Likewise.
(EVEN_ACC_REGS): New macro.  Alias for QUAD_ACC_REGS.
(ACC_REGS): New macro.  Alias for QUAD_ACC_REGS.
(FEVEN_REGS): New macro.  Alias for QUAD_ACC_REGS.
(FPR_REGS): New macro.  Alias for QUAD_ACC_REGS.
(EVEN_REGS): New macro.  Alias for QUAD_REGS.
* config/frv/frv.c (frv_secondary_reload_class): Remove use of
duplicate register classes.
(frv_class_likely_spileld_p): Likewise.
(frv_register_move_cost): Likewise.

Index: gcc/config/frv/frv.h
===
--- gcc/config/frv/frv.h(revision 173012)
+++ gcc/config/frv/frv.h(working copy)
@@ -864,14 +864,9 @@
   FDPIC_CALL_REGS,
   SPR_REGS,
   QUAD_ACC_REGS,
-  EVEN_ACC_REGS,
-  ACC_REGS,
   ACCG_REGS,
   QUAD_FPR_REGS,
-  FEVEN_REGS,
-  FPR_REGS,
   QUAD_REGS,
-  EVEN_REGS,
   GPR_REGS,
   ALL_REGS,
   LIM_REG_CLASSES
@@ -904,14 +899,9 @@
"FDPIC_CALL_REGS",  \
"SPR_REGS", \
"QUAD_ACC_REGS",\
-   "EVEN_ACC_REGS",\
-   "ACC_REGS", \
"ACCG_REGS",
\
"QUAD_FPR_REGS",\
-   "FEVEN_REGS",   \
-   "FPR_REGS", \
"QUAD_REGS",
\
-   "EVEN_REGS",
\
"GPR_REGS", \
"ALL_REGS"  \
 }
@@ -945,18 +935,19 @@
   { 0xc000,0x,0x,0x,0x,0x0}, /* 
FDPIC_CALL_REGS */\
   { 0x,0x,0x,0x,0x,0x1e00}, /* 
SPR_REGS */\
   { 0x,0x,0x,0x,0x0fff,0x0}, /* QUAD_ACC 
*/\
-  { 0x,0x,0x,0x,0x0fff,0x0}, /* EVEN_ACC 
*/\
-  { 0x,0x,0x,0x,0x0fff,0x0}, /* ACC_REGS 
*/\
   { 0x,0x,0x,0x,0xf000,0xff}, /* 
ACCG_REGS*/\
   { 0x,0x,0x,0x,0x,0x0}, /* QUAD_FPR 
*/\
-  { 0x,0x,0x,0x,0x,0x0}, /* 
FEVEN_REG*/\
-  { 0x,0x,0x,0x,0x,0x0}, /* FPR_REGS 
*/\
   { 0x0ffc,0x,0x,0x,0x,0x0}, /* 
QUAD_REGS*/\
-  { 0xfffc,0x,0x,0x,0x,0x0}, /* 
EVEN_REGS*/\
   { 0x,0x,0x,0x,0x,0x100}, /* GPR_REGS 
*/\
   { 0x,0x,0x,0x,0x,0x1fff}, /* 
ALL_REGS */\
 }
 
+#define EVEN_ACC_REGS   QUAD_ACC_REGS
+#define ACC_REGSQUAD_ACC_REGS
+#define FEVEN_REGS  QUAD_FPR_REGS
+#define FPR_REGSQUAD_FPR_REGS
+#define EVEN_REGS   QUAD_REGS
+
 /* A C expression whose value is a register class containing hard register
REGNO.  In general there is more than one such class; choose a class which
is "minimal", meaning that no smaller class also contains the register.  */
Index: gcc/config/frv/frv.c
===
--- gcc/config/frv/frv.c(revision 173012)
+++ gcc/config/frv/frv.c(working copy)
@@ -6371,7 +6371,6 @@
   /* Accumulators/Accumulator guard registers need to go through floating
  point registers.  */
 case QUAD_REGS:
-case EVEN_REGS:
 case GPR_REGS:
   ret = NO_REGS;
   if (x && GET_CODE (x) == REG)
@@ -6385,8 +6384,6 @@
 
   /* Nonzero constants should be loaded into an FPR through a GPR.  */
 case QUAD_FPR_REGS:
-case FEVEN_REGS:
-case FPR_REGS:
   if (x && CONSTANT_P (x) && !ZERO_P (x))
ret = GPR_REGS;
   else
@@ -6406,8 +6403,6 @@
   break;
 
   /* The accumulators need fpr registers.  */
-case ACC_REGS:
-case EVEN_ACC_REGS:
 case QUAD_ACC_REGS:
 case ACCG_REGS:
   ret = FPR_REGS;
@@ -6481,8 +6476,6 @@
 case LR_REG:
 case SPR_REGS:
 case QUAD_ACC_REGS:
-case EVEN_ACC_REGS:
-case ACC_REGS:
 case ACCG_REGS:
   return true;
 }
@@ -6842,19 +6835,

[PATCH][2/n] Alias housekeeping

2011-04-27 Thread Richard Guenther

This fixes TARGET_MEM_REF handling in indirect_refs_may_alias_p,
unifying handling of it and MEM_REFs where possible.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-04-27  Richard Guenther  

* tree-ssa-alias.c (indirect_refs_may_alias_p): Fix
TARGET_MEM_REF handling.

Index: gcc/tree-ssa-alias.c
===
--- gcc/tree-ssa-alias.c(revision 172965)
+++ gcc/tree-ssa-alias.c(working copy)
@@ -925,12 +935,12 @@ indirect_refs_may_alias_p (tree ref1 ATT
   /* If both references are through the same type, they do not alias
  if the accesses do not overlap.  This does extra disambiguation
  for mixed/pointer accesses but requires strict aliasing.  */
-  if ((TREE_CODE (base1) != TARGET_MEM_REF || !TMR_INDEX (base1))
-  && (TREE_CODE (base2) != TARGET_MEM_REF || !TMR_INDEX (base2))
-  && (TREE_CODE (base1) != MEM_REF
- || same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1)
-  && (TREE_CODE (base2) != MEM_REF
- || same_type_for_tbaa (TREE_TYPE (base2), TREE_TYPE (ptrtype2)) == 1)
+  if ((TREE_CODE (base1) != TARGET_MEM_REF
+   || (!TMR_INDEX (base1) && !TMR_INDEX2 (base1)))
+  && (TREE_CODE (base2) != TARGET_MEM_REF
+ || (!TMR_INDEX (base2) && !TMR_INDEX2 (base2)))
+  && same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1
+  && same_type_for_tbaa (TREE_TYPE (base2), TREE_TYPE (ptrtype2)) == 1
   && same_type_for_tbaa (TREE_TYPE (ptrtype1),
 TREE_TYPE (ptrtype2)) == 1)
 return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
@@ -942,14 +952,9 @@ indirect_refs_may_alias_p (tree ref1 ATT
 
   /* Do access-path based disambiguation.  */
   if (ref1 && ref2
-  && handled_component_p (ref1)
-  && handled_component_p (ref2)
-  && TREE_CODE (base1) != TARGET_MEM_REF
-  && TREE_CODE (base2) != TARGET_MEM_REF
-  && (TREE_CODE (base1) != MEM_REF
- || same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1)
-  && (TREE_CODE (base2) != MEM_REF
- || same_type_for_tbaa (TREE_TYPE (base2), TREE_TYPE (ptrtype2)) == 1))
+  && (handled_component_p (ref1) || handled_component_p (ref2))
+  && same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1
+  && same_type_for_tbaa (TREE_TYPE (base2), TREE_TYPE (ptrtype2)) == 1)
 return aliasing_component_refs_p (ref1,
  ref1_alias_set, base1_alias_set,
  offset1, max_size1,


Commit: Fix MCore REGNO_REG_CLASS macro

2011-04-27 Thread Nick Clifton
Hi Guys,

  I am applying the patch below to fix the REGNO_REG_CLASS macro for
  the MCore backend so that it will not try to index beyond the end of
  the regno_reg_class array.  This was causing a segmentation fault
  whilst building the MCore toolchain.

Cheers
  Nick

gcc/ChangeLog
2011-04-27  Nick Clifton  

* config/mcore/mcore.h (REGNO_REG_CLASS): Do not index beyond the
end of the regno_reg_class array.

Index: gcc/config/mcore/mcore.h
===
--- gcc/config/mcore/mcore.h(revision 173012)
+++ gcc/config/mcore/mcore.h(working copy)
@@ -357,7 +357,7 @@
or could index an array.  */
 
 extern const enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];
-#define REGNO_REG_CLASS(REGNO) regno_reg_class[REGNO]
+#define REGNO_REG_CLASS(REGNO) ((REGNO) < FIRST_PSEUDO_REGISTER ? 
regno_reg_class[REGNO] : NO_REGS)
 
 /* When this hook returns true for MODE, the compiler allows
registers explicitly used in the rtl to be used as spill registers


[C++ Patch] PR 48771

2011-04-27 Thread Paolo Carlini

Hi,

today I (re-)tested the below. As you can see, wrt the audit trail 
discussion, I also removed altogether valid_type_in_constexpr_fundecl_p, 
I can restore it if you want, just let me know.


Tested x86_64-linux. Ok for mainline? (not sure if it qualifies for the 
branch or we want to reconsider it in a couple of weeks?!?)


Thanks,
Paolo.

///
/cp
2011-04-27  Paolo Carlini  

PR c++/48771
* semantics.c (literal_type_p): Reference types are literal types,
per the FDIS.
(valid_type_in_constexpr_fundecl_p): Remove.
(is_valid_constexpr_fn): Adjust.

/testsuite
2011-04-27  Paolo Carlini  

PR c++/48771
* g++.dg/ext/is_literal_type1.C: New.
Index: testsuite/g++.dg/ext/is_literal_type1.C
===
--- testsuite/g++.dg/ext/is_literal_type1.C (revision 0)
+++ testsuite/g++.dg/ext/is_literal_type1.C (revision 0)
@@ -0,0 +1,11 @@
+// PR c++/48771
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+struct NonLiteral {
+  NonLiteral();
+  ~NonLiteral();
+};
+
+static_assert(__is_literal_type(NonLiteral&), "Error");
+static_assert(__is_literal_type(NonLiteral&&), "Error");
Index: cp/semantics.c
===
--- cp/semantics.c  (revision 173012)
+++ cp/semantics.c  (working copy)
@@ -5331,7 +5331,8 @@ float_const_decimal64_p (void)
 bool
 literal_type_p (tree t)
 {
-  if (SCALAR_TYPE_P (t))
+  if (SCALAR_TYPE_P (t)
+  || TREE_CODE (t) == REFERENCE_TYPE)
 return true;
   if (CLASS_TYPE_P (t))
 return CLASSTYPE_LITERAL_P (t);
@@ -5406,18 +5407,6 @@ retrieve_constexpr_fundef (tree fun)
   return (constexpr_fundef *) htab_find (constexpr_fundef_table, &fundef);
 }
 
-/* Return true if type expression T is a valid parameter type, or
-   a valid return type, of a constexpr function.  */
-
-static bool
-valid_type_in_constexpr_fundecl_p (tree t)
-{
-  return (literal_type_p (t)
- /* FIXME we allow ref to non-literal; should change standard to
-match, or change back if not.  */
- || TREE_CODE (t) == REFERENCE_TYPE);
-}
-
 /* Check whether the parameter and return types of FUN are valid for a
constexpr function, and complain if COMPLAIN.  */
 
@@ -5427,7 +5416,7 @@ is_valid_constexpr_fn (tree fun, bool complain)
   tree parm = FUNCTION_FIRST_USER_PARM (fun);
   bool ret = true;
   for (; parm != NULL; parm = TREE_CHAIN (parm))
-if (!valid_type_in_constexpr_fundecl_p (TREE_TYPE (parm)))
+if (!literal_type_p (TREE_TYPE (parm)))
   {
ret = false;
if (complain)
@@ -5438,7 +5427,7 @@ is_valid_constexpr_fn (tree fun, bool complain)
   if (!DECL_CONSTRUCTOR_P (fun))
 {
   tree rettype = TREE_TYPE (TREE_TYPE (fun));
-  if (!valid_type_in_constexpr_fundecl_p (rettype))
+  if (!literal_type_p (rettype))
{
  ret = false;
  if (complain)


  1   2   >