Re: [RFC] Fix unwind info for sparc -mflat

2011-06-26 Thread Eric Botcazou
> I tried to figure out why things had been done in this
> slightly convoluted manner and failed.  It seems to me that
> this is easily represented with the individual instructions.
> A comment indicated that there had been problems with the
> copy to %o7 being deleted.  Elsewhere we have successfully
> used a naked USE pattern to keep such things from being
> deleted.

I have 4 regressions in the C testsuite with -mflat on SPARC/Solaris:

FAIL: gcc.c-torture/execute/builtins/stpcpy-chk.c execution,  -O2 -flto
FAIL: gcc.c-torture/execute/nestfunc-4.c execution,  -Os
FAIL: gcc.c-torture/execute/pr19005.c execution,  -O2
FAIL: gcc.c-torture/execute/strncmp-1.c execution,  -O2 -flt

The problem is that the blockage isn't emitted if the frame pointer isn't used.
I have also fixed the swapping %o7/%i7 (despite the name, %o7 is the incoming 
return address register from GCC's viewpoint, and %i7 the register where you 
save the return address for the rest of the function).

Tested on SPARC/Solaris, applied on the mainline.


2011-06-26  Eric Botcazou  

* config/sparc/sparc.c (save_local_or_in_reg_p): Adjust comment.
(emit_save_register_window): Likewise.
(sparc_expand_prologue): Use SIZE_INT_RTX and SIZE_RTX variables.
(sparc_flat_expand_prologue): Add comment.  Always emit blockage.
Swap back %o7/%i7 in register naming.


-- 
Eric Botcazou
Index: config/sparc/sparc.c
===
--- config/sparc/sparc.c	(revision 175398)
+++ config/sparc/sparc.c	(working copy)
@@ -4149,7 +4149,7 @@ save_local_or_in_reg_p (unsigned int reg
   if (regno == RETURN_ADDR_REGNUM && return_addr_reg_needed_p (leaf_function))
 return true;
 
-  /* PIC register (%l7) if needed.  */
+  /* GOT register (%l7) if needed.  */
   if (regno == PIC_OFFSET_TABLE_REGNUM && crtl->uses_pic_offset_table)
 return true;
 
@@ -4600,11 +4600,12 @@ emit_save_register_window (rtx increment
   insn = emit_insn (gen_save_register_window_1 (increment));
   RTX_FRAME_RELATED_P (insn) = 1;
 
-  /* The return address (%i7) is saved in %o7.  */
+  /* The incoming return address (%o7) is saved in %i7.  */
   add_reg_note (insn, REG_CFA_REGISTER,
 		gen_rtx_SET (VOIDmode,
 			 gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM),
-			 gen_rtx_REG (Pmode, INCOMING_RETURN_ADDR_REGNUM)));
+			 gen_rtx_REG (Pmode,
+	  INCOMING_RETURN_ADDR_REGNUM)));
 
   /* The window save event.  */
   add_reg_note (insn, REG_CFA_WINDOW_SAVE, const0_rtx);
@@ -4688,8 +4689,10 @@ sparc_expand_prologue (void)
 ; /* do nothing.  */
   else if (sparc_leaf_function_p)
 {
+  rtx size_int_rtx = GEN_INT (-size);
+
   if (size <= 4096)
-	insn = emit_insn (gen_stack_pointer_inc (GEN_INT (-size)));
+	insn = emit_insn (gen_stack_pointer_inc (size_int_rtx));
   else if (size <= 8192)
 	{
 	  insn = emit_insn (gen_stack_pointer_inc (GEN_INT (-4096)));
@@ -4699,19 +4702,21 @@ sparc_expand_prologue (void)
 	}
   else
 	{
-	  rtx reg = gen_rtx_REG (Pmode, 1);
-	  emit_move_insn (reg, GEN_INT (-size));
-	  insn = emit_insn (gen_stack_pointer_inc (reg));
+	  rtx size_rtx = gen_rtx_REG (Pmode, 1);
+	  emit_move_insn (size_rtx, size_int_rtx);
+	  insn = emit_insn (gen_stack_pointer_inc (size_rtx));
 	  add_reg_note (insn, REG_FRAME_RELATED_EXPR,
-			gen_stack_pointer_inc (GEN_INT (-size)));
+			gen_stack_pointer_inc (size_int_rtx));
 	}
 
   RTX_FRAME_RELATED_P (insn) = 1;
 }
   else
 {
+  rtx size_int_rtx = GEN_INT (-size);
+
   if (size <= 4096)
-	emit_save_register_window (GEN_INT (-size));
+	emit_save_register_window (size_int_rtx);
   else if (size <= 8192)
 	{
 	  emit_save_register_window (GEN_INT (-4096));
@@ -4720,9 +4725,9 @@ sparc_expand_prologue (void)
 	}
   else
 	{
-	  rtx reg = gen_rtx_REG (Pmode, 1);
-	  emit_move_insn (reg, GEN_INT (-size));
-	  emit_save_register_window (reg);
+	  rtx size_rtx = gen_rtx_REG (Pmode, 1);
+	  emit_move_insn (size_rtx, size_int_rtx);
+	  emit_save_register_window (size_rtx);
 	}
 }
 
@@ -4783,6 +4788,10 @@ sparc_flat_expand_prologue (void)
 
   size_rtx = size_int_rtx = GEN_INT (-size);
 
+  /* We establish the frame (i.e. decrement the stack pointer) first, even
+	 if we use a frame pointer, because we cannot clobber any call-saved
+	 registers, including the frame pointer, if we haven't created a new
+	 register save area, for the sake of compatibility with the ABI.  */
   if (size <= 4096)
 	insn = emit_insn (gen_stack_pointer_inc (size_int_rtx));
   else if (size <= 8192 && !frame_pointer_needed)
@@ -4801,6 +4810,9 @@ sparc_flat_expand_prologue (void)
 	}
   RTX_FRAME_RELATED_P (insn) = 1;
 
+  /* Ensure nothing is scheduled until after the frame is established.  */
+  emit_insn (gen_blockage ());
+
   if (frame_pointer_needed)
 	{
 	  insn = emit_insn (gen_rtx_SET (VOIDmode, hard_frame_pointer_rtx,
@@ -4813,26 +4825,22 @@ sparc_flat_expand_prologue (void)
 			ge

[trunk] RFA: translate built-in include paths for sysroot (issue4641076)

2011-06-26 Thread Chris Demetriou
The setup:

Configuring a toolchain targeting x86-64 GNU Linux (Ubuntu Lucid), as a
cross-compiler.  Using a sysroot to provide the Lucid headers+libraries,
with the sysroot path being within the GCC install tree.  Want to use the
Lucid system libstdc++ and headers, which means that I'm not
building/installing libstdc++-v3.

So, configuring with:
  --with-sysroot="$SYSROOT"
  --disable-libstdc++-v3 \
  --with-gxx-include-dir="$SYSROOT/usr/include/c++/4.4" \
(among other options).

Hoping to support two usage models with this configuration, w.r.t. use of
the sysroot:

(1) somebody installs the sysroot in the normal location relative to the
GCC install, and relocates the whole bundle (sysroot+GCC).  This works
great AFAICT, GCC finds its includes (including the C++ includes) thanks
to the add_standard_paths iprefix handling.

(2) somebody installs the sysroot in a non-standard location, and uses
--sysroot to try to access it.  This works fine for the C headers, but
doesn't work.

For the C headers, add_standard_paths prepends the sysroot location to
the /usr/include path (since that's what's specified in cppdefault.c for
that path).  It doesn't do the same for the C++ include path, though
(again, as specified in cppdefault.c).

add_standard_paths doesn't attempt to relocate built-in include paths that
start with the compiled-in sysroot location (e.g., the g++ include dir, in
this case).  This isn't surprising really: normally you either prepend the
sysroot location or you don't (as specified by cppdefault.c); none of the
built-in paths normally *start* with the sysroot location and need to be
relocated.  However, in this odd-ball case of trying to use the C++ headers
from the sysroot, one of the paths *does* need to be relocated in this way.


The following patch adds code to add_standard_paths to do the sysroot
translation (for oddball configurations like mine).


Tested before/after on a x86_64-unknown-linux-gnu system, with
--enable-languages=all, RUNTESTFLAGS='--target_board=unix\{-m32,-m64\}'.
No changes in test results.  (!! usually there are some, only dates this time!)
Also built my special cross configuration, that worked as expected.


OK for trunk?



chris
---
[gcc/ChangeLog]
2011-06-25  Chris Demetriou  

* cppdefault.h (cpp_TARGET_SYSTEM_ROOT): New variable.
(cpp_TARGET_SYSTEM_ROOT_len): Likewise.
* cppdefault.c (cpp_TARGET_SYSTEM_ROOT): Likewise.
(cpp_TARGET_SYSTEM_ROOT_len): Likewise.
* incpath.c (add_standard_paths): Relocate paths that start
with the compiled-in sysroot path, if a sysroot is given.

Index: incpath.c
===
--- incpath.c   (revision 175395)
+++ incpath.c   (working copy)
@@ -133,6 +133,30 @@ add_standard_paths (const char *sysroot, const cha
   int relocated = cpp_relocated();
   size_t len;
 
+  if (sysroot && (len = cpp_TARGET_SYSTEM_ROOT_len) != 0)
+{
+  /* Look for directories that start with the compiled-in sysroot prefix.
+"Translate" them, i.e. replace /usr/local/target/sys-root... with
+SYSROOT and search them first.  */
+  for (p = cpp_include_defaults; p->fname; p++)
+   {
+ if (!p->cplusplus || cxx_stdinc)
+   {
+  /* If we're going to add the sysroot to a path, then it
+ is not expected to start with the path to the sysroot.  */
+ if (p->add_sysroot)
+   continue;
+ if (!filename_ncmp (p->fname, cpp_TARGET_SYSTEM_ROOT, len))
+   {
+ char *str = concat (sysroot, p->fname + len, NULL);
+ if (p->multilib && imultilib)
+   str = concat (str, dir_separator_str, imultilib, NULL);
+ add_path (str, SYSTEM, p->cxx_aware, false);
+   }
+   }
+   }
+}
+
   if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0)
 {
   /* Look for directories that start with the standard prefix.
Index: cppdefault.c
===
--- cppdefault.c(revision 175395)
+++ cppdefault.c(working copy)
@@ -117,6 +117,15 @@ const char cpp_EXEC_PREFIX[] = STANDARD_EXEC_PREFI
 /* This value is set by cpp_relocated at runtime */
 const char *gcc_exec_prefix;
 
+/* The configured target system root (sysroot).  */
+#ifdef TARGET_SYSTEM_ROOT
+const char cpp_TARGET_SYSTEM_ROOT[] = TARGET_SYSTEM_ROOT;
+const size_t cpp_TARGET_SYSTEM_ROOT_len = sizeof TARGET_SYSTEM_ROOT - 1;
+#else
+const char cpp_TARGET_SYSTEM_ROOT[] = "";
+const size_t cpp_TARGET_SYSTEM_ROOT_len = 0;
+#endif
+
 /* Return true if the toolchain is relocated.  */
 bool
 cpp_relocated (void)
Index: cppdefault.h
===
--- cppdefault.h(revision 175395)
+++ cppdefault.h(working copy)
@@ -63,6 +63,11 @@ extern const char cpp_EXEC_PREFIX[];
 /* The run-time execution prefix.  This is

Updated: RFA: partially hookize POINTER_SIZE

2011-06-26 Thread Joern Rennecke



This is basically the same patch as posted before in
http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02772.html and updated in
http://gcc.gnu.org/viewcvs?view=revision&revision=168273, but with a
few merge conflicts in current mainline resolved.

Re-tested natively with a bootstrap & regtest on gcc20, and
cross-configurations with the contrib/config-list.mk makefile.
Configurations that could not be tested because they are currently broken
in mainline (PR47093) are:
arm-freebsd6 arm-wince-pe i686-interix3 --enable-obsolete i686-openbsd3.0 
i686-pc-msdosdjgpp i686-wrs-vxworksae lm32-elf lm32-rtems lm32-uclinux mep-elf 
microblaze-elf microblaze-linux mips-openbsd powerpc-wrs-vxworksae 
rs6000-ibm-aix5.2.0 rs6000-ibm-aix5.3.0 rs6000-ibm-aix6.0 score-elf 
--enable-obsolete vax-openbsd x86_64-knetbsd-gnu

2011-06-26  Joern Rennecke  

PR other/46677
gcc:
* targhooks.c (pointer_size): New function.
* cppbuiltin.c (define_builtin_macros_for_lp64): Use pointer_size.
(define_builtin_macros_for_type_sizes): Likewise.
* target.h (pointer_size): Declare.

* cppbuiltin.c (define_builtin_macros_for_type_sizes):
Use TYPE_PRECISION (char_type_node).
gcc/c-family:
c-common.c (c_common_nodes_and_builtins): Use pointer_size.
gcc/java:
* java-tree.h (JAVA_POINTER_SIZE): Define.
* class.c (make_class_data): Use JAVA_POINTER_SIZE.
(emit_register_classes): Likewise.
* jcf-parse.c (handle_long_constant): Likewise.
* constants.c (build_constants_constructor): Likewise.
* builtins.c (UNMARSHAL3, UNMARSHAL4, UNMARSHAL5): Likewise.
(compareAndSwapObject_builtin): Likewise.
* boehm.c (get_boehm_type_descriptor): Likewise.
(mark_reference_fields): Add log2_size parameter.  Changed all callers.
gcc/cp:
* cvt.c (cp_convert_to_pointer): Use TYPE_PRECISION (ptr_type_node).
gcc/fortran:
* trans-types.c (gfc_init_kinds): Use pointer_size.
gcc/lto:
* lto-object.c (lto_obj_begin_section): Use pointer_size.
ada:
* gcc-interface/decl.c (gnat_to_gnu_entity): Replace pointer_size
with pointer_size_t.  Replace POINTER_SIZE with pointer_size ().
(gnat_to_gnu_param): Use pointer_size.
(annotate_rep, make_type_from_size): Likewise.
* gcc-interface/utils.c (finish_fat_pointer_type): Likewise.
* gcc-interface/utils2.c: Include target.h .
(maybe_wrap_malloc, maybe_wrap_free): Use pointer_size.
* gcc-interface/targtyps.c: Include target.h .
(get_target_pointer_size): Use pointer_size.

Index: gcc/targhooks.c
===
--- gcc/targhooks.c (revision 175397)
+++ gcc/targhooks.c (working copy)
@@ -1441,4 +1441,23 @@ default_pch_valid_p (const void *data_p,
   return NULL;
 }
 
+/* Return the size of a pointer.  This function might be used when
+   ptr_type_node is not / is not known to be set up, like in the
+   preprocessor.  */
+unsigned
+pointer_size (void)
+{
+  enum machine_mode
+mode = targetm.addr_space.pointer_mode (ADDR_SPACE_GENERIC);
+
+  /* If the hook definition uses ptr_mode, and we are called before
+ init_emit_once, e.g. from the preprocessor, we might see VOIDmode.  */
+  if (mode == VOIDmode)
+{
+  gcc_assert (mode == ptr_mode);
+  return POINTER_SIZE;
+}
+  return GET_MODE_BITSIZE (mode);
+}
+
 #include "gt-targhooks.h"
Index: gcc/cppbuiltin.c
===
--- gcc/cppbuiltin.c(revision 175397)
+++ gcc/cppbuiltin.c(working copy)
@@ -105,7 +105,7 @@ define_builtin_macros_for_compilation_fl
 define_builtin_macros_for_lp64 (cpp_reader *pfile)
 {
   if (TYPE_PRECISION (long_integer_type_node) == 64
-  && POINTER_SIZE == 64
+  && pointer_size () == 64
   && TYPE_PRECISION (integer_type_node) == 32)
 {
   cpp_define (pfile, "_LP64");
@@ -163,9 +163,13 @@ #define define_type_sizeof(NAME, TYPE)
  : "__ORDER_LITTLE_ENDIAN__"));
 
   /* ptr_type_node can't be used here since ptr_mode is only set when
- toplev calls backend_init which is not done with -E switch.  */
+ toplev calls backend_init which is not done with -E switch.
+ In principle we could use
+ targetm.addr_space.pointer_mode (ADDR_SPACE_GENERIC), but we don't really
+ want the prepocessor to have to know about machine modes, and most
+ definitions of the hook also use ptr_mode.  */
   cpp_define_formatted (pfile, "__SIZEOF_POINTER__=%d",
-   POINTER_SIZE / BITS_PER_UNIT);
+   pointer_size () / TYPE_PRECISION (char_type_node));
 }
 
 
Index: gcc/c-family/c-common.c
===
--- gcc/c-family/c-common.c (revision 175397)
+++ gcc/c-family/c-common.c (working copy)
@@ -5000,7 +5000,7 @@ c_common_nodes_and_builtins (void)
   /* Create the built-

C++ PATCH for c++/49528 (omitting destructor for temporary with constant value)

2011-06-26 Thread Jason Merrill
The constant expression evaluation code was happily replacing an 
expression involving a temporary with its constant value even if the 
temporary had a destructor that needed to be run.


After fixing that, I needed to adjust expand_default_init to avoid 
adding a TARGET_EXPR when we aren't really creating a temporary.


Tested x86_64-pc-linux-gnu, applying to trunk.  Jakub, should this go 
into 4.6.1 or .2?
commit e42fdb0afe8827e3320239e252d804e2e3bbd63d
Author: Jason Merrill 
Date:   Sat Jun 25 20:52:43 2011 -0400

	PR c++/49528
	* semantics.c (potential_constant_expression_1): A TARGET_EXPR
	with a cleanup isn't constant.
	(cxx_eval_constant_expression): Likewise.
	* init.c (expand_default_init): Use maybe_constant_init.

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 3c347a4..3ceed90 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1514,7 +1514,7 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags,
   tree fn = get_callee_fndecl (rval);
   if (fn && DECL_DECLARED_CONSTEXPR_P (fn))
 	{
-	  tree e = maybe_constant_value (rval);
+	  tree e = maybe_constant_init (rval);
 	  if (TREE_CONSTANT (e))
 	rval = build2 (INIT_EXPR, type, exp, e);
 	}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index f4aa350..5404c9f 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7020,6 +7020,16 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
   break;
 
 case TARGET_EXPR:
+  /* A cleanup isn't constant.  */
+  if (TARGET_EXPR_CLEANUP (t))
+	{
+	  if (!allow_non_constant)
+	error ("temporary of type %qT needing destruction in a "
+		   "constant expression", TREE_TYPE (t));
+	  *non_constant_p = true;
+	  break;
+	}
+  /* else fall through.  */
 case INIT_EXPR:
   /* Pass false for 'addr' because these codes indicate
 	 initialization of a temporary.  */
@@ -7840,8 +7850,16 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
   return potential_constant_expression_1 (TREE_OPERAND (t, 1),
 	  want_rval, flags);
 
-case INIT_EXPR:
 case TARGET_EXPR:
+  /* A cleanup isn't constant.  */
+  if (TARGET_EXPR_CLEANUP (t))
+	{
+	  if (flags & tf_error)
+	error ("temporary of type %qT needing destruction in a "
+		   "constant expression", TREE_TYPE (t));
+	  return false;
+	}
+case INIT_EXPR:
   return potential_constant_expression_1 (TREE_OPERAND (t, 1),
 	  rval, flags);
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C
new file mode 100644
index 000..b3fb9a8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C
@@ -0,0 +1,9 @@
+// { dg-options -std=c++0x }
+
+struct A
+{
+  int i;
+  ~A();
+};
+
+constexpr int i = A().i;	// { dg-error "destruction" }
diff --git a/gcc/testsuite/g++.dg/init/ref19.C b/gcc/testsuite/g++.dg/init/ref19.C
new file mode 100644
index 000..ed78c93
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/ref19.C
@@ -0,0 +1,17 @@
+// PR c++/49528
+// { dg-do run }
+
+int d;
+
+struct A
+{
+  int i;
+  ~A() { ++d; };
+};
+
+int main()
+{
+  const int &r = A().i;
+  if (d != 1)
+return 1;
+}


Re: C++ PATCH for c++/49528 (omitting destructor for temporary with constant value)

2011-06-26 Thread Jason Merrill

On 06/26/2011 10:00 AM, Jason Merrill wrote:

Tested x86_64-pc-linux-gnu, applying to trunk. Jakub, should this go
into 4.6.1 or .2?


I think it's fine to wait for .2, since a class with a non-trivial 
destructor is likely to also have a non-trivial, non-constexpr 
constructor, which would prevent A() from having a constant value.


Jason


Re: [trunk] RFA: translate built-in include paths for sysroot (issue4641076)

2011-06-26 Thread Joseph S. Myers
On Sat, 25 Jun 2011, Chris Demetriou wrote:

> For the C headers, add_standard_paths prepends the sysroot location to
> the /usr/include path (since that's what's specified in cppdefault.c for
> that path).  It doesn't do the same for the C++ include path, though
> (again, as specified in cppdefault.c).

It seems to me that what's really wanted here is to change the add_sysroot 
flag for the C++ path (all of the C++ paths?), rather than adding special 
code to detect paths starting with the sysroot and reinterpret them.  And 
so making configure detect when the --with-gxx-include-dir setting starts 
with the sysroot and adjusting the flag accordingly in that case would be 
a cleaner solution - that way it would be obvious that the semantics of 
the relocation are exactly the same as for other sysrooted paths, whereas 
it isn't when the relocation goes through different code paths in the 
compiler.

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


Re: Updated: RFA: partially hookize POINTER_SIZE

2011-06-26 Thread Joseph S. Myers
The cppbuiltin.c and c-common.c changes are OK.  I'm not sure what the 
best approach is for a proper hook conversion of POINTER_SIZE, but I don't 
think this patch makes things any worse.  (The things that need 
considering together in a hook conversion are how the modes for both Pmode 
and ptr_mode are defined, as well as the POINTER_SIZE macro - and I'm not 
sure why Pmode is a macro but ptr_mode a global variable.  I suspect it 
should be necessary to define just the two modes and not a separate 
POINTER_SIZE, but this may be one of the trickier and riskier hook 
conversions, and a wrapper pointer_size function, such as in this patch, 
probably does make sense for use in front-end code rather than front ends 
using the modes and target hooks directly.  Maybe things should be turned 
around so that the pointer_mode and address_mode hooks are what are used 
to define ptr_mode and Pmode, rather than being defined in terms of those 
modes.)

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


Re: C++ PATCH for c++/49528 (omitting destructor for temporary with constant value)

2011-06-26 Thread Gabriel Dos Reis
On Sun, Jun 26, 2011 at 9:00 AM, Jason Merrill  wrote:
> The constant expression evaluation code was happily replacing an expression
> involving a temporary with its constant value even if the temporary had a
> destructor that needed to be run.

I thought we wanted literal types to have trivial destructor; did that change?

-- Gaby


[patch, darwin, committed] fix PR47997

2011-06-26 Thread Iain Sandoe
I applied the following patch (approved in the PR thread) to fix this  
in trunk.

It should also be applied to 4.6.x at some stage.
cheers
Iain

gcc/

PR target/47997
* config/darwin.c (darwin_mergeable_string_section): Place string
constants in '.cstring' rather than '.const' when CF/NSStrings are
active.

Index: gcc/config/darwin.c
===
--- gcc/config/darwin.c (revision 175409)
+++ gcc/config/darwin.c (working copy)
@@ -1195,7 +1195,11 @@ static section *
 darwin_mergeable_string_section (tree exp,
 unsigned HOST_WIDE_INT align)
 {
-  if (flag_merge_constants
+  /* Darwin's ld expects to see non-writable string literals in  
the .cstring
+ section.  Later versions of ld check and complain when CFStrings  
are
+ enabled.  Therefore we shall force the strings into .cstring  
since we

+ don't support writable ones anyway.  */
+  if ((darwin_constant_cfstrings || flag_merge_constants)
   && TREE_CODE (exp) == STRING_CST
   && TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
   && align <= 256



Re: C++ PATCH for c++/49528 (omitting destructor for temporary with constant value)

2011-06-26 Thread Jason Merrill
No, that's still the case, just getting confused by the need to also support 
constant initialization of non-literal types.

Gabriel Dos Reis  wrote:

On Sun, Jun 26, 2011 at 9:00 AM, Jason Merrill  wrote:
> The constant expression evaluation code was happily replacing an expression
> involving a temporary with its constant value even if the temporary had a
> destructor that needed to be run.

I thought we wanted literal types to have trivial destructor; did that change?

-- Gaby


Re: [trunk] RFA: translate built-in include paths for sysroot (issue4641076)

2011-06-26 Thread Chris Demetriou
On Sun, Jun 26, 2011 at 07:28, Joseph S. Myers  wrote:
> It seems to me that what's really wanted here is to change the add_sysroot
> flag for the C++ path (all of the C++ paths?), rather than adding special
> code to detect paths starting with the sysroot and reinterpret them.

I considered doing that, I wasn't sure what (if any) implications that
would have on the way gcc normally builds + configures / how it works
when other people use flags like --with-gxx-include-dir.

I couldn't think of *harm*, but it seemed to me that my change was
least likely to cause harm to existing working paths.
(That doesn't mean that it's the right change, just the one that I
thought I could understand best.  8-)


> And
> so making configure detect when the --with-gxx-include-dir setting starts
> with the sysroot and adjusting the flag accordingly in that case would be
> a cleaner solution - that way it would be obvious that the semantics of
> the relocation are exactly the same as for other sysrooted paths, whereas
> it isn't when the relocation goes through different code paths in the
> compiler.

yeah, i can do that.


thanks for the quick look.



chris


Re: C++ PATCH for c++/49528 (omitting destructor for temporary with constant value)

2011-06-26 Thread Jakub Jelinek
On Sun, Jun 26, 2011 at 10:13:23AM -0400, Jason Merrill wrote:
> On 06/26/2011 10:00 AM, Jason Merrill wrote:
> >Tested x86_64-pc-linux-gnu, applying to trunk. Jakub, should this go
> >into 4.6.1 or .2?
> 
> I think it's fine to wait for .2, since a class with a non-trivial
> destructor is likely to also have a non-trivial, non-constexpr
> constructor, which would prevent A() from having a constant value.

Yeah, I'd prefer to defer it for 4.6.2 and be able to roll the release tomorrow.

Jakub


[PATCH, PR 49094] Refrain from creating misaligned accesses in SRA

2011-06-26 Thread Martin Jambor
Hi,

under some circumstances involving user specified alignment and/or
packed attributes, SRA can create a misaligned MEM_REF.  As the
testcase demonstrates, it is not enough to not consider variables with
these type attributes, mainly because we might attempt to load/store
the scalar replacements from/to right/left sides of original aggregate
assignments which might be misaligned.

I'm wondering whether this approach isn't too heavy-handed but I have
not been able to convince myself that anything short of this is
sufficient, esp. in presence of the all-time-SRA-favorite type-casts,
one-field-structures and unions.  At the very least I therefore do
this only for strict-alignment architectures, where this is actually
an issue.

I have verified the testcase fails with a "bus error" on sparc64 and
passes when the patch is applied.  I have run make -k test for c and
c++ on sparc64-linux without any issues as well as traditional
bootstrap and full testsuite run on x86_64-linux.  OK for trunk and
for 4.6 when unfrozen?

Thanks,

Martin


2011-06-24  Martin Jambor  

PR tree-optimization/49094
* tree-sra.c (potential_alignment_issues): New function.
(build_accesses_from_assign): Use it.

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


Index: src/gcc/tree-sra.c
===
--- src.orig/gcc/tree-sra.c
+++ src/gcc/tree-sra.c
@@ -1023,6 +1023,33 @@ disqualify_ops_if_throwing_stmt (gimple
   return false;
 }
 
+/* Return true iff type of EXP or any of the types it is based on are
+   user-aligned and packed.  */
+
+static bool
+potential_alignment_issues (tree exp)
+{
+  if (!STRICT_ALIGNMENT)
+return false;
+
+  while (true)
+{
+  tree type = TREE_TYPE (exp);
+
+  if (TYPE_USER_ALIGN (type)
+ || TYPE_PACKED (type))
+   return true;
+
+  if (handled_component_p (exp))
+   exp = TREE_OPERAND (exp, 0);
+  else
+   break;
+}
+
+  return false;
+}
+
+
 /* Scan expressions occuring in STMT, create access structures for all accesses
to candidates for scalarization and remove those candidates which occur in
statements or expressions that prevent them from being split apart.  Return
@@ -1047,7 +1074,10 @@ build_accesses_from_assign (gimple stmt)
   lacc = build_access_from_expr_1 (lhs, stmt, true);
 
   if (lacc)
-lacc->grp_assignment_write = 1;
+{
+  lacc->grp_assignment_write = 1;
+  lacc->grp_unscalarizable_region |= potential_alignment_issues (rhs);
+}
 
   if (racc)
 {
@@ -1055,6 +1085,7 @@ build_accesses_from_assign (gimple stmt)
   if (should_scalarize_away_bitmap && !gimple_has_volatile_ops (stmt)
  && !is_gimple_reg_type (racc->type))
bitmap_set_bit (should_scalarize_away_bitmap, DECL_UID (racc->base));
+  racc->grp_unscalarizable_region |= potential_alignment_issues (lhs);
 }
 
   if (lacc && racc
Index: src/gcc/testsuite/gcc.dg/tree-ssa/pr49094.c
===
--- /dev/null
+++ src/gcc/testsuite/gcc.dg/tree-ssa/pr49094.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-O" } */
+
+struct in_addr {
+   unsigned int s_addr;
+};
+
+struct ip {
+   unsigned char ip_p;
+   unsigned short ip_sum;
+   struct  in_addr ip_src,ip_dst;
+} __attribute__ ((aligned(1), packed));
+
+struct ip ip_fw_fwd_addr;
+
+int test_alignment( char *m )
+{
+  struct ip *ip = (struct ip *) m;
+  struct in_addr pkt_dst;
+  pkt_dst = ip->ip_dst ;
+  if( pkt_dst.s_addr == 0 )
+return 1;
+  else
+return 0;
+}
+
+int __attribute__ ((noinline, noclone))
+intermediary (char *p)
+{
+  return test_alignment (p);
+}
+
+int
+main (int argc, char *argv[])
+{
+  ip_fw_fwd_addr.ip_dst.s_addr = 1;
+  return intermediary ((void *) &ip_fw_fwd_addr);
+}



Re: [Patch, AVR]: Fix PR46779

2011-06-26 Thread Denis Chertykov
2011/6/24 Richard Henderson :
> On 06/23/2011 01:15 PM, Denis Chertykov wrote:
>>>   text    data     bss     dec     hex filename
>>>  10032      25       0   10057    2749 bld-avr-orig/gcc/z.o
>>>   5816      25       0    5841    16d1 bld-avr-new/gcc/z.o
>>
>> Richard, can you send me this z.c file ?
>> Right now I'm notice that new code is worse.
>
> That's gcc.c-torture/compile/950612-1.c.
>

I have founded that postreload optimizations can't handle results of
new L_R_A code.
I think that it's can be handled by CSE (postreload).

This is a fragment from 950612-1.c:

-- you can skip it I have a short version below ---
(insn 5186 23 5187 2 (set (reg:HI 30 r30)
(const_int 128 [0x80])) c950612-1.c:20 9 {*movhi}
 (nil))

(insn 5187 5186 5189 2 (set (reg:HI 30 r30)
(plus:HI (reg:HI 30 r30)
(reg/f:HI 28 r28))) c950612-1.c:20 21 {*addhi3}
 (expr_list:REG_EQUIV (plus:HI (reg/f:HI 28 r28)
(const_int 128 [0x80]))
(nil)))

(insn 5189 5187 2451 2 (set (mem/c:HI (plus:HI (reg:HI 30 r30)
(const_int 1 [0x1])) [8 %sfp+129 S2 A8])
(reg:HI 18 r18)) c950612-1.c:20 9 {*movhi}
 (nil))

(note 2451 5189 2537 2 NOTE_INSN_DELETED)

(note 2537 2451 1651 2 NOTE_INSN_DELETED)

(note 1651 2537 3180 2 NOTE_INSN_DELETED)

(note 3180 1651 5191 2 NOTE_INSN_DELETED)

(insn 5191 3180 5192 2 (set (reg:HI 30 r30)
(const_int 128 [0x80])) c950612-1.c:132 9 {*movhi}
 (nil))

(insn 5192 5191 5071 2 (set (reg:HI 30 r30)
(plus:HI (reg:HI 30 r30)
(reg/f:HI 28 r28))) c950612-1.c:132 21 {*addhi3}
 (expr_list:REG_EQUIV (plus:HI (reg/f:HI 28 r28)
(const_int 128 [0x80]))
(nil)))

(insn 5071 5192 5073 2 (set (mem/c:HI (plus:HI (reg:HI 30 r30)
(const_int 3 [0x3])) [8 %sfp+131 S2 A8])
(reg/v/f:HI 8 r8 [orig:211 pc ] [211])) c950612-1.c:132 9 {*movhi}
 (nil))
--

Insns 5186,5187 equal to 5191,5192 and 5191,5192 can be removed, but
reload_cse_regs_1 operate only on one insn.

5186 Z=128
5187 Z=Y+128   ; REG_EQUIV Z=Y+128
5189 HI:[Z+1]=HI:R18
...(deleted insns)
5191 Z=128
5192 Z=Y+128   ; REG_EQUIV Z=Y+128

(5191,5192) really a one three addressing add Z=Y+128.
Insns (5191,5192) exists because AVR havn't 3 addressing add.
Insn 5191 destroy REG_EQUIV (it's right), but reload_cse_regs_1 can't
optimize insns 5191,5192.

Right now I have only one idea:
1. create peephole2 for joining such insns (5191,5192);
2. inside machine dependent pass rerun postreload and may be gcse2;
3. split joined insns to originals.

Denis.


Re: PATCH [8/n]: Prepare x32: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-06-26 Thread Jason Merrill

On 06/25/2011 12:13 PM, H.J. Lu wrote:

This patch introduces UNIQUE_UNWIND_CONTEXT


Where is this documented?  The ABI document doesn't seem to say anything 
about it.


Jason


Re: [Patch, AVR]: Fix PR46779

2011-06-26 Thread Georg-Johann Lay

Denis Chertykov schrieb:

2011/6/24 Richard Henderson :


On 06/23/2011 01:15 PM, Denis Chertykov wrote:


 textdata bss dec hex filename
10032  25   0   100572749 bld-avr-orig/gcc/z.o
 5816  25   0584116d1 bld-avr-new/gcc/z.o


Richard, can you send me this z.c file ?
Right now I'm notice that new code is worse.


That's gcc.c-torture/compile/950612-1.c.


I have founded that postreload optimizations can't handle results of
new L_R_A code.
I think that it's can be handled by CSE (postreload).

This is a fragment from 950612-1.c:

-- you can skip it I have a short version below ---
(insn 5186 23 5187 2 (set (reg:HI 30 r30)
(const_int 128 [0x80])) c950612-1.c:20 9 {*movhi}
 (nil))

(insn 5187 5186 5189 2 (set (reg:HI 30 r30)
(plus:HI (reg:HI 30 r30)
(reg/f:HI 28 r28))) c950612-1.c:20 21 {*addhi3}
 (expr_list:REG_EQUIV (plus:HI (reg/f:HI 28 r28)
(const_int 128 [0x80]))
(nil)))

(insn 5189 5187 2451 2 (set (mem/c:HI (plus:HI (reg:HI 30 r30)
(const_int 1 [0x1])) [8 %sfp+129 S2 A8])
(reg:HI 18 r18)) c950612-1.c:20 9 {*movhi}
 (nil))

(note 2451 5189 2537 2 NOTE_INSN_DELETED)

(note 2537 2451 1651 2 NOTE_INSN_DELETED)

(note 1651 2537 3180 2 NOTE_INSN_DELETED)

(note 3180 1651 5191 2 NOTE_INSN_DELETED)

(insn 5191 3180 5192 2 (set (reg:HI 30 r30)
(const_int 128 [0x80])) c950612-1.c:132 9 {*movhi}
 (nil))

(insn 5192 5191 5071 2 (set (reg:HI 30 r30)
(plus:HI (reg:HI 30 r30)
(reg/f:HI 28 r28))) c950612-1.c:132 21 {*addhi3}
 (expr_list:REG_EQUIV (plus:HI (reg/f:HI 28 r28)
(const_int 128 [0x80]))
(nil)))

(insn 5071 5192 5073 2 (set (mem/c:HI (plus:HI (reg:HI 30 r30)
(const_int 3 [0x3])) [8 %sfp+131 S2 A8])
(reg/v/f:HI 8 r8 [orig:211 pc ] [211])) c950612-1.c:132 9 {*movhi}
 (nil))
--

Insns 5186,5187 equal to 5191,5192 and 5191,5192 can be removed, but
reload_cse_regs_1 operate only on one insn.

5186 Z=128
5187 Z=Y+128   ; REG_EQUIV Z=Y+128
5189 HI:[Z+1]=HI:R18
...(deleted insns)
5191 Z=128
5192 Z=Y+128   ; REG_EQUIV Z=Y+128

(5191,5192) really a one three addressing add Z=Y+128.
Insns (5191,5192) exists because AVR havn't 3 addressing add.
Insn 5191 destroy REG_EQUIV (it's right), but reload_cse_regs_1 can't
optimize insns 5191,5192.


Did you try to add constraint alternative to *addhi3?
Like "*!d,d,n" or even "*!r,r,n"

I saw some code improvement with that alternative.

Johann


Right now I have only one idea:
1. create peephole2 for joining such insns (5191,5192);
2. inside machine dependent pass rerun postreload and may be gcse2;
3. split joined insns to originals.

Denis.





Re: PATCH [8/n]: Prepare x32: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-06-26 Thread H.J. Lu
On Sun, Jun 26, 2011 at 12:54 PM, Jason Merrill  wrote:
> On 06/25/2011 12:13 PM, H.J. Lu wrote:
>>
>> This patch introduces UNIQUE_UNWIND_CONTEXT
>
> Where is this documented?  The ABI document doesn't seem to say anything
> about it.
>

I added a short paragraph in the updated patch:

http://gcc.gnu.org/ml/gcc-patches/2011-06/msg01922.html

+@defmac UNIQUE_UNWIND_CONTEXT
+
+Define this macro if the target only supports single unqiue unwind
+context.  The default is to support multiple unwind contexts.
+
+@end defmac

This is the implementation detail and isn't required by the ABI.
With the unique unwind context, we can update the unwind
context format without breaking binary compatibility.

Thanks.


-- 
H.J.


New German PO file for 'gcc' (version 4.6.0)

2011-06-26 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the German team of translators.  The file is available at:

http://translationproject.org/latest/gcc/de.po

(This file, 'gcc-4.6.0.de.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

http://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

http://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




Re: C++ PATCH for c++/49528 (omitting destructor for temporary with constant value)

2011-06-26 Thread Gabriel Dos Reis
On Sun, Jun 26, 2011 at 12:09 PM, Jason Merrill  wrote:
> No, that's still the case, just getting confused by the need to also support 
> constant initialization of non-literal types.

Ah, thanks!

-- Gaby


Re: PATCH [8/n]: Prepare x32: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-06-26 Thread Jason Merrill

On 06/26/2011 04:06 PM, H.J. Lu wrote:

I added a short paragraph in the updated patch:

+@defmac UNIQUE_UNWIND_CONTEXT
+
+Define this macro if the target only supports single unqiue unwind
+context.  The default is to support multiple unwind contexts.


I saw that.  I don't know what it means.

Jason


Re: PATCH [8/n]: Prepare x32: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-06-26 Thread H.J. Lu
On Sun, Jun 26, 2011 at 2:45 PM, Jason Merrill  wrote:
> On 06/26/2011 04:06 PM, H.J. Lu wrote:
>>
>> I added a short paragraph in the updated patch:
>>
>> +@defmac UNIQUE_UNWIND_CONTEXT
>> +
>> +Define this macro if the target only supports single unqiue unwind
>> +context.  The default is to support multiple unwind contexts.
>
> I saw that.  I don't know what it means.
>

The current unwind library scheme provides only one unwind
context and is backward compatible with multiple different unwind
contexts from multiple unwind libraries:

http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01769.html

My patch fixes UNITS_PER_WORD > sizeof (void *) and
enforces single unwind context when backward compatibility
isn't needed.


-- 
H.J.


Re: C++ PATCH for c++/49528 (omitting destructor for temporary with constant value)

2011-06-26 Thread Jason Merrill

But yes, I think checking for literal type is a better idea.

Tested x86_64-pc-linux-gnu, applying to trunk.

commit 81e093c1d6f2657c8c3c2abc2af559111ca82da4
Author: Jason Merrill 
Date:   Sun Jun 26 15:23:00 2011 -0400

	PR c++/49528
	* semantics.c (potential_constant_expression_1): Check
	for non-literality rather than cleanup.
	(cxx_eval_constant_expression): Likewise.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 5404c9f..d1af0c6 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7020,11 +7020,10 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
   break;
 
 case TARGET_EXPR:
-  /* A cleanup isn't constant.  */
-  if (TARGET_EXPR_CLEANUP (t))
+  if (!literal_type_p (TREE_TYPE (t)))
 	{
 	  if (!allow_non_constant)
-	error ("temporary of type %qT needing destruction in a "
+	error ("temporary of non-literal type %qT in a "
 		   "constant expression", TREE_TYPE (t));
 	  *non_constant_p = true;
 	  break;
@@ -7851,11 +7850,10 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
 	  want_rval, flags);
 
 case TARGET_EXPR:
-  /* A cleanup isn't constant.  */
-  if (TARGET_EXPR_CLEANUP (t))
+  if (!literal_type_p (TREE_TYPE (t)))
 	{
 	  if (flags & tf_error)
-	error ("temporary of type %qT needing destruction in a "
+	error ("temporary of non-literal type %qT in a "
 		   "constant expression", TREE_TYPE (t));
 	  return false;
 	}
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C
index b3fb9a8..de17f3d 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C
@@ -6,4 +6,4 @@ struct A
   ~A();
 };
 
-constexpr int i = A().i;	// { dg-error "destruction" }
+constexpr int i = A().i;	// { dg-error "non-literal" }


Re: [testsuite] skip ARM neon-fp16 tests for other -mcpu values

2011-06-26 Thread Janis Johnson
On 06/25/2011 04:56 PM, Mike Stump wrote:
> On Jun 15, 2011, at 5:57 PM, Janis Johnson wrote:
>> The bug was in my attempt to run the tests with other -mfpu values, so
>> I'm very glad you caught that.  I tried again, getting rid of the neon
>> requirement along the way, and found a way to run the VFP fp16 tests
>> with any of the fp16 values that Joseph listed.
>>
>> This patch renames *arm_neon_fp16* to *arm_fp16* and skips tests if the
>> multilib does not support arm32, includes -mfpu that is not fp16, or
>> includes -mfloat-abi=soft.  If the multilib uses -mfpu= with an fp16
>> value then that is used, otherwise -mfpu=vfpv4 is used.  Added flags
>> include -mfloat-abi=softfp in case the default is "soft".
> 
>> OK for trunk, and for 4.6 a few days later?
> 
> Ok.  Ok for 4.6.  For 4.6, as also please ensure that the RMs don't have the 
> branch locked down.

I'm waiting until after the 4.6.1 release to move anything more to that branch.

> General comment, I'm happy to have the front-end, target and library
> maintainers review and approve the normal additions to the .exp files
> to support testing their bits.

Yep!

Janis


[committed] Fix gcc.dg/debug/pr49294.c on hppa*-*-hpux*

2011-06-26 Thread John David Anglin
Yet another case where we can't use common.  Tested on hppa2.0w-hp-hpux11.11
and hppa64-hp-hpux11.11.  Committed to trunk.

Dave
-- 
J. David Anglin  dave.ang...@nrc-cnrc.gc.ca
National Research Council of Canada  (613) 990-0752 (FAX: 952-6602)

2011-06-26  John David Anglin  

* gcc.dg/debug/pr49294.c (dg-options): Add -fno-common to options on
hppa*-*-hpux*.

Index: gcc.dg/debug/pr49294.c
===
--- gcc.dg/debug/pr49294.c  (revision 175293)
+++ gcc.dg/debug/pr49294.c  (working copy)
@@ -1,5 +1,6 @@
 /* PR debug/49294 */
 /* { dg-do compile } */
+/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */
 
 typedef __attribute__ ((vector_size ((8) * sizeof (short short V;
 


[committed] Fix gcc.dg/ipa/ipa-pta-17.c on hppa2.0w-hp-hpux11.11

2011-06-26 Thread John David Anglin
Test uses alias attribute, so it needs dg-require-alias.  Tested on
hppa64-hp-hpux11.11.  Committed to trunk as obvious.

Dave
-- 
J. David Anglin  dave.ang...@nrc-cnrc.gc.ca
National Research Council of Canada  (613) 990-0752 (FAX: 952-6602)

2011-06-26  John David Anglin  

PR testsuite/49529
* gcc.dg/ipa/ipa-pta-17.c: Use dg-require-alias.

Index: gcc.dg/ipa/ipa-pta-17.c
===
--- gcc.dg/ipa/ipa-pta-17.c (revision 175404)
+++ gcc.dg/ipa/ipa-pta-17.c (working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-alias "" } */
 /* { dg-options "-O -fipa-pta" } */
 
 static int i;


Re: [Patch, AVR]: Fix PR46779

2011-06-26 Thread Denis Chertykov
2011/6/26 Georg-Johann Lay :
> Denis Chertykov schrieb:
>>
>> 2011/6/24 Richard Henderson :
>>
>>> On 06/23/2011 01:15 PM, Denis Chertykov wrote:
>>>
>  text    data     bss     dec     hex filename
> 10032      25       0   10057    2749 bld-avr-orig/gcc/z.o
>  5816      25       0    5841    16d1 bld-avr-new/gcc/z.o

 Richard, can you send me this z.c file ?
 Right now I'm notice that new code is worse.
>>>
>>> That's gcc.c-torture/compile/950612-1.c.
>>
>> I have founded that postreload optimizations can't handle results of
>> new L_R_A code.
>> I think that it's can be handled by CSE (postreload).
> Did you try to add constraint alternative to *addhi3?
> Like "*!d,d,n" or even "*!r,r,n"
>
> I saw some code improvement with that alternative.

I'm trying:

(define_insn "*addhi3"
  [(set (match_operand:HI 0 "register_operand" "=r,!w,!w,d,r,r,!d")
(plus:HI
 (match_operand:HI 1 "register_operand" "%0,0,0,0,0,0,!r")
 (match_operand:HI 2 "nonmemory_operand" "r,I,J,i,P,N,!ri")))]
  ""
  "@
add %A0,%A2\;adc %B0,%B2
adiw %A0,%2
sbiw %A0,%n2
subi %A0,lo8(-(%2))\;sbci %B0,hi8(-(%2))
sec\;adc %A0,__zero_reg__\;adc %B0,__zero_reg__
sec\;sbc %A0,__zero_reg__\;sbc %B0,__zero_reg__
#"
  [(set_attr "length" "2,1,1,2,3,3,4")
   (set_attr "cc" "set_n,set_czn,set_czn,set_czn,set_n,set_n,set_n")])

;; Special split three addressing addhi3
;; to make postreload optimization possible
(define_split ; addhi3 !d,!r,!ri
  [(set (match_operand:HI 0 "d_register_operand" "")
(plus:HI (match_operand:HI 1 "register_operand" "")
 (match_operand:HI 2 "nonmemory_operand" "")))]
  "reload_completed"
  [(set (match_dup 0) (match_dup 2))
   (set (match_dup 0) (plus:HI (match_dup 0) (match_dup 1)))]
  "")

The main problem for me is that the new addressing mode produce a
worse code in many tests.
Although, results for gcc.c-torture/compile/950612-1.c is
significantly better with new addressing.

Denis.


PING patch trunk: seek plugin also in a language specific directory when given a short name

2011-06-26 Thread Basile Starynkevitch
Hello All,

I am pinging http://gcc.gnu.org/ml/gcc-patches/2011-06/msg01524.html :

On Mon, 20 Jun 2011 21:34:44 +0200
Basile Starynkevitch  wrote:
> 
> The attached patch to trunk 175201 makes cc1, cc1plus, ... lto1 also
> search a language specific subdirectory.
> 
> # gcc/ChangeLog entry ##
> 2011-06-20  Basile Starynkevitch  
> 
>   * plugin.c: Update copyright year.
>   (PLUGIN_FILE_SUFFIX): New macro.
>   (add_new_plugin): Short-named plugins are also searched in a
>   language-specific sub-directory.
> 
>   * doc/plugins.texi (Loading Plugins): Document how short-named
>   plugins are searched in a language-specific sub-directory.
>   (Plugin callbacks): Remind that PLUGIN_PRAGMAS event is not
>   possible from lto1.
> 
> 
> Ok for trunk? With what changes?

Cheers
-- 
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basilestarynkevitchnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***
Index: gcc/doc/plugins.texi
===
--- gcc/doc/plugins.texi	(revision 175201)
+++ gcc/doc/plugins.texi	(working copy)
@@ -23,10 +23,16 @@ plugins as key-value pairs. Multiple plugins can b
 specifying multiple @option{-fplugin} arguments.
 
 A plugin can be simply given by its short name (no dots or
-slashes). When simply passing @option{-fplugin=@var{name}}, the plugin is
-loaded from the @file{plugin} directory, so @option{-fplugin=@var{name}} is
-the same as @option{-fplugin=`gcc -print-file-name=plugin`/@var{name}.so},
-using backquote shell syntax to query the @file{plugin} directory.
+slashes). When simply passing @option{-fplugin=@var{name}}, the plugin
+is loaded from the @file{plugin} directory, or one of its front-end
+specific subdirectories, so @option{-fplugin=@var{name}} is the same
+as @option{-fplugin=`gcc
+-print-file-name=plugin`/@var{program}/@var{name}.so} or
+@option{-fplugin=`gcc -print-file-name=plugin`/@var{name}.so}, using
+backquote shell syntax to query the @file{plugin} directory, where
+@var{program} is one of @code{cc1}, @code{cc1plus}, @code{lto1} etc.
+Therefore, a plugin can be made available only to some front-ends,
+or can have language-specific variants.
 
 @section Plugin API
 
@@ -207,10 +213,11 @@ For the PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO, PL
 and PLUGIN_REGISTER_GGC_CACHES pseudo-events the @code{callback} should be
 null, and the @code{user_data} is specific.
 
-When the PLUGIN_PRAGMAS event is triggered (with a null
-pointer as data from GCC), plugins may register their own pragmas
-using functions like @code{c_register_pragma} or
-@code{c_register_pragma_with_expansion}.
+When the PLUGIN_PRAGMAS event is triggered (with a null pointer as
+data from GCC), plugins may register their own pragmas using functions
+like @code{c_register_pragma} or
+@code{c_register_pragma_with_expansion}. This is not possible in
+plugins run from @code{lto1}.
 
 @section Interacting with the pass manager
 
Index: gcc/plugin.c
===
--- gcc/plugin.c	(revision 175201)
+++ gcc/plugin.c	(working copy)
@@ -1,5 +1,5 @@
 /* Support for GCC plugin mechanism.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -117,6 +117,12 @@ get_plugin_base_name (const char *full_name)
 }
 
 
+/* FIXME: the ".so" suffix is currently builtin, since plugins
+   only work on ELF host systems like e.g. Linux or Solaris.  
+   When plugins shall be available on non ELF systems such as
+   Windows or MacOS, this code has to be greatly improved.  */
+#define PLUGIN_FILE_SUFFIX ".so"
+
 /* Create a plugin_name_args object for the given plugin and insert it
to the hash table. This function is called when
-fplugin=/path/to/NAME.so or -fplugin=NAME option is processed.  */
@@ -140,17 +146,43 @@ add_new_plugin (const char* plugin_name)
 
   if (name_is_short)
 {
+  char *plugpath;
+  char* foundpath = NULL;
   base_name = CONST_CAST (char*, plugin_name);
-  /* FIXME: the ".so" suffix is currently builtin, since plugins
-	 only work on ELF host systems like e.g. Linux or Solaris.
-	 When plugins shall be available on non ELF systems such as
-	 Windows or MacOS, this code has to be greatly improved.  */
-  plugin_name = concat (default_plugin_dir_name (), "/",
-			plugin_name, ".so", NULL);
-  if (access (plugin_name, R_OK))
-	fatal_error
-	  ("inacessible plugin file %s expanded from short plugin name %s: %m",
-	   plugin_name, base_name);
+
+  /* Look for PLUGINDIR/PROGNAME/NAME.so.  This is useful for
+	 front-end specific plugins.  */
+  if (!foundpath)
+	plugpath = concat (default_plugin_dir_name (), "/",
+			   progname, "/",
+			   plugin_name, PLUGIN_FILE_SUFFIX, NULL