Re: [RFA][PATCH] Fix tree-optimization/57124

2013-05-02 Thread Richard Biener
On Wed, May 1, 2013 at 10:26 PM, Jeff Law  wrote:
>
> range_fits_type_p erroneously returns true in cases where the range has
> overflowed.  So for example, we might have a range [0, +INF(OVF)] and
> conclude the range fits in an unsigned type.
>
> This in turn can cause VRP to rewrite a conditional in an unsafe way as seen
> by the testcase.
>
> Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
>
> OK for the trunk?

Hmm, actually when [0, +INF(OVF)] appears then it says that the
range is [0, +INF], but we relied on that no undefined overflow happened
when computing it.

So in fact the value must fit, otherwise the program invoked undefined
behavior.

Which means you should at most _warn_, not disable the transform.

In fact the testcase is invalid:

  x1 = *p1;
  x2 = (int) x1;
  x3 = x2 * 65536;

performs 65531 * 65536 which overflows in type int.

You probably should disable the transform with -fno-strict-overflow,
that is, make sure the testcase works at -O1 -ftree-vrp for example.

Richard.

> commit 45d8f974a4fae7bf07b7213b4ccda81fe410d49b
> Author: Jeff Law 
> Date:   Wed May 1 12:33:20 2013 -0600
>
> PR tree-optimization/57124
> * tree-vrp.c (range_fits_type_p): If min/max of the range has
> overflowed, then the range does not fit the type.
>
> PR tree-optimization/57124
> * gcc.c-torture/execute/pr57124.c: New test.
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 50a3b1d..658ddda 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,9 @@
> +2013-04-26  Jeff Law  
> +
> +   PR tree-optimization/57124
> +   * tree-vrp.c (range_fits_type_p): If min/max of the range has
> +   overflowed, then the range does not fit the type.
> +
>  2013-04-30  Greta Yorsh  
>
> * config/arm/thumb2.md (thumb2_incscc, thumb2_decscc): Delete.
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index 1016036..3ed531e 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2013-05-01  Jeff Law  
> +
> +   PR tree-optimization/57124
> +   * gcc.c-torture/execute/pr57124.c: New test.
> +
>  2013-04-30  Thomas Koenig  
>
> PR fortran/57071
> diff --git a/gcc/testsuite/gcc.c-torture/execute/pr57124.c
> b/gcc/testsuite/gcc.c-torture/execute/pr57124.c
> new file mode 100644
> index 000..835d249
> --- /dev/null
> +++ b/gcc/testsuite/gcc.c-torture/execute/pr57124.c
> @@ -0,0 +1,27 @@
> +__attribute__ ((noinline))
> +foo(short unsigned int *p1, short unsigned int *p2)
> +{
> +  short unsigned int x1, x4;
> +  int x2, x3, x5, x6;
> +  unsigned int x7;
> +
> +  x1 = *p1;
> +  x2 = (int) x1;
> +  x3 = x2 * 65536;
> +  x4 = *p2;
> +  x5 = (int) x4;
> +  x6 = x3 + x4;
> +  x7 = (unsigned int) x6;
> +  if (x7 <= 268435455U)
> +abort ();
> +  exit (0);
> +}
> +
> +main()
> +{
> +  short unsigned int x, y;
> +  x = -5;
> +  y = -10;
> +  foo (&x, &y);
> +}
> +
> diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
> index 6ed353f..02f2f19 100644
> --- a/gcc/tree-vrp.c
> +++ b/gcc/tree-vrp.c
> @@ -8537,7 +8537,9 @@ range_fits_type_p (value_range_t *vr, unsigned
> precision, bool unsigned_p)
>/* Now we can only handle ranges with constant bounds.  */
>if (vr->type != VR_RANGE
>|| TREE_CODE (vr->min) != INTEGER_CST
> -  || TREE_CODE (vr->max) != INTEGER_CST)
> +  || TREE_CODE (vr->max) != INTEGER_CST
> +  || is_negative_overflow_infinity (vr->min)
> +  || is_positive_overflow_infinity (vr->max))
>  return false;
>
>/* For sign changes, the MSB of the double_int has to be clear.
>


[v3] Add std::is_null_pointer

2013-05-02 Thread Paolo Carlini

Hi,

this adds the trait per LWG 2247 [Ready]. For the time being I'm keeping 
__is_nullptr_t, which maybe somebody was using as an extension...


Tested x86_64-linux.

Thanks,
Paolo.

/
2013-05-02  Paolo Carlini  

* include/std/type_traits (is_null_pointer): Add.
(__is_nullptr_t): Implement in terms of the latter.
(is_fundamental, is_scalar): Adjust.
* testsuite/20_util/is_null_pointer/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_null_pointer/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/is_null_pointer/value.cc: Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
line number.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
Index: include/std/type_traits
===
--- include/std/type_traits (revision 198511)
+++ include/std/type_traits (working copy)
@@ -402,17 +402,23 @@
 : public true_type { };
 
   template
-struct __is_nullptr_t_helper
+struct __is_null_pointer_helper
 : public false_type { };
 
   template<>
-struct __is_nullptr_t_helper
+struct __is_null_pointer_helper
 : public true_type { };
 
+  // is_null_pointer (LWG 2247).
+  template
+struct is_null_pointer
+: public __is_null_pointer_helper::type>::type
+{ };
+
   // __is_nullptr_t (extension).
   template
 struct __is_nullptr_t
-: public __is_nullptr_t_helper::type>::type
+: public is_null_pointer<_Tp>
 { };
 
   // Composite type categories.
@@ -433,7 +439,8 @@
   /// is_fundamental
   template
 struct is_fundamental
-: public __or_, is_void<_Tp>, __is_nullptr_t<_Tp>>::type
+: public __or_, is_void<_Tp>,
+  is_null_pointer<_Tp>>::type
 { };
 
   /// is_object
@@ -450,7 +457,7 @@
   template
 struct is_scalar
 : public __or_, is_enum<_Tp>, is_pointer<_Tp>,
-   is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type
+   is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
 { };
 
   /// is_compound
Index: testsuite/20_util/declval/requirements/1_neg.cc
===
--- testsuite/20_util/declval/requirements/1_neg.cc (revision 198511)
+++ testsuite/20_util/declval/requirements/1_neg.cc (working copy)
@@ -19,7 +19,7 @@
 // with this library; see the file COPYING3.  If not see
 // .
 
-// { dg-error "static assertion failed" "" { target *-*-* } 1852 }
+// { dg-error "static assertion failed" "" { target *-*-* } 1859 }
 
 #include 
 
Index: testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc
===
--- testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc
(revision 0)
+++ testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc
(working copy)
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+// 2013-05-02  Paolo Carlini  
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include 
+
+namespace std
+{
+  typedef short test_type;
+  template struct is_null_pointer;
+}
Index: testsuite/20_util/is_null_pointer/requirements/typedefs.cc
===
--- testsuite/20_util/is_null_pointer/requirements/typedefs.cc  (revision 0)
+++ testsuite/20_util/is_null_pointer/requirements/typedefs.cc  (working copy)
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++11" }
+// 2013-05-02  Paolo Carlini  
+//
+// Copyright (C) 2013 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

[Fortran-dev, committed] scan-dump fix, iso_ts29113.c lower_bound corrections

2013-05-02 Thread Tobias Burnus

I have committed the attached patch to the Fortran-dev branch (Rev. 198513).

Dump scan: Using scan-tree-dump-times does not seem to handle patterns; 
thus, scan-tree-dump is now used.


runtime/iso_ts29113.c: Correctly set lower_bound for CFI_establish and 
CFI_select_part, I think it should now match the standard. For 
CFI_is_contiguous, I missed to handle negative strides.


Tobias
Index: gcc/testsuite/ChangeLog.fortran-dev
===
--- gcc/testsuite/ChangeLog.fortran-dev	(Revision 198512)
+++ gcc/testsuite/ChangeLog.fortran-dev	(Arbeitskopie)
@@ -1,3 +1,7 @@
+2013-05-02  Tobias Burnus  
+
+	* gfortran.dg/iso-ts-29113_2.f90: Update scan-dump.
+
 2013-04-30  Tobias Burnus  
 
 	* gfortran.dg/iso-ts-29113_2.f90: New.
Index: gcc/testsuite/gfortran.dg/iso-ts-29113_2.f90
===
--- gcc/testsuite/gfortran.dg/iso-ts-29113_2.f90	(Revision 198512)
+++ gcc/testsuite/gfortran.dg/iso-ts-29113_2.f90	(Arbeitskopie)
@@ -125,8 +125,8 @@
 ! { dg-final { scan-tree-dump-times "x_str1b.type = 261;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "x_str4a.type = 1029;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "x_str4b.type = 1029;" 1 "original" } }
-! { dg-final { scan-tree-dump-times "x_cptr.type = (1025|2049);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "x_funcptr.type = (1025|2049);" 1 "original" } }
+! { dg-final { scan-tree-dump   "x_cptr.type = (1025|2049);"  "original" } }
+! { dg-final { scan-tree-dump   "x_funcptr.type = (1025|2049);" "original" } }
 ! { dg-final { scan-tree-dump-times "x_seq.type = 6;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "x_bindc.type = 6;" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "x_ext.type = -1;" 1 "original" } }
Index: libgfortran/ChangeLog.fortran-dev
===
--- libgfortran/ChangeLog.fortran-dev	(Revision 198512)
+++ libgfortran/ChangeLog.fortran-dev	(Arbeitskopie)
@@ -1,3 +1,9 @@
+2013-05-02  Tobias Burnus  
+
+	* runtime/iso_ts29113.c (CFI_establish, CFI_select_part):
+	Correctly set lower_bound.
+	(CFI_is_contiguous): Handle negative strides.
+
 2013-04-30  Tobias Burnus  
 
 	* ISO_Fortran_binding.h.tmpl (CFI_cdesc_t): Change order
Index: libgfortran/runtime/iso_ts29113.c
===
--- libgfortran/runtime/iso_ts29113.c	(Revision 198512)
+++ libgfortran/runtime/iso_ts29113.c	(Arbeitskopie)
@@ -169,7 +169,7 @@
   sm = dv->elem_len;
   for (i = 0; i < rank; i++)
 {
-  dv->dim[i].lower_bound = 0; /* Note: Only required for pointers.  */
+  dv->dim[i].lower_bound = 0;
   dv->dim[i].extent = extents[i];
   dv->dim[i].sm = sm;
   sm *= extents[i];
@@ -196,7 +196,7 @@
   size = dv->elem_len;
   for (i = 1; i < dv->rank; i++)
 {
-  if (size < dv->dim[i].sm)
+  if (size < dv->dim[i].sm || dv->dim[i].sm < 0)
 	return 0;
   size *= dv->dim[i].sm;
 }
@@ -314,8 +314,7 @@
 
   for (i = 1; i < result->rank; i++)
{
-  result->dim[i].lower_bound = result->attribute == CFI_attribute_other
-   ? 0 : source->dim[i].lower_bound;
+  result->dim[i].lower_bound = source->dim[i].lower_bound;
   result->dim[i].extent = source->dim[i].extent;
   result->dim[i].sm = source->dim[i].sm;
 }


[PATCH RX] Added target specific macros for macros for RX100, RX200, and RX600

2013-05-02 Thread Sandeep Kumar Singh
Hi,

Please find the attached patch to add specific macros related to targets.

The current RX port does not contain specific macros related to targets.
For the compiler option "-mcpu=name", the valid names are rx600, rx200
and rx610. RX610 was first target supported, so this macro may have
been added for testing purpose.

$rx-elf-gcc test.c -mcpu=rx600
The rx600 is the default target and defines the macro "__RX_FPU_INSNS__"

The below command will generate code specific for RX200, $rx-elf-gcc
test.c -
mcpu=rx200 This command does not pass any specific macro, but does not
define __RX_FPU_INSNS__.

The -mcpu option does not support the rx100 target name, however the
rx200 should have the same effect as this target also does not support FPU.

No regression found with this patch.

Please review the patch and let me know if there should be any
modifications in it?


Regards,
Sandeep Kumar Singh,
KPIT Cummins InfoSystems Ltd.
Pune, India

gcc/ChangeLog
2013-05-02  Sandeep Kumar Singh  

* rx/rx.h (TARGET_CPU_CPP_BUILTINS): Add macros for RX100, RX200, and 
RX600. 
* rx/rx.opt: Add macro for rx100 with string rx100 and value RX100.
* rx/rx-opts.h (rx_cpu_types): Add new cpu type rx100.
* rx/t-rx: Add rx100 under multi library matches option for nofpu 
option.



rx_macros.patch
Description: rx_macros.patch


[PATCH] Move instantiate_scev/resolve_mixers cache from GC to heap

2013-05-02 Thread Richard Biener

This moves the very short-lived hashtable used by instantiate_scev
and resolve_mixers out of GC memory.  See my mail to g...@gcc.gnu.org
for how hash_table is lacking to improve the new code even further.

I've timed the patch for aermod from polyhedron (the benchmark
with the largest compile-time) and cannot measure any compile-time
effect.  The number of cached entries distribution is

  84776 0
 176181 1
347 2
  3 3

so that may be not surprising (though we now avoid allocating
the hashtable for the case where nothing is cached).  maxresident
goes down though, so do the number of minor pagefaults.

Bootstrap / regtest on x86_64-unknown-linux-gnu in progress.

Richard.

2013-05-02  Richard Biener  

* tree-scalar-evolution.c (scev_info_hasher): Remove.
(struct instantiate_cache_entry): New type.
(struct instantiate_cache_entry_hasher): New hashtable descriptor.
(struct instantiate_cache_type): New type.
(set_instantiated_value, get_instantiated_value): Remove.
(get_instantiated_value_entry): New function.
(instantiate_scev_name): Use the new cache and adjust.
(instantiate_scev_poly): Adjust.
(instantiate_scev_binary): Likewise.
(instantiate_array_ref): Likewise.
(instantiate_scev_convert): Likewise.
(instantiate_scev_not): Likewise.
(instantiate_scev_3): Likewise.
(instantiate_scev_2): Likewise.
(instantiate_scev_r): Likewise.
(instantiate_scev): Likewise.
(resolve_mixers): Likewise.

Index: gcc/tree-scalar-evolution.c
===
--- gcc/tree-scalar-evolution.c (revision 198441)
+++ gcc/tree-scalar-evolution.c (working copy)
@@ -344,38 +346,6 @@ del_scev_info (void *e)
   ggc_free (e);
 }
 
-/* Hashtable helpers.  */
-
-struct scev_info_hasher
-{
-  typedef scev_info_str value_type;
-  typedef scev_info_str compare_type;
-  static inline hashval_t hash (const value_type *);
-  static inline bool equal (const value_type *, const compare_type *);
-  static inline void remove (value_type *);
-};
-
-inline hashval_t
-scev_info_hasher::hash (const value_type *elt)
-{
-  return hash_scev_info (elt);
-}
-
-inline bool
-scev_info_hasher::equal (const value_type *elt1, const compare_type *elt2)
-{
-  return eq_scev_info (elt1, elt2);
-}
-
-/* Deletes database element E.  */
-
-inline void
-scev_info_hasher::remove (value_type *e)
-{
-  del_scev_info (e);
-}
-
-typedef hash_table  scev_info_hash_table_type;
 
 /* Get the scalar evolution of VAR for INSTANTIATED_BELOW basic block.
A first query on VAR returns chrec_not_analyzed_yet.  */
@@ -2078,43 +2048,87 @@ analyze_scalar_evolution_in_loop (struct
 }
 }
 
-/* Returns from CACHE the value for VERSION instantiated below
-   INSTANTIATED_BELOW block.  */
 
-static tree
-get_instantiated_value (scev_info_hash_table_type cache,
-   basic_block instantiated_below, tree version)
+/* Hashtable helpers for a temporary hash-table used when
+   instantiating a CHREC or resolving mixers.  For this use
+   instantiated_below is always the same.  */
+
+struct instantiate_cache_entry
 {
-  struct scev_info_str *info, pattern;
+  tree name;
+  tree chrec;
+};
 
-  pattern.var = version;
-  pattern.instantiated_below = instantiated_below;
-  info = cache.find (&pattern);
+struct instantiate_cache_entry_hasher : typed_noop_remove 
+{
+  typedef uintptr_t value_type;
+  typedef instantiate_cache_entry compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+};
 
-  if (info)
-return info->chrec;
-  else
-return NULL_TREE;
+struct instantiate_cache_type
+{
+  hash_table  htab;
+  vec entries;
+
+  ~instantiate_cache_type();
+};
+
+instantiate_cache_type::~instantiate_cache_type ()
+{
+  if (htab.is_created ())
+{
+  htab.dispose ();
+  entries.release ();
+}
 }
 
-/* Sets in CACHE the value of VERSION instantiated below basic block
-   INSTANTIATED_BELOW to VAL.  */
+static instantiate_cache_type *ctbl;
 
-static void
-set_instantiated_value (scev_info_hash_table_type cache,
-   basic_block instantiated_below, tree version, tree val)
+inline hashval_t
+instantiate_cache_entry_hasher::hash (const value_type *idx)
 {
-  struct scev_info_str *info, pattern;
-  scev_info_str **slot;
+  instantiate_cache_entry *elt
+= &ctbl->entries[reinterpret_cast  (idx) - 2];
+  return SSA_NAME_VERSION (elt->name);
+}
 
-  pattern.var = version;
-  pattern.instantiated_below = instantiated_below;
-  slot = cache.find_slot (&pattern, INSERT);
+inline bool
+instantiate_cache_entry_hasher::equal (const value_type *idx1,
+  const compare_type *elt2)
+{
+  compare_type *elt1 = &ctbl->entries[reinterpret_cast  (idx1) - 2];
+  return elt1->name == elt2->name;
+}
 
+/* Returns from CACHE a pointer to the cached chrec 

Re: [PATCH] Move instantiate_scev/resolve_mixers cache from GC to heap

2013-05-02 Thread Jakub Jelinek
On Thu, May 02, 2013 at 12:56:05PM +0200, Richard Biener wrote:
> +
> +  ~instantiate_cache_type();

Missing space.

Jakub


Re: [PATCH] Loop distribution improvements

2013-05-02 Thread Richard Biener
On Fri, 5 Apr 2013, Marc Glisse wrote:

> On Fri, 5 Apr 2013, Marc Glisse wrote:
> 
> > Shouldn't we change integer_all_onesp to do what its name says and create a
> > separate integer_minus_onep for the single place I could find where it would
> > break, the folding of x * -1 ?
> 
> 2013-04-05  Marc Glisse  
> 
>   * tree.c (integer_all_onesp) : Test that both
>   components are all 1s.
>   (integer_minus_onep): New function.
>   * tree.h (integer_minus_onep): Declare it.
>   * fold-const.c (fold_binary_loc) : Test
>   integer_minus_onep instead of integer_all_onesp.
> 
> It passes bootstrap+testsuite on x86_64-linux-gnu, but if someone else wants
> to go through the (not that long) list of integer_all_onesp to check for
> things that might break... I did not change places where the name "-1" might
> make more sense than "all 1s" but the type cannot be complex.

Ok.

Can you followup with a patch to do 
s/integer_all_onesp/integer_minus_onep/ where it makes sense?

Thanks,
Richard.


Re: [PING] SLSR for conditional candidates

2013-05-02 Thread Richard Biener
On Mon, 29 Apr 2013, Bill Schmidt wrote:

> Half-hearted ping for
> http://gcc.gnu.org/ml/gcc-patches/2013-03/msg01291.html ...
> 
> I promise this is the last major code dump for SLSR. ;)



+ if (!operand_equal_p (arg_cand->stride, integer_one_node, 0))
+   return;

!integer_onep (arg_cand->stride);

+ arg_stmt = SSA_NAME_DEF_STMT (arg);
+
+ if (arg_stmt
+ && gimple_code (arg_stmt) != GIMPLE_NOP)
+   arg_bb = gimple_bb (arg_stmt);
+ else
+   arg_bb = ENTRY_BLOCK_PTR->next_bb;

   if (SSA_NAME_IS_DEFAULT_DEF (arg))
 arg_bb = single_succ (ENTRY_BLOCK_PTR);
   else
 arg_bb = gimple_bb (SSA_NAME_DEF_STMT (arg));

don't use ->next_bb - the ordering of BBs is arbitrary.   No idea
why you needed to look for !arg_stmt.

+  /* If the basis name and the candidate's LHS have incompatible
+types, introduce a cast.  */
+  if (!types_compatible_p (target_type,
+  TREE_TYPE (basis_name)))
+   basis_name = introduce_cast_before_cand (c, target_type,
+basis_name, var);

use !useless_type_conversion_p (target_type, TREE_TYPE (basis_name))
if you are looking whether the op can be used where target_type is
requested (as opposed to where it can be assigned _from_ a target_type
thing).

+ tree rhs1 = gimple_assign_rhs1 (c->cand_stmt);
+ tree rhs2 = gimple_assign_rhs2 (c->cand_stmt);
+ if (cand_code != NEGATE_EXPR

are you sure you are not accessing out-of-bounds for the
single-operand NEGATE_EXPR case?

+/* Return the index in the increment vector of the given INCREMENT.  */
+
+static inline unsigned
+incr_vec_index (double_int increment)
+{
+  unsigned i;
+  
+  for (i = 0; i < incr_vec_len && increment != incr_vec[i].incr; i++)
+;

I smell quadratic complexity here.  Is the incr_vec maybe better
sorted by 'incr'?

+  basis_type = TREE_TYPE (basis_name);
+  lazy_create_slsr_reg (var, basis_type);
+  lhs = make_ssa_name (*var, NULL);

btw, lazy_create_slsr_reg should go away now as we have
the notion of "anonymous" SSA names (SSA names without underlying
VAR_DECLs).  Just do

   lhs = make_ssa_name (basis_type, NULL);

here.  You can followup with a patch to remove lazy_create_slsr_reg.
Another possibility is to use make_temp_ssa_name which has an
additional char *name argument:

   lhs = make_temp_ssa_name (basis_type, NULL, "slsr");

which then makes the SSA names show as slsr_N in dumps.

+  int cost = 0;
+  slsr_cand_t phi_cand = base_cand_from_table (gimple_phi_result (phi));
 
-  gcc_assert (i < incr_vec_len);
-  return i;
+  for (i = 0; i < gimple_phi_num_args (phi); i++)
+{
+  tree arg = gimple_phi_arg_def (phi, i);
+
+  if (!operand_equal_p (arg, phi_cand->base_expr, 0))

generally SSA names can be compared with == / != directly.
PHI results are always SSA names so no need to dispatch
to operand_equal_p here.

Otherwise the patch looks ok.

Thanks,
Richard.



Re: Logic operators ! && || for vectors

2013-05-02 Thread Richard Biener
On Fri, Apr 26, 2013 at 2:23 PM, Marc Glisse  wrote:
> Ping http://gcc.gnu.org/ml/gcc-patches/2013-04/msg00783.html
>
> Even if we decide not to implement logic operators in the front-end, we
> still need the fix for the wrong code (the 2 save_expr in
> cp_build_binary_op, is that part of the patch ok with the vector-scalar-2.c
> testcase? and for 4.8?) and to avoid ICEing on __m128i f(__m128d a,__m128d
> b){return a On Fri, 12 Apr 2013, Marc Glisse wrote:
>
>> Hello,
>>
>> this adds support for vector !, && and ||. In the long run, I think it
>> would be good to be able to use TRUTH_*_EXPR with vectors, but that's
>> probably a lot of work.
>>
>> It currently restricts && and || to vector-vector operations. I'd like to
>> also support mixed scalar-vector later, but it is a bit more complicated.
>> With vectors, && evaluates both sides. For scal && vec, we have the choice
>> of making it short-circuit: cond_expr((bool)scal, vec!=0, {0}) or do a
>> vector and. For vec && scal, it seems clear we have to evaluate both
>> operands, but then we can also make it a cond_expr instead of a BIT_AND_EXPR
>> (technically, I think I can achieve that with save_expr and a compound_expr,
>> I don't know if there is a better way to add statements).
>>
>> The missing save_expr before build_vector_from_val are a bug I introduced
>> when I adapted the code from the C front-end. This bit (and the
>> vector-scalar-2.c testcase that goes with it) should probably be backported
>> to 4.8.
>>
>> The code we generate for these examples is not very good, but that's a
>> different issue.
>>
>> Bootstrap+testsuite on x86_64-linux-gnu.
>>
>> 2013-04-12  Marc Glisse  
>>
>> gcc/cp/
>> * typeck.c (cp_build_binary_op): Call save_expr before
>> build_vector_from_val.
>> > TRUTH_OR_EXPR>: Handle vectors.
>> (cp_build_unary_op) : Likewise.
>>
>> gcc/c-family/
>> * c-common.c (warn_logical_operator): Give up for vectors.
>>
>> gcc/testsuite/
>> * c-c++-common/vector-scalar-2.c: New testcase.
>> * g++.dg/ext/vector22.C: Likewise.
>> * g++.dg/ext/vector23.C: Likewise.
>> * g++.dg/ext/vector9.C: Adapt.
>> * g++.dg/other/error23.C: Adapt.
>>
>>
>
> --
> Marc Glisse


Re: [PATCH] Convert profile scaling computations to rounding divides (issue9050044)

2013-05-02 Thread Richard Biener
On Tue, Apr 30, 2013 at 4:21 PM, Teresa Johnson  wrote:
> Follow-on patch to r197595 to complete the replacement of truncating divides
> in profile scaling code with rounding divide equivalents using helper routines
> in basic-block.h. See http://gcc.gnu.org/ml/gcc-patches/2013-04/msg00321.html
> for background.
>
> In addition to bootstrap and profiledbootstrap builds and tests (with and
> without LTO), I built and tested performance of the SPEC cpu2006 benchmarks
> with FDO on a Nehalem system. I didn't see any performance changes that
> looked significant.
>
> Ok for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> Teresa
>
> 2013-04-30  Teresa Johnson  
>
> * loop-unswitch.c (unswitch_loop): Use helper routines with rounding
> divides.
> * cfg.c (update_bb_profile_for_threading): Ditto.
> * tree-inline.c (copy_bb): Ditto.
> (copy_edges_for_bb): Ditto.
> (initialize_cfun): Ditto.
> (copy_cfg_body): Ditto.
> (expand_call_inline): Ditto.
> * ipa-inline-analysis.c (estimate_edge_size_and_time): Ditto.
> (estimate_node_size_and_time): Ditto.
> (inline_merge_summary): Ditto.
> * cgraphclones.c (cgraph_clone_edge): Ditto.
> (cgraph_clone_node): Ditto.
> * sched-rgn.c (compute_dom_prob_ps): Ditto.
> (compute_trg_info): Ditto.
>
> Index: loop-unswitch.c
> ===
> --- loop-unswitch.c (revision 198416)
> +++ loop-unswitch.c (working copy)
> @@ -436,12 +436,10 @@ unswitch_loop (struct loop *loop, basic_block unsw
>emit_insn_after (seq, BB_END (switch_bb));
>e = make_edge (switch_bb, true_edge->dest, 0);
>e->probability = prob;
> -  /* Update to use apply_probability().  */
> -  e->count = latch_edge->count * prob / REG_BR_PROB_BASE;
> +  e->count = apply_probability (latch_edge->count, prob);
>e = make_edge (switch_bb, FALLTHRU_EDGE (unswitch_on)->dest, 
> EDGE_FALLTHRU);
>e->probability = false_edge->probability;
> -  /* Update to use apply_probability().  */
> -  e->count = latch_edge->count * (false_edge->probability) / 
> REG_BR_PROB_BASE;
> +  e->count = apply_probability (latch_edge->count, false_edge->probability);
>
>if (irred_flag)
>  {
> Index: cfg.c
> ===
> --- cfg.c   (revision 198416)
> +++ cfg.c   (working copy)
> @@ -848,8 +848,7 @@ update_bb_profile_for_threading (basic_block bb, i
>/* Compute the probability of TAKEN_EDGE being reached via threaded edge.
>   Watch for overflows.  */
>if (bb->frequency)
> -/* Update to use GCOV_COMPUTE_SCALE.  */
> -prob = edge_frequency * REG_BR_PROB_BASE / bb->frequency;
> +prob = GCOV_COMPUTE_SCALE (edge_frequency, bb->frequency);
>else
>  prob = 0;
>if (prob > taken_edge->probability)
> Index: tree-inline.c
> ===
> --- tree-inline.c   (revision 198416)
> +++ tree-inline.c   (working copy)
> @@ -1519,13 +1519,11 @@ copy_bb (copy_body_data *id, basic_block bb, int f
>   basic_block_info automatically.  */
>copy_basic_block = create_basic_block (NULL, (void *) 0,
>   (basic_block) prev->aux);
> -  /* Update to use apply_scale().  */
> -  copy_basic_block->count = bb->count * count_scale / REG_BR_PROB_BASE;
> +  copy_basic_block->count = apply_scale (bb->count, count_scale);
>
>/* We are going to rebuild frequencies from scratch.  These values
>   have just small importance to drive canonicalize_loop_headers.  */
> -  /* Update to use EDGE_FREQUENCY.  */
> -  freq = ((gcov_type)bb->frequency * frequency_scale / REG_BR_PROB_BASE);
> +  freq = apply_scale ((gcov_type)bb->frequency, frequency_scale);
>
>/* We recompute frequencies after inlining, so this is quite safe.  */
>if (freq > BB_FREQ_MAX)
> @@ -1891,8 +1889,7 @@ copy_edges_for_bb (basic_block bb, gcov_type count
> && old_edge->dest->aux != EXIT_BLOCK_PTR)
>   flags |= EDGE_FALLTHRU;
> new_edge = make_edge (new_bb, (basic_block) old_edge->dest->aux, 
> flags);
> -/* Update to use apply_scale().  */
> -   new_edge->count = old_edge->count * count_scale / REG_BR_PROB_BASE;
> +   new_edge->count = apply_scale (old_edge->count, count_scale);
> new_edge->probability = old_edge->probability;
>}
>
> @@ -2066,10 +2063,10 @@ initialize_cfun (tree new_fndecl, tree callee_fnde
>struct function *src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl);
>gcov_type count_scale;
>
> -  /* Update to use GCOV_COMPUTE_SCALE.  */
>if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count)
> -count_scale = (REG_BR_PROB_BASE * count
> -  / ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count);
> +count_scale
> += GCOV_COMPUTE_SCALE (count,
> +  ENTRY_BLOCK_PTR_FOR_FUNCTION 
>

[v3] Add some tests for std::integral_constant

2013-05-02 Thread Paolo Carlini

Hi,

committed to mainline.

Thanks,
Paolo.

///
Index: testsuite/20_util/integral_constant/operator_value_type.cc
===
--- testsuite/20_util/integral_constant/operator_value_type.cc  (revision 0)
+++ testsuite/20_util/integral_constant/operator_value_type.cc  (working copy)
@@ -0,0 +1,36 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+//
+// Copyright (C) 2013 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  //testsuite_hooks.h>
+
+typedef std::integral_constant   ic_one;
+typedef std::integral_constant   ic_zero;
+typedef std::integral_constant  ic_minus_one;
+
+typedef std::integral_constant   ic_true;
+typedef std::integral_constant  ic_false;
+
+static_assert( ic_one() == 1, "" );
+static_assert( ic_zero() == 0, "" );
+static_assert( ic_minus_one() == -1, "" );
+
+static_assert( ic_true() == true, "" );
+static_assert( ic_false() == false, "" );
Index: testsuite/20_util/integral_constant/requirements/constexpr_data.cc
===
--- testsuite/20_util/integral_constant/requirements/constexpr_data.cc  
(revision 0)
+++ testsuite/20_util/integral_constant/requirements/constexpr_data.cc  
(working copy)
@@ -0,0 +1,52 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2013 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 
+
+namespace __gnu_test
+{
+  struct constexpr_member_data
+  {
+template
+  void
+  operator()()
+  {
+   struct _Concept
+   {
+ void __constraint()
+ {
+   constexpr auto v __attribute__((unused)) (_Ttesttype::value);
+ }
+   };
+
+   _Concept c;
+   c.__constraint();
+  }
+  };
+}
+
+int main()
+{
+  __gnu_test::constexpr_member_data test;
+  test.operator()>();
+  test.operator()>();
+  return 0;
+}
Index: 
testsuite/20_util/integral_constant/requirements/explicit_instantiation.cc
===
--- testsuite/20_util/integral_constant/requirements/explicit_instantiation.cc  
(revision 0)
+++ testsuite/20_util/integral_constant/requirements/explicit_instantiation.cc  
(working copy)
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include 
+
+namespace std
+{
+  typedef short test_type;
+  template struct integral_constant;
+}
Index: testsuite/20_util/integral_constant/requirements/typedefs.cc
===
--- testsuite/20_util/integral_constant/requirements/typedefs.cc
(revision 0)
+++ testsuite/20_util/integral_constant/requ

[PATCH] Use an obstack for graphds graph vertices and edges

2013-05-02 Thread Richard Biener

I've noticed quite some malloc/free load coming from graphds.
The following uses an obstack for both, simplifying freeing the
graph.  This reduces the allocator load by a constant factor
as well and eventually improves cache locality.  graphds users
may use the obstack to allocate auxiliar data they hang off
vertices and edges from as well (mainly the RDG code).

Bootstrap / regtest pending on x86_64-unknown-linux-gnu.

Richard.

2013-05-02  Richard Biener  

* graphds.h (struct graph): Add obstack member.
* graphds.c (new_graph): Initialize obstack and allocate
vertices from it.
(add_edge): Allocate edge from the obstack.
(free_graph): Free the obstack instead of all edges and
vertices.

Index: gcc/graphds.c
===
*** gcc/graphds.c   (revision 198441)
--- gcc/graphds.c   (working copy)
*** new_graph (int n_vertices)
*** 58,65 
  {
struct graph *g = XNEW (struct graph);
  
g->n_vertices = n_vertices;
!   g->vertices = XCNEWVEC (struct vertex, n_vertices);
  
return g;
  }
--- 58,67 
  {
struct graph *g = XNEW (struct graph);
  
+   gcc_obstack_init (&g->ob);
g->n_vertices = n_vertices;
!   g->vertices = XOBNEWVEC (&g->ob, struct vertex, n_vertices);
!   memset (g->vertices, 0, sizeof (struct vertex) * n_vertices);
  
return g;
  }
*** new_graph (int n_vertices)
*** 69,78 
  struct graph_edge *
  add_edge (struct graph *g, int f, int t)
  {
!   struct graph_edge *e = XNEW (struct graph_edge);
struct vertex *vf = &g->vertices[f], *vt = &g->vertices[t];
  
- 
e->src = f;
e->dest = t;
  
--- 71,79 
  struct graph_edge *
  add_edge (struct graph *g, int f, int t)
  {
!   struct graph_edge *e = XOBNEW (&g->ob, struct graph_edge);
struct vertex *vf = &g->vertices[f], *vt = &g->vertices[t];
  
e->src = f;
e->dest = t;
  
*** for_each_edge (struct graph *g, graphds_
*** 324,343 
  void
  free_graph (struct graph *g)
  {
!   struct graph_edge *e, *n;
!   struct vertex *v;
!   int i;
! 
!   for (i = 0; i < g->n_vertices; i++)
! {
!   v = &g->vertices[i];
!   for (e = v->succ; e; e = n)
!   {
! n = e->succ_next;
! free (e);
!   }
! }
!   free (g->vertices);
free (g);
  }
  
--- 325,331 
  void
  free_graph (struct graph *g)
  {
!   obstack_free (&g->ob, NULL);
free (g);
  }
  
Index: gcc/graphds.h
===
*** gcc/graphds.h   (revision 198441)
--- gcc/graphds.h   (working copy)
*** struct vertex
*** 43,51 
  
  struct graph
  {
!   int n_vertices; /* Number of vertices.  */
!   struct vertex *vertices;
!   /* The vertices.  */
  };
  
  struct graph *new_graph (int);
--- 43,51 
  
  struct graph
  {
!   int n_vertices;/* Number of vertices.  */
!   struct vertex *vertices; /* The vertices.  */
!   struct obstack ob; /* Obstack for vertex and edge allocation.  */
  };
  
  struct graph *new_graph (int);


Re: [PATCH] Move instantiate_scev/resolve_mixers cache from GC to heap

2013-05-02 Thread Richard Biener
On Thu, 2 May 2013, Jakub Jelinek wrote:

> On Thu, May 02, 2013 at 12:56:05PM +0200, Richard Biener wrote:
> > +
> > +  ~instantiate_cache_type();
> 
> Missing space.

Fixed and committed after bootstrap / regtest on x86_64-unknown-linux-gnu.

Richard.


Re: Ping: [PATCH, PR 42371] Remove references to functions from symbol table during inlining

2013-05-02 Thread Jan Hubicka
> 2013-03-22  Martin Jambor  
> 
>   PR middle-end/42371
>   * ipa-prop.h (IPA_UNDESCRIBED_USE): New macro.
>   (ipa_constant_data): New type.
>   (ipa_jump_func): Use ipa_constant_data to hold information about
>   constant jump functions.
>   (ipa_get_jf_constant): Adjust to jump function type changes.
>   (ipa_get_jf_constant_rdesc): New function.
>   (ipa_param_descriptor): New field controlled_uses.
>   (ipa_get_controlled_uses): New function.
>   (ipa_set_controlled_uses): Likewise.
>   * ipa-ref.h (ipa_find_reference): Declare.
>   * ipa-prop.c (ipa_cst_ref_desc): New type.
>   (ipa_print_node_jump_functions_for_edge): Adjust for jump function type
>   changes.
>   (ipa_set_jf_constant): Likewise.  Also create reference descriptions.
>   New parameter cs.  Adjust all callers.
>   (ipa_analyze_params_uses): Detect uncontrolled and controlled uses.
>   (remove_described_reference): New function.
>   (jfunc_rdesc_usable): Likewise.
>   (try_make_edge_direct_simple_call): Decrement controlled use count,
>   attempt to remove reference if it hits zero.
>   (combine_controlled_uses_counters): New function.
>   (propagate_controlled_uses): Likewise.
>   (ipa_propagate_indirect_call_infos): Call propagate_controlled_uses.
>   (ipa_edge_duplication_hook): Duplicate reference descriptions.
>   (ipa_print_node_params): Print described use counter.
>   (ipa_write_jump_function): Adjust to jump function type changes.
>   (ipa_read_jump_function): New parameter CS, pass it to
>   ipa_set_jf_constant.  Adjust caller.
>   (ipa_write_node_info): Stream controlled use count
>   (ipa_read_node_info): Likewise.
>   * cgraph.c (cgraph_mark_address_taken_node): Bail out instead of
>   asserting.
>   * ipa-cp.c (ipcp_discover_new_direct_edges): Decrement controlled use
>   count.  Remove cloning-added reference if it reaches zero.
>   * ipa-ref.c (ipa_find_reference): New function.

As mentioned offline, I think the patch should be extended to work on 
references in general,
so we can do more of promoting to !TREE_ADDRESSABLE. But it can be handled 
incrementally.

> Index: src/gcc/cgraph.c
> ===
> *** src.orig/gcc/cgraph.c
> --- src/gcc/cgraph.c
> *** cgraph_remove_node (struct cgraph_node *
> *** 1409,1415 
>   void
>   cgraph_mark_address_taken_node (struct cgraph_node *node)
>   {
> !   gcc_assert (!node->global.inlined_to);
> /* FIXME: address_taken flag is used both as a shortcut for testing 
> whether
>IPA_REF_ADDR reference exists (and thus it should be set on node
>representing alias we take address of) and as a test whether address
> --- 1409,1418 
>   void
>   cgraph_mark_address_taken_node (struct cgraph_node *node)
>   {
> !   /* Indirect inlining can figure out that all uses of the address are
> !  inlined.  */
> !   if (node->global.inlined_to)
> ! return;
> /* FIXME: address_taken flag is used both as a shortcut for testing 
> whether
>IPA_REF_ADDR reference exists (and thus it should be set on node
>representing alias we take address of) and as a test whether address

Perhaps add assert that after_inlining is set?

Paths is OK,
thanks


[PATCH,ARM] Fix PR56732

2013-05-02 Thread Greta Yorsh
Epilogue in RTL (r188743) generated for naked functions adds simple return
jump insn and causes an ICE, as described here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56732

There is a missing check of really_return argument in arm_expand_epilogue.
This patch adds the missing check and a new test.

No regression on qemu for arm-none-eabi with cortex-a15 arm/thumb.
Bootstrap successful on Cortex-A15 and no regression.

Ok for trunk?

Thanks,
Greta

gcc/ChangeLog

2013-05-02  Greta Yorsh  

PR target/56732
* config/arm/arm.c (arm_expand_epilogue): Check really_return before
generating simple_return for naked functions.

gcc/testsuite/ChangeLog

2013-05-02  Greta Yorsh  

PR target/56732
* gcc.target/arm/pr56732-1.c: New test.diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 464d91c..9d4a453 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -24067,7 +24067,8 @@ arm_expand_epilogue (bool really_return)
   if (IS_NAKED (func_type)
   || (IS_VOLATILE (func_type) && TARGET_ABORT_NORETURN))
 {
-  emit_jump_insn (simple_return_rtx);
+  if (really_return)
+emit_jump_insn (simple_return_rtx);
   return;
 }
 
diff --git a/gcc/testsuite/gcc.target/arm/pr56732-1.c 
b/gcc/testsuite/gcc.target/arm/pr56732-1.c
new file mode 100644
index 000..ac8b8cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr56732-1.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target naked_functions } */
+/* { dg-options "-O2 -Wall" } */
+extern void bar();
+
+void __attribute__((__naked__))
+foo(void)
+{
+  bar ();
+}
+
+int __attribute__((naked))
+zoo (int a, int b, int c, int d, int e, int f)
+{
+  bar ();
+  return e;
+}
+/* Verify that __attribute__((naked)) produces a naked function that
+   does not use bx to return. */
+/* { dg-final { scan-assembler-not "\tbx\tlr" } } */


Re: [PATCH,ARM] Fix PR56732

2013-05-02 Thread Richard Earnshaw

On 02/05/13 13:52, Greta Yorsh wrote:

Epilogue in RTL (r188743) generated for naked functions adds simple return
jump insn and causes an ICE, as described here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56732

There is a missing check of really_return argument in arm_expand_epilogue.
This patch adds the missing check and a new test.

No regression on qemu for arm-none-eabi with cortex-a15 arm/thumb.
Bootstrap successful on Cortex-A15 and no regression.

Ok for trunk?

Thanks,
Greta

gcc/ChangeLog

2013-05-02  Greta Yorsh  

PR target/56732
* config/arm/arm.c (arm_expand_epilogue): Check really_return before
generating simple_return for naked functions.

gcc/testsuite/ChangeLog

2013-05-02  Greta Yorsh  

PR target/56732
* gcc.target/arm/pr56732-1.c: New test.



OK.

R.



[linaro/gcc-4_8-branch] Selective backports from trunk

2013-05-02 Thread Matthew Gretton-Dann

All,

I have just backported the following revisions from trunk to the 
linaro/gcc-4_8-branch:


196795-196797, 196957, 197489-197491, 197513, 197517-197523, 197526-197528, 
197530, 197642, 197770, 197807, 197921,  197925, 197965, 198004, 
198019-198020, 198029-198030, 198090, 198136-198137, 198142, 198176, 198298, 
198302-198306, 198316, 198394, 198396-198400, 198402-198404, 198406, 198412, 
198424-198425, 198443


Thanks,

Matt

--
Matthew Gretton-Dann
Toolchain Working Group, Linaro


[PATCH, AArch64] Testcases for TST instruction

2013-05-02 Thread Ian Bolton
I previously fixed a bug with the patterns that generate TST.

I added these testcases to make our regression testing more solid.

They've been running on our internal branch for about a month.

OK to commit to trunk?

Cheers,
Ian


2013-05-02  Ian Bolton  

   * gcc.target/aarch64/tst_1.c: New test.
   * gcc.target/aarch64/tst_2.c: LikewiseIndex: gcc/testsuite/gcc.target/aarch64/tst_1.c
===
--- gcc/testsuite/gcc.target/aarch64/tst_1.c(revision 0)
+++ gcc/testsuite/gcc.target/aarch64/tst_1.c(revision 0)
@@ -0,0 +1,150 @@
+/* { dg-do run } */
+/* { dg-options "-O2 --save-temps -fno-inline" } */
+
+extern void abort (void);
+
+int
+tst_si_test1 (int a, int b, int c)
+{
+  int d = a & b;
+
+  /* { dg-final { scan-assembler-times "tst\tw\[0-9\]+, w\[0-9\]+" 2 } } */
+  if (d == 0)
+return 12;
+  else
+return 18;
+}
+
+int
+tst_si_test2 (int a, int b, int c)
+{
+  int d = a & 0x;
+
+  /* { dg-final { scan-assembler "tst\tw\[0-9\]+, -1717986919" } } */
+  if (d == 0)
+return 12;
+  else
+return 18;
+}
+
+int
+tst_si_test3 (int a, int b, int c)
+{
+  int d = a & (b << 3);
+
+  /* { dg-final { scan-assembler "tst\tw\[0-9\]+, w\[0-9\]+, lsl 3" } } */
+  if (d == 0)
+return 12;
+  else
+return 18;
+}
+
+typedef long long s64;
+
+s64
+tst_di_test1 (s64 a, s64 b, s64 c)
+{
+  s64 d = a & b;
+
+  /* { dg-final { scan-assembler-times "tst\tx\[0-9\]+, x\[0-9\]+" 2 } } */
+  if (d == 0)
+return 12;
+  else
+return 18;
+}
+
+s64
+tst_di_test2 (s64 a, s64 b, s64 c)
+{
+  s64 d = a & 0xll;
+
+  /* { dg-final { scan-assembler "tst\tx\[0-9\]+, -6148914691236517206" } } */
+  if (d == 0)
+return 12;
+  else
+return 18;
+}
+
+s64
+tst_di_test3 (s64 a, s64 b, s64 c)
+{
+  s64 d = a & (b << 3);
+
+  /* { dg-final { scan-assembler "tst\tx\[0-9\]+, x\[0-9\]+, lsl 3" } } */
+  if (d == 0)
+return 12;
+  else
+return 18;
+}
+
+int
+main ()
+{
+  int x;
+  s64 y;
+
+  x = tst_si_test1 (29, 4, 5);
+  if (x != 18)
+abort ();
+
+  x = tst_si_test1 (5, 2, 20);
+  if (x != 12)
+abort ();
+
+  x = tst_si_test2 (29, 4, 5);
+  if (x != 18)
+abort ();
+
+  x = tst_si_test2 (1024, 2, 20);
+  if (x != 12)
+abort ();
+
+  x = tst_si_test3 (35, 4, 5);
+  if (x != 18)
+abort ();
+
+  x = tst_si_test3 (5, 2, 20);
+  if (x != 12)
+abort ();
+
+  y = tst_di_test1 (0x13029ll,
+ 0x32004ll,
+ 0x505050505ll);
+
+  if (y != 18)
+abort ();
+
+  y = tst_di_test1 (0x5000500050005ll,
+ 0x2111211121112ll,
+ 0x02020ll);
+  if (y != 12)
+abort ();
+
+  y = tst_di_test2 (0x13029ll,
+ 0x32004ll,
+ 0x505050505ll);
+  if (y != 18)
+abort ();
+
+  y = tst_di_test2 (0x540004100ll,
+ 0x32004ll,
+ 0x805050205ll);
+  if (y != 12)
+abort ();
+
+  y = tst_di_test3 (0x13029ll,
+ 0x06408ll,
+ 0x505050505ll);
+  if (y != 18)
+abort ();
+
+  y = tst_di_test3 (0x130002900ll,
+ 0x08808ll,
+ 0x505050505ll);
+  if (y != 12)
+abort ();
+
+  return 0;
+}
+
+/* { dg-final { cleanup-saved-temps } } */
Index: gcc/testsuite/gcc.target/aarch64/tst_2.c
===
--- gcc/testsuite/gcc.target/aarch64/tst_2.c(revision 0)
+++ gcc/testsuite/gcc.target/aarch64/tst_2.c(revision 0)
@@ -0,0 +1,156 @@
+/* { dg-do run } */
+/* { dg-options "-O2 --save-temps -fno-inline" } */
+
+extern void abort (void);
+
+int
+tst_si_test1 (int a, int b, int c)
+{
+  int d = a & b;
+
+  /* { dg-final { scan-assembler-not "tst\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" } 
} */
+  /* { dg-final { scan-assembler-times "and\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" 
2 } } */
+  if (d <= 0)
+return 12;
+  else
+return 18;
+}
+
+int
+tst_si_test2 (int a, int b, int c)
+{
+  int d = a & 0x;
+
+  /* { dg-final { scan-assembler-not "tst\tw\[0-9\]+, w\[0-9\]+, -1717986919" 
} } */
+  /* { dg-final { scan-assembler "and\tw\[0-9\]+, w\[0-9\]+, -1717986919" } } 
*/
+  if (d <= 0)
+return 12;
+  else
+return 18;
+}
+
+int
+tst_si_test3 (int a, int b, int c)
+{
+  int d = a & (b << 3);
+
+  /* { dg-final { scan-assembler-not "tst\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, 
lsl 3" } } */
+  /* { dg-final { scan-assembler "and\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" 
} } */
+  if (d <= 0)
+return 12;
+  else
+return 18;
+}
+
+typedef long long s64;
+
+s64
+tst_di_test1 (s64 a, s64 b, s64 c)
+{
+  s64 d = a & b;
+
+  /* { dg-final { scan-assembler-not "tst\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" } 
} */
+  /* { dg-final { scan-assembler-times "and\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" 
2 } } */
+  if (d <= 0)
+return 12;
+  else
+return 18;
+}
+
+s64
+tst_di_test2 (s64 a, s64 b, s64 c)
+{
+  s6

[PATCH] Fix GO bootstrap (?)

2013-05-02 Thread Richard Biener

The following patch should fix Go bootstrap.  We need to preserve
virtual SSA form properly during EH cleanup and for the
cleanup_empty_eh_merge_phis the same arguments that hold for
real variables should hold for virtual operands - they are not
changed by empty EH handlers and thus we can simply re-use them.

Bootstrap / regtest pending on x86_64-unknown-linux-gnu.

Richard.

Index: gcc/tree-eh.c
===
*** gcc/tree-eh.c   (revision 198522)
--- gcc/tree-eh.c   (working copy)
*** cleanup_empty_eh_merge_phis (basic_block
*** 3949,3955 
gimple_stmt_iterator ngsi, ogsi;
edge_iterator ei;
edge e;
-   bitmap rename_virts;
bitmap ophi_handled;
  
/* The destination block must not be a regular successor for any
--- 3949,3954 
*** cleanup_empty_eh_merge_phis (basic_block
*** 3972,3978 
  redirect_edge_var_map_clear (e);
  
ophi_handled = BITMAP_ALLOC (NULL);
-   rename_virts = BITMAP_ALLOC (NULL);
  
/* First, iterate through the PHIs on NEW_BB and set up the edge_var_map
   for the edges we're going to move.  */
--- 3971,3976 
*** cleanup_empty_eh_merge_phis (basic_block
*** 4025,4035 
  redirect_edge_var_map_add (e, nresult, oop, oloc);
}
}
!   /* If we didn't find the PHI, but it's a VOP, remember to rename
!it later, assuming all other tests succeed.  */
!   else if (virtual_operand_p (nresult))
!   bitmap_set_bit (rename_virts, SSA_NAME_VERSION (nresult));
!   /* If we didn't find the PHI, and it's a real variable, we know
 from the fact that OLD_BB is tree_empty_eh_handler_p that the
 variable is unchanged from input to the block and we can simply
 re-use the input to NEW_BB from the OLD_BB_OUT edge.  */
--- 4023,4029 
  redirect_edge_var_map_add (e, nresult, oop, oloc);
}
}
!   /* If we didn't find the PHI, if it's a real variable or a VOP, we know
 from the fact that OLD_BB is tree_empty_eh_handler_p that the
 variable is unchanged from input to the block and we can simply
 re-use the input to NEW_BB from the OLD_BB_OUT edge.  */
*** cleanup_empty_eh_merge_phis (basic_block
*** 4052,4075 
goto fail;
  }
  
-   /* At this point we know that the merge will succeed.  Remove the PHI
-  nodes for the virtuals that we want to rename.  */
-   if (!bitmap_empty_p (rename_virts))
- {
-   for (ngsi = gsi_start_phis (new_bb); !gsi_end_p (ngsi); )
-   {
- gimple nphi = gsi_stmt (ngsi);
- tree nresult = gimple_phi_result (nphi);
- if (bitmap_bit_p (rename_virts, SSA_NAME_VERSION (nresult)))
-   {
- mark_virtual_phi_result_for_renaming (nphi);
- remove_phi_node (&ngsi, true);
-   }
- else
-   gsi_next (&ngsi);
-   }
- }
- 
/* Finally, move the edges and update the PHIs.  */
for (ei = ei_start (old_bb->preds); (e = ei_safe_edge (ei)); )
  if (e->flags & EDGE_EH)
--- 4046,4051 
*** cleanup_empty_eh_merge_phis (basic_block
*** 4097,4110 
ei_next (&ei);
  
BITMAP_FREE (ophi_handled);
-   BITMAP_FREE (rename_virts);
return true;
  
   fail:
FOR_EACH_EDGE (e, ei, old_bb->preds)
  redirect_edge_var_map_clear (e);
BITMAP_FREE (ophi_handled);
-   BITMAP_FREE (rename_virts);
return false;
  }
  
--- 4073,4084 
*** struct gimple_opt_pass pass_cleanup_eh =
*** 4467,4473 
 0, /* properties_provided */
 0, /* properties_destroyed */
 0, /* todo_flags_start */
!0  /* todo_flags_finish */
 }
  };
  
--- 4441,4447 
 0, /* properties_provided */
 0, /* properties_destroyed */
 0, /* todo_flags_start */
!TODO_verify_ssa/* todo_flags_finish */
 }
  };
  


[PATCH] Fix PR57140

2013-05-02 Thread Richard Biener

The following fixes PR57140 - we did not properly consider loops
marked for removal when copying them during inlining.  The following
patch simply keeps them that way and makes sure to schedule a fixup.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2013-05-02  Richard Biener  

PR middle-end/57140
* tree-inline.c (copy_loops): Properly handle removed loops.
(copy_cfg_body): Mark destination loops for fixup if source
loops needed fixup.

* g++.dg/torture/pr57140.C: New testcase.

Index: gcc/tree-inline.c
===
*** gcc/tree-inline.c   (revision 198441)
--- gcc/tree-inline.c   (working copy)
*** copy_loops (bitmap blocks_to_copy,
*** 2211,2218 
  
  /* Assign the new loop its header and latch and associate
 those with the new loop.  */
! dest_loop->header = (basic_block)src_loop->header->aux;
! dest_loop->header->loop_father = dest_loop;
  if (src_loop->latch != NULL)
{
  dest_loop->latch = (basic_block)src_loop->latch->aux;
--- 2211,2221 
  
  /* Assign the new loop its header and latch and associate
 those with the new loop.  */
! if (src_loop->header != NULL)
!   {
! dest_loop->header = (basic_block)src_loop->header->aux;
! dest_loop->header->loop_father = dest_loop;
!   }
  if (src_loop->latch != NULL)
{
  dest_loop->latch = (basic_block)src_loop->latch->aux;
*** copy_cfg_body (copy_body_data * id, gcov
*** 2341,2346 
--- 2344,2354 
loops_state_set (LOOPS_NEED_FIXUP);
  }
  
+   /* If the loop tree in the source function needed fixup, mark the
+  destination loop tree for fixup, too.  */
+   if (loops_for_fn (src_cfun)->state & LOOPS_NEED_FIXUP)
+ loops_state_set (LOOPS_NEED_FIXUP);
+ 
if (gimple_in_ssa_p (cfun))
  FOR_ALL_BB_FN (bb, cfun_to_copy)
if (!blocks_to_copy
Index: gcc/testsuite/g++.dg/torture/pr57140.C
===
--- gcc/testsuite/g++.dg/torture/pr57140.C  (revision 0)
+++ gcc/testsuite/g++.dg/torture/pr57140.C  (working copy)
@@ -0,0 +1,186 @@
+// { dg-do compile }
+
+namespace std {
+typedef long unsigned int size_t;
+template class allocator;
+template struct char_traits;
+template,  
  typename _Alloc = allocator<_CharT> > class basic_string;
+typedef basic_string string;
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+}
+namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
+}
+namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
+template class new_allocator {
+};
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+template class allocator: public 
__gnu_cxx::new_allocator<_Tp> {
+public:
+   template struct rebind {
+   typedef allocator<_Tp1> other;
+   };
+};
+}
+namespace std {
+}
+namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+template class 
basic_string {
+   struct _Alloc_hider : _Alloc   {
+   _Alloc_hider(_CharT* __dat, const _Alloc& __a)  : _Alloc(__a), 
_M_p(__dat) {
+   }
+   _CharT* _M_p;
+   };
+   mutable _Alloc_hider _M_dataplus;
+public:
+   basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
+};
+template inline 
bool operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, 
const _CharT* __rhs) {
+}
+}
+extern "C" {
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+namespace __detail   {
+   struct _List_node_base {
+   _List_node_base* _M_next;
+   };
+}
+template struct _List_node : public 
__detail::_List_node_base {
+};
+template struct _List_iterator {
+   typedef _List_iterator<_Tp> _Self;
+   typedef _Tp& reference;
+   reference   operator*() const   {
+   }
+   bool   operator!=(const _Self& __x) const   {
+   }
+};
+template class _List_base {
+protected:
+   typedef typename _Alloc::template rebind<_List_node<_Tp> >::other   
  _Node_alloc_type;
+   struct _List_impl   : public _Node_alloc_type   {
+   __detail::_List_node_base _M_node;
+   _List_impl()  : _Node_alloc_type(), _M_node()  {
+   }
+   _List_impl(const _Node_alloc_type& __a)  : _Node_alloc_type(__a), 
_M_node()  {
+   }
+   };
+   _List_impl _M_impl;
+   ~_List_base()   {
+   }
+   void   _M_clear();
+};
+template > class 
list : protected _List_base<_Tp, _Alloc> {
+   type

[Patch, Fortran] PR57142 - Fix simplify for SHAPE and SIZE for large arrays

2013-05-02 Thread Tobias Burnus
Instead of using the return "size" value directly, the code converted it 
first to an int and then back into a GMP number. This patch now directly 
uses the mpz value.


Additionally, I added range checks - to print the proper function name 
(SHAPE instead of SIZE), I split the worker code from the checking code.


Build and regtested on x86-64-gnu-linux.
OK for the trunk and the 4.7/4.8 branches?

Tobias
2013-05-02  Tobias Burnus  

	PR fortran/57142
	* simplify.c (gfc_simplify_size): Renamed from
	simplify_size; fix kind=8 handling.
	(gfc_simplify_size): New function.
	(gfc_simplify_shape): Add range check.
	* resolve.c (resolve_function): Fix handling
	for ISYM_SIZE.
	
2013-05-02  Tobias Burnus  

	PR fortran/57142
	* gfortran.dg/size_kind_2.f90: New.
	* gfortran.dg/size_kind_3.f90: New.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 6e1f56f..2860e41 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -2856,16 +2856,17 @@ resolve_function (gfc_expr *expr)
   /* Array intrinsics must also have the last upper bound of an
 	 assumed size array argument.  UBOUND and SIZE have to be
 	 excluded from the check if the second argument is anything
 	 than a constant.  */
 
   for (arg = expr->value.function.actual; arg; arg = arg->next)
 	{
 	  if ((GENERIC_ID == GFC_ISYM_UBOUND || GENERIC_ID == GFC_ISYM_SIZE)
+	  && arg == expr->value.function.actual
 	  && arg->next != NULL && arg->next->expr)
 	{
 	  if (arg->next->expr->expr_type != EXPR_CONSTANT)
 		break;
 
 	  if (arg->next->name && strncmp (arg->next->name, "kind", 4) == 0)
 		break;
 
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 02505db..815043b 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3.  If not see
 
 gfc_expr gfc_bad_expr;
 
+static gfc_expr *simplify_size (gfc_expr *, gfc_expr *, int);
+
 
 /* Note that 'simplification' is not just transforming expressions.
For functions that are not simplified at compile time, range
@@ -3248,7 +3250,7 @@ simplify_bound_dim (gfc_expr *array, gfc_expr *kind, int d, int upper,
 	  gfc_expr* dim = result;
 	  mpz_set_si (dim->value.integer, d);
 
-	  result = gfc_simplify_size (array, dim, kind);
+	  result = simplify_size (array, dim, k);
 	  gfc_free_expr (dim);
 	  if (!result)
 	goto returnNull;
@@ -5538,15 +5540,12 @@ gfc_simplify_shape (gfc_expr *source, gfc_expr *kind)
   e = gfc_get_constant_expr (BT_INTEGER, k, &source->where);
 
   if (t)
-	{
-	  mpz_set (e->value.integer, shape[n]);
-	  mpz_clear (shape[n]);
-	}
+	mpz_set (e->value.integer, shape[n]);
   else
 	{
 	  mpz_set_ui (e->value.integer, n + 1);
 
-	  f = gfc_simplify_size (source, e, NULL);
+	  f = simplify_size (source, e, k);
 	  gfc_free_expr (e);
 	  if (f == NULL)
 	{
@@ -5557,23 +5556,30 @@ gfc_simplify_shape (gfc_expr *source, gfc_expr *kind)
 	e = f;
 	}
 
+  if (e == &gfc_bad_expr || range_check (e, "SHAPE") == &gfc_bad_expr)
+	{
+	  gfc_free_expr (result);
+	  if (t)
+	gfc_clear_shape (shape, source->rank);
+	  return &gfc_bad_expr;
+	}
+
   gfc_constructor_append_expr (&result->value.constructor, e, NULL);
 }
 
+  if (t)
+gfc_clear_shape (shape, source->rank);
+
   return result;
 }
 
 
-gfc_expr *
-gfc_simplify_size (gfc_expr *array, gfc_expr *dim, gfc_expr *kind)
+static gfc_expr *
+simplify_size (gfc_expr *array, gfc_expr *dim, int k)
 {
   mpz_t size;
   gfc_expr *return_value;
   int d;
-  int k = get_kind (BT_INTEGER, kind, "SIZE", gfc_default_integer_kind);
-
-  if (k == -1)
-return &gfc_bad_expr;
 
   /* For unary operations, the size of the result is given by the size
  of the operand.  For binary ones, it's the size of the first operand
@@ -5603,7 +5609,7 @@ gfc_simplify_size (gfc_expr *array, gfc_expr *dim, gfc_expr *kind)
 	  replacement = array->value.op.op1;
 	else
 	  {
-		simplified = gfc_simplify_size (array->value.op.op1, dim, kind);
+		simplified = simplify_size (array->value.op.op1, dim, k);
 		if (simplified)
 		  return simplified;
 
@@ -5613,18 +5619,20 @@ gfc_simplify_size (gfc_expr *array, gfc_expr *dim, gfc_expr *kind)
 	}
 
   /* Try to reduce it directly if possible.  */
-  simplified = gfc_simplify_size (replacement, dim, kind);
+  simplified = simplify_size (replacement, dim, k);
 
   /* Otherwise, we build a new SIZE call.  This is hopefully at least
 	 simpler than the original one.  */
   if (!simplified)
-	simplified = gfc_build_intrinsic_call (gfc_current_ns,
-	   GFC_ISYM_SIZE, "size",
-	   array->where, 3,
-	   gfc_copy_expr (replacement),
-	   gfc_copy_expr (dim),
-	   gfc_copy_expr (kind));
-
+	{
+	  gfc_expr *kind = gfc_get_int_expr (gfc_default_integer_kind, NULL, k);
+	  simplified = gfc_build_intrinsic_call (gfc_current_ns,
+		 GFC_ISYM_SIZE, "size",
+		 array->where, 3,
+		 gfc_copy_expr (replacemen

Re: FW: Fortran Compiler Hangs

2013-05-02 Thread H.J. Lu
On Wed, May 1, 2013 at 4:28 PM, Iyer, Balaji V  wrote:
> Hello Everyone,
> Sorry for the repost, but when I downloaded  the trunk, then 
> configured with just the prefix option in the build directory and tried to 
> compile it (both make and make -j8), the Fortran compiler seem to hang. I am 
> not using the Fortran compiler, but the build script seem to hang at this 
> spot:
>
> checking whether -lc should be explicitly linked in... no
> checking dynamic linker characteristics... GNU/Linux ld.so
> checking how to hardcode library paths into programs... immediate
> checking whether stripping libraries is possible... yes
> checking if libtool supports shared libraries... yes
> checking whether to build shared libraries... yes
> checking whether to build static libraries... yes
> checking whether to enable maintainer-specific portions of Makefiles... no
> checking for x86_64-unknown-linux-gnu-gfortran... 
> /export/users/gcc-work/b-gcc.git/./gcc/gfortran 
> -B/export/users/gcc-work/b-gcc.git/./gcc/ 
> -B/export/users/gcc-work/install-gcc.git/x86_64-unknown-linux-gnu/bin/ 
> -B/export/users/gcc-work/install-gcc.git/x86_64-unknown-linux-gnu/lib/ 
> -isystem 
> /export/users/gcc-work/install-gcc.git/x86_64-unknown-linux-gnu/include 
> -isystem 
> /export/users/gcc-work/install-gcc.git/x86_64-unknown-linux-gnu/sys-include
> checking whether we are using the GNU Fortran compiler...
>
>
> I have tried it on SuSE and uBuntu and the result seem to be the same.
>
> I tried a small "Hello World" program with f951 and that seem to hang too. My 
> experience with Fortran and gfortran is very limited (almost none), so I am 
> sorry I can't provide more information.
>
>> Here is the test program:
>>
>>PRINT *, 'Hello, world!'
>>END
>
> Then I tried to debug it and here is the backtrace:
>
>> (gdb) bt
>> #0  0x00ece7f1 in __gmpn_mul_1 ()
>> #1  0x00ed540b in __gmpn_mul_basecase ()
>> #2  0x00ed3c2f in __gmpn_kara_mul_n ()
>> #3  0x00ed40df in __gmpn_kara_mul_n ()
>> #4  0x00ed4bd5 in __gmpn_toom3_mul_n ()
>> #5  0x00ed52ac in __gmpn_mul_n ()
>> #6  0x00ed011f in __gmpn_mul ()
>> #7  0x00edd4e4 in __gmpn_toom22_mul ()
>> #8  0x00eded73 in __gmpn_toom32_mul ()
>> #9  0x00ed0080 in __gmpn_mul ()
>> #10 0x00ec9cd3 in __gmpz_mul ()
>> #11 0x00ea2fb1 in S ()
>> #12 0x00ea2f95 in S ()
>> #13 0x00ea2f6b in S ()
>> #14 0x00ea2f95 in S ()
>> #15 0x00ea2f6b in S ()
>> #16 0x00ea2f6b in S ()
>> #17 0x00ea2f95 in S ()
>> #18 0x00ea2f6b in S ()
>> #19 0x00ea2f6b in S ()
>> #20 0x00ea326b in mpfr_const_log2_internal ()
>> #21 0x00eb98af in mpfr_cache ()
>> #22 0x00ea36eb in mpfr_log ()
>> #23 0x00eb3165 in mpfr_log10 ()
>> #24 0x0051d2af in gfc_arith_init_1() ()
>> #25 0x00576463 in gfc_init_1() ()
>> #26 0x005c5bb3 in gfc_init() ()
>> #27 0x0097d8b7 in toplev_main(int, char**) ()
>> #28 0x77644bc6 in __libc_start_main () from /lib64/libc.so.6
>> #29 0x0051bb41 in _start () at ../sysdeps/x86_64/elf/start.S:113
>
> Any help is greatly appreciated!
>
> Sincerely,
>
> Balaji V. Iyer.
>
>
> P.S. I downloaded GMP, MPFR and MPC using ./contrib/download_prerequisites.

You may run into

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


--
H.J.


Re: [Patch, Fortran] PR57142 - Fix simplify for SHAPE and SIZE for large arrays

2013-05-02 Thread Steve Kargl
On Thu, May 02, 2013 at 05:46:55PM +0200, Tobias Burnus wrote:
> Instead of using the return "size" value directly, the code converted it 
> first to an int and then back into a GMP number. This patch now directly 
> uses the mpz value.
> 
> Additionally, I added range checks - to print the proper function name 
> (SHAPE instead of SIZE), I split the worker code from the checking code.
> 
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk and the 4.7/4.8 branches?
> 

OK.

-- 
steve


[PATCH] Fix up make_compound_operation (PR rtl-optimization/57130)

2013-05-02 Thread Jakub Jelinek
Hi!

As described in the PR, in some cases it is unsafe for
make_compound_operation, if called with in_code == COMPARE,
to pass through that value to make_compound_operation on
the SUBREG_REG of a SUBREG.

My understanding is that in_code == COMPARE (as opposed to
in_code == SET) is mostly harmless, just tells make_extraction
to no longer special case zero extraction at position 0, but there is one
exception - AND with constant power of two CONST_INT.
If we have
make_compound_operation ( (subreg:SI (and:DI (reg:DI) (const_int 0x8)) 
0), COMPARE)
then
make_compound_operation ( (and:DI (reg:DI) (const_int 0x8)), COMPARE)
returns extraction of the 35th bit, and subreg of that is again either zero
or one, but the original subreg is always 0.

Fixed by passing through SET instead of in_code to the recursive invocation,
if
1) the subreg isn't lowpart
2) nested SUBREGs (should be usually simplified, but just in case it hasn't 
been yet)
3) if subreg's operand is AND with power of two CONST_INT above the bitsize
   of the outer mode

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8?

2013-05-02  Jakub Jelinek  

PR rtl-optimization/57130
* combine.c (make_compound_operation): For SUBREG, pass
SET instead of COMPARE as in_code to the recursive call
if needed.

* gcc.c-torture/execute/pr57130.c: New test.

--- gcc/combine.c.jj2013-04-11 09:09:39.0 +0200
+++ gcc/combine.c   2013-05-02 12:46:07.540196281 +0200
@@ -7697,8 +7697,24 @@ make_compound_operation (rtx x, enum rtx
 what it originally did, do this SUBREG as a force_to_mode.  */
   {
rtx inner = SUBREG_REG (x), simplified;
-   
-   tem = make_compound_operation (inner, in_code);
+   enum rtx_code subreg_code = in_code;
+
+   /* If in_code is COMPARE, it isn't always safe to pass it through
+  to the recursive make_compound_operation call.  */
+   if (subreg_code == COMPARE
+   && (!subreg_lowpart_p (x)
+   || GET_CODE (inner) == SUBREG
+   /* (subreg:SI (and:DI (reg:DI) (const_int 0x8)) 0)
+  is (const_int 0), rather than
+  (subreg:SI (lshiftrt:DI (reg:DI) (const_int 35)) 0).  */
+   || (GET_CODE (inner) == AND
+   && CONST_INT_P (XEXP (inner, 1))
+   && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (inner))
+   && exact_log2 (UINTVAL (XEXP (inner, 1)))
+  >= GET_MODE_BITSIZE (mode
+ subreg_code = SET;
+
+   tem = make_compound_operation (inner, subreg_code);
 
simplified
  = simplify_subreg (mode, tem, GET_MODE (inner), SUBREG_BYTE (x));
--- gcc/testsuite/gcc.c-torture/execute/pr57130.c.jj2013-05-02 
10:52:00.389263977 +0200
+++ gcc/testsuite/gcc.c-torture/execute/pr57130.c   2013-05-02 
10:51:45.0 +0200
@@ -0,0 +1,21 @@
+/* PR rtl-optimization/57130 */
+
+struct S { int a, b, c, d; } s[2] = { { 6, 8, -8, -5 }, { 0, 2, -1, 2 } };
+
+__attribute__((noinline, noclone)) void
+foo (struct S r)
+{
+  static int cnt;
+  if (__builtin_memcmp (&r, &s[cnt++], sizeof r) != 0)
+__builtin_abort ();
+}
+
+int
+main ()
+{
+  struct S r = { 6, 8, -8, -5 };
+  foo (r);
+  r = (struct S) { 0, 2, -1, 2 };
+  foo (r);
+  return 0;
+}

Jakub


[PATCH] Improve simplify_subreg

2013-05-02 Thread Jakub Jelinek
Hi!

When working on PR57130, I've wondered why we don't simplify it much earlier
and end up with creating such weirdness.

The following patch fixes that, by using nonzero_bits to see if all the low
bits must be zero and in that case just return zero.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2013-05-02  Jakub Jelinek  

* simplify-rtx.c (simplify_truncation): If nonzero_bits
on op shows all bits zero in mode, return zero.

--- gcc/simplify-rtx.c.jj   2013-04-03 15:46:45.0 +0200
+++ gcc/simplify-rtx.c  2013-05-02 11:16:18.202043607 +0200
@@ -774,6 +774,11 @@ simplify_truncation (enum machine_mode m
 return simplify_gen_unary (TRUNCATE, mode, XEXP (op, 0),
   GET_MODE (XEXP (op, 0)));
 
+  /* If op is known to have all lower bits zero, the result is zero.  */
+  if (HWI_COMPUTABLE_MODE_P (op_mode)
+  && (nonzero_bits (op, op_mode) & GET_MODE_MASK (mode)) == 0)
+return CONST0_RTX (mode);
+
   return NULL_RTX;
 }
 

Jakub


Re: patch to fix constant math - builtins.c - the first of the tree level patches for wide-int

2013-05-02 Thread Kenneth Zadeck

The only changes here were account for the changes to the wide-int api.

On 04/16/2013 04:24 PM, Kenneth Zadeck wrote:
Richard, this is the first of the tree level patches so that you can 
see how the wide-int changes will effect the tree level.   This patch 
converts builtins.c so that it does not in any way assume that 
tree-cst holds two HWIs.   The patch divides all math into two 
categories:   Things that are always so small that we can easily 
assume that the math can be done using a single HWI and everything 
else.   The things that it assumes can easily be done with a HWI are 
guarded with assertions.   The everything else is done with wide-int.  
Everything else in this patch is additional abi to support this.


The idea is that each pass will be converted, 1 pass per patch in this 
way.Once everything does not depend on the internals of tree-cst 
as they do now, then tree-cst will be converted to have an array 
inside of it rather than just two hwis.


Kenny


diff --git a/gcc/builtins.c b/gcc/builtins.c
index 0c587d1..181784b 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -339,8 +339,8 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
   if (TREE_CODE (addr) == BIT_AND_EXPR
 	  && TREE_CODE (TREE_OPERAND (addr, 1)) == INTEGER_CST)
 	{
-	  align = (TREE_INT_CST_LOW (TREE_OPERAND (addr, 1))
-		& -TREE_INT_CST_LOW (TREE_OPERAND (addr, 1)));
+	  align = (tree_to_hwi (TREE_OPERAND (addr, 1))
+		   & -tree_to_hwi (TREE_OPERAND (addr, 1)));
 	  align *= BITS_PER_UNIT;
 	  addr = TREE_OPERAND (addr, 0);
 	}
@@ -357,7 +357,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
 	{
 	  unsigned HOST_WIDE_INT step = 1;
 	  if (TMR_STEP (exp))
-		step = TREE_INT_CST_LOW (TMR_STEP (exp));
+		step = tree_to_hwi (TMR_STEP (exp));
 	  align = MIN (align, (step & -step) * BITS_PER_UNIT);
 	}
 	  if (TMR_INDEX2 (exp))
@@ -379,7 +379,8 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
 	  bitpos += ptr_bitpos;
 	  if (TREE_CODE (exp) == MEM_REF
 	  || TREE_CODE (exp) == TARGET_MEM_REF)
-	bitpos += mem_ref_offset (exp).low * BITS_PER_UNIT;
+	bitpos += wide_int::from_tree (TREE_OPERAND (exp, 1))
+	  .to_shwi () * BITS_PER_UNIT;
 	}
 }
   else if (TREE_CODE (exp) == STRING_CST)
@@ -408,23 +409,23 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
 	}
   else
 	next_offset = NULL;
-  if (host_integerp (offset, 1))
+  if (tree_fits_uhwi_p (offset))
 	{
 	  /* Any overflow in calculating offset_bits won't change
 	 the alignment.  */
 	  unsigned offset_bits
-	= ((unsigned) tree_low_cst (offset, 1) * BITS_PER_UNIT);
+	= ((unsigned) tree_to_hwi (offset) * BITS_PER_UNIT);
 
 	  if (offset_bits)
 	inner = MIN (inner, (offset_bits & -offset_bits));
 	}
   else if (TREE_CODE (offset) == MULT_EXPR
-	   && host_integerp (TREE_OPERAND (offset, 1), 1))
+	   && tree_fits_uhwi_p (TREE_OPERAND (offset, 1)))
 	{
 	  /* Any overflow in calculating offset_factor won't change
 	 the alignment.  */
 	  unsigned offset_factor
-	= ((unsigned) tree_low_cst (TREE_OPERAND (offset, 1), 1)
+	= ((unsigned) tree_to_hwi (TREE_OPERAND (offset, 1))
 	   * BITS_PER_UNIT);
 
 	  if (offset_factor)
@@ -515,7 +516,7 @@ get_pointer_alignment_1 (tree exp, unsigned int *alignp,
   else if (TREE_CODE (exp) == INTEGER_CST)
 {
   *alignp = BIGGEST_ALIGNMENT;
-  *bitposp = ((TREE_INT_CST_LOW (exp) * BITS_PER_UNIT)
+  *bitposp = ((tree_to_hwi (exp) * BITS_PER_UNIT)
 		  & (BIGGEST_ALIGNMENT - 1));
   return true;
 }
@@ -624,10 +625,10 @@ c_strlen (tree src, int only_value)
  a null character if we can represent it as a single HOST_WIDE_INT.  */
   if (offset_node == 0)
 offset = 0;
-  else if (! host_integerp (offset_node, 0))
+  else if (!tree_fits_shwi_p (offset_node))
 offset = -1;
   else
-offset = tree_low_cst (offset_node, 0);
+offset = tree_to_hwi (offset_node);
 
   /* If the offset is known to be out of bounds, warn, and call strlen at
  runtime.  */
@@ -665,11 +666,11 @@ c_getstr (tree src)
 
   if (offset_node == 0)
 return TREE_STRING_POINTER (src);
-  else if (!host_integerp (offset_node, 1)
+  else if (!tree_fits_uhwi_p (offset_node)
 	   || compare_tree_int (offset_node, TREE_STRING_LENGTH (src) - 1) > 0)
 return 0;
 
-  return TREE_STRING_POINTER (src) + tree_low_cst (offset_node, 1);
+  return TREE_STRING_POINTER (src) + tree_to_uhwi (offset_node);
 }
 
 /* Return a constant integer corresponding to target reading
@@ -723,7 +724,9 @@ target_char_cast (tree cst, char *p)
   || CHAR_TYPE_SIZE > HOST_BITS_PER_WIDE_INT)
 return 1;
 
-  val = TREE_INT_CST_LOW (cst);
+  /* Do not care if it fits or not right here.  */
+  val = tree_to_hwi (cst);
+
   if (CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT)
 val &= (((unsigned HOST_WIDE_INT) 1) << CHAR_TYPE_SIZE) - 1;
 
@@ -3168,7 +3171,7 @@ expand_builtin_mempcpy_args (tree dest, tree src, tree len,
 

Re: [PATCH] Improve simplify_subreg

2013-05-02 Thread Richard Sandiford
Jakub Jelinek  writes:
> Hi!
>
> When working on PR57130, I've wondered why we don't simplify it much earlier
> and end up with creating such weirdness.
>
> The following patch fixes that, by using nonzero_bits to see if all the low
> bits must be zero and in that case just return zero.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2013-05-02  Jakub Jelinek  
>
>   * simplify-rtx.c (simplify_truncation): If nonzero_bits
>   on op shows all bits zero in mode, return zero.

I'm probably wrong, but just in case: it looks like this might
fall foul of:

/* Try to simplify a MODE truncation of OP, which has OP_MODE.
   Only handle cases where the truncated value is inherently an rvalue.

If op is a register, it might be being used as an lvalue instead of an rvalue.
We don't want to simplify (subreg (reg ..)) to (const_int 0) in that case.

It should be OK to put this under the TRUNCATE case in
simplify_unary_operation_1, but I don't know if that'd be good
enough for your testcase.

Thanks,
Richard


patches backported to gcc-4_8-branch

2013-05-02 Thread Vladimir Makarov

  The following patches were back-ported to gcc4.8 branch.

  Successfully bootstrapped and tested on x86 and x86-64.

  Committed as revisions 198553-198557.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-29  Vladimir Makarov  

PR target/57097
* lra-constraints.c (process_alt_operands): Discourage a bit more
using memory for pseudos.  Print cost dump for alternatives.
Modify cost values for conflicts with early clobbers.
(curr_insn_transform): Spill pseudos reassigned to NO_REGS.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-24  Vladimir Makarov  

PR rtl-optimizations/57046
* lra-constraints (split_reg): Set up lra_risky_transformations_p
for multi-reg splits.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-22  Vladimir Makarov  

PR target/57018
* lra-eliminations.c (mark_not_eliminable): Prevent elimination of
a set sp if no stack realignment.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-18  Vladimir Makarov  

PR rtl-optimization/56992
* lra-coalesce.c (coalescable_pseudo_p): Remove 2nd parameter and
related code.
(lra_coalesce): Remove split_origin_bitmap and related code.
* lra.c (lra): Coalesce after undoing inheritance. Recreate live
ranges if necessary.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-19  Vladimir Makarov  

PR rtl-optimization/56847
* lra-constraints.c (process_alt_operands): Discourage alternative
with non-matche doffsettable memory constraint fro memory with
known offset.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-29  Vladimir Makarov  

PR target/57097
* gcc.target/i386/pr57097.c: New test.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-24  Vladimir Makarov  

PR rtl-optimizations/57046
* gcc.target/i386/pr57046.c: New test.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-22  Vladimir Makarov  

PR target/57018
* gcc.target/i386/pr57018.c: New test.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-18  Jakub Jelinek  

PR rtl-optimization/56992
* g++.dg/opt/pr56999.C: New test.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-04-19  Vladimir Makarov  

PR rtl-optimization/56847
* gcc.dg/pr56847.c: New test.




[AArch64] Support scalar form of FABD

2013-05-02 Thread Vidya Praveen

Hello,

This attached patch adds support to the scalar form of FABD
instruction along with the compile & execute tests for the same.

Regression tested on aarch64-none-elf with no issues.

OK?

Regards
VP

---

gcc/ChangeLog

2013-05-02  Vidya Praveen  

* config/aarch64/aarch64-simd.md (*fabd_scalar3): Support
  scalar form of FABD instruction.

gcc/testsuite/ChangeLog

2013-05-02  Vidya Praveen 

* gcc.target/aarch64/fabd.c: New file.diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index 5862d26..e5fc032 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -556,6 +556,17 @@
(set_attr "simd_mode" "")]
 )
 
+(define_insn "*fabd_scalar3"
+  [(set (match_operand:GPF 0 "register_operand" "=w")
+(abs:GPF (minus:GPF
+ (match_operand:GPF 1 "register_operand" "w")
+ (match_operand:GPF 2 "register_operand" "w"]
+  "TARGET_SIMD"
+  "fabd\t%0, %1, %2"
+  [(set_attr "simd_type" "simd_fabd")
+   (set_attr "mode" "")]
+)
+
 (define_insn "and3"
   [(set (match_operand:VDQ 0 "register_operand" "=w")
 (and:VDQ (match_operand:VDQ 1 "register_operand" "w")
diff --git a/gcc/testsuite/gcc.target/aarch64/fabd.c b/gcc/testsuite/gcc.target/aarch64/fabd.c
new file mode 100644
index 000..7206d5e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/fabd.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-O1 -fno-inline --save-temps" } */
+
+extern double fabs (double);
+extern float fabsf (float);
+extern void abort ();
+extern void exit (int);
+
+void
+fabd_d (double x, double y, double d)
+{
+  if ((fabs (x - y) - d) > 0.1)
+abort ();
+}
+
+/* { dg-final { scan-assembler "fabd\td\[0-9\]+" } } */
+
+void
+fabd_f (float x, float y, float d)
+{
+  if ((fabsf (x - y) - d) > 0.1)
+abort ();
+}
+
+/* { dg-final { scan-assembler "fabd\ts\[0-9\]+" } } */
+
+int
+main ()
+{
+  fabd_d (10.0, 5.0, 5.0);
+  fabd_d (5.0, 10.0, 5.0);
+  fabd_f (10.0, 5.0, 5.0);
+  fabd_f (5.0, 10.0, 5.0);
+
+  return 0;
+}
+
+/* { dg-final { cleanup-saved-temps } } */

[google][4.7] Move the building of gcov constructor function after initialization of gcov_info_var

2013-05-02 Thread Carrot Wei
This patch fixes google bug 8397853 and targets google 4.7 branch.

In LIPO mode, when coverage_obj_init is called, cgraph_state is
CGRAPH_STATE_FINISHED. The variable gcov_info_var is created but not
initialized. When cgraph_build_static_cdtor is called, the new function and
variables are expanded immediately since cgraph_state is CGRAPH_STATE_FINISHED.
It causes gcov_info_var into .bss section. But later in function
coverage_obj_finish we initialize gcov_info_var with non zero contents, so it
should not be put into .bss section.

In FDO mode we don't have this problem because when coverage_obj_init is called,
cgraph_state is CGRAPH_STATE_IPA_SSA. When cgraph_build_static_cdtor is called,
the new function is not immediately expanded. The variable will have been
properly initialized when it is expanded.

It can be fixed by moving the construction of gcov constructor after
initialization of gcov_info_var.

Tested with following testing:
x86-64 bootstrap.
x86-64 regression test.
power64 regression test on qemu.

The only regression for power64 is
FAIL: gcc.dg/torture/tls/tls-test.c  -O2 -flto -fno-use-linker-plugin
-flto-partition=none  execution test
It is a flaky test case in our testing environment since all other executions
with different compiler options failed. All testing of tls-test.c pass native
power64 testing.

thanks
Carrot

2013-05-02  Guozhi Wei  

* coverage.c (gcov_info_type): New global variable.
(coverage_obj_init): Move the construction of gcov constructor to
(build_init_ctor): here.
(coverage_obj_finish): Call build_init_ctor after initialization of
gcov_info_var.


Index: coverage.c
===
--- coverage.c (revision 198425)
+++ coverage.c (working copy)
@@ -123,6 +123,7 @@

 /* Coverage info VAR_DECL and function info type nodes.  */
 static GTY(()) tree gcov_info_var;
+static GTY(()) tree gcov_info_type;
 static GTY(()) tree gcov_fn_info_type;
 static GTY(()) tree gcov_fn_info_ptr_type;

@@ -2478,14 +2479,12 @@
   return build_constructor (info_type, v1);
 }

-/* Create the gcov_info types and object.  Generate the constructor
-   function to call __gcov_init.  Does not generate the initializer
+/* Create the gcov_info types and object. Does not generate the initializer
for the object.  Returns TRUE if coverage data is being emitted.  */

 static bool
 coverage_obj_init (void)
 {
-  tree gcov_info_type, ctor, stmt, init_fn;
   unsigned n_counters = 0;
   unsigned ix;
   struct coverage_data *fn;
@@ -2531,24 +2530,6 @@
   ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 0);
   DECL_NAME (gcov_info_var) = get_identifier (name_buf);

-  /* Build a decl for __gcov_init.  */
-  init_fn = build_pointer_type (gcov_info_type);
-  init_fn = build_function_type_list (void_type_node, init_fn, NULL);
-  init_fn = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
- get_identifier ("__gcov_init"), init_fn);
-  TREE_PUBLIC (init_fn) = 1;
-  DECL_EXTERNAL (init_fn) = 1;
-  DECL_ASSEMBLER_NAME (init_fn);
-
-  /* Generate a call to __gcov_init(&gcov_info).  */
-  ctor = NULL;
-  stmt = build_fold_addr_expr (gcov_info_var);
-  stmt = build_call_expr (init_fn, 1, stmt);
-  append_to_statement_list (stmt, &ctor);
-
-  /* Generate a constructor to run it.  */
-  cgraph_build_static_cdtor ('I', ctor, DEFAULT_INIT_PRIORITY);
-
   return true;
 }

@@ -2570,6 +2551,32 @@
   return ctor;
 }

+/* Generate the constructor function to call __gcov_init.  */
+
+static void
+build_init_ctor ()
+{
+  tree ctor, stmt, init_fn;
+
+  /* Build a decl for __gcov_init.  */
+  init_fn = build_pointer_type (gcov_info_type);
+  init_fn = build_function_type_list (void_type_node, init_fn, NULL);
+  init_fn = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
+ get_identifier ("__gcov_init"), init_fn);
+  TREE_PUBLIC (init_fn) = 1;
+  DECL_EXTERNAL (init_fn) = 1;
+  DECL_ASSEMBLER_NAME (init_fn);
+
+  /* Generate a call to __gcov_init(&gcov_info).  */
+  ctor = NULL;
+  stmt = build_fold_addr_expr (gcov_info_var);
+  stmt = build_call_expr (init_fn, 1, stmt);
+  append_to_statement_list (stmt, &ctor);
+
+  /* Generate a constructor to run it.  */
+  cgraph_build_static_cdtor ('I', ctor, DEFAULT_INIT_PRIORITY);
+}
+
 /* Finalize the coverage data.  Generates the array of pointers to
function objects from CTOR.  Generate the gcov_info initializer.  */

@@ -2589,9 +2596,12 @@
   DECL_NAME (fn_info_ary) = get_identifier (name_buf);
   DECL_INITIAL (fn_info_ary) = build_constructor (fn_info_ary_type, ctor);
   varpool_finalize_decl (fn_info_ary);
-
+
   DECL_INITIAL (gcov_info_var)
 = build_info (TREE_TYPE (gcov_info_var), fn_info_ary);
+
+  build_init_ctor ();
+
   varpool_finalize_decl (gcov_info_var);
 }


Re: [google][4.7] Move the building of gcov constructor function after initialization of gcov_info_var

2013-05-02 Thread Xinliang David Li
I suggest submitting the refactoring part of the changes to GCC trunk first.

thanks,

David

On Thu, May 2, 2013 at 11:06 AM, Carrot Wei  wrote:
> This patch fixes google bug 8397853 and targets google 4.7 branch.
>
> In LIPO mode, when coverage_obj_init is called, cgraph_state is
> CGRAPH_STATE_FINISHED. The variable gcov_info_var is created but not
> initialized. When cgraph_build_static_cdtor is called, the new function and
> variables are expanded immediately since cgraph_state is 
> CGRAPH_STATE_FINISHED.
> It causes gcov_info_var into .bss section. But later in function
> coverage_obj_finish we initialize gcov_info_var with non zero contents, so it
> should not be put into .bss section.
>
> In FDO mode we don't have this problem because when coverage_obj_init is 
> called,
> cgraph_state is CGRAPH_STATE_IPA_SSA. When cgraph_build_static_cdtor is 
> called,
> the new function is not immediately expanded. The variable will have been
> properly initialized when it is expanded.
>
> It can be fixed by moving the construction of gcov constructor after
> initialization of gcov_info_var.
>
> Tested with following testing:
> x86-64 bootstrap.
> x86-64 regression test.
> power64 regression test on qemu.
>
> The only regression for power64 is
> FAIL: gcc.dg/torture/tls/tls-test.c  -O2 -flto -fno-use-linker-plugin
> -flto-partition=none  execution test
> It is a flaky test case in our testing environment since all other executions
> with different compiler options failed. All testing of tls-test.c pass native
> power64 testing.
>
> thanks
> Carrot
>
> 2013-05-02  Guozhi Wei  
>
> * coverage.c (gcov_info_type): New global variable.
> (coverage_obj_init): Move the construction of gcov constructor to
> (build_init_ctor): here.
> (coverage_obj_finish): Call build_init_ctor after initialization of
> gcov_info_var.
>
>
> Index: coverage.c
> ===
> --- coverage.c (revision 198425)
> +++ coverage.c (working copy)
> @@ -123,6 +123,7 @@
>
>  /* Coverage info VAR_DECL and function info type nodes.  */
>  static GTY(()) tree gcov_info_var;
> +static GTY(()) tree gcov_info_type;
>  static GTY(()) tree gcov_fn_info_type;
>  static GTY(()) tree gcov_fn_info_ptr_type;
>
> @@ -2478,14 +2479,12 @@
>return build_constructor (info_type, v1);
>  }
>
> -/* Create the gcov_info types and object.  Generate the constructor
> -   function to call __gcov_init.  Does not generate the initializer
> +/* Create the gcov_info types and object. Does not generate the initializer
> for the object.  Returns TRUE if coverage data is being emitted.  */
>
>  static bool
>  coverage_obj_init (void)
>  {
> -  tree gcov_info_type, ctor, stmt, init_fn;
>unsigned n_counters = 0;
>unsigned ix;
>struct coverage_data *fn;
> @@ -2531,24 +2530,6 @@
>ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 0);
>DECL_NAME (gcov_info_var) = get_identifier (name_buf);
>
> -  /* Build a decl for __gcov_init.  */
> -  init_fn = build_pointer_type (gcov_info_type);
> -  init_fn = build_function_type_list (void_type_node, init_fn, NULL);
> -  init_fn = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
> - get_identifier ("__gcov_init"), init_fn);
> -  TREE_PUBLIC (init_fn) = 1;
> -  DECL_EXTERNAL (init_fn) = 1;
> -  DECL_ASSEMBLER_NAME (init_fn);
> -
> -  /* Generate a call to __gcov_init(&gcov_info).  */
> -  ctor = NULL;
> -  stmt = build_fold_addr_expr (gcov_info_var);
> -  stmt = build_call_expr (init_fn, 1, stmt);
> -  append_to_statement_list (stmt, &ctor);
> -
> -  /* Generate a constructor to run it.  */
> -  cgraph_build_static_cdtor ('I', ctor, DEFAULT_INIT_PRIORITY);
> -
>return true;
>  }
>
> @@ -2570,6 +2551,32 @@
>return ctor;
>  }
>
> +/* Generate the constructor function to call __gcov_init.  */
> +
> +static void
> +build_init_ctor ()
> +{
> +  tree ctor, stmt, init_fn;
> +
> +  /* Build a decl for __gcov_init.  */
> +  init_fn = build_pointer_type (gcov_info_type);
> +  init_fn = build_function_type_list (void_type_node, init_fn, NULL);
> +  init_fn = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
> + get_identifier ("__gcov_init"), init_fn);
> +  TREE_PUBLIC (init_fn) = 1;
> +  DECL_EXTERNAL (init_fn) = 1;
> +  DECL_ASSEMBLER_NAME (init_fn);
> +
> +  /* Generate a call to __gcov_init(&gcov_info).  */
> +  ctor = NULL;
> +  stmt = build_fold_addr_expr (gcov_info_var);
> +  stmt = build_call_expr (init_fn, 1, stmt);
> +  append_to_statement_list (stmt, &ctor);
> +
> +  /* Generate a constructor to run it.  */
> +  cgraph_build_static_cdtor ('I', ctor, DEFAULT_INIT_PRIORITY);
> +}
> +
>  /* Finalize the coverage data.  Generates the array of pointers to
> function objects from CTOR.  Generate the gcov_info initializer.  */
>
> @@ -2589,9 +2596,12 @@
>DECL_NAME (fn_info_ary) = get_identifier (name_buf);
>DECL_INITIAL (fn_info_ary) = build_constructor (fn_info_ary_type, ctor);
>varpool_finalize_decl (fn_info_ary);
> -
> +
>DECL_INITIAL (gcov_info_var)

[AArch64] Fix the description of simd_fabd

2013-05-02 Thread Vidya Praveen

Hello,

This attached patch corrects the description for simd_fabd.

OK?

Regards
VP


gcc/ChangeLog

2013-05-02  Vidya Praveen  

* config/aarch64/aarch64-simd.md (simd_fabd): Correct the description.diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index 5862d26..65847ce 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -44,7 +44,7 @@
 ; simd_dup  duplicate element.
 ; simd_dupgpduplicate general purpose register.
 ; simd_ext  bitwise extract from pair.
-; simd_fabd floating absolute difference and accumulate.
+; simd_fabd floating point absolute difference.
 ; simd_fadd floating point add/sub.
 ; simd_fcmp floating point compare.
 ; simd_fcvtifloating point convert to integer.

patch to add one more criterium for choosing alternatives in LRA

2013-05-02 Thread Vladimir Makarov
The following patch fixes two GCC testsuite failures on i686 after 
submitting patch to fix PR57091.


The first alternative is always preferable then subsequent ones when all 
costs are the same.  That is how reload works. This checks needs when we 
have commutative operator in an insn.


Committed as rev. 198558.

2013-05-02  Vladimir Makarov  

* lra-constraints.c (process_alt_operands): Add checking alt
number to choose the best alternative.

Index: lra-constraints.c
===
--- lra-constraints.c   (revision 198503)
+++ lra-constraints.c   (working copy)
@@ -2197,7 +2197,9 @@ process_alt_operands (int only_alternati
 number of reload regs.  */
  && (reload_nregs < best_reload_nregs
  || (reload_nregs == best_reload_nregs
- && best_reload_sum < reload_sum))
+ && (best_reload_sum < reload_sum
+ || (best_reload_sum == reload_sum
+ && nalt < goal_alt_number
{
  for (nop = 0; nop < n_operands; nop++)
{



backporting patch for PR57091

2013-05-02 Thread Vladimir Makarov

The following was back-ported to gcc-4_8-branch.

Committed as rev. 198559.

2013-05-02  Vladimir Makarov  

Backport from mainline
2013-05-02  Vladimir Makarov 

* lra-constraints.c (process_alt_operands): Add checking alt
number to choose the best alternative.

2013-05-01  Vladimir Makarov 

PR target/57091
* lra-constraints.c (best_small_class_operands_num): Remove.
(process_alt_operands): Remove small_class_operands_num.  Take
small classes operands into losers and only if the operand is not
matched.  Modify debugging output.
(curr_insn_transform): Remove best_small_class_operands_num.
Print insn name.

2013-05-02  Vladimir Makarov  

Backport from mainline
PR target/57091
* gcc.target/i386/pr57091.c: New test.




Re: [PATCH, boehm-gc, AArch64] Add AArch64 support

2013-05-02 Thread Christophe Lyon
I have just added the ChangeLog entry (in boehm-gc/), which I forgot
to add when I committed this patch for you.
(as r198562)

Christophe.


On 11 April 2013 13:20, Yvan Roux  wrote:
> Hi Marcus,
>
> thanks for pointing this, but unfortunately I don't have the svn write
> access for the moment, thus
> if somebody can commit it for me, i would be very thankful.
>
> Cheers,
> Yvan
>
> On 11 April 2013 13:02, Marcus Shawcroft  wrote:
>> Hi Yvan,  My understanding of the 'Free for all' section of
>> http://gcc.gnu.org/svnwrite.html#policies is that since this is a
>> backport from an upstream project you do not need to seek further
>> approval to commit this change.
>>
>> Cheers
>> /Marcus
>>
>> On 2 April 2013 11:50, Yvan Roux  wrote:
>>> Ping (second try)
>>>
>>> Sorry if you received it twice, it seems that my gmail account
>>> switched in text/html mode :(
>>>
>>> Many thanks,
>>> Yvan
>>>
>>> On 2 April 2013 11:21, Yvan Roux  wrote:

 Ping


 On 17 March 2013 21:34, Yvan Roux  wrote:
>
> Hi,
>
> this is a backport from gc mainline of the basic AArch64 support (it
> covers the Linux and bare machine mode). I tested it on the Foundation
> model with enabling the objc frontend, and passing the testsuite
> manually (maybe I miss-configured it, but it seems that the boehm-gc
> testsuite is not cross-environment friendly, as the gctest script
> looks for the host gcc build tree), and everything is fine, except the
> thread_leak_test which has a different output than the x86 one:
>
> x86 thread_leak_test output
>
> Leaked composite object at 0x2ab05fe0
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
> Leaked composite object at start: 0x2ab03fa0, appr. length: 40
> Leaked composite object at 0x2ab05ec0
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
> Leaked composite object at 0x2ab05f20
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
> Leaked composite object at start: 0x2ab03f50, appr. length: 40
> Leaked composite object at start: 0x2ab03f78, appr. length: 40
> Leaked composite object at 0x2ab05ef0
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
> Leaked composite object at start: 0x2ab03fa0, appr. length: 40
> Leaked composite object at 0x2ab05e00
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
> Leaked composite object at start: 0x2ab03f78, appr. length: 40
>
> AArch64 thread_leak_test output:
>
> Leaked composite object at 0x7f91e14ef0
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
> Leaked composite object at 0x7f91e14fe0
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
> Leaked composite object at 0x7f91e14e00
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
> Leaked composite object at 0x7f91e14e30
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
> Leaked composite object at 0x7f91e14fe0
>
> (/work/sources/gcc-fsf/bgc/boehm-gc/testsuite/boehm-gc.c/thread_leak_test.c:21,
> sz=4, NORMAL)
>
>
> Regards,
> Yvan
>
> 2013-03-16  Yvan Roux 
>
> * include/private/gcconfig.h (AARCH64): New macro (defined
> only if
> __aarch64__).
> * include/private/gcconfig.h (mach_type_known): Update comment
> adding
> ARM AArch64 target.
> * include/private/gcconfig.h (NOSYS, mach_type_known,
> CPP_WORDSZ,
> MACH_TYPE, ALIGNMENT, HBLKSIZE, OS_TYPE, LINUX_STACKBOTTOM,
> USE_GENERIC_PUSH_REGS, DYNAMIC_LOADING, DATASTART, DATAEND,
> STACKBOTTOM): Define for AArch64.




[patch, mips] Allow users to avoid promoting prototypes.

2013-05-02 Thread Steve Ellcey
MIPS architectures set TARGET_PROMOTE_PROTOTYPES to true.  I would like
to have an option to set this to false in order to avoid extra masking
when passing char or short types.  I don't think we can change this by
default since it would affect the ABI, but I would like to allow users
the option of turning if off if desired.

Tested on mips-mti-elf.  OK for checkin?

Steve Ellcey
sell...@imgtec.com


2013-05-02  Steve Ellcey  

* config/mips/mips.c (mips_promote_prototypes) :New.
(TARGET_PROMOTE_PROTOTYPES): Change to use mips_promote_prototypes.
* config/mips/mips.opt (mpromote-prototypes): New.


diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 7545b60..072a68b 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -5721,6 +5721,15 @@ mips_return_in_memory (const_tree type, const_tree 
fndecl ATTRIBUTE_UNUSED)
  ? TYPE_MODE (type) == BLKmode
  : !IN_RANGE (int_size_in_bytes (type), 0, 2 * UNITS_PER_WORD));
 }
+
+/* Implement TARGET_PROMOTE_PROTOTYPES.  It is true by default but can
+   be turned off with -mno-promote-prototypes.  */
+
+static bool
+mips_promote_prototypes (const_tree t ATTRIBUTE_UNUSED)
+{
+  return (mips_do_promote_prototypes != 0);
+}
 
 /* Implement TARGET_SETUP_INCOMING_VARARGS.  */
 
@@ -18708,7 +18717,7 @@ mips_expand_vec_minmax (rtx target, rtx op0, rtx op1,
 #undef  TARGET_PROMOTE_FUNCTION_MODE
 #define TARGET_PROMOTE_FUNCTION_MODE 
default_promote_function_mode_always_promote
 #undef TARGET_PROMOTE_PROTOTYPES
-#define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true
+#define TARGET_PROMOTE_PROTOTYPES mips_promote_prototypes
 
 #undef TARGET_FUNCTION_VALUE
 #define TARGET_FUNCTION_VALUE mips_function_value
diff --git a/gcc/config/mips/mips.opt b/gcc/config/mips/mips.opt
index e11710d..1881d9d 100644
--- a/gcc/config/mips/mips.opt
+++ b/gcc/config/mips/mips.opt
@@ -305,6 +305,10 @@ mpaired-single
 Target Report Mask(PAIRED_SINGLE_FLOAT)
 Use paired-single floating-point instructions
 
+mpromote-prototypes
+Target Report Var(mips_do_promote_prototypes) Init(1)
+Promote integral arguments smaller then an int to int.
+
 mr10k-cache-barrier=
 Target Joined RejectNegative Enum(mips_r10k_cache_barrier_setting) 
Var(mips_r10k_cache_barrier) Init(R10K_CACHE_BARRIER_NONE)
 -mr10k-cache-barrier=SETTING   Specify when r10k cache barriers should be 
inserted



[PATCH] Refactor coverage.c, outline the construction of gcov constructor

2013-05-02 Thread Carrot Wei
This patch outline the construction of gcov constructor from coverage_obj_init
as a separate function build_init_ctor.

It passed bootstrap and regression test on x86-64.

OK for trunk and google 4.7 branch?

thanks
Carrot


2013-05-02  Guozhi Wei  

* coverage.c (gcov_info_type): New global variable.
(coverage_obj_init): Move the construction of gcov constructor to
(build_init_ctor): here.


Index: coverage.c
===
--- coverage.c (revision 198557)
+++ coverage.c (working copy)
@@ -99,6 +99,7 @@

 /* Coverage info VAR_DECL and function info type nodes.  */
 static GTY(()) tree gcov_info_var;
+static GTY(()) tree gcov_info_type;
 static GTY(()) tree gcov_fn_info_type;
 static GTY(()) tree gcov_fn_info_ptr_type;

@@ -967,6 +968,32 @@
   return build_constructor (info_type, v1);
 }

+/* Generate the constructor function to call __gcov_init.  */
+
+static void
+build_init_ctor ()
+{
+  tree ctor, stmt, init_fn;
+
+  /* Build a decl for __gcov_init.  */
+  init_fn = build_pointer_type (gcov_info_type);
+  init_fn = build_function_type_list (void_type_node, init_fn, NULL);
+  init_fn = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
+ get_identifier ("__gcov_init"), init_fn);
+  TREE_PUBLIC (init_fn) = 1;
+  DECL_EXTERNAL (init_fn) = 1;
+  DECL_ASSEMBLER_NAME (init_fn);
+
+  /* Generate a call to __gcov_init(&gcov_info).  */
+  ctor = NULL;
+  stmt = build_fold_addr_expr (gcov_info_var);
+  stmt = build_call_expr (init_fn, 1, stmt);
+  append_to_statement_list (stmt, &ctor);
+
+  /* Generate a constructor to run it.  */
+  cgraph_build_static_cdtor ('I', ctor, DEFAULT_INIT_PRIORITY);
+}
+
 /* Create the gcov_info types and object.  Generate the constructor
function to call __gcov_init.  Does not generate the initializer
for the object.  Returns TRUE if coverage data is being emitted.  */
@@ -974,7 +1001,6 @@
 static bool
 coverage_obj_init (void)
 {
-  tree gcov_info_type, ctor, stmt, init_fn;
   unsigned n_counters = 0;
   unsigned ix;
   struct coverage_data *fn;
@@ -1020,24 +1046,8 @@
   ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 0);
   DECL_NAME (gcov_info_var) = get_identifier (name_buf);

-  /* Build a decl for __gcov_init.  */
-  init_fn = build_pointer_type (gcov_info_type);
-  init_fn = build_function_type_list (void_type_node, init_fn, NULL);
-  init_fn = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
- get_identifier ("__gcov_init"), init_fn);
-  TREE_PUBLIC (init_fn) = 1;
-  DECL_EXTERNAL (init_fn) = 1;
-  DECL_ASSEMBLER_NAME (init_fn);
+  build_init_ctor ();

-  /* Generate a call to __gcov_init(&gcov_info).  */
-  ctor = NULL;
-  stmt = build_fold_addr_expr (gcov_info_var);
-  stmt = build_call_expr (init_fn, 1, stmt);
-  append_to_statement_list (stmt, &ctor);
-
-  /* Generate a constructor to run it.  */
-  cgraph_build_static_cdtor ('I', ctor, DEFAULT_INIT_PRIORITY);
-
   return true;
 }


[C++ Patch] PR 14283

2013-05-02 Thread Paolo Carlini

Hi,

in this rather old diagnostic issue, we want to provide better error 
messages, spelling out template if appropriate, and also fix the column 
numbers (in practice location_of (id) boils down to input_location which 
is the right position for this kind of error message among those handled 
by cp_parser_diagnose_invalid_type_name). Tested x86_64-linux.


Thanks,
Paolo.

/
/cp
2013-05-02  Paolo Carlini  

PR c++/14283
* parser.c (cp_parser_diagnose_invalid_type_name): Improve error
messages for template types and fix column number.

/testsuite
2013-05-02  Paolo Carlini  

PR c++/14283
* g++.dg/parse/error51.C: New.
* g++.dg/parse/error15.C: Adjust column numbers.
Index: cp/parser.c
===
--- cp/parser.c (revision 198521)
+++ cp/parser.c (working copy)
@@ -2872,8 +2872,16 @@ cp_parser_diagnose_invalid_type_name (cp_parser *p
   else if (parser->scope != error_mark_node)
 {
   if (TREE_CODE (parser->scope) == NAMESPACE_DECL)
-   error_at (location, "%qE in namespace %qE does not name a type",
- id, parser->scope);
+   {
+ if (cp_lexer_next_token_is (parser->lexer, CPP_LESS))
+   error_at (location_of (id),
+ "%qE in namespace %qE does not name a template type",
+ id, parser->scope);
+ else
+   error_at (location_of (id),
+ "%qE in namespace %qE does not name a type",
+ id, parser->scope);
+   }
   else if (CLASS_TYPE_P (parser->scope)
   && constructor_name_p (id, parser->scope))
{
@@ -2890,8 +2898,16 @@ cp_parser_diagnose_invalid_type_name (cp_parser *p
  "%qT is a dependent scope",
  parser->scope, id, parser->scope);
   else if (TYPE_P (parser->scope))
-   error_at (location, "%qE in %q#T does not name a type",
- id, parser->scope);
+   {
+ if (cp_lexer_next_token_is (parser->lexer, CPP_LESS))
+   error_at (location_of (id),
+ "%qE in %q#T does not name a template type",
+ id, parser->scope);
+ else
+   error_at (location_of (id),
+ "%qE in %q#T does not name a type",
+ id, parser->scope);
+   }
   else
gcc_unreachable ();
 }
Index: testsuite/g++.dg/parse/error15.C
===
--- testsuite/g++.dg/parse/error15.C(revision 198521)
+++ testsuite/g++.dg/parse/error15.C(working copy)
@@ -11,9 +11,9 @@ namespace N
 }
 
 N::A f2;  // { dg-error "1:invalid use of template-name 'N::A' 
without an argument list" }
-N::INVALID f3;// { dg-error "1:'INVALID' in namespace 'N' does not 
name a type" }
-N::C::INVALID f4; // { dg-error "1:'INVALID' in 'struct N::C' does not 
name a type" }
-N::K f6;  // { dg-error "1:'K' in namespace 'N' does not name a 
type" }
+N::INVALID f3;// { dg-error "4:'INVALID' in namespace 'N' does not 
name a type" }
+N::C::INVALID f4; // { dg-error "7:'INVALID' in 'struct N::C' does not 
name a type" }
+N::K f6;  // { dg-error "4:'K' in namespace 'N' does not name a 
type" }
 typename N::A f7;
 // { dg-error "13:invalid use of template-name 'N::A' without an argument 
list" "13" { target *-*-* } 17 }
 // { dg-error "17:invalid type in declaration before ';' token" "17" { target 
*-*-* } 17 }
@@ -21,9 +21,9 @@ typename N::A f7;
 struct B
 {
   N::A f2;// { dg-error "3:invalid use of template-name 'N::A' 
without an argument list" }
-  N::INVALID f3;  // { dg-error "3:'INVALID' in namespace 'N' does not 
name a type" }
-  N::C::INVALID f4;   // { dg-error "3:'INVALID' in 'struct N::C' does not 
name a type" }
-  N::K f6;// { dg-error "3:'K' in namespace 'N' does not name a 
type" }
+  N::INVALID f3;  // { dg-error "6:'INVALID' in namespace 'N' does not 
name a type" }
+  N::C::INVALID f4;   // { dg-error "9:'INVALID' in 'struct N::C' does not 
name a type" }
+  N::K f6;// { dg-error "6:'K' in namespace 'N' does not name a 
type" }
   typename N::A f7;
 // { dg-error "15:invalid use of template-name 'N::A' without an argument 
list" "15" { target *-*-* } 27 }
 };
@@ -32,9 +32,9 @@ template 
 struct C
 {
   N::A f2;// { dg-error "3:invalid use of template-name 'N::A' 
without an argument list" }
-  N::INVALID f3;  // { dg-error "3:'INVALID' in namespace 'N' does not 
name a type" }
-  N::C::INVALID f4;   // { dg-error "3:'INVALID' in 'struct N::C' does not 
name a type" }
-  N::K f6;// { dg-error "3:'K' in namespace 'N' does not name a 
type" }
+  N::INVALID f3;  // { dg-error "6:'INVALID' in namespace 'N' does not 
name a type" }
+  N::C::INVALID f4;   // { dg-error "9:'INVALID' in 'struct N::C' does no

Re: [patch, mips] Allow users to avoid promoting prototypes.

2013-05-02 Thread Richard Sandiford
"Steve Ellcey "  writes:
> MIPS architectures set TARGET_PROMOTE_PROTOTYPES to true.  I would like
> to have an option to set this to false in order to avoid extra masking
> when passing char or short types.  I don't think we can change this by
> default since it would affect the ABI, but I would like to allow users
> the option of turning if off if desired.
>
> Tested on mips-mti-elf.  OK for checkin?
>
> Steve Ellcey
> sell...@imgtec.com
>
>
> 2013-05-02  Steve Ellcey  
>
>   * config/mips/mips.c (mips_promote_prototypes) :New.
>   (TARGET_PROMOTE_PROTOTYPES): Change to use mips_promote_prototypes.
>   * config/mips/mips.opt (mpromote-prototypes): New.

It'd need an invoke.texi change too.

The ABI thing is a problem though.  Unlike the recent -mimadd option,
this isn't something a user could reasonably turn on and off for
individual files to see what happens.  They'd need to rebuild all
their libraries with it.  And as written, the patch provides no way
to compile gcc's own libraries that way, so they'd need to patch the
gcc sources locally.

If you want to change the TARGET_PROMOTE_PROTOTYPES part of the
ABI for mips*-mti-elf then that would be OK with me.  It would
be better done without a command-line option.

I'm less keen on adding -mpromote-prototypes to mips*-mti-elf,
both because of the large number of variations there already,
and because continuing to have -mno-promote-prototypes multilibs
would give the impression that the change isn't much of a win.

Ideally we'd also have a .gnu_attribute to record which promotion
rules are being used, so that the linker can pick up incompatibilities.

Sorry to be a pain...

Thanks,
Richard


Re: GCC does not support *mmintrin.h with function specific opts

2013-05-02 Thread Sriraman Tallam
Ping.

On Mon, Apr 29, 2013 at 10:47 AM, Sriraman Tallam  wrote:
> On Thu, Apr 25, 2013 at 12:41 PM, Joseph S. Myers
>  wrote:
>> On Tue, 16 Apr 2013, Sriraman Tallam wrote:
>>
>>> Ok, it is on by default now.  There is a way to turn it off, with
>>> -mno-generate-builtins.
>>
>> Any new option needs documenting in invoke.texi.
>
> Added and new patch attached.
>
> Thanks
> Sri
>
>>
>> --
>> Joseph S. Myers
>> jos...@codesourcery.com


Re: [GOOGLE] Change function naming to use context function assembler name to replace function id

2013-05-02 Thread Dehao Chen
The root problem is that -fsigned-char and -funsigned-char is
incompatible. The fix of the problem:

Index: coverage.c
===
--- coverage.c (revision 198362)
+++ coverage.c (working copy)
@@ -336,6 +336,7 @@
 { "-fsized-delete", "-fno-sized-delete", false },
 { "-frtti", "-fno-rtti", true },
 { "-fstrict-aliasing", "-fno-strict-aliasing", true },
+{ "-fsigned-char", "-funsigned-char", true},
 { NULL, NULL, false }
   };

Ok for google branches?

Thanks,
Dehao

On Wed, May 1, 2013 at 10:26 AM, Dehao Chen  wrote:
> I've seen a case when func_id in aux module is not the same (off by
> 1). This is when -fexception is specified. I had not looked into why
> though. I'll find out why it is off-by-1
>
> Dehao
>
> On Wed, May 1, 2013 at 9:57 AM, Xinliang David Li  wrote:
>> On Tue, Apr 30, 2013 at 4:10 PM, Dehao Chen  wrote:
>>> This patch changes to use context function name to replace function
>>> id, which is not available in AutoFDO builds.
>>
>> Why isn't func_id not available in autofdo builds? The func-id for the
>> the same function should remain the same regardless whether the module
>> is compiled as an aux module or the primary module.
>>
>> David
>>
>>>
>>> Bootstrapped and passed regression tests.
>>>
>>> OK for google branches?
>>>
>>> Thanks,
>>> Dehao
>>>
>>> Index: gcc/l-ipo.c
>>> ===
>>> --- gcc/l-ipo.c (revision 198469)
>>> +++ gcc/l-ipo.c (working copy)
>>> @@ -1714,9 +1714,10 @@ create_unique_name (tree decl, unsigned module_id)
>>>  {
>>>tree id, assemb_id;
>>>char *assembler_name;
>>> +  const char *context = NULL;
>>>const char *name;
>>> -  struct  function *context = NULL;
>>>int seq = 0;
>>> +  int len;
>>>
>>>if (TREE_CODE (decl) == FUNCTION_DECL)
>>>  {
>>> @@ -1740,7 +1741,8 @@ create_unique_name (tree decl, unsigned module_id)
>>>else if (TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
>>>  {
>>>id = DECL_NAME (decl);
>>> -  context = DECL_STRUCT_FUNCTION (DECL_CONTEXT (decl));
>>> +  context = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (
>>> +  DECL_CONTEXT (decl)));
>>>  }
>>>else
>>>  /* file scope context */
>>> @@ -1748,17 +1750,12 @@ create_unique_name (tree decl, unsigned module_id)
>>>  }
>>>
>>>name = IDENTIFIER_POINTER (id);
>>> +  len = strlen (name) + context ? strlen (context) : 0;
>>> +  assembler_name = (char*) alloca (len + 30);
>>>if (context)
>>> -{
>>> -  char *n;
>>> -  unsigned fno =  FUNC_DECL_FUNC_ID (context);
>>> -  n = (char *)alloca (strlen (name) + 15);
>>> -  sprintf (n, "%s.%u", name, fno);
>>> -  name = n;
>>> -}
>>> -
>>> -  assembler_name = (char*) alloca (strlen (name) + 30);
>>> -  sprintf (assembler_name, "%s.cmo.%u", name, module_id);
>>> +sprintf (assembler_name, "%s.%s.cmo.%u", context, name, module_id);
>>> +  else
>>> +sprintf (assembler_name, "%s.cmo.%u", name, module_id);
>>>seq = get_name_seq_num (assembler_name);
>>>if (seq)
>>>  sprintf (assembler_name, "%s.%d", assembler_name, seq);


Re: [GOOGLE] Change function naming to use context function assembler name to replace function id

2013-05-02 Thread Xinliang David Li
ok.

thanks,

David

On Thu, May 2, 2013 at 4:38 PM, Dehao Chen  wrote:
> The root problem is that -fsigned-char and -funsigned-char is
> incompatible. The fix of the problem:
>
> Index: coverage.c
> ===
> --- coverage.c (revision 198362)
> +++ coverage.c (working copy)
> @@ -336,6 +336,7 @@
>  { "-fsized-delete", "-fno-sized-delete", false },
>  { "-frtti", "-fno-rtti", true },
>  { "-fstrict-aliasing", "-fno-strict-aliasing", true },
> +{ "-fsigned-char", "-funsigned-char", true},
>  { NULL, NULL, false }
>};
>
> Ok for google branches?
>
> Thanks,
> Dehao
>
> On Wed, May 1, 2013 at 10:26 AM, Dehao Chen  wrote:
>> I've seen a case when func_id in aux module is not the same (off by
>> 1). This is when -fexception is specified. I had not looked into why
>> though. I'll find out why it is off-by-1
>>
>> Dehao
>>
>> On Wed, May 1, 2013 at 9:57 AM, Xinliang David Li  wrote:
>>> On Tue, Apr 30, 2013 at 4:10 PM, Dehao Chen  wrote:
 This patch changes to use context function name to replace function
 id, which is not available in AutoFDO builds.
>>>
>>> Why isn't func_id not available in autofdo builds? The func-id for the
>>> the same function should remain the same regardless whether the module
>>> is compiled as an aux module or the primary module.
>>>
>>> David
>>>

 Bootstrapped and passed regression tests.

 OK for google branches?

 Thanks,
 Dehao

 Index: gcc/l-ipo.c
 ===
 --- gcc/l-ipo.c (revision 198469)
 +++ gcc/l-ipo.c (working copy)
 @@ -1714,9 +1714,10 @@ create_unique_name (tree decl, unsigned module_id)
  {
tree id, assemb_id;
char *assembler_name;
 +  const char *context = NULL;
const char *name;
 -  struct  function *context = NULL;
int seq = 0;
 +  int len;

if (TREE_CODE (decl) == FUNCTION_DECL)
  {
 @@ -1740,7 +1741,8 @@ create_unique_name (tree decl, unsigned module_id)
else if (TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
  {
id = DECL_NAME (decl);
 -  context = DECL_STRUCT_FUNCTION (DECL_CONTEXT (decl));
 +  context = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (
 +  DECL_CONTEXT (decl)));
  }
else
  /* file scope context */
 @@ -1748,17 +1750,12 @@ create_unique_name (tree decl, unsigned module_id)
  }

name = IDENTIFIER_POINTER (id);
 +  len = strlen (name) + context ? strlen (context) : 0;
 +  assembler_name = (char*) alloca (len + 30);
if (context)
 -{
 -  char *n;
 -  unsigned fno =  FUNC_DECL_FUNC_ID (context);
 -  n = (char *)alloca (strlen (name) + 15);
 -  sprintf (n, "%s.%u", name, fno);
 -  name = n;
 -}
 -
 -  assembler_name = (char*) alloca (strlen (name) + 30);
 -  sprintf (assembler_name, "%s.cmo.%u", name, module_id);
 +sprintf (assembler_name, "%s.%s.cmo.%u", context, name, module_id);
 +  else
 +sprintf (assembler_name, "%s.cmo.%u", name, module_id);
seq = get_name_seq_num (assembler_name);
if (seq)
  sprintf (assembler_name, "%s.%d", assembler_name, seq);


Re: [PING] SLSR for conditional candidates

2013-05-02 Thread Bill Schmidt
On Thu, 2013-05-02 at 13:29 +0200, Richard Biener wrote:
> On Mon, 29 Apr 2013, Bill Schmidt wrote:
> 
> > Half-hearted ping for
> > http://gcc.gnu.org/ml/gcc-patches/2013-03/msg01291.html ...
> > 
> > I promise this is the last major code dump for SLSR. ;)
> 
> 
> 
> +   if (!operand_equal_p (arg_cand->stride, integer_one_node, 0))
> + return;
> 
> !integer_onep (arg_cand->stride);
> 
> +   arg_stmt = SSA_NAME_DEF_STMT (arg);
> +
> +   if (arg_stmt
> +   && gimple_code (arg_stmt) != GIMPLE_NOP)
> + arg_bb = gimple_bb (arg_stmt);
> +   else
> + arg_bb = ENTRY_BLOCK_PTR->next_bb;
> 
>if (SSA_NAME_IS_DEFAULT_DEF (arg))
>  arg_bb = single_succ (ENTRY_BLOCK_PTR);
>else
>  arg_bb = gimple_bb (SSA_NAME_DEF_STMT (arg));
> 
> don't use ->next_bb - the ordering of BBs is arbitrary.   No idea
> why you needed to look for !arg_stmt.
> 
> +  /* If the basis name and the candidate's LHS have incompatible
> +  types, introduce a cast.  */
> +  if (!types_compatible_p (target_type,
> +TREE_TYPE (basis_name)))
> + basis_name = introduce_cast_before_cand (c, target_type,
> +  basis_name, var);
> 
> use !useless_type_conversion_p (target_type, TREE_TYPE (basis_name))
> if you are looking whether the op can be used where target_type is
> requested (as opposed to where it can be assigned _from_ a target_type
> thing).
> 
> +   tree rhs1 = gimple_assign_rhs1 (c->cand_stmt);
> +   tree rhs2 = gimple_assign_rhs2 (c->cand_stmt);
> +   if (cand_code != NEGATE_EXPR
> 
> are you sure you are not accessing out-of-bounds for the
> single-operand NEGATE_EXPR case?
> 
> +/* Return the index in the increment vector of the given INCREMENT.  */
> +
> +static inline unsigned
> +incr_vec_index (double_int increment)
> +{
> +  unsigned i;
> +  
> +  for (i = 0; i < incr_vec_len && increment != incr_vec[i].incr; i++)
> +;
> 
> I smell quadratic complexity here.  Is the incr_vec maybe better
> sorted by 'incr'?

Good point.  We already have the potential for a problem here (in
record_increment, a linear search is used to update the count for the
increment).  I was presuming here that the number of increments for a
candidate group would be a small finite number, which is generally true,
though I suspect a pathological case could be built.  Realistic?
Doubtful, but we should plan for the worst.

I can fix this, but I think I should do it as a separate patch prior to
committing this one, then replace this code with a binary search when
the size of incr_vec is larger than a small constant.

I agree with all your other comments.  Thanks for the review!

Bill

> 
> +  basis_type = TREE_TYPE (basis_name);
> +  lazy_create_slsr_reg (var, basis_type);
> +  lhs = make_ssa_name (*var, NULL);
> 
> btw, lazy_create_slsr_reg should go away now as we have
> the notion of "anonymous" SSA names (SSA names without underlying
> VAR_DECLs).  Just do
> 
>lhs = make_ssa_name (basis_type, NULL);
> 
> here.  You can followup with a patch to remove lazy_create_slsr_reg.
> Another possibility is to use make_temp_ssa_name which has an
> additional char *name argument:
> 
>lhs = make_temp_ssa_name (basis_type, NULL, "slsr");
> 
> which then makes the SSA names show as slsr_N in dumps.
> 
> +  int cost = 0;
> +  slsr_cand_t phi_cand = base_cand_from_table (gimple_phi_result (phi));
> 
> -  gcc_assert (i < incr_vec_len);
> -  return i;
> +  for (i = 0; i < gimple_phi_num_args (phi); i++)
> +{
> +  tree arg = gimple_phi_arg_def (phi, i);
> +
> +  if (!operand_equal_p (arg, phi_cand->base_expr, 0))
> 
> generally SSA names can be compared with == / != directly.
> PHI results are always SSA names so no need to dispatch
> to operand_equal_p here.
> 
> Otherwise the patch looks ok.
> 
> Thanks,
> Richard.
> 



Re: [C++ Patch] PR 14283

2013-05-02 Thread Jason Merrill

OK.

Jason


[RFA][PATCH] Fix tree-optimization/57144

2013-05-02 Thread Jeff Law


When we have

x = (T) y;
if (x > CONST)
  true arm
else
  false arm

Assume CONST is larger than what can be represented in T.  If we use 
fold_convert, any bits not not in T will be dropped.  So if CONST is say 
0x1 and T is a 32 bit type, the returned constant will be 0x0. 
So we change the code to


x = (T) y;
if (y > 0)
  true arm
else
  false arm

If y happens to have a value such as "1" we end up taking the true arm 
when we should have taken the false arm.


The astute reader will note that VRP should have simply eliminated the 
condition because it can never be true, at least not in the testcase 
which is derived from real code in mpfr.  Probably we're too 
conservative when propagating a [0..INF(OV)] through a widening conversion.


Bootstrapped and regression tested on x86_64-unknown-linux-gnu, OK for 
trunk?


Note this fixes the mpfr-2.x testsuite failures on x86_64.  While I 
believe this fix will address 57144 (ia64), I haven't directly confirmed 
that's true.






commit baf070f82c7c6f19fd0a9e72514cc0ce03920c29
Author: Jeff Law 
Date:   Thu May 2 22:19:37 2013 -0600

PR tree-optimization/57411
* tree-vrp.c (simplify_cond_using_ranges): Verify the constant
operand of the condition will bit into the new type when eliminating
a cast feeding a condition.

PR tree-optimization/57411
* gcc.c-torture/execute/pr57144.c: New test.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9e3d783..f245097 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-02  Jeff Law  
+
+   PR tree-optimization/57411
+   * tree-vrp.c (simplify_cond_using_ranges): Verify the constant
+   operand of the condition will bit into the new type when eliminating
+   a cast feeding a condition.
+
 2013-05-02  Richard Biener  
 
* tree-eh.c (cleanup_empty_eh_merge_phis): Remove rename_virts
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c8dc189..be30c51 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-05-02  Jeff Law  
+
+   PR tree-optimization/57411
+   * gcc.c-torture/execute/pr57144.c: New test.
+
 2013-05-02  Tobias Burnus  
 
PR fortran/57142
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr57144.c 
b/gcc/testsuite/gcc.c-torture/execute/pr57144.c
new file mode 100644
index 000..e96c749
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr57144.c
@@ -0,0 +1,15 @@
+__attribute__ ((noinline))
+foo(int a)
+{
+  int z = a > 0 ? a : -a;
+  long x = z;
+  if (x > 0x1)
+abort ();
+  else
+exit (0);
+}
+
+main()
+{
+  foo (1);
+}
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 6ed353f..b5de683 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -8668,7 +8668,8 @@ simplify_cond_using_ranges (gimple stmt)
  if (range_int_cst_p (vr)
  && range_fits_type_p (vr,
TYPE_PRECISION (TREE_TYPE (op0)),
-   TYPE_UNSIGNED (TREE_TYPE (op0
+   TYPE_UNSIGNED (TREE_TYPE (op0)))
+ && int_fits_type_p (op1, TREE_TYPE (innerop)))
{
  tree newconst = fold_convert (TREE_TYPE (innerop), op1);
  gimple_cond_set_lhs (stmt, innerop);


Re: [RFA][PATCH] Fix tree-optimization/57144

2013-05-02 Thread Jakub Jelinek
On Thu, May 02, 2013 at 10:30:57PM -0600, Jeff Law wrote:
> --- /dev/null
> +++ b/gcc/testsuite/gcc.c-torture/execute/pr57144.c
> @@ -0,0 +1,15 @@
> +__attribute__ ((noinline))
> +foo(int a)
> +{
> +  int z = a > 0 ? a : -a;
> +  long x = z;
> +  if (x > 0x1)
> +abort ();
> +  else
> +exit (0);
> +}
> +
> +main()
> +{
> +  foo (1);
> +}

Just commenting on the testcase, could you please:
1) add return types (void to foo and int to main)
2) use long long instead of long, otherwise the testcase doesn't fail
   without your patch with -m32
3) I'd add LL suffix to the constant too
4) either prototype extern void abort (void); extern void exit (int);
   or use __builtin_{abort,exit}?

For 1) and 4) we usually add at least C89 testcases now, unless strictly
necessary (testing K&R stuff).  I believe with long long the testcase should
be fine even on say AVR, because C99 says that long long must be at least
64-bit.

Jakub