Go patch committed: Be more careful to follow type rules

2012-03-09 Thread Ian Lance Taylor
The Go frontend can create multiple instances of unnamed types that are,
in the Go language, the same type.  This can lead to using different
tree types when generating GENERIC.  This normally does no harm because
the differences are usually pointer types.  However, it is possible in
some cases to build two unnamed structs that are really the same type in
Go, but GENERIC does not permit assignments between different structs.
This patch makes the Go frontend stricter about this sort of thing, by
calling fold_convert or inserting a VIEW_CONVERT_EXPR where necessary.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian


2012-03-09  Ian Lance Taylor  i...@google.com

* go-gcc.cc (Gcc_backend::assignment_statement): Convert the rhs
to the lhs type if necessary.


Index: gcc/go/go-gcc.cc
===
--- gcc/go/go-gcc.cc	(revision 185115)
+++ gcc/go/go-gcc.cc	(working copy)
@@ -918,6 +918,30 @@ Gcc_backend::assignment_statement(Bexpre
 return this-compound_statement(this-expression_statement(lhs),
 this-expression_statement(rhs));
 
+  // Sometimes the same unnamed Go type can be created multiple times
+  // and thus have multiple tree representations.  Make sure this does
+  // not confuse the middle-end.
+  if (TREE_TYPE(lhs_tree) != TREE_TYPE(rhs_tree))
+{
+  tree lhs_type_tree = TREE_TYPE(lhs_tree);
+  gcc_assert(TREE_CODE(lhs_type_tree) == TREE_CODE(TREE_TYPE(rhs_tree)));
+  if (POINTER_TYPE_P(lhs_type_tree)
+	  || INTEGRAL_TYPE_P(lhs_type_tree)
+	  || SCALAR_FLOAT_TYPE_P(lhs_type_tree)
+	  || COMPLEX_FLOAT_TYPE_P(lhs_type_tree))
+	rhs_tree = fold_convert_loc(location.gcc_location(), lhs_type_tree,
+rhs_tree);
+  else if (TREE_CODE(lhs_type_tree) == RECORD_TYPE
+	   || TREE_CODE(lhs_type_tree) == ARRAY_TYPE)
+	{
+	  gcc_assert(int_size_in_bytes(lhs_type_tree)
+		 == int_size_in_bytes(TREE_TYPE(rhs_tree)));
+	  rhs_tree = fold_build1_loc(location.gcc_location(),
+ VIEW_CONVERT_EXPR,
+ lhs_type_tree, rhs_tree);
+	}
+}
+
   return this-make_statement(fold_build2_loc(location.gcc_location(),
   MODIFY_EXPR,
 	  void_type_node,
Index: gcc/go/gofrontend/expressions.cc
===
--- gcc/go/gofrontend/expressions.cc	(revision 185092)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -205,9 +205,6 @@ Expression::convert_for_assignment(Trans
    Type* rhs_type, tree rhs_tree,
    Location location)
 {
-  if (lhs_type == rhs_type)
-return rhs_tree;
-
   if (lhs_type-is_error() || rhs_type-is_error())
 return error_mark_node;
 
@@ -220,7 +217,7 @@ Expression::convert_for_assignment(Trans
   if (lhs_type_tree == error_mark_node)
 return error_mark_node;
 
-  if (lhs_type-interface_type() != NULL)
+  if (lhs_type != rhs_type  lhs_type-interface_type() != NULL)
 {
   if (rhs_type-interface_type() == NULL)
 	return Expression::convert_type_to_interface(context, lhs_type,
@@ -231,7 +228,7 @@ Expression::convert_for_assignment(Trans
 			  rhs_type, rhs_tree,
 			  false, location);
 }
-  else if (rhs_type-interface_type() != NULL)
+  else if (lhs_type != rhs_type  rhs_type-interface_type() != NULL)
 return Expression::convert_interface_to_type(context, lhs_type, rhs_type,
 		 rhs_tree, location);
   else if (lhs_type-is_slice_type()  rhs_type-is_nil_type())
@@ -289,10 +286,16 @@ Expression::convert_for_assignment(Trans
 	   || (TREE_CODE(lhs_type_tree) == ARRAY_TYPE
 	TREE_CODE(TREE_TYPE(rhs_tree)) == ARRAY_TYPE))
 {
+  // Avoid confusion from zero sized variables which may be
+  // represented as non-zero-sized.
+  if (int_size_in_bytes(lhs_type_tree) == 0
+	  || int_size_in_bytes(TREE_TYPE(rhs_tree)) == 0)
+	return rhs_tree;
+
   // This conversion must be permitted by Go, or we wouldn't have
   // gotten here.
   go_assert(int_size_in_bytes(lhs_type_tree)
-		 == int_size_in_bytes(TREE_TYPE(rhs_tree)));
+		== int_size_in_bytes(TREE_TYPE(rhs_tree)));
   return fold_build1_loc(location.gcc_location(), VIEW_CONVERT_EXPR,
  lhs_type_tree, rhs_tree);
 }


[PATCH] GCC 4.7 and 4.8 PowerPC RTEMS

2012-03-09 Thread Sebastian Huber

Hi,

please have a look at the attached patch.  Test suite results for GCC 4.7

http://gcc.gnu.org/ml/gcc-testresults/2012-03/msg00986.html

--
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
2012-03-08  Sebastian Huber  sebastian.hu...@embedded-brains.de

* config.host (powerpc-*-rtems*): Add rs6000/t-savresfgpr to
tmake_file.

diff --git a/libgcc/config.host b/libgcc/config.host
index 257622a..f6432c5 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -884,7 +884,7 @@ powerpc-*-eabi*)
 	extra_parts=$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o
 	;;
 powerpc-*-rtems*)
-	tmake_file=${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit
+	tmake_file=${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff t-crtstuff-pic t-fdpbit
 	extra_parts=$extra_parts crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o
 	;;
 powerpc-*-linux* | powerpc64-*-linux*)


Re: [PATCH] Fix PRs 52080, 52097 and 48124, rewrite bitfield expansion, enable the C++ memory model wrt bitfields everywhere

2012-03-09 Thread Eric Botcazou
 This patch also completely replaces get_bit_range (which is where
 PR52097 ICEs) by a trivial implementation.

How does it short-circuit the decision made by get_best_mode exactly?  By 
making get_bit_range return non-zero in more cases?

 There is PR52134 which will make this patch cause 1 gnat regression.

This looks rather benign to me.

   * gimplify.c (gimplify_expr): Translate bitfield accesses
   to BIT_FIELD_REFs of the representative.

This part isn't in the patch.

 + /* Return a new underlying object for a bitfield started with FIELD.  */
 +
 + static tree
 + start_bitfield_representative (tree field)
 + {
 +   tree repr = make_node (FIELD_DECL);
 +   DECL_FIELD_OFFSET (repr) = DECL_FIELD_OFFSET (field);
 +   /* Force the representative to begin at an BITS_PER_UNIT aligned

...at a BITS_PER_UNIT aligned...

 +  boundary - C++ may use tail-padding of a base object to
 +  continue packing bits so the bitfield region does not start
 +  at bit zero (see g++.dg/abi/bitfield5.C for example).
 +  Unallocated bits may happen for other reasons as well,
 +  for example Ada which allows explicit bit-granular structure layout.
  */ +   DECL_FIELD_BIT_OFFSET (repr)
 + = size_binop (BIT_AND_EXPR,
 +   DECL_FIELD_BIT_OFFSET (field),
 +   bitsize_int (~(BITS_PER_UNIT - 1)));
 +   SET_DECL_OFFSET_ALIGN (repr, DECL_OFFSET_ALIGN (field));
 +   DECL_SIZE (repr) = DECL_SIZE (field);
 +   DECL_PACKED (repr) = DECL_PACKED (field);
 +   DECL_CONTEXT (repr) = DECL_CONTEXT (field);
 +   return repr;

Any particular reason to set DECL_SIZE but not DECL_SIZE_UNIT here?  They are 
generally set together.

 +
 + /* Finish up a bitfield group that was started by creating the underlying
 +object REPR with the last fied in the bitfield group FIELD.  */

...the last field...

 +   /* Round up bitsize to multiples of BITS_PER_UNIT.  */
 +   bitsize = (bitsize + BITS_PER_UNIT - 1)  ~(BITS_PER_UNIT - 1);
 +
 +   /* Find the smallest nice mode to use.
 +  ???  Possibly use get_best_mode with appropriate arguments instead
 +  (which would eventually require splitting representatives here).  */
 +   for (modesize = bitsize; modesize = maxbitsize; modesize +=
 BITS_PER_UNIT) + {
 +   mode = mode_for_size (modesize, MODE_INT, 1);
 +   if (mode != BLKmode)
 + break;
 + }

The double loop looks superfluous.  Why not re-using the implementation of 
smallest_mode_for_size?

  for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
   mode = GET_MODE_WIDER_MODE (mode))
if (GET_MODE_PRECISION (mode) = bitsize)
  break;

  if (mode != VOIDmode  GET_MODE_PRECISION (mode)  maxbitsize)
mode = VOIDmode;

  if (mode == VOIDmode)
...

-- 
Eric Botcazou


[Ada] Clean up implementation of thin pointers in gigi

2012-03-09 Thread Eric Botcazou
This is in preparation for the upcoming implementation change.  This removes 
useless code, modernizes obsolete idioms and makes things more explicit.

Tested on i586-suse-linux, applied on the mainline.


2012-03-09  Eric Botcazou  ebotca...@adacore.com

* gcc-interface/ada-tree.h (TYPE_VAX_FLOATING_POINT_P): Move around.
(TYPE_UNCONSTRAINED_ARRAY): Adjust comment.
* gcc-interface/trans.c (Attribute_to_gnu) Attr_Pool_Address: Tidy
up.  Add comment and use canonical predicate for thin pointers.
(gnat_to_gnu) N_Free_Statement: Tidy up and reorder.  Add comment
and use canonical predicate for thin pointers.
* gcc-interface/utils.c (convert_to_fat_pointer): Remove superfluous
'else' and use standard name.
(convert_to_thin_pointer): Delete.
(convert) POINTER_TYPE: Do the difference in sizetype directly and
change obsolete idioms.  Do not call above function.
(unchecked_convert): Fix formatting.
* gcc-interface/utils2.c (build_unary_op) INDIRECT_REF: In the thin
pointer case, use byte_position to get the field position.


-- 
Eric Botcazou
Index: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 185130)
+++ gcc-interface/utils.c	(working copy)
@@ -220,7 +220,6 @@ static tree compute_related_constant (tr
 static tree split_plus (tree, tree *);
 static tree float_type_for_precision (int, enum machine_mode);
 static tree convert_to_fat_pointer (tree, tree);
-static tree convert_to_thin_pointer (tree, tree);
 static bool potential_alignment_gap (tree, tree, tree);
 static void process_attributes (tree, struct attrib *);
 
@@ -3608,10 +3607,10 @@ convert_to_fat_pointer (tree type, tree
   return t;
 }
 
-  /* If EXPR is a thin pointer, make template and data from the record..  */
-  else if (TYPE_IS_THIN_POINTER_P (etype))
+  /* If EXPR is a thin pointer, make template and data from the record.  */
+  if (TYPE_IS_THIN_POINTER_P (etype))
 {
-  tree fields = TYPE_FIELDS (TREE_TYPE (etype));
+  tree field = TYPE_FIELDS (TREE_TYPE (etype));
 
   expr = gnat_protect_expr (expr);
   if (TREE_CODE (expr) == ADDR_EXPR)
@@ -3619,10 +3618,10 @@ convert_to_fat_pointer (tree type, tree
   else
 	expr = build1 (INDIRECT_REF, TREE_TYPE (etype), expr);
 
-  template_tree = build_component_ref (expr, NULL_TREE, fields, false);
+  template_tree = build_component_ref (expr, NULL_TREE, field, false);
   expr = build_unary_op (ADDR_EXPR, NULL_TREE,
 			 build_component_ref (expr, NULL_TREE,
-		  DECL_CHAIN (fields), false));
+		  DECL_CHAIN (field), false));
 }
 
   /* Otherwise, build the constructor for the template.  */
@@ -3649,27 +3648,6 @@ convert_to_fat_pointer (tree type, tree
   return gnat_build_constructor (type, v);
 }
 
-/* Convert to a thin pointer type, TYPE.  The only thing we know how to convert
-   is something that is a fat pointer, so convert to it first if it EXPR
-   is not already a fat pointer.  */
-
-static tree
-convert_to_thin_pointer (tree type, tree expr)
-{
-  if (!TYPE_IS_FAT_POINTER_P (TREE_TYPE (expr)))
-expr
-  = convert_to_fat_pointer
-	(TREE_TYPE (TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type))), expr);
-
-  /* We get the pointer to the data and use a NOP_EXPR to make it the
- proper GCC type.  */
-  expr = build_component_ref (expr, NULL_TREE, TYPE_FIELDS (TREE_TYPE (expr)),
-			  false);
-  expr = build1 (NOP_EXPR, type, expr);
-
-  return expr;
-}
-
 /* Create an expression whose value is that of EXPR,
converted to type TYPE.  The TREE_TYPE of the value
is always TYPE.  This function implements all reasonable
@@ -4124,33 +4102,25 @@ convert (tree type, tree expr)
 
 case POINTER_TYPE:
 case REFERENCE_TYPE:
-  /* If converting between two pointers to records denoting
-	 both a template and type, adjust if needed to account
-	 for any differing offsets, since one might be negative.  */
+  /* If converting between two thin pointers, adjust if needed to account
+	 for any differing offsets, since one of them might be negative.  */
   if (TYPE_IS_THIN_POINTER_P (etype)  TYPE_IS_THIN_POINTER_P (type))
 	{
-	  tree bit_diff
-	= size_diffop (bit_position (TYPE_FIELDS (TREE_TYPE (etype))),
-			   bit_position (TYPE_FIELDS (TREE_TYPE (type;
 	  tree byte_diff
-	= size_binop (CEIL_DIV_EXPR, bit_diff, sbitsize_unit_node);
+	= size_diffop (byte_position (TYPE_FIELDS (TREE_TYPE (etype))),
+			   byte_position (TYPE_FIELDS (TREE_TYPE (type;
+
 	  expr = build1 (NOP_EXPR, type, expr);
-	  TREE_CONSTANT (expr) = TREE_CONSTANT (TREE_OPERAND (expr, 0));
 	  if (integer_zerop (byte_diff))
 	return expr;
 
 	  return build_binary_op (POINTER_PLUS_EXPR, type, expr,
-  fold (convert (sizetype, byte_diff)));
+  fold_convert (sizetype, byte_diff));
 	}
 
-  /* If converting to a thin pointer, handle 

Re: [RFC]: Add support for pragma pointer_size

2012-03-09 Thread Tristan Gingold

On Mar 8, 2012, at 7:10 PM, Mike Stump wrote:

 On Mar 8, 2012, at 5:49 AM, Tristan Gingold wrote:
 Argh, that's an issue.  We don't run the gcc test suite natively on VMS
 because there is no port of Dejagnu (if ever doable) to VMS.  We haven't 
 tried
 to test a cross-compiler (and running the executable on the VMS host) because
 an early attempt for another test suite pointed out slowness and reliability
 issues.
 
 dejagnu slices through this type of testing just fine.  dejagnu is also adept 
 at handling reliability issues, its history is littered with unreliability 
 and it is usually fairly easy to work around any unreliability.  Selecting 
 targets that happen to be in a `working' state, powercycling them, as needed, 
 noticing when things go wrong, retrying things a few times, as sometimes, 
 something doesn't just work and so on.  Also, the cross testing can come in 
 many flavors, you can use a simulator (if you have one) and do cross and test 
 on simulator.  You can do this, without the simulator and just fail all the 
 execute tests, you can do canadian cross controlling host to native host 
 testing.  As for speed, well, it is all about latency and reliability, the 
 lower the latency and the higher the reliability, the faster the testing, 
 but, it is, what it is.  The modern testsuite might be 8 hour range or more, 
 but overnight testing is better than no testing.  If you hide it behind a git 
 send hook and stage everything through git and then push out from git as the 
 testsuite passes...  you should be able to achieve a nice work-flow.
 
 VMS machines could be considered as slow from today's standard POV.
 I haven't found a method to run only the compile tests and skip the 
 executing one.
 Is it possible to do that with the gcc test suite ?
 
 If you configure a cross compiler and do a make check, you'll just get a fast 
 fail on all the execute tests.  If you just look for regressions, you'll 
 notice this works just fine.  Sit back, don't worry about the execution 
 failures.  When you wire up sim, just say the simulator is /bin/false or 
 /bin/true (set_board_info sim /bin/false)
 
 Feel free to email me directly if you need additional pointers.  It is fairly 
 easy to setup, though, daunting, one has never done it before.

Thank you Mike for details.

I think I will investigate the cross compiler path first.

Tristan.



Re: [Patch, libfortran] PR 52434/48878/38199 Improve floating point formatted writes

2012-03-09 Thread Janne Blomqvist
On Fri, Mar 9, 2012 at 00:40, Janne Blomqvist blomqvist.ja...@gmail.com wrote:
 Note that GFortran previously did roundTiesToAway, whereas at least
 glibc snprintf() does roundTiesToEven, so some change in behavior is
 expected. Anyway, this is IMHO for the better, as it avoids biasing
 the magnitude upwards in some common cases. Also, roundTiesToAway is
 the default rounding mode for arithmetic.

Err, roundTiestToEven is the default, that is.

Also, the patch contains a bunch of commented out printf's for
debugging. I will obviously remove those before committing, so please
disregard those when reviewing. Thanks!


-- 
Janne Blomqvist


[VMS/committed]: Follow VMS name rules more closely for module include files

2012-03-09 Thread Tristan Gingold
Hi,

on VMS systems, the systems headers are in text archives.  We require that 
these headers are unarchived, but we also need to follow more closely the 
naming rules.
In particular, directories and suffixes are stripped when DEC-C looks in 
archives, and the archives are case insensitive.
To follow that, the patch uses the lower case base name of the file with the .h 
extension when looking for files in module directories.

Simply building building gcc for VMS tests this patch as there is at least an 
'#include sys/types.h' instance.  (Before, the trick was to add a symlink).

Committed on trunk.

Tristan.

2012-03-09  Tristan Gingold  ging...@adacore.com

* config/vms/vms-c.c (vms_construct_include_filename): New function.
(vms_c_register_includes): Reference it.

Index: vms-c.c
===
--- vms-c.c (revision 185132)
+++ vms-c.c (working copy)
@@ -304,6 +304,36 @@
   c_register_pragma (NULL, __extern_prefix, vms_pragma_extern_prefix);
 }
 
+/* Canonicalize the filename (remove directory prefix, force the .h extension),
+   and append it to the directory to create the path, but don't
+   turn / into // or // into ///; // may be a namespace escape.  */
+
+static char *
+vms_construct_include_filename (const char *fname, cpp_dir *dir)
+{
+  size_t dlen, flen;
+  char *path;
+  const char *fbasename = lbasename (fname);
+  size_t i;
+
+  dlen = dir-len;
+  flen = strlen (fbasename) + 2;
+  path = XNEWVEC (char, dlen + 1 + flen + 1);
+  memcpy (path, dir-name, dlen);
+  if (dlen  !IS_DIR_SEPARATOR (path[dlen - 1]))
+path[dlen++] = '/';
+  for (i = 0; i  flen; i++)
+if (fbasename[i] == '.')
+  break;
+else
+  path[dlen + i] = TOLOWER (fbasename[i]);
+  path[dlen + i + 0] = '.';
+  path[dlen + i + 1] = 'h';
+  path[dlen + i + 2] = 0;
+
+  return path;
+}
+
 /* Standard modules list.  */
 static const char * const vms_std_modules[] = { rtldef, starlet_c, NULL };
 
@@ -341,7 +371,7 @@
   p-next = NULL;
   p-name = path;
   p-sysp = 1;
-  p-construct = 0;
+  p-construct = vms_construct_include_filename;
   p-user_supplied_p = 0;
   add_cpp_dir_path (p, SYSTEM);
 }



Re: [PATCH][1/n] No longer sign-extend sizetype constants, remove TYPE_IS_SIZETYPE

2012-03-09 Thread Eric Botcazou
 Well.  I suppose fixing that negative DECL_FIELD_OFFSET thing should
 be #1 priority.

Tentative patch attached (you need an up-to-date tree).  We cannot really get 
rid of the negative offsets for thin pointers, so the patch pulls them out of 
record types and uses pointer arithmetics instead.


* gcc-interface/gigi.h (shift_unc_components_for_thin_pointers): Kill.
* gcc-interface/decl.c (gnat_to_gnu_entity) E_Array_Type: Remove call
to above function.
* gcc-interface/trans.c (Attribute_to_gnu) Attr_Pool_Address: Adjust
handling of thin pointers.
Attr_Descriptor_Size: Likewise.
(gnat_to_gnu) N_Free_Statement: Likewise.
* gcc-interface/utils.c (shift_unc_components_for_thin_pointers): Kill.
(convert_to_fat_pointer): Adjust handling of thin pointers.
(convert) POINTER_TYPE: Likewise.
* gcc-interface/utils2.c (build_unary_op) INDIRECT_REF: Likewise.


-- 
Eric Botcazou
Index: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 185132)
+++ gcc-interface/utils.c	(working copy)
@@ -3411,27 +3411,6 @@ build_unc_object_type_from_ptr (tree thi
   return
 build_unc_object_type (template_type, object_type, name, debug_info_p);
 }
-
-/* Shift the component offsets within an unconstrained object TYPE to make it
-   suitable for use as a designated type for thin pointers.  */
-
-void
-shift_unc_components_for_thin_pointers (tree type)
-{
-  /* Thin pointer values designate the ARRAY data of an unconstrained object,
- allocated past the BOUNDS template.  The designated type is adjusted to
- have ARRAY at position zero and the template at a negative offset, so
- that COMPONENT_REFs on (*thin_ptr) designate the proper location.  */
-
-  tree bounds_field = TYPE_FIELDS (type);
-  tree array_field  = DECL_CHAIN (TYPE_FIELDS (type));
-
-  DECL_FIELD_OFFSET (bounds_field)
-= size_binop (MINUS_EXPR, size_zero_node, byte_position (array_field));
-
-  DECL_FIELD_OFFSET (array_field) = size_zero_node;
-  DECL_FIELD_BIT_OFFSET (array_field) = bitsize_zero_node;
-}
 
 /* Update anything previously pointing to OLD_TYPE to point to NEW_TYPE.
In the normal case this is just two adjustments, but we have more to
@@ -3616,7 +3595,18 @@ convert_to_fat_pointer (tree type, tree
   if (TREE_CODE (expr) == ADDR_EXPR)
 	expr = TREE_OPERAND (expr, 0);
   else
-	expr = build1 (INDIRECT_REF, TREE_TYPE (etype), expr);
+	{
+	  /* If we have a TYPE_UNCONSTRAINED_ARRAY attached to the RECORD_TYPE,
+	 the thin pointer value has been shifted so we first need to shift
+	 it back to get the template address.  */
+	  if (TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (etype)))
+	expr
+	  = build_binary_op (POINTER_PLUS_EXPR, etype, expr,
+ fold_build1 (NEGATE_EXPR, sizetype,
+	  byte_position
+	  (DECL_CHAIN (field;
+	  expr = build1 (INDIRECT_REF, TREE_TYPE (etype), expr);
+	}
 
   template_tree = build_component_ref (expr, NULL_TREE, field, false);
   expr = build_unary_op (ADDR_EXPR, NULL_TREE,
@@ -4103,12 +4093,19 @@ convert (tree type, tree expr)
 case POINTER_TYPE:
 case REFERENCE_TYPE:
   /* If converting between two thin pointers, adjust if needed to account
-	 for any differing offsets, since one of them might be negative.  */
+	 for differing offsets from the base pointer, depending on whether
+	 there is a TYPE_UNCONSTRAINED_ARRAY attached to the record type.  */
   if (TYPE_IS_THIN_POINTER_P (etype)  TYPE_IS_THIN_POINTER_P (type))
 	{
-	  tree byte_diff
-	= size_diffop (byte_position (TYPE_FIELDS (TREE_TYPE (etype))),
-			   byte_position (TYPE_FIELDS (TREE_TYPE (type;
+	  tree etype_pos
+	= TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (etype)) != NULL_TREE
+	  ? byte_position (DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (etype
+	  : size_zero_node;
+	  tree type_pos
+	= TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type)) != NULL_TREE
+	  ? byte_position (DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (type
+	  : size_zero_node;
+	  tree byte_diff = size_diffop (type_pos, etype_pos);
 
 	  expr = build1 (NOP_EXPR, type, expr);
 	  if (integer_zerop (byte_diff))
Index: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 185130)
+++ gcc-interface/decl.c	(working copy)
@@ -2280,13 +2280,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 			  gnu_fat_type, NULL, !Comes_From_Source (gnat_entity),
 			  debug_info_p, gnat_entity);
 
-	/* Create the type to be used as what a thin pointer designates:
-	   a record type for the object and its template with the fields
-	   shifted to have the template at a negative offset.  */
+	/* Create the type to be designated by thin pointers: a record type for
+	   the array and its template.  We used to shift the fields to have the
+	   template at a negative offset, but this was somewhat of a 

Re: [patch, libffi] Sync merge libffi

2012-03-09 Thread Iain Sandoe

Hello Anthony,

On 4 Mar 2012, at 21:20, Anthony Green wrote:

The attached patch includes changes that have been reviewed,  
approved and merged into the stand-alone libffi release tree**.


This hunk (and an identical change in src/powerpc/darwin.S) ..

Index: src/powerpc/darwin_closure.S
===
--- src/powerpc/darwin_closure.S(revision 184894)
+++ src/powerpc/darwin_closure.S(working copy)
@@ -484,7 +484,7 @@
.byte   EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor
.byte   0x41; CIE RA Column
.byte   0x1 ; uleb128 0x1; Augmentation size
-   .byte   0x90; FDE Encoding (indirect pcrel)
+   .byte   0x10; FDE Encoding (indirect pcrel)
.byte   0xc ; DW_CFA_def_cfa
.byte   0x1 ; uleb128 0x1
.byte   0x0 ; uleb128 0x0

.. appear to be incomplete - they change the FDE encoding - without  
changing the way in which the information is provided (and the  
parenthesized portion of the comment is now misleading).


Consequently, unwinding through libffi for m32/m64 powerpc-darwin is  
not working on trunk at present which causes fails in libffi.special/ 
special.exp (and also causes some additional fails for libjava).


===

Reverting the hunks is one possibility;  however the use of indirect- 
pcrel is somewhat out-of-line with what the system compiler produces  
for FDE encoding (although it is the preferred method for personality  
routine encoding)...


... so the following patch modifies the provided data to use just  
pcrel (as per the usual output of the system gcc-4.2.1).


I have tested this on a quad G5 running darwin9
libffi/libjava: \{,-mmacosx-version-min=10.4\}\{-m32,-m64\}

The patch restores libffi/libjava to the pre-merge results.

[one new libffi test - err_bad_abi.c - is also failing on trunk for  
ppc-darwin, but that's to be investigated separately].


Mike, do you know any special reason that indirect-pcrel was being  
used there?


.. or, is this OK for trunk?
Iain


libffi:

* src/powerpc/darwin_closure.S (EH_FRAME_LABEL): New.
Remove indirect reference for Lstartcode.  Change comment on FDE
encoding.  Use amended EH_FRAME_LABEL for CIE offset.
Adjust initial location to use PCrel, and no indirection.
* src/powerpc/darwin.S: Likewise.

Index: libffi/src/powerpc/darwin_closure.S
===
--- libffi/src/powerpc/darwin_closure.S (revision 185095)
+++ libffi/src/powerpc/darwin_closure.S (working copy)
@@ -466,14 +466,10 @@ Lendcode:
 /* 176, 400 */
 #define EH_FRAME_OFFSETA MODE_CHOICE(176,0x90)
 #define EH_FRAME_OFFSETB MODE_CHOICE(1,3)
+#define EH_FRAME_LABEL MODE_CHOICE(LEH_frame1,EH_frame1)
 
-   .static_data
-   .align LOG2_GPR_BYTES
-LLFB1$non_lazy_ptr:
-   .g_long Lstartcode
-
.section 
__TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
-EH_frame1:
+EH_FRAME_LABEL:
.setL$set$0,LECIE1-LSCIE1
.long   L$set$0 ; Length of Common Information Entry
 LSCIE1:
@@ -484,7 +480,7 @@ LSCIE1:
.byte   EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor
.byte   0x41; CIE RA Column
.byte   0x1 ; uleb128 0x1; Augmentation size
-   .byte   0x10; FDE Encoding (indirect pcrel)
+   .byte   0x10; FDE Encoding (pcrel)
.byte   0xc ; DW_CFA_def_cfa
.byte   0x1 ; uleb128 0x1
.byte   0x0 ; uleb128 0x0
@@ -497,8 +493,8 @@ LSFDE1:
.long   L$set$1 ; FDE Length
 
 LASFDE1:
-   .long   LASFDE1-EH_frame1   ; FDE CIE offset
-   .g_long LLFB1$non_lazy_ptr-.; FDE initial location
+   .long   LASFDE1-EH_FRAME_LABEL  ; FDE CIE offset
+   .g_long Lstartcode-.; FDE initial location
.setL$set$3,LFE1-Lstartcode
.g_long L$set$3 ; FDE address range
.byte   0x0 ; uleb128 0x0; Augmentation size
Index: libffi/src/powerpc/darwin.S
===
--- libffi/src/powerpc/darwin.S (revision 185095)
+++ libffi/src/powerpc/darwin.S (working copy)
@@ -317,14 +317,10 @@ _ffi_call_AIX:
 /* EH stuff.  */
 
 #define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78)
+#define EH_FRAME_LABEL MODE_CHOICE(LEH_frame1,EH_frame1)
 
-   .static_data
-   .align LOG2_GPR_BYTES
-LLFB0$non_lazy_ptr:
-   .g_long Lstartcode
-
.section 
__TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
-EH_frame1:
+EH_FRAME_LABEL:
.setL$set$0,LECIE1-LSCIE1
.long   L$set$0 ; Length of Common Information Entry
 LSCIE1:
@@ -335,7 +331,7 @@ LSCIE1:
.byte   EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor
.byte   0x41; CIE RA Column
.byte   0x1 ; uleb128 0x1; Augmentation size
-   .byte   0x10; FDE Encoding (indirect pcrel)
+   .byte   0x10; FDE Encoding 

Re: [RFC]: Add support for pragma pointer_size

2012-03-09 Thread Tristan Gingold

On Mar 8, 2012, at 4:18 PM, Joseph S. Myers wrote:

 On Thu, 8 Mar 2012, Tristan Gingold wrote:
 
 Argh, that's an issue.  We don't run the gcc test suite natively on VMS
 because there is no port of Dejagnu (if ever doable) to VMS.  We haven't 
 tried
 to test a cross-compiler (and running the executable on the VMS host) because
 an early attempt for another test suite pointed out slowness and reliability
 issues.  VMS machines could be considered as slow from today's standard POV.
 I haven't found a method to run only the compile tests and skip the 
 executing one.
 Is it possible to do that with the gcc test suite ?  That's would be very
 useful to test cross compilers.
 
 Thanks for the explanation.  I advise solving the unreliability issues for 
 cross-testing to VMS (and living with the slowness), so that you can run 
 the testsuite, but the patch is OK as-is.

Thank you for your comments.
No C regressions on x86_64-darwin after full bootstrap.
Now committed.

Tristan.



Merge from trunk to gccgo branch

2012-03-09 Thread Ian Lance Taylor
I have merged trunk revision 185128 to the gccgo branch.

Ian


[VMS/committed]: Add more crtl map entries

2012-03-09 Thread Tristan Gingold
Hi,

this patch adds new entries to vms-crtlmap.map.
I hope this is the last such patch before I extract by a script all the entries.

Committed on trunk.

Tristan.

2012-03-09  Tristan Gingold  ging...@adacore.com

* config/vms/vms-crtlmap.map: Add comments.
Add entries needed to build Ada RTS.

Index: gcc/config/vms/vms-crtlmap.map
===
--- gcc/config/vms/vms-crtlmap.map  (revision 185132)
+++ gcc/config/vms/vms-crtlmap.map  (working copy)
@@ -13,9 +13,10 @@
 # - map lines consist in an identifier optionnaly followed by at most 2
 #   space-separated flags.
 # Flags are:
-#  FLOAT: will be prefixed by 't'/'g'/'d'
-#  64: There is a 64-bit variant
-#  BSD44: name will be prefixed by __bsd44__
+#  FLOAT: will be prefixed by 't'/'g'/'d'.
+#  64: There is a 64-bit variant.
+#  GLOBAL: name will be prefixed by ga_
+#  BSD44: name will be prefixed by __bsd44__.
 #  LDBL: a 'x' prefix will be added if 128 bit long doubles are enabled.
 #  MALLOC: malloc related function.
 #
@@ -25,24 +26,36 @@
 __32_ssignal
 __64_signal
 __64_ssignal
+__posix__exit
+__posix_exit
+__posix_kill
+__posix_long_gid_kill
+__unix_getuid
+__utc_fstat
 __utc_localtime
-__utc_localtime_t
+__utc_localtime_r
+__utc_lstat
 __utc_stat
+__utc_strftime
 __utc_time
 __utctz_gmtime
 __utctz_localtime
-__utctz_localtime_t
+__utctz_localtime_r
 abort
 abs
 accept
 access
 acos  FLOAT
 alarm
+asctime
+asctime_r
 asin  FLOAT
 atan  FLOAT
 atan2 FLOAT
 atexit
+atof  FLOAT
 atoi
+atol
 atoll
 atoq
 basename  64
@@ -53,38 +66,55 @@
 calloc64 MALLOC
 ceil  FLOAT
 chdir
+chmod
 chown
 clearerr
 clock
 close
+closedir
 connect
 cos   FLOAT
 ctermid   64
 ctime
+dlclose
+dlerror
+dlopen
+dlsym
 dup
 dup2
 environ   GLOBAL
+execv
+execve
+execvp
 exit
 exp   FLOAT
 fabs  FLOAT
 fclose
+fcntl
 fdopen
+feof
+ferror
 fflush
 ffs
 fgetc
+fgetname  64 MALLOC
 fgets 64
+fileno
 floor FLOAT
 fopen
+fpathconf
 fprintf   FLOAT LDBL
 fputc
 fputs
 fread
 free
 freopen
+frexpFLOAT
 fseek
 ftell
 fwrite
 getc
+getchar
 getcwd64
 getegid
 getenv
@@ -92,10 +122,14 @@
 getgid
 gethostbyaddr
 gethostbyname
+getname
 getpagesize
 getpid
+getpwent
+getpwnam
 getservbyname
 getservbyport
+getsockopt
 gettimeofday
 getuid
 gmtime
@@ -103,16 +137,29 @@
 iconv
 index 64
 ioctl
+isalnum
+isalpha
+isapipe
+isascii
 isatty
+iscntrl
 isdigit
+isgraph
 islower
 isprint
+ispunct
 isspace
 isupper
+isxdigit
 kill
+ldexp FLOAT
+locale
+localeconv
 localtime
+localtime_r
 log   FLOAT
 log10 FLOAT
+longjmp
 lseek
 malloc64 MALLOC
 mbstowcs  64
@@ -126,10 +173,14 @@
 mktemp64
 mmap  64
 munmap
+nanosleep
 nl_langinfo
 open
+opendir
+pathconf
 pclose
 perror
+pipe
 popen
 pow   FLOAT
 printfFLOAT LDBL
@@ -138,58 +189,79 @@
 putenv
 puts
 qsort 64
+raise
 random
 read
+readdir
 realloc   64 MALLOC
 recv
 recvfrom
 recvmsg   BSD44 64
+remove
 rename
 rewind
 rindex64
 rmdir
+scanf FLOAT LDBL
+select
 send
 sendmsg   BSD44 64
 sendto
+setbuf
 setenv
 setlocale
+setpwent
+setsockopt
 setvbuf
+siglongjmp
 signal
+sigsetjmp
 sigsetmask
 sin   FLOAT
+sleep
 snprintf  FLOAT LDBL
 socket
 sprintf  FLOAT LDBL
 sqrt  FLOAT
+sscanfFLOAT LDBL
 stat
 strcasecmp
 strcat64
 strchr64
 strcmp
 strcpy64
+strcspn
 strdup64 MALLOC
 strerror
 strlen
 strncasecmp
+strncat   64
 strncmp
 strncpy   64
+strpbrk   64
 strrchr   64
+strspn
 strstr64
 strtod64 FLOAT
+strtok64 MALLOC
+strtok_r  64 MALLOC
 strtol64
 strtoul   64
 sysconf
 system
 tan   FLOAT
+tempnam
 time
 times
 tmpfile
 tmpnam64
 tolower
 toupper
+ttyname
 umask
 ungetc
 unlink
+usleep
 utime
 vfprintf  FLOAT LDBL
 vprintf   FLOAT LDBL


[Ada] Adding new frontend support for inlining

2012-03-09 Thread Arnaud Charlet
This patch adjusts the behavior of the wavefront to incorporate frontend
inlining support when compiling on AMMP or VM targets. This new support
is temporarily available using -gnatd.k

 These are the rules:

  * At -O0, or compiling on AAMP or VM targets, use fe inlining when
inline_always is specified except if the function returns a controlled
type. The deprecated switch -gnatN can be used at this level.

  * At other optimization levels use the fe inlining for both inline
and inline_always in the following cases:
  - function returning a known at compile time constant
  - function returning a call to an intrinsic function
  - function returning an unconstrained type through an Ada 2005
extended return statement
  - function returning a call to a frontend-inlined function
Use the back-end mechanism otherwise

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-03-09  Javier Miranda  mira...@adacore.com

* sem_ch6.adb (Check_Body_To_Inline): In AAMP and VM targets
use frontend inlining at all optimization levels.
* sem_util.adb (Must_Inline): In AAMP and VM targets, given that
there is no inlining support in the backend, use also frontend
inlining when compiling with optimizations enabled.
* exp_ch6.adb (Expand_Call): Minor code reorganization.

Index: sem_util.adb
===
--- sem_util.adb(revision 185136)
+++ sem_util.adb(working copy)
@@ -9422,7 +9422,13 @@
 
function Must_Inline (Subp : Entity_Id) return Boolean is
begin
-  return Optimization_Level = 0
+  --  AAMP and VM targets have no support for inlining in the backend.
+  --  Hence we do as much inlining as possible in the front end.
+
+  return
+(Optimization_Level = 0
+   or else AAMP_On_Target
+   or else VM_Target /= No_VM)
 and then Has_Pragma_Inline (Subp)
 and then (Has_Pragma_Inline_Always (Subp) or else Front_End_Inlining);
end Must_Inline;
Index: exp_ch6.adb
===
--- exp_ch6.adb (revision 185136)
+++ exp_ch6.adb (working copy)
@@ -3790,10 +3790,7 @@
Spec : constant Node_Id := Unit_Declaration_Node (Subp);
 
 begin
-   if Optimization_Level  0 then
-  Do_Inline (Subp, Orig_Subp);
-
-   elsif Must_Inline (Subp) then
+   if Must_Inline (Subp) then
   if In_Extended_Main_Code_Unit (Call_Node)
 and then In_Same_Extended_Unit (Sloc (Spec), Loc)
 and then not Has_Completion (Subp)
@@ -3805,6 +3802,9 @@
   else
  Do_Inline_Always (Subp, Orig_Subp);
   end if;
+
+   elsif Optimization_Level  0 then
+  Do_Inline (Subp, Orig_Subp);
end if;
 
--  The call may have been inlined or may have been passed to
Index: sem_ch6.adb
===
--- sem_ch6.adb (revision 185136)
+++ sem_ch6.adb (working copy)
@@ -4888,9 +4888,13 @@
  Remove (Body_To_Analyze);
 
  --  Keep separate checks needed when compiling without optimizations
+ --  AAMP and VM targets have no support for inlining in the backend
+ --  and hence we use frontend inlining at all optimization levels.
 
- if Optimization_Level = 0 then
-
+ if Optimization_Level = 0
+   or else AAMP_On_Target
+   or else VM_Target /= No_VM
+ then
 --  Cannot inline functions whose body has a call that returns an
 --  unconstrained type since the secondary stack is involved, and
 --  it is not worth inlining.


[Ada] Fix Current_Directory behavior for root dirs on Windows

2012-03-09 Thread Arnaud Charlet
Current_Directory incorrectly returned the path of the form X:
instead of X:\

Manually tested on i686-pc-mingw32.
Tested on x86_64-pc-linux-gnu, committed on trunk

2012-03-09  Vasiliy Fofanov  fofa...@adacore.com

* a-direct.adb: Do not strip the trailing directory separator
from path, as this is already done inside Normalize_Pathname;
doing it again produces the wrong result on Windows for the
drive's root dir (i.e. X:\ becomes X:).

Index: a-direct.adb
===
--- a-direct.adb(revision 185136)
+++ a-direct.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 2004-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 2004-2012, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -514,18 +514,10 @@
begin
   Local_Get_Current_Dir (Buffer'Address, Path_Len'Address);
 
-  declare
- --  We need to resolve links because of A.16(47), since we must not
- --  return alternative names for files
- Cur : constant String := Normalize_Pathname (Buffer (1 .. Path_Len));
+  --  We need to resolve links because of A.16(47), since we must not
+  --  return alternative names for files
+  return Normalize_Pathname (Buffer (1 .. Path_Len));
 
-  begin
- if Cur'Length  1 and then Cur (Cur'Last) = Dir_Separator then
-return Cur (1 .. Cur'Last - 1);
- else
-return Cur;
- end if;
-  end;
end Current_Directory;
 
--


[Ada] Front-end support for attribute Scalar_Storage_Order

2012-03-09 Thread Arnaud Charlet
This change adds the front-end support for new representation attribute/aspect
Scalar_Storage_Order.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-03-09  Thomas Quinot  qui...@adacore.com

* exp_attr.adb, freeze.adb, sem_attr.adb, aspects.adb, aspects.ads,
sem_ch13.adb, snames.ads-tmpl (Exp_Attr.Expand_N_Attribute_Reference):
Add Attribute_Scalar_Storage_Order.
(Sem_Attr.Analyze_Attribute, Eval_Attribute): Ditto.
(Aspects): Add Aspect_Scalar_Storage_Order (Snames): Add
Name_Scalar_Storage_Order and Attribute_Scalar_Storage_Order.
(Sem_Ch13.Analyze_Attribute_Definition_Clause): Add processing
for Scalar_Storage_Order.
(Freeze): If Scalar_Storage_Order is specified, check that it
is compatible with Bit_Order.

Index: exp_attr.adb
===
--- exp_attr.adb(revision 185136)
+++ exp_attr.adb(working copy)
@@ -5672,7 +5672,8 @@
Attribute_Definite |
Attribute_Null_Parameter   |
Attribute_Passed_By_Reference  |
-   Attribute_Pool_Address =
+   Attribute_Pool_Address |
+   Attribute_Scalar_Storage_Order =
  null;
 
   --  The following attributes are also handled by the back end, but return
Index: freeze.adb
===
--- freeze.adb  (revision 185136)
+++ freeze.adb  (working copy)
@@ -2129,6 +2129,28 @@
 Next_Entity (Comp);
  end loop;
 
+ --  Check compatibility of Scalar_Storage_Order with Bit_Order, if the
+ --  former is specified.
+
+ ADC := Get_Attribute_Definition_Clause
+  (Rec, Attribute_Scalar_Storage_Order);
+
+ if Present (ADC)
+  and then
+Reverse_Bit_Order (Rec) /= Reverse_Storage_Order (Rec)
+ then
+if Bytes_Big_Endian = not Reverse_Storage_Order (Rec) then
+   Error_Msg_N
+ (Scalar_Storage_Order High_Order_First is inconsistent with
+Bit_Order, ADC);
+else
+   Error_Msg_N
+ (Scalar_Storage_Order Low_Order_First is inconsistent with
+Bit_Order, ADC);
+
+end if;
+ end if;
+
  --  Deal with Bit_Order aspect specifying a non-default bit order
 
  if Reverse_Bit_Order (Rec) and then Base_Type (Rec) = Rec then
Index: sem_attr.adb
===
--- sem_attr.adb(revision 185136)
+++ sem_attr.adb(working copy)
@@ -4442,6 +4442,35 @@
  Check_Object_Reference (E1);
  Set_Etype (N, Standard_Boolean);
 
+  --
+  -- Scalar_Storage_Order --
+  --
+
+  when Attribute_Scalar_Storage_Order = Scalar_Storage_Order :
+  begin
+ Check_E0;
+ Check_Type;
+
+ if not Is_Record_Type (P_Type) then
+Error_Attr_P (prefix of % attribute must be record type);
+ end if;
+
+ if Bytes_Big_Endian xor Reverse_Storage_Order (P_Type) then
+Rewrite (N,
+  New_Occurrence_Of (RTE (RE_High_Order_First), Loc));
+ else
+Rewrite (N,
+  New_Occurrence_Of (RTE (RE_Low_Order_First), Loc));
+ end if;
+
+ Set_Etype (N, RTE (RE_Bit_Order));
+ Resolve (N);
+
+ --  Reset incorrect indication of staticness
+
+ Set_Is_Static_Expression (N, False);
+  end Scalar_Storage_Order;
+
   ---
   -- Scale --
   ---
@@ -7963,6 +7992,7 @@
Attribute_Priority   |
Attribute_Read   |
Attribute_Result |
+   Attribute_Scalar_Storage_Order   |
Attribute_Simple_Storage_Pool|
Attribute_Storage_Pool   |
Attribute_Storage_Size   |
Index: aspects.adb
===
--- aspects.adb (revision 185136)
+++ aspects.adb (working copy)
@@ -278,6 +278,7 @@
 Aspect_Pure_12  = Aspect_Pure_12,
 Aspect_Remote_Call_Interface= Aspect_Remote_Call_Interface,
 Aspect_Remote_Types = Aspect_Remote_Types,
+Aspect_Scalar_Storage_Order = Aspect_Scalar_Storage_Order,
 Aspect_Shared_Passive   = Aspect_Shared_Passive,
 Aspect_Universal_Data   = Aspect_Universal_Data,
 Aspect_Input= Aspect_Input,
Index: aspects.ads
===
--- aspects.ads (revision 185136)
+++ aspects.ads (working copy)
@@ -74,6 +74,7 @@
   Aspect_Predicate, 

[Ada] Expansion of of iterator loop over multidimensional arrays

2012-03-09 Thread Arnaud Charlet
This patch implements the expansion of the so-called of iterator over
multidimensional arrays (for Element of Array loop).

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-03-09  Vincent Pucci  pu...@adacore.com

* exp_ch5.adb (Expand_Iterator_Loop):
Call to Expand_Iterator_Loop_Over_Array added.
(Expand_Iterator_Loop_Over_Array): New routine. Expansion of
of iterator loop over arrays. Multidimensional array case added.

Index: exp_ch5.adb
===
--- exp_ch5.adb (revision 185136)
+++ exp_ch5.adb (working copy)
@@ -107,6 +107,9 @@
--  Expand loop over arrays and containers that uses the form for X of C
--  with an optional subtype mark, or for Y in C.
 
+   procedure Expand_Iterator_Loop_Over_Array (N : Node_Id);
+   --  Expand loop over arrays that uses the form for X of C
+
procedure Expand_Predicated_Loop (N : Node_Id);
--  Expand for loop over predicated subtype
 
@@ -2946,369 +2949,432 @@
   --  Processing for arrays
 
   if Is_Array_Type (Container_Typ) then
+ Expand_Iterator_Loop_Over_Array (N);
+ return;
+  end if;
 
- --  for Element of Array loop
- --
- --  This case requires an internally generated cursor to iterate over
- --  the array.
+  --  Processing for containers
 
- if Of_Present (I_Spec) then
-Iterator := Make_Temporary (Loc, 'C');
+  --  For an of iterator the name is a container expression, which
+  --  is transformed into a call to the default iterator.
 
---  Generate:
---Element : Component_Type renames Container (Iterator);
+  --  For an iterator of the form in the name is a function call
+  --  that delivers an iterator type.
 
-Prepend_To (Stats,
-  Make_Object_Renaming_Declaration (Loc,
-Defining_Identifier = Id,
-Subtype_Mark =
-  New_Reference_To (Component_Type (Container_Typ), Loc),
-Name =
-  Make_Indexed_Component (Loc,
-Prefix = Relocate_Node (Container),
-Expressions = New_List (
-  New_Reference_To (Iterator, Loc);
+  --  In both cases, analysis of the iterator has introduced an object
+  --  declaration to capture the domain, so that Container is an entity.
 
- --  for Index in Array loop
+  --  The for loop is expanded into a while loop which uses a container
+  --  specific cursor to desgnate each element.
 
- --  This case utilizes the already given iterator name
+  --Iter : Iterator_Type := Container.Iterate;
+  --Cursor : Cursor_type := First (Iter);
+  --while Has_Element (Iter) loop
+  --   declare
+  --   --  The block is added when Element_Type is controlled
 
+  --  Obj : Pack.Element_Type := Element (Cursor);
+  --  --  for the of loop form
+  --   begin
+  --  original loop statements
+  --   end;
+
+  --   Cursor := Iter.Next (Cursor);
+  --end loop;
+
+  --  If reverse is present, then the initialization of the cursor
+  --  uses Last and the step becomes Prev. Pack is the name of the
+  --  scope where the container package is instantiated.
+
+  declare
+ Element_Type : constant Entity_Id := Etype (Id);
+ Iter_Type: Entity_Id;
+ Pack : Entity_Id;
+ Decl : Node_Id;
+ Name_Init: Name_Id;
+ Name_Step: Name_Id;
+
+  begin
+ --  The type of the iterator is the return type of the Iterate
+ --  function used. For the of form this is the default iterator
+ --  for the type, otherwise it is the type of the explicit
+ --  function used in the iterator specification. The most common
+ --  case will be an Iterate function in the container package.
+
+ --  The primitive operations of the container type may not be
+ --  use-visible, so we introduce the name of the enclosing package
+ --  in the declarations below. The Iterator type is declared in a
+ --  an instance within the container package itself.
+
+ --  If the container type is a derived type, the cursor type is
+ --  found in the package of the parent type.
+
+ if Is_Derived_Type (Container_Typ) then
+Pack := Scope (Root_Type (Container_Typ));
  else
-Iterator := Id;
+Pack := Scope (Container_Typ);
  end if;
 
- --  Generate:
- --for Iterator in [reverse] Container'Range loop
- --   Element : Component_Type renames Container (Iterator);
- --   --  for the of form
+ Iter_Type := Etype (Name (I_Spec));
 
- --   original loop statements
- --end loop;
+ 

[PATCH] Fix up register_edge_assert_for_2 (PR tree-optimization/52533)

2012-03-09 Thread Jakub Jelinek
Hi!

My recent commit to tree-vrp.c on the trunk caused the following
testcase to fail, the problem is that we would insert = 255
assertion for unsigned char expression (which doesn't say anything)
and VRP insist that such ASSERT_EXPRs aren't added.

Fixed thusly, in addition the patch cleans the code slightly,
e.g. by using double_int instead of a pair of uHWIs.

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

2012-03-09  Jakub Jelinek  ja...@redhat.com

PR tree-optimization/52533
* tree-vrp.c (register_edge_assert_for_2): Use double_int
type for mask, only handle shifts by non-zero in-range
shift count, for LE_EXPR and GT_EXPR if new_val is
maximum, don't add the assertion.

* gcc.c-torture/compile/pr52533.c: New test.

--- gcc/tree-vrp.c.jj   2012-03-09 10:26:26.0 +0100
+++ gcc/tree-vrp.c  2012-03-09 12:30:19.348501480 +0100
@@ -4470,7 +4470,8 @@ register_edge_assert_for_2 (tree name, e
   gimple def_stmt = SSA_NAME_DEF_STMT (name);
   tree name2 = NULL_TREE, cst2 = NULL_TREE;
   tree val2 = NULL_TREE;
-  unsigned HOST_WIDE_INT mask[2] = { 0, 0 };
+  double_int mask = double_int_zero;
+  unsigned int prec = TYPE_PRECISION (TREE_TYPE (val));
 
   /* Extract CST2 from the right shift.  */
   if (is_gimple_assign (def_stmt)
@@ -4480,23 +4481,13 @@ register_edge_assert_for_2 (tree name, e
  cst2 = gimple_assign_rhs2 (def_stmt);
  if (TREE_CODE (name2) == SSA_NAME
   host_integerp (cst2, 1)
-  (unsigned HOST_WIDE_INT) tree_low_cst (cst2, 1)
- 2 * HOST_BITS_PER_WIDE_INT
   INTEGRAL_TYPE_P (TREE_TYPE (name2))
+  IN_RANGE (tree_low_cst (cst2, 1), 1, prec - 1)
+  prec = 2 * HOST_BITS_PER_WIDE_INT
   live_on_edge (e, name2)
   !has_single_use (name2))
{
- if ((unsigned HOST_WIDE_INT) tree_low_cst (cst2, 1)
-  HOST_BITS_PER_WIDE_INT)
-   mask[0] = ((unsigned HOST_WIDE_INT) 1
-   tree_low_cst (cst2, 1)) - 1;
- else
-   {
- mask[1] = ((unsigned HOST_WIDE_INT) 1
- (tree_low_cst (cst2, 1)
-- HOST_BITS_PER_WIDE_INT)) - 1;
- mask[0] = -1;
-   }
+ mask = double_int_mask (tree_low_cst (cst2, 1));
  val2 = fold_binary (LSHIFT_EXPR, TREE_TYPE (val), val, cst2);
}
}
@@ -4515,37 +4506,40 @@ register_edge_assert_for_2 (tree name, e
{
  if (!TYPE_UNSIGNED (TREE_TYPE (val)))
{
- unsigned int prec = TYPE_PRECISION (TREE_TYPE (val));
  tree type = build_nonstandard_integer_type (prec, 1);
  tmp = build1 (NOP_EXPR, type, name2);
  val2 = fold_convert (type, val2);
}
  tmp = fold_build2 (MINUS_EXPR, TREE_TYPE (tmp), tmp, val2);
- new_val = build_int_cst_wide (TREE_TYPE (tmp), mask[0], mask[1]);
+ new_val = double_int_to_tree (TREE_TYPE (tmp), mask);
  new_comp_code = comp_code == EQ_EXPR ? LE_EXPR : GT_EXPR;
}
  else if (comp_code == LT_EXPR || comp_code == GE_EXPR)
new_val = val2;
  else
{
- new_val = build_int_cst_wide (TREE_TYPE (val2),
-   mask[0], mask[1]);
- new_val = fold_binary (BIT_IOR_EXPR, TREE_TYPE (val2),
-val2, new_val);
+ mask = double_int_ior (tree_to_double_int (val2), mask);
+ if (double_int_minus_one_p (double_int_sext (mask, prec)))
+   new_val = NULL_TREE;
+ else
+   new_val = double_int_to_tree (TREE_TYPE (val2), mask);
}
 
- if (dump_file)
+ if (new_val)
{
- fprintf (dump_file, Adding assert for );
- print_generic_expr (dump_file, name2, 0);
- fprintf (dump_file,  from );
- print_generic_expr (dump_file, tmp, 0);
- fprintf (dump_file, \n);
-   }
+ if (dump_file)
+   {
+ fprintf (dump_file, Adding assert for );
+ print_generic_expr (dump_file, name2, 0);
+ fprintf (dump_file,  from );
+ print_generic_expr (dump_file, tmp, 0);
+ fprintf (dump_file, \n);
+   }
 
- register_new_assert_for (name2, tmp, new_comp_code, new_val,
-  NULL, e, bsi);
- retval = true;
+ register_new_assert_for (name2, tmp, new_comp_code, new_val,
+  NULL, e, bsi);
+ retval = true;
+   }
}
 }
 
--- gcc/testsuite/gcc.c-torture/compile/pr52533.c.jj

[PATCH] Further VRP improvements (take 2)

2012-03-09 Thread Jakub Jelinek
On Thu, Mar 08, 2012 at 04:54:31PM +0100, Jakub Jelinek wrote:
 This patch adds ASSERT_EXPRs for
 if ((int) var cmp CST)
 (for cmp , =, , =).  As the testcase shows, various different tests
 are folded into that form.
 
 Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

This patch no longer applies after the PR tree-optimization/52533 fix,
so here is an updated patch that does apply and contains a tiny cleanup too:

2012-03-09  Jakub Jelinek  ja...@redhat.com

PR tree-optimization/51721
* tree-vrp.c (register_edge_assert_for_2): Add asserts for unsvar
if (int) unsvar cmp CST.

* gcc.dg/tree-ssa/vrp64.c: New test.

--- gcc/tree-vrp.c.jj   2012-03-09 12:30:19.348501480 +0100
+++ gcc/tree-vrp.c  2012-03-09 12:53:41.844227149 +0100
@@ -4462,8 +4462,6 @@ register_edge_assert_for_2 (tree name, e
}
 }
 
-  /* Similarly add asserts for NAME == CST and NAME being defined as
- NAME = NAME2  CST2.  */
   if (TREE_CODE_CLASS (comp_code) == tcc_comparison
TREE_CODE (val) == INTEGER_CST)
 {
@@ -4473,7 +4471,60 @@ register_edge_assert_for_2 (tree name, e
   double_int mask = double_int_zero;
   unsigned int prec = TYPE_PRECISION (TREE_TYPE (val));
 
-  /* Extract CST2 from the right shift.  */
+  /* Add asserts for NAME cmp CST and NAME being defined
+as NAME = (int) NAME2.  */
+  if (!TYPE_UNSIGNED (TREE_TYPE (val))
+  (comp_code == LE_EXPR || comp_code == LT_EXPR
+ || comp_code == GT_EXPR || comp_code == GE_EXPR)
+  gimple_assign_cast_p (def_stmt))
+   {
+ name2 = gimple_assign_rhs1 (def_stmt);
+ if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))
+  INTEGRAL_TYPE_P (TREE_TYPE (name2))
+  TYPE_UNSIGNED (TREE_TYPE (name2))
+  prec == TYPE_PRECISION (TREE_TYPE (name2))
+  (comp_code == LE_EXPR || comp_code == GT_EXPR
+ || !tree_int_cst_equal (val,
+ TYPE_MIN_VALUE (TREE_TYPE (val
+  live_on_edge (e, name2)
+  !has_single_use (name2))
+   {
+ tree tmp, cst;
+ enum tree_code new_comp_code = comp_code;
+
+ cst = fold_convert (TREE_TYPE (name2),
+ TYPE_MIN_VALUE (TREE_TYPE (val)));
+ /* Build an expression for the range test.  */
+ tmp = build2 (PLUS_EXPR, TREE_TYPE (name2), name2, cst);
+ cst = fold_build2 (PLUS_EXPR, TREE_TYPE (name2), cst,
+fold_convert (TREE_TYPE (name2), val));
+ if (comp_code == LT_EXPR || comp_code == GE_EXPR)
+   {
+ new_comp_code = comp_code == LT_EXPR ? LE_EXPR : GT_EXPR;
+ cst = fold_build2 (MINUS_EXPR, TREE_TYPE (name2), cst,
+build_int_cst (TREE_TYPE (name2), 1));
+   }
+
+ if (dump_file)
+   {
+ fprintf (dump_file, Adding assert for );
+ print_generic_expr (dump_file, name2, 0);
+ fprintf (dump_file,  from );
+ print_generic_expr (dump_file, tmp, 0);
+ fprintf (dump_file, \n);
+   }
+
+ register_new_assert_for (name2, tmp, new_comp_code, cst, NULL,
+  e, bsi);
+
+ retval = true;
+   }
+   }
+
+  /* Add asserts for NAME cmp CST and NAME being defined as
+NAME = NAME2  CST2.
+
+Extract CST2 from the right shift.  */
   if (is_gimple_assign (def_stmt)
   gimple_assign_rhs_code (def_stmt) == RSHIFT_EXPR)
{
@@ -4491,7 +4542,6 @@ register_edge_assert_for_2 (tree name, e
  val2 = fold_binary (LSHIFT_EXPR, TREE_TYPE (val), val, cst2);
}
}
-
   if (val2 != NULL_TREE
   TREE_CODE (val2) == INTEGER_CST
   simple_cst_equal (fold_build2 (RSHIFT_EXPR,
--- gcc/testsuite/gcc.dg/tree-ssa/vrp64.c.jj2012-03-09 12:45:23.287171268 
+0100
+++ gcc/testsuite/gcc.dg/tree-ssa/vrp64.c   2012-03-09 12:45:23.287171268 
+0100
@@ -0,0 +1,152 @@
+/* PR tree-optimization/51721 */
+/* { dg-do link } */
+/* { dg-options -O2 } */
+
+extern void link_error (void);
+
+#define BITSM1 (sizeof (int) * __CHAR_BIT__ - 1)
+
+void
+f1 (unsigned int s)
+{
+  if (s  BITSM1 != 0)
+{
+  if (s == 0 || s == 5 || s == __INT_MAX__)
+   link_error ();
+}
+  else
+{
+  if (s == 1U + __INT_MAX__ || s == 6U + __INT_MAX__ || s == -1U)
+   link_error ();
+}
+}
+
+void
+f2 (int s)
+{
+  if (s  BITSM1 == 0)
+{
+  if (s == -1 || s == -5 || s == -__INT_MAX__ - 1)
+   link_error ();
+}
+  else
+{
+  if (s == 0 || s == 5 || s == __INT_MAX__)
+   link_error ();
+}
+}
+
+void
+f3 (unsigned int s)
+{
+  if ((s  (1U  BITSM1)) != 0)
+{
+  if (s == 0 || s == 5 || s == 

Re: [PATCH 02/10] addr32: Only handle zero-extended DImode addresses

2012-03-09 Thread H.J. Lu
On Thu, Mar 8, 2012 at 7:20 AM, Uros Bizjak ubiz...@gmail.com wrote:
 On Sun, Mar 4, 2012 at 9:13 PM, Uros Bizjak ubiz...@gmail.com wrote:

 We only need to handle zero-extended addresses in DImode.
 OK for trunk?

 2012-03-02  H.J. Lu  hongjiu...@intel.com

        * config/i386/i386.c (ix86_print_operand_address): Only handle
        zero-extended DImode addresses.

 OK.

 The patch was reverted due to PR target/52530.


Revert breaks Pmode == SImode for x32.  Here is a different patch.
It checks Pmode == DImode instead of TARGET_64BIT.  Tested on
Linux/x32.  OK for trunk?

Thanks.

-- 
H.J.

2012-03-08  H.J. Lu  hongjiu...@intel.com

* config/i386/i386.c (ix86_print_operand_address): Only handle
zero-extended DImode addresses if Pmode == DImode.
2012-03-08  H.J. Lu  hongjiu...@intel.com

* config/i386/i386.c (ix86_print_operand_address): Only handle
zero-extended DImode addresses if Pmode == DImode.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 69cb6ae..c2cad5a 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -14548,7 +14548,7 @@ ix86_print_operand_address (FILE *file, rtx addr)
 
   /* Print SImode registers for zero-extended addresses to force
 addr32 prefix.  Otherwise print DImode registers to avoid it.  */
-  if (TARGET_64BIT)
+  if (Pmode == DImode)
code = ((GET_CODE (addr) == ZERO_EXTEND
 || GET_CODE (addr) == AND)
? 'l'


[PATCH] Don’t insert white space in ‘orig_option_with_args_text’ for OPT_l

2012-03-09 Thread Ludovic Courtès
Hi,

This patch changes ‘generate_option’ to not insert any white spaces
after ‘-l’.

This fixes a problem introduced in GCC 4.6 (r163459) whereby
‘gfortran -v’ would emit erroneous strings like this:

  Driving: […] -l gfortran -l m -shared-libgcc […]

Note the space after ‘-l’.

(In turn, that would confuse Libtool’s ‘_LT_SYS_HIDDEN_LIBDEPS’ macro,
which would determine something like this:

  postdeps=[…] 
-L/nix/store/wnzgsfhmb3ys5ssfgpcpwjnmdzn717mk-gfortran-4.6.3/lib -l -l […]

eventually leading to a link command-line like this:

  libtool: link: gfortran -shared […] -l 
-L/nix/store/blsdhiik2lk4zmz3hbzf77g6hcrq7ckx-gfortran-wrapper-4.6.3/bin […]

leading to an error like:

  ld: cannot find 
-l-L/nix/store/blsdhiik2lk4zmz3hbzf77g6hcrq7ckx-gfortran-wrapper-4.6.3/bin

Ouch!)

Thanks,
Ludo’.

2012-03-09  Ludovic Courtès  ludovic.cour...@inria.fr

* gcc/opts-common.c (generate_option): Don't insert white space in
`canonical_option' when OPT_INDEX is OPT_l.

diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 354bce0..60ec02d 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -931,6 +931,12 @@ generate_option (size_t opt_index, const char *arg, int value,
   break;
 
 case 2:
+  if (opt_index == OPT_l)
+	/* Don't insert any white spaces between `-l' and its argument.  */
+	decoded-orig_option_with_args_text
+	  = concat (decoded-canonical_option[0],
+		decoded-canonical_option[1], NULL);
+  else
   decoded-orig_option_with_args_text
 	= concat (decoded-canonical_option[0],  ,
 		  decoded-canonical_option[1], NULL);


pgpI71dhyx4sL.pgp
Description: PGP signature


Re: [PATCH] Make powerpc honor PROCESSOR_DEFAULT{,64} in tm*.h files

2012-03-09 Thread David Edelsohn
On Thu, Mar 8, 2012 at 1:17 PM, Michael Meissner
meiss...@linux.vnet.ibm.com wrote:
 David noticed that I set default_cpu twice in my previous patch.  This patch
 fixes that, and also updates the ChangeLog message to indicate fixing some
 tests for using = 0 instead of  0, since processor 0 is a valid index.  I've
 bootstrapped both 4.7 and 4.8 with this new patch.  Is it ok to install?  As I
 said, in the original message, we would like to install in 4.7 rather than
 waiting for 4.7.1.

 2012-03-08  Michael Meissner  meiss...@the-meissners.org

        * config/rs6000/linux64.h (OPTION_TARGET_CPU_DEFAULT): Do not
        redefine to be NULL if the current bit-size is different from the
        configured bit-size.

        * config/rs6000/rs6000.c (rs6000_option_override_internal): If the
        cpu is defaulted, use PROCESSOR_DEFAULT and PROCESSOR_DEFAULT64 to
        set the default tuning.  Add asserts to make sure the cpu and tune
        indexes are defined.  Fix tests for cpu/tune index to use = 0 to
        test whether the index is set, instead of  0.
        (rs6000_file_start): Do not reset the default cpu if the current
        bit-size is different from the configured bit-size.

This patch is okay.

Let's try this on trunk and hopefully it can be included in the
release candidate.

Thanks, David


[PATCH][Cilkplus] elemental functions parsing patch

2012-03-09 Thread Iyer, Balaji V
 Hello Everyone,
   This patch is for the Cilkplus branch affecting mainly the C compiler. This 
patch will start the implementation of elemental functions in the branch. This 
patch will parse the elemental function attributes in the C compiler

Thanking You,

Yours Sincerely,

Balaji V. Iyer.diff --git a/gcc/ChangeLog.cilk b/gcc/ChangeLog.cilk
index ebabff6..1398870 100644
--- a/gcc/ChangeLog.cilk
+++ b/gcc/ChangeLog.cilk
@@ -1,3 +1,15 @@
+2012-03-09  Balaji V. Iyer  balaji.v.i...@intel.com
+
+   * attribs.c (decl_attributes): Added a check for elemental function
+   attribute.
+   (is_elem_fn_attribute_p): New function.
+   * c-parser.c (c_parser_attributes): Added a check for vector attribute.
+   (c_parser_elem_fn_processor_clause): New function.
+   (c_parser_elem_fn_uniform_clause): Likewise.
+   (c_parser_elem_fn_linear_clause): Likewise.
+   (c_parser_elem_fn_vlength_clause): Likewise.
+   (c_parser_elem_fn_expr_list): Likewise.
+
 2012-02-15  Balaji V. Iyer  balaji.v.i...@intel.com
 
* cilk.c (cilk_fix_stack_reg): New function.
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 0e94fd2..2ececc4 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -228,6 +228,18 @@ lookup_attribute_spec (const_tree name)
 substring_hash (attr.str, attr.length));
 }
 
+
+static bool
+is_elem_fn_attribute_p (tree name)
+{
+  return is_attribute_p (mask, name)
+|| is_attribute_p (unmask, name)
+|| is_attribute_p (vectorlength, name)
+|| is_attribute_p (vector, name)
+|| is_attribute_p (linear, name)
+|| is_attribute_p (uniform, name);
+}
+
 /* Process the attributes listed in ATTRIBUTES and install them in *NODE,
which is either a DECL (including a TYPE_DECL) or a TYPE.  If a DECL,
it should be modified in place; if a TYPE, a copy should be created
@@ -312,8 +324,9 @@ decl_attributes (tree *node, tree attributes, int flags)
 
   if (spec == NULL)
{
- warning (OPT_Wattributes, %qE attribute directive ignored,
-  name);
+ if (!is_elem_fn_attribute_p (name))
+   warning (OPT_Wattributes, %qE attribute directive ignored,
+name);
  continue;
}
   else if (list_length (args)  spec-min_length
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index c67ea97..4f940e1 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -65,6 +65,7 @@ extern struct c_expr  fix_array_notation_expr (location_t, 
enum tree_code,
 extern bool contains_array_notation_expr (tree);
 struct pragma_simd_values local_simd_values;
 
+   
 
 /* Initialization routine for this file.  */
 
@@ -242,6 +243,8 @@ typedef struct GTY(()) c_parser {
 
 static GTY (()) c_parser *the_parser;
 
+static VEC(tree,gc) *c_parser_elem_fn_expr_list (c_parser *parser);
+
 /* Read in and lex a single token, storing it in *TOKEN.  */
 
 static void
@@ -3635,7 +3638,12 @@ c_parser_attributes (c_parser *parser)
attr_args = NULL_TREE;
  else
{
- expr_list = c_parser_expr_list (parser, false, true, NULL);
+ if (TREE_CODE (attr_name) == IDENTIFIER_NODE
+  simple_cst_equal (attr_name,
+  get_identifier (vector)) == 1)
+   expr_list = c_parser_elem_fn_expr_list (parser);
+ else
+   expr_list = c_parser_expr_list (parser, false, true, NULL);
  attr_args = build_tree_list_vec (expr_list);
  release_tree_vector (expr_list);
}
@@ -11870,4 +11878,421 @@ c_parser_array_notation (c_parser *parser, tree 
initial_index, tree array_value)
   return value_tree;
 }
 
+static tree
+c_parser_elem_fn_processor_clause (c_parser *parser)
+{
+  c_token *token;
+  tree proc_tree_list = NULL_TREE;
+  VEC(tree,gc) *proc_vec_list = NULL;
+
+  token = c_parser_peek_token (parser);
+  if (!c_parser_next_token_is (parser, CPP_OPEN_PAREN))
+{
+  c_parser_error (parser, expected %)%);
+  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
+  return NULL_TREE;
+}
+  else
+c_parser_consume_token (parser);
+
+  proc_vec_list = make_tree_vector ();
+  
+  if (!c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
+{
+  token = c_parser_peek_token (parser);
+  if (token-value  TREE_CODE (token-value) == IDENTIFIER_NODE
+  simple_cst_equal (token-value, get_identifier (pentium_4)) == 1)
+   {
+ c_parser_consume_token (parser);
+ VEC_safe_push (tree, gc, proc_vec_list,
+build_string (strlen (pentium_4), pentium_4));
+   }
+  else if (token-value  TREE_CODE (token-value) == IDENTIFIER_NODE
+   simple_cst_equal (token-value,
+   get_identifier (pentium4_sse3)) == 1)
+   {
+ c_parser_consume_token (parser);
+ VEC_safe_push (tree, gc, 

Re: [PATCH, 4.5, 4.6] Fix PR50181 by backporting mainline reload.c patches

2012-03-09 Thread Peter Bergner
I'd like to ping this patch backport:

http://gcc.gnu.org/ml/gcc-patches/2012-02/msg01428.html


Peter





Re: [PATCH] Make powerpc honor PROCESSOR_DEFAULT{,64} in tm*.h files

2012-03-09 Thread Michael Meissner
On Fri, Mar 09, 2012 at 11:04:17AM -0500, David Edelsohn wrote:
 Let's try this on trunk and hopefully it can be included in the
 release candidate.

Committed, subversion id 185146.

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



Re: [patch, libffi] Sync merge libffi

2012-03-09 Thread Mike Stump
On Mar 9, 2012, at 4:45 AM, Iain Sandoe wrote:
 The patch restores libffi/libjava to the pre-merge results.

 Mike, do you know any special reason that indirect-pcrel was being used there?

Nope.  The gcc repo has all the pointers to people that did all the changes...

 .. or, is this OK for trunk?

Ok from my perspective.


Re: [VMS/committed]: Do not define __size_t on VMS

2012-03-09 Thread Joseph S. Myers
On Fri, 9 Mar 2012, Tristan Gingold wrote:

 as it is already defined and used by the system headers.
 
 No regressions for x86_64-darwin after full bootstrap.
 
 Tristan.
 
 2012-03-09  Tristan Gingold  ging...@adacore.com
 
   * ginclude/stddef.h: Do not define __size_t on VMS.

Sorry, this patch is wrong.  The identifier VMS is in the user's 
namespace and users on non-VMS platforms must be able to define it as a 
macro without affecting how stddef.h behaves.  Please change this to test 
a macro in the implementation namespace instead.

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


Re: [PATCH] Don't insert white space in 'orig_option_with_args_text' for OPT_l

2012-03-09 Thread Joseph S. Myers
On Fri, 9 Mar 2012, Ludovic Court?s wrote:

   * gcc/opts-common.c (generate_option): Don't insert white space in
   `canonical_option' when OPT_INDEX is OPT_l.

No, opts-common.c should not have special cases for individual options 
like that.  The canonical form has the separate arguments.  gcc.c has a 
special case for how it passes this option to subprocesses; if you have 
problems with some output from gfortran involving -l options, you should 
change the gfortran driver as needed so it outputs -l options in a 
different way.

Your subject refers to orig_option_with_args_text while your ChangeLog 
entry refers to canonical_option.

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

[PATCH] Add missing __throw_exception_again

2012-03-09 Thread Andreas Schwab
This prevents the 22_locale/locale/cons/12352.cc test from crashing.
Tested on m68k-linux.

Andreas.

2012-03-09  Andreas Schwab  sch...@linux-m68k.org

* config/locale/gnu/monetary_members.cc
(moneypunctchar,true::_M_initialize_moneypunct): Throw caught
exception again.
(moneypunctchar,false::_M_initialize_moneypunct): Likewise.
---
 libstdc++-v3/config/locale/gnu/monetary_members.cc |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/locale/gnu/monetary_members.cc 
b/libstdc++-v3/config/locale/gnu/monetary_members.cc
index 214c4af..d1d9939 100644
--- a/libstdc++-v3/config/locale/gnu/monetary_members.cc
+++ b/libstdc++-v3/config/locale/gnu/monetary_members.cc
@@ -1,6 +1,6 @@
 // std::moneypunct implementation details, GNU version -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 
2012
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -339,6 +339,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  delete [] __group;
  delete [] __ps;
  delete [] __ns;
+ __throw_exception_again;
}
 
  char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
@@ -489,6 +490,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  delete [] __group;
  delete [] __ps;
  delete [] __ns;
+ __throw_exception_again;
}
 
  char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
-- 
1.7.9.3


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


Re: [PATCH 02/10] addr32: Only handle zero-extended DImode addresses

2012-03-09 Thread Uros Bizjak
On Fri, Mar 9, 2012 at 4:26 PM, H.J. Lu hjl.to...@gmail.com wrote:
 On Thu, Mar 8, 2012 at 7:20 AM, Uros Bizjak ubiz...@gmail.com wrote:
 On Sun, Mar 4, 2012 at 9:13 PM, Uros Bizjak ubiz...@gmail.com wrote:

 We only need to handle zero-extended addresses in DImode.
 OK for trunk?

 2012-03-02  H.J. Lu  hongjiu...@intel.com

        * config/i386/i386.c (ix86_print_operand_address): Only handle
        zero-extended DImode addresses.

 OK.

 The patch was reverted due to PR target/52530.


 Revert breaks Pmode == SImode for x32.  Here is a different patch.
 It checks Pmode == DImode instead of TARGET_64BIT.  Tested on
 Linux/x32.  OK for trunk?

This will still emit i.e. leal 1(%rSImode), %rSImode on Pmode ==
SImode targets, so you win nothing really.

Attached patch finally decouples LEA operand handling from generic
address handling, and by introducing %E operand modifier, we are able
to always emit DImode registers for LEAs (which is good anyway to
avoid unnecessary addr32 prefixes). Luckily, the leal 1(%rSImode),
%rSImode triggered some unknown problem with Sun assembler, so we
were able to detect the problem.

I would like to point out that the patched compiler now also emits
address registers in their natural mode (modulo zero-extended RTXes)
and fixes following failure on Pmode == SImode targets:

--cut here--
struct foo
{
 int *f;
 int i;
};

void
__attribute__ ((noinline))
bar (struct foo x)
{
 *(x.f) = 1;
}
--cut here--

For Pmode == SImode, the compiler emitted (%rdi) address, which was
wrong, since i was passed in the high part of (%rdi) register.

2012-03-09  Uros Bizjak  ubiz...@gmail.com

       PR target/52530
       * config/i386/i386.c (ix86_print_operand): Handle 'E' operand modifier.
       (ix86_print_operand_address): Handle UNSPEC_LEA_ADDR. Do not fallback
       to set code to 'q'.
       * config/i386/i386.md (UNSPEC_LEA_ADDR): New unspec.
       (*movdi_internal_rex64): Use %E operand modifier for lea.
       (*movsi_internal): Ditto.
       (*lea_1): Ditto.
       (*leamode_2): Ditto.
       (*lea_{3,4,5,6}_zext): Ditto.
       (*tls_global_dynamic_32_gnu): Ditto.
       (*tls_global_dynamic_64): Ditto.
       (*tls_dynamic_gnu2_lea_32): Ditto.
       (*tls_dynamic_gnu2_lea_64): Ditto.
       (pro_epilogue_adjust_stack_mode_add): Ditto.

Patch was tested on x86_64-pc-linux-gnu {,-m32}. I have also eyeballed
x32 code (Pmode == SImode) and found no problems.

Committed to mainline SVN.

H.J., can you please construct a runtime test from the above example code?

Uros.
Index: i386.md
===
--- i386.md (revision 185139)
+++ i386.md (working copy)
@@ -38,6 +38,7 @@
 ;; Z -- likewise, with special suffixes for x87 instructions.
 ;; * -- print a star (in certain assembler syntax)
 ;; A -- print an absolute memory reference.
+;; E -- print address with DImode register names if TARGET_64BIT.
 ;; w -- print the operand as if it's a word (HImode) even if it isn't.
 ;; s -- print a shift double count, followed by the assemblers argument
 ;; delimiter.
@@ -111,6 +112,7 @@
   UNSPEC_MS_TO_SYSV_CALL
   UNSPEC_CALL_NEEDS_VZEROUPPER
   UNSPEC_PAUSE
+  UNSPEC_LEA_ADDR
 
   ;; For SSE/MMX support:
   UNSPEC_FIX_NOTRUNC
@@ -1965,7 +1967,7 @@
   return #;
 
 case TYPE_LEA:
-  return lea{q}\t{%a1, %0|%0, %a1};
+  return lea{q}\t{%E1, %0|%0, %E1};
 
 default:
   gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
@@ -1974,7 +1976,7 @@
   else if (which_alternative == 2)
return movabs{q}\t{%1, %0|%0, %1};
   else if (ix86_use_lea_for_mov (insn, operands))
-   return lea{q}\t{%a1, %0|%0, %a1};
+   return lea{q}\t{%E1, %0|%0, %E1};
   else
return mov{q}\t{%1, %0|%0, %1};
 }
@@ -2206,12 +2208,12 @@
   return movd\t{%1, %0|%0, %1};
 
 case TYPE_LEA:
-  return lea{l}\t{%a1, %0|%0, %a1};
+  return lea{l}\t{%E1, %0|%0, %E1};
 
 default:
   gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
   if (ix86_use_lea_for_mov (insn, operands))
-   return lea{l}\t{%a1, %0|%0, %a1};
+   return lea{l}\t{%E1, %0|%0, %E1};
   else
return mov{l}\t{%1, %0|%0, %1};
 }
@@ -5426,7 +5428,7 @@
   [(set (match_operand:SI 0 register_operand =r)
(subreg:SI (match_operand:DI 1 lea_address_operand p) 0))]
   TARGET_64BIT
-  lea{l}\t{%a1, %0|%0, %a1}
+  lea{l}\t{%E1, %0|%0, %E1}
reload_completed  ix86_avoid_lea_for_addr (insn, operands)
   [(const_int 0)]
 {
@@ -5440,7 +5442,7 @@
   [(set (match_operand:SWI48 0 register_operand =r)
(match_operand:SWI48 1 lea_address_operand p))]
   
-  lea{imodesuffix}\t{%a1, %0|%0, %a1}
+  lea{imodesuffix}\t{%E1, %0|%0, %E1}
   reload_completed  ix86_avoid_lea_for_addr (insn, operands)
   [(const_int 0)]
 {
@@ -5455,7 +5457,7 @@
(zero_extend:DI
  (subreg:SI (match_operand:DI 1 lea_address_operand j) 0)))]
   TARGET_64BIT
-  lea{l}\t{%a1, %k0|%k0, %a1}

Re: [PATCH] Add missing __throw_exception_again

2012-03-09 Thread Paolo Carlini

HI,

This prevents the 22_locale/locale/cons/12352.cc test from crashing.
Tested on m68k-linux.
Depending on the system, doesn't crash that easily, but indeed the issue 
is real and the patch is right, we want it in 4.7.1 (if not 4.7.0?) and 
mainline.


Thanks,
Paolo.



[Patch,AVR]: Hack around PR rtl-optimization/52543

2012-03-09 Thread Georg-Johann Lay
The problem with the PR is that lower-subreg.c happily splits multi-byte moves
from address spaces without knowing anything about the additional costs this is
causing.

The TARGET_MODE_DEPENDENT_ADDRESS_P hook cannot be used for 16-bit addresses
because that hook is not sensitive to address spaces, but is is used for the
24-bit address space to avoid subreg lowering for PSImode.

For the 16-bit address spaces the mov expander now assigns the address register
by hand as post-increment.

Luckily, post-increment is the only addressing mode that makes sense with the
non-generic address spaces and there is no choice for the address register
resp. addressing mode, anyway...

This patch does not fix the PR issue, of course, it just avoids subreg lowering
by using/pretending mode-dependent addresses.

Ok for trunk?

Johann

PR rtl-optimization/52543
* config/avr/avr.c (avr_mode_dependent_address_p): New function.
(TARGET_MODE_DEPENDENT_ADDRESS_P): New define.

* config/avr/avr.md (unspec): Add UNSPEC_LPM.
(load_mode_libgcc): Use UNSPEC_LPM instead of MEM.
(movmode): For multi-byte move from non-generic
16-bit address spaces: Expand to use Z++ as address for
inline code and use UNSPEC_LPM (Z) for code from libgcc.
(loadmode_libgcc): Remove expander.
(split-lpmx): Remove split.


Index: config/avr/avr.md
===
--- config/avr/avr.md	(revision 185105)
+++ config/avr/avr.md	(working copy)
@@ -63,6 +63,7 @@ (define_c_enum unspec
   [UNSPEC_STRLEN
UNSPEC_MOVMEM
UNSPEC_INDEX_JMP
+   UNSPEC_LPM
UNSPEC_FMUL
UNSPEC_FMULS
UNSPEC_FMULSU
@@ -364,43 +365,24 @@ (define_split
 ;;
 ;; Move stuff around
 
-;; loadqi_libgcc
-;; loadhi_libgcc
-;; loadpsi_libgcc
-;; loadsi_libgcc
-;; loadsf_libgcc
-(define_expand loadmode_libgcc
-  [(set (match_dup 3)
-(match_dup 2))
-   (set (reg:MOVMODE 22)
-(match_operand:MOVMODE 1 memory_operand ))
-   (set (match_operand:MOVMODE 0 register_operand )
-(reg:MOVMODE 22))]
-  avr_load_libgcc_p (operands[1])
-  {
-operands[3] = gen_rtx_REG (HImode, REG_Z);
-operands[2] = force_operand (XEXP (operands[1], 0), NULL_RTX);
-operands[1] = replace_equiv_address (operands[1], operands[3]);
-set_mem_addr_space (operands[1], ADDR_SPACE_FLASH);
-  })
+;; Represent a load from __flash that needs libgcc support as UNSPEC.
+;; This is legal because we read from non-changing memory.
+;; For rationale see the FIXME below.
 
-;; load_qi_libgcc
-;; load_hi_libgcc
 ;; load_psi_libgcc
 ;; load_si_libgcc
 ;; load_sf_libgcc
 (define_insn load_mode_libgcc
   [(set (reg:MOVMODE 22)
-(match_operand:MOVMODE 0 memory_operand m,m))]
-  avr_load_libgcc_p (operands[0])
-REG_P (XEXP (operands[0], 0))
-REG_Z == REGNO (XEXP (operands[0], 0))
+(unspec:MOVMODE [(reg:HI REG_Z)]
+UNSPEC_LPM))]
+  
   {
-operands[0] = GEN_INT (GET_MODE_SIZE (MODEmode));
-return %~call __load_%0;
+rtx n_bytes = GEN_INT (GET_MODE_SIZE (MODEmode));
+output_asm_insn (%~call __load_%0, n_bytes);
+return ;
   }
-  [(set_attr length 1,2)
-   (set_attr isa rjmp,jmp)
+  [(set_attr type xcall)
(set_attr cc clobber)])
 
 
@@ -549,10 +531,53 @@ (define_expand movmode
   DONE;
 }
 
-if (avr_load_libgcc_p (src))
+/* ; FIXME: Load from non-generic 16-bit address spaces by means of
+   ; POST_INC or a call to a support routine from libgcc.  Reason is the
+   ; extreme code bloat caused by subreg lowering which splits multi-byte
+   ; moves without knowing anything about the additional costs caused by
+   ; these splits, see PR rtl-optimization/52543.
+   ; We assign the address to Z already at expand-time because there is
+   ; no choice for the address register, anyway, and pre-post-increment
+   ; optimization is virtually non-existent.  */
+
+if (avr_load_libgcc_p (src)
+|| (GET_MODE_SIZE (MODEmode)  1
+ avr_mem_flash_p (src)
+ can_create_pseudo_p()
+ (GET_CODE (XEXP (src, 0)) != POST_INC
+|| (GET_CODE (XEXP (src, 0)) == POST_INC
+ REGNO (XEXP (XEXP (src, 0), 0)) != REG_Z
   {
-/* For the small devices, do loads per libgcc call.  */
-emit_insn (gen_loadmode_libgcc (dest, src));
+rtx addr = XEXP (src, 0);
+rtx regz = gen_rtx_REG (Pmode, REG_Z);
+
+if (GET_CODE (addr) == POST_INC)
+  emit_move_insn (regz, XEXP (addr, 0));
+else
+  emit_move_insn (regz, force_reg (Pmode, addr));
+
+if (avr_load_libgcc_p (src))
+  {
+/* For old devices without LPMX, prefer loads per libcall.  */
+
+emit_insn (gen_load_mode_libgcc ());
+emit_move_insn (operands[0], gen_rtx_REG 

Re: [PATCH] Add missing __throw_exception_again

2012-03-09 Thread Jakub Jelinek
On Fri, Mar 09, 2012 at 07:14:52PM +0100, Paolo Carlini wrote:
 This prevents the 22_locale/locale/cons/12352.cc test from crashing.
 Tested on m68k-linux.
 Depending on the system, doesn't crash that easily, but indeed the
 issue is real and the patch is right, we want it in 4.7.1 (if not
 4.7.0?) and mainline.

Ok for 4.7.0.

Jakub


[google] save -std to lipo profile (issue5754067)

2012-03-09 Thread Rong Xu
Hi,

This patch is for google branches only.

It saves -std=* option to lipo profile so that non-c99 primary module
can include c99 auxiliay modules with restrict keyword.

Tested with bootstrap and google internal benchmarks.

-Rong

2012-03-09   Rong Xu  x...@google.com

* opts-global.c (lipo_save_cl_args): save -std option.
Google ref b/6117980.

Index: opts-global.c
===
--- opts-global.c   (revision 185148)
+++ opts-global.c   (working copy)
@@ -210,10 +210,12 @@
  (3) -W...
  (4) -O...
  (5) --param...
+ (6) -std=... (-std=c99 for restrict keyword)
   */
   if (opt[0] == '-'
(opt[1] == 'f' || opt[1] == 'm' || opt[1] == 'W' || opt[1] == 'O'
- || (strstr (opt, --param) == opt))
+ || (strstr (opt, --param) == opt)
+ || (strstr (opt, -std=)))
!strstr(opt, -frandom-seed)
!strstr(opt, -fripa-disallow-opt-mismatch)
!strstr(opt, -Wripa-opt-mismatch))

--
This patch is available for review at http://codereview.appspot.com/5754067


Re: [PATCH] Add missing __throw_exception_again

2012-03-09 Thread Andreas Schwab
This makes the 22_locale/locale/cons/12352.cc test fail everywhere.

Andreas.

2012-03-09  Andreas Schwab  sch...@linux-m68k.org

* config/locale/gnu/monetary_members.cc
(moneypunctchar,true::_M_initialize_moneypunct): Throw caught
exception again.
(moneypunctchar,false::_M_initialize_moneypunct): Likewise.

testsuite/
* testsuite/22_locale/locale/cons/12352.cc: Also test en_US
locale.
---
 libstdc++-v3/config/locale/gnu/monetary_members.cc |4 +++-
 .../testsuite/22_locale/locale/cons/12352.cc   |4 
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/locale/gnu/monetary_members.cc 
b/libstdc++-v3/config/locale/gnu/monetary_members.cc
index 214c4af..d1d9939 100644
--- a/libstdc++-v3/config/locale/gnu/monetary_members.cc
+++ b/libstdc++-v3/config/locale/gnu/monetary_members.cc
@@ -1,6 +1,6 @@
 // std::moneypunct implementation details, GNU version -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 
2012
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -339,6 +339,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  delete [] __group;
  delete [] __ps;
  delete [] __ns;
+ __throw_exception_again;
}
 
  char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
@@ -489,6 +490,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  delete [] __group;
  delete [] __ps;
  delete [] __ns;
+ __throw_exception_again;
}
 
  char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/12352.cc 
b/libstdc++-v3/testsuite/22_locale/locale/cons/12352.cc
index f56bf67..0449bf3 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/12352.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/12352.cc
@@ -1,4 +1,5 @@
 // { dg-require-namedlocale  }
+// { dg-require-namedlocale en_US }
 
 // Copyright (C) 2003, 2005, 2009 Free Software Foundation
 //
@@ -105,6 +106,9 @@ void test01(int iters)
  std::locale loc1 = std::locale();
  std::locale loc2(loc1, std::locale::classic(),
   std::locale::numeric);
+ std::locale loc3 = std::locale(en_US);
+ std::locale loc4(loc3, std::locale::classic(),
+  std::locale::numeric);
}
  catch (std::exception)
{
-- 
1.7.9.3


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


Re: [patch] Fix non-standard Ada bootstrap failure on IA-64

2012-03-09 Thread Eric Botcazou
 I'd say that alias.c when processing non-debug insn content should just
 ignore any cselib locs which have DEBUG_INSN_P setting_insn.

That wouldn't work though, as promote_debug_loc overwrites setting_insn.

-- 
Eric Botcazou


Re: [PATCH] Add missing __throw_exception_again

2012-03-09 Thread Paolo Carlini

On 03/09/2012 08:01 PM, Andreas Schwab wrote:

This makes the 22_locale/locale/cons/12352.cc test fail everywhere.

Excellent. Thus Ok mainline and 4_7-branch with the testcase extension too.

Thanks again,
Paolo.


Re: [patch] Fix non-standard Ada bootstrap failure on IA-64

2012-03-09 Thread Jakub Jelinek
On Fri, Mar 09, 2012 at 08:05:39PM +0100, Eric Botcazou wrote:
  I'd say that alias.c when processing non-debug insn content should just
  ignore any cselib locs which have DEBUG_INSN_P setting_insn.
 
 That wouldn't work though, as promote_debug_loc overwrites setting_insn.

It does that only in case the -g0 build would add the same locs to the
table.  Only the DEBUG_INSN_P setting_insn locs are there just in -g builds
and not in -g0 ones.

Jakub


Re: [google] save -std to lipo profile (issue5754067)

2012-03-09 Thread Xinliang David Li
ok for google branches.

David

On Fri, Mar 9, 2012 at 10:59 AM, Rong Xu x...@google.com wrote:
 Hi,

 This patch is for google branches only.

 It saves -std=* option to lipo profile so that non-c99 primary module
 can include c99 auxiliay modules with restrict keyword.

 Tested with bootstrap and google internal benchmarks.

 -Rong

 2012-03-09   Rong Xu  x...@google.com

        * opts-global.c (lipo_save_cl_args): save -std option.
        Google ref b/6117980.

 Index: opts-global.c
 ===
 --- opts-global.c       (revision 185148)
 +++ opts-global.c       (working copy)
 @@ -210,10 +210,12 @@
      (3) -W...
      (4) -O...
      (5) --param...
 +     (6) -std=... (-std=c99 for restrict keyword)
   */
   if (opt[0] == '-'
        (opt[1] == 'f' || opt[1] == 'm' || opt[1] == 'W' || opt[1] == 'O'
 -         || (strstr (opt, --param) == opt))
 +         || (strstr (opt, --param) == opt)
 +         || (strstr (opt, -std=)))
        !strstr(opt, -frandom-seed)
        !strstr(opt, -fripa-disallow-opt-mismatch)
        !strstr(opt, -Wripa-opt-mismatch))

 --
 This patch is available for review at http://codereview.appspot.com/5754067


Re: [PATCH] Improve PHI-OPT when there are multiple phis

2012-03-09 Thread Andrew Pinski
On Tue, Jan 24, 2012 at 2:50 AM, Richard Guenther
richard.guent...@gmail.com wrote:
 On Tue, Jan 24, 2012 at 7:34 AM, Andrew Pinski
 andrew.pin...@caviumnetworks.com wrote:
 Hi,
  Right now PHI-OPT does try to handle the case where we have multiple
 PHIs but the other PHIs have the same value for the edges we care
 about.
 This fixes the issue and allows PHI-OPT to handle a few more cases and
 it removes the TODO in the comments.

 OK For 4.8? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

 Thanks,
 Andrew Pinski

 ChangeLog:
 * tree-ssa-phiopt.c (gimple_phi_singleton_for_edges): New function.

 The name is confusing I think, because it returns the single non-singleton
 PHI for the edge pair ... you can avoid choosing a better name by
 inlining it to its single call site.  I'd maybe name it
 single_non_singleton_phi_for_edges.

 Otherwise ok.

Here is the updated patch with one small change, value_replacement
uses single_non_singleton_phi_for_edges now too.

OK still?  Bootstrapped and tested on x86_64-linux-gnu with no regressions.


Thanks,
Andrew Pinski


ChangeLog:
* tree-ssa-phiopt.c (single_non_singleton_phi_for_edges): New function.
(tree_ssa_phiopt_worker): Use single_non_singleton_phi_for_edges.
(value_replacement): Likewise.
(empty_block_p): Check also if the PHIs for the block are empty.

testsuite/ChangeLog:
* gcc.dg/tree-ssa/phi-opt-7.c: New testcase.



 Thanks,
 Richard.

 (tree_ssa_phiopt_worker): Use gimple_phi_singleton_for_edges.
 (empty_block_p): Check also if the PHIs for the block are empty.

 testsuite/ChangeLog:
 * gcc.dg/tree-ssa/phi-opt-7.c: New testcase.


Re: [patch] Fix non-standard Ada bootstrap failure on IA-64

2012-03-09 Thread Eric Botcazou
 It does that only in case the -g0 build would add the same locs to the
 table.  Only the DEBUG_INSN_P setting_insn locs are there just in -g builds
 and not in -g0 ones.

If that's really supposed to work like so, then this is the bug, because the 
non-legitimate expression is present only with -g and its location promoted.

-- 
Eric Botcazou


[Fortran-dev, Patch] Fix extent calculation, fix test suite failures

2012-03-09 Thread Tobias Burnus
Without the patch, I got some coarray failures (for -fcoarray=lib) and 
425 other failures. With this patch, the number of failures is down to 269.


I intent to commit the patch to the fortran-devel branch tomorrow, 
unless there are objection.


Changes:
* Fix offset for coarray's token field
* Extent is in number of elements and not in bytes; fix setting of the 
compatibility fields

* Set lbound before ubound as ubound uses lbound (plus extent).
* For character namelist read: Also set extent (and sm) - used by UBOUND 
macro
* Switch library's UBOUND/EXTENT macros to use only new fields rather 
than the old one.


I think the front end should be mostly okay, but the library still 
accesses ubound directly - and for stride vs. sm: Well, sm is 
currently not set at all. As the element size is needed, it requires 
larger changes. I wouldn't be surprised if the remaining failures relate 
to sm and/or extent issues.


Tobias
Index: gcc/fortran/ChangeLog.fortran-dev
===
--- gcc/fortran/ChangeLog.fortran-dev	(Revision 185103)
+++ gcc/fortran/ChangeLog.fortran-dev	(Arbeitskopie)
@@ -1,3 +1,14 @@
+2012-03-10  Tobias Burnus  bur...@net-b.de
+
+	* trans-array.c (CAF_TOKEN_FIELD): Set to the correct value.
+	(gfc_conv_descriptor_ubound_get, gfc_conv_descriptor_ubound_set):
+	Remove bogus byte-size handling, correctly handle lower bounds
+	which don't start with unity.
+	(gfc_conv_shift_descriptor_lbound): Reorder to make sure that
+	lbound comes before ubound.
+	* trans-expr.c (gfc_conv_subref_array_arg,
+	gfc_trans_alloc_subarray_assign): Ditto.
+
 2010-09-01  Paul Thomas  pa...@gcc.gnu.org
 
 	* trans-array.c : Define and subsequently undefine descriptor
Index: gcc/fortran/trans-array.c
===
--- gcc/fortran/trans-array.c	(Revision 185103)
+++ gcc/fortran/trans-array.c	(Arbeitskopie)
@@ -130,7 +130,7 @@ gfc_array_dataptr_type (tree desc)
 #define DTYPE_FIELD 2
 #define SIZE_FIELD 3
 #define DIMENSION_FIELD 4
-#define CAF_TOKEN_FIELD 4
+#define CAF_TOKEN_FIELD 5
 
 #define STRIDE_SUBFIELD 0
 #define LBOUND_SUBFIELD 1
@@ -472,16 +472,13 @@ gfc_conv_descriptor_ubound (tree desc, tree dim)
 tree
 gfc_conv_descriptor_ubound_get (tree desc, tree dim)
 {
-  tree cond, size;
-  tree tmp = gfc_get_element_type (TREE_TYPE (desc));
-  size = size_in_bytes (tmp);
-  size = fold_convert (gfc_array_index_type, size);
-  tmp = fold_build2_loc (input_location, FLOOR_DIV_EXPR, gfc_array_index_type,
-			 gfc_conv_descriptor_extent_get (desc, dim), size);
-  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, size,
-			  gfc_index_zero_node);
-  tmp = fold_build3_loc (input_location, COND_EXPR, gfc_array_index_type, cond,
-			 gfc_index_zero_node, tmp);
+  tree lb = gfc_conv_descriptor_lbound (desc, dim);
+  tree tmp = gfc_conv_descriptor_extent_get (desc, dim);
+  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+ fold_convert (gfc_array_index_type, lb),
+ fold_convert (gfc_array_index_type, tmp));
+  tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+			 tmp, gfc_index_one_node);
   return tmp;
 }
 
@@ -492,11 +489,12 @@ gfc_conv_descriptor_ubound_set (stmtblock_t *block
   tree tmp;
   tree t = gfc_conv_descriptor_ubound (desc, dim);
   gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
-  tmp = gfc_get_element_type (TREE_TYPE (desc));
-  tmp = size_in_bytes (tmp);
-  tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
-			 fold_convert (TREE_TYPE (t), value),
+  tmp =  gfc_conv_descriptor_lbound (desc, dim);
+  tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+			 fold_convert (TREE_TYPE (t), t),
 			 fold_convert (TREE_TYPE (t), tmp));
+  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+			 tmp, gfc_index_one_node);
   gfc_conv_descriptor_extent_set (block, desc, dim, tmp);
 }
 
@@ -542,19 +540,20 @@ gfc_conv_shift_descriptor_lbound (stmtblock_t* blo
   diff = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
 			  new_lbound, lbound);
 
-  /* Shift ubound and offset accordingly.  This has to be done before
- updating the lbound, as they depend on the lbound expression!  */
-  ubound = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-			ubound, diff);
-  gfc_conv_descriptor_ubound_set (block, desc, gfc_rank_cst[dim], ubound);
   offs_diff = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
 			   diff, stride);
   offs = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
 			  offs, offs_diff);
   gfc_conv_descriptor_offset_set (block, desc, offs);
 
-  /* Finally set lbound to value we want.  */
+  /* Set lbound to value we want.  */
   gfc_conv_descriptor_lbound_set (block, desc, gfc_rank_cst[dim], new_lbound);
+
+  /* Update ubound. 

Re: [PR51752] publication safety violations in loop invariant motion pass

2012-03-09 Thread Aldy Hernandez



Note that partial PRE (enabled at -O3) can insert expressions into paths
that did _not_ execute the expression.  For regular PRE you are right.

Richard.


I've thought about this some more, and Torvald's comment makes a lot of 
sense.  PRE can make things completely redundant, and a later pass may 
move things before its publication.  I believe it's wise to disable PRE 
inside transactions as originally discussed.  The attached patch does so.


Below is an example (from my patch) with an explanation of what may go 
wrong.


Torvald is this what you were thinking of?

Richards, is this OK for the 4.7 branch and trunk (pending tests)?

Thanks.
Aldy

+ /* Non local loads in a transaction cannot be hoisted out,
+because they may make partially redundant expressions
+totally redundant, which a later pass may move before its
+publication by another thread.
+
+For example:
+
+  __transaction_atomic {
+if (flag)
+  y = x + 4;
+else
+  // stuff
+z = x + 4;
+  }
+
+PRE can rewrite this into:
+
+  __transaction_atomic {
+if (flag) {
+  tmp = x + 4;
+  y = tmp;
+} else {
+  // stuff
+  tmp = x + 4;
+}
+z = tmp;
+  }
+
+A later pass can move the now totally redundant [x + 4]
+before its publication predicated by flag:
+
+  __transaction_atomic {
+tmp = x + 4;
+if (flag) {
+} else {
+  // stuff
+}
+z = tmp;
+ */
PR middle-end/51752
* tree-ssa-pre.c (compute_avail): Disable PRE movements inside a
transaction.
(execute_pre): Compute transaction bits.

Index: testsuite/gcc.dg/tm/pr51752.c
===
--- testsuite/gcc.dg/tm/pr51752.c   (revision 0)
+++ testsuite/gcc.dg/tm/pr51752.c   (revision 0)
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options -fgnu-tm -fdump-tree-pre -O2 } */
+
+int flag, hoist, y, z, george;
+
+void
+foo (void)
+{
+  __transaction_atomic
+  {
+if (george)
+  {
+   if (flag)
+ y = hoist + 4;
+   else
+ flag = 888;
+   z = hoist + 4;
+  }
+  }
+}
+
+/* { dg-final { scan-tree-dump-times pretmp.*= hoist 0 pre } } */
+/* { dg-final { cleanup-tree-dump pre } } */
Index: tree-ssa-pre.c
===
--- tree-ssa-pre.c  (revision 184935)
+++ tree-ssa-pre.c  (working copy)
@@ -3986,6 +3986,54 @@ compute_avail (void)
  || stmt_could_throw_p (stmt))
continue;
 
+ /* Non local loads in a transaction cannot be hoisted out,
+because they may make partially redundant expressions
+totally redundant, which a later pass may move before its
+publication by another thread.
+
+For example:
+
+  __transaction_atomic {
+if (flag)
+  y = x + 4;
+else
+  // stuff
+z = x + 4;
+  }
+
+PRE can rewrite this into:
+
+  __transaction_atomic {
+if (flag) {
+  tmp = x + 4;
+  y = tmp;
+} else {
+  // stuff
+  tmp = x + 4;
+}
+z = tmp;
+  }
+
+A later pass can move the now totally redundant [x + 4]
+before its publication predicated by flag:
+
+  __transaction_atomic {
+tmp = x + 4;
+if (flag) {
+} else {
+  // stuff
+}
+z = tmp;
+ */
+ if (flag_tm
+  gimple_in_transaction (stmt)
+  gimple_assign_single_p (stmt))
+   {
+ tree rhs = gimple_assign_rhs1 (stmt);
+ if (DECL_P (rhs)  is_global_var (rhs))
+   continue;
+   }
+
  switch (gimple_code (stmt))
{
case GIMPLE_RETURN:
@@ -4896,6 +4944,9 @@ execute_pre (bool do_fre)
   init_pre (do_fre);
   scev_initialize ();
 
+  if (flag_tm)
+compute_transaction_bits ();
+
   /* Collect and value number expressions computed in each basic block.  */
   compute_avail ();
 


[google/4.6] Add powerpc64-grtev2-linux-gnu.xfail (issue5794044)

2012-03-09 Thread Doug Kwan
Hi Diego,

This patch adds the XFAIL file for powerpc64-grtev2-linux-gnu in 4.6.

-Doug

2012-03-09   Doug Kwan  dougk...@google.com

* contrib/testsuite-management/powerpc64-grtev2-linux-gnu.xfail:
New file.

Index: contrib/testsuite-management/powerpc64-grtev2-linux-gnu.xfail
===
--- contrib/testsuite-management/powerpc64-grtev2-linux-gnu.xfail   
(revision 0)
+++ contrib/testsuite-management/powerpc64-grtev2-linux-gnu.xfail   
(revision 0)
@@ -0,0 +1,103 @@
+# *** gcc:
+FAIL: gcc.c-torture/execute/builtins/memset-chk.c compilation,  -O2 -flto 
+UNRESOLVED: gcc.c-torture/execute/builtins/memset-chk.c execution,  -O2 -flto 
+FAIL: gcc.c-torture/execute/20020226-1.c execution,  -O0 
+FAIL: gcc.c-torture/execute/20020226-1.c execution,  -O1 
+FAIL: gcc.c-torture/execute/20020226-1.c execution,  -O2 
+FAIL: gcc.c-torture/execute/20020226-1.c execution,  -O3 -fomit-frame-pointer 
+FAIL: gcc.c-torture/execute/20020226-1.c execution,  -O3 -g 
+FAIL: gcc.c-torture/execute/20020226-1.c execution,  -Os 
+FAIL: gcc.c-torture/execute/20020508-1.c execution,  -O0 
+FAIL: gcc.c-torture/execute/20020508-1.c execution,  -O1 
+FAIL: gcc.c-torture/execute/20020508-1.c execution,  -O2 
+FAIL: gcc.c-torture/execute/20020508-1.c execution,  -O3 -fomit-frame-pointer 
+FAIL: gcc.c-torture/execute/20020508-1.c execution,  -O3 -g 
+FAIL: gcc.c-torture/execute/20020508-1.c execution,  -Os 
+FAIL: gcc.c-torture/execute/pr52129.c compilation,  -O2 -flto 
+UNRESOLVED: gcc.c-torture/execute/pr52129.c execution,  -O2 -flto 
+FAIL: gcc.dg/and-1.c scan-assembler-not nand
+FAIL: gcc.dg/automversn_1.c (test for excess errors)
+UNRESOLVED: gcc.dg/automversn_1.c compilation failed to produce executable
+UNRESOLVED: gcc.dg/automversn_1.c scan-tree-dump auto_clone 
foo.autoclone.original
+UNRESOLVED: gcc.dg/automversn_1.c scan-tree-dump auto_clone foo.autoclone.0
+FAIL: gcc.dg/cleanup-10.c execution test
+FAIL: gcc.dg/cleanup-11.c execution test
+FAIL: gcc.dg/cleanup-8.c execution test
+FAIL: gcc.dg/cleanup-9.c execution test
+FAIL: gcc.dg/pr44194-1.c scan-rtl-dump dse1 global deletions = 2
+FAIL: gcc.dg/sms-2.c scan-rtl-dump-times sms SMS succeeded 1
+FAIL: gcc.dg/sms-4.c scan-rtl-dump-times sms SMS succeeded 1
+FAIL: gcc.dg/sms-5.c scan-rtl-dump-times sms SMS succeeded 1
+FAIL: gcc.dg/sms-6.c scan-rtl-dump-times sms SMS succeeded 3
+FAIL: gcc.dg/sms-7.c scan-rtl-dump-times sms SMS succeeded 3
+FAIL: gcc.dg/sms-8.c scan-rtl-dump-times sms SMS succeeded 1
+FAIL: gcc.dg/stack-usage-1.c scan-file foo\t(256|264)\tstatic
+FAIL: gcc.dg/lto/20110201-1 c_lto_20110201-1_0.o-c_lto_20110201-1_0.o link,  
-O0 -flto 
+UNRESOLVED: gcc.dg/lto/20110201-1 c_lto_20110201-1_0.o-c_lto_20110201-1_0.o 
execute  -O0 -flto 
+FAIL: gcc.dg/torture/tls/tls-test.c  -O0  execution test
+FAIL: gcc.dg/torture/tls/tls-test.c  -O1  execution test
+FAIL: gcc.dg/torture/tls/tls-test.c  -O2  execution test
+FAIL: gcc.dg/torture/tls/tls-test.c  -O3 -fomit-frame-pointer  execution test
+FAIL: gcc.dg/torture/tls/tls-test.c  -O3 -g  execution test
+FAIL: gcc.dg/torture/tls/tls-test.c  -Os  execution test
+FAIL: gcc.dg/torture/tls/tls-test.c  -O2 -flto -flto-partition=none  execution 
test
+FAIL: gcc.dg/torture/tls/tls-test.c  -O2 -flto  execution test
+FAIL: gcc.dg/tree-prof/lipo/ic-misattribution-1_0.c scan-ipa-dump-times 
profile Indirect call - direct call 2
+FAIL: gcc.dg/tree-prof/lipo/indir-call-prof_0.c scan-ipa-dump profile 
Indirect call - direct call.* a1
+FAIL: gcc.dg/tree-prof/lipo/lipo_inline1_0.c scan-tree-dump-not optimized foo
+FAIL: gcc.dg/tree-prof/lipo/lipo_inline1_0.c scan-tree-dump-not optimized goo
+FAIL: gcc.dg/tree-ssa/vrp47.c scan-tree-dump-times vrp1 [xy][^ ]* != 0
+FAIL: gcc.dg/tree-ssa/vrp47.c scan-tree-dump-times dom1 x[^ ]*  y 1
+FAIL: gcc.dg/vmx/3a-03.c  -O0  execution test
+FAIL: gcc.dg/vmx/3a-03.c  -O1  execution test
+FAIL: gcc.dg/vmx/3a-03.c  -O2  execution test
+FAIL: gcc.dg/vmx/3a-03.c  -O3 -fomit-frame-pointer  execution test
+FAIL: gcc.dg/vmx/3a-03.c  -O3 -g  execution test
+FAIL: gcc.dg/vmx/3a-03.c  -Os  execution test
+FAIL: gcc.dg/vmx/3a-03.c  -O2 -flto -flto-partition=none  execution test
+FAIL: gcc.dg/vmx/3a-03.c  -O2 -flto  execution test
+FAIL: gcc.dg/vmx/3a-03m.c  -O0  execution test
+FAIL: gcc.dg/vmx/3a-03m.c  -O1  execution test
+FAIL: gcc.dg/vmx/3a-03m.c  -O2  execution test
+FAIL: gcc.dg/vmx/3a-03m.c  -O3 -fomit-frame-pointer  execution test
+FAIL: gcc.dg/vmx/3a-03m.c  -O3 -g  execution test
+FAIL: gcc.dg/vmx/3a-03m.c  -Os  execution test
+FAIL: gcc.dg/vmx/3a-03m.c  -O2 -flto -flto-partition=none  execution test
+FAIL: gcc.dg/vmx/3a-03m.c  -O2 -flto  execution test
+FAIL: gcc.target/powerpc/ppc-vector-memcpy.c scan-assembler lvx
+FAIL: gcc.target/powerpc/pr47755-2.c execution test
+
+# *** gfortran:
+XPASS: gfortran.dg/nint_2.f90  -O0  execution test
+FAIL: gfortran.dg/vect/pr45714-b.f  -O  (internal compiler error)
+FAIL: 

[Patch, Fortran] PR 52542 - Fix PROCEDURE() with Bind(C)

2012-03-09 Thread Tobias Burnus
If the interface in a PROCEDURE() statement is Bind(C), also the 
procedure (pointer) declared in that statement is BIND(C).


From the F2008 standard: A proc-language-binding-spec without a NAME= 
is allowed, but is redundant with the proc-interface required by C1222.


Build and currently regtested on x86-64-linux.
OK for the trunk (if regtesting succeeded)?

Tobias
2012-03-10  Tobias Burnus  bur...@net-b.de

	PR fortran/52542
	* decl.c (match_procedure_decl): If the interface
	is bind(C), the procedure is as well.

2012-03-10  Tobias Burnus  bur...@net-b.de

	PR fortran/52542
	* gfortran.dg/proc_ptr_35.f90: New.

--- /dev/null	2012-03-09 19:41:57.079829322 +0100
+++ gcc/gcc/testsuite/gfortran.dg/proc_ptr_35.f90	2012-03-09 22:22:31.0 +0100
@@ -0,0 +1,16 @@
+! { dg-do compile }
+!
+! PR fortran/52542
+!
+! Ensure that the procedure myproc is Bind(C).
+!
+! Contribute by Mat Cross of NAG
+!
+interface
+  subroutine s() bind(c)
+  end subroutine s
+end interface
+procedure(s) :: myproc
+call myproc()
+end
+! { dg-final { scan-assembler-not myproc_ } }
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 75b8a89..7c5e518 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -4855,6 +4855,9 @@ match_procedure_decl (void)
   if (m == MATCH_ERROR)
 return MATCH_ERROR;
 
+  if (proc_if  proc_if-attr.is_bind_c)
+current_attr.is_bind_c = 1;
+
   /* Get procedure symbols.  */
   for(num=1;;num++)
 {


PATCH RFA: Update Go frontend on gcc 4.7 branch

2012-03-09 Thread Ian Lance Taylor
I would like to update the Go support on the 4.7 branch.  As I've
mentioned before, Go is working toward a stable Go 1 release.  That
release is not complete, but it is quite close.  The 4.7 branch was made
at a slightly unstable point in the process.  I've updated the library
one more time, and I've spent the week testing the result on a bunch of
Google-internal programs.  What I have now is not perfect, but it is
better than what is on the 4.7 branch today.

This proposed patch does include a library update, which is fairly
large.  However, this update should not be destabilizing.  I've tested
the 4.7 branch plus this patch on x86_64-unknown-linux-gnu, and I'm
preparing to test it on Solaris.

This will be the last large Go patch I will commit before the 4.7.0
release.  I may commit some small patches to fix serious bugs, subject
to approval by the RMs.

The bzipped patch is 375146 bytes, too large for the mailing list.  I've
put it at ftp://ftp.airs.com/pub/go-4_7.patch.bz2 .

OK to commit to 4.7 branch?

Ian


PATCH: Properly generate X32 IE sequence

2012-03-09 Thread H.J. Lu
On Mon, Mar 5, 2012 at 9:25 AM, Uros Bizjak ubiz...@gmail.com wrote:
 On Mon, Mar 5, 2012 at 6:03 PM, H.J. Lu hjl.to...@gmail.com wrote:

 X86-64 linker optimizes TLS_MODEL_INITIAL_EXEC to TLS_MODEL_LOCAL_EXEC
 by checking

        movq foo@gottpoff(%rip), %reg

 and

        addq foo@gottpoff(%rip), %reg

 It uses the REX prefix to avoid the last byte of the previous
 instruction.  With 32bit Pmode, we may not have the REX prefix and
 the last byte of the previous instruction may be an offset, which
 may look like a REX prefix.  IE-LE optimization will generate corrupted
 binary.  This patch makes sure we always output an REX pfrefix for
 UNSPEC_GOTNTPOFF.  OK for trunk?

 Actually, linker has:

    case R_X86_64_GOTTPOFF:
      /* Check transition from IE access model:
                mov foo@gottpoff(%rip), %reg
                add foo@gottpoff(%rip), %reg
       */

      /* Check REX prefix first.  */
      if (offset = 3  (offset + 4) = sec-size)
        {
          val = bfd_get_8 (abfd, contents + offset - 3);
          if (val != 0x48  val != 0x4c)
            {
              /* X32 may have 0x44 REX prefix or no REX prefix.  */
              if (ABI_64_P (abfd))
                return FALSE;
            }
        }
      else
        {
          /* X32 may not have any REX prefix.  */
          if (ABI_64_P (abfd))
            return FALSE;
          if (offset  2 || (offset + 3)  sec-size)
            return FALSE;
        }

 So, it should handle the case without REX just OK. If it doesn't, then
 this is a bug in binutils.


 The last byte of the displacement in the previous instruction
 may happen to look like a REX byte. In that case, linker
 will overwrite the last byte of the previous instruction and
 generate the wrong instruction sequence.

 I need to update linker to enforce the REX byte check.

 One important observation: if we want to follow the x86_64 TLS spec
 strictly, we have to use existing DImode patterns only. This also
 means that we should NOT convert other TLS patterns to Pmode, since
 they explicitly state movq and addq. If this is not the case, then we
 need new TLS specification for X32.

Here is a patch to properly generate X32 IE sequence.

This is the summary of differences between x86-64 TLS and x32 TLS:

 x86-64   x32
GD
byte 0x66; leaq foo@tlsgd(%rip),%rdi; leaq foo@tlsgd(%rip),%rdi;
.word 0x; rex64; call __tls_get_addr@plt  .word 0x; rex64;
call __tls_get_addr@plt

GD-IE optimization
   movq %fs:0,%rax; addq x@gottpoff(%rip),%raxmovl %fs:0,%eax;
addq x@gottpoff(%rip),%rax

GD-LE optimization
   movq %fs:0,%rax; leaq x@tpoff(%rax),%rax   movl %fs:0,%eax;
leaq x@tpoff(%rax),%rax

LD
  leaq foo@tlsld(%rip),%rdi;  leaq foo@tlsld(%rip),%rdi;
  call __tls_get_addr@plt call __tls_get_addr@plt

LD-LE optimization
  .word 0x; .byte 0x66; movq %fs:0, %rax  nopl 0x0(%rax); movl
%fs:0, %eax

IE
   movq %fs:0,%reg64; movl %fs:0,%reg32;
   addq x@gottpoff(%rip),%reg64   addl x@gottpoff(%rip),%reg32

   or
  Not supported if
Pmode == SImode
   movq x@gottpoff(%rip),%reg64;  movq x@gottpoff(%rip),%reg64;
   movq %fs:(%reg64),%reg32   movl %fs:(%reg64), %reg32

IE-LE optimization

   movq %fs:0,%reg64; movl %fs:0,%reg32;
   addq x@gottpoff(%rip),%reg64   addl x@gottpoff(%rip),%reg32

   to

   movq %fs:0,%reg64; movl %fs:0,%reg32;
   addq foo@tpoff, %reg64 addl foo@tpoff, %reg32

   movq %fs:0,%reg64; movl %fs:0,%reg32;
   leaq foo@tpoff(%reg64), %reg64 leal foo@tpoff(%reg32), %reg32

   or

   movq x@gottpoff(%rip),%reg64   movq x@gottpoff(%rip),%reg64;
   movl %fs:(%reg64),%reg32   movl %fs:(%reg64), %reg32

   to

   movq foo@tpoff, %reg64 movq foo@tpoff, %reg64
   movl %fs:(%reeg64),%reg32  movl %fs:(%reg64), %reg32

LE
   movq %fs:0,%reg64; movl %fs:0,%reg32;
   leaq x@tpoff(%reg64),%reg32leal x@tpoff(%reg32),%reg32

   or

   movq %fs:0,%reg64; movl %fs:0,%reg32;
   addq $x@tpoff,%reg64   addl $x@tpoff,%reg32

   or

   movq %fs:0,%reg64; movl %fs:0,%reg32;
   movl x@tpoff(%reg64),%reg32movl x@tpoff(%reg32),%reg32

   or

   movl %fs:x@tpoff,%reg32movl %fs:x@tpoff,%reg32


X32 TLS implementation is straight forward, except for IE:

1. Since address override works only on the (reg32) part in fs:(reg32),
we can't use it as memory operand.  This patch changes ix86_decompose_address
to disallow  fs:(reg) if Pmode != word_mode.
2. When Pmode 

Re: Swap SECTION_EXCLUDE and SECTION_MACH_DEP

2012-03-09 Thread Sriraman Tallam
Please see:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52545

SECTION_EXCLUDE should not take up bits reserved for SECTION_MACH_DEP

Patch:

PR 52545
* output.h (SECTION_MACH_DEP)
(SECTION_EXCLUDE):  Swap values.



Index: output.h
===
--- output.h(revision 185120)
+++ output.h(working copy)
@@ -446,8 +446,8 @@
 #define SECTION_STYLE_MASK 0x60/* bits used for SECTION_STYLE */
 #define SECTION_COMMON   0x80  /* contains common data */
 #define SECTION_RELRO   0x100  /* data is readonly after relocation
processing */
-#define SECTION_MACH_DEP 0x200 /* subsequent bits reserved for target 
*/
-#define SECTION_EXCLUDE  0x400  /* discarded by the linker */
+#define SECTION_EXCLUDE  0x200  /* discarded by the linker */
+#define SECTION_MACH_DEP 0x400 /* subsequent bits reserved for target 
*/

Ok to submit?

Thanks.
-Sri.


On Fri, Mar 9, 2012 at 3:07 PM, Sriraman Tallam tmsri...@google.com wrote:



Re: [Patch ARM/ configury] Add fall-back check for gnu_unique_object

2012-03-09 Thread Ramana Radhakrishnan
 Ping -  http://gcc.gnu.org/ml/gcc-patches/2012-03/msg00549.html

And now really add Paolo and DJ.

Ramana

 regards,
 Ramana



 regards,
 Ramana


 2012-03-07  Ramana Radhakrishnan   ramana.radhakrish...@linaro.org

       * config.gcc (target_type_format_char): New. Document it. Set it for
         arm*-*-* .
       * configure.ac (gnu_unique_option): Use target_type_format_char in 
 test.
       * configure: Regenerate .


Re: [Patch ARM/ configury] Add fall-back check for gnu_unique_object

2012-03-09 Thread DJ Delorie

  Ping -  http://gcc.gnu.org/ml/gcc-patches/2012-03/msg00549.html
 
 And now really add Paolo and DJ.

+   [.type foo, '$target_type_format_char'gnu_unique_object],,

This un-quoting looks incorrect if you don't know what's going on
under the hood, but I don't see a clean way around it.  A suitable
comment would be appropriate.

+target_type_format_char=@
+   target_type_format_char=%

Since the string always has special characters, it's likely that
single quotes are more appropriate here.  The two characters in the
patch don't care, but some future porter might naively do $ and
wonder why (or worse, not wonder why) it doesn't work right.

Other than that it looks OK to me, assuming you tested it on all the
relevent targets (i.e. arm and not-arm).


[pph] System Headers. Nested Types. (issue5797052)

2012-03-09 Thread Lawrence Crowl
Disable warning when a system header is a primary compilation file.
This change is necessary when creating a PPH file from a system
header.  The change adds and option -fprimary-system-header-okay and
implicitly sets it when a PPH output file is specified.  Added tests
x0sysheader.h and x1sysheader.cc.

Prepare for merging the lang_type in classes to support merging
types nested within classes.  The change adds some merging routines,
but only the bitsets are actually merged, and there is no effect
on existing tests.  Added tests x0neststruct1.h, x0neststruct2.h,
x4neststruct1.cc, and x4neststruct2.cc.  The latter test demonstrates
the problem with a failure.

Tested on x64.


Index: gcc/c-family/ChangeLog.pph

2012-03-09   Lawrence Crowl  cr...@google.com

* c.opt (-fprimary-system-header-okay): New.
* c-opts.c (c_common_handle_option): Add handling for
-fprimary-system-header-okay.  Make PPH output imply this option.

Index: gcc/cp/ChangeLog.pph

2012-03-09   Lawrence Crowl  cr...@google.com

* name-lookup.c (pph_out_binding_table): Correct comment.
(pph_in_binding_table): Correct comment.
* pph-out.c (pph_out_lang_type_class_bits): New.
(pph_out_lang_type_class): Factor out the bitpack writing into
pph_out_lang_type_class_bits.
(pph_out_merge_key_lang_type_class): New.
(pph_out_merge_key_lang_type): New.
(pph_out_merge_key_tree): Also emit merge key for lang_type for classes.
* pph-in.c (typedef merge_toc_entry): Generalize context.
(pph_toc_lookup_add): New.
(pph_merge_into_chain): Factor out TOC lookup and add to
pph_toc_lookup_add.
(pph_in_merge_lang_type_class_bits): New.
(pph_in_lang_type_class): Factor out the bitpack reading into
pph_in_merge_lang_type_class_bits.
(pph_in_merge_key_lang_type_class): New.
(pph_in_merge_key_lang_type): New.
(pph_in_merge_key_tree_with_searcher): Also merge key for lang_type
for classes.

Index: libcpp/ChangeLog.pph

2012-03-09   Lawrence Crowl  cr...@google.com

* include/cpplib.h (struct cpp_options): Add option to supress warning
about a system header as a primary file.
* directives.c (do_pragma_system_header): Implement the effect of the
above option.


Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 185111)
+++ gcc/c-family/c.opt  (working copy)
@@ -1017,6 +1017,10 @@ fpreprocessed
 C ObjC C++ ObjC++
 Treat the input file as already preprocessed
 
+fprimary-system-header-okay
+C ObjC C++ ObjC++
+Supress warning about compiling a primary system header file.
+
 ftrack-macro-expansion
 C ObjC C++ ObjC++ JoinedOrMissing RejectNegative UInteger
 ; converted into ftrack-macro-expansion=
Index: gcc/c-family/c-opts.c
===
--- gcc/c-family/c-opts.c   (revision 185111)
+++ gcc/c-family/c-opts.c   (working copy)
@@ -385,6 +385,7 @@ c_common_handle_option (size_t scode, co
 
 case OPT__output_pph_:
   pph_out_file = arg;
+  cpp_opts-primary_system_header_okay = true;
   break;
 
 case OPT_A:
@@ -803,6 +804,10 @@ c_common_handle_option (size_t scode, co
   add_pph_include_maps (arg);
   break;
 
+case OPT_fprimary_system_header_okay:
+  cpp_opts-primary_system_header_okay = true;
+  break;
+
 case OPT_idirafter:
   add_path (xstrdup (arg), AFTER, 0, true);
   break;
Index: gcc/cp/pph-out.c
===
--- gcc/cp/pph-out.c(revision 185112)
+++ gcc/cp/pph-out.c(working copy)
@@ -1691,10 +1691,10 @@ pph_out_sorted_fields_type (pph_stream *
 }
 
 
-/* Write all the fields in lang_type_class instance LTC to STREAM.  */
+/* Write all the packed bits in lang_type_class instance LTC to STREAM.  */
 
 static void
-pph_out_lang_type_class (pph_stream *stream, struct lang_type_class *ltc)
+pph_out_lang_type_class_bits (pph_stream *stream, struct lang_type_class *ltc)
 {
   struct bitpack_d bp;
 
@@ -1745,7 +1745,15 @@ pph_out_lang_type_class (pph_stream *str
   bp_pack_value (bp, ltc-has_complex_move_assign, 1);
   bp_pack_value (bp, ltc-has_constexpr_ctor, 1);
   pph_out_bitpack (stream, bp);
+}
+
 
+/* Write all the fields in lang_type_class instance LTC to STREAM.  */
+
+static void
+pph_out_lang_type_class (pph_stream *stream, struct lang_type_class *ltc)
+{
+  pph_out_lang_type_class_bits (stream, ltc);
   pph_out_tree (stream, ltc-primary_base);
   pph_out_tree_pair_vec (stream, ltc-vcall_indices);
   pph_out_tree (stream, ltc-vtables);
@@ -1774,6 +1782,16 @@ pph_out_lang_type_class (pph_stream *str
 }
 
 
+/* Write all the merge key fields in lang_type_class instance LTC to STREAM.  
*/
+
+static void
+pph_out_merge_key_lang_type_class (pph_stream *stream,
+  struct 

[patch, committed] invoke.texi: DWARF, stabs, and ELF

2012-03-09 Thread Sandra Loosemore
Per the DWARF web site

http://dwarfstd.org/Download.php

the correct names of the various versions of the DWARF standard appear 
to be either DWARF Version N or DWARF N, rather than e.g. DWARF2, 
DWARF-2, dwarf2, or whatever.  This patch to invoke.texi makes usages 
reflect the official names.  Similarly, I've fixed up a couple instances 
of incorrect usage of stabs (official name seems to be all lowercase, 
like that) and ELF.

Checked in to trunk as obvious.

-Sandra


2012-03-09  Sandra Loosemore  san...@codesourcery.com

gcc/
* doc/invoke.texi: Use correct names for DWARF, stabs, and ELF.

Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 185148)
+++ gcc/doc/invoke.texi	(working copy)
@@ -4756,7 +4756,7 @@ factor of two.
 @item -fno-debug-types-section
 @opindex fno-debug-types-section
 @opindex fdebug-types-section
-By default when using DWARF v4 or higher type DIEs will be put into
+By default when using DWARF Version 4 or higher type DIEs will be put into
 their own .debug_types section instead of making them part of the
 .debug_info section.  It is more efficient to put them in a separate
 comdat sections since the linker will then be able to remove duplicates.
@@ -4794,7 +4794,7 @@ Produce debugging information in DWARF f
 supported).  This is the format used by DBX on IRIX 6.  The value
 of @var{version} may be either 2, 3 or 4; the default version is 2.
 
-Note that with DWARF version 2 some ports require, and will always
+Note that with DWARF Version 2 some ports require, and will always
 use, some non-conflicting DWARF 3 extensions in the unwind tables.
 
 Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
@@ -4919,9 +4919,9 @@ other than debugging the compiler proper
 
 @item -feliminate-dwarf2-dups
 @opindex feliminate-dwarf2-dups
-Compress DWARF2 debugging information by eliminating duplicated
+Compress DWARF 2 debugging information by eliminating duplicated
 information about each symbol.  This option only makes sense when
-generating DWARF2 debugging information with @option{-gdwarf-2}.
+generating DWARF 2 debugging information with @option{-gdwarf-2}.
 
 @item -femit-struct-debug-baseonly
 Emit debug information for struct-like types
@@ -6096,7 +6096,7 @@ is used when GCC itself is being built.)
 
 @item -feliminate-unused-debug-types
 @opindex feliminate-unused-debug-types
-Normally, when producing DWARF2 output, GCC will emit debugging
+Normally, when producing DWARF 2 output, GCC will emit debugging
 information for all types declared in a compilation
 unit, regardless of whether or not they are actually used
 in that compilation unit.  Sometimes this is useful, such as
@@ -11764,7 +11764,7 @@ is default.
 @item -msim
 @opindex msim
 Links the library libsim.a which is in compatible with simulator. Applicable
-to elf compiler only.
+to ELF compiler only.
 
 @item -mint32
 @opindex mint32
@@ -11851,7 +11851,7 @@ warn about constructs contained within h
 
 @item -gused
 @opindex gused
-Emit debugging information for symbols that are used.  For STABS
+Emit debugging information for symbols that are used.  For stabs
 debugging format, this enables @option{-feliminate-unused-debug-symbols}.
 This is by default ON@.
 
@@ -17651,7 +17651,7 @@ type. This is the default.
 Store (do not store) the address of the caller's frame as backchain pointer
 into the callee's stack frame.
 A backchain may be needed to allow debugging using tools that do not understand
-DWARF-2 call frame information.
+DWARF 2 call frame information.
 When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
 at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
 the backchain is placed into the topmost word of the 96/160 byte register
@@ -19156,7 +19156,7 @@ that needs this handling would enable it
 
 @item -fasynchronous-unwind-tables
 @opindex fasynchronous-unwind-tables
-Generate unwind table in dwarf2 format, if supported by target machine.  The
+Generate unwind table in DWARF 2 format, if supported by target machine.  The
 table is exact at each instruction boundary, so it can be used for stack
 unwinding from asynchronous events (such as debugger or garbage collector).
 


[patch, committed] invoke.texi: use correct name/markup for GCC and other program names

2012-03-09 Thread Sandra Loosemore
Per the GCC Coding Conventions, GCC should be referred to as GCC or 
@command{gcc}, depending on whether one is talking about the program 
generally or the command to run it.  Also, when GCC appears at the 
end of a sentence, the correct Texinfo markup is GCC@. rather than 
just GCC.

While I was at it, I checked references to GDB and ld.  For the latter, 
the GNU ld manual seems to prefer @command markup in all contexts, so that's 
what I did here.

Checked in to trunk as obvious.

-Sandra


2012-03-09  Sandra Loosemore  san...@codesourcery.com

gcc/
* doc/invoke.texi: Use correct names/markup for GCC, GDB, ld,
and related program names.

Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 185167)
+++ gcc/doc/invoke.texi	(working copy)
@@ -1303,7 +1303,7 @@ option.
 @item @var{language}
 This will display the options supported for @var{language}, where
 @var{language} is the name of one of the languages supported in this
-version of GCC.
+version of GCC@.
 
 @item @samp{common}
 This will display the options that are common to all languages.
@@ -2746,7 +2746,7 @@ which is controlled by the separate C/C+
 this option is used with the Objective-C or Objective-C++ compiler,
 any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
 This is useful if you need to make sure that your Objective-C code can
-be compiled with older versions of GCC.
+be compiled with older versions of GCC@.
 
 @item -freplace-objc-classes
 @opindex freplace-objc-classes
@@ -2898,7 +2898,7 @@ are not inherently erroneous but that ar
 may have been an error.
 
 The following language-independent options do not enable specific
-warnings but control the kinds of diagnostics produced by GCC.
+warnings but control the kinds of diagnostics produced by GCC@.
 
 @table @gcctabopt
 @cindex syntax checking
@@ -4415,7 +4415,7 @@ when applied ensure that two sequences t
 the same sequence.  GCC can warn you if you are using identifiers that
 have not been normalized; this option controls that warning.
 
-There are four levels of warning supported by GCC.  The default is
+There are four levels of warning supported by GCC@.  The default is
 @option{-Wnormalized=nfc}, which warns about any identifier that is
 not in the ISO 10646 ``C'' normalized form, @dfn{NFC}.  NFC is the
 recommended form for most uses.
@@ -7936,7 +7936,7 @@ The current implementation of LTO makes 
 attempt to generate bytecode that is portable between different
 types of hosts.  The bytecode files are versioned and there is a
 strict version check, so bytecode files generated in one version of
-GCC will not work with an older/newer version of GCC.
+GCC will not work with an older/newer version of GCC@.
 
 Link-time optimization does not work well with generation of debugging
 information.  Combining @option{-flto} with
@@ -8010,7 +8010,8 @@ and is ignored at link time.
 
 @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
 requires the complete toolchain to be aware of LTO. It requires a linker with
-linker plugin support for basic functionality.  Additionally, nm, ar and ranlib
+linker plugin support for basic functionality.  Additionally,
+@command{nm}, @command{ar} and @command{ranlib}
 need to support linker plugins to allow a full-featured build environment
 (capable of building static libraries etc).
 
@@ -8584,7 +8585,7 @@ when modulo scheduling a loop.  Larger v
 compilation time.
 
 @item max-inline-insns-single
-Several parameters control the tree inliner used in gcc.
+Several parameters control the tree inliner used in GCC@.
 This number sets the maximum number of instructions (counted in GCC's
 internal representation) in a single function that the tree inliner
 will consider for inlining.  This only affects functions declared
@@ -9631,7 +9632,7 @@ This option specifies where to find the 
 include files, and data files of the compiler itself.
 
 The compiler driver program runs one or more of the subprograms
-@file{cpp}, @file{cc1}, @file{as} and @file{ld}.  It tries
+@command{cpp}, @command{cc1}, @command{as} and @command{ld}.  It tries
 @var{prefix} as a prefix for each program it tries to run, both with and
 without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}).
 
@@ -9671,9 +9672,9 @@ with boot-strapping the compiler.
 @item -specs=@var{file}
 @opindex specs
 Process @var{file} after the compiler reads in the standard @file{specs}
-file, in order to override the defaults which the @file{gcc} driver
-program uses when determining what switches to pass to @file{cc1},
-@file{cc1plus}, @file{as}, @file{ld}, etc.  More than one
+file, in order to override the defaults which the @command{gcc} driver
+program uses when determining what switches to pass to @command{cc1},
+@command{cc1plus}, @command{as}, @command{ld}, etc.  More than one
 @option{-specs=@var{file}} can be specified on the command line, and they
 are 

[patch, RFA] delete obsolete -madjust-unroll option for SH

2012-03-09 Thread Sandra Loosemore
When I was working on cleanups to invoke.texi I noticed this bit in the
SH Options section:

@item -madjust-unroll
@opindex madjust-unroll
Throttle unrolling to avoid thrashing target registers.
This option only has an effect if the GCC code base supports the
TARGET_ADJUST_UNROLL_MAX target hook.

Well, the current manual is supposed to document what the current GCC 
code base does, so I looked up this target hook and found it was deleted 
in 2007 with a ChangeLog note that it has been dead since gcc 4.0.0.  
However the command-line option is still present.  :-S

Any reason why we should not delete this entirely, per the attached patch?  
I haven't built/tested this (except for the manual) but can do that if the 
patch isn't sufficiently obvious.

-Sandra


2012-03-09  Sandra Loosemore  san...@codesourcery.com

gcc/
* config/sh/sh.opt (madjust-unroll): Delete.
* config/sh/sh.h (TARGET_OPT_DEFAULT): Don't use MASK_ADJUST_UNROLL.
* doc/invoke.texi (Option Summary): Remove -madjust-unroll.
(SH Options): Likewise.
Index: gcc/config/sh/sh.opt
===
--- gcc/config/sh/sh.opt	(revision 185167)
+++ gcc/config/sh/sh.opt	(working copy)
@@ -205,10 +205,6 @@ maccumulate-outgoing-args
 Target Report Mask(ACCUMULATE_OUTGOING_ARGS)
 Reserve space for outgoing arguments in the function prologue
 
-madjust-unroll
-Target Report Mask(ADJUST_UNROLL) Condition(SUPPORT_ANY_SH5)
-Throttle unrolling to avoid thrashing target registers unless the unroll benefit outweighs this
-
 mb
 Target Report RejectNegative InverseMask(LITTLE_ENDIAN)
 Generate code in big endian mode
Index: gcc/config/sh/sh.h
===
--- gcc/config/sh/sh.h	(revision 185167)
+++ gcc/config/sh/sh.h	(working copy)
@@ -290,7 +290,7 @@ do { \
 #endif
 
 #ifndef TARGET_OPT_DEFAULT
-#define TARGET_OPT_DEFAULT  MASK_ADJUST_UNROLL
+#define TARGET_OPT_DEFAULT  0
 #endif
 
 #define TARGET_DEFAULT \
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 185168)
+++ gcc/doc/invoke.texi	(working copy)
@@ -885,7 +885,7 @@ See RS/6000 and PowerPC Options.
 -mieee  -mbitops  -misize  -minline-ic_invalidate -mpadstruct  -mspace @gol
 -mprefergot  -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol
 -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol
--madjust-unroll -mindexed-addressing -mgettrcost=@var{number} -mpt-fixed @gol
+-mindexed-addressing -mgettrcost=@var{number} -mpt-fixed @gol
 -maccumulate-outgoing-args -minvalid-symbols -msoft-atomic @gol
 -mbranch-cost=@var{num} -mcbranchdi -mcmpeqdi -mfused-madd -mpretend-cmove @gol
 -menable-tas}
@@ -18129,12 +18129,6 @@ useful when compiling kernel code.  A re
 two registers separated by a dash.  Multiple register ranges can be
 specified separated by a comma.
 
-@item -madjust-unroll
-@opindex madjust-unroll
-Throttle unrolling to avoid thrashing target registers.
-This option only has an effect if the GCC code base supports the
-TARGET_ADJUST_UNROLL_MAX target hook.
-
 @item -mindexed-addressing
 @opindex mindexed-addressing
 Enable the use of the indexed addressing mode for SHmedia32/SHcompact.


Re: [PATCH] Improve PHI-OPT when there are multiple phis

2012-03-09 Thread Andrew Pinski
Woops I forgot the patch.

Thanks,
Andrew Pinski

On Fri, Mar 9, 2012 at 11:45 AM, Andrew Pinski
andrew.pin...@caviumnetworks.com wrote:
 On Tue, Jan 24, 2012 at 2:50 AM, Richard Guenther
 richard.guent...@gmail.com wrote:
 On Tue, Jan 24, 2012 at 7:34 AM, Andrew Pinski
 andrew.pin...@caviumnetworks.com wrote:
 Hi,
  Right now PHI-OPT does try to handle the case where we have multiple
 PHIs but the other PHIs have the same value for the edges we care
 about.
 This fixes the issue and allows PHI-OPT to handle a few more cases and
 it removes the TODO in the comments.

 OK For 4.8? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

 Thanks,
 Andrew Pinski

 ChangeLog:
 * tree-ssa-phiopt.c (gimple_phi_singleton_for_edges): New function.

 The name is confusing I think, because it returns the single non-singleton
 PHI for the edge pair ... you can avoid choosing a better name by
 inlining it to its single call site.  I'd maybe name it
 single_non_singleton_phi_for_edges.

 Otherwise ok.

 Here is the updated patch with one small change, value_replacement
 uses single_non_singleton_phi_for_edges now too.

 OK still?  Bootstrapped and tested on x86_64-linux-gnu with no regressions.


 Thanks,
 Andrew Pinski


 ChangeLog:
 * tree-ssa-phiopt.c (single_non_singleton_phi_for_edges): New function.
 (tree_ssa_phiopt_worker): Use single_non_singleton_phi_for_edges.
 (value_replacement): Likewise.
 (empty_block_p): Check also if the PHIs for the block are empty.

 testsuite/ChangeLog:
 * gcc.dg/tree-ssa/phi-opt-7.c: New testcase.



 Thanks,
 Richard.

 (tree_ssa_phiopt_worker): Use gimple_phi_singleton_for_edges.
 (empty_block_p): Check also if the PHIs for the block are empty.

 testsuite/ChangeLog:
 * gcc.dg/tree-ssa/phi-opt-7.c: New testcase.
Index: testsuite/gcc.dg/tree-ssa/phi-opt-7.c
===
--- testsuite/gcc.dg/tree-ssa/phi-opt-7.c   (revision 0)
+++ testsuite/gcc.dg/tree-ssa/phi-opt-7.c   (revision 0)
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options -O1 -fdump-tree-optimized } */
+
+int g(int,int);
+int f(int t, int c)
+{
+  int d = 0;
+  int e = 0;
+  if (t)
+{
+  d = t;
+  if (c) e = 1;
+}
+  else d = 0, e = 0;
+  return g(d,e);
+}
+
+/* There should be one ifs as one of them should be changed into
+   a conditional and the other should be there still.  */
+/* { dg-final { scan-tree-dump-times if 1 optimized }  }*/
+/* { dg-final { scan-tree-dump-times D.\[0-9\]*_\[0-9\]* = c_\[0-9\]*.D. != 
0 1 optimized  } } */
+/* { dg-final { cleanup-tree-dump optimized } } */
+
Index: testsuite/gcc.dg/tree-ssa/phi-opt-8.c
===
--- testsuite/gcc.dg/tree-ssa/phi-opt-8.c   (revision 185132)
+++ testsuite/gcc.dg/tree-ssa/phi-opt-8.c   (working copy)
@@ -19,7 +19,7 @@ int f(int t, int c)
but currently is not as PHI-OPT does not reduce the t PHI as we have
two phis.  Note this is fixed with
http://gcc.gnu.org/ml/gcc-patches/2012-01/msg01195.html .  */
-/* { dg-final { scan-tree-dump-not if phiopt1 { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-not if phiopt1 } } */
 /* { dg-final { scan-tree-dump g .t_\[0-9\]*.D., optimized } } */
 /* { dg-final { scan-tree-dump-not PHI optimized } } */
 /* { dg-final { cleanup-tree-dump phiopt1 } } */
Index: tree-ssa-phiopt.c
===
--- tree-ssa-phiopt.c   (revision 185132)
+++ tree-ssa-phiopt.c   (working copy)
@@ -193,6 +193,33 @@ tree_ssa_cs_elim (void)
   return tree_ssa_phiopt_worker (true);
 }
 
+/* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */
+
+static gimple
+single_non_singleton_phi_for_edges (gimple_seq seq, edge e0, edge e1)
+{
+  gimple_stmt_iterator i;
+  gimple phi = NULL;
+  if (gimple_seq_singleton_p (seq))
+return gsi_stmt (gsi_start (seq));
+  for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (i))
+{
+  gimple p = gsi_stmt (i);
+  /* If the PHI arguments are equal then we can skip this PHI. */
+  if (operand_equal_for_phi_arg_p (gimple_phi_arg_def (p, e0-dest_idx),
+  gimple_phi_arg_def (p, e1-dest_idx)))
+   continue;
+
+  /* If we already have a PHI that has the two edge arguments are
+different, then return it is not a singleton for these PHIs. */
+  if (phi)
+   return NULL;
+
+  phi = p;
+}
+  return phi;
+}
+
 /* For conditional store replacement we need a temporary to
put the old contents of the memory in.  */
 static tree condstoretemp;
@@ -316,6 +343,7 @@ tree_ssa_phiopt_worker (bool do_store_el
  gimple_seq phis = phi_nodes (bb2);
  gimple_stmt_iterator gsi;
  bool candorest = true;
+
  /* Value replacement can work with more than one PHI
 so try that first. */
  for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (gsi))
@@ -333,21 +361,8