Re: [PATCH] Detect loops in find_comparison_args

2012-07-26 Thread Paolo Bonzini
Il 26/07/2012 04:25, Sandra Loosemore ha scritto:
> On 07/25/2012 01:27 AM, Paolo Bonzini wrote:
>> 
>> What I'm worried about is the extra cost of malloc-ing and free-ing
>> the pointer set.  Perhaps you can skip the pointer set creation in
>> the common case where find_comparison_args does not iterate?
>> Something like this:
>> 
>> [snip]
> 
> I think this version is a little neater; it just defers
> initialization of the pointer set to the end of the loop.

But the while condition could still fail right after you create the set,
and I would expect that to be the common case.

Paolo

> I checked
> the test case on the two targets where we've previously observed
> failures (the original one on MIPS and the current one on PowerPC),
> as well as doing a full bootstrap and regression-test on x86_64.  OK
> to check in?
> 
> -Sandra
> 
> 
> 2012-07-25  Andrew Jenner   Sandra Loosemore
> 
> 
> gcc/ * cse.c (find_comparison_args): Check for cycles of any length.
> 
> gcc/testsuite/ * gcc.c-torture/compile/pr50380.c: Add code to cause
> cycle of length 2.
> 




[rs6000 0/3] POWER removal

2012-07-26 Thread Segher Boessenkool
This patch series removes support for the old POWER CPUs (the RIOS,
RSC, and RIOS2).

It does not do any more than that: it leaves common mode alone,
it does not remove the old assembler mnemonics and the {xx|yy}
insn template syntax, etc.

Bootstrapped and regtested on powerpc64-linux (c,c++,fortran);
no new failures.

Comments?

Segher



( There is a bit of jitter in tests that passed before and now
don't, or the other way around, e.g. pr42246.c; all those
fail in the latest results from Pat Haugen, so I presume it
has nothing to do with these patches; see
http://gcc.gnu.org/ml/gcc-testresults/2012-07/msg0.html )


Segher Boessenkool (3):
  Remove RIOS, RSC and RIOS2 processor types
  Remove support for old POWER
  Remove MQ

 gcc/common/config/rs6000/rs6000-common.c   |   28 +-
 gcc/config/rs6000/601.md   |  136 ++
 gcc/config/rs6000/aix43.h  |   18 +-
 gcc/config/rs6000/aix51.h  |   18 +-
 gcc/config/rs6000/aix52.h  |   12 +-
 gcc/config/rs6000/aix53.h  |   12 +-
 gcc/config/rs6000/aix61.h  |   12 +-
 gcc/config/rs6000/constraints.md   |7 +-
 gcc/config/rs6000/darwin.h |5 +-
 gcc/config/rs6000/dfp.md   |   21 +-
 gcc/config/rs6000/driver-rs6000.c  |   23 +-
 gcc/config/rs6000/predicates.md|5 +-
 gcc/config/rs6000/rios1.md |  191 --
 gcc/config/rs6000/rios2.md |  129 --
 gcc/config/rs6000/rs6000-c.c   |   11 +-
 gcc/config/rs6000/rs6000-cpus.def  |   15 +-
 gcc/config/rs6000/rs6000-opts.h|5 +-
 gcc/config/rs6000/rs6000-tables.opt|   41 +-
 gcc/config/rs6000/rs6000.c |   90 +-
 gcc/config/rs6000/rs6000.h |   51 +-
 gcc/config/rs6000/rs6000.md| 2234 ++--
 gcc/config/rs6000/rs6000.opt   |   17 +-
 gcc/config/rs6000/sysv4.h  |8 +-
 gcc/config/rs6000/t-aix43  |   15 +-
 gcc/config/rs6000/t-rs6000 |8 +-
 gcc/doc/invoke.texi|   41 +-
 gcc/testsuite/gcc.target/powerpc/rs6000-power2-1.c |   21 -
 gcc/testsuite/gcc.target/powerpc/rs6000-power2-2.c |   22 -
 28 files changed, 392 insertions(+), 2804 deletions(-)
 create mode 100644 gcc/config/rs6000/601.md
 delete mode 100644 gcc/config/rs6000/rios1.md
 delete mode 100644 gcc/config/rs6000/rios2.md
 delete mode 100644 gcc/testsuite/gcc.target/powerpc/rs6000-power2-1.c
 delete mode 100644 gcc/testsuite/gcc.target/powerpc/rs6000-power2-2.c

-- 
1.7.7.6



[rs6000 3/3] Remove MQ

2012-07-26 Thread Segher Boessenkool
gcc/
* config/rs6000/constraints.md: Delete "q" constraint.
* config/rs6000/dfp.md (movsd_hardfloat, movsd_softfloat):
Delete the "q" alternative.
* config/rs6000/predicates.md (gpc_reg_operand): Replace
MQ_REGNO with the literal 64.
* config/rs6000/rs6000.c (rs6000_debug_reg_global,
rs6000_init_hard_regno_mode_ok, rs6000_dbx_register_number):
Adjust to MQ_REGNO removal.
* config/rs6000/rs6000.h (FIRST_PSEUDO_REGISTER): Adjust
comment.
(REG_ALLOC_ORDER): Adjust comment.  Remove MQ from alloc order.
(enum reg_class): Adjust comment.  Delete MQ_REGS.
(REG_CLASS_CONTENTS): Adjust.
(REGISTER_NAMES, ADDITIONAL_REGISTER_NAMES): Adjust comment.
* config/rs6000/rs6000.md: Delete MQ_REGNO.
(movsi_internal1, movsi_internal1_single, movhi_internal,
movqi_internal, movcc_internal1, movsf_hardfloat,
movsf_softfloat): Delete the "q" alternative.
(ctr_internal1, ctr_internal2, ctr_internal5,
ctr_internal6): Delete "q" constraint.
---
 gcc/config/rs6000/constraints.md |7 +---
 gcc/config/rs6000/dfp.md |   21 +--
 gcc/config/rs6000/predicates.md  |5 +--
 gcc/config/rs6000/rs6000.c   |4 --
 gcc/config/rs6000/rs6000.h   |   26 ++
 gcc/config/rs6000/rs6000.md  |   74 +-
 6 files changed, 57 insertions(+), 80 deletions(-)

diff --git a/gcc/config/rs6000/constraints.md b/gcc/config/rs6000/constraints.md
index e53320e..4a153d4 100644
--- a/gcc/config/rs6000/constraints.md
+++ b/gcc/config/rs6000/constraints.md
@@ -1,5 +1,5 @@
 ;; Constraint definitions for RS6000
-;; Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2012 Free Software Foundation, Inc.
 ;;
 ;; This file is part of GCC.
 ;;
@@ -17,7 +17,7 @@
 ;; along with GCC; see the file COPYING3.  If not see
 ;; .
 
-;; Available constraint letters: "e", "k", "u", "A", "B", "C", "D"
+;; Available constraint letters: "e", "k", "q", "u", "A", "B", "C", "D"
 
 ;; Register constraints
 
@@ -33,9 +33,6 @@ (define_register_constraint "b" "BASE_REGS"
 (define_register_constraint "h" "SPECIAL_REGS"
   "@internal")
 
-(define_register_constraint "q" "MQ_REGS"
-  "@internal")
-
 (define_register_constraint "c" "CTR_REGS"
   "@internal")
 
diff --git a/gcc/config/rs6000/dfp.md b/gcc/config/rs6000/dfp.md
index 4fc7310..d2fd12b 100644
--- a/gcc/config/rs6000/dfp.md
+++ b/gcc/config/rs6000/dfp.md
@@ -1,6 +1,5 @@
 ;; Decimal Floating Point (DFP) patterns.
-;; Copyright (C) 2007, 2008, 2010, 2011
-;; Free Software Foundation, Inc.
+;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
 ;; Contributed by Ben Elliston (b...@au.ibm.com) and Peter Bergner
 ;; (berg...@vnet.ibm.com).
 
@@ -62,8 +61,8 @@ (define_split
 }")
 
 (define_insn "movsd_hardfloat"
-  [(set (match_operand:SD 0 "nonimmediate_operand" 
"=r,r,m,f,*c*l,*q,!r,*h,!r,!r")
-   (match_operand:SD 1 "input_operand""r,m,r,f,r,r,h,0,G,Fn"))]
+  [(set (match_operand:SD 0 "nonimmediate_operand" "=r,r,m,f,*c*l,!r,*h,!r,!r")
+   (match_operand:SD 1 "input_operand""r,m,r,f,r,h,0,G,Fn"))]
   "(gpc_reg_operand (operands[0], SDmode)
|| gpc_reg_operand (operands[1], SDmode))
&& (TARGET_HARD_FLOAT && TARGET_FPRS)"
@@ -73,24 +72,22 @@ (define_insn "movsd_hardfloat"
{st%U0%X0|stw%U0%X0} %1,%0
fmr %0,%1
mt%0 %1
-   mt%0 %1
mf%1 %0
{cror 0,0,0|nop}
#
#"
-  [(set_attr "type" "*,load,store,fp,mtjmpr,*,mfjmpr,*,*,*")
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,8")])
+  [(set_attr "type" "*,load,store,fp,mtjmpr,mfjmpr,*,*,*")
+   (set_attr "length" "4,4,4,4,4,4,4,4,8")])
 
 (define_insn "movsd_softfloat"
-  [(set (match_operand:SD 0 "nonimmediate_operand" 
"=r,cl,q,r,r,m,r,r,r,r,r,*h")
-   (match_operand:SD 1 "input_operand" "r,r,r,h,m,r,I,L,R,G,Fn,0"))]
+  [(set (match_operand:SD 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r,r,r,*h")
+   (match_operand:SD 1 "input_operand" "r,r,h,m,r,I,L,R,G,Fn,0"))]
   "(gpc_reg_operand (operands[0], SDmode)
|| gpc_reg_operand (operands[1], SDmode))
&& (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
   "@
mr %0,%1
mt%0 %1
-   mt%0 %1
mf%1 %0
{l%U1%X1|lwz%U1%X1} %0,%1
{st%U0%X0|stw%U0%X0} %1,%0
@@ -100,8 +97,8 @@ (define_insn "movsd_softfloat"
#
#
{cror 0,0,0|nop}"
-  [(set_attr "type" "*,mtjmpr,*,mfjmpr,load,store,*,*,*,*,*,*")
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8,4")])
+  [(set_attr "type" "*,mtjmpr,mfjmpr,load,store,*,*,*,*,*,*")
+   (set_attr "length" "4,4,4,4,4,4,4,4,4,8,4")])
 
 (define_insn "movsd_store"
   [(set (match_operand:DD 0 "nonimmediate_operand" "=m")
diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index f29d091..a68be9b 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -1,6 +1,5 @@
 ;; Predicate definitions for POWER an

[rs6000 1/3] Remove RIOS, RSC and RIOS2 processor types

2012-07-26 Thread Segher Boessenkool
Move those parts of rios.md that apply to 601 to a new file
601.md, renaming everything from rios1* to ppc601*.

2012-07-26  Segher Boessenkool  

gcc/
* config/rs6000/601.md: New file.
* config/rs6000/aix43.h (ASM_CPU_SPEC): Delete support for
RIOS CPUs.
* config/rs6000/aix51.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/driver-rs6000.c (detect_processor_aix,
struct asm_names): Likewise.
* config/rs6000/rios1.md: Delete file.
* config/rs6000/rios2.md: Delete file.
* config/rs6000/rs6000-cpus.def: Delete definitions for RIOS
CPUs.
* config/rs6000/rs6000-opts.h (enum processor_type): Delete
PROCESSOR_RIOS1 and PROCESSOR_RIOS2.
* config/rs6000/rs6000-tables.opt: Regenerated.
* config/rs6000/rs6000.c (struct rios1_cost, struct rios2_cost):
Delete.
(rs6000_option_override_internal): Delete support for RIOS CPUs.
(rs6000_conditional_register_usage): Adjust comment.
(rs6000_issue_rate):Delete support for RIOS CPUs.
* config/rs6000/rs6000.h (ASM_CPU_SPEC): Delete support for
RIOS CPUs.
(PROCESSOR_POWER): Change to PROCESSOR_PPC601.
(PROCESSOR_DEFAULT): Change to PROCESSOR_PPC603.
* config/rs6000/rs6000.md (define_attr "cpu"): Delete rios1
and rios2.
(include "rios1.md", include "rios2.md"): Delete.
(include "601.md"): New.
* config/rs6000/rs6000.opt (enum rs6000_cpu): Default to
PROCESSOR_PPC603.
* config/rs6000/t-aix43 (MULTILIB_MATCHES): Delete support
for RIOS CPUs.
* config/rs6000/t-rs6000 (MD_INCLUDES): Delete rios1.md and
rios2.md .  Add 601.md .
---
 gcc/config/rs6000/601.md|  136 +
 gcc/config/rs6000/aix43.h   |8 +--
 gcc/config/rs6000/aix51.h   |8 +--
 gcc/config/rs6000/driver-rs6000.c   |   16 +---
 gcc/config/rs6000/rios1.md  |  191 ---
 gcc/config/rs6000/rios2.md  |  129 ---
 gcc/config/rs6000/rs6000-cpus.def   |   10 +--
 gcc/config/rs6000/rs6000-opts.h |5 +-
 gcc/config/rs6000/rs6000-tables.opt |   17 +---
 gcc/config/rs6000/rs6000.c  |   56 +--
 gcc/config/rs6000/rs6000.h  |   14 +--
 gcc/config/rs6000/rs6000.md |   10 +--
 gcc/config/rs6000/rs6000.opt|5 +-
 gcc/config/rs6000/t-aix43   |7 +-
 gcc/config/rs6000/t-rs6000  |8 +-
 15 files changed, 156 insertions(+), 464 deletions(-)
 create mode 100644 gcc/config/rs6000/601.md
 delete mode 100644 gcc/config/rs6000/rios1.md
 delete mode 100644 gcc/config/rs6000/rios2.md

diff --git a/gcc/config/rs6000/601.md b/gcc/config/rs6000/601.md
new file mode 100644
index 000..52644f2
--- /dev/null
+++ b/gcc/config/rs6000/601.md
@@ -0,0 +1,136 @@
+;; Scheduling description for PowerPC 601 processor.
+;;   Copyright (C) 2003-2012 Free Software Foundation, Inc.
+;;
+;; This file is part of GCC.
+
+;; GCC is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published
+;; by the Free Software Foundation; either version 3, or (at your
+;; option) any later version.
+
+;; GCC is distributed in the hope that it will be useful, but WITHOUT
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+;; License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING3.  If not see
+;; .
+
+(define_automaton "ppc601,ppc601fp")
+(define_cpu_unit "iu_ppc601" "ppc601")
+(define_cpu_unit "fpu_ppc601" "ppc601fp")
+(define_cpu_unit "bpu_ppc601" "ppc601")
+
+;; PPC601  32-bit IU, FPU, BPU
+
+(define_insn_reservation "ppc601-load" 2
+  (and (eq_attr "type" "load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,\
+   load_l,store_c,sync")
+   (eq_attr "cpu" "ppc601"))
+  "iu_ppc601")
+
+(define_insn_reservation "ppc601-store" 2
+  (and (eq_attr "type" "store,store_ux,store_u")
+   (eq_attr "cpu" "ppc601"))
+  "iu_ppc601")
+
+(define_insn_reservation "ppc601-fpload" 3
+  (and (eq_attr "type" "fpload,fpload_ux,fpload_u")
+   (eq_attr "cpu" "ppc601"))
+  "iu_ppc601")
+
+(define_insn_reservation "ppc601-fpstore" 3
+  (and (eq_attr "type" "fpstore,fpstore_ux,fpstore_u")
+   (eq_attr "cpu" "ppc601"))
+  "iu_ppc601+fpu_ppc601")
+
+(define_insn_reservation "ppc601-integer" 1
+  (and (eq_attr "type" "integer,insert_word,insert_dword,shift,\
+trap,var_shift_rotate,cntlz,exts,isel")
+   (eq_attr "cpu" "ppc601"))
+  "iu_ppc601")
+
+(define_insn_reservation "ppc601-two" 1
+  (and (eq_attr "type" "two")
+   (eq_attr "cpu" "ppc601"))
+  "iu_ppc601,iu_ppc601")
+
+(define_insn_reservation "ppc601-three" 1
+  (and (eq_attr "type" "three")

Re: [Patch, Fortran] Fix module I/O with assumed-rank arrays

2012-07-26 Thread Mikael Morin
On 25/07/2012 23:23, Tobias Burnus wrote:
> Tobias Burnus wrote:
>> The following issue was found by Alessandro. (It got triggered by a
>> larger test case, which is required for a larger patch by Alessandro,
>> which is not yet finished.)
>>
>> Accessing the "lower[-1]" is probably not the best idea …
>>
>> Build on x86-64-linux.
>> OK for the trunk?
> 
> I attached the wrong version – the additional problem was that
> mio_integer expects nonnegative numbers.
> 
> Build and tested on x86-64-linux.
> OK?
> 
Hello,

I assume this sits on top of the previous patch?
Then OK for both.

Mikael.


Re: [PATCH][4/n] VRP and anti-range handling

2012-07-26 Thread Roman Zhuykov
2012/6/18 Richard Guenther :
> On Fri, 15 Jun 2012, Richard Guenther wrote:
>
>>
>> This tries to completely implement the intersect primitive for
>> VRP (what extract_range_from_assert does at its end when merging
>> new and old knowledge).
>>
>> Bootstrap and regtest pending on x86_64-unknown-linux-gnu.
>>
>> I plan to re-organize vrp_meet in a similar fashion as a followup.
>
> The following is what I ended up applying, less conservative in the
> [ () ] and ( [] ) cases.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
>
> Richard.
>
> 2012-06-18  Richard Guenther  
>
> * tree-vrp.c (extract_range_from_assert): Split out range
> intersecting code.
> (intersect_ranges): New function.
> (vrp_intersect_ranges): Likewise.
>
> Index: trunk/gcc/tree-vrp.c
> ===
> *** trunk.orig/gcc/tree-vrp.c   2012-06-18 11:23:34.0 +0200
> --- trunk/gcc/tree-vrp.c2012-06-18 11:37:39.117212903 +0200
> *** live_on_edge (edge e, tree name)
> *** 95,100 
> --- 95,101 
>   static int compare_values (tree val1, tree val2);
>   static int compare_values_warnv (tree val1, tree val2, bool *);
>   static void vrp_meet (value_range_t *, value_range_t *);
> + static void vrp_intersect_ranges (value_range_t *, value_range_t *);
>   static tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code,
>  tree, tree, bool, bool *,
>  bool *);
> *** static void
> *** 1515,1521 
>   extract_range_from_assert (value_range_t *vr_p, tree expr)
>   {
> tree var, cond, limit, min, max, type;
> !   value_range_t *var_vr, *limit_vr;
> enum tree_code cond_code;
>
> var = ASSERT_EXPR_VAR (expr);
> --- 1516,1522 
>   extract_range_from_assert (value_range_t *vr_p, tree expr)
>   {
> tree var, cond, limit, min, max, type;
> !   value_range_t *limit_vr;
> enum tree_code cond_code;
>
> var = ASSERT_EXPR_VAR (expr);
> *** extract_range_from_assert (value_range_t
> *** 1777,2014 
> else
>   gcc_unreachable ();
>
> !   /* If VAR already had a known range, it may happen that the new
> !  range we have computed and VAR's range are not compatible.  For
> !  instance,
> !
> !   if (p_5 == NULL)
> ! p_6 = ASSERT_EXPR ;
> ! x_7 = p_6->fld;
> ! p_8 = ASSERT_EXPR ;
> !
> !  While the above comes from a faulty program, it will cause an ICE
> !  later because p_8 and p_6 will have incompatible ranges and at
> !  the same time will be considered equivalent.  A similar situation
> !  would arise from
> !
> !   if (i_5 > 10)
> ! i_6 = ASSERT_EXPR  10>;
> ! if (i_5 < 5)
> !   i_7 = ASSERT_EXPR ;
> !
> !  Again i_6 and i_7 will have incompatible ranges.  It would be
> !  pointless to try and do anything with i_7's range because
> !  anything dominated by 'if (i_5 < 5)' will be optimized away.
> !  Note, due to the wa in which simulation proceeds, the statement
> !  i_7 = ASSERT_EXPR <...> we would never be visited because the
> !  conditional 'if (i_5 < 5)' always evaluates to false.  However,
> !  this extra check does not hurt and may protect against future
> !  changes to VRP that may get into a situation similar to the
> !  NULL pointer dereference example.
> !
> !  Note that these compatibility tests are only needed when dealing
> !  with ranges or a mix of range and anti-range.  If VAR_VR and VR_P
> !  are both anti-ranges, they will always be compatible, because two
> !  anti-ranges will always have a non-empty intersection.  */
> !
> !   var_vr = get_value_range (var);
> !
> !   /* We may need to make adjustments when VR_P and VAR_VR are numeric
> !  ranges or anti-ranges.  */
> !   if (vr_p->type == VR_VARYING
> !   || vr_p->type == VR_UNDEFINED
> !   || var_vr->type == VR_VARYING
> !   || var_vr->type == VR_UNDEFINED
> !   || symbolic_range_p (vr_p)
> !   || symbolic_range_p (var_vr))
> ! return;
> !
> !   if (var_vr->type == VR_RANGE && vr_p->type == VR_RANGE)
> ! {
> !   /* If the two ranges have a non-empty intersection, we can
> !refine the resulting range.  Since the assert expression
> !creates an equivalency and at the same time it asserts a
> !predicate, we can take the intersection of the two ranges to
> !get better precision.  */
> !   if (value_ranges_intersect_p (var_vr, vr_p))
> !   {
> ! /* Use the larger of the two minimums.  */
> ! if (compare_values (vr_p->min, var_vr->min) == -1)
> !   min = var_vr->min;
> ! else
> !   min = vr_p->min;
> !
> ! /* Use the smaller of the two maximums.  */
> ! if (compare_values (vr_p->max, var_vr->max) == 1)
> !   max = var_vr->max;
> ! 

Re: [Patch, Fortran] Fix module I/O with assumed-rank arrays

2012-07-26 Thread Tobias Burnus

On 07/26/2012 10:00 AM, Mikael Morin wrote:

I assume this sits on top of the previous patch? Then OK for both.


Yes. It was supposed to be a complete patch, but as I screwed up (git 
diff vs. git diff --cached, combined with git add), it was only an 
interdiff.


Thanks for the review. I committed it as Rev. 189881.

Tobias,
who should really avoid late-evening patches and feels the need for 
vacation.
Index: gcc/fortran/ChangeLog
===
--- gcc/fortran/ChangeLog	(revision 189880)
+++ gcc/fortran/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2012-07-26  Alessandro Fanfarillo  
+	Tobias Burnus  
+
+	* module.c (mio_array_spec): Don't read as->lower for
+	assumed-rank arrays.
+
 2012-07-25  Tobias Burnus  
 
 	* trans-types.c (gfc_real16_is_float128): Fix spelling
Index: gcc/fortran/module.c
===
--- gcc/fortran/module.c	(revision 189880)
+++ gcc/fortran/module.c	(working copy)
@@ -2359,9 +2359,15 @@
 
   if (iomode == IO_OUTPUT)
 {
+  int rank;
+
   if (*asp == NULL)
 	goto done;
   as = *asp;
+
+  /* mio_integer expects nonnegative values.  */
+  rank = as->rank > 0 ? as->rank : 0;
+  mio_integer (&rank);
 }
   else
 {
@@ -2372,20 +2378,23 @@
 	}
 
   *asp = as = gfc_get_array_spec ();
+  mio_integer (&as->rank);
 }
 
-  mio_integer (&as->rank);
   mio_integer (&as->corank);
   as->type = MIO_NAME (array_type) (as->type, array_spec_types);
 
+  if (iomode == IO_INPUT && as->type == AS_ASSUMED_RANK)
+as->rank = -1;
   if (iomode == IO_INPUT && as->corank)
 as->cotype = (as->type == AS_DEFERRED) ? AS_DEFERRED : AS_EXPLICIT;
 
-  for (i = 0; i < as->rank + as->corank; i++)
-{
-  mio_expr (&as->lower[i]);
-  mio_expr (&as->upper[i]);
-}
+  if (as->rank > 0)
+for (i = 0; i < as->rank + as->corank; i++)
+  {
+	mio_expr (&as->lower[i]);
+	mio_expr (&as->upper[i]);
+  }
 
 done:
   mio_rparen ();


Re: [PATCH/MIPS] Emit stack executable note

2012-07-26 Thread Hans-Peter Nilsson
On Wed, 25 Jul 2012, Andrew Pinski wrote:
> Hi,
>   The Linux kernel already supports non-executable stack since around
> February 2010.  This patch has GCC emit the notes that are associated
> with non-executable stack.

What does the kernel do when the note isn't present?

> OK?  Bootstrapped and tested on mips64-linux-gnu with kernel already
> supporting the non-executable stack with no regressions.
>
> Thanks,
> Andrew Pinski
>
> ChangeLog:
>
> * config/mips/linux-common.h (TARGET_ASM_FILE_END): Define.
>

I can't quote your non-inline patch so I'll copy-paste it.

+
+/* For MIPS, the default is to assume *no* executable stack, so output
+an executable-stack-note only when needed.  */
+#define TARGET_ASM_FILE_END file_end_indicate_exec_stack

The comment is wrong, your patch is always emitting the note.
Besides IIRC, *glibc* defaults to an executable stack for MIPS,
so you need to emit it if (!trampolines_created) or something
like that.  See the CRIS cris_file_end from which the comment
seems copy-pasted, but the opposite condition. :)

If the kernel and glibc are in contradiction regarding the
default, you do need to use a slightly different expression,
checking too whether you're creating an executable, if you
really mean to emit the note only when needed.

brgds, H-P


Re: PR 54075 Fix hashtable::reserve

2012-07-26 Thread Jonathan Wakely
On 25 July 2012 21:29, François Dumont wrote:
> (_Hashtable<>::rehash): Likewise. Set _M_prev_resize to 0 to avoid
> the hashtable to be shrinking on next insertion.

Not "to be shrinking" just "shrinking", but nevermind.


[patch[ Add explanations to sbitmap, bitmap, and sparseset

2012-07-26 Thread Steven Bosscher
Hello,

Add some explanations because I see a lot of places where the choice
of data structure is less than optimal.

Also some functional changes: sbitmap with popcounts are only used in
ebitmap, and they penalize the "normal" case without popcount a lot.

Bootstrapped&tested on powepc64-unknown-linux-gnu. OK?

Ciao!
Steven


sets.diff
Description: Binary data


Re: [patch[ Add explanations to sbitmap, bitmap, and sparseset

2012-07-26 Thread Richard Guenther
On Thu, Jul 26, 2012 at 11:16 AM, Steven Bosscher  wrote:
> Hello,
>
> Add some explanations because I see a lot of places where the choice
> of data structure is less than optimal.
>
> Also some functional changes: sbitmap with popcounts are only used in
> ebitmap, and they penalize the "normal" case without popcount a lot.
>
> Bootstrapped&tested on powepc64-unknown-linux-gnu. OK?

Ok!  Thanks for adding this exhaustive documentation.

Btw, ebitmap is unused since it was added - maybe we should simply remove
it ...?

Thanks,
Richard.

> Ciao!
> Steven


[Patch ARM] Committed - Adjust a couple of neon intrinsics testcases.

2012-07-26 Thread Ramana Radhakrishnan
Hi,

This adjusts the test for vld1Q_dups/u64 which started failing after
the recent fixes in this area.

Committed to trunk after testing.  I've got a few more patches to the
neon intrinsics tests but this leaves these tests in a sane state.

Ramana


2012-07-26  Ramana Radhakrishnan  

* config/arm/neon.ml (ops): Fix regexp for vld1Q_dups64 and
vld1Q_dupu64 tests.

2012-07-26  Ramana Radhakrishnan  

* gcc.target/arm/neon/vld1Q_dupu64.c: Regenerate.
* gcc.target/arm/neon/vld1Q_dups64.c: Likewise.


Re: [patch[ Add explanations to sbitmap, bitmap, and sparseset

2012-07-26 Thread Steven Bosscher
On Thu, Jul 26, 2012 at 11:23 AM, Richard Guenther
 wrote:
> Ok!  Thanks for adding this exhaustive documentation.

There's more to come! I want to add some explanations to ebitmap,
pointer-set, fibheap, and splay-tree as sets, and add a chapter in the
gccint manual too.

Now if only you'd document those loop changes... ;-)


> Btw, ebitmap is unused since it was added - maybe we should simply remove
> it ...?

I wouldn't remove it just yet. I'm going to make sure that bitmap.[ch]
and ebitmap.[ch] provide the same interface and see if there are
places where ebitmap is a better choice than bitmap or sbitmap (cprop
and gcse.c come to mind).

Ciao!
Steven


Re: [patch[ Add explanations to sbitmap, bitmap, and sparseset

2012-07-26 Thread Alexander Monakov
Hello,

+   the set.  If an element I is in the set, then sparse[I] is the
+   index of I in the dense vector, and dense[I] == I.  The dense
^
This should read "dense[sparse[I]] == I"

Thanks

Alexander



[PATCH] Fix PR54098

2012-07-26 Thread Richard Guenther

This fixes PR54098 - if the original range was UNDEFINED simply
use the update and iterate once more.

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

Richard.

2012-07-26  Richard Guenther  

PR tree-optimization/54098
* tree-vrp.c (vrp_visit_phi_node): Iterate once more if the
original range was UNDEFINED.

* gcc.dg/torture/pr54098.c: New testcase.

Index: gcc/tree-vrp.c
===
*** gcc/tree-vrp.c  (revision 189882)
--- gcc/tree-vrp.c  (working copy)
*** vrp_visit_phi_node (gimple phi)
*** 7684,7693 
   when the new value is slightly bigger or smaller than the
   previous one.  We don't do this if we have seen a new executable
   edge; this helps us avoid an overflow infinity for conditionals
!  which are not in a loop.  */
if (edges > 0
&& gimple_phi_num_args (phi) > 1
!   && edges == old_edges)
  {
int cmp_min = compare_values (lhs_vr->min, vr_result.min);
int cmp_max = compare_values (lhs_vr->max, vr_result.max);
--- 7684,7695 
   when the new value is slightly bigger or smaller than the
   previous one.  We don't do this if we have seen a new executable
   edge; this helps us avoid an overflow infinity for conditionals
!  which are not in a loop.  If the old value-range was VR_UNDEFINED
!  use the updated range and iterate one more time.  */
if (edges > 0
&& gimple_phi_num_args (phi) > 1
!   && edges == old_edges
!   && lhs_vr->type != VR_UNDEFINED)
  {
int cmp_min = compare_values (lhs_vr->min, vr_result.min);
int cmp_max = compare_values (lhs_vr->max, vr_result.max);
Index: gcc/testsuite/gcc.dg/torture/pr54098.c
===
*** gcc/testsuite/gcc.dg/torture/pr54098.c  (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr54098.c  (working copy)
***
*** 0 
--- 1,72 
+ /* { dg-do compile } */
+ 
+ extern int printf(const char *, ...);
+ struct list_head {
+   struct list_head *next, *prev;
+ };
+ struct resource {
+   unsigned long long start;
+   unsigned long long end;
+   unsigned long flags;
+   struct resource *parent, *sibling, *child;
+ };
+ struct pci_dev {
+   struct list_head bus_list;
+   struct resource resource[12];
+ };
+ struct pci_bus {
+   struct list_head devices;
+   unsigned char secondary;
+   unsigned char subordinate;
+ };
+ struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
+ static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned 
long type) {
+   int i;
+   struct resource *r;
+   unsigned long type_mask = 0x0100 | 0x0200 | 0x2000;
+   for (i = 0; (r = pci_bus_resource_n(bus, i)) || i < 4; i++) {
+   if (r && (r->flags & type_mask) == type && !r->parent) return r;
+   }
+   return ((void *)0);
+ }
+ static unsigned long long calculate_memsize(unsigned long long size, unsigned 
long long min_size, unsigned long long size1, unsigned long long old_size, 
unsigned long long align) {
+   if (old_size == 1 ) old_size = 0;
+   if (size < old_size) size = old_size;
+   return size;
+ }
+ void pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long 
type, unsigned long long min_size, unsigned long long add_size, void 
*realloc_head) {
+   struct pci_dev *dev;
+   unsigned long long min_align, align, size, size0, size1;
+   int order;
+   struct resource *b_res = find_free_bus_resource(bus, type);
+   unsigned long long children_add_size = 0;
+   if (!b_res) return;
+   for (dev = ({
+   const typeof( ((typeof(*dev) *)0)->bus_list ) 
*__mptr = ((&bus->devices)->next);
+   (typeof(*dev) *)( (char *)__mptr - 
__builtin_offsetof(typeof(*dev),bus_list) );
+   }
+  );
+   &dev->bus_list != (&bus->devices);
+   dev = ({
+   const typeof( ((typeof(*dev) *)0)->bus_list ) 
*__mptr = (dev->bus_list.next);
+   (typeof(*dev) *)( (char *)__mptr - 
__builtin_offsetof(typeof(*dev),bus_list) );
+   }
+ )) {
+   int i;
+   for (i = 0; i < 12; i++) {
+   struct resource *r = &dev->resource[i];
+   unsigned long long r_size;
+   if (r->parent || (r->flags & mask) != type) continue;
+   r_size = r->end - r->start + 1;
+   if (order > 11) {
+   printf("%d: %pR %#llx\n", i, r, (unsigned long 
long) align);
+   }
+   size += r_size;
+   }
+   }
+   if (ch

[PATCH]Remove duplicate check on BRANCH_COST in fold-const.c

2012-07-26 Thread Bin Cheng
Hi,
This patch removes the duplicate check on BRANCH_COST in fold_truth_andor.
The BRANCH_COST condition removed is a duplicate of the default definition
of LOGICAL_OP_NON_SHORT_CIRCUIT.
All current targets (mips and rs6000) that provide non-default definitions
of LOGICAL_OP_SHORT_CIRCUIT set it to 0, so this patch is therefore just a
code cleanup and does not change behaviour in the compiler.

I built mipsel-elf cross compiler and compared newlib/libstdc++ compiled by
the patched/original compilers.

Is it OK?

Thanks

2012-07-26  Bin Cheng  

* fold-const.c (fold_truth_andor) Remove duplicated check on
BRANCH_COST.Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 189835)
+++ gcc/fold-const.c(working copy)
@@ -8443,9 +8443,7 @@
   if ((tem = fold_truth_andor_1 (loc, code, type, arg0, arg1)) != 0)
 return tem;
 
-  if ((BRANCH_COST (optimize_function_for_speed_p (cfun),
-   false) >= 2)
-  && LOGICAL_OP_NON_SHORT_CIRCUIT
+  if (LOGICAL_OP_NON_SHORT_CIRCUIT
   && (code == TRUTH_AND_EXPR
   || code == TRUTH_ANDIF_EXPR
   || code == TRUTH_OR_EXPR


[PATCH arm]Define LOGICAL_OP_NON_SHORT_CIRCUIT in ARM back end

2012-07-26 Thread Bin Cheng
Hi,
This patch defines LOGICAL_OP_NON_SHORT_CIRCUIT in arm back-end by calling a
new hook function(logical_op_non_short_circuit") in tune_params structure.
For most cases the value of the macro is same as the default version in
fold-const.c, while it is "FALSE" to prefer short circuit when optimizing
for size on armv6-m processors. This brings us ~0.2% code size improvement
for CSiBE benchmark on cortex-m0.
 
Also tunes on other ARM processes could be followed.

No regression introduced, is it OK?
Thanks

2012-07-26  Bin Cheng  

* config/arm/arm-cores.def (cortex-m1, cortex-m0, cortex-m0plus):
Use v6m.
* config/arm/arm-protos.h (tune_params): Add
logical_op_non_short_circuit hook.
* config/arm/arm.c (arm_default_logical_op_non_short_circuit)
(arm_v6m_logical_op_non_short_circuit): New functions.
(arm_slowmul_tune, arm_fastmul_tune, arm_strongarm_tune,
arm_xscale_tune)
(arm_9e_tune, arm_v6t2_tune, arm_cortex_tune, arm_cortex_a15_tune)
(arm_cortex_a5_tune, arm_cortex_a9_tune, arm_fa726te_tune): Set the
field
logical_op_non_short_circuit to
arm_default_logical_op_non_short_circuit.
(arm_v6m_tune): New tune_params struct.
* config/arm/arm.h (LOGICAL_OP_NON_SHORT_CIRCUIT): Use the hook
logical_op_non_short_circuit from current_tune structure.
Index: gcc/config/arm/arm.c
===
--- gcc/config/arm/arm.c(revision 189835)
+++ gcc/config/arm/arm.c(working copy)
@@ -265,6 +265,9 @@
 static int arm_default_branch_cost (bool, bool);
 static int arm_cortex_a5_branch_cost (bool, bool);
 
+static bool arm_default_logical_op_non_short_circuit (void);
+static bool arm_v6m_logical_op_non_short_circuit (void);
+
 static bool arm_vectorize_vec_perm_const_ok (enum machine_mode vmode,
 const unsigned char *sel);
 
@@ -876,7 +879,8 @@
   ARM_PREFETCH_NOT_BENEFICIAL,
   true,/* Prefer constant 
pool.  */
   arm_default_branch_cost,
-  false /* Prefer LDRD/STRD.  */
+  false,   /* Prefer LDRD/STRD.  */
+  arm_default_logical_op_non_short_circuit,
 };
 
 const struct tune_params arm_fastmul_tune =
@@ -888,7 +892,8 @@
   ARM_PREFETCH_NOT_BENEFICIAL,
   true,/* Prefer constant 
pool.  */
   arm_default_branch_cost,
-  false /* Prefer LDRD/STRD.  */
+  false,   /* Prefer LDRD/STRD.  */
+  arm_default_logical_op_non_short_circuit,
 };
 
 /* StrongARM has early execution of branches, so a sequence that is worth
@@ -903,7 +908,8 @@
   ARM_PREFETCH_NOT_BENEFICIAL,
   true,/* Prefer constant 
pool.  */
   arm_default_branch_cost,
-  false /* Prefer LDRD/STRD.  */
+  false,   /* Prefer LDRD/STRD.  */
+  arm_default_logical_op_non_short_circuit,
 };
 
 const struct tune_params arm_xscale_tune =
@@ -915,7 +921,8 @@
   ARM_PREFETCH_NOT_BENEFICIAL,
   true,/* Prefer constant 
pool.  */
   arm_default_branch_cost,
-  false /* Prefer LDRD/STRD.  */
+  false,   /* Prefer LDRD/STRD.  */
+  arm_default_logical_op_non_short_circuit,
 };
 
 const struct tune_params arm_9e_tune =
@@ -927,7 +934,8 @@
   ARM_PREFETCH_NOT_BENEFICIAL,
   true,/* Prefer constant 
pool.  */
   arm_default_branch_cost,
-  false /* Prefer LDRD/STRD.  */
+  false,   /* Prefer LDRD/STRD.  */
+  arm_default_logical_op_non_short_circuit,
 };
 
 const struct tune_params arm_v6t2_tune =
@@ -939,7 +947,8 @@
   ARM_PREFETCH_NOT_BENEFICIAL,
   false,   /* Prefer constant pool.  */
   arm_default_branch_cost,
-  false /* Prefer LDRD/STRD.  */
+  false,   /* Prefer LDRD/STRD.  */
+  arm_default_logical_op_non_short_circuit,
 };
 
 /* Generic Cortex tuning.  Use more specific tunings if appropriate.  */
@@ -952,7 +961,8 @@
   ARM_PREFETCH_NOT_BENEFICIAL,
   false,   /* Prefer constant pool.  */
   arm_default_branch_cost,
-  false /* Prefer LDRD/STRD.  */
+  false,   /* Prefer LDRD/STRD.  */
+  arm_default_logical_op_non_short_circuit,
 };
 
 const struct tune_params arm_cortex_a15_tune =
@@ -964,7 +974,8 @@
   ARM_PREFETCH_NOT_BENEFICIAL,
   false,   /* Prefer constant pool.  */
   arm_default_branch_cost,
-  true  

Re: [PATCH]Remove duplicate check on BRANCH_COST in fold-const.c

2012-07-26 Thread Andrew Pinski
On Thu, Jul 26, 2012 at 3:20 AM, Bin Cheng  wrote:
> Hi,
> This patch removes the duplicate check on BRANCH_COST in fold_truth_andor.
> The BRANCH_COST condition removed is a duplicate of the default definition
> of LOGICAL_OP_NON_SHORT_CIRCUIT.
> All current targets (mips and rs6000) that provide non-default definitions
> of LOGICAL_OP_SHORT_CIRCUIT set it to 0, so this patch is therefore just a
> code cleanup and does not change behaviour in the compiler.
>
> I built mipsel-elf cross compiler and compared newlib/libstdc++ compiled by
> the patched/original compilers.
>
> Is it OK?

Just some history here on this.  The BRANCH COST check was there
before LOGICAL_OP_NON_SHORT_CIRCUIT was added.  I will be submitting a
patch which changes the MIPS definition soon but it will not be based
on the branch cost but rather than another option.  So in the end it
might not be redundant as it is currently.

Thanks,
Andrew


Re: [PATCH arm]Define LOGICAL_OP_NON_SHORT_CIRCUIT in ARM back end

2012-07-26 Thread Ramana Radhakrishnan
> No regression introduced, is it OK?

By testing in what configuration ?

Ramana


RE: [PATCH arm]Define LOGICAL_OP_NON_SHORT_CIRCUIT in ARM back end

2012-07-26 Thread Bin Cheng


> -Original Message-
> From: Ramana Radhakrishnan [mailto:ramana.radhakrish...@linaro.org]
> Sent: Thursday, July 26, 2012 6:45 PM
> To: Bin Cheng
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH arm]Define LOGICAL_OP_NON_SHORT_CIRCUIT in ARM back
end
> 
> > No regression introduced, is it OK?
> 
> By testing in what configuration ?
Since the patch affects only armv6-m, I measured and test it on cortex-m0.

Thanks.





Re: [Patch, Fortran, committed] Some spell fixes

2012-07-26 Thread Tobias Burnus

On 07/25/2012 08:04 PM, Tobias Burnus wrote:

Committed as obvious (Rev. 189859).


I just saw that I missed the testsuite changes. I have now committed 
them as Rev. 189887.


Tobias
Index: testsuite/gfortran.dg/contiguous_1.f90
===
--- testsuite/gfortran.dg/contiguous_1.f90	(revision 189886)
+++ testsuite/gfortran.dg/contiguous_1.f90	(working copy)
@@ -129,7 +129,7 @@ subroutine C1241
   integer, pointer, contiguous :: a(:)
   integer, pointer :: b(:)
   call test(a)
-  call test(b) ! { dg-error "must be simply contigous" }
+  call test(b) ! { dg-error "must be simply contiguous" }
 contains
   subroutine test(x)
 integer, pointer, contiguous :: x(:)
@@ -169,7 +169,7 @@ end subroutine sect12528
 subroutine test34
   implicit none
   integer, volatile,pointer :: a(:,:),i
-  call foo(a(2,2:3:2)) ! { dg-error "must be simply contigous" }
+  call foo(a(2,2:3:2)) ! { dg-error "must be simply contiguous" }
 contains
   subroutine foo(x)
 integer, pointer, contiguous, volatile :: x(:)
Index: testsuite/gfortran.dg/proc_ptr_32.f90
===
--- testsuite/gfortran.dg/proc_ptr_32.f90	(revision 189886)
+++ testsuite/gfortran.dg/proc_ptr_32.f90	(working copy)
@@ -6,7 +6,7 @@
 
   implicit none
   procedure(my_dcos), pointer :: f
-  f => my_dcos   ! { dg-error "invalid in procedure pointer assigment" }
+  f => my_dcos   ! { dg-error "invalid in procedure pointer assignment" }
 contains
   real elemental function my_dcos(x)
 real, intent(in) :: x
Index: testsuite/ChangeLog
===
--- testsuite/ChangeLog	(revision 189886)
+++ testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2012-07-26  Tobias Burnus  
+
+	* gfortran.dg/contiguous_1.f90: Update dg-error.
+	* gfortran.dg/proc_ptr_32.f90: Ditto.
+
 2012-07-26  Richard Guenther  
 
 	PR tree-optimization/54098


Re: [patch[ Add explanations to sbitmap, bitmap, and sparseset

2012-07-26 Thread Steven Bosscher
On Thu, Jul 26, 2012 at 12:14 PM, Alexander Monakov  wrote:
> Hello,
>
> +   the set.  If an element I is in the set, then sparse[I] is the
> +   index of I in the dense vector, and dense[I] == I.  The dense
> ^
> This should read "dense[sparse[I]] == I"

Of course. Thanks for spotting this mistake!

Ciao!
Steven


Re: PR 54075 Fix hashtable::reserve

2012-07-26 Thread François Dumont

Attached patch applied on 4.7 branch.

Tested under Linux x86_64.

I will fix this small english issue in trunk ChangeLog.

François


On 07/26/2012 11:11 AM, Jonathan Wakely wrote:

On 25 July 2012 21:29, François Dumont wrote:

 (_Hashtable<>::rehash): Likewise. Set _M_prev_resize to 0 to avoid
 the hashtable to be shrinking on next insertion.

Not "to be shrinking" just "shrinking", but nevermind.



Index: include/bits/hashtable.h
===
--- include/bits/hashtable.h	(revision 189710)
+++ include/bits/hashtable.h	(working copy)
@@ -760,11 +760,12 @@
 	_M_element_count(0),
 	_M_rehash_policy()
   {
-	_M_bucket_count = std::max(_M_rehash_policy._M_next_bkt(__bucket_hint),
-   _M_rehash_policy.
-   _M_bkt_for_elements(__detail::
-		   __distance_fw(__f,
- __l)));
+	_M_bucket_count =
+	  _M_rehash_policy._M_bkt_for_elements(__detail::__distance_fw(__f,
+   __l));
+	if (_M_bucket_count <= __bucket_hint)
+	  _M_bucket_count = _M_rehash_policy._M_next_bkt(__bucket_hint);
+
 // We don't want the rehash policy to ask for the hashtable to shrink
 // on the first insertion so we need to reset its previous resize
 	// level.
@@ -1582,10 +1583,20 @@
 rehash(size_type __n)
 {
   const _RehashPolicyState& __saved_state = _M_rehash_policy._M_state();
-  _M_rehash(std::max(_M_rehash_policy._M_next_bkt(__n),
-			 _M_rehash_policy._M_bkt_for_elements(_M_element_count
-			  + 1)),
-		__saved_state);
+  std::size_t __buckets
+	= _M_rehash_policy._M_bkt_for_elements(_M_element_count + 1);
+  if (__buckets <= __n)
+	__buckets = _M_rehash_policy._M_next_bkt(__n);
+
+  if (__buckets != _M_bucket_count)
+	{
+	  _M_rehash(__buckets, __saved_state);
+	  
+	  // We don't want the rehash policy to ask for the hashtable to shrink
+	  // on the next insertion so we need to reset its previous resize
+	  // level.
+	  _M_rehash_policy._M_prev_resize = 0;
+	}
 }
 
   template
+
+	PR libstdc++/54075
+	* include/bits/hashtable.h
+	(_Hashtable<>::_Hashtable(_InputIterator, _InputIterator,
+	size_type, ...): Remove std::max usage to guarantee that hashtable
+	state is consistent with hash policy state.
+	(_Hashtable<>::rehash): Likewise. Set _M_prev_resize to 0 to avoid
+	the hashtable shrinking on next insertion.
+	* testsuite/23_containers/unordered_set/modifiers/reserve.cc: New.
+	* testsuite/23_containers/unordered_multiset/modifiers/reserve.cc: New.
+	* testsuite/23_containers/unordered_map/modifiers/reserve.cc: New.
+	* testsuite/23_containers/unordered_multimap/modifiers/reserve.cc: New.
+
 2012-07-20  Paolo Carlini  
 
 	* testsuite/30_threads/thread/adl.cc: Add missing dg-requires.
Index: testsuite/23_containers/unordered_multimap/modifiers/reserve.cc
===
--- testsuite/23_containers/unordered_multimap/modifiers/reserve.cc	(revision 0)
+++ testsuite/23_containers/unordered_multimap/modifiers/reserve.cc	(revision 189889)
@@ -0,0 +1,48 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2012 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+#include 
+#include 
+
+bool test __attribute__((unused)) = true;
+
+void test01()
+{
+  const int N = 1000;
+
+  typedef std::unordered_multimap MMap;
+  MMap m;
+  m.reserve(N * 2);
+
+  std::size_t bkts = m.bucket_count();
+  for (int i = 0; i != N; ++i)
+{
+  m.insert(std::make_pair(i, i));
+  m.insert(std::make_pair(i, i));
+  // As long as we insert less than the reserved number of elements we
+  // shouldn't experiment any rehash.
+  VERIFY( m.bucket_count() == bkts );
+}
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
Index: testsuite/23_containers/unordered_set/modifiers/reserve.cc
===
--- testsuite/23_containers/unordered_set/modifiers/reserve.cc	(revision 0)
+++ testsuite/23_containers/unordered_set/modifiers/reserve.cc	(revision 189889)
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2012 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or

Re: [PATCH arm]Define LOGICAL_OP_NON_SHORT_CIRCUIT in ARM back end

2012-07-26 Thread Richard Earnshaw
On 26/07/12 11:21, Bin Cheng wrote:
> Hi,
> This patch defines LOGICAL_OP_NON_SHORT_CIRCUIT in arm back-end by calling a
> new hook function(logical_op_non_short_circuit") in tune_params structure.
> For most cases the value of the macro is same as the default version in
> fold-const.c, while it is "FALSE" to prefer short circuit when optimizing
> for size on armv6-m processors. This brings us ~0.2% code size improvement
> for CSiBE benchmark on cortex-m0.
>  
> Also tunes on other ARM processes could be followed.
> 
> No regression introduced, is it OK?
> Thanks
> 

This all looks way too complex.  It shouldn't be necessary to
write a whole load of per-tune method calls to deal with this.  What we
need is a simple parameter in the tune table.

So, LOGICAL_OP_NON_SHORT_CIRCUIT, should effectively be:

if (OPTIMIZE_SIZE)
return ANSWER_BASED_ON_ISA;
else
return tune->log_op_non_short_circuit[TARGET_ARM ? 0 : 1];

Where tune->log_op_non_short_circuit[2] is defined for each tuning
table, to cover ARM and Thumb states.

ANSWER_BASED_ON_ISA will do the right thing for Thumb1, Thumb2 and ARM
depending on which leads to smallest code.

R.

> 2012-07-26  Bin Cheng  
> 
>   * config/arm/arm-cores.def (cortex-m1, cortex-m0, cortex-m0plus):
> Use v6m.
>   * config/arm/arm-protos.h (tune_params): Add
> logical_op_non_short_circuit hook.
>   * config/arm/arm.c (arm_default_logical_op_non_short_circuit)
>   (arm_v6m_logical_op_non_short_circuit): New functions.
>   (arm_slowmul_tune, arm_fastmul_tune, arm_strongarm_tune,
> arm_xscale_tune)
>   (arm_9e_tune, arm_v6t2_tune, arm_cortex_tune, arm_cortex_a15_tune)
>   (arm_cortex_a5_tune, arm_cortex_a9_tune, arm_fa726te_tune): Set the
> field
>   logical_op_non_short_circuit to
> arm_default_logical_op_non_short_circuit.
>   (arm_v6m_tune): New tune_params struct.
>   * config/arm/arm.h (LOGICAL_OP_NON_SHORT_CIRCUIT): Use the hook
>   logical_op_non_short_circuit from current_tune structure.
> 
> 
> short-circuit-20120726.txt
> 
> 
> Index: gcc/config/arm/arm.c
> ===
> --- gcc/config/arm/arm.c  (revision 189835)
> +++ gcc/config/arm/arm.c  (working copy)
> @@ -265,6 +265,9 @@
>  static int arm_default_branch_cost (bool, bool);
>  static int arm_cortex_a5_branch_cost (bool, bool);
>  
> +static bool arm_default_logical_op_non_short_circuit (void);
> +static bool arm_v6m_logical_op_non_short_circuit (void);
> +
>  static bool arm_vectorize_vec_perm_const_ok (enum machine_mode vmode,
>const unsigned char *sel);
>  
> @@ -876,7 +879,8 @@
>ARM_PREFETCH_NOT_BENEFICIAL,
>true,  /* Prefer constant 
> pool.  */
>arm_default_branch_cost,
> -  false /* Prefer LDRD/STRD.  */
> +  false, /* Prefer LDRD/STRD.  */
> +  arm_default_logical_op_non_short_circuit,
>  };
>  
>  const struct tune_params arm_fastmul_tune =
> @@ -888,7 +892,8 @@
>ARM_PREFETCH_NOT_BENEFICIAL,
>true,  /* Prefer constant 
> pool.  */
>arm_default_branch_cost,
> -  false /* Prefer LDRD/STRD.  */
> +  false, /* Prefer LDRD/STRD.  */
> +  arm_default_logical_op_non_short_circuit,
>  };
>  
>  /* StrongARM has early execution of branches, so a sequence that is worth
> @@ -903,7 +908,8 @@
>ARM_PREFETCH_NOT_BENEFICIAL,
>true,  /* Prefer constant 
> pool.  */
>arm_default_branch_cost,
> -  false /* Prefer LDRD/STRD.  */
> +  false, /* Prefer LDRD/STRD.  */
> +  arm_default_logical_op_non_short_circuit,
>  };
>  
>  const struct tune_params arm_xscale_tune =
> @@ -915,7 +921,8 @@
>ARM_PREFETCH_NOT_BENEFICIAL,
>true,  /* Prefer constant 
> pool.  */
>arm_default_branch_cost,
> -  false /* Prefer LDRD/STRD.  */
> +  false, /* Prefer LDRD/STRD.  */
> +  arm_default_logical_op_non_short_circuit,
>  };
>  
>  const struct tune_params arm_9e_tune =
> @@ -927,7 +934,8 @@
>ARM_PREFETCH_NOT_BENEFICIAL,
>true,  /* Prefer constant 
> pool.  */
>arm_default_branch_cost,
> -  false /* Prefer LDRD/STRD.  */
> +  f

Re: [PATCH]Remove duplicate check on BRANCH_COST in fold-const.c

2012-07-26 Thread Richard Earnshaw
On 26/07/12 11:27, Andrew Pinski wrote:
> On Thu, Jul 26, 2012 at 3:20 AM, Bin Cheng  wrote:
>> Hi,
>> This patch removes the duplicate check on BRANCH_COST in fold_truth_andor.
>> The BRANCH_COST condition removed is a duplicate of the default definition
>> of LOGICAL_OP_NON_SHORT_CIRCUIT.
>> All current targets (mips and rs6000) that provide non-default definitions
>> of LOGICAL_OP_SHORT_CIRCUIT set it to 0, so this patch is therefore just a
>> code cleanup and does not change behaviour in the compiler.
>>
>> I built mipsel-elf cross compiler and compared newlib/libstdc++ compiled by
>> the patched/original compilers.
>>
>> Is it OK?
> 
> Just some history here on this.  The BRANCH COST check was there
> before LOGICAL_OP_NON_SHORT_CIRCUIT was added.  I will be submitting a
> patch which changes the MIPS definition soon but it will not be based
> on the branch cost but rather than another option.  So in the end it
> might not be redundant as it is currently.
> 
> Thanks,
> Andrew
> 

You can always factor BRANCH_COST into LOGICAL_OP_NON_SHORT_CIRCUIT (as
the default currently does), so there's no loss of functionality from
removing this currently redundant check.  However, the current
definition is broken in that it makes it impossible to force the
compiler to use this optimization when the branch cost is low.

R.





[Patch, Fortran] Update c_funloc/c_f_procpointer for TS29113

2012-07-26 Thread Tobias Burnus
TS29113 allows also non interoperable procedures with 
c_funloc/c_f_procpointer; hence, this patch allows them with -std=f2008ts:


"The function C F PROCPOINTER from the intrinsic module ISO C BINDING 
has the restriction in ISO/IEC 1539-1:2010 that CPTR and FPTR shall not 
be the C address and interface of a noninteroperable Fortran procedure.


"The function C FUNLOC from the intrinsic module ISO C BINDING has the 
restriction in ISO/IEC 1539-1:2010 that its argument shall be interoperable.


"These restrictions are removed."


Additionally, I changed "parameter" to "argument" and added a diagnostic 
that the first argument to c_f_pointer/c_f_procpointer is the correct 
one - before both accepted c_ptr and c_funptr.


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

Tobias

PS: For c_loc/c_f_pointer a similar restriction has been removed. 
However, to fix c_loc is more complicated as the current implementation 
has several rejects-valid/wrong-code bugs (cf. the existing PRs). For 
the full to-do list of TS29113, see 
http://gcc.gnu.org/ml/fortran/2012-07/msg00115.html
2012-07-26  Tobias Burnus  

	* interface.c (gfc_procedure_use): Return gfc_try instead of void.
	* gfortran.h (gfc_procedure_use): Update prototype.
	* resolve.c (gfc_iso_c_func_interface): Allow noninteroperable
	procedures for c_funloc for TS29113.
	* (gfc_iso_c_sub_interface): Ditto for c_f_procpointer. Add
	diagnostic for c_ptr vs. c_funptr for c_f_(proc)pointer.

2012-07-26  Tobias Burnus  

	* gfortran.dg/c_funloc_tests_6.f90: New.
	* gfortran.dg/c_funloc_tests_7.f90: New.
	* gfortran.dg/c_funloc_tests_5.f03: Compile with -std=f2003.

diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index e1f2e3c..f803916 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2848,7 +2848,7 @@ int gfc_compare_types (gfc_typespec *, gfc_typespec *);
 int gfc_compare_interfaces (gfc_symbol*, gfc_symbol*, const char *, int, int,
 			char *, int, const char *, const char *);
 void gfc_check_interfaces (gfc_namespace *);
-void gfc_procedure_use (gfc_symbol *, gfc_actual_arglist **, locus *);
+gfc_try gfc_procedure_use (gfc_symbol *, gfc_actual_arglist **, locus *);
 void gfc_ppc_use (gfc_component *, gfc_actual_arglist **, locus *);
 gfc_symbol *gfc_search_interface (gfc_interface *, int,
   gfc_actual_arglist **);
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 098ec3d2..0f8951c 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2927,7 +2927,7 @@ check_intents (gfc_formal_arglist *f, gfc_actual_arglist *a)
well, the actual argument list will also end up being properly
sorted.  */
 
-void
+gfc_try
 gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
 {
   /* Warn about calls with an implicit interface.  Special case
@@ -2954,7 +2954,7 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
 	  gfc_error("The pointer object '%s' at %L must have an explicit "
 		"function interface or be declared as array",
 		sym->name, where);
-	  return;
+	  return FAILURE;
 	}
 
   if (sym->attr.allocatable && !sym->attr.external)
@@ -2962,14 +2962,14 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
 	  gfc_error("The allocatable object '%s' at %L must have an explicit "
 		"function interface or be declared as array",
 		sym->name, where);
-	  return;
+	  return FAILURE;
 	}
 
   if (sym->attr.allocatable)
 	{
 	  gfc_error("Allocatable function '%s' at %L must have an explicit "
 		"function interface", sym->name, where);
-	  return;
+	  return FAILURE;
 	}
 
   for (a = *ap; a; a = a->next)
@@ -3009,7 +3009,7 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
 	  && a->expr->ts.type == BT_UNKNOWN)
 	{
 	  gfc_error ("MOLD argument to NULL required at %L", &a->expr->where);
-	  return;
+	  return FAILURE;
 	}
 
 	  /* TS 29113, C407b.  */
@@ -3018,19 +3018,23 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
 	{
 	  gfc_error ("Assumed-rank argument requires an explicit interface "
 			 "at %L", &a->expr->where);
-	  return;
+	  return FAILURE;
 	}
 	}
 
-  return;
+  return SUCCESS;
 }
 
   if (!compare_actual_formal (ap, sym->formal, 0, sym->attr.elemental, where))
-return;
+return FAILURE;
+
+  if (check_intents (sym->formal, *ap) == FAILURE)
+return FAILURE;
 
-  check_intents (sym->formal, *ap);
   if (gfc_option.warn_aliasing)
 check_some_aliasing (sym->formal, *ap);
+
+  return SUCCESS;
 }
 
 
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 370e5cd..b4c3e4d 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -3012,20 +3007,18 @@ gfc_iso_c_func_interface (gfc_symbol *sym, gfc_actual_arglist *args,
 {
   /* TODO: Update this error message to allow for procedure
  pointers onc

Re: [PATCH/MIPS] Emit stack executable note

2012-07-26 Thread Joseph S. Myers
On Wed, 25 Jul 2012, Andrew Pinski wrote:

> * config/mips/linux-common.h (TARGET_ASM_FILE_END): Define.

Do you also need to change libgcc/config/mips/*.S to include the 
appropriate note?

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


Re: [Patch, Fortran] assumed-rank some bound intrinsics support, fix failures and improve diagnostcs

2012-07-26 Thread Mikael Morin
On 21/07/2012 13:08, Tobias Burnus wrote:
> Only failing are:
>   lbound(x) / ubound(x) / shape(x)
> 
Here is a draft for those.
Lightly tested with print *, ...

Mikael

Index: trans-array.c
===
--- trans-array.c	(révision 189883)
+++ trans-array.c	(copie de travail)
@@ -249,6 +249,20 @@ gfc_conv_descriptor_dtype (tree desc)
 
 
 tree
+gfc_conv_descriptor_rank (tree desc)
+{
+  tree tmp;
+  tree dtype;
+
+  dtype = gfc_conv_descriptor_dtype (desc);
+  tmp = build_int_cst (TREE_TYPE (dtype), GFC_DTYPE_RANK_MASK);
+  tmp = fold_build2_loc (input_location, BIT_AND_EXPR, TREE_TYPE (dtype),
+			 dtype, tmp);
+  return fold_convert (gfc_get_int_type (gfc_default_integer_kind), tmp);
+}
+
+
+tree
 gfc_get_descriptor_dimension (tree desc)
 {
   tree type, field;
@@ -3794,6 +3808,40 @@ done:
 	/* Fall through to supply start and stride.  */
 	case GFC_ISYM_LBOUND:
 	case GFC_ISYM_UBOUND:
+	  {
+		gfc_expr *arg;
+
+		/* This is the variant without DIM=...  */
+		gcc_assert (expr->value.function.actual->next->expr == NULL);
+
+		arg = expr->value.function.actual->expr;
+		if (arg->rank == -1)
+		  {
+		gfc_se se;
+		tree rank, tmp;
+
+		/* The rank (hence the return value's shape) is unknown,
+		   we have to retrieve it.  */
+		gfc_init_se (&se, NULL);
+		se.descriptor_only = 1;
+		gfc_conv_expr (&se, arg);
+		/* This is a bare variable, so there is no preliminary
+		   or cleanup code.  */
+		gcc_assert (se.pre.head == NULL_TREE
+&& se.post.head == NULL_TREE);
+		rank = gfc_conv_descriptor_rank (se.expr);
+		tmp = fold_build2_loc (input_location, MINUS_EXPR,
+	   gfc_array_index_type,
+	   fold_convert (gfc_array_index_type,
+			 rank),
+	   gfc_index_one_node);
+		info->end[0] = gfc_evaluate_now (tmp, &loop->pre);
+		info->start[0] = gfc_index_zero_node;
+		info->stride[0] = gfc_index_one_node;
+		continue;
+		  }
+		  /* Otherwise fall through GFC_SS_FUNCTION.  */
+	  }
 	case GFC_ISYM_LCOBOUND:
 	case GFC_ISYM_UCOBOUND:
 	case GFC_ISYM_THIS_IMAGE:
@@ -4430,22 +4478,11 @@ set_loop_bounds (gfc_loopinfo *loop)
 	  continue;
 	}
 
-	  /* TODO: Pick the best bound if we have a choice between a
-	 function and something else.  */
-	  if (ss_type == GFC_SS_FUNCTION)
-	{
-	  loopspec[n] = ss;
-	  continue;
-	}
-
 	  /* Avoid using an allocatable lhs in an assignment, since
 	 there might be a reallocation coming.  */
 	  if (loopspec[n] && ss->is_alloc_lhs)
 	continue;
 
-	  if (ss_type != GFC_SS_SECTION)
-	continue;
-
 	  if (!loopspec[n])
 	loopspec[n] = ss;
 	  /* Criteria for choosing a loop specifier (most important first):
@@ -4520,6 +4557,20 @@ set_loop_bounds (gfc_loopinfo *loop)
 	  gcc_assert (loop->to[n] == NULL_TREE);
 	  break;
 
+	case GFC_SS_INTRINSIC:
+	  {
+		gfc_expr *expr = loopspec[n]->info->expr;
+
+		/* The {l,u}bound of an assumed rank.  */
+		gcc_assert ((expr->value.function.isym->id == GFC_ISYM_LBOUND
+			 || expr->value.function.isym->id == GFC_ISYM_UBOUND)
+			 && expr->value.function.actual->next->expr == NULL
+			 && expr->value.function.actual->expr->rank == -1);
+
+		loop->to[n] = info->end[dim];
+		break;
+	  }
+
 	default:
 	  gcc_unreachable ();
 	}
Index: trans-array.h
===
--- trans-array.h	(révision 189881)
+++ trans-array.h	(copie de travail)
@@ -154,6 +154,7 @@ tree gfc_conv_descriptor_data_get (tree);
 tree gfc_conv_descriptor_data_addr (tree);
 tree gfc_conv_descriptor_offset_get (tree);
 tree gfc_conv_descriptor_dtype (tree);
+tree gfc_conv_descriptor_rank (tree);
 tree gfc_get_descriptor_dimension (tree);
 tree gfc_conv_descriptor_stride_get (tree, tree);
 tree gfc_conv_descriptor_lbound_get (tree, tree);
Index: iresolve.c
===
--- iresolve.c	(révision 189881)
+++ iresolve.c	(copie de travail)
@@ -134,9 +134,12 @@ resolve_bound (gfc_expr *f, gfc_expr *array, gfc_e
   if (dim == NULL)
 {
   f->rank = 1;
-  f->shape = gfc_get_shape (1);
-  mpz_init_set_ui (f->shape[0], coarray ? gfc_get_corank (array)
-	: array->rank);
+  if (array->rank != -1)
+	{
+	  f->shape = gfc_get_shape (1);
+	  mpz_init_set_ui (f->shape[0], coarray ? gfc_get_corank (array)
+		: array->rank);
+	}
 }
 
   f->value.function.name = xstrdup (name);
@@ -2225,8 +2228,12 @@ gfc_resolve_shape (gfc_expr *f, gfc_expr *array, g
 f->ts.kind = gfc_default_integer_kind;
 
   f->rank = 1;
-  f->shape = gfc_get_shape (1);
-  mpz_init_set_ui (f->shape[0], array->rank);
+  if (array->rank != -1)
+{
+  f->shape = gfc_get_shape (1);
+  mpz_init_set_ui (f->shape[0], array->rank);
+}
+ 
   f->value.function.name = gfc_get_string (PREFIX ("shape_%d"), f->ts.kind);
 }
 
Index: trans-

[contrib] Do not use 'with ... as ...' in validate_failures.py

2012-07-26 Thread Diego Novillo
Some of the hosts were we run this script are still using Python 2.4.
This patch replaces the use of 'with ... as ...' to avoid syntax errors.


2012-07-26   Diego Novillo  

* testsuite-management/validate_failures.py: Do not use
'with ... as ...' constructs.


diff --git a/contrib/testsuite-management/validate_failures.py 
b/contrib/testsuite-management/validate_failures.py
index b2c52fc..67ea054 100755
--- a/contrib/testsuite-management/validate_failures.py
+++ b/contrib/testsuite-management/validate_failures.py
@@ -138,12 +138,14 @@ class TestResult(object):
 
 def GetMakefileValue(makefile_name, value_name):
   if os.path.exists(makefile_name):
-with open(makefile_name) as makefile:
-  for line in makefile:
-if line.startswith(value_name):
-  (_, value) = line.split('=', 1)
-  value = value.strip()
-  return value
+makefile = open(makefile_name)
+for line in makefile:
+  if line.startswith(value_name):
+(_, value) = line.split('=', 1)
+value = value.strip()
+makefile.close()
+return value
+makefile.close()
   return None
 
 
@@ -173,10 +175,11 @@ def IsInterestingResult(line):
 def ParseSummary(sum_fname):
   """Create a set of TestResult instances from the given summary file."""
   result_set = set()
-  with open(sum_fname) as sum_file:
-for line in sum_file:
-  if IsInterestingResult(line):
-result_set.add(TestResult(line))
+  sum_file = open(sum_fname)
+  for line in sum_file:
+if IsInterestingResult(line):
+  result_set.add(TestResult(line))
+  sum_file.close()
   return result_set
 
 
@@ -312,10 +315,11 @@ def ProduceManifest(options):
   manifest_name)
 
   actual = GetResults(options.build_dir)
-  with open(manifest_name, 'w') as manifest_file:
-for result in sorted(actual):
-  print result
-  manifest_file.write('%s\n' % result)
+  manifest_file = open(manifest_name, 'w')
+  for result in sorted(actual):
+print result
+manifest_file.write('%s\n' % result)
+  manifest_file.close()
 
   return True
 


Re: [Patch, Fortran] assumed-rank some bound intrinsics support, fix failures and improve diagnostcs

2012-07-26 Thread Mikael Morin
On 26/07/2012 16:53, Mikael Morin wrote:
> On 21/07/2012 13:08, Tobias Burnus wrote:
>> Only failing are:
>>   lbound(x) / ubound(x) / shape(x)
>>
> Here is a draft for those.
> Lightly tested with print *, ...
> 
Better with the tests.


$ ./test1
   1   1
   3   8
   3   8

$ ./test2
  11 101
  13 108
   3   8



program test

  integer :: a(1:3,-2:5)

  call foo(a)

contains
  subroutine foo(arg)
integer :: arg(..)

print *, lbound(arg)
print *, ubound(arg)
print *, shape(arg)
  end subroutine foo
end program test



program test

  integer :: a(1:3,-2:5)
  integer, allocatable :: b(:,:)

  b = foo(a)
  print *,b(:,1)
  print *,b(:,2)
  print *,b(:,3)

contains
  function foo(arg) result(res)
integer :: arg(..)
integer, allocatable :: res(:,:)

allocate(res(rank(arg), 3))

res(:,1) = lbound(arg) + (/ 10, 100 /)
res(:,2) = (/ 10, 100 /) + ubound(arg) 
res(:,3) = shape(arg)

  end function foo
end program test



Re: [Patch, Fortran] assumed-rank some bound intrinsics support, fix failures and improve diagnostcs

2012-07-26 Thread Tobias Burnus

On 07/26/2012 05:12 PM, Mikael Morin wrote:

On 26/07/2012 16:53, Mikael Morin wrote:
Here is a draft for those. Lightly tested with print *, ... 


Looks rather nice. The output for test1 is also  good:

  integer :: a(1:3,-2:5)
gives
  lbound(arg) == [1, 1]
  ubound(arg) == [3, 8]
  shape(arg) == [3, 8]

However, if the dummy is allocatable or a pointer, the result should be:

  lbound(arg) == [1, -2]
  ubound(arg) == [3, 5]
  shape(arg) == [3, 8]

which your second test case doesn't give. (At least that's how I understand TS 
and F2008.)

Except for that issue, I like your patch. Thanks!

Tobias



PING [PATCH] PR preprocessor/53469 - argument tokens of _Pragma miss virtual location

2012-07-26 Thread Dodji Seketeli
Hello

I am friendly pinging this patch that felt below my radar.

Dodji Seketeli  a écrit:

> Hello,
>
> Consider this short test snippet:
>
> -8---
> #define STRINGIFY(x) #x
> #define TEST(x) \
>   _Pragma(STRINGIFY(GCC diagnostic ignored "-Wunused-local-typedefs")) \
>   typedef int myint;
>
> void bar ()
> {
>   TEST(myint)
> }
> -8---
>
> The _Pragma is effectively ignored, and compiling with
> -Wunused-local-typedefs warns on the local typedef, even though the
> pragma should have prevented the warning to be emitted.
>
> This is because when the preprocessor sees the _Pragma operator and
> then goes to handle the first token ('GCC' here) that makes up its
> operands, it retains the spelling location of that token, not its
> virtual location.
>
> Later when diagnostic_report_diagnostic is called to emit the warning
> (or ignore it because of the pragma), it compares the location of the
> first operand of the pragma with the location of the unused location,
> (by calling linemap_location_before_p) and that comparison fails
> because in this case, both locations should be virtual.
>
> This patch fixes the issue by teaching the pragma handling to use
> virtual locations.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.
>
> libcpp/
>
>   PR preprocessor/53469
>   * directives.c (do_pragma): Use the virtual location for the
>   pragma token, instead of its spelling location.
>
> gcc/testsuite/
>
>   PR preprocessor/53469
>   * gcc.dg/cpp/_Pragma7.c: New test case.
> ---
>  gcc/testsuite/ChangeLog |5 +
>  gcc/testsuite/gcc.dg/cpp/_Pragma7.c |   14 ++
>  libcpp/ChangeLog|6 ++
>  libcpp/directives.c |8 +---
>  4 files changed, 30 insertions(+), 3 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/cpp/_Pragma7.c
>
> diff --git a/gcc/testsuite/gcc.dg/cpp/_Pragma7.c 
> b/gcc/testsuite/gcc.dg/cpp/_Pragma7.c
> new file mode 100644
> index 000..a7a5b1b
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/cpp/_Pragma7.c
> @@ -0,0 +1,14 @@
> +/*
> +  Origin: PR preprocessor/53469
> +  { dg-do compile }
> + */
> +
> +#define STRINGIFY(x) #x
> +#define TEST(x) \
> +  _Pragma(STRINGIFY(GCC diagnostic ignored "-Wunused-local-typedefs")) \
> +  typedef int myint;
> +
> +void bar ()
> +{
> +  TEST(myint)
> +}
> diff --git a/libcpp/directives.c b/libcpp/directives.c
> index e46280e..cd880f1 100644
> --- a/libcpp/directives.c
> +++ b/libcpp/directives.c
> @@ -1347,13 +1347,15 @@ static void
>  do_pragma (cpp_reader *pfile)
>  {
>const struct pragma_entry *p = NULL;
> -  const cpp_token *token, *pragma_token = pfile->cur_token;
> +  const cpp_token *token, *pragma_token;
> +  source_location pragma_token_virt_loc = 0;
>cpp_token ns_token;
>unsigned int count = 1;
>  
>pfile->state.prevent_expansion++;
>  
> -  token = cpp_get_token (pfile);
> +  pragma_token = token = cpp_get_token_with_location (pfile,
> +   &pragma_token_virt_loc);
>ns_token = *token;
>if (token->type == CPP_NAME)
>  {
> @@ -1407,7 +1409,7 @@ do_pragma (cpp_reader *pfile)
>  {
>if (p->is_deferred)
>   {
> -   pfile->directive_result.src_loc = pragma_token->src_loc;
> +   pfile->directive_result.src_loc = pragma_token_virt_loc;
> pfile->directive_result.type = CPP_PRAGMA;
> pfile->directive_result.flags = pragma_token->flags;
> pfile->directive_result.val.pragma = p->u.ident;

-- 
Dodji


Re: [PATCH] New fdo summary-based icache sensitive unrolling (issue6351086)

2012-07-26 Thread Teresa Johnson
Ping.

Teresa

On Wed, Jul 18, 2012 at 8:48 AM, Teresa Johnson  wrote:
> Ping (retrying ping in plain text mode so that it goes through properly).
>
> Thanks,
> Teresa
>
> On Wed, Jul 11, 2012 at 10:42 AM, Teresa Johnson  wrote:
>> Ports some patches related to improving FDO program summary information
>> and using it to guide loop unrolling from google branches to mainline.
>> The patch is enhanced to add additional summary information to aid
>> in determining hot/cold decisions.
>>
>> The original patch description is at:
>>   http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00437.html
>> and further discussion about incorporating onto mainline is at:
>>   http://gcc.gnu.org/ml/gcc-patches/2012-06/threads.html#00414
>>
>> Honza, can you take a look to see if this patch meets your needs?
>>
>> Full description:
>>
>> This patch adds new program summary information to the gcov
>> profile files that indicate how many profiled counts compose
>> the majority of the program's execution time. This is used to
>> provide an indication of the overall code size of the program.
>>
>> The new profile summary information is then used to guide
>> codesize based unroll and peel decisions, to prevent those
>> optimizations from increasing code size too much when the
>> program may be sensitive to icache effects.
>>
>> This patch also pulls in dependent portions of google/main r187660 that cache
>> additional loop analysis results in the niter_desc auxiliary information
>> hanging off the loop structure (the optimization portions of that
>> change are not included here, and have an outstanding review request
>> for mainline).
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?
>>
>> Thanks,
>> Teresa
>>
>> 2012-07-11  Teresa Johnson  
>>
>> * libgcc/libgcov.c (sort_by_reverse_gcov_value): New function.
>> (gcov_compute_cutoff_values): Ditto.
>> (gcov_exit): Call gcov_compute_cutoff_values and merge new summary
>> information.
>> * gcc/doc/invoke.texi (roll much): Document new options
>> -fpeel-codesize-limit and -funroll-codesize-limit, and new params
>> codesize-hotness-threshold and unrollpeel-hotness-threshold.
>> * gcc/gcov-io.c (gcov_write_summary): Write new summary info.
>> (gcov_read_summary): Read new summary info.
>> * gcc/gcov-io.h (GCOV_TAG_SUMMARY_LENGTH): Update for new summary 
>> info.
>> (struct gcov_ctr_summary): Add new summary info: num_hot_counters and
>> hot_cutoff_value.
>> * gcc/loop-unroll.c (code_size_limit_factor): New function.
>> (decide_unroll_runtime_iterations): Call code_size_limit_factor
>> to control the unroll factor, and retrieve number of branches from
>> niter_desc instead of via function that walks loop.
>> (decide_peel_simple, decide_unroll_stupid): Ditto.
>> * gcc/coverage.c (read_counts_file): Propagate new summary info.
>> * gcc/loop-iv.c (get_simple_loop_desc): Invoke new analyze_loop_insns
>> function, and add guards to enable this function to work for the
>> outermost loop.
>> * gcc/common.opt: Add -fpeel-codesize-limit and
>> -funroll-codesize-limit.
>> * gcc/cfgloop.c (insn_has_fp_set, analyze_loop_insns): New functions.
>> (num_loop_branches): Remove.
>> * gcc/cfgloop.h (struct niter_desc): Added new fields to cache
>> additional loop analysis information.
>> (num_loop_branches): Remove.
>> (analyze_loop_insns): Declare.
>> * gcc/params.def (PARAM_UNROLLPEEL_CODESIZE_THRESHOLD): Add.
>> (PARAM_UNROLLPEEL_HOTNESS_THRESHOLD): Ditto.
>> * gcc/gcov-dump.c (tag_summary): Dump new summary info.
>>
>> Index: libgcc/libgcov.c
>> ===
>> --- libgcc/libgcov.c(revision 189413)
>> +++ libgcc/libgcov.c(working copy)
>> @@ -276,6 +276,120 @@ gcov_version (struct gcov_info *ptr, gcov_unsigned
>>return 1;
>>  }
>>
>> +/* Used by qsort to sort gcov values in descending order.  */
>> +
>> +static int
>> +sort_by_reverse_gcov_value (const void *pa, const void *pb)
>> +{
>> +  const gcov_type a = *(gcov_type const *)pa;
>> +  const gcov_type b = *(gcov_type const *)pb;
>> +
>> +  if (b > a)
>> +return 1;
>> +  else if (b == a)
>> +return 0;
>> +  else
>> +return -1;
>> +}
>> +
>> +/* Determines the number of counters required to cover a given percentage
>> +   of the total sum of execution counts in the summary, which is then also
>> +   recorded in SUM.  */
>> +
>> +static void
>> +gcov_compute_cutoff_values (struct gcov_summary *sum)
>> +{
>> +  struct gcov_info *gi_ptr;
>> +  const struct gcov_fn_info *gfi_ptr;
>> +  const struct gcov_ctr_info *ci_ptr;
>> +  struct gcov_ctr_summary *cs_ptr;
>> +  unsigned t_ix, f_ix, i, ctr_info_ix, index;
>> +  gcov_unsigned_t c_num;
>> +  gcov_type *value_array;
>> +  gcov_type cum, cum_cutoff;
>> +  

Re: [PATCH] Improve ifcombine (PR 52005)

2012-07-26 Thread Marc Glisse

Hello,

here is a new version of the ifcombine patch, which handles Andrew's 
examples (though only with -O2 for one of them, same_phi_args_p returns 
false otherwise).


Note that the new patch never calls maybe_fold_or_comparisons, only 
maybe_fold_and_comparisons. It would be possible to call 
maybe_fold_or_comparisons, when maybe_fold_and_comparisons fails, but I 
don't know if there are optimizations that one does and not the other, 
except for the odd trapping-math case.


Bootstrap and testsuite are fine.

2012-07-26 Marc Glisse 

gcc/
PR tree-optimization/51938
PR tree-optimization/52005
* tree-ssa-ifcombine.c (ifcombine_ifandif): New parameters for
inverted conditions.
(ifcombine_iforif): Remove, merge code into ifcombine_ifandif.
(tree_ssa_ifcombine_bb): Update calls to the above. Detect !a&&b
and !a||b patterns.


gcc/testsuite/
PR tree-optimization/51938
PR tree-optimization/52005
* gcc.dg/tree-ssa/ssa-ifcombine-8.c: New testcase.
* gcc.dg/tree-ssa/ssa-ifcombine-9.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-10.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-11.c: Likewise.

--
Marc GlisseIndex: testsuite/gcc.dg/tree-ssa/ssa-ifcombine-10.c
===
--- testsuite/gcc.dg/tree-ssa/ssa-ifcombine-10.c(revision 0)
+++ testsuite/gcc.dg/tree-ssa/ssa-ifcombine-10.c(revision 0)
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+/* Testcase for PR31657.  */
+
+int f(int x, int a, int b)
+{
+  int t = 0;
+  int c = 1 << a;
+  if (!(x & 1))
+t = 0;
+  else
+if (x & (1 << 2))
+  t = 3;
+else
+  t = 0;
+  return t;
+}
+/* { dg-final { scan-tree-dump "& 5" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */

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

Index: testsuite/gcc.dg/tree-ssa/ssa-ifcombine-8.c
===
--- testsuite/gcc.dg/tree-ssa/ssa-ifcombine-8.c (revision 0)
+++ testsuite/gcc.dg/tree-ssa/ssa-ifcombine-8.c (revision 0)
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-trapping-math -fdump-tree-ifcombine" } */
+
+double test1 (double i, double j)
+{
+  if (i >= j)
+if (i <= j)
+  goto plif;
+else
+  goto plouf;
+  else
+goto plif;
+
+plif:
+  return 0;
+plouf:
+  return -1;
+}
+
+/* The above should be optimized to a i > j test by ifcombine.
+   The transformation would also be legal with -ftrapping-math.
+   Instead we get u<=, which is acceptable with -fno-trapping-math.  */
+
+/* { dg-final { scan-tree-dump " u<= " "ifcombine" } } */
+/* { dg-final { cleanup-tree-dump "ifcombine" } } */

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

Index: testsuite/gcc.dg/tree-ssa/ssa-ifcombine-11.c
===
--- testsuite/gcc.dg/tree-ssa/ssa-ifcombine-11.c(revision 0)
+++ testsuite/gcc.dg/tree-ssa/ssa-ifcombine-11.c(revision 0)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+/* Testcase for PR31657.  */
+int g(void);
+int f(int x, int a, int b)
+{
+  int t = 0;
+  int c = 1 << a;
+  if (!(x & 1))
+t = 0;
+  else
+if (x & (1 << 2))
+  t = g();
+else
+  t = 0;
+  return t;
+}
+
+/* { dg-final { scan-tree-dump "& 5" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */

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

Index: testsuite/gcc.dg/tree-ssa/ssa-ifcombine-9.c
===
--- testsuite/gcc.dg/tree-ssa/ssa-ifcombine-9.c (revision 0)
+++ testsuite/gcc.dg/tree-ssa/ssa-ifcombine-9.c (revision 0)
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-trapping-math -fdump-tree-ifcombine" } */
+
+void f ();
+enum Sign { NEG=-1, ZERO, POS };
+
+static inline enum Sign sign (double x)
+{
+  if (x > 0) return POS;
+  if (x < 0) return NEG;
+  return ZERO;
+}
+void g (double x)
+{
+  if (sign (x) == NEG) f();
+}
+
+/* The above should be optimized to x < 0 by ifcombine.
+   The transformation would also be legal with -ftrapping-math.  */
+
+/* { dg-final { scan-tree-dump "optimizing.* < " "ifcombine" } } */
+/* { dg-final { cleanup-tree-dump "ifcombine" } } */

Property changes on: testsuite/gcc.dg/tree-ssa/ssa-ifcombine-9.c
___

Re: [PATCH] PR 53528 c++/ C++11 Generalized Attribute support

2012-07-26 Thread Joseph S. Myers
Do you handle how, in certain syntactic locations, a C++11 attribute binds 
differently to a GNU attribute?  (I haven't studied the patch, so feel 
free to point me to testcases it adds that verify such differences, if 
applicable.)

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


[patch, fortran] Fix PR 54033, problems with -I

2012-07-26 Thread Thomas Koenig

Hello world,

the attached, rather obvious patch emits warnings for several
cases where there is something wrong with include directories.
No test case because I couldn't figure out how to test for a
warning with no line number.

OK for trunk?

Thomas

2012-07-26  Thomas König  

PR fortran/54033
* scanner.c (add_path_to_list): Emit warning if an error occurs
for an include path, if it is not present or if it is not a
directory.  Do not add the path in these cases.
Index: scanner.c
===
--- scanner.c	(Revision 189754)
+++ scanner.c	(Arbeitskopie)
@@ -311,12 +311,31 @@ add_path_to_list (gfc_directorylist **list, const
 {
   gfc_directorylist *dir;
   const char *p;
-
+  struct stat st;
+  
   p = path;
   while (*p == ' ' || *p == '\t')  /* someone might do "-I include" */
 if (*p++ == '\0')
   return;
 
+  if (stat (p, &st))
+{
+  if (errno != ENOENT)
+	gfc_warning_now ("Include directory \"%s\": %s", path,
+			 xstrerror(errno));
+  else
+	/* FIXME:  Also support -Wmissing-include-dirs.  */
+	gfc_warning_now ("Include directory \"%s\" does not exist",
+			 path);
+  return;
+}
+
+  else if (!S_ISDIR (st.st_mode))
+{
+  gfc_warning_now ("\"%s\" is not a directory", path);
+  return;
+}
+
   if (head || *list == NULL)
 {
   dir = XCNEW (gfc_directorylist);


Re: [patch, fortran] Fix PR 54033, problems with -I

2012-07-26 Thread Janis Johnson
On 07/26/2012 10:16 AM, Thomas Koenig wrote:

> No test case because I couldn't figure out how to test for a
> warning with no line number.

Try using line number 0.

Janis


Re: [PATCH] New fdo summary-based icache sensitive unrolling (issue 6351086)

2012-07-26 Thread davidxl


http://codereview.appspot.com/6351086/diff/1/gcc/gcov-io.h
File gcc/gcov-io.h (right):

http://codereview.appspot.com/6351086/diff/1/gcc/gcov-io.h#newcode396
gcc/gcov-io.h:396: gcov_unsigned_t num_hot_counters;/* number of
counters to reach a given
Should it be made into an array accessed with pre-defined indices?

http://codereview.appspot.com/6351086/diff/1/gcc/gcov-io.h#newcode399
gcc/gcov-io.h:399: num_hot_counters.  */
Similarly for this one -- or put the above two values into a pair and
declare an array of the pairs?

http://codereview.appspot.com/6351086/diff/1/libgcc/libgcov.c
File libgcc/libgcov.c (right):

http://codereview.appspot.com/6351086/diff/1/libgcc/libgcov.c#newcode332
libgcc/libgcov.c:332: if (cs_ptr->sum_all*cutoff_perc < cs_ptr->sum_all)
space needed

http://codereview.appspot.com/6351086/diff/1/libgcc/libgcov.c#newcode332
libgcc/libgcov.c:332: if (cs_ptr->sum_all*cutoff_perc < cs_ptr->sum_all)
space needed. Is it better to check if (cs_ptr->sum_all * cutoff_perc
/cutoff_perc != cs_ptr->sum_all)?

http://codereview.appspot.com/6351086/diff/1/libgcc/libgcov.c#newcode718
libgcc/libgcov.c:718: if (cs_tprg->num_hot_counters >
cs_prg->num_hot_counters)
Why guard the update under !cs_prg->runs++ --> the condition is used to
identify if it is a first write or a merged write.  (verify with a test
case to see if the merge of the summary is correct).

http://codereview.appspot.com/6351086/


Re: [rs6000 0/3] POWER removal

2012-07-26 Thread Michael Meissner
On Thu, Jul 26, 2012 at 12:38:47AM -0700, Segher Boessenkool wrote:
> This patch series removes support for the old POWER CPUs (the RIOS,
> RSC, and RIOS2).
> 
> It does not do any more than that: it leaves common mode alone,
> it does not remove the old assembler mnemonics and the {xx|yy}
> insn template syntax, etc.
> 
> Bootstrapped and regtested on powerpc64-linux (c,c++,fortran);
> no new failures.
> 
> Comments?
> 
> Segher

These look good.  It will be good to get rid of them, even with the pain it
causes to my condition code branch (since the power stuff touchs things like
abs, min, max, and some tests).

Note, you will need to update the copyright to include 2012 for the files that
have not been modified in this year.  Using grep, etc. the files in question
are:

gcc/config/rs6000/aix53.h
gcc/config/rs6000/rs6000-tables.opt
gcc/config/rs6000/constraints.md
gcc/config/rs6000/predicates.md
gcc/config/rs6000/rs6000-cpus.def
gcc/config/rs6000/aix51.h
gcc/config/rs6000/t-rs6000
gcc/config/rs6000/aix43.h
gcc/config/rs6000/rs6000-c.c
gcc/config/rs6000/rs6000.opt
gcc/config/rs6000/darwin.h
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/aix52.h
gcc/config/rs6000/rs6000.h
gcc/config/rs6000/t-aix43
gcc/config/rs6000/601.md
gcc/config/rs6000/dfp.md
gcc/config/rs6000/aix61.h
gcc/config/rs6000/rs6000.md
gcc/config/rs6000/rs6000-opts.h
gcc/config/rs6000/driver-rs6000.c
gcc/config/rs6000/sysv4.h
gcc/common/config/rs6000/rs6000-common.c

In running parallel tests for both 64-bit and 32-bit, I see 3 differences:

gcc.dg/pr42389.cTrunk fails,  Segher passes for 64-bit
gcc.dg/pr46521.cTrunk fails,  Segher passes for 64-bit
gcc.dg/tree-prof/pr45354.c  Trunk passes, Segher fails  for 64-bit

gcc.dg/pr45352-1.c  Trunk passes, Segher fails  for 32-bit
gcc.dg/pr46522.cTrunk passes, Segher fails  for 32-bit
gcc.dg/pr48144.cTrunk fails,  Segher passes for 32-bit
gcc.dg/pr50205.cTrunk passes, Segher fails  for 32-bit
gcc.dg/tree-prof/pr45354.c  Trunk fails,  Segher passes for 32-bit

gfortran.dg/pr44691.f   Trunk fails,  Segher passes for 64-bit

Now, all of these differences are in tests that do selective scheduling, so I'm
not sure they are blockers.

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899



Re: [rs6000 0/3] POWER removal

2012-07-26 Thread Segher Boessenkool
Note, you will need to update the copyright to include 2012 for the  
files that

have not been modified in this year.


I think you looked at the old version of the patch I mailed
to you privately; this is fixed already (there are some other
small differences as well).

In running parallel tests for both 64-bit and 32-bit, I see 3  
differences:


gcc.dg/pr42389.cTrunk fails,  Segher passes for 64-bit
gcc.dg/pr46521.cTrunk fails,  Segher passes for 64-bit
gcc.dg/tree-prof/pr45354.c  Trunk passes, Segher fails  for 64-bit

gcc.dg/pr45352-1.c  Trunk passes, Segher fails  for 32-bit
gcc.dg/pr46522.cTrunk passes, Segher fails  for 32-bit
gcc.dg/pr48144.cTrunk fails,  Segher passes for 32-bit
gcc.dg/pr50205.cTrunk passes, Segher fails  for 32-bit
gcc.dg/tree-prof/pr45354.c  Trunk fails,  Segher passes for 32-bit

gfortran.dg/pr44691.f   Trunk fails,  Segher passes for 64-bit

Now, all of these differences are in tests that do selective  
scheduling, so I'm

not sure they are blockers.


As I said, all of these fail in the latest PowerPC results on
gcc-testresults (it's an ICE in free_regset_pool, there is no PR
for it it seems, but is is mentioned in PR53957 comment #9).


Segher



Re: [rs6000 0/3] POWER removal

2012-07-26 Thread Michael Meissner
On Thu, Jul 26, 2012 at 09:18:09PM +0200, Segher Boessenkool wrote:
> >Note, you will need to update the copyright to include 2012 for
> >the files that
> >have not been modified in this year.
> 
> I think you looked at the old version of the patch I mailed
> to you privately; this is fixed already (there are some other
> small differences as well).

Yes, I was using the previous versions.  Sorry about that.

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899



Re: [PATCH] Detect loops in find_comparison_args

2012-07-26 Thread Sandra Loosemore
On 07/26/2012 01:28 AM, Paolo Bonzini wrote:
> Il 26/07/2012 04:25, Sandra Loosemore ha scritto:
>> On 07/25/2012 01:27 AM, Paolo Bonzini wrote:
>>>
>>> What I'm worried about is the extra cost of malloc-ing and free-ing
>>> the pointer set.  Perhaps you can skip the pointer set creation in
>>> the common case where find_comparison_args does not iterate?
>>> Something like this:
>>>
>>> [snip]
>>
>> I think this version is a little neater; it just defers
>> initialization of the pointer set to the end of the loop.
> 
> But the while condition could still fail right after you create the set,
> and I would expect that to be the common case.

Aha, I honestly couldn't figure out that was what you were trying to catch with 
the version you posted previously.

How about this one?  Tested as before.

-Sandra

2012-07-26  Andrew Jenner  
Sandra Loosemore  

gcc/
* cse.c (find_comparison_args): Check for cycles of any length.

gcc/testsuite/
* gcc.c-torture/compile/pr50380.c: Add code to cause cycle of length 2.



Index: gcc/cse.c
===
--- gcc/cse.c	(revision 189859)
+++ gcc/cse.c	(working copy)
@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3.  
 #include "tree-pass.h"
 #include "df.h"
 #include "dbgcnt.h"
+#include "pointer-set.h"
 
 /* The basic idea of common subexpression elimination is to go
through the code, keeping a record of expressions that would
@@ -2897,6 +2898,9 @@ find_comparison_args (enum rtx_code code
 		  enum machine_mode *pmode1, enum machine_mode *pmode2)
 {
   rtx arg1, arg2;
+  struct pointer_set_t *visited = NULL;
+  /* Set nonzero when we find something of interest.  */
+  rtx x = 0;
 
   arg1 = *parg1, arg2 = *parg2;
 
@@ -2904,11 +2908,18 @@ find_comparison_args (enum rtx_code code
 
   while (arg2 == CONST0_RTX (GET_MODE (arg1)))
 {
-  /* Set nonzero when we find something of interest.  */
-  rtx x = 0;
   int reverse_code = 0;
   struct table_elt *p = 0;
 
+  /* Remember state from previous iteration.  */
+  if (x)
+	{
+	  if (!visited)
+	visited = pointer_set_create ();
+	  pointer_set_insert (visited, x);
+	  x = 0;
+	}
+
   /* If arg1 is a COMPARE, extract the comparison arguments from it.
 	 On machines with CC0, this is the only case that can occur, since
 	 fold_rtx will return the COMPARE or item being compared with zero
@@ -2985,10 +2996,8 @@ find_comparison_args (enum rtx_code code
 	  if (! exp_equiv_p (p->exp, p->exp, 1, false))
 	continue;
 
-	  /* If it's the same comparison we're already looking at, skip it.  */
-	  if (COMPARISON_P (p->exp)
-	  && XEXP (p->exp, 0) == arg1
-	  && XEXP (p->exp, 1) == arg2)
+	  /* If it's a comparison we've used before, skip it.  */
+	  if (visited && pointer_set_contains (visited, p->exp))
 	continue;
 
 	  if (GET_CODE (p->exp) == COMPARE
@@ -3069,6 +3078,8 @@ find_comparison_args (enum rtx_code code
   *pmode1 = GET_MODE (arg1), *pmode2 = GET_MODE (arg2);
   *parg1 = fold_rtx (arg1, 0), *parg2 = fold_rtx (arg2, 0);
 
+  if (visited)
+pointer_set_destroy (visited);
   return code;
 }
 
Index: gcc/testsuite/gcc.c-torture/compile/pr50380.c
===
--- gcc/testsuite/gcc.c-torture/compile/pr50380.c	(revision 189859)
+++ gcc/testsuite/gcc.c-torture/compile/pr50380.c	(working copy)
@@ -1,12 +1,22 @@
-/* This test used to get stuck in an infinite loop in find_comparison_args
-   when compiling for MIPS at -O2.  */
-
 __attribute__ ((__noreturn__)) extern void fail (void);
 
 char x;
 
+/* This used to get stuck in an infinite loop in find_comparison_args
+   when compiling this function for MIPS at -O2.  */
+
 void foo (const unsigned char y)
 {
((void) (__builtin_expect((!! y == y), 1) ? 0 : (fail (), 0)));
x = ! y;
 }
+
+/* This used to similarly get stuck when compiling for PowerPC at -O2.  */
+
+int foo2 (int arg)
+{
+  if (arg != !arg)
+fail ();
+  if (arg)
+fail ();
+}


Re: [PATCH] Detect loops in find_comparison_args

2012-07-26 Thread Richard Henderson
On 07/26/2012 01:22 PM, Sandra Loosemore wrote:
> 2012-07-26  Andrew Jenner  
>   Sandra Loosemore  
> 
>   gcc/
>   * cse.c (find_comparison_args): Check for cycles of any length.
> 
>   gcc/testsuite/
>   * gcc.c-torture/compile/pr50380.c: Add code to cause cycle of length 2.

Ok.

> +  struct pointer_set_t *visited = NULL;
> +  /* Set nonzero when we find something of interest.  */
> +  rtx x = 0;

Might as well fix this to = NULL too.


r~


Re: [PATCH] New fdo summary-based icache sensitive unrolling (issue 6351086)

2012-07-26 Thread Teresa Johnson
Resending in plain text mode...sigh.

Teresa


On Thu, Jul 26, 2012 at 1:32 PM, Teresa Johnson  wrote:
>
>
>
>
> On Thu, Jul 26, 2012 at 11:26 AM,  wrote:
>>
>>
>> http://codereview.appspot.com/6351086/diff/1/gcc/gcov-io.h
>> File gcc/gcov-io.h (right):
>>
>> http://codereview.appspot.com/6351086/diff/1/gcc/gcov-io.h#newcode396
>> gcc/gcov-io.h:396: gcov_unsigned_t num_hot_counters;/* number of
>>
>> counters to reach a given
>> Should it be made into an array accessed with pre-defined indices?
>
>
> You mean provide an array of values for different thresholds? In that case 
> both num_hot_counters and hot_cutoff_value would need to be arrays (oh, I see 
> now that you indicate that below too). And we would possibly need another 
> array to hold the thresholds, unless they are hard coded values. I've been 
> thinking about extending this to provide data for more threshold values, but 
> was holding that off for a follow-on, when I had a better idea of how the 
> expanded summary info would be used.
>
> Honza - you were talking about using this type of summary info to guide 
> hot/cold decisions, do you find the current single threshold data useful 
> enough?
>
>>
>> http://codereview.appspot.com/6351086/diff/1/gcc/gcov-io.h#newcode399
>> gcc/gcov-io.h:399: num_hot_counters.  */
>> Similarly for this one -- or put the above two values into a pair and
>> declare an array of the pairs?
>>
>> http://codereview.appspot.com/6351086/diff/1/libgcc/libgcov.c
>> File libgcc/libgcov.c (right):
>>
>> http://codereview.appspot.com/6351086/diff/1/libgcc/libgcov.c#newcode332
>> libgcc/libgcov.c:332: if (cs_ptr->sum_all*cutoff_perc < cs_ptr->sum_all)
>> space needed
>>
>
> I think I have added the space you wanted (around the '*' char) - let me know 
> if you meant something else.
>
>>
>> http://codereview.appspot.com/6351086/diff/1/libgcc/libgcov.c#newcode332
>> libgcc/libgcov.c:332: if (cs_ptr->sum_all*cutoff_perc < cs_ptr->sum_all)
>> space needed. Is it better to check if (cs_ptr->sum_all * cutoff_perc
>> /cutoff_perc != cs_ptr->sum_all)?
>
>
> Good suggestion - changed.
>
>>
>>
>> http://codereview.appspot.com/6351086/diff/1/libgcc/libgcov.c#newcode718
>> libgcc/libgcov.c:718: if (cs_tprg->num_hot_counters >
>> cs_prg->num_hot_counters)
>> Why guard the update under !cs_prg->runs++ --> the condition is used to
>> identify if it is a first write or a merged write.  (verify with a test
>> case to see if the merge of the summary is correct).
>
>
> In fact the ">" check doesn't make sense if this is the first write, which is 
> currently how I have it guarded. The question is how to best "merge" this 
> information. After thinking about this, I am going to move this code out from 
> under the !cs_prg->runs++ check, so that on a merge, we use the summary with 
> the largest num_hot_counters.
>
> I am going to do a little testing with my changes and will upload a new patch.
>
> Thanks,
> Teresa
>
>>
>>
>> http://codereview.appspot.com/6351086/
>
>
>
>
> --
> Teresa Johnson | Software Engineer |  tejohn...@google.com |  408-460-2413
>



--
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413


Re: [PATCH] PR 53528 c++/ C++11 Generalized Attribute support

2012-07-26 Thread Richard Henderson
On 07/26/2012 08:19 AM, Dodji Seketeli wrote:
> +  attributes_table->scoped = XRESIZEVEC (struct scoped_attributes,
> +  attributes_table->scoped,
> +  attributes_table->len + 1);

A good clue that you want VEC's instead, with VEC_safe_push.


r~


[SH] PR 54089 - adjust shift costs

2012-07-26 Thread Oleg Endo
Hello,

This adjusts the cost calculations for shifts on SH.
I tried out Richard's advice
( http://gcc.gnu.org/ml/gcc-patches/2012-07/msg01206.html )
and it seems to work OK to just leave out the mentioned CONST_INT_P
case.
Tested on rev 189870 with
make -k check RUNTESTFLAGS="--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,-m4-single/-ml,
-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}"

and no new failures.
I've also confirmed that the example function in
tree-switch-conversion.c:184 now is transformed as expected.  The CSiBE
set shows a few improvements here and there, where these kind of
transformations can be applied for when dynamic shifts are available
(SH3+).  For SH2 (no dynamic shifts) there also seem to be some minor
improvements.

OK?

Cheers,
Oleg

ChangeLog

PR target/54089
* config/sh/sh.c (shiftcosts): Remove case where first operand 
is a const_int.  Move COSTS_N_INSNS usage into caller ...
(sh_rtx_costs) ... here.  Return false when shiftcosts cannot be
calculated instead of MAX_COST.
Index: gcc/config/sh/sh.c
===
--- gcc/config/sh/sh.c	(revision 189877)
+++ gcc/config/sh/sh.c	(working copy)
@@ -2859,26 +2859,22 @@
 {
   int value;
 
-  /* There is no pattern for constant first operand.  */
-  if (CONST_INT_P (XEXP (x, 0)))
-return MAX_COST;
-
   if (TARGET_SHMEDIA)
-return COSTS_N_INSNS (1);
+return 1;
 
   if (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
 {
   if (GET_MODE (x) == DImode
 	  && CONST_INT_P (XEXP (x, 1))
 	  && INTVAL (XEXP (x, 1)) == 1)
-	return COSTS_N_INSNS (2);
+	return 2;
 
   /* Everything else is invalid, because there is no pattern for it.  */
-  return MAX_COST;
+  return -1;
 }
   /* If shift by a non constant, then this will be expensive.  */
   if (!CONST_INT_P (XEXP (x, 1)))
-return COSTS_N_INSNS (SH_DYNAMIC_SHIFT_COST);
+return SH_DYNAMIC_SHIFT_COST;
 
   /* Otherwise, return the true cost in instructions.  Cope with out of range
  shift counts more or less arbitrarily.  */
@@ -2887,13 +2883,14 @@
   if (GET_CODE (x) == ASHIFTRT)
 {
   int cost = ashiftrt_insns[value];
-  /* If SH3, then we put the constant in a reg and use shad.  */
+  /* If dynamic shifts are available and profitable in this case, then we
+	 put the constant in a reg and use shad.  */
   if (cost > 1 + SH_DYNAMIC_SHIFT_COST)
 	cost = 1 + SH_DYNAMIC_SHIFT_COST;
-  return COSTS_N_INSNS (cost);
+  return cost;
 }
   else
-return COSTS_N_INSNS (shift_insns[value]);
+return shift_insns[value];
 }
 
 /* Return the cost of an AND/XOR/IOR operation.  */
@@ -3147,8 +3144,13 @@
 case ASHIFT:
 case ASHIFTRT:
 case LSHIFTRT:
-  *total = shiftcosts (x);
-  return true;
+  {
+	int cost = shiftcosts (x);
+	if (cost < 0)
+	  return false;
+	*total = COSTS_N_INSNS (cost);
+	return true;
+  }
 
 case DIV:
 case UDIV:


Re: [google/gcc-4_7] Compute dwo_id for Fission (issue6442047)

2012-07-26 Thread Sterling Augustine
On Wed, Jul 25, 2012 at 5:06 PM, Cary Coutant  wrote:
> This patch is for the google/gcc-4_7 branch.
>
> Compute a dwo_id and write the DW_AT_GNU_dwo_id attribute to both the
> skeleton compile unit DIE and the DWO compile unit DIE.
>

This is OK for google 4.7.

Sterling


Add hot/cold attributes for labels

2012-07-26 Thread Richard Henderson
This is a patch I should have gone ahead and committed when I wrote it
against gcc 4.6, but... better late than never I suppose.

The Idea is to have some mechanism akin to __builtin_expect that can apply
to the edges created by asm goto.  We tossed around possible syntax additions
to the asm construct, but nothing we came up with looked easy to use.  In
the end it seemed fantastically cleaner to simply use the existing attribute
syntax and apply the existing hot/cold attributes to labels.

This patch by itself doesn't actually accomplish what we really want for use
in the kernel (which is why it didn't get committed before I guess), but it's
the user-visible portion that would enable further work.

Tested on x86_64 and committed.


r~


Re: Add hot/cold attributes for labels

2012-07-26 Thread Richard Henderson
On 07/26/2012 02:41 PM, Richard Henderson wrote:
> This is a patch...

... that I should have attached.  Bah.


r~
gcc/
* doc/extend.texi (attribute): Document hot/cold for labels.
* predict.c (tree_estimate_probability_bb): Handle hot/cold
attributes on user labels.
* predict.def (PRED_HOT_LABEL, PRED_COLD_LABEL): New.
gcc/c-family/
* c-common.c (handle_hot_attribute): Allow labels.
(handle_cold_attribute): Likewise.
gcc/testsuite/
* gcc.dg/attr-hotcold-1.c: New.
* gcc.dg/tree-ssa/attr-hotcold-2.c: New.


diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index b72506b..a002541 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -6169,7 +6169,8 @@ static tree
 handle_hot_attribute (tree *node, tree name, tree ARG_UNUSED (args),
  int ARG_UNUSED (flags), bool *no_add_attrs)
 {
-  if (TREE_CODE (*node) == FUNCTION_DECL)
+  if (TREE_CODE (*node) == FUNCTION_DECL
+  || TREE_CODE (*node) == LABEL_DECL)
 {
   if (lookup_attribute ("cold", DECL_ATTRIBUTES (*node)) != NULL)
{
@@ -6188,6 +6189,7 @@ handle_hot_attribute (tree *node, tree name, tree 
ARG_UNUSED (args),
 
   return NULL_TREE;
 }
+
 /* Handle a "cold" and attribute; arguments as in
struct attribute_spec.handler.  */
 
@@ -6195,7 +6197,8 @@ static tree
 handle_cold_attribute (tree *node, tree name, tree ARG_UNUSED (args),
   int ARG_UNUSED (flags), bool *no_add_attrs)
 {
-  if (TREE_CODE (*node) == FUNCTION_DECL)
+  if (TREE_CODE (*node) == FUNCTION_DECL
+  || TREE_CODE (*node) == LABEL_DECL)
 {
   if (lookup_attribute ("hot", DECL_ATTRIBUTES (*node)) != NULL)
{
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index c3faf09..5d851a7 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -3345,33 +3345,53 @@ than 2.96.
 
 @item hot
 @cindex @code{hot} function attribute
-The @code{hot} attribute is used to inform the compiler that a function is a
-hot spot of the compiled program.  The function is optimized more aggressively
-and on many target it is placed into special subsection of the text section so
-all hot functions appears close together improving locality.
+The @code{hot} attribute on a function is used to inform the compiler that
+the function is a hot spot of the compiled program.  The function is
+optimized more aggressively and on many target it is placed into special
+subsection of the text section so all hot functions appears close together
+improving locality.
 
 When profile feedback is available, via @option{-fprofile-use}, hot functions
 are automatically detected and this attribute is ignored.
 
-The @code{hot} attribute is not implemented in GCC versions earlier
-than 4.3.
+The @code{hot} attribute on functions is not implemented in GCC versions
+earlier than 4.3.
+
+@cindex @code{hot} label attribute
+The @code{hot} attribute on a label is used to inform the compiler that
+path following the label are more likely than paths that are not so
+annotated.  This attribute is used in cases where @code{__builtin_expect}
+cannot be used, for instance with computed goto or @code{asm goto}.
+
+The @code{hot} attribute on labels is not implemented in GCC versions
+earlier than 4.8.
 
 @item cold
 @cindex @code{cold} function attribute
-The @code{cold} attribute is used to inform the compiler that a function is
-unlikely executed.  The function is optimized for size rather than speed and on
-many targets it is placed into special subsection of the text section so all
-cold functions appears close together improving code locality of non-cold parts
-of program.  The paths leading to call of cold functions within code are marked
-as unlikely by the branch prediction mechanism. It is thus useful to mark
-functions used to handle unlikely conditions, such as @code{perror}, as cold to
-improve optimization of hot functions that do call marked functions in rare
-occasions.
-
-When profile feedback is available, via @option{-fprofile-use}, hot functions
+The @code{cold} attribute on functions is used to inform the compiler that
+the function is unlikely to be executed.  The function is optimized for
+size rather than speed and on many targets it is placed into special
+subsection of the text section so all cold functions appears close together
+improving code locality of non-cold parts of program.  The paths leading
+to call of cold functions within code are marked as unlikely by the branch
+prediction mechanism.  It is thus useful to mark functions used to handle
+unlikely conditions, such as @code{perror}, as cold to improve optimization
+of hot functions that do call marked functions in rare occasions.
+
+When profile feedback is available, via @option{-fprofile-use}, cold functions
 are automatically detected and this attribute is ignored.
 
-The @code{cold} attribute is not implemented in GCC versions earlier than 4.3.
+The @code{cold} attribute on functions i

[patch, libiberty] avoid closing files twice on Windows when exec fails

2012-07-26 Thread Sandra Loosemore
This is a libiberty patch for Windows that we've had in our local tree for a 
couple of years now.  The problem it addresses showed up in Windows-hosted GDB; 
we were getting a crash inside _close() in the case where creation of the child 
process has failed. 

Apparently Windows gets very unhappy if you try to close an already-closed file 
descriptor a second time.  This documentation, which turned up at the top of a 
Google search,

http://msdn.microsoft.com/en-us/library/5fzwd5ss%28v=vs.80%29.aspx
http://msdn.microsoft.com/en-us/library/ksazx244%28v=vs.80%29.aspx

seems to indicate that crashing is the default behavior if "fd is a bad file 
descriptor".

The duplicate calls causing the crash in pex_run_in_environment are pretty easy 
to avoid.  In the unmodified code, the stdin/stdout/stderr file descriptors are 
closed once in pex_win32_exec_child, immediately after they are dup'ed for the 
child; if process creation fails, they get closed a second time in 
pex_run_in_environment.  This patch fixes pex_win32_exec_child to only close 
the original file descriptors if process creation succeeds, leaving 
pex_run_in_environment to take care of the failure case.

We haven't tried to monitor other uses of _close in libiberty.  I was looking 
around for a Windows function to test whether a file descriptor is already 
closed that we could guard the calls in pex_win32_close with, but didn't see 
anything.  In any case, this patch has been working well enough for us, as far 
as it goes, and is at least an incremental improvement in robustness.  OK for 
mainline?

-Sandra


2012-07-26  Kazu Hirata  
Sandra Loosemore  

libiberty/
* pex-win32.c (pex_win32_exec_child): Only close original file
descriptors if child is launched successfully.

Index: libiberty/pex-win32.c
===
--- libiberty/pex-win32.c	(revision 189895)
+++ libiberty/pex-win32.c	(working copy)
@@ -741,24 +741,17 @@ pex_win32_exec_child (struct pex_obj *ob
   int orig_out, orig_in, orig_err;
   BOOL separate_stderr = !(flags & PEX_STDERR_TO_STDOUT);
 
-  /* Ensure we have inheritable descriptors to pass to the child, and close the
- original descriptors.  */
+  /* Ensure we have inheritable descriptors to pass to the child.  */
   orig_in = in;
   in = _dup (orig_in);
-  if (orig_in != STDIN_FILENO)
-_close (orig_in);
   
   orig_out = out;
   out = _dup (orig_out);
-  if (orig_out != STDOUT_FILENO)
-_close (orig_out);
   
   if (separate_stderr)
 {
   orig_err = errdes;
   errdes = _dup (orig_err);
-  if (orig_err != STDERR_FILENO)
-	_close (orig_err);
 }
 
   stdin_handle = INVALID_HANDLE_VALUE;
@@ -836,6 +829,22 @@ pex_win32_exec_child (struct pex_obj *ob
   *errmsg = "CreateProcess";
 }
 
+  /* If the child was created successfully, close the original file
+ descriptors.  If the process creation fails, these are closed by
+ pex_run_in_environment instead.  We must not close them twice as
+ that seems to cause a Windows exception.  */
+ 
+  if (pid != (pid_t) -1)
+{
+  if (orig_in != STDIN_FILENO)
+	_close (orig_in);
+  if (orig_out != STDOUT_FILENO)
+	_close (orig_out);
+  if (separate_stderr
+	  && orig_err != STDERR_FILENO)
+	_close (orig_err);
+}
+
   /* Close the standard input, standard output and standard error handles
  in the parent.  */ 
 


[testsuite] gcc.dg/pr45259.c: fix dg-options for non-fpic

2012-07-26 Thread Janis Johnson
Test gcc.dg/pr45259 fails on targets that don't support fpic because it
skips using -w and therefore gets pedantic warnings that are enabled by
default.  This patch provides an alternate dg-option command to supply
options other than -fpic for targets that don't support fpic.

Checked in on trunk, coming soon to the 4.7 branch.

Janis
2012-07-26  Janis Johnson  

* gcc.dg/pr45259.c: Only -fpic depends on fpic support.

Index: gcc/testsuite/gcc.dg/pr45259.c
===
--- gcc/testsuite/gcc.dg/pr45259.c  (revision 189892)
+++ gcc/testsuite/gcc.dg/pr45259.c  (working copy)
@@ -1,6 +1,7 @@
 /* PR debug/45259 */
 /* { dg-do compile } */
-/* { dg-options "-g -O2 -fpic -w" { target fpic } } */
+/* { dg-options "-g -O2 -w -fpic" { target fpic } } */
+/* { dg-options "-g -O2 -w" { target { ! fpic } } } */
 
 struct S { void (*bar) (long); };
 struct T { struct S *t; };


Re: PR 54075 Fix hashtable::reserve

2012-07-26 Thread Paolo Carlini

On 07/25/2012 04:55 PM, Jonathan Wakely wrote:

Yes, I think so, it's a regression from 4.6.

Thanks for dealing with it so quickly.

Thanks indeed.

However, looks like we have another issue, unrelated to reserve, pure 
performance not correctness, with the sheer number of rehashes when the 
map grows. First blush doesn't seem something very too hard to fix, but 
submitters for some reason don't feel like providing a complete testcase 
for it...


Thanks again!
Paolo.


Re: [patch, libiberty] avoid closing files twice on Windows when exec fails

2012-07-26 Thread DJ Delorie

I wonder if registering a handler for invalid parameters, at least
around those calls, so that we can enforce the posix-like "return an
error" semantics?

> OK for mainline?

Ok.

> 2012-07-26  Kazu Hirata  
>   Sandra Loosemore  
> 
>   libiberty/
>   * pex-win32.c (pex_win32_exec_child): Only close original file
>   descriptors if child is launched successfully.


Re: [SH] PR 54089 - adjust shift costs

2012-07-26 Thread Kaz Kojima
Oleg Endo  wrote:
> This adjusts the cost calculations for shifts on SH.
> I tried out Richard's advice
> ( http://gcc.gnu.org/ml/gcc-patches/2012-07/msg01206.html )
> and it seems to work OK to just leave out the mentioned CONST_INT_P
> case.
> Tested on rev 189870 with
> make -k check RUNTESTFLAGS="--target_board=sh-sim
> \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,-m4-single/-ml,
> -m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}"
> 
> and no new failures.
> I've also confirmed that the example function in
> tree-switch-conversion.c:184 now is transformed as expected.  The CSiBE
> set shows a few improvements here and there, where these kind of
> transformations can be applied for when dynamic shifts are available
> (SH3+).  For SH2 (no dynamic shifts) there also seem to be some minor
> improvements.
> 
> OK?

OK.

Regards,
kaz


[PATCH] New fdo summary-based icache sensitive unrolling (issue6351086)

2012-07-26 Thread Teresa Johnson
Updated patch based on review feedback.

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

Teresa


Original patch description:

Ports some patches related to improving FDO program summary information
and using it to guide loop unrolling from google branches to mainline.
The patch is enhanced to add additional summary information to aid
in determining hot/cold decisions.

The original patch description is at:
  http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00437.html
and further discussion about incorporating onto mainline is at:
  http://gcc.gnu.org/ml/gcc-patches/2012-06/threads.html#00414

Honza, can you take a look to see if this patch meets your needs?

Full description:

This patch adds new program summary information to the gcov
profile files that indicate how many profiled counts compose
the majority of the program's execution time. This is used to
provide an indication of the overall code size of the program.

The new profile summary information is then used to guide
codesize based unroll and peel decisions, to prevent those
optimizations from increasing code size too much when the
program may be sensitive to icache effects.

This patch also pulls in dependent portions of google/main r187660 that cache
additional loop analysis results in the niter_desc auxiliary information
hanging off the loop structure (the optimization portions of that
change are not included here, and have an outstanding review request
for mainline).

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

Thanks,
Teresa

2012-07-26  Teresa Johnson  

* libgcc/libgcov.c (sort_by_reverse_gcov_value): New function.
(gcov_compute_cutoff_values): Ditto.
(gcov_exit): Call gcov_compute_cutoff_values and merge new summary
information.
* gcc/doc/invoke.texi (roll much): Document new options
-fpeel-codesize-limit and -funroll-codesize-limit, and new params
codesize-hotness-threshold and unrollpeel-hotness-threshold.
* gcc/gcov-io.c (gcov_write_summary): Write new summary info.
(gcov_read_summary): Read new summary info.
* gcc/gcov-io.h (GCOV_TAG_SUMMARY_LENGTH): Update for new summary info.
(struct gcov_ctr_summary): Add new summary info: num_hot_counters and
hot_cutoff_value.
* gcc/loop-unroll.c (code_size_limit_factor): New function.
(decide_unroll_runtime_iterations): Call code_size_limit_factor
to control the unroll factor, and retrieve number of branches from
niter_desc instead of via function that walks loop.
(decide_peel_simple, decide_unroll_stupid): Ditto.
* gcc/coverage.c (read_counts_file): Propagate new summary info.
* gcc/loop-iv.c (get_simple_loop_desc): Invoke new analyze_loop_insns
function, and add guards to enable this function to work for the
outermost loop.
* gcc/common.opt: Add -fpeel-codesize-limit and
-funroll-codesize-limit.
* gcc/cfgloop.c (insn_has_fp_set, analyze_loop_insns): New functions.
(num_loop_branches): Remove.
* gcc/cfgloop.h (struct niter_desc): Added new fields to cache
additional loop analysis information.
(num_loop_branches): Remove.
(analyze_loop_insns): Declare.
* gcc/params.def (PARAM_UNROLLPEEL_CODESIZE_THRESHOLD): Add.
(PARAM_UNROLLPEEL_HOTNESS_THRESHOLD): Ditto.
* gcc/gcov-dump.c (tag_summary): Dump new summary info.

Index: libgcc/libgcov.c
===
--- libgcc/libgcov.c(revision 189893)
+++ libgcc/libgcov.c(working copy)
@@ -276,6 +276,120 @@ gcov_version (struct gcov_info *ptr, gcov_unsigned
   return 1;
 }
 
+/* Used by qsort to sort gcov values in descending order.  */
+
+static int
+sort_by_reverse_gcov_value (const void *pa, const void *pb)
+{
+  const gcov_type a = *(gcov_type const *)pa;
+  const gcov_type b = *(gcov_type const *)pb;
+
+  if (b > a)
+return 1;
+  else if (b == a)
+return 0;
+  else
+return -1;
+}
+
+/* Determines the number of counters required to cover a given percentage
+   of the total sum of execution counts in the summary, which is then also
+   recorded in SUM.  */
+
+static void
+gcov_compute_cutoff_values (struct gcov_summary *sum)
+{
+  struct gcov_info *gi_ptr;
+  const struct gcov_fn_info *gfi_ptr;
+  const struct gcov_ctr_info *ci_ptr;
+  struct gcov_ctr_summary *cs_ptr;
+  unsigned t_ix, f_ix, i, ctr_info_ix, index;
+  gcov_unsigned_t c_num;
+  gcov_type *value_array;
+  gcov_type cum, cum_cutoff;
+  char *cutoff_str;
+  unsigned cutoff_perc;
+
+#define CUM_CUTOFF_PERCENT_TIMES_10 999
+  cutoff_str = getenv ("GCOV_HOTCODE_CUTOFF_TIMES_10");
+  if (cutoff_str && strlen (cutoff_str))
+cutoff_perc = atoi (cutoff_str);
+  else
+cutoff_perc = CUM_CUTOFF_PERCENT_TIMES_10;
+
+  /* This currently only applies to arc counters.  */
+  t_ix = GCOV_COUNTER_ARCS;
+
+  /* First check if there are any c

Re: [PATCH] Detect loops in find_comparison_args

2012-07-26 Thread Paolo Bonzini
Il 26/07/2012 22:22, Sandra Loosemore ha scritto:
> Aha, I honestly couldn't figure out that was what you were trying to
> catch with the version you posted previously.
> 
> How about this one?  Tested as before.

Yeah, that's cleaner.

Paolo