Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-10-28 Thread Andreas Schwab
Joern Rennecke  writes:

> Index: gcc/doc/tm.texi
> ===
> --- gcc/doc/tm.texi   (revision 192840)
> +++ gcc/doc/tm.texi   (working copy)
> @@ -11333,3 +11333,11 @@ @deftypefn {Target Hook} {unsigned HOST_
>  @deftypevr {Target Hook} {unsigned char} TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
>  This value should be set if the result written by @code{atomic_test_and_set} 
> is not exactly 1, i.e. the @code{bool} @code{true}.
>  @end deftypevr
> +
> +@deftypevr {Target Hook} bool TARGET_HAVE_CC0
> +@deftypevrx {Target Hook} {bool} TARGET_AUTO_INC_DEC
> +@deftypevrx {Target Hook} {bool} TARGET_STACK_REGS
> +@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_ENABLED
> +@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_LENGTH
> +These flags are automatically generated;  you should not override them in 
> tm.c:

Typo: s/:$/./, also @file{tm.c}.

Andreas.

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


Move @end to own line

2012-10-28 Thread Andreas Schwab
The texinfo manual says that @end should always be put on a line of its
own.  Tested with make info dvi pdf html and checked in as obvious.

(None of the converters have a problem with this so the output will be
the same.)

Andreas.

* doc/tm.texi.in (Misc): Add newline before @end.
* doc/tm.texi: Update.

Index: doc/tm.texi
===
--- doc/tm.texi (revision 192885)
+++ doc/tm.texi (working copy)
@@ -11323,7 +11323,8 @@ accepted by immediate-add plus one.  We
 value of @code{TARGET_CONST_ANCHOR} is a power of 2.  For example, on
 MIPS, where add-immediate takes a 16-bit signed value,
 @code{TARGET_CONST_ANCHOR} is set to @samp{0x8000}.  The default value
-is zero, which disables this optimization.  @end deftypevr
+is zero, which disables this optimization.
+@end deftypevr
 
 @deftypefn {Target Hook} {unsigned HOST_WIDE_INT} TARGET_MEMMODEL_CHECK 
(unsigned HOST_WIDE_INT @var{val})
 Validate target specific memory model mask bits. When NULL no target specific
Index: doc/tm.texi.in
===
--- doc/tm.texi.in  (revision 192885)
+++ doc/tm.texi.in  (working copy)
@@ -11165,7 +11165,8 @@ accepted by immediate-add plus one.  We
 value of @code{TARGET_CONST_ANCHOR} is a power of 2.  For example, on
 MIPS, where add-immediate takes a 16-bit signed value,
 @code{TARGET_CONST_ANCHOR} is set to @samp{0x8000}.  The default value
-is zero, which disables this optimization.  @end deftypevr
+is zero, which disables this optimization.
+@end deftypevr
 
 @hook TARGET_MEMMODEL_CHECK
 Validate target specific memory model mask bits. When NULL no target specific
-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Re: [RFC PATCH, i386]: Remove peephole2s for (subreg (operator (...)(...))) RTXes

2012-10-28 Thread Uros Bizjak
On Sun, Oct 28, 2012 at 2:37 AM, H.J. Lu  wrote:

>>> As suggested by Richard S. [1], after the patch that converts subreg:M
>>> (op:N (...)(...)) to op:M (subreg:M (...) subreg:M (...)), we can
>>> remove several peephole2 patterns that handle subregs of PLUS, MINUS
>>> and MULT operators. I have attached RFC prototype patch that will
>>> trigger an ICE when to-be-removed pattern triggers, with the intention
>>> that these patterns wil be removed entirely (An "invalid" pattern was
>>> indeed generated elsewhere, see patch).
>>>
>>> 2012-10-18  Uros Bizjak  
>>>
>>> * config/i386/i386.md (ashift to lea splitter): Split to SImode 
>>> mult.
>>> (simple lea to add/shift peephole2s): Remove peephole2s that operate
>>> on subregs of DImode operations.
>>> (*mov_insv_1_rex64): Use gen_int_mode to truncate
>>> const_int RTX to QImode value.
>>> (*movsi_insv_1): Ditto.
>>>
>>> The patch was bootstrapped and regression tested on
>>> x86_64-pc-linux-gnu {,-m32} without problems, but I will ask H.J. to
>>> test the patch on x32 before it is committed to mainline SVN.
>>>
>>> [1] http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01856.html
>>>
>>> Uros.
>>
>> I tested it on x32, ia32 and x86-64 with GCC testsuite and glibc.
>> There are no GCC regressions on x32. However, for glibc trunk,
>> on x32 and x86-64, I got
>>
>> make[4]: *** 
>> [/export/build/gnu/glibc-test/build-x86_64-linux/math/test-ildoubl.out]
>> Error 1
>> make[4]: *** 
>> [/export/build/gnu/glibc-test/build-x86_64-linux/math/test-ldouble.out]
>> Error 1
>>
>> On ia32, I got
>>
>> make[4]: *** 
>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-fenv.out]
>> Error 1
>> make[4]: *** 
>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-ifloat.out]
>> Error 1
>> make[4]: *** 
>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-idouble.out]
>> Error 1
>> make[4]: *** 
>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-float.out]
>> Error 1
>> make[4]: *** 
>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-double.out]
>> Error 1
>>
>> I am testing if they are caused by the change.
>>
>
> They are caused by this patch. I configure glibc with CFLAGS="-O3 -g"

Can you please send me offline preprocessed sources to investigate
this failure? There is another place in the code that generates subreg
"by hand".

Thanks,
Uros.


Re: [RFC PATCH, i386]: Remove peephole2s for (subreg (operator (...)(...))) RTXes

2012-10-28 Thread Uros Bizjak
On Sun, Oct 28, 2012 at 9:57 AM, Uros Bizjak  wrote:
> On Sun, Oct 28, 2012 at 2:37 AM, H.J. Lu  wrote:
>
 As suggested by Richard S. [1], after the patch that converts subreg:M
 (op:N (...)(...)) to op:M (subreg:M (...) subreg:M (...)), we can
 remove several peephole2 patterns that handle subregs of PLUS, MINUS
 and MULT operators. I have attached RFC prototype patch that will
 trigger an ICE when to-be-removed pattern triggers, with the intention
 that these patterns wil be removed entirely (An "invalid" pattern was
 indeed generated elsewhere, see patch).

 2012-10-18  Uros Bizjak  

 * config/i386/i386.md (ashift to lea splitter): Split to SImode 
 mult.
 (simple lea to add/shift peephole2s): Remove peephole2s that 
 operate
 on subregs of DImode operations.
 (*mov_insv_1_rex64): Use gen_int_mode to truncate
 const_int RTX to QImode value.
 (*movsi_insv_1): Ditto.

 The patch was bootstrapped and regression tested on
 x86_64-pc-linux-gnu {,-m32} without problems, but I will ask H.J. to
 test the patch on x32 before it is committed to mainline SVN.

 [1] http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01856.html

 Uros.
>>>
>>> I tested it on x32, ia32 and x86-64 with GCC testsuite and glibc.
>>> There are no GCC regressions on x32. However, for glibc trunk,
>>> on x32 and x86-64, I got
>>>
>>> make[4]: *** 
>>> [/export/build/gnu/glibc-test/build-x86_64-linux/math/test-ildoubl.out]
>>> Error 1
>>> make[4]: *** 
>>> [/export/build/gnu/glibc-test/build-x86_64-linux/math/test-ldouble.out]
>>> Error 1
>>>
>>> On ia32, I got
>>>
>>> make[4]: *** 
>>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-fenv.out]
>>> Error 1
>>> make[4]: *** 
>>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-ifloat.out]
>>> Error 1
>>> make[4]: *** 
>>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-idouble.out]
>>> Error 1
>>> make[4]: *** 
>>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-float.out]
>>> Error 1
>>> make[4]: *** 
>>> [/export/build/gnu/glibc-32bit-test/build-i686-linux/math/test-double.out]
>>> Error 1
>>>
>>> I am testing if they are caused by the change.
>>>
>>
>> They are caused by this patch. I configure glibc with CFLAGS="-O3 -g"
>
> Can you please send me offline preprocessed sources to investigate
> this failure? There is another place in the code that generates subreg
> "by hand".

Maybe following patch helps:

--cut here--
Index: i386.c
===
--- i386.c  (revision 192872)
+++ i386.c  (working copy)
@@ -11821,7 +11821,7 @@ ix86_decompose_address (rtx addr, struct ix86_addr
return 0;
}
  else if (GET_MODE (addr) == DImode)
-   addr = gen_rtx_SUBREG (SImode, addr, 0);
+   addr = simplify_gen_subreg (SImode, addr, DImode, 0);
  else if (GET_MODE (addr) != VOIDmode)
return 0;
}
--cut here--

Uros.


Fix use of @item vs. @itemx inside @table

2012-10-28 Thread Andreas Schwab
Tested with make info dvi pdf html and checked in as obvious.

Andreas.

* doc/cppopts.texi: Fix use of @item vs. @itemx inside @table.
* doc/extend.texi: Likewise.
* doc/generic.texi: Likewise.
* doc/invoke.texi: Likewise.
* doc/md.texi: Likewise.
* doc/sourcebuild.texi: Likewise.

diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi
index 27b1095..a2eb79d 100644
--- a/gcc/doc/cppopts.texi
+++ b/gcc/doc/cppopts.texi
@@ -1,5 +1,5 @@
 @c Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-@c 2010, Free Software Foundation, Inc.
+@c 2010, 2012, Free Software Foundation, Inc.
 @c This is part of the CPP and GCC manuals.
 @c For copying conditions, see the file gcc.texi.
 
@@ -805,7 +805,7 @@ Replacement:  []@{@}#\^|
~
 Enable special code to work around file systems which only permit very
 short file names, such as MS-DOS@.
 
-@itemx --help
+@item --help
 @itemx --target-help
 @opindex help
 @opindex target-help
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index fb1becb..5c4f8fd 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1251,10 +1251,10 @@ The @code{__flash} qualifier will locate data in the
 instruction. Pointers to this address space are 16 bits wide.
 
 @item __flash1
-@item __flash2
-@item __flash3
-@item __flash4
-@item __flash5
+@itemx __flash2
+@itemx __flash3
+@itemx __flash4
+@itemx __flash5
 @cindex @code{__flash1} AVR Named Address Spaces
 @cindex @code{__flash2} AVR Named Address Spaces
 @cindex @code{__flash3} AVR Named Address Spaces
diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi
index c739731..e878811 100644
--- a/gcc/doc/generic.texi
+++ b/gcc/doc/generic.texi
@@ -1,4 +1,4 @@
-@c Copyright (c) 2004, 2005, 2007, 2008, 2010 Free Software Foundation, Inc.
+@c Copyright (c) 2004, 2005, 2007, 2008, 2010, 2012 Free Software Foundation, 
Inc.
 @c Free Software Foundation, Inc.
 @c This is part of the GCC manual.
 @c For copying conditions, see the file gcc.texi.
@@ -1417,13 +1417,13 @@ generate these expressions anyhow, if it can tell that 
strictness does
 not matter.  The type of the operands and that of the result are
 always of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
 
-@itemx POINTER_PLUS_EXPR
+@item POINTER_PLUS_EXPR
 This node represents pointer arithmetic.  The first operand is always
 a pointer/reference type.  The second operand is always an unsigned
 integer type compatible with sizetype.  This is the only binary
 arithmetic operand that can operate on pointer types.
 
-@itemx PLUS_EXPR
+@item PLUS_EXPR
 @itemx MINUS_EXPR
 @itemx MULT_EXPR
 These nodes represent various binary arithmetic operations.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index afb9f21..15ecaf1 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1617,7 +1617,7 @@ GNU dialect of ISO C99.  When ISO C99 is fully 
implemented in GCC,
 this will become the default.  The name @samp{gnu9x} is deprecated.
 
 @item gnu11
-@item gnu1x
+@itemx gnu1x
 GNU dialect of ISO C11.  Support is incomplete and experimental.  The
 name @samp{gnu1x} is deprecated.
 
@@ -5310,7 +5310,7 @@ is set by this option.
 For example, with @option{-fdbg-cnt=dce:10,tail_call:0},
 @code{dbg_cnt(dce)} returns true only for first 10 invocations.
 
-@itemx -fenable-@var{kind}-@var{pass}
+@item -fenable-@var{kind}-@var{pass}
 @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
 @opindex fdisable-
 @opindex fenable-
@@ -5464,11 +5464,11 @@ Dump after duplicating the computed gotos.
 @option{-fdump-rtl-ce3} enable dumping after the three
 if conversion passes.
 
-@itemx -fdump-rtl-cprop_hardreg
+@item -fdump-rtl-cprop_hardreg
 @opindex fdump-rtl-cprop_hardreg
 Dump after hard register copy propagation.
 
-@itemx -fdump-rtl-csa
+@item -fdump-rtl-csa
 @opindex fdump-rtl-csa
 Dump after combining stack adjustments.
 
@@ -5479,11 +5479,11 @@ Dump after combining stack adjustments.
 @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
 the two common subexpression elimination passes.
 
-@itemx -fdump-rtl-dce
+@item -fdump-rtl-dce
 @opindex fdump-rtl-dce
 Dump after the standalone dead code elimination passes.
 
-@itemx -fdump-rtl-dbr
+@item -fdump-rtl-dbr
 @opindex fdump-rtl-dbr
 Dump after delayed branch scheduling.
 
@@ -5528,7 +5528,7 @@ Dump after the initialization of the registers.
 @opindex fdump-rtl-initvals
 Dump after the computation of the initial value sets.
 
-@itemx -fdump-rtl-into_cfglayout
+@item -fdump-rtl-into_cfglayout
 @opindex fdump-rtl-into_cfglayout
 Dump after converting to cfglayout mode.
 
@@ -5558,7 +5558,7 @@ Dump after removing redundant mode switches.
 @opindex fdump-rtl-rnreg
 Dump after register renumbering.
 
-@itemx -fdump-rtl-outof_cfglayout
+@item -fdump-rtl-outof_cfglayout
 @opindex fdump-rtl-outof_cfglayout
 Dump after converting from cfglayout mode.
 
@@ -10815,10 +10815,10 @@ integer multiply, or integer multiply-and-accumula

Make inliner to take cgraph SCCs into account

2012-10-28 Thread Jan Hubicka

Hi,
this patch implements simple hints on strongly connected components to inliner.
It increases badness of inlining functions within the same scc component, since 
this
non-trivial recursive inlining is not win very often and it may blow up stack
frames a lot.

It also increases the entry points of SCC components to have bigger badness,
this is because inlining ufnctions in SCCs is usually also just complicating
callgraph furhter (it however can be great win when the recursion over SCC
is unlikely)

This is based on Richard's observation on one of the fortran testcases and
also on analysis of povray where we make our live very difficult by first
inlining within scc missing obvious inline of cheap entry of the component.

The badness update is a quick hack. I am experimenting with new and simpler
badness metric for 4.8. So with bit of luck good part of estimate_edge_badness
will go.

Bootstrapped/regtested x86_64-linux.

Honza

* ipa-inline.c (edge_badness): Reduce precision; use scc hints.
(inline_small_functions): Fix dumps; update all callees after inlining.
* ipa-inline.h (INLINE_HINT_in_scc, INLINE_HINT_same_scc): New 
constants.
(inline summary): Add SCC_NO.
* ipa-inline-analysis.c (dump_inline_hints): Dump SCC hints.
(reset_inline_summary): Reset scc_no.
(estimate_node_size_and_time): Set in_scc hint.
(do_estimate_edge_time): Add same_scc hint.
(do_estimate_edge_hints): Likewise.
Index: ipa-inline.c
===
*** ipa-inline.c(revision 192887)
--- ipa-inline.c(working copy)
*** edge_badness (struct cgraph_edge *edge, 
*** 845,852 
 precision for small bandesses (those are interesting) yet we don't
 overflow for growths that are still in interesting range.
  
!Fixed point arithmetic with point at 8th bit. */
!   badness = ((gcov_type)growth) * (1<<(19+8));
badness = (badness + div / 2) / div;
  
/* Overall growth of inlining all calls of function matters: we want to
--- 845,852 
 precision for small bandesses (those are interesting) yet we don't
 overflow for growths that are still in interesting range.
  
!Fixed point arithmetic with point at 6th bit. */
!   badness = ((gcov_type)growth) * (1<<(19+6));
badness = (badness + div / 2) / div;
  
/* Overall growth of inlining all calls of function matters: we want to
*** edge_badness (struct cgraph_edge *edge, 
*** 861,869 
 We might mix the valud into the fraction by taking into account
 relative growth of the unit, but for now just add the number
 into resulting fraction.  */
!   if (badness > INT_MAX / 2)
{
! badness = INT_MAX / 2;
  if (dump)
fprintf (dump_file, "Badness overflow\n");
}
--- 861,869 
 We might mix the valud into the fraction by taking into account
 relative growth of the unit, but for now just add the number
 into resulting fraction.  */
!   if (badness > INT_MAX / 4)
{
! badness = INT_MAX / 4;
  if (dump)
fprintf (dump_file, "Badness overflow\n");
}
*** edge_badness (struct cgraph_edge *edge, 
*** 871,876 
--- 871,880 
   | INLINE_HINT_loop_iterations
   | INLINE_HINT_loop_stride))
badness /= 8;
+   if (hints & (INLINE_HINT_same_scc))
+   badness *= 4;
+   if (hints & (INLINE_HINT_in_scc))
+   badness *= 2;
if (dump)
{
  fprintf (dump_file,
*** inline_small_functions (void)
*** 1337,1352 
if (flag_indirect_inlining)
  new_indirect_edges = VEC_alloc (cgraph_edge_p, heap, 8);
  
-   if (dump_file)
- fprintf (dump_file,
-"\nDeciding on inlining of small functions.  Starting with size 
%i.\n",
-initial_size);
- 
/* Compute overall unit size and other global parameters used by badness
   metrics.  */
  
max_count = 0;
-   initialize_growth_caches ();
  
FOR_EACH_DEFINED_FUNCTION (node)
  if (!node->global.inlined_to)
--- 1341,1350 
*** inline_small_functions (void)
*** 1355,1369 
--- 1353,1377 
|| node->thunk.thunk_p)
  {
struct inline_summary *info = inline_summary (node);
+   struct ipa_dfs_info *dfs = (struct ipa_dfs_info *) node->symbol.aux;
  
if (!DECL_EXTERNAL (node->symbol.decl))
  initial_size += info->size;
+   info->scc_no = (dfs && dfs->next_cycle && dfs->next_cycle != node
+   ? dfs->scc_no + 1 : 0);
  }
  
for (edge = node->callers; edge; edge = edge->next_caller)
  if (max_count < edge->count)
max_count = edge->count;
}
+   ipa_free_postorder_info ();
+   initialize_growth_caches ();

Re: [m68k] Fix option handling for -m68020-40 and -m68020-60

2012-10-28 Thread Gunther Nikl
Andreas Schwab wrote:
> Gunther Nikl  writes:
> 
>> The patch should be installed on trunk and on the 4.7 branch.
> 
> Thanks, done.  The 4.7 branch required some adjustment, since it's not
> compiled as C++.

Right. Maybe a better solution would have been then to only change
m68k.c/m68k_option_override to additionally check for -m68020-[46]0
in global_options_set when setting cpu and tune entries.

Thank you for taking care of the patch. Sorry that I didn't remember
to adjust the copyright year.

Regards,
Gunther Nikl



Re: Make inliner to take cgraph SCCs into account

2012-10-28 Thread Marc Glisse

On Sun, 28 Oct 2012, Jan Hubicka wrote:


Bootstrapped/regtested x86_64-linux.

Honza

* ipa-inline.c (edge_badness): Reduce precision; use scc hints.
(inline_small_functions): Fix dumps; update all callees after inlining.
* ipa-inline.h (INLINE_HINT_in_scc, INLINE_HINT_same_scc): New 
constants.
(inline summary): Add SCC_NO.
* ipa-inline-analysis.c (dump_inline_hints): Dump SCC hints.
(reset_inline_summary): Reset scc_no.
(estimate_node_size_and_time): Set in_scc hint.
(do_estimate_edge_time): Add same_scc hint.
(do_estimate_edge_hints): Likewise.


Hello,

I haven't tried bisecting or anything, but bootstrap is broken on
x86_64-linux:

libtool: compile:  /tmp/testgcc/pristine/build/./gcc/xgcc 
-B/tmp/testgcc/pristine/build/./gcc/ 
-B/tmp/testgcc/pristine/inst/x86_64-unknown-linux-gnu/bin/ 
-B/tmp/testgcc/pristine/inst/x86_64-unknown-linux-gnu/lib/ -isystem 
/tmp/testgcc/pristine/inst/x86_64-unknown-linux-gnu/include -isystem 
/tmp/testgcc/pristine/inst/x86_64-unknown-linux-gnu/sys-include -DHAVE_CONFIG_H 
-I.. -I/data/repos/gcc/pristine/libstdc++-v3/../libiberty 
-I/data/repos/gcc/pristine/libstdc++-v3/../include -D_GLIBCXX_SHARED 
-I/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
 -I/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3/include 
-I/data/repos/gcc/pristine/libstdc++-v3/libsupc++ -g -O2 -DIN_GLIBCPP_V3 
-Wno-error -c cp-demangle.c  -fPIC -DPIC -o cp-demangle.o
cp-demangle.c:5462:1: internal compiler error: in edge_badness, at 
ipa-inline.c:910
 }
 ^
0x1046ce7 edge_badness
/data/repos/gcc/pristine/gcc/ipa-inline.c:910
0x1046d33 update_edge_key
/data/repos/gcc/pristine/gcc/ipa-inline.c:922
0x1047fe6 inline_small_functions
/data/repos/gcc/pristine/gcc/ipa-inline.c:1399
0x1048cf9 ipa_inline
/data/repos/gcc/pristine/gcc/ipa-inline.c:1717
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
make[5]: *** [cp-demangle.lo] Error 1
make[5]: Leaving directory 
`/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory 
`/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3'
make[3]: *** [all] Error 2
make[3]: Leaving directory 
`/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3'
make[2]: *** [all-stage1-target-libstdc++-v3] Error 2
make[2]: Leaving directory `/tmp/testgcc/pristine/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/tmp/testgcc/pristine/build'
make: *** [all] Error 2


--
Marc Glisse


[C++ Patch] PR 54526 (again)

2012-10-28 Thread Paolo Carlini

Hi,

as pointed out in the audit trail, my first patch for this C++11 parsing 
issue was misguided: I changed cp_parser_template_id but in fact C++11 
wants new special *lexing* rules, which must be active outside templates 
too, as the additional test (and the old manded one) shows. Thus the below.


Tested x86_64-linux.

Thanks,
Paolo.


/libcpp
2012-10-28  Paolo Carlini  

PR c++/54526 (again)
* lex.c (_cpp_lex_direct): In C++11 mode, implement 2.5 p3, bullet 2.

/gcc/cp
2012-10-28  Paolo Carlini  

PR c++/54526 (again)
* parser.c (cp_parser_template_id): Revert core of previous change
(keep adjusted inform message).

/gcc/testsuite
2012-10-28  Paolo Carlini  

PR c++/54526 (again)
* g++.dg/cpp0x/parse2.C: Extend.
* g++.old-deja/g++.other/crash28.C: Adjust.
Index: gcc/cp/parser.c
===
--- gcc/cp/parser.c (revision 192887)
+++ gcc/cp/parser.c (working copy)
@@ -12655,9 +12655,8 @@ cp_parser_template_id (cp_parser *parser,
   /* Otherwise, emit an error about the invalid digraph, but continue
 parsing because we got our argument list.  In C++11 do not emit
 any error, per 2.5/3.  */
-  if (cxx_dialect < cxx0x
- && permerror (next_token->location,
-   "%<<::%> cannot begin a template-argument list"))
+  if (permerror (next_token->location,
+"%<<::%> cannot begin a template-argument list"))
{
  static bool hint = false;
  inform (next_token->location,
Index: gcc/testsuite/g++.dg/cpp0x/parse2.C
===
--- gcc/testsuite/g++.dg/cpp0x/parse2.C (revision 192887)
+++ gcc/testsuite/g++.dg/cpp0x/parse2.C (working copy)
@@ -10,3 +10,6 @@ int main()
 {
   X<::A> x;
 }
+
+int a;
+bool b = 0<::a;
Index: gcc/testsuite/g++.old-deja/g++.other/crash28.C
===
--- gcc/testsuite/g++.old-deja/g++.other/crash28.C  (revision 192887)
+++ gcc/testsuite/g++.old-deja/g++.other/crash28.C  (working copy)
@@ -31,5 +31,5 @@ class foo
 };
 void foo::x() throw(bar)
 {
-  if (!b) throw bar (static_cast<::N::X*>(this));  // { dg-error "lambda 
expressions|expected" } parse error
+  if (!b) throw bar (static_cast<::N::X*>(this));  // { dg-error "lambda 
expressions|expected|invalid" } parse error
 }
Index: libcpp/lex.c
===
--- libcpp/lex.c(revision 192887)
+++ libcpp/lex.c(working copy)
@@ -2291,6 +2291,25 @@ _cpp_lex_direct (cpp_reader *pfile)
  if (*buffer->cur == ':')
{
  buffer->cur++;
+
+ /* C++11 - 2.5 p3, bullet 2.  */
+ if (CPP_OPTION (pfile, cplusplus)
+ && (CPP_OPTION (pfile, lang) == CLK_CXX11
+ || CPP_OPTION (pfile, lang) == CLK_GNUCXX11))
+   {
+ if (*buffer->cur == ':')
+   {
+ buffer->cur++;
+ if (*buffer->cur != ':' && *buffer->cur != '>')
+   {
+ --buffer->cur;
+ --buffer->cur;
+ break;
+   }
+ --buffer->cur;
+   }
+   }
+
  result->flags |= DIGRAPH;
  result->type = CPP_OPEN_SQUARE;
}


[wwwdocs] Rewrite glibc list archive references

2012-10-28 Thread Gerald Pfeifer
...from sources.redhat.com to sourceware.org.

With that, there are only a few references left in java/ .

Gerald

Index: c99status.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/c99status.html,v
retrieving revision 1.58
diff -u -3 -p -r1.58 c99status.html
--- c99status.html  13 Mar 2012 23:11:38 -  1.58
+++ c99status.html  28 Oct 2012 11:03:53 -
@@ -326,11 +326,11 @@ expressions as required by C99.
 
 Compiler support is needed for thorough support of 
math_errhandling; see
 messages http://sources.redhat.com/ml/libc-hacker/2000-06/msg8.html";>1,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg8.html";>1,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00014.html";>2,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00014.html";>2,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00015.html";>3
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00015.html";>3
 on this subject to libc-hacker.  The compiler needs to mark its output
 from compilations using -fno-trapping-math
 or -fno-math-errno, possibly using
Index: gcc-3.0/c99status.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.0/c99status.html,v
retrieving revision 1.7
diff -u -3 -p -r1.7 c99status.html
--- gcc-3.0/c99status.html  29 Mar 2009 02:20:02 -  1.7
+++ gcc-3.0/c99status.html  28 Oct 2012 11:03:54 -
@@ -314,11 +314,11 @@ definitions.
 
 Compiler support is needed for math_errhandling; see
 messages http://sources.redhat.com/ml/libc-hacker/2000-06/msg8.html";>1,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg8.html";>1,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00014.html";>2,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00014.html";>2,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00015.html";>3
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00015.html";>3
 on this subject to libc-hacker.
 
 In some places, -pedantic warnings don't take proper
Index: gcc-3.1/c99status.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.1/c99status.html,v
retrieving revision 1.6
diff -u -3 -p -r1.6 c99status.html
--- gcc-3.1/c99status.html  29 Mar 2009 02:20:02 -  1.6
+++ gcc-3.1/c99status.html  28 Oct 2012 11:03:55 -
@@ -315,11 +315,11 @@ definitions.
 
 Compiler support is needed for math_errhandling; see
 messages http://sources.redhat.com/ml/libc-hacker/2000-06/msg8.html";>1,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg8.html";>1,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00014.html";>2,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00014.html";>2,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00015.html";>3
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00015.html";>3
 on this subject to libc-hacker.
 
 In some places, -pedantic warnings don't take proper
Index: gcc-3.3/c99status.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.3/c99status.html,v
retrieving revision 1.5
diff -u -3 -p -r1.5 c99status.html
--- gcc-3.3/c99status.html  29 Mar 2009 02:20:02 -  1.5
+++ gcc-3.3/c99status.html  28 Oct 2012 11:03:55 -
@@ -304,11 +304,11 @@ pragmas.
 
 Compiler support is needed for math_errhandling; see
 messages http://sources.redhat.com/ml/libc-hacker/2000-06/msg8.html";>1,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg8.html";>1,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00014.html";>2,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00014.html";>2,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00015.html";>3
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00015.html";>3
 on this subject to libc-hacker.
 
 In some places, -pedantic warnings don't take proper
Index: gcc-3.4/c99status.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.4/c99status.html,v
retrieving revision 1.4
diff -u -3 -p -r1.4 c99status.html
--- gcc-3.4/c99status.html  29 Mar 2009 02:20:02 -  1.4
+++ gcc-3.4/c99status.html  28 Oct 2012 11:03:56 -
@@ -304,11 +304,11 @@ pragmas.
 
 Compiler support is needed for math_errhandling; see
 messages http://sources.redhat.com/ml/libc-hacker/2000-06/msg8.html";>1,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg8.html";>1,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00014.html";>2,
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00014.html";>2,
 http://sources.redhat.com/ml/libc-hacker/2000-06/msg00015.html";>3
+href="http://sourceware.org/ml/libc-hacker/2000-06/msg00015.html";>3
 on this subject to libc-hacker.
 
 In some places, -pedantic warnings don't take proper
Index: gcc-4.0/c99status.html
==

Re: Make inliner to take cgraph SCCs into account

2012-10-28 Thread Jan Hubicka
> On Sun, 28 Oct 2012, Jan Hubicka wrote:
> 
> >Bootstrapped/regtested x86_64-linux.
> >
> >Honza
> >
> > * ipa-inline.c (edge_badness): Reduce precision; use scc hints.
> > (inline_small_functions): Fix dumps; update all callees after inlining.
> > * ipa-inline.h (INLINE_HINT_in_scc, INLINE_HINT_same_scc): New 
> > constants.
> > (inline summary): Add SCC_NO.
> > * ipa-inline-analysis.c (dump_inline_hints): Dump SCC hints.
> > (reset_inline_summary): Reset scc_no.
> > (estimate_node_size_and_time): Set in_scc hint.
> > (do_estimate_edge_time): Add same_scc hint.
> > (do_estimate_edge_hints): Likewise.
> 
> Hello,
> 
> I haven't tried bisecting or anything, but bootstrap is broken on
> x86_64-linux:

Hmm, sorry, that is indeed mine.  I am testing a fix.

Honza
> 
> libtool: compile:  /tmp/testgcc/pristine/build/./gcc/xgcc 
> -B/tmp/testgcc/pristine/build/./gcc/ 
> -B/tmp/testgcc/pristine/inst/x86_64-unknown-linux-gnu/bin/ 
> -B/tmp/testgcc/pristine/inst/x86_64-unknown-linux-gnu/lib/ -isystem 
> /tmp/testgcc/pristine/inst/x86_64-unknown-linux-gnu/include -isystem 
> /tmp/testgcc/pristine/inst/x86_64-unknown-linux-gnu/sys-include 
> -DHAVE_CONFIG_H -I.. -I/data/repos/gcc/pristine/libstdc++-v3/../libiberty 
> -I/data/repos/gcc/pristine/libstdc++-v3/../include -D_GLIBCXX_SHARED 
> -I/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
>  -I/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3/include 
> -I/data/repos/gcc/pristine/libstdc++-v3/libsupc++ -g -O2 -DIN_GLIBCPP_V3 
> -Wno-error -c cp-demangle.c  -fPIC -DPIC -o cp-demangle.o
> cp-demangle.c:5462:1: internal compiler error: in edge_badness, at 
> ipa-inline.c:910
>  }
>  ^
> 0x1046ce7 edge_badness
> /data/repos/gcc/pristine/gcc/ipa-inline.c:910
> 0x1046d33 update_edge_key
> /data/repos/gcc/pristine/gcc/ipa-inline.c:922
> 0x1047fe6 inline_small_functions
> /data/repos/gcc/pristine/gcc/ipa-inline.c:1399
> 0x1048cf9 ipa_inline
> /data/repos/gcc/pristine/gcc/ipa-inline.c:1717
> Please submit a full bug report,
> with preprocessed source if appropriate.
> Please include the complete backtrace with any bug report.
> See  for instructions.
> make[5]: *** [cp-demangle.lo] Error 1
> make[5]: Leaving directory 
> `/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++'
> make[4]: *** [all-recursive] Error 1
> make[4]: Leaving directory 
> `/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3'
> make[3]: *** [all] Error 2
> make[3]: Leaving directory 
> `/tmp/testgcc/pristine/build/x86_64-unknown-linux-gnu/libstdc++-v3'
> make[2]: *** [all-stage1-target-libstdc++-v3] Error 2
> make[2]: Leaving directory `/tmp/testgcc/pristine/build'
> make[1]: *** [stage1-bubble] Error 2
> make[1]: Leaving directory `/tmp/testgcc/pristine/build'
> make: *** [all] Error 2
> 
> 
> -- 
> Marc Glisse


Re: Make inliner to take cgraph SCCs into account

2012-10-28 Thread Jan Hubicka
> > On Sun, 28 Oct 2012, Jan Hubicka wrote:
> > 
> > >Bootstrapped/regtested x86_64-linux.
> > >
> > >Honza
> > >
> > >   * ipa-inline.c (edge_badness): Reduce precision; use scc hints.
> > >   (inline_small_functions): Fix dumps; update all callees after inlining.
> > >   * ipa-inline.h (INLINE_HINT_in_scc, INLINE_HINT_same_scc): New 
> > > constants.
> > >   (inline summary): Add SCC_NO.
> > >   * ipa-inline-analysis.c (dump_inline_hints): Dump SCC hints.
> > >   (reset_inline_summary): Reset scc_no.
> > >   (estimate_node_size_and_time): Set in_scc hint.
> > >   (do_estimate_edge_time): Add same_scc hint.
> > >   (do_estimate_edge_hints): Likewise.
> > 
> > Hello,
> > 
> > I haven't tried bisecting or anything, but bootstrap is broken on
> > x86_64-linux:
> 
> Hmm, sorry, that is indeed mine.  I am testing a fix.
Hi,
this is patch I comitted after regtesting and making sure that it gets past the 
failure
point in the bootstrap.  The issue s showing only on specific (most?) setups, 
it is an
overflow in badness metric.

I also constructed testcase for the hint and found out there are two cases I 
need
to deal with, too.  First the linked list holding SCC components is not cyclic,
this looks like a bug - I do not see how it can reliably work, but I will look 
into
that incrementaly. Second I do not want to handle simple recursion as SCCs since
those are understood by the inliner well, so when SCC gets collapsed into a 
single
node and self recursive edge is created, we ought to ignore its SCC flag.

Honza

* gcc.dg/ipa/inlinehint-3.c: New testcase.
* ipa-inline.c (edge_badness): Fix overflow.
(inline_small_functions): Initialize SCCs correctly.
(do_estimate_edge_time, do_estimate_edge_hints): Skip self
recursive ufnctions in SCC hints.
Index: testsuite/gcc.dg/ipa/inlinehint-3.c
===
*** testsuite/gcc.dg/ipa/inlinehint-3.c (revision 0)
--- testsuite/gcc.dg/ipa/inlinehint-3.c (revision 0)
***
*** 0 
--- 1,37 
+ /* { dg-options "-O3 -c -fdump-ipa-inline-details -fno-early-inlining 
-fno-ipa-cp"  } */
+ void abort (void);
+ int sum;
+ int a[10];
+ int
+ scc_next (int c)
+ {
+   int i;
+   for (i=0;i INT_MAX / 4)
{
! badness = INT_MAX / 4;
  if (dump)
fprintf (dump_file, "Badness overflow\n");
}
--- 861,869 
 We might mix the valud into the fraction by taking into account
 relative growth of the unit, but for now just add the number
 into resulting fraction.  */
!   if (badness > INT_MAX / 8)
{
! badness = INT_MAX / 8;
  if (dump)
fprintf (dump_file, "Badness overflow\n");
}
*** inline_small_functions (void)
*** 1360,1367 
  
if (!DECL_EXTERNAL (node->symbol.decl))
  initial_size += info->size;
!   info->scc_no = (dfs && dfs->next_cycle && dfs->next_cycle != node
!   ? dfs->scc_no + 1 : 0);
  }
  
for (edge = node->callers; edge; edge = edge->next_caller)
--- 1360,1378 
  
if (!DECL_EXTERNAL (node->symbol.decl))
  initial_size += info->size;
!   if (dfs && dfs->next_cycle)
! {
!   struct cgraph_node *n2;
!   int id = dfs->scc_no + 1;
!   for (n2 = node; n2;
!n2 = ((struct ipa_dfs_info *) 
node->symbol.aux)->next_cycle)
! {
!   struct inline_summary *info2 = inline_summary (n2);
!   if (info2->scc_no)
! break;
!   info2->scc_no = id;
! }
! }
  }
  
for (edge = node->callers; edge; edge = edge->next_caller)
Index: ipa-inline-analysis.c
===
*** ipa-inline-analysis.c   (revision 192888)
--- ipa-inline-analysis.c   (working copy)
*** dump_inline_summary (FILE * f, struct cg
*** 1375,1380 
--- 1375,1383 
   (int) s->estimated_self_stack_size);
fprintf (f, "  global stack:%i\n",
   (int) s->estimated_stack_size);
+   if (s->scc_no)
+ fprintf (f, "  In SCC:  %i\n",
+(int) s->scc_no);
for (i = 0;
   VEC_iterate (size_time_entry, s->entry, i, e);
   i++)
*** do_estimate_edge_time (struct cgraph_edg
*** 3348,3354 
VEC_index (edge_growth_cache_entry, edge_growth_cache, edge->uid).size
= size + (size >= 0);
if (inline_summary (to)->scc_no
! && inline_summary (to)->scc_no == inline_summary (callee)->scc_no)
hints |= INLINE_HINT_same_scc;
VEC_index (edge_growth_cache_entry, edge_growth_cache, edge->uid).hints
= hints + 1;
--- 3351,3358 
VEC_index (edge_growth_cache_entry, edge_growth_cache, edge->uid).size

PR libstdc++/55041 update python printers

2012-10-28 Thread Jonathan Wakely
This fixes part of PR 55041 by updating the hash table printers to
account for Francois's recent changes.

PR libstdc++/55041
* python/libstdcxx/v6/printers.py (Tr1UnorderedMapPrinter): Update
to handle hashtable as member of unordered_map not base class.
(Tr1UnorderedSetPrinter): Likewise.

Tested x86_64-linux and committed to trunk.
commit a554179e10f867f983ca1915455ceb23a9edad3d
Author: Jonathan Wakely 
Date:   Sun Oct 28 13:16:31 2012 +

PR libstdc++/55041
* python/libstdcxx/v6/printers.py (Tr1UnorderedMapPrinter): Update
to handle hashtable as member of unordered_map not base class.
(Tr1UnorderedSetPrinter): Likewise.

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py 
b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 0eac413..07a5ee6 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -633,8 +633,13 @@ class Tr1UnorderedSetPrinter:
 self.typename = typename
 self.val = val
 
+def hashtable (self):
+if self.typename.startswith('std::tr1'):
+return self.val
+return self.val['_M_h']
+
 def to_string (self):
-return '%s with %d elements' % (self.typename, 
self.val['_M_element_count'])
+return '%s with %d elements' % (self.typename, 
self.hashtable()['_M_element_count'])
 
 @staticmethod
 def format_count (i):
@@ -642,7 +647,7 @@ class Tr1UnorderedSetPrinter:
 
 def children (self):
 counter = itertools.imap (self.format_count, itertools.count())
-return itertools.izip (counter, Tr1HashtableIterator (self.val))
+return itertools.izip (counter, Tr1HashtableIterator 
(self.hashtable()))
 
 class Tr1UnorderedMapPrinter:
 "Print a tr1::unordered_map"
@@ -651,8 +656,13 @@ class Tr1UnorderedMapPrinter:
 self.typename = typename
 self.val = val
 
+def hashtable (self):
+if self.typename.startswith('std::tr1'):
+return self.val
+return self.val['_M_h']
+
 def to_string (self):
-return '%s with %d elements' % (self.typename, 
self.val['_M_element_count'])
+return '%s with %d elements' % (self.typename, 
self.hashtable()['_M_element_count'])
 
 @staticmethod
 def flatten (list):
@@ -671,7 +681,7 @@ class Tr1UnorderedMapPrinter:
 def children (self):
 counter = itertools.imap (self.format_count, itertools.count())
 # Map over the hash table and flatten the result.
-data = self.flatten (itertools.imap (self.format_one, 
Tr1HashtableIterator (self.val)))
+data = self.flatten (itertools.imap (self.format_one, 
Tr1HashtableIterator (self.hashtable(
 # Zip the two iterators together.
 return itertools.izip (counter, data)
 


real_zerop for vectors

2012-10-28 Thread Marc Glisse

Hello,

this patch lets some predicates on floating point constants answer true 
for vectors, so optimizations are applied.


Tested bootstrap + testsuite (default languages).

2012-10-29  Marc Glisse  

PR middle-end/55027

gcc/
* tree.c (real_zerop, real_onep, real_twop, real_minus_onep):
Handle VECTOR_CST.

testsuite/
* gcc.dg/pr55027.c: New testcase.

--
Marc GlisseIndex: gcc/testsuite/gcc.dg/pr55027.c
===
--- gcc/testsuite/gcc.dg/pr55027.c  (revision 0)
+++ gcc/testsuite/gcc.dg/pr55027.c  (revision 0)
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fdump-tree-optimized-raw" } */
+
+typedef double v2df __attribute__ ((__vector_size__ (2 * sizeof (double;
+
+void f (v2df *x)
+{
+  *x = 0 + 1 * *x;
+}
+
+/* { dg-final { scan-tree-dump-not "gimple_assign" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */

Property changes on: gcc/testsuite/gcc.dg/pr55027.c
___
Added: svn:keywords
   + Author Date Id Revision URL
Added: svn:eol-style
   + native

Index: gcc/tree.c
===
--- gcc/tree.c  (revision 192894)
+++ gcc/tree.c  (working copy)
@@ -1985,75 +1985,127 @@ tree_floor_log2 (const_tree expr)
 }
 
 /* Return 1 if EXPR is the real constant zero.  Trailing zeroes matter for
decimal float constants, so don't return 1 for them.  */
 
 int
 real_zerop (const_tree expr)
 {
   STRIP_NOPS (expr);
 
-  return ((TREE_CODE (expr) == REAL_CST
-  && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst0)
-  && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)
- || (TREE_CODE (expr) == COMPLEX_CST
- && real_zerop (TREE_REALPART (expr))
- && real_zerop (TREE_IMAGPART (expr;
+  switch (TREE_CODE (expr))
+{
+case REAL_CST:
+  return REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst0)
+&& !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr;
+case COMPLEX_CST:
+  return real_zerop (TREE_REALPART (expr))
+&& real_zerop (TREE_IMAGPART (expr));
+case VECTOR_CST:
+  {
+   unsigned i;
+   for (i = 0; i < VECTOR_CST_NELTS (expr); ++i)
+ if (!real_zerop (VECTOR_CST_ELT (expr, i)))
+   return false;
+   return true;
+  }
+default:
+  return false;
+}
 }
 
 /* Return 1 if EXPR is the real constant one in real or complex form.
Trailing zeroes matter for decimal float constants, so don't return
1 for them.  */
 
 int
 real_onep (const_tree expr)
 {
   STRIP_NOPS (expr);
 
-  return ((TREE_CODE (expr) == REAL_CST
-  && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst1)
-  && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)
- || (TREE_CODE (expr) == COMPLEX_CST
- && real_onep (TREE_REALPART (expr))
- && real_zerop (TREE_IMAGPART (expr;
+  switch (TREE_CODE (expr))
+{
+case REAL_CST:
+  return REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst1)
+&& !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr;
+case COMPLEX_CST:
+  return real_onep (TREE_REALPART (expr))
+&& real_zerop (TREE_IMAGPART (expr));
+case VECTOR_CST:
+  {
+   unsigned i;
+   for (i = 0; i < VECTOR_CST_NELTS (expr); ++i)
+ if (!real_onep (VECTOR_CST_ELT (expr, i)))
+   return false;
+   return true;
+  }
+default:
+  return false;
+}
 }
 
 /* Return 1 if EXPR is the real constant two.  Trailing zeroes matter
for decimal float constants, so don't return 1 for them.  */
 
 int
 real_twop (const_tree expr)
 {
   STRIP_NOPS (expr);
 
-  return ((TREE_CODE (expr) == REAL_CST
-  && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst2)
-  && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)
- || (TREE_CODE (expr) == COMPLEX_CST
- && real_twop (TREE_REALPART (expr))
- && real_zerop (TREE_IMAGPART (expr;
+  switch (TREE_CODE (expr))
+{
+case REAL_CST:
+  return REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst2)
+&& !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr;
+case COMPLEX_CST:
+  return real_twop (TREE_REALPART (expr))
+&& real_zerop (TREE_IMAGPART (expr));
+case VECTOR_CST:
+  {
+   unsigned i;
+   for (i = 0; i < VECTOR_CST_NELTS (expr); ++i)
+ if (!real_twop (VECTOR_CST_ELT (expr, i)))
+   return false;
+   return true;
+  }
+default:
+  return false;
+}
 }
 
 /* Return 1 if EXPR is the real constant minus one.  Trailing zeroes
matter for decimal float constants, so don't return 1 for them.  */
 
 int
 real_minus_onep (const_tree expr)
 {
   STRIP_NOPS (expr);
 
-  return ((TREE_CODE (expr) == REAL_CST
-  && REAL_VALUES_EQU

Ping: [PATCH] Install error handler for out-of-memory when using STL containers

2012-10-28 Thread Tobias Schlüter


Ping.  This issue stands in the way of a very simple solution of PR 
fortran/51727.  I've re-attached the patch for your convenience.


On 15 Oct 2012 at 22:51:05 +0200 Tobias Schlüter wrote:

The attached patch adds out-of-memory diagnostics for code using STL
containers by using set_new_handler. Since the intended allocation
size is not available to a new_handler, I had to forego a more
detailed error message such as the one from xmalloc_failed().
fatal_error() and abort() don't give a meaningful location when the
new_handler is called, so I chose to put together the error message
manually as is done in xmalloc_failed(). I would have found it more
appealing to have operator new call xmalloc() unless a custom
allocator is given, but I don't think there's a standard way of doing
this.

Built and tested on the C and Fortran testsuites. Ok for trunk?


Best regards,
- Tobi

2012-10-15  Tobias Schlüter  

* toplev.c: Add '#include '.
(cxx_out_of_memory): New function.
(general_init): Install cxx_out_of_memory as handler for
out-of-memory condition.
2012-10-15  Tobias Schlüter  

* toplev.c: Add '#include '.
(cxx_out_of_memory): New function.
(general_init): Install cxx_out_of_memory as handler for
out-of-memory condition.

diff --git a/gcc/toplev.c b/gcc/toplev.c
index 2c9329f..2e6248a 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -89,6 +89,8 @@ along with GCC; see the file COPYING3.  If not see
   declarations for e.g. AIX 4.x.  */
 #endif
 
+#include 
+
 static void general_init (const char *);
 static void do_compile (void);
 static void process_options (void);
@@ -1061,6 +1063,21 @@ open_auxiliary_file (const char *ext)
   return file;
 }
 
+
+/* Error handler for use with C++ memory allocation.  Will be
+   installed via std::set_new_handler().  */
+
+static void
+cxx_out_of_memory()
+{
+  fprintf (stderr,
+  "\n%s%sout of memory\n",
+  progname, *progname ? ": " : "");
+
+  xexit (1);
+}
+
+
 /* Initialization of the front end environment, before command line
options are parsed.  Signal handlers, internationalization etc.
ARGV0 is main's argv[0].  */
@@ -1074,6 +1091,8 @@ general_init (const char *argv0)
 --p;
   progname = p;
 
+  std::set_new_handler (cxx_out_of_memory);
+
   xmalloc_set_program_name (progname);
 
   hex_init ();


Re: real_zerop for vectors

2012-10-28 Thread Paolo Carlini

On 10/28/2012 04:14 PM, Marc Glisse wrote:

Hello,

this patch lets some predicates on floating point constants answer 
true for vectors, so optimizations are applied.

Great.

I wonder how are we doing lately in terms of function pointer inlining?! 
If the current optimizers can already able to smoothly inline real_zerop 
& co we could have a single helper function and avoid all this 
redundancy... In case, I suppose other code could also benefit.


Thanks,
Paolo.


*ping* Re: [Patch, Fortran] Fix some libgfortran issues found by coverity

2012-10-28 Thread Tobias Burnus

* ping *

On 16.10.2012 23:18, Tobias Burnus wrote:

In the Bessel-function algorithm, there was the useless code:
  ret->base_addr = ret->base_addr;

And in all files which included ifunction.m4 is such code:


iall_i4 (gfc_array_i4 * const restrict retarray,
...
if (len <= 0)
  *dest = 0;
else
...
}

miall_i4 (gfc_array_i4 * const restrict retarray,
...
  if (len <= 0)
return;
...
if (len <= 0)
  *dest = 0;
else

Hence, for the MASK version (m'name`), the second if condition is 
always false.


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

Tobias




*ping* Re: [Patch, Fortran] PR54958 - Allow ac-implied-do and data-implied-do with INTENT(IN)

2012-10-28 Thread Tobias Burnus

* ping *

On 19.10.2012 18:54, Tobias Burnus wrote:
gfortran's INTENT(IN) check was too strict for "do" variables. While a 
variable in the normal do-stmt and in an io-implied-do is in the scope 
and, hence, the variable may not be modified for a nonpointer 
intent(in) variable.


However, ac-implied-do and data-implied-do live in their own scope and 
hence INTENT(IN) doesn't apply to them. (Neither does it apply to the 
FORALL/DO CONCURRENT index-name, but that was already handled correctly.)


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

Tobias




Re: real_zerop for vectors

2012-10-28 Thread Paolo Carlini

On 10/28/2012 04:46 PM, Paolo Carlini wrote:

On 10/28/2012 04:14 PM, Marc Glisse wrote:

Hello,

this patch lets some predicates on floating point constants answer 
true for vectors, so optimizations are applied.

Great.

I wonder how are we doing lately in terms of function pointer 
inlining?! If the current optimizers can already able to smoothly 
inline real_zerop & co we could have a single helper function and 
avoid all this redundancy... In case, I suppose other code could also 
benefit.
Uhm, sorry, I didn't notice the functions are recursive. The situation 
seems hopeless, too bad.


Paolo.


Re: real_zerop for vectors

2012-10-28 Thread Marc Glisse

On Sun, 28 Oct 2012, Paolo Carlini wrote:


On 10/28/2012 04:46 PM, Paolo Carlini wrote:

On 10/28/2012 04:14 PM, Marc Glisse wrote:

Hello,

this patch lets some predicates on floating point constants answer true 
for vectors, so optimizations are applied.

Great.

I wonder how are we doing lately in terms of function pointer inlining?! If 
the current optimizers can already able to smoothly inline real_zerop & co


Inlining real_zerop can only happen in lto builds.

we could have a single helper function and avoid all this redundancy... In 
case, I suppose other code could also benefit.
Uhm, sorry, I didn't notice the functions are recursive. The situation seems 
hopeless, too bad.


The recursion has a bounded depth of 2 ;-)

It is true that we could have a single function in tree.c:
bool real_intcstp (const_tree, int);

with possible trivial wrappers in tree.h.

--
Marc Glisse


Re: *ping* Re: [Patch, Fortran] Fix some libgfortran issues found by coverity

2012-10-28 Thread Thomas Koenig

Hi Tobias,


* ping *

On 16.10.2012 23:18, Tobias Burnus wrote:

In the Bessel-function algorithm, there was the useless code:
  ret->base_addr = ret->base_addr;


The patch is OK.  Thanks a lot!

Thomas



Re: *ping* Re: [Patch, Fortran] PR54958 - Allow ac-implied-do and data-implied-do with INTENT(IN)

2012-10-28 Thread Thomas Koenig

Hi Tobias,


* ping *


This is OK. Thanks for the patch!

Thomas



Re: real_zerop for vectors

2012-10-28 Thread Marc Glisse

On Sun, 28 Oct 2012, Marc Glisse wrote:

[there are 4 real_*p that only differ by 1 character]


It is true that we could have a single function in tree.c:
bool real_intcstp (const_tree, int);


The helper function could even take a REAL_VALUE_TYPE as second 
argument, so the non-inline part doesn't have more work than currently.


Trying to also merge the real_*p predicates with the integer_*p predicates 
seems harder (in fancy C++, we'd have a number of ways of writing the code 
for complex and vectors only once, but I don't think we want to go there).



with possible trivial wrappers in tree.h.


--
Marc Glisse


Re: real_zerop for vectors

2012-10-28 Thread Paolo Carlini

Hi,

On 10/28/2012 05:51 PM, Marc Glisse wrote:

On Sun, 28 Oct 2012, Marc Glisse wrote:

[there are 4 real_*p that only differ by 1 character]


It is true that we could have a single function in tree.c:
bool real_intcstp (const_tree, int);


The helper function could even take a REAL_VALUE_TYPE as second 
argument, so the non-inline part doesn't have more work than currently.

I was writing something like the below.

Paolo.

/
Index: tree.c
===
--- tree.c  (revision 192887)
+++ tree.c  (working copy)
@@ -1984,20 +1984,39 @@ tree_floor_log2 (const_tree expr)
  : floor_log2 (low));
 }
 
+static int
+real_somep (const_tree expr, REAL_VALUE_TYPE dcst)
+{
+  STRIP_NOPS (expr);
+
+  switch (TREE_CODE (expr))
+{
+case REAL_CST:
+  return REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dcst)
+&& !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr;
+case COMPLEX_CST:
+  return real_somep (TREE_REALPART (expr), dcst)
+&& real_somep (TREE_IMAGPART (expr), dconst0);
+case VECTOR_CST:
+  {
+   unsigned i;
+   for (i = 0; i < VECTOR_CST_NELTS (expr); ++i)
+ if (!real_somep (VECTOR_CST_ELT (expr, i), dcst))
+   return false;
+   return true;
+  }
+default:
+  return false;
+}
+}
+
 /* Return 1 if EXPR is the real constant zero.  Trailing zeroes matter for
decimal float constants, so don't return 1 for them.  */
 
 int
 real_zerop (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
-  return ((TREE_CODE (expr) == REAL_CST
-  && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst0)
-  && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)
- || (TREE_CODE (expr) == COMPLEX_CST
- && real_zerop (TREE_REALPART (expr))
- && real_zerop (TREE_IMAGPART (expr;
+  return real_somep (expr, dconst0);
 }
 
 /* Return 1 if EXPR is the real constant one in real or complex form.
@@ -2007,14 +2026,7 @@ real_zerop (const_tree expr)
 int
 real_onep (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
-  return ((TREE_CODE (expr) == REAL_CST
-  && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst1)
-  && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)
- || (TREE_CODE (expr) == COMPLEX_CST
- && real_onep (TREE_REALPART (expr))
- && real_zerop (TREE_IMAGPART (expr;
+  return real_somep (expr, dconst1);
 }
 
 /* Return 1 if EXPR is the real constant two.  Trailing zeroes matter
@@ -2023,14 +2035,7 @@ real_onep (const_tree expr)
 int
 real_twop (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
-  return ((TREE_CODE (expr) == REAL_CST
-  && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst2)
-  && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)
- || (TREE_CODE (expr) == COMPLEX_CST
- && real_twop (TREE_REALPART (expr))
- && real_zerop (TREE_IMAGPART (expr;
+  return real_somep (expr, dconst2);
 }
 
 /* Return 1 if EXPR is the real constant minus one.  Trailing zeroes
@@ -2039,14 +2044,7 @@ real_twop (const_tree expr)
 int
 real_minus_onep (const_tree expr)
 {
-  STRIP_NOPS (expr);
-
-  return ((TREE_CODE (expr) == REAL_CST
-  && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconstm1)
-  && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)
- || (TREE_CODE (expr) == COMPLEX_CST
- && real_minus_onep (TREE_REALPART (expr))
- && real_zerop (TREE_IMAGPART (expr;
+  return real_somep (expr, dconstm1);
 }
 
 /* Nonzero if EXP is a constant or a cast of a constant.  */


Re: real_zerop for vectors

2012-10-28 Thread Marc Glisse

On Sun, 28 Oct 2012, Paolo Carlini wrote:


I was writing something like the below.


I would move the one-liners (real_zerop, etc) to tree.h, but that looks 
good, yes.


--
Marc Glisse


Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-10-28 Thread Joern Rennecke

Quoting Andreas Schwab :

+These flags are automatically generated;  you should not override   
them in tm.c:


Typo: s/:$/./, also @file{tm.c}.


Thanks.  I have re-bootstrapped the amended patch on i686-pc-linux-gnu.
2012-10-28  Joern Rennecke  

* doc/md.texi (Defining Attributes): Document that we are defining
HAVE_ATTR_name macors as 1 for defined attributes, and as 0
for undefined special attributes.
* doc/tm.texi.in: Add @hook TARGET_HAVE_CC0.
* doc/tm.texi: Regenerate.
* final.c (asm_insn_count, align_fuzz): Always define.
(insn_current_reference_address): Likewise.
(init_insn_lengths): Use if (HAVE_ATTR_length) instead of
#ifdef HAVE_ATTR_length.
(get_attr_length_1, shorten_branches, final): Likewise.
(final_scan_insn, output_asm_name): Likewise.
* genattr.c (gen_attr): Define HAVE_ATTR_name macros for
defined attributes as 1.
Remove ancient get_attr_alternative compatibility code.
For special purpose attributes not provided, define HAVE_ATTR_name
as 0.
In case no length attribute is given, provide stub definitions
for insn_*_length* functions, and also include insn-addr.h.
In case no enabled attribute is given, provide stub definition.
* genattrtab.c (write_length_unit_log): Always write a definition.
* hooks.c (hook_int_rtx_1): New function.
* hooks.h (hook_int_rtx_1): Declare.
* lra-int.h (struct lra_insn_recog_data): Make member
alternative_enabled_p unconditional.
* lra.c (free_insn_recog_data): Use if (HAVE_ATTR_length) instead of
#ifdef HAVE_ATTR_length.
(lra_set_insn_recog_data): Likewise.  Make initialization of
alternative_enabled_p unconditional.
(lra_update_insn_recog_data): Use #if instead of #ifdef for
HAVE_ATTR_enabled.
* recog.c [!HAVE_ATTR_enabled] (get_attr_enabled): Don't define.
(extract_insn): Check HAVE_ATTR_enabled.
(gate_handle_split_before_regstack): Use #if instead of
#if defined for HAVE_ATTR_length.
* gcc/target-def.h: Provide definitions for TARGET_HAVE_CC0,
TARGET_AUTO_INC_DEC, TARGET_STACK_REGS, TARGET_HAVE_ATTR_LENGTH
and TARGET_HAVE_ATTR_ENABLED.
* target.def (have_cc0, auto_inc_dec): New flags in target structure.
(stack_regs, have_attr_enabled, have_attr_length): Likewise.

Index: gcc/doc/md.texi
===
--- gcc/doc/md.texi (revision 192840)
+++ gcc/doc/md.texi (working copy)
@@ -7558,7 +7558,7 @@ (define_attr "type" "branch,fp,load,stor
 the following lines will be written to the file @file{insn-attr.h}.
 
 @smallexample
-#define HAVE_ATTR_type
+#define HAVE_ATTR_type 1
 enum attr_type @{TYPE_BRANCH, TYPE_FP, TYPE_LOAD,
  TYPE_STORE, TYPE_ARITH@};
 extern enum attr_type get_attr_type ();
@@ -7583,6 +7583,10 @@ extern enum attr_type get_attr_type ();
 generation. @xref{Disable Insn Alternatives}.
 @end table
 
+For each of these special attributes, the corresponding
+@samp{HAVE_ATTR_@var{name}} @samp{#define} is also written when the
+attribute is not defined; in that case, it is defined as @samp{0}.
+
 @findex define_enum_attr
 @anchor{define_enum_attr}
 Another way of defining an attribute is to use:
Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi (revision 192840)
+++ gcc/doc/tm.texi (working copy)
@@ -11333,3 +11333,11 @@ @deftypefn {Target Hook} {unsigned HOST_
 @deftypevr {Target Hook} {unsigned char} TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
 This value should be set if the result written by @code{atomic_test_and_set} 
is not exactly 1, i.e. the @code{bool} @code{true}.
 @end deftypevr
+
+@deftypevr {Target Hook} bool TARGET_HAVE_CC0
+@deftypevrx {Target Hook} {bool} TARGET_AUTO_INC_DEC
+@deftypevrx {Target Hook} {bool} TARGET_STACK_REGS
+@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_ENABLED
+@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_LENGTH
+These flags are automatically generated;  you should not override them in 
@file{tm.c}.
+@end deftypevr
Index: gcc/doc/tm.texi.in
===
--- gcc/doc/tm.texi.in  (revision 192840)
+++ gcc/doc/tm.texi.in  (working copy)
@@ -11173,3 +11173,5 @@ @hook TARGET_MEMMODEL_CHECK
 @end deftypefn
 
 @hook TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
+
+@hook TARGET_HAVE_CC0
Index: gcc/final.c
===
--- gcc/final.c (revision 192840)
+++ gcc/final.c (working copy)
@@ -204,9 +204,7 @@ Software Foundation; either version 3, o
 /* True if printing into -fdump-final-insns= dump.  */   
 bool final_insns_dump_p;
 
-#ifdef HAVE_ATTR_length
 static int asm_insn_count (rtx);
-#endif
 static void profile_function (FILE *);
 static void profile_after_prologue (FILE *)

RFA: hookize ADJUST_INSN_LENGTH (Was: RFA: Add lock_lenth attribute to support the ARC port)

2012-10-28 Thread Joern Rennecke

Quoting Richard Biener :


Thus, you can allow the length to vary downwards as well as upwards
across iterations with suitable definitions of the @code{length} attribute
and/or @code{ADJUST_INSN_LENGTH}.  Care has to be taken that this does not
lead to infinite loops.


I don't see that you can shrink length with just suitable lock_length and
length attributes.


I disagree there (for certain values of 'just'), but we can just agree
to disagree on this point because...


 What seems to be the cruical difference is that you
apply ADJUST_INSN_LENGTH after combining lock-length-max and length.
But then you _decrease_ length with ADJUST_INSN_LENGHT ...

Maybe what you really want is ADJUST_INSN_LENGTH_AFTER which is
applied afterwards?  Thus,


Well, actually, I found a number of problems with ADJUST_INSN_LENGTH:
- it is not applied to inner insn is a delay slot sequence.  You can
  sort of work around this by stitching recursive calls together, but
  then you are faced with another problem:
- You don't know what the length prior to ADJUST_INSN_LENGTH was.  That
  was even worse with the non-unique uids where you didn't knew squat
  about the instructions in the delay slot.
- As you said, I want the adjustment happen after the maximum calculation.
  Well, usually.  There are actually special cases where it would be useful
  to have some sort of maximum calculation in place, to break up
  alignment-driven cycles, but only applicable with a lesser priority than
  for the range-driven branch offset calculations.

But adding yet another macro neither does solve all these problems, nor
would it align with our goal to move away from target macros.

I found now an alternate way to make the ARC port termiante building its
insn-attrtab.c - it involves using match_test("get_attr_length (insn) == 2")
instead of eq_attr("[lock_]length" (const_int 2)) - where I really want to
know if the instruction was considered short in the previous iteration.

So, I have made a patch to replace the ADJUST_INSN_LENGTH macro in final.c
with an adjust_insn_length hook, for which a default implementation
using ADJUST_INSN_LENGTH is provided in targhooks.c to provide for an
easy transition.
I've looked at the existing ports that use ADJUST_INSN_LENGTH, and some
seem to prefer to return an adjustment to be added to the length, while
others prefer to return the new length.  The latter seemed to be slightly
more numerous, so I went with that.

The hook has two new parameters:
- a flag that tells it if the insn in question is a delay sequence.
  The default hook implementation skips the invocation of ADJUST_INSN_LENGTH
  in this case for the sake of compatibility.
- a pointer to int to set the number of iteration loops till the length
  locking feature is supposed to apply to this instruction length when
  using the increasing size calculations.  The pointed-to value is initialized
  to zero, which means that length locking is always applied (assuming final.c
  uses the increasing length algorithm).  Setting this to a higher number
  effectively gives the new instruction length a lower priority to be put
  into uid_lock_length.


Note that


Care has to be taken that this does not
lead to infinite loops.


doesn't convince me that is properly designed ;)


With the hook mechanism, it is much harder to create an infinite loop
inside shorten_branches.  (It would involve something like setting
 iteration_threshold to MAX_INT and making length decreasing when niter
 is at MAX_INT, then letting integer overflow of niter take its course.
 Making it impossible for a port maintainer to get things wrong is not a
 meaningful goal for GCC, but making it straightforward to get it right is.)

This patch builds on:
http://gcc.gnu.org/ml/gcc-patches/2012-10/msg02527.html

Bootstrapped in revision 192879 on i686-pc-linux-gnu.
Tested with config-list.mk on x86_64-unknown-linux-gnu.
2012-10-28  Joern Rennecke  

* doc/tm.texi.in (@hook TARGET_ADJUST_INSN_LENGTH): Add.
* doc/tm.texi: Regenerate. 
* final.c (get_attr_length_1): Use targetm.adjust_insn_length
instead of ADJUST_INSN_LENGTH.
(adjust_length): New function.
(shorten_branches): Use adjust_length instead of ADJUST_INSN_LENGTH.
* target.def (adjust_insn_length): New hook.
* targhooks.c (default_adjust_insn_length): New function.
* targhooks.h (default_adjust_insn_length): Declare.

diff -drup gcc-192879-haveattr/doc/tm.texi gcc/doc/tm.texi
--- gcc-192879-haveattr/doc/tm.texi 2012-10-28 01:07:38.463469923 +
+++ gcc/doc/tm.texi 2012-10-28 01:31:15.57927 +
@@ -11341,3 +11341,7 @@ This value should be set if the result w
 @deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_LENGTH
 These flags are automatically generated;  you should not override them in tm.c:
 @end deftypevr
+
+@deftypefn {Target Hook} int TARGET_ADJUST_INSN_LENGTH (rtx @var{insn}, int 
@var{length}, bool @var{in_delay_sequence}, int *@var{iteration_thr

Re: real_zerop for vectors

2012-10-28 Thread Paolo Carlini

On 10/28/2012 06:06 PM, Marc Glisse wrote:

On Sun, 28 Oct 2012, Paolo Carlini wrote:


I was writing something like the below.


I would move the one-liners (real_zerop, etc) to tree.h, but that 
looks good, yes.
Ah great. But please, don't wait on me, I'm in the middle of too many 
other things, if you like the idea just integrate it with your other 
work in this area and go ahead!


Cheers,
Paolo.


Re: [PATCH] Fix CDDCE miscompilation (PR tree-optimization/55018)

2012-10-28 Thread Steven Bosscher
On Mon, Oct 22, 2012 at 11:09 PM, Jakub Jelinek wrote:
> On Mon, Oct 22, 2012 at 10:51:43PM +0200, Steven Bosscher wrote:
> Wouldn't it be way cheaper to just export dfs_find_deadend from cfganal.c
> and call it in calc_dfs_tree on each unconnected bb?
> I.e. (untested with the exception of the testcase):
>
> 2012-10-22  Jakub Jelinek  
>
> PR tree-optimization/55018
> * cfganal.c (dfs_find_deadend): No longer static.
> * basic-block.h (dfs_find_deadend): New prototype.
> * dominance.c (calc_dfs_tree): If saw_unconnected,
> traverse from dfs_find_deadend of unconnected b
> instead of b directly.
>
> * gcc.dg/torture/pr55018.c: New test.

I have no better solution than this for the moment. I thought there
was a common DFS machinery in cfganal.c but there are actually many of
them, but unfortunately all doing things slightly different. Something
for the cleanup list for GCC 4.9...

We should use dfs_find_deadend in flow_dfs_compute_reverse_execute
also. This results in fewer fake edges created in
connect_infinite_loops_to_exit, especially for loops with multiple
dead ends.

(BTW, connect_infinite_loops_to_exit also connects other
reverse-unreachable points in the CFG to EXIT, so that calling
add_noreturn_fake_exit_edges and connect_infinite_loops_to_exit is
doing a bit of duplicate work -- another thing for the cleanup
list...)

Attached patch was bootstrapped&tested on
{powerpc64,x86_64}-unknown-linux-gnu. OK?

Ciao!
Steven


PR55018.diff
Description: Binary data


patch to remove temporary clobbers in LRA

2012-10-28 Thread Vladimir Makarov
  Working on a problem where var-tracking started to spend more time 
after LRA is switched on, I found that LRA creates significant # 
clobbers for x86 code (I saw 20% of all insns). Clobbers are created for 
correct live range analysis in LRA in cases when matching pseudos of 
*different modes* should be in the same hard register.
  As these clobbers are not needed anymore after LRA, the following 
patch removes them.


  Unfortunately, it does not solve the problem I mentioned.  Now, LRA 
generates approximately the same # of insns and debug_insn.  Moreover, 
two functions (canonicalize_values_star and set_slot_part) in 
var-tracking spending most of time have approximately the same coverage, 
in other words numbers of execution for each line are the same 
(differences < 1%).  Still var-tracking after LRA spent on 20% more time 
than after reload. I have no idea what to investigate more but I'll 
continue my work on the problem next week.


  The patch was successfully bootstrapped on x86/x86-64.

  Committed as rev. 192897.

2012-10-28  Vladimir Makarov  

* rtl.h (struct rtx_def): Add a comment for member unchanging.
* lra-int.h (LRA_TEMP_CLOBBER_P): New macro.
(lra_hard_reg_substitution): Rename to lra_final_code_change.
* lra-constraints.c (match_reload): Mark temporary clobbers.
* lra-spill.c (lra_hard_reg_substitution): Rename to
lra_final_code_change.  Remove temporary clobbers.
* lra.c (lra): Rename to lra_final_code_change.

Index: rtl.h
===
--- rtl.h   (revision 192896)
+++ rtl.h   (working copy)
@@ -283,7 +283,8 @@ struct GTY((chain_next ("RTX_NEXT (&%h)"
  1 in a NOTE, or EXPR_LIST for a const call.
  1 in a JUMP_INSN of an annulling branch.
  1 in a CONCAT is VAL_EXPR_IS_CLOBBERED in var-tracking.c.
- 1 in a preserved VALUE is PRESERVED_VALUE_P in cselib.c.  */
+ 1 in a preserved VALUE is PRESERVED_VALUE_P in cselib.c.
+ 1 in a clobber temporarily created for LRA.  */
   unsigned int unchanging : 1;
   /* 1 in a MEM or ASM_OPERANDS expression if the memory reference is volatile.
  1 in an INSN, CALL_INSN, JUMP_INSN, CODE_LABEL, BARRIER, or NOTE
Index: lra.c
===
--- lra.c   (revision 192896)
+++ lra.c   (working copy)
@@ -2334,7 +2334,7 @@ lra (FILE *f)
 }
   restore_scratches ();
   lra_eliminate (true);
-  lra_hard_reg_substitution ();
+  lra_final_code_change ();
   lra_in_progress = 0;
   lra_clear_live_ranges ();
   lra_live_ranges_finish ();
Index: lra-constraints.c
===
--- lra-constraints.c   (revision 192896)
+++ lra-constraints.c   (working copy)
@@ -663,7 +663,7 @@ match_reload (signed char out, signed ch
  rtx *before, rtx *after)
 {
   int i, in;
-  rtx new_in_reg, new_out_reg, reg;
+  rtx new_in_reg, new_out_reg, reg, clobber;
   enum machine_mode inmode, outmode;
   rtx in_rtx = *curr_id->operand_loc[ins[0]];
   rtx out_rtx = *curr_id->operand_loc[out];
@@ -694,8 +694,10 @@ match_reload (signed char out, signed ch
new_in_reg = gen_rtx_SUBREG (inmode, reg, 0);
  /* NEW_IN_REG is non-paradoxical subreg.  We don't want
 NEW_OUT_REG living above.  We add clobber clause for
-this.  */
- emit_clobber (new_out_reg);
+this.  This is just a temporary clobber.  We can remove
+it at the end of LRA work.  */
+ clobber = emit_clobber (new_out_reg);
+ LRA_TEMP_CLOBBER_P (PATTERN (clobber)) = 1;
}
 }
   else
Index: lra-int.h
===
--- lra-int.h   (revision 192896)
+++ lra-int.h   (working copy)
@@ -241,6 +241,10 @@ struct lra_insn_recog_data
 
 typedef struct lra_insn_recog_data *lra_insn_recog_data_t;
 
+/* Whether the clobber is used temporary in LRA.  */
+#define LRA_TEMP_CLOBBER_P(x) \
+  (RTL_FLAG_CHECK1 ("TEMP_CLOBBER_P", (x), CLOBBER)->unchanging)
+
 /* lra.c: */
 
 extern FILE *lra_dump_file;
@@ -346,7 +350,7 @@ extern bool lra_coalesce (void);
 
 extern bool lra_need_for_spills_p (void);
 extern void lra_spill (void);
-extern void lra_hard_reg_substitution (void);
+extern void lra_final_code_change (void);
 
 
 /* lra-elimination.c: */
Index: lra-spills.c
===
--- lra-spills.c(revision 192896)
+++ lra-spills.c(working copy)
@@ -614,13 +614,13 @@ alter_subregs (rtx *loc, bool final_p)
 }
 
 /* Final change of pseudos got hard registers into the corresponding
-   hard registers.  */
+   hard registers and removing temporary clobbers.  */
 void
-lra_hard_reg_substitution (void)
+lra_final_code_change (void)
 {
   int i, hard_regno;
   basic_block bb;
-  rtx insn;
+  rtx insn, curr;
   int max_regno = max_reg_num ();
 
   for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)

Re: patch to remove temporary clobbers in LRA

2012-10-28 Thread Steven Bosscher
On Sun, Oct 28, 2012 at 9:06 PM, Vladimir Makarov wrote:
>   Unfortunately, it does not solve the problem I mentioned.  Now, LRA
> generates approximately the same # of insns and debug_insn.  Moreover, two
> functions (canonicalize_values_star and set_slot_part) in var-tracking
> spending most of time have approximately the same coverage, in other words
> numbers of execution for each line are the same (differences < 1%).  Still
> var-tracking after LRA spent on 20% more time than after reload. I have no
> idea what to investigate more but I'll continue my work on the problem next
> week.

Well, it may be more fruitful to see why var-tracking is so slow. The
problem existed before LRA was merged, it's just triggered more often
after the LRA merge. But the real problem is var-tracking.

Ciao!
Steven


Re: [PR38711] Use DF_LIVE in IRA if it available (for -O2 and higher)

2012-10-28 Thread Vladimir Makarov

On 12-10-27 6:07 PM, Steven Bosscher wrote:

On Sat, Oct 27, 2012 at 11:49 PM, Steven Bosscher wrote:

So I'm going to revert this patch.

Or actually better, this lighter-weight patch. Will commit after the
usual testing.


I returned to this problem several times and every time I failed to use 
LIVE info (may be I was not so persistent to solve the problem or had 
few time for this).  Your problem description helped me to remember what 
I saw many years ago.


May be this patch is even better because we don't need to spend time to 
calculate DF_LIVE although as Kenny wrote DF_LIVE might help for extreme 
tests as DF_LIVE is more compact than DF_LR.




Re: committed: Fix WORDS_BIG_ENDIAN use in lra-assign.c:find_hard_regno_for

2012-10-28 Thread Vladimir Makarov

On 12-10-27 11:34 AM, Joern Rennecke wrote:

Bootstrapped (c,c++) on i686-pc-linux-gnu.

Committed as obvious.

Thanks, Joern.



[wwwdocs] gcc-4.8/changes.html markup consistency

2012-10-28 Thread Gerald Pfeifer
Installed.

Gerald

Index: changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.8/changes.html,v
retrieving revision 1.48
diff -u -3 -p -r1.48 changes.html
--- changes.html21 Oct 2012 11:01:37 -  1.48
+++ changes.html28 Oct 2012 18:36:07 -
@@ -133,10 +133,10 @@ B b(42); // OK
 
   
 
-  G++ now supports a -std=c++1y option for experimentation
+  G++ now supports a >-std=c++1y option for experimentation
 with features proposed for the next revision of the standard, expected
-around 2017.  Currently the only difference from -std=c++11 is
-support for return type deduction in normal functions, as proposed in 
+around 2017.  Currently the only difference from -std=c++11
+is support for return type deduction in normal functions, as proposed in 
 http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3386.html";>N3386.
 
 


[patch, RFC] PR 30146, warning/errors for potentially changing values in DO loops

2012-10-28 Thread Thomas Koenig

Hello world,

the attached patch, which is not in its final stage, implements some
warnings for index variables of DO loops. For the following situations,
errors/warnings are issued when an index loop variable is
passed as an actual argument:

- If the dummy argument has INTENT(OUT). I think an error should be
  issued unconditionally.

- If the dummy argument has INTENT(INOUT). My opinion is that
  a warning should be issued unconditionally, but I am open
  to the opinions that an error would be better, or that it should
  depend on an option.

- If the dummy argument has no INTENT, or if the procedure has no
  explicit interface, I think that there should be a warning
  depending on an option (which I haven't yet implemented).

Opinions?  If there is agreement on the question of which options should
select which errors/warnings, then I will submit a final patch including
some more comments, a ChangeLog entry and a deja-gnuified test case.

Thomas

Index: frontend-passes.c
===
--- frontend-passes.c	(Revision 192894)
+++ frontend-passes.c	(Arbeitskopie)
@@ -39,6 +39,7 @@ static bool optimize_trim (gfc_expr *);
 static bool optimize_lexical_comparison (gfc_expr *);
 static void optimize_minmaxloc (gfc_expr **);
 static bool empty_string (gfc_expr *e);
+static void do_warn (gfc_namespace *);
 
 /* How deep we are inside an argument list.  */
 
@@ -76,12 +77,29 @@ static bool in_omp_workshare;
 
 static int iterator_level;
 
-/* Entry point - run all passes for a namespace.  So far, only an
-   optimization pass is run.  */
+/* Keep track of DO loop levels.  */
 
+static gfc_code **do_list;
+static int do_size, do_level;
+
+/* Vector of gfc_expr * to keep track of DO loops.  */
+
+struct my_struct *evec;
+
+/* Entry point - run all passes for a namespace. */
+
 void
 gfc_run_passes (gfc_namespace *ns)
 {
+
+  /* Warn about dubious DO loops where the index might
+ change.  */
+
+  do_size = 20;
+  do_list = XNEWVEC(gfc_code *, do_size);
+  do_warn (ns);
+  XDELETEVEC (do_list);
+
   if (gfc_option.flag_frontend_optimize)
 {
   expr_size = 20;
@@ -605,6 +623,7 @@ optimize_namespace (gfc_namespace *ns)
   current_ns = ns;
   forall_level = 0;
   iterator_level = 0;
+  do_level = 0;
   in_omp_workshare = false;
 
   gfc_code_walker (&ns->code, convert_do_while, dummy_expr_callback, NULL);
@@ -1225,6 +1244,157 @@ optimize_minmaxloc (gfc_expr **e)
   mpz_set_ui (a->expr->value.integer, 1);
 }
 
+static int
+do_code (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED,
+	 void *data ATTRIBUTE_UNUSED)
+{
+  gfc_code *co;
+  int i;
+  gfc_formal_arglist *f;
+  gfc_actual_arglist *a;
+
+  co = *c;
+
+  switch (co->op)
+{
+case EXEC_DO:
+  if (do_level >= do_size)
+	{
+	  do_size = 2 * do_size;
+	  do_list = XRESIZEVEC (gfc_code *, do_list, do_size);
+	}
+
+  if (co->ext.iterator && co->ext.iterator->var)
+	do_list[do_level] = co;
+  else
+	do_list[do_level] = NULL;
+  break;
+
+case EXEC_CALL:
+  a = co->ext.actual;
+  f = co->symtree->n.sym->formal;
+
+  while (a)
+	{
+	  for (i=0; iext.iterator->var->symtree->n.sym;
+	  
+	  if (a->expr && a->expr->symtree
+		  && a->expr->symtree->n.sym == do_sym)
+		{
+		  if (f)
+		{
+		  if (f->sym->attr.intent == INTENT_OUT)
+			gfc_error_now("Variable '%s' at %L redefined inside loop "
+  "beginning at %L as INTENT(OUT) argument to "
+  "subroutine '%s'", do_sym->name, &a->expr->where,
+  &do_list[i]->loc, co->symtree->n.sym->name);
+		  else if (f->sym->attr.intent == INTENT_INOUT)
+			gfc_warning_now("Variable '%s' at %L may redefined inside loop "
+	"beginning at %L as INTENT(INOUT) argument to "
+	"subroutine '%s'", do_sym->name, &a->expr->where,
+	&do_list[i]->loc, co->symtree->n.sym->name);
+		  else if (f->sym->attr.intent == INTENT_UNKNOWN)
+			gfc_warning_now("Variable '%s' at %L may redefined inside loop "
+	"beginning at %L as argument to "
+	"subroutine '%s'", do_sym->name, &a->expr->where,
+	&do_list[i]->loc, co->symtree->n.sym->name);
+		}
+		  else
+		gfc_warning_now("Variable '%s' at %L may redefined inside loop "
+"beginning at %L as argument to "
+"subroutine '%s'", do_sym->name, &a->expr->where,
+&do_list[i]->loc, co->symtree->n.sym->name);
+		}
+	}
+	  a = a->next;
+	  if (f)
+	f = f->next;
+	}
+  break;
+
+default:
+  break;
+}
+  return 0;
+}
+
+static int
+do_function (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED,
+	 void *data ATTRIBUTE_UNUSED)
+{
+  gfc_formal_arglist *f;
+  gfc_actual_arglist *a;
+  gfc_expr *expr;
+  int i;
+
+  expr = *e;
+  if (expr->expr_type != EXPR_FUNCTION)
+return 0;
+
+  /* Intrinsic functions don't modify their arguments.  */
+
+  if (expr->value.function.isym)
+return 0;
+
+  a = expr->value.function.actual;
+  f = expr->symtree->n.sym->formal;
+
+  while (a)
+ 

Re: [wwwdocs] gcc-4.8/changes.html markup consistency

2012-10-28 Thread Andreas Schwab
Gerald Pfeifer  writes:

> +  G++ now supports a >-std=c++1y option for experimentation

Fixed the typo.

Andreas.

--- changes.html.~1.49.~2012-10-28 22:11:57.0 +0100
+++ changes.html2012-10-28 22:12:37.0 +0100
@@ -133,7 +133,7 @@ B b(42); // OK
 
   
 
-  G++ now supports a >-std=c++1y option for experimentation
+  G++ now supports a -std=c++1y option for experimentation
 with features proposed for the next revision of the standard, expected
 around 2017.  Currently the only difference from -std=c++11
 is support for return type deduction in normal functions, as proposed in 

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


[wwwdocs,Java] Some build-snapshot.html updates

2012-10-28 Thread Gerald Pfeifer
While working on the sources->sourceware transition, I noticed
some not directly related items and went ahead and addressed
them.  Committed.

2012-10-28  Gerald Pfeifer  
 
* build-snapshot.html: Refer to GNU/Linux, simplify link to
installation documentation, remove reference to an old FAQ,
some editorial changes.

Index: build-snapshot.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/java/build-snapshot.html,v
retrieving revision 1.17
diff -u -3 -p -r1.17 build-snapshot.html
--- build-snapshot.html 29 Oct 2011 19:35:05 -  1.17
+++ build-snapshot.html 27 Oct 2012 19:01:44 -
@@ -6,7 +6,7 @@
 
 
 
-Howto build and run libgcj/gcj snapshots or checkouts
+How to build and run libgcj/gcj snapshots or checkouts
 
 
 
@@ -72,17 +72,13 @@
 
 The Boehm GC is the collector picked up by default.
 
-If you compile under Linux you could omit the last two options. Under
+If you compile under GNU/Linux you could omit the last two options. Under
 Solaris you'll need them. If you omit '--prefix' the compiled source
 will be installed under /usr/local. For more information about
 installing gcc and/or configuration options see:
 
-  http://gcc.gnu.org/install/index.html";>http://gcc.gnu.org/install/index.html
+  http://gcc.gnu.org/install/";>http://gcc.gnu.org/install/
 
-If you have a broken gas/bin-utils (such as Debian potato) then you
-want to edit the auto-host.h file and remove the definition of
-HAVE_GAS_HIDDEN after configuring, but before typeing make.  See
-the FAQ for more information.
 
 
 
@@ -92,14 +88,11 @@ HAVE_GAS_HIDDEN after configuring, but b
 
 6. Adjust your environment
 
-Reflect your choice of --prefix value to your environment. It depends
-on which shell you're running. For csh compatible shells, edit a file
-env.csh:
+Reflect your choice of --prefix value to your environment. For csh
+compatible shells, this would be something like the following:
 
 setenv PATH /home/joerg/gcc/bin:$PATH
 setenv LD_LIBRARY_PATH /home/joerg/gcc/lib
-
-  $ source env.csh
 
 
 


Re: [wwwdocs] gcc-4.8/changes.html markup consistency

2012-10-28 Thread Gerald Pfeifer
On Sun, 28 Oct 2012, Andreas Schwab wrote:
>> +  G++ now supports a >-std=c++1y option for experimentation
> Fixed the typo.

Thanks, Andreas!  The validator did not complain -- which shows
that a pair of human eyes _is_ valuable. :-)

Gerald


Re: [wwwdocs] changes.html update

2012-10-28 Thread Gerald Pfeifer
On Wed, 24 Oct 2012, Jan Hubicka wrote:
> few things I think are worth to be mentioned in changes.html.

Nice!


> Index: changes.html
> ===
> +  LTO partitioning has been rewritten for better reliability
> +  and maintanibility. Several important bugs leading to link
> +  failures has been fixed.

"have been fixed"

> + Interprocedural optimization improvements:
> + 
> +  New symbol table has been implemented. The symbol table

"A new symbol table" ... "It..."

> +  builds on earlier callgraph and varpool modules and 
> +  provide a new API.

"provides"

When you say "builds on", is this "existing modules" or "builds
on and replaces"?

> +  more aggrssive unreachable code removal with LTO.

"aggressive"

> +  The inline heuristic can now bypass limits on size of

"on the size"

> +  inlined function when the inlining is particularly profitable.

"of an inlined function" (or "of inlined functions")

> +  This happens, for example, when loop bounds or array strides
> +  gets propagated.

"get"

> +  Values passed through aggregates (either by value or refernece)

"reference"

> +  are now propagated at inter-procedural level leading to better

"at the"

> +  inlining decisions (for exmaple in the case of Fortran

"example"


Can you please make these changes and commit?

Thanks,
Gerald


Re: [AARCH64] Update maintainers file

2012-10-28 Thread Gerald Pfeifer
On Tue, 23 Oct 2012, Richard Earnshaw wrote:
> On 23/10/12 23:36, Steven Bosscher wrote:
>> Will you also add an announcement of this to the news page (home page)
>> and to gcc-4.8/changes.html?
> I'm sure we can... :-)

You have to. :-)  Please.

Gerald


../.././gcc/system.h:28:20: fatal error: stdarg.h: No such file or directory

2012-10-28 Thread Bruce Korb
Say, what?  Anyone know what this is about?

cp ../.././gcc/../fixincludes/README-fixinc include-fixed/README
chmod a+r include-fixed/README
echo timestamp > stmp-int-hdrs
TARGET_CPU_DEFAULT="" \
HEADERS="auto-host.h ansidecl.h" DEFINES="USED_FOR_TARGET " \
/bin/sh ../.././gcc/mkconfig.sh tconfig.h
(SHLIB='true'; \
g++ -c   -g -DIN_GCC   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables 
-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute 
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings 
-fno-common  -DHAVE_CONFIG_H -I. -I. -I../.././gcc -I../.././gcc/. 
-I../.././gcc/../include -I../.././gcc/../libcpp/include  
-I../.././gcc/../libdecnumber -I../.././gcc/../libdecnumber/bid 
-I../libdecnumber -I../.././gcc/../libbacktrace
-DSTANDARD_STARTFILE_PREFIX=\"../../../\" 
-DSTANDARD_EXEC_PREFIX=\"/u/gnu/proj/gcc-svn-inst/lib64/gcc/\" 
-DSTANDARD_LIBEXEC_PREFIX=\"/u/gnu/proj/gcc-svn-inst/lib/gcc/\" 
-DDEFAULT_TARGET_VERSION=\"4.8.0\" 
-DDEFAULT_TARGET_MACHINE=\"x86_64-unknown-linux-gnu\" 
-DSTANDARD_BINDIR_PREFIX=\"/u/gnu/proj/gcc-svn-inst/bin/\" 
-DTOOLDIR_BASE_PREFIX=\"../../../../\"  `test "X${SHLIB}" = "X" || test "yes" 
!= "yes" || echo "-DENABLE_SHARED_LIBGCC"` -DCONFIGURE_SPECS="\"\"" \
-I. -I. -I../.././gcc -I../.././gcc/. -I../.././gcc/../include 
-I../.././gcc/../libcpp/include  -I../.././gcc/../libdecnumber 
-I../.././gcc/../libdecnumber/bid -I../libdecnumber 
-I../.././gcc/../libbacktrace   ../.././gcc/cp/g++spec.c)
g++   -g -DIN_GCC   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W 
-Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute 
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings 
-fno-common  -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  -o g++ \
  gcc.o ggc-none.o g++spec.o driver-i386.o  libcommon-target.a \
   libcommon.a ../libcpp/libcpp.a   ../libbacktrace/.libs/libbacktrace.a 
../libiberty/libiberty.a ../libdecnumber/libdecnumber.a
g++ -c   -g -DIN_GCC   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables 
-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute 
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings 
-fno-common  -DHAVE_CONFIG_H -I. -Ilto -I../.././gcc -I../.././gcc/lto 
-I../.././gcc/../include -I../.././gcc/../libcpp/include  
-I../.././gcc/../libdecnumber -I../.././gcc/../libdecnumber/bid 
-I../libdecnumber -I../.././gcc/../libbacktrace../.././gcc/lto/lto-lang.c 
-o lto/lto-lang.o
In file included from ../.././gcc/lto/lto-lang.c:22:0:
../.././gcc/system.h:28:20: fatal error: stdarg.h: No such file or directory
 #include 
^
compilation terminated.
make[3]: *** [lto/lto-lang.o] Error 1
make[3]: Leaving directory 
`/u/gnu/proj/gcc-svn-bld/host-x86_64-unknown-linux-gnu/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/u/gnu/proj/gcc-svn-bld'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/u/gnu/proj/gcc-svn-bld'
make: *** [all] Error 2


Re: [patch] fix outdated path in cpp.texi

2012-10-28 Thread Gerald Pfeifer
On Sun, 21 Oct 2012, Jonathan Wakely wrote:
>> I was going to say "Ack", since it's a doc patch, but somehow my
>> own tests on various platforms (FreeBSD, GNU/Linux,...) did not
>> confirm /usr/include/c++ in the search path.
>>
>> Or do you mean that it's at the root of some search paths, that
>> is /usr/include/c++/... instead of /usr/include/g++-v3 ?  (I
>> definitely have not seen the latter anywhere, so if it's this,
>> then it looks okay.)
> I get:
> 
> echo  | g++ -v -E -x c++  - 2>&1 | sed -n '/#include <...> search
> starts/,/End of search list/p'
> #include <...> search starts here:
>  /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3
>  
> /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/x86_64-redhat-linux
>  /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/backward
>  /usr/lib/gcc/x86_64-redhat-linux/4.6.3/include
>  /usr/local/include
>  /usr/include
> End of search list.
> 
> And:
> 
> readlink -f 
> /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3
> /usr/include/c++/4.6.3

Yep, just I first read the text as /usr/include/c++ itself being in
the include path (which it is not).  Of course, g++-v3 is even more
incorrecot :-), so the patch is fine.

Perhaps you can rephrase it a bit to help clarify that?  (But that
is optional; in any case, your patch improves what is currently there.)

Gerald


[Patch] Remove _GLIBCXX_HAVE_BROKEN_VSWPRINTF from

2012-10-28 Thread JonY
Hi,

Workaround now exists for trunk mingw-w64 headers.
Kai approved over IRC, so anybody with commit rights please push.

ChangeLog
2012-10-29  Jonathan Yong  

* config/os/mingw32-w64/os_defines.h: Remove 
_GLIBCXX_HAVE_BROKEN_VSWPRINTF
as no longer required.



Index: libstdc++-v3/config/os/mingw32-w64/os_defines.h
===
--- libstdc++-v3/config/os/mingw32-w64/os_defines.h (revision 192802)
+++ libstdc++-v3/config/os/mingw32-w64/os_defines.h (working copy)
@@ -63,8 +63,9 @@
 // See libstdc++/20806.
 #define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1

-// See  libstdc++/37522.
-#define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1
+// See  libstdc++/37522. mingw-w64 stdio redirect for C++
+// #define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1
+// Workaround added for mingw-w64 trunk headers r5437

 // See libstdc++/43738
 // On native windows targets there is no ioctl function. And the existing



signature.asc
Description: OpenPGP digital signature


Make inliner to predict &this->field to be optimized out

2012-10-28 Thread Jan Hubicka
Hi,
this patch makes optimizer to predict &this->field to be optimized out.
The main motivation for this is to make destructors that only calls destructor
of inner type to be inlined, even in the cold regions.

Bootstrapped/regtested x86_64-linux. Comitted.

2012-10-28  Jan Hubicka  

* ipa-inline-analysis.c (eliminated_by_inlining_prob): Handle
&this->field expressions.

Index: ipa-inline-analysis.c
===
--- ipa-inline-analysis.c   (revision 192898)
+++ ipa-inline-analysis.c   (working copy)
@@ -1567,6 +1567,7 @@ eliminated_by_inlining_prob (gimple stmt
if (gimple_assign_rhs_code (stmt) == CONVERT_EXPR
|| gimple_assign_rhs_code (stmt) == NOP_EXPR
|| gimple_assign_rhs_code (stmt) == VIEW_CONVERT_EXPR
+   || gimple_assign_rhs_code (stmt) == ADDR_EXPR
|| gimple_assign_rhs_class (stmt) == GIMPLE_SINGLE_RHS)
  {
tree rhs = gimple_assign_rhs1 (stmt);
@@ -1584,6 +1585,20 @@ eliminated_by_inlining_prob (gimple stmt
/* Reads of parameter are expected to be free.  */
if (unmodified_parm (stmt, inner_rhs))
  rhs_free = true;
+   /* Match expressions of form &this->field. Those will most likely
+  combine with something upstream after inlining.  */
+   else if (TREE_CODE (inner_rhs) == ADDR_EXPR)
+ {
+   tree op = get_base_address (TREE_OPERAND (inner_rhs, 0));
+   if (TREE_CODE (op) == PARM_DECL)
+ rhs_free = true;
+   else if (TREE_CODE (op) == MEM_REF)
+ {
+   op = get_base_address (TREE_OPERAND (op, 0));
+   if (unmodified_parm (stmt, op))
+ rhs_free = true;
+ }
+ }
 
/* When parameter is not SSA register because its address is taken
   and it is just copied into one, the statement will be completely


Re: [patch] fix outdated path in cpp.texi

2012-10-28 Thread Jonathan Wakely
On 28 October 2012 22:21, Gerald Pfeifer wrote:
> On Sun, 21 Oct 2012, Jonathan Wakely wrote:
>>> I was going to say "Ack", since it's a doc patch, but somehow my
>>> own tests on various platforms (FreeBSD, GNU/Linux,...) did not
>>> confirm /usr/include/c++ in the search path.
>>>
>>> Or do you mean that it's at the root of some search paths, that
>>> is /usr/include/c++/... instead of /usr/include/g++-v3 ?  (I
>>> definitely have not seen the latter anywhere, so if it's this,
>>> then it looks okay.)
>> I get:
>>
>> echo  | g++ -v -E -x c++  - 2>&1 | sed -n '/#include <...> search
>> starts/,/End of search list/p'
>> #include <...> search starts here:
>>  /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3
>>  
>> /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/x86_64-redhat-linux
>>  
>> /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/backward
>>  /usr/lib/gcc/x86_64-redhat-linux/4.6.3/include
>>  /usr/local/include
>>  /usr/include
>> End of search list.
>>
>> And:
>>
>> readlink -f 
>> /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3
>> /usr/include/c++/4.6.3
>
> Yep, just I first read the text as /usr/include/c++ itself being in
> the include path (which it is not).  Of course, g++-v3 is even more
> incorrecot :-), so the patch is fine.
>
> Perhaps you can rephrase it a bit to help clarify that?  (But that
> is optional; in any case, your patch improves what is currently there.)

Yes, libdir/gcc/target/version/../../../../include/c++/version would
be more accurate, because libdir is not necessarily /usr

I'll come up with something better ...


Re: [patch] fix outdated path in cpp.texi

2012-10-28 Thread Jonathan Wakely
On 29 October 2012 00:08, Jonathan Wakely wrote:
> Yes, libdir/gcc/target/version/../../../../include/c++/version would
> be more accurate, because libdir is not necessarily /usr
>
> I'll come up with something better ...

I've committed this to the trunk.
commit 258a736d80af598109fae44e55b057711d24
Author: Jonathan Wakely 
Date:   Thu Oct 18 00:32:07 2012 +0100

* doc/cpp.texi (Search Path): Fix outdated C++ path.

diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index fa5989e..c463e7c 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -856,7 +856,8 @@ requested with @code{@w{#include <@var{file}>}} in:
 /usr/include
 @end smallexample
 
-For C++ programs, it will also look in @file{/usr/include/g++-v3},
+For C++ programs, it will also look in
+@file{@var{libdir}/../include/c++/@var{version}},
 first.  In the above, @var{target} is the canonical name of the system
 GCC was configured to compile code for; often but not always the same as
 the canonical name of the system it runs on.  @var{version} is the


patch to fix PR55106

2012-10-28 Thread Vladimir Makarov
  The following patch fixes PR55106.  A value in GENERAL_REGS is 
inherited into a move with destination pseudo of SSE_REGS.  It results 
into secondary move for which inheritance is tried again an again.  It 
means cycling LRA passes.


  The patch was successfully bootstrapped on x86/x86-64.

  Committed as rev. 192904.

2012-10-28  Vladimir Makarov  

PR rtl-optimization/55106
* lra-constraints.c (skip_usage_debug_insns): New function.
(check_secondary_memory_needed_p): Ditto.
(inherit_reload_reg): Use the new functions.  Improve debug
output.

Index: lra-constraints.c
===
--- lra-constraints.c   (revision 192897)
+++ lra-constraints.c   (working copy)
@@ -3573,6 +3573,48 @@ substitute_pseudo (rtx *loc, int old_reg
   return result;
 }
 
+/* Return first non-debug insn in list USAGE_INSNS.  */
+static rtx
+skip_usage_debug_insns (rtx usage_insns)
+{
+  rtx insn;
+
+  /* Skip debug insns.  */
+  for (insn = usage_insns;
+   insn != NULL_RTX && GET_CODE (insn) == INSN_LIST;
+   insn = XEXP (insn, 1))
+;
+  return insn;
+}
+
+/* Return true if we need secondary memory moves for insn in
+   USAGE_INSNS after inserting inherited pseudo of class INHER_CL
+   into the insn.  */
+static bool
+check_secondary_memory_needed_p (enum reg_class inher_cl, rtx usage_insns)
+{
+#ifndef SECONDARY_MEMORY_NEEDED
+  return false;
+#else
+  rtx insn, set, dest;
+  enum reg_class cl;
+
+  if (inher_cl == ALL_REGS
+  || (insn = skip_usage_debug_insns (usage_insns)) == NULL_RTX)
+return false;
+  lra_assert (INSN_P (insn));
+  if ((set = single_set (insn)) == NULL_RTX || ! REG_P (SET_DEST (set)))
+return false;
+  dest = SET_DEST (set);
+  if (! REG_P (dest))
+return false;
+  lra_assert (inher_cl != NO_REGS);
+  cl = get_reg_class (REGNO (dest));
+  return (cl != NO_REGS && cl != ALL_REGS
+ && SECONDARY_MEMORY_NEEDED (inher_cl, cl, GET_MODE (dest)));
+#endif
+}
+
 /* Registers involved in inheritance/split in the current EBB
(inheritance/split pseudos and original registers). */
 static bitmap_head check_only_regs;
@@ -3610,18 +3652,18 @@ inherit_reload_reg (bool def_p, int orig
   lra_assert (! usage_insns[original_regno].after_p);
   if (lra_dump_file != NULL)
 fprintf (lra_dump_file,
-"<<\n");
+"<<\n");
   if (! ira_reg_classes_intersect_p[cl][rclass])
 {
   if (lra_dump_file != NULL)
{
  fprintf (lra_dump_file,
-  "Rejecting inheritance for %d "
+  "Rejecting inheritance for %d "
   "because of disjoint classes %s and %s\n",
   original_regno, reg_class_names[cl],
   reg_class_names[rclass]);
  fprintf (lra_dump_file,
-  ">>\n");
+  ">>\n");
}
   return false;
 }
@@ -3638,6 +3680,31 @@ inherit_reload_reg (bool def_p, int orig
   
   rclass = cl;
 }
+  if (check_secondary_memory_needed_p (cl, next_usage_insns))
+{
+  /* Reject inheritance resulting in secondary memory moves.
+Otherwise, there is a danger in LRA cycling.  Also such
+transformation will be unprofitable.  */
+  if (lra_dump_file != NULL)
+   {
+ rtx insn = skip_usage_debug_insns (next_usage_insns);
+ rtx set = single_set (insn);
+
+ lra_assert (set != NULL_RTX);
+
+ rtx dest = SET_DEST (set);
+
+ lra_assert (REG_P (dest));
+ fprintf (lra_dump_file,
+  "Rejecting inheritance for insn %d(%s)<-%d(%s) "
+  "as secondary mem is needed\n",
+  REGNO (dest), reg_class_names[get_reg_class (REGNO (dest))],
+  original_regno, reg_class_names[cl]);
+ fprintf (lra_dump_file,
+  ">>\n");
+   }
+  return false;
+}
   new_reg = lra_create_new_reg (GET_MODE (original_reg), original_reg,
rclass, "inheritance");
   start_sequence ();
@@ -3652,7 +3719,7 @@ inherit_reload_reg (bool def_p, int orig
   if (lra_dump_file != NULL)
{
  fprintf (lra_dump_file,
-  "Rejecting inheritance %d->%d "
+  "Rejecting inheritance %d->%d "
   "as it results in 2 or more insns:\n",
   original_regno, REGNO (new_reg));
  debug_rtl_slim (lra_dump_file, new_insns, NULL_RTX, -1, 0);
@@ -3667,7 +3734,7 @@ inherit_reload_reg (bool def_p, int orig
 /* We now have a new usage insn for original regno.  */
 setup_next_usage_insn (original_regno, new_insns, reloads_num, false);
   if (lra_dump_file != NULL)
- 

Re: patch to fix PR55106

2012-10-28 Thread H.J. Lu
On Sun, Oct 28, 2012 at 5:43 PM, Vladimir Makarov  wrote:
>   The following patch fixes PR55106.  A value in GENERAL_REGS is inherited
> into a move with destination pseudo of SSE_REGS.  It results into secondary
> move for which inheritance is tried again an again.  It means cycling LRA
> passes.
>
>   The patch was successfully bootstrapped on x86/x86-64.
>
>   Committed as rev. 192904.
>
> 2012-10-28  Vladimir Makarov  
>
> PR rtl-optimization/55106
> * lra-constraints.c (skip_usage_debug_insns): New function.
> (check_secondary_memory_needed_p): Ditto.
> (inherit_reload_reg): Use the new functions.  Improve debug
> output.
>

Please add the testcase at

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55106#c1

Thanks.


-- 
H.J.


Re: PR c/53066 Wshadow should not warn for shadowing an extern function

2012-10-28 Thread Joseph S. Myers
The code changes seem fine, but I don't think a testcase should depend on 
the details of what system strings.h declares (or even that it exists) 
like that.  If you want a system header declaration, add a header to the 
testsuite that uses #pragma GCC system_header to be sure it's handled as 
such, and include that header in the testcase; there are several existing 
examples of this in gcc.dg.

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


Trailing white spaces in LRA codes

2012-10-28 Thread H.J. Lu
Hi Vladimir,

There are many trialling white spaces in LRA codes.  This patch removes
them.

H.J.
---
diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
index 1f89338..c558a4d 100644
--- a/gcc/lra-assigns.c
+++ b/gcc/lra-assigns.c
@@ -149,7 +149,7 @@ init_regno_assign_info (void)
 {
   int i, regno1, regno2, max_regno = max_reg_num ();
   lra_copy_t cp;
-  
+
   regno_assign_info = XNEWVEC (struct regno_assign_info, max_regno);
   for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
 {
@@ -185,10 +185,10 @@ reload_pseudo_compare_func (const void *v1p, const void 
*v2p)
   enum reg_class cl1 = regno_allocno_class_array[r1];
   enum reg_class cl2 = regno_allocno_class_array[r2];
   int diff;
-  
+
   lra_assert (r1 >= lra_constraint_new_regno_start
  && r2 >= lra_constraint_new_regno_start);
-  
+
   /* Prefer to assign reload registers with smaller classes first to
  guarantee assignment to all reload registers.  */
   if ((diff = (ira_class_hard_regs_num[cl1]
@@ -217,7 +217,7 @@ pseudo_compare_func (const void *v1p, const void *v2p)
   /* Prefer to assign more frequently used registers first.  */
   if ((diff = lra_reg_info[r2].freq - lra_reg_info[r1].freq) != 0)
 return diff;
-  
+
   /* If regs are equally good, sort by their numbers, so that the
  results of qsort leave nothing to chance. */
   return r1 - r2;
@@ -378,7 +378,7 @@ init_live_reload_and_inheritance_pseudos (void)
 {
   int i, p, max_regno = max_reg_num ();
   lra_live_range_t r;
-  
+
   conflict_reload_and_inheritance_pseudos = sparseset_alloc (max_regno);
   live_reload_and_inheritance_pseudos = XNEWVEC (bitmap_head, 
lra_live_max_point);
   bitmap_obstack_initialize 
(&live_reload_and_inheritance_pseudos_bitmap_obstack);
@@ -470,7 +470,7 @@ find_hard_regno_for (int regno, int *cost, int 
try_only_hard_regno)
   for (p = r->start + 1; p <= r->finish; p++)
{
  lra_live_range_t r2;
- 
+
  for (r2 = start_point_ranges[p];
   r2 != NULL;
   r2 = r2->start_next)
@@ -511,7 +511,7 @@ find_hard_regno_for (int regno, int *cost, int 
try_only_hard_regno)
 [lra_reg_info[conflict_regno].biggest_mode]);
/* Remember about multi-register pseudos.  For example, 2 hard
   register pseudos can start on the same hard register but can
-  not start on HR and HR+1/HR-1.  */ 
+  not start on HR and HR+1/HR-1.  */
for (hr = conflict_hr + 1;
 hr < FIRST_PSEUDO_REGISTER && hr < conflict_hr + nregs;
 hr++)
@@ -810,7 +810,7 @@ spill_for (int regno, bitmap spilled_pseudo_bitmap)
   EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi)
 {
   struct lra_insn_reg *ir;
-  
+
   for (ir = lra_get_insn_regs (uid); ir != NULL; ir = ir->next)
if (ir->regno >= FIRST_PSEUDO_REGISTER)
  bitmap_set_bit (&insn_conflict_pseudos, ir->regno);
@@ -867,7 +867,7 @@ spill_for (int regno, bitmap spilled_pseudo_bitmap)
  for (p = r->start; p <= r->finish; p++)
{
  lra_live_range_t r2;
- 
+
  for (r2 = start_point_ranges[p];
   r2 != NULL;
   r2 = r2->start_next)
@@ -913,7 +913,7 @@ spill_for (int regno, bitmap spilled_pseudo_bitmap)
  EXECUTE_IF_SET_IN_BITMAP (&spill_pseudos_bitmap, 0, spill_regno, bi)
{
  rtx x;
- 
+
  cost += lra_reg_info[spill_regno].freq;
  if (ira_reg_equiv[spill_regno].memory != NULL
  || ira_reg_equiv[spill_regno].constant != NULL)
@@ -1038,7 +1038,7 @@ setup_live_pseudos_and_spill_after_risky_transforms 
(bitmap
  for (p = r->start + 1; p <= r->finish; p++)
{
  lra_live_range_t r2;
- 
+
  for (r2 = start_point_ranges[p];
   r2 != NULL;
   r2 = r2->start_next)
@@ -1239,7 +1239,7 @@ assign_by_spills (void)
  {
lra_insn_recog_data_t data;
struct lra_insn_reg *r;
- 
+
data = lra_get_insn_recog_data (insn);
for (r = data->regs; r != NULL; r = r->next)
  {
diff --git a/gcc/lra-coalesce.c b/gcc/lra-coalesce.c
index 57c3111..6b5c3f0 100644
--- a/gcc/lra-coalesce.c
+++ b/gcc/lra-coalesce.c
@@ -79,7 +79,7 @@ move_freq_compare_func (const void *v1p, const void *v2p)
   rtx mv1 = *(const rtx *) v1p;
   rtx mv2 = *(const rtx *) v2p;
   int pri1, pri2;
-  
+
   pri1 = BLOCK_FOR_INSN (mv1)->frequency;
   pri2 = BLOCK_FOR_INSN (mv2)->frequency;
   if (pri2 - pri1)
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 4b3dbc0..9b98324 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -87,7 +87,7 @@
 
r <- ... or ... <- r r <- ... or ... <- r
...  s <- r (new insn -- save)
-   ...   => 
+   ...

[PATCH GCC]Improving register pressure directed hoist

2012-10-28 Thread Bin Cheng
Hi,
This patch improves register pressure directed hoist by accurately
monitoring the change of register pressure during code hoisting and use this
information to feedback further code hoisting. To know how register pressure
is affected when hoisting an expression(x+y) through a basic block, the
patch checks:
1.  whether x/y is live at the end of the basic block, the live range can't
be shrunk if yes. The live information at the IN/OUT of basic blocks have to
be updated manually by the patch, since these information won't be updated
until next call to function df_analyze.
2.  whether x/y is referred by any other instructions in the basic block,
the live range can't be shrunk if yes. This is done by iterating all
references of x/y by using DF cached information and checking whether any
reference is made in this basic block.

Since GCC calls should_hoist_expr_to_dom to determine whether an expression
should be hoisted, this patch saves/restores/updates LIVE and register
pressure information before/after the call by introducing back-trace
utility.

Though additional computation is introduced by this patch, I bootstrapped
x86 with patch enabled and see no obvious slow down in compilation time.

With this patch, the effect on CSiBE of option "-fira-hoist-pressure" is
improved as below:
improvement
Thumb1  0.22%(0.13% before this patch)
ARM 0.16%(0.12% before)
MIPS0.25%(0.24% before)
PowerPC 0.62%
Thumb2  X
x86 X
x86_64  X
Note: Though X means no obvious effect on code size, this patch does improve
it a little bit on these targets.

I bootstrapped this patch on x86/x86_64, and tested it on
x86/x86_64/arm-none-eabi. Is it OK?

Thanks.


2012-10-29  Bin Cheng  

* gcse.c: (struct bb_data): Add new fields, old_pressure, live_in
and backup.
(calculate_bb_reg_pressure): Initialize live_in and backup.
(update_bb_reg_pressure): New.
(should_hoist_expr_to_dom): Add new parameter from.
Monitor the change of reg pressure and use it to drive hoisting.
(hoist_code): Update LIVE and reg pressure information.

gcc/testsuite/ChangeLog
2012-10-29  Bin Cheng  

* gcc.dg/hoist-register-pressure-3.c: New test.
Index: gcc/testsuite/gcc.dg/hoist-register-pressure-3.c
===
--- gcc/testsuite/gcc.dg/hoist-register-pressure-3.c(revision 0)
+++ gcc/testsuite/gcc.dg/hoist-register-pressure-3.c(revision 0)
@@ -0,0 +1,32 @@
+/* { dg-options "-Os -fdump-rtl-hoist" }  */
+/* { dg-final { scan-rtl-dump "PRE/HOIST: end of bb .* copying expression" 
"hoist" } } */
+
+#define BUF 100
+int a[BUF];
+
+void com (int);
+void bar (int);
+
+int foo (int x, int y, int z)
+{
+  /* "x+y" won't be hoisted if "-fira-hoist-pressure" is disabled,
+ because its rtx_cost is too small.  */
+  if (z)
+{
+  a[1] = a[0] + a[2] + a[3] + a[4] + a[5] + a[6];
+  a[2] = a[1] + a[3] + a[5] + a[5] + a[6] + a[7];
+  a[3] = a[2] + a[5] + a[7] + a[6] + a[7] + a[8];
+  a[4] = a[3] + a[7] + a[11] + a[7] + a[8] + a[9];
+  a[5] = a[5] + a[11] + a[13] + a[8] + a[9] + a[10];
+  a[6] = a[7] + a[13] + a[17] + a[9] + a[10] + a[11];
+  a[7] = a[11] + a[17] + a[19] + a[10] + a[11] + a[12];
+  com (x+y);
+}
+  else
+{
+  bar (x+y);
+}
+
+  return 0;
+}
+
Index: gcc/gcse.c
===
--- gcc/gcse.c  (revision 192758)
+++ gcc/gcse.c  (working copy)
@@ -20,9 +20,6 @@ along with GCC; see the file COPYING3.  If not see
 
 /* TODO
- reordering of memory allocation and freeing to be more space efficient
-   - simulate register pressure change of each basic block accurately during
- hoist process.  But I doubt the benefit since most expressions hoisted
- are constant or address, which usually won't reduce register pressure.
- calc rough register pressure information and use the info to drive all
  kinds of code motion (including code hoisting) in a unified way.
 */
@@ -421,6 +418,15 @@ struct bb_data
   /* Maximal register pressure inside basic block for given register class
  (defined only for the pressure classes).  */
   int max_reg_pressure[N_REG_CLASSES];
+  /* Recorded register pressure of basic block before trying to hoist
+ an expression.  Will be used to restore the register pressure
+ if the expression should not be hoisted.  */
+  int old_pressure;
+  /* Recorded register live_in info of basic block during code hoisting
+ process.  BACKUP is used to record live_in info before trying to
+ hoist an expression, and will be used to restore LIVE_IN if the
+ expression should not be hoisted.  */
+  bitmap live_in, backup;
 };
 
 #define BB_DATA(bb) ((struct bb_data *) (bb)->aux)
@@ -481,7 +487,7 @@ static void compute_code_hoist_vbeinout (void);
 static void compute_code_hoist_data (void);
 static int should_hoist_expr_to_dom (b