Re: [Patch,avr] Ad PR 54222: Add roundfx, countlsfx to stdfix.h

2013-02-07 Thread Denis Chertykov
2013/2/7 Georg-Johann Lay :
> This patch adds more fixed-point features from embedded-C:
>
> - roundfx rounding functions
> - countlsfx bit counting functions
> - add implementations of builtins so that an implementation / symbol is
>   available when the address of such a function is taken
>
> The stdfix.h header is cleaned up and just contains defines that map the
> available embedded-C functions to their builtin like
>
> #define roundr   __builtin_avr_roundr
>
> Reasoning is
>
> 1) Is is possible to take the address of roundr
>
> 2) Some builtins might print diagnostics.  If the functions in
>stdfix.h were implemented as inline functions, the diagnose
>will point to the implementation in stdfix.h but not to the
>used code that uses the builtin with odd values.
>
> I found no way to get the location of the argument; EXPR_LOCATION won't work,
> and emitting a warning during built-in folding will show at locations more or
> less randomly distributed (depending on pass) around the correct location...
>
> The type-generic functions are implemented by overloading them.
>
> A new, avr-specific C source is added to libgcc that is used to compile 
> objects
> to be added to libgcc.a.  The objects are compiled by iterating over the
> source, which is not possible with LIB2ADD.  That is: With LIB2ADD, there 
> would
> be a bunch of new C modules, one for each function.  The new iteration scheme
> is similar to iterating over libgcc sources like lib1funcs.S, fp-bit.c,
> fixed-bit.c, etc.
>
> The new test cases pass but they need the following patch to work correctly:
>
> http://gcc.gnu.org/ml/gcc-patches/2013-02/msg00313.html
>
> This is pending review.
>
> Ok for trunk?
>
> Johann
>
>
> gcc/
> PR target/54222
> * config/avr/avr.md (unspec) : Add.
> * config/avr/avr-fixed.md (ALL4QA, ALL124QA): New mode iterators.
> (round3, round3_const): New expanders for fixed-mode.
> (*round3.libgcc): New insns for fixed-modes.
> * config/avr/builtins.def (ABSxx): Use a non-NULL LIBNAME.
> (ROUNDxx, COUNTLSxx, BITSxx, xxBITS): New DEF_BUILTINs.
> (ROUNDFX, COUNTLSFX, ABSFX): New DEF_BUILTINs.
> * config/avr/stdfix.h (absFX, bitsFX, FXbits): Remove inline
> implementations.  Define to __builtin_avr_absFX,
> __builtin_avr_bitsFX, __builtin_avr_FXbits, respectively.
> (roundFX, countlsFX): Define to __builtin_avr_roundFX,
> __builtin_avr_countlsFX, respectively.
> * config/avr/avr-c.c (target.h): Include it.
> (enum avr_builtin_id): New enum.
> (avr_resolve_overloaded_builtin): New static function.
> (avr_register_target_pragmas): Use it to set
> targetm.resolve_overloaded_builtin.
> * config/avr/avr.c (avr_init_builtins): Supply myriads of local
> tree nodes used by DEF_BUILTIN.
> (avr_expand_builtin) : Sanity-check them.
> (avr_fold_builtin) : Fold to VIEW_COVERT_EXPR.
> : Same.
>
> libgcc/
> PR target/54222
> * config/avr/lib2funcs.c: New C sources for modules for libgcc.a.
> * config/avr/lib2-object.mk: New iterator to build objects from it.
> * config/avr/t-avr: Iterate lib2-object.mk to build objects from
> lib2funcs.c.
> (LIB2FUNCS_EXCLUDE): Add _clrsbdi2.
> (LIB1ASMFUNCS): Add: _ssabs_1, _mask1, _ret, _roundqq3, _rounduqq3,
> _round_s2, _round_u2, _round_2_const, _addmask_2, _round_s4,
> _round_u4, _round_4_const, _addmask_4, _round_x8, _rounddq3
> _roundudq3, _roundda3 _rounduda3, _roundta3 _rounduta3.
> * config/avr/lib1funcs-fixed.S: Implement them.
>
> gcc/testsuite/
> PR target/54222
> * gcc.target/avr/torture/builtins-4-roundfx.c: New test.
> * gcc.target/avr/torture/builtins-5-countlsfx.c: New test.
>
>

Approved.

Denis.


[PATCH][Revised} Fix PR libitm/55693

2013-02-07 Thread Jack Howarth
   The attached revised patch eliminates the failure of the libitm.c++/eh-1.C 
execution test on
darwin10 and later, PR55693. With the introduction of c++ weak-symbol 
coalescing in Mac OS X 10.6,
dyld no longer looks up weak symbols that reside in object files rather than 
shared libraries. This
prevents weak symbols for the dummy functions in libgcc/config/darwin-crt-tm.c 
from being replaced
by those in the libstdc++ shared library. The solution is not to define these 
dummy symbols when
targeting Mac OS X 10.6 or later. Also, the previous hack of not declaring the 
dummy symbols in
libitm/alloc_cpp.cc and libitm/eh_cpp.cc on darwin is reverted as this produces 
undefined symbols
for the combination of darwin10 with Xcode 4.2 (where the dummy symbols are not 
provided in
config/darwin-crt-tm.c but HAVE_ELF_STYLE_WEAKREF is undefined). Bootstrap and 
regression tested on
x86_64-apple-darwin10 with Xcode 3.2.6 and Xcode 4.2 as well as for both 
x86_64-apple-darwin11 and
x86_64-apple-darwin12 with Xcode 4.5.2/4.6. Okay for gcc trunk after testing on 
darwin9?
 Jack
/libgcc

2013-02-07  Iain Sandoe  
Jack Howarth  

PR libitm/55693
* config/darwin-crt-tm.c: Provide dummy functions only prior to 10.6.

/gcc

2013-02-07  Iain Sandoe  
Jack Howarth  

PR libitm/55693
* gcc/config/darwin.h: Replace ENDFILE_SPEC with TM_DESTRUCTOR and
define ENDFILE_SPEC as TM_DESTRUCTOR.
* config/i386/darwin.h (ENDFILE_SPEC): Use TM_DESTRUCTOR.

/libitm

2013-02-07  Iain Sandoe  
Jack Howarth  

PR libitm/55693
* alloc_cpp.cc:  Enable dummy funtions on darwin.
* eh_cpp.cc:  Likewise.

Index: libgcc/config/darwin-crt-tm.c
===
--- libgcc/config/darwin-crt-tm.c   (revision 195764)
+++ libgcc/config/darwin-crt-tm.c   (working copy)
@@ -103,9 +103,12 @@ void __doTMdeRegistrations (void)
 _ITM_deregisterTMCloneTable (tmct);
 }
 
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__  < 1060
+
 /* Provide dummy functions to satisfy linkage for versions of the Darwin 
tool-chain that that can't handle undefined weak refs at the link stage.
-   ??? Define these dummy functions only when !HAVE_ELF_STYLE_WEAKREF. */
+   Don't define for 10.6 or later with faster weak-symbol coalescing. */
 
 extern void *__cxa_allocate_exception (size_t) WEAK;
 extern void __cxa_throw (void *, void *, void *) WEAK;
@@ -144,5 +147,5 @@ void _ZdlPvRKSt9nothrow_t (void * a UNUS
 void *_ZnaXRKSt9nothrow_t (size_t s UNUSED, c_nothrow_p b UNUSED)
   { return NULL; }
 void _ZdaPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED) { return; }
-
+#endif
 #endif
Index: gcc/config/i386/darwin.h
===
--- gcc/config/i386/darwin.h(revision 195764)
+++ gcc/config/i386/darwin.h(working copy)
@@ -131,8 +131,7 @@ extern int darwin_emit_branch_islands;
   "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{mpc32:crtprec32.o%s} \
%{mpc64:crtprec64.o%s} \
-   %{mpc80:crtprec80.o%s} \
-   %{fgnu-tm: -lcrttme.o}"
+   %{mpc80:crtprec80.o%s}" TM_DESTRUCTOR
 
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS   \
Index: gcc/config/darwin.h
===
--- gcc/config/darwin.h (revision 195764)
+++ gcc/config/darwin.h (working copy)
@@ -363,7 +363,8 @@ extern GTY(()) int darwin_ms_struct;
   %{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
 
 /* We want a destructor last in the list.  */
-#define ENDFILE_SPEC "%{fgnu-tm: -lcrttme.o}"
+#define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}"
+#define ENDFILE_SPEC TM_DESTRUCTOR
 
 #define DARWIN_EXTRA_SPECS \
   { "darwin_crt1", DARWIN_CRT1_SPEC }, \
Index: libitm/alloc_cpp.cc
===
--- libitm/alloc_cpp.cc (revision 195861)
+++ libitm/alloc_cpp.cc (working copy)
@@ -60,7 +60,7 @@
 extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
 extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
 
-#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined (__MACH__)
+#if !defined (HAVE_ELF_STYLE_WEAKREF) 
 void *_ZnwX (size_t) { return NULL; }
 void _ZdlPv (void *) { return; }
 void *_ZnaX (size_t) { return NULL; }
Index: libitm/eh_cpp.cc
===
--- libitm/eh_cpp.cc(revision 195861)
+++ libitm/eh_cpp.cc(working copy)
@@ -39,7 +39,7 @@
 extern void __cxa_end_catch (void) WEAK;
 extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
 
-#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined (__MACH__)
+#if !defined (HAVE_ELF_STYLE_WEA

Re: libgo patch committed: Update to current version of Go library

2013-02-07 Thread Ian Lance Taylor
On Thu, Feb 7, 2013 at 2:43 PM, Uros Bizjak  wrote:
>
> I did hit one new error that seems related:
>
> --- FAIL: TestChtimes (0.00 seconds)
> os_test.go:681: AccessTime didn't go backwards;
> was={63495872497 0 47130825733376}, after={63495872497 0
> 47130825733376}
> os_test.go:685: ModTime didn't go backwards; was={63495872497
> 0 47130825733376}, after={63495872497 0 47130825733376}
> FAIL
> FAIL: os

Something has gone wrong in the file
libgo/go/syscall/libcall_linux_utimesnano.go.  The function in that
file will try utimensat.  On your system that should return ENOSYS.
In that case the function should convert the times and call utimes.
The code looks OK to me but there may be something wrong with it.  It
looks like the file times didn't change at all.

Ian


Re: [PATCH] Fix up get_reload_reg (PR rtl-optimization/56195)

2013-02-07 Thread David Miller
From: Jakub Jelinek 
Date: Fri, 8 Feb 2013 01:27:02 +0100

> +void
> +fn (void)
> +{
> +  if (b)
> +{
> +  int *p, *q;
> +  char g;
> +
> +  if (f++)
> + for (;; e++);
> +lbl:
> +  for (b = 0; b < 2; b++)
> + t /= d + 1 ? : i || a < c < (d = f) ? : 1 | (j = 2);
> +
> +  *p = g >= *q ^ c != a ^ *p;

I know this is "just a testcase" but it looks like both 'p' and 'q'
can be uninitialized at this point.



Re: [PATCH] PR 56043, Fix segfault in 4.7/4.8 powerpc tests

2013-02-07 Thread David Edelsohn
On Thu, Feb 7, 2013 at 5:34 PM, Michael Meissner
 wrote:
> The following patch fixes a segmentation fault for the powerpc-none-eabi
> toolchain on the vsx-mass-1.c test.  Some of the builtin functions are not
> defined in that environment, and the compiler did not check whether a pointer
> was NULL before using it.  I also fixed the test so that it would only run
> under powerpc*-*-linux*, since the text would fail on systems like eabi 
> because
> some of the builtin functions would not call their vector counterparts in the
> MASS library.
>
> I've built both 4.8 and 4.7 with this patch, and I didn't notice any
> regressions.  Is it ok to install in both the 4.7 tree and trunk?
>
> [gcc]
> 2013-02-07  Michael Meissner  
>
> PR target/56043
> * config/rs6000/rs6000.c (rs6000_builtin_vectorized_libmass):
> If there is no implicit builtin declaration, just return NULL.
>
> [gcc/testsuite]
> 2013-02-07  Michael Meissner  
>
> PR target/56043
> * gcc.target/powerpc/vsx-mass-1.c: Only run this test on
> powerpc*-*-linux*.

Okay.

Thanks, David


[PATCH] Fix up get_reload_reg (PR rtl-optimization/56195)

2013-02-07 Thread Jakub Jelinek
Hi!

As the following testcase shows, get_reload_reg could sometimes return
a reused reg in a wrong mode.  If curr_insn_input_reloads[i].input
and original have VOIDmode, they could compare equal (same integer
constant), yet mode might be different from
GET_MODE (curr_insn_input_reloads[i].reg).
If we need a wider reg than we already have, we can't reuse it easily,
but if we need a narrower one, we can just use a subreg of the wider one.

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

2013-02-07  Jakub Jelinek  

PR rtl-optimization/56195
* lra-constraints.c (get_reload_reg): Don't reuse regs
if they have smaller mode than requested, if they have
wider mode than requested, try to return a SUBREG.

* gcc.dg/torture/pr56195.c: New test.

--- gcc/lra-constraints.c.jj2013-02-07 18:34:39.0 +0100
+++ gcc/lra-constraints.c   2013-02-07 20:58:25.558920536 +0100
@@ -421,8 +421,20 @@ get_reload_reg (enum op_type type, enum
   if (rtx_equal_p (curr_insn_input_reloads[i].input, original)
  && in_class_p (curr_insn_input_reloads[i].reg, rclass, &new_class))
{
- *result_reg = curr_insn_input_reloads[i].reg;
- regno = REGNO (*result_reg);
+ rtx reg = curr_insn_input_reloads[i].reg;
+ regno = REGNO (reg);
+ /* If input is equal to original and both are VOIDmode,
+GET_MODE (reg) might be still different from mode.
+Ensure we don't return *result_reg with wrong mode.  */
+ if (GET_MODE (reg) != mode)
+   {
+ if (GET_MODE_SIZE (GET_MODE (reg)) < GET_MODE_SIZE (mode))
+   continue;
+ reg = lowpart_subreg (mode, reg, GET_MODE (reg));
+ if (reg == NULL_RTX || GET_CODE (reg) != SUBREG)
+   continue;
+   }
+ *result_reg = reg;
  if (lra_dump_file != NULL)
{
  fprintf (lra_dump_file, "  Reuse r%d for reload ", regno);
--- gcc/testsuite/gcc.dg/torture/pr56195.c.jj   2013-02-07 21:08:34.244334032 
+0100
+++ gcc/testsuite/gcc.dg/torture/pr56195.c  2013-02-07 21:08:18.0 
+0100
@@ -0,0 +1,31 @@
+/* PR rtl-optimization/56195 */
+/* { dg-do assemble } */
+
+int i, a, t, b, c, d, e, f, j, *h;
+
+void
+fn (void)
+{
+  if (b)
+{
+  int *p, *q;
+  char g;
+
+  if (f++)
+   for (;; e++);
+lbl:
+  for (b = 0; b < 2; b++)
+   t /= d + 1 ? : i || a < c < (d = f) ? : 1 | (j = 2);
+
+  *p = g >= *q ^ c != a ^ *p;
+
+  if (!e)
+   {
+ q = p;
+ goto lbl;
+   }
+}
+
+  if (h++)
+goto lbl;
+}

Jakub


Re: [PATCH] Multiversioning fixes (PR c++/55742, take 2)

2013-02-07 Thread Sriraman Tallam
On Thu, Feb 7, 2013 at 6:29 AM, Jason Merrill  wrote:
> On 02/06/2013 08:39 PM, Sriraman Tallam wrote:
>>
>> +// Test to check if an error is generated when virtual functions
>> +// are multiversioned.
>
>
> This seems like a TODO, rather than something to test for.  I don't see any
> reason why we couldn't support multiversioned virtual functions.
>
>>  error_at (DECL_SOURCE_LOCATION (decl),
>> - "Virtual function versioning not supported\n");
>> + "Virtual function multiversioning not supported\n");
>
>
> And so this should be a sorry rather than an error.

Attached a new patch with these changes. Also made more minor changes
to config/i386/i386.c.

Thanks
Sri

>
> Jason
>
* doc/extend.texi: Document Function Multiversioning and "default"
parameter string to target attribute.
* g++.dg/ext/mv12.C: New test.
* g++.dg/ext/mv12.h: New file.
* g++.dg/ext/mv12-aux.C: New file.
* g++.dg/ext/mv13.C: New test.
* config/i386/i386.c (get_builtin_code_for_version): Return 0 if
target attribute parameter is "default".
(ix86_compare_version_priority): Remove checks for target attribute.
(ix86_mangle_function_version_assembler_name): Change error to sorry.
Remove check for target attribute equal to NULL. Add assert.
(ix86_generate_version_dispatcher_body): Change error to sorry.

Index: gcc/doc/extend.texi
===
--- gcc/doc/extend.texi (revision 195818)
+++ gcc/doc/extend.texi (working copy)
@@ -3655,6 +3655,11 @@ Enable/disable the generation of the advanced bit
 @cindex @code{target("aes")} attribute
 Enable/disable the generation of the AES instructions.
 
+@item default
+@cindex @code{target("default")} attribute
+@xref{Function Multiversioning}, where it is used to specify the
+default function version.
+
 @item mmx
 @itemx no-mmx
 @cindex @code{target("mmx")} attribute
@@ -15215,6 +15220,7 @@ Predefined Macros,cpp,The GNU C Preprocessor}).
 * Bound member functions:: You can extract a function pointer to the
 method denoted by a @samp{->*} or @samp{.*} expression.
 * C++ Attributes::  Variable, function, and type attributes for C++ only.
+* Function Multiversioning::   Declaring multiple function versions.
 * Namespace Association:: Strong using-directives for namespace association.
 * Type Traits:: Compiler support for type traits
 * Java Exceptions:: Tweaking exception handling to work with Java.
@@ -15744,6 +15750,64 @@ interface table mechanism, instead of regular virt
 
 See also @ref{Namespace Association}.
 
+@node Function Multiversioning
+@section Function Multiversioning
+@cindex function versions
+
+With the GNU C++ front end, for target i386, you may specify multiple
+versions of a function, where each function is specialized for a
+specific target feature.  At runtime, the appropriate version of the
+function is automatically executed depending on the characteristics of
+the execution platform.  Here is an example.
+
+@smallexample
+__attribute__ ((target ("default")))
+int foo ()
+@{
+  // The default version of foo.
+  return 0;
+@}
+
+__attribute__ ((target ("sse4.2")))
+int foo ()
+@{
+  // foo version for SSE4.2
+  return 1;
+@}
+
+__attribute__ ((target ("arch=atom")))
+int foo ()
+@{
+  // foo version for the Intel ATOM processor
+  return 2;
+@}
+
+__attribute__ ((target ("arch=amdfam10")))
+int foo ()
+@{
+  // foo version for the AMD Family 0x10 processors.
+  return 3;
+@}
+
+int main ()
+@{
+  int (*p)() = &foo;
+  assert ((*p) () == foo ());
+  return 0;
+@}
+@end smallexample
+
+In the above example, four versions of function foo are created. The
+first version of foo with the target attribute "default" is the default
+version.  This version gets executed when no other target specific
+version qualifies for execution on a particular platform. A new version
+of foo is created by using the same function signature but with a
+different target string.  Function foo is called or a pointer to it is
+taken just like a regular function.  GCC takes care of doing the
+dispatching to call the right version at runtime.  Refer to the
+@uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
+Function Multiversioning} for more details.
+
 @node Namespace Association
 @section Namespace Association
 
Index: gcc/testsuite/g++.dg/ext/mv12-aux.C
===
--- gcc/testsuite/g++.dg/ext/mv12-aux.C (revision 0)
+++ gcc/testsuite/g++.dg/ext/mv12-aux.C (revision 0)
@@ -0,0 +1,11 @@
+// Test case to check if multiversioning works as expected when the versions
+// are defined in different files. Auxiliary file for mv12.C.
+// { dg-do compile }
+
+#include "mv12.h"
+
+__attribute__ ((target ("sse4.2")))
+int foo ()
+{
+  return 1;
+}
Index: gcc/testsuite/g++.dg/ext/mv12.C
=

Re: var-tracking wrt. leaf regs on sparc

2013-02-07 Thread David Miller
From: Jakub Jelinek 
Date: Thu, 7 Feb 2013 20:43:32 +0100

> This and earlier patch are ok, if it bootstraps/regtests fine, and suitable
> ChangeLog entry is provided.
> Running gdb testsuite before and after wouldn't hurt though.

I've done all of this, and committed to trunk and the gcc-4.7 branch,
thanks.

In looking at the remaining failures, several have to do with
an early clobber if the first incoming argument register.

The issue is that this is where return values are placed, so we run
into a situation where that incoming argument value can't be
reconstituted in any way by the variable tracking code and thus gdb
says that it has been optimized out.

Many non-x86 cpus are going to run into this problem.  For example,
from pr36728-1.c:

foo:
save%sp, -96, %sp
add %sp, -40, %sp
mov 2, %g2
add %sp, 123, %g1
mov 25, %g4
and %g1, -32, %g1
sethi   %hi(b), %g3
st  %g2, [%g1]
ld  [%fp+92], %g2
nop
ld  [%g1], %i0
add %g2, 14, %g2
and %g2, -8, %g2
sub %sp, %g2, %sp
stb %g4, [%sp+96]
add %sp, 96, %g2
sethi   %hi(a), %g4
nop
return  %i7+8
 nop

Here %i0 is written early, and then the tests can't view 'arg1'
properly later in the function.

Also, I noticed that calculation of the on-stack address of values
with alignment regressed in gcc-4.8 vs. gcc-4.7 Again, in pr36728-1.c,
'y' can be printed properly in gcc-4.7 but in gcc-4.8 it cannot.

I think it might be getting the base register wrong, I'll look
more deeply if I get a chance.


Re: [RFC, 4.9 patch] Reload alternative weighting vs. wrong class regs

2013-02-07 Thread Alan Modra
On Thu, Feb 07, 2013 at 11:01:13PM +0100, Steven Bosscher wrote:
> FWIW, left trunk vs. LRA right (with PR54009 patch on rs6000.c):
[snip]
> 
> I don't speak POWER but perhaps you can make sense of it :-)

No real difference in "r" function, and interesting that LRA does a
better job of "w", about the same as trunk with my reload patch.

-- 
Alan Modra
Australia Development Lab, IBM


Re: libgo patch committed: Update to current version of Go library

2013-02-07 Thread Uros Bizjak
On Thu, Feb 7, 2013 at 5:27 PM, Ian Lance Taylor  wrote:
> On Thu, Feb 7, 2013 at 2:26 AM, Uros Bizjak  wrote:
>>
>> Thanks, I have tested it on CentOS 5.9. However, for some reason, I
>> got unrelated linker errors that prevents further testing:
>>
>> === libgo tests ===
>>
>> ./a.out: error while loading shared libraries:
>> /home/uros/gcc-build/x86_64-unknown-linux-gnu/libgo/.libs/libgo.so.3:
>> ELF file OS ABI invalid
>
> This is not, of course, related to Go.
>
> It looks like libgo.so.3 and libatomic.so.1 got created with the
> EI_OSABI field set to ELFOSABI_GNU, and it looks like your kernel is
> too old and does not know about that.  I assume that you are using a
> new version of the binutils, not the one that comes with the system.
> Are you using GNU ld or gold?  In general the linker will set EI_OSABI
> to ELFOSABI_GNU if it sees a STB_GNU_UNIQUE symbol or a STT_GNU_IFUNC
> symbol.  As far as I know neither libgo nor libatomic have either type
> of symbol.  So I'm not sure where this is coming from.
>
> If you start again and configure GCC to use the system binutils rather
> than a newer binutils, then you should be safe in not getting any
> UNIQUE or IFUNC symbols.  I don't know if you might run into other
> problems.

You are right, reverting binutils back to default CentOS 5.9:

GNU ld version 2.17.50.0.6-20.el5_8.3 20061020

I was able to run go testsuite.

I did hit one new error that seems related:

--- FAIL: TestChtimes (0.00 seconds)
os_test.go:681: AccessTime didn't go backwards;
was={63495872497 0 47130825733376}, after={63495872497 0
47130825733376}
os_test.go:685: ModTime didn't go backwards; was={63495872497
0 47130825733376}, after={63495872497 0 47130825733376}
FAIL
FAIL: os

But haven't debug it yet.

Thanks,
Uros.


[PATCH] PR 56043, Fix segfault in 4.7/4.8 powerpc tests

2013-02-07 Thread Michael Meissner
The following patch fixes a segmentation fault for the powerpc-none-eabi
toolchain on the vsx-mass-1.c test.  Some of the builtin functions are not
defined in that environment, and the compiler did not check whether a pointer
was NULL before using it.  I also fixed the test so that it would only run
under powerpc*-*-linux*, since the text would fail on systems like eabi because
some of the builtin functions would not call their vector counterparts in the
MASS library.

I've built both 4.8 and 4.7 with this patch, and I didn't notice any
regressions.  Is it ok to install in both the 4.7 tree and trunk?

[gcc]
2013-02-07  Michael Meissner  

PR target/56043
* config/rs6000/rs6000.c (rs6000_builtin_vectorized_libmass):
If there is no implicit builtin declaration, just return NULL.

[gcc/testsuite]
2013-02-07  Michael Meissner  

PR target/56043
* gcc.target/powerpc/vsx-mass-1.c: Only run this test on
powerpc*-*-linux*.

-- 
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
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 195825)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -3699,7 +3699,8 @@ rs6000_builtin_vectorized_libmass (tree 
  bdecl = builtin_decl_implicit (fn);
  suffix = "d2";/* pow -> powd2 */
  if (el_mode != DFmode
- || n != 2)
+ || n != 2
+ || !bdecl)
return NULL_TREE;
  break;
 
@@ -3736,7 +3737,8 @@ rs6000_builtin_vectorized_libmass (tree 
  bdecl = builtin_decl_implicit (fn);
  suffix = "4"; /* powf -> powf4 */
  if (el_mode != SFmode
- || n != 4)
+ || n != 4
+ || !bdecl)
return NULL_TREE;
  break;
 
@@ -3749,6 +3751,9 @@ rs6000_builtin_vectorized_libmass (tree 
 
   gcc_assert (suffix != NULL);
   bname = IDENTIFIER_POINTER (DECL_NAME (bdecl));
+  if (!bname)
+return NULL_TREE;
+
   strcpy (name, bname + sizeof ("__builtin_") - 1);
   strcat (name, suffix);
 
Index: gcc/testsuite/gcc.target/powerpc/vsx-mass-1.c
===
--- gcc/testsuite/gcc.target/powerpc/vsx-mass-1.c   (revision 195825)
+++ gcc/testsuite/gcc.target/powerpc/vsx-mass-1.c   (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-do compile { target { powerpc*-*-linux* } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 /* { dg-require-effective-target powerpc_vsx_ok } */
 /* { dg-options "-O3 -ftree-vectorize -mcpu=power7 -ffast-math 
-mveclibabi=mass" } */


[Patch, fortran] PR54107 ICE on recursive interface

2013-02-07 Thread Mikael Morin
Hello,

this is the last remaining patch to fix an infinite recursion when
creating the middle-end type of a function having a dummy
procedure whose interface is the function itself.
This patch is a slight variation of the comment 4 fix that was attached
to the PR.  It sets the procedure's backend_decl to error_mark_node, so
that the recursion can be detected and handled in the next iteration.  I
don't think the middle-end supports recursive function types, so the
middle-end types for recursive dummy procedure are actually variadic
procedure types.

regression tested on x86_64-unknown-linux-gnu. OK for trunk?


2013-02-07  Mikael Morin  

PR fortran/54107
* trans-types.c (gfc_get_function_type): Change a NULL backend_decl
to error_mark_node on entry.  Detect recursive types.  Build a variadic
procedure type if the type is recursive.  Restore the initial
backend_decl.

2013-02-07  Mikael Morin  

PR fortran/54107
* gfortran.dg/recursive_interface_2.f90: New test.
diff --git a/trans-types.c b/trans-types.c
index 21aa75c..360c782 100644
--- a/trans-types.c
+++ b/trans-types.c
@@ -2711,19 +2711,23 @@ gfc_get_function_type (gfc_symbol * sym)
   gfc_formal_arglist *f;
   gfc_symbol *arg;
   int alternate_return;
-  bool is_varargs = true;
+  bool is_varargs = true, recursive_type = false;
 
   /* Make sure this symbol is a function, a subroutine or the main
  program.  */
   gcc_assert (sym->attr.flavor == FL_PROCEDURE
  || sym->attr.flavor == FL_PROGRAM);
 
-  if (sym->backend_decl)
-{
-  if (sym->attr.proc_pointer)
-   return TREE_TYPE (TREE_TYPE (sym->backend_decl));
-  return TREE_TYPE (sym->backend_decl);
-}
+  /* To avoid recursing infinitely on recrusive types, we use error_mark_node
+ so that they can be detected here and handled further down.  */
+  if (sym->backend_decl == NULL)
+sym->backend_decl = error_mark_node;
+  else if (sym->backend_decl == error_mark_node)
+recursive_type = true;
+  else if (sym->attr.proc_pointer)
+return TREE_TYPE (TREE_TYPE (sym->backend_decl));
+  else
+return TREE_TYPE (sym->backend_decl);
 
   alternate_return = 0;
   typelist = NULL;
@@ -2775,6 +2779,13 @@ gfc_get_function_type (gfc_symbol * sym)
 
  if (arg->attr.flavor == FL_PROCEDURE)
{
+ /* We don't know in the general case which argument causes
+recursion.  But we know that it is a procedure.  So we give up
+creating the procedure argument type list at the first
+procedure argument.  */
+ if (recursive_type)
+   goto arg_type_list_done;
+
  type = gfc_get_function_type (arg);
  type = build_pointer_type (type);
}
@@ -2828,6 +2839,11 @@ gfc_get_function_type (gfc_symbol * sym)
   || sym->attr.if_source != IFSRC_UNKNOWN)
 is_varargs = false;
 
+arg_type_list_done:
+
+  if (!recursive_type && sym->backend_decl == error_mark_node)
+sym->backend_decl = NULL_TREE;
+
   if (alternate_return)
 type = integer_type_node;
   else if (!sym->attr.function || gfc_return_by_reference (sym))
@@ -2865,7 +2881,7 @@ gfc_get_function_type (gfc_symbol * sym)
   else
 type = gfc_sym_type (sym);
 
-  if (is_varargs)
+  if (is_varargs || recursive_type)
 type = build_varargs_function_type_vec (type, typelist);
   else
 type = build_function_type_vec (type, typelist);
! { dg-do compile }
!
! PR fortran/54107
! Recursive interfaces used to lead to an infinite recursion during
! resolution.

module m
 contains
! subroutine foo (arg) 
!   procedure(foo) :: arg 
! end subroutine 
  subroutine bar()
  end subroutine bar
  function foo2 (arg) result(r)
!   procedure(foo2) :: arg
procedure(bar) :: arg
procedure(foo2), pointer :: r
  end function 
! subroutine bar (arg) 
!   procedure(baz) :: arg 
! end subroutine 
! subroutine baz (arg) 
!   procedure(bar) :: arg 
! end subroutine 
end module m




Re: [PATCH, go]: Change type of main in libgo/runtime/goc2c.c to int

2013-02-07 Thread Ian Lance Taylor
On Thu, Feb 7, 2013 at 2:15 PM, Uros Bizjak  wrote:
>
> Just a small patch to remove a compile warning.
>
> Tested on x86_64-pc-linux-gnu.

Committed.

Thanks.

Ian


> Index: runtime/goc2c.c
> ===
> --- runtime/goc2c.c (revision 195856)
> +++ runtime/goc2c.c (working copy)
> @@ -633,7 +633,7 @@
> sysfatal("Usage: goc2c [--go-pkgpath PKGPATH] [--go-prefix
> PREFIX] [file]\n");
>  }
>
> -void
> +int
>  main(int argc, char **argv)
>  {
> char *goarch;


[PATCH, go]: Change type of main in libgo/runtime/goc2c.c to int

2013-02-07 Thread Uros Bizjak
Hello!

Just a small patch to remove a compile warning.

Tested on x86_64-pc-linux-gnu.

Uros.

Index: runtime/goc2c.c
===
--- runtime/goc2c.c (revision 195856)
+++ runtime/goc2c.c (working copy)
@@ -633,7 +633,7 @@
sysfatal("Usage: goc2c [--go-pkgpath PKGPATH] [--go-prefix
PREFIX] [file]\n");
 }

-void
+int
 main(int argc, char **argv)
 {
char *goarch;


Re: [RFC, 4.9 patch] Reload alternative weighting vs. wrong class regs

2013-02-07 Thread Steven Bosscher
On Thu, Feb 7, 2013 at 4:09 AM, Alan Modra wrote:
> After fixing PR54009 (again), I thought I'd take a look at why reload
> is generating the following correct but poor code
>
>  stw 10,8(1)
>  stw 11 12(1)
>  ...
>  lfd 0,8(1)
>  stfd 0,x+32764@l(9)
>
> rather than
>
>  addi 9,x+32764@l(9)
>  ...
>  stw 10,0(9)
>  stw 11 4(9)

FWIW, left trunk vs. LRA right (with PR54009 patch on rs6000.c):

r:  r:
stwu 1,-160(1)  stwu 1,-160(1)
lis 9,x+32764@halis 9,x+32764@ha
la 9,x+32764@l(9) | la 8,x+32764@l(9)
lwz 10,0(9)   <
lwz 11,4(9)   <
lis 9,y@ha  lis 9,y@ha
  > lwz 10,0(8)
  > lwz 11,4(8)
stfd ...
...
lfd ...
...
stw 10,y@l(9)   stw 10,y@l(9)
stw 11,y+4@l(9) stw 11,y+4@l(9)
addi 1,1,160addi 1,1,160
blr blr

w:  w:
stwu 1,-160(1)  stwu 1,-160(1)
lis 9,y@ha  lis 9,y@ha
la 10,y@l(9)la 10,y@l(9)
  > lis 9,x+32764@ha
lwz 11,4(10)lwz 11,4(10)
lwz 10,0(10)lwz 10,0(10)
lis 9,x+32764@ha  | la 8,x+32764@l(9)
stfd ...
...
lfd ...
...
lfd 31,152(1)   lfd 31,152(1)
lfd 0,8(1)| stw 10,0(8)
stfd 0,x+32764@l(9)   | stw 11,4(8)
addi 1,1,160addi 1,1,160
blr blr

I don't speak POWER but perhaps you can make sense of it :-)

Ciao!
Steven


libgo patch committed: Fix md5 on big-endian systems

2013-02-07 Thread Ian Lance Taylor
PR 56173 points out a number of checksum failures that turn out to be
related to a bug in the crypto/md5 package: some optimizations had been
added that make it only work correctly on little-endian systems.  This
patch corrects the problem.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 317c1f1eb8c1 libgo/go/crypto/md5/md5block.go
--- a/libgo/go/crypto/md5/md5block.go	Thu Feb 07 10:01:36 2013 -0800
+++ b/libgo/go/crypto/md5/md5block.go	Thu Feb 07 13:32:23 2013 -0800
@@ -5,6 +5,16 @@
 	"unsafe"
 )
 
+const x86 = runtime.GOARCH == "amd64" || runtime.GOARCH == "386"
+
+var littleEndian bool
+
+func init() {
+	x := uint32(0x04030201)
+	y := [4]byte{0x1, 0x2, 0x3, 0x4}
+	littleEndian = *(*[4]byte)(unsafe.Pointer(&x)) == y
+}
+
 func block(dig *digest, p []byte) {
 	a := dig.s[0]
 	b := dig.s[1]
@@ -16,13 +26,13 @@
 		aa, bb, cc, dd := a, b, c, d
 
 		// This is a constant condition - it is not evaluated on each iteration.
-		if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" {
+		if x86 {
 			// MD5 was designed so that x86 processors can just iterate
 			// over the block data directly as uint32s, and we generate
 			// less code and run 1.3x faster if we take advantage of that.
 			// My apologies.
 			X = (*[16]uint32)(unsafe.Pointer(&p[0]))
-		} else if uintptr(unsafe.Pointer(&p[0]))&(unsafe.Alignof(uint32(0))-1) == 0 {
+		} else if littleEndian && uintptr(unsafe.Pointer(&p[0]))&(unsafe.Alignof(uint32(0))-1) == 0 {
 			X = (*[16]uint32)(unsafe.Pointer(&p[0]))
 		} else {
 			X = &xbuf


[committed] Fix up C++ ICEs in build_constructor (PR c++/56241)

2013-02-07 Thread Jakub Jelinek
Hi!

build_constructor assumes the elts it is called with have all non-NULL
value, otherwise one shouldn't add those elts at all.

The following patch makes sure that we don't push elts with NULL value
into the ctor element vectors.

Bootstrapped/regtested on x86_64-linux and i686-linux, approved by Jason in
the PR, committed to trunk.

2013-02-07  Jakub Jelinek  

PR c++/56241
* init.c (build_vec_init): Don't append NULL values into new_vec.
(build_zero_init_1): Don't push anything into v if recursive call
returned NULL_TREE.
(build_value_init_noctor): Don't push anything into v if
build_value_init call returned NULL_TREE.

* g++.dg/parse/crash61.C: New test.

--- gcc/cp/init.c.jj2013-02-07 17:40:59.432029399 +0100
+++ gcc/cp/init.c   2013-02-07 19:05:02.044062934 +0100
@@ -253,8 +253,6 @@ build_zero_init_1 (tree type, tree nelts
{
  constructor_elt ce;
 
- vec_alloc (v, 1);
-
  /* If this is a one element array, we just use a regular init.  */
  if (tree_int_cst_equal (size_zero_node, max_index))
ce.index = size_zero_node;
@@ -265,7 +263,11 @@ build_zero_init_1 (tree type, tree nelts
  ce.value = build_zero_init_1 (TREE_TYPE (type),
 /*nelts=*/NULL_TREE,
 static_storage_p, NULL_TREE);
- v->quick_push (ce);
+ if (ce.value)
+   {
+ vec_alloc (v, 1);
+ v->quick_push (ce);
+   }
}
 
   /* Build a constructor to contain the initializations.  */
@@ -447,8 +449,6 @@ build_value_init_noctor (tree type, tsub
{
  constructor_elt ce;
 
- vec_alloc (v, 1);
-
  /* If this is a one element array, we just use a regular init.  */
  if (tree_int_cst_equal (size_zero_node, max_index))
ce.index = size_zero_node;
@@ -456,16 +456,20 @@ build_value_init_noctor (tree type, tsub
ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node, max_index);
 
  ce.value = build_value_init (TREE_TYPE (type), complain);
- v->quick_push (ce);
+ if (ce.value)
+   {
+ if (ce.value == error_mark_node)
+   return error_mark_node;
 
- if (ce.value == error_mark_node)
-   return error_mark_node;
+ vec_alloc (v, 1);
+ v->quick_push (ce);
 
- /* We shouldn't have gotten here for anything that would need
-non-trivial initialization, and gimplify_init_ctor_preeval
-would need to be fixed to allow it.  */
- gcc_assert (TREE_CODE (ce.value) != TARGET_EXPR
- && TREE_CODE (ce.value) != AGGR_INIT_EXPR);
+ /* We shouldn't have gotten here for anything that would need
+non-trivial initialization, and gimplify_init_ctor_preeval
+would need to be fixed to allow it.  */
+ gcc_assert (TREE_CODE (ce.value) != TARGET_EXPR
+ && TREE_CODE (ce.value) != AGGR_INIT_EXPR);
+   }
}
 
   /* Build a constructor to contain the initializations.  */
@@ -3469,9 +3473,12 @@ build_vec_init (tree base, tree maxindex
  else
{
  if (do_static_init)
-   CONSTRUCTOR_APPEND_ELT (new_vec, field,
-   build_zero_init (TREE_TYPE (e),
-NULL_TREE, true));
+   {
+ tree value = build_zero_init (TREE_TYPE (e), NULL_TREE,
+   true);
+ if (value)
+   CONSTRUCTOR_APPEND_ELT (new_vec, field, value);
+   }
  saw_non_const = true;
}
}
--- gcc/testsuite/g++.dg/parse/crash61.C.jj 2013-02-07 19:03:49.713481742 
+0100
+++ gcc/testsuite/g++.dg/parse/crash61.C2013-02-07 19:03:49.713481742 
+0100
@@ -0,0 +1,6 @@
+// PR c++/56241
+// { dg-do compile }
+
+struct pair { constexpr pair (const) : }; // { dg-error "" }
+template <0> make_pair () {} // { dg-error "" }
+pair prefix[] = { 0, make_pair } // { dg-error "" }

Jakub


Re: var-tracking wrt. leaf regs on sparc

2013-02-07 Thread David Miller
From: David Miller 
Date: Thu, 07 Feb 2013 14:38:18 -0500 (EST)

> From: Jakub Jelinek 
> Date: Thu, 7 Feb 2013 18:22:32 +0100
> 
>> Then supposedly somewhere in dwarf2out we do some adjustment,
>> but still end up with d/e loclist of:
>> .LLST2:
>> .uaxword.LVL0-.Ltext0   ! Location list begin address 
>> (*.LLST2)
>> .uaxword.LVL1-.Ltext0   ! Location list end address (*.LLST2)
>> .uahalf 0x6 ! Location expression size
>> .byte   0x88! DW_OP_breg24
>> .byte   0   ! sleb128 0
>> .byte   0x89! DW_OP_breg25
>> .byte   0   ! sleb128 0
>> .byte   0x22! DW_OP_plus
>> .byte   0x9f! DW_OP_stack_value
>> .uaxword.LVL1-.Ltext0   ! Location list begin address 
>> (*.LLST2)
>> .uaxword.LFE0-.Ltext0   ! Location list end address (*.LLST2)
>> .uahalf 0x1 ! Location expression size
>> .byte   0x58! DW_OP_reg8
>> .uaxword0   ! Location list terminator begin (*.LLST2)
>> .uaxword0   ! Location list terminator end (*.LLST2)
>> where I'd expect breg8/breg9 instead.
> 
> The fix for this is trivial, just a missing leaf renumbering in dwarf2out.c:

So the combined patch is below, any objections?

Here is the testsuite diff:

@@ -155,8 +148,8 @@ FAIL: gcc.dg/guality/vla-2.c  -O2 -flto

=== gcc Summary ===

-# of expected passes   2128
-# of unexpected failures   122
+# of expected passes   2135
+# of unexpected failures   115
 # of unexpected successes  31
 # of expected failures 17
 # of unsupported tests 136

This is undoubtedly an improvement.

gcc/

2013-02-07  David S. Miller  

* dwarf2out.c (based_loc_descr): Perform leaf register remapping
on 'reg'.
* var-tracking.c (vt_add_function_parameter): Test the presence of
HAVE_window_save properly and do not remap argument registers when
we have a leaf function.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 06cfb18..765d5c5 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10864,7 +10864,16 @@ based_loc_descr (rtx reg, HOST_WIDE_INT offset,
}
 }
 
-  regno = DWARF_FRAME_REGNUM (REGNO (reg));
+  regno = REGNO (reg);
+#ifdef LEAF_REG_REMAP
+  if (crtl->uses_only_leaf_regs)
+{
+  int leaf_reg = LEAF_REG_REMAP (regno);
+  if (leaf_reg != -1)
+   regno = (unsigned) leaf_reg;
+}
+#endif
+  regno = DWARF_FRAME_REGNUM (regno);
 
   if (!optimize && fde
   && (fde->drap_reg == regno || fde->vdrap_reg == regno))
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 714acb69..0db1562 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -9502,31 +9502,34 @@ vt_add_function_parameter (tree parm)
   /* DECL_INCOMING_RTL uses the INCOMING_REGNO of parameter registers.
  If the target machine has an explicit window save instruction, the
  actual entry value is the corresponding OUTGOING_REGNO instead.  */
-  if (REG_P (incoming)
-  && HARD_REGISTER_P (incoming)
-  && OUTGOING_REGNO (REGNO (incoming)) != REGNO (incoming))
+  if (HAVE_window_save && !crtl->uses_only_leaf_regs)
 {
-  parm_reg_t p;
-  p.incoming = incoming;
-  incoming
-   = gen_rtx_REG_offset (incoming, GET_MODE (incoming),
- OUTGOING_REGNO (REGNO (incoming)), 0);
-  p.outgoing = incoming;
-  vec_safe_push (windowed_parm_regs, p);
-}
-  else if (MEM_P (incoming)
-  && REG_P (XEXP (incoming, 0))
-  && HARD_REGISTER_P (XEXP (incoming, 0)))
-{
-  rtx reg = XEXP (incoming, 0);
-  if (OUTGOING_REGNO (REGNO (reg)) != REGNO (reg))
+  if (REG_P (incoming)
+ && HARD_REGISTER_P (incoming)
+ && OUTGOING_REGNO (REGNO (incoming)) != REGNO (incoming))
{
  parm_reg_t p;
- p.incoming = reg;
- reg = gen_raw_REG (GET_MODE (reg), OUTGOING_REGNO (REGNO (reg)));
- p.outgoing = reg;
+ p.incoming = incoming;
+ incoming
+   = gen_rtx_REG_offset (incoming, GET_MODE (incoming),
+ OUTGOING_REGNO (REGNO (incoming)), 0);
+ p.outgoing = incoming;
  vec_safe_push (windowed_parm_regs, p);
- incoming = replace_equiv_address_nv (incoming, reg);
+   }
+  else if (MEM_P (incoming)
+  && REG_P (XEXP (incoming, 0))
+  && HARD_REGISTER_P (XEXP (incoming, 0)))
+   {
+ rtx reg = XEXP (incoming, 0);
+ if (OUTGOING_REGNO (REGNO (reg)) != REGNO (reg))
+   {
+ parm_reg_t p;
+ p.incoming = reg;
+ reg = gen_raw_REG (GET_MODE (reg), OUTGOING_REGNO (REGNO (reg)));
+ p.outgoing = reg;
+ vec_safe_push (windowed_parm_regs, p);
+ incoming = replace_equiv_address_nv (incoming, reg);
+   }
}
 }
 #endif


Re: var-tracking wrt. leaf regs on sparc

2013-02-07 Thread Jakub Jelinek
On Thu, Feb 07, 2013 at 02:38:18PM -0500, David Miller wrote:
> The fix for this is trivial, just a missing leaf renumbering in dwarf2out.c:
> 
> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> index 06cfb18..765d5c5 100644
> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -10864,7 +10864,16 @@ based_loc_descr (rtx reg, HOST_WIDE_INT offset,
>   }
>  }
>  
> -  regno = DWARF_FRAME_REGNUM (REGNO (reg));
> +  regno = REGNO (reg);
> +#ifdef LEAF_REG_REMAP
> +  if (crtl->uses_only_leaf_regs)
> +{
> +  int leaf_reg = LEAF_REG_REMAP (regno);
> +  if (leaf_reg != -1)
> + regno = (unsigned) leaf_reg;
> +}
> +#endif
> +  regno = DWARF_FRAME_REGNUM (regno);
>  
>if (!optimize && fde
>&& (fde->drap_reg == regno || fde->vdrap_reg == regno))

This and earlier patch are ok, if it bootstraps/regtests fine, and suitable
ChangeLog entry is provided.
Running gdb testsuite before and after wouldn't hurt though.

Jakub


Re: var-tracking wrt. leaf regs on sparc

2013-02-07 Thread David Miller
From: Jakub Jelinek 
Date: Thu, 7 Feb 2013 18:22:32 +0100

> Then supposedly somewhere in dwarf2out we do some adjustment,
> but still end up with d/e loclist of:
> .LLST2:
> .uaxword.LVL0-.Ltext0   ! Location list begin address 
> (*.LLST2)
> .uaxword.LVL1-.Ltext0   ! Location list end address (*.LLST2)
> .uahalf 0x6 ! Location expression size
> .byte   0x88! DW_OP_breg24
> .byte   0   ! sleb128 0
> .byte   0x89! DW_OP_breg25
> .byte   0   ! sleb128 0
> .byte   0x22! DW_OP_plus
> .byte   0x9f! DW_OP_stack_value
> .uaxword.LVL1-.Ltext0   ! Location list begin address 
> (*.LLST2)
> .uaxword.LFE0-.Ltext0   ! Location list end address (*.LLST2)
> .uahalf 0x1 ! Location expression size
> .byte   0x58! DW_OP_reg8
> .uaxword0   ! Location list terminator begin (*.LLST2)
> .uaxword0   ! Location list terminator end (*.LLST2)
> where I'd expect breg8/breg9 instead.

The fix for this is trivial, just a missing leaf renumbering in dwarf2out.c:

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 06cfb18..765d5c5 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10864,7 +10864,16 @@ based_loc_descr (rtx reg, HOST_WIDE_INT offset,
}
 }
 
-  regno = DWARF_FRAME_REGNUM (REGNO (reg));
+  regno = REGNO (reg);
+#ifdef LEAF_REG_REMAP
+  if (crtl->uses_only_leaf_regs)
+{
+  int leaf_reg = LEAF_REG_REMAP (regno);
+  if (leaf_reg != -1)
+   regno = (unsigned) leaf_reg;
+}
+#endif
+  regno = DWARF_FRAME_REGNUM (regno);
 
   if (!optimize && fde
   && (fde->drap_reg == regno || fde->vdrap_reg == regno))


Re: [PATCH][IRA] Analysis of register usage of functions for usage by IRA.

2013-02-07 Thread Tom de Vries
Vladimir,

On 25/01/13 16:36, Vladimir Makarov wrote:
> On 01/25/2013 08:05 AM, Tom de Vries wrote:
>> Vladimir,
>>
>> this patch adds analysis of register usage of functions for usage by IRA.
>>
>> The patch:
>> - adds analysis in pass_final to track which hard registers are set or 
>> clobbered
>>by the function body, and stores that information in a struct cgraph_node.
>> - adds a target hook fn_other_hard_reg_usage to list hard registers that are
>>set or clobbered by a call to a function, but are not listed as such in 
>> the
>>function body, such as f.i. registers clobbered by veneers inserted by the
>>linker.
>> - adds a reg-note REG_CALL_DECL, to be able to easily link call_insns to 
>> their
>>corresponding declaration, even after the calls may have been split into 
>> an
>>insn (set register to function address) and a call_insn (call register), 
>> which
>>can happen for f.i. sh, and mips with -mabi-calls.
>> - uses the register analysis in IRA.
>> - adds an option -fuse-caller-save to control the optimization, on by default
>>at -Os and -O2 and higher.



>> Bootstrapped and reg-tested on x86_64, Ada inclusive. Build and reg-tested on
>> mips, arm, ppc and sh. No issues found. OK for stage1 trunk?
>>
>>
> Thanks for the patch.  I'll look at it during the next week.
> 

Did you get a chance to look at this?

> Right now I see that the code is based on reload which uses 
> caller-saves.c.  LRA does not use caller-saves.c at all.  Right now we 
> have LRA support only for x86/x86-64 but the next version will probably 
> have a few more targets based on LRA.  Fortunately, LRA modification 
> will be pretty easy with all this machinery.
> 

I see, thanks for noticing that. Btw I'm now working on a testsuite construct
dg-size-compare to be able to do
  dg-size-compare "text" "-fuse-caller-save" "<" "-fno-use-caller-save"
which I could have used to create a generic testcase, which would have
demonstrated that the optimization didn't work for x86_64.

I'm also currently looking at how to use the analysis in LRA.
AFAIU, in lra-constraints.c we do a backward scan over the insns, and keep track
of how many calls we've seen (calls_num), and mark insns with that number. Then
when looking at a live-range segment consisting of a def or use insn a and a
following use insn b, we can compare the number of calls seen for each insn, and
if they're not equal there is at least one call between the 2 insns, and if the
corresponding hard register is clobbered by calls, we spill after insn a and
restore before insn b.

That is too coarse-grained to use with our analysis, since we need to know which
calls occur in between insn a and insn b, and more precisely which registers
those calls clobbered.

I wonder though if we can do something similar: we keep an array
call_clobbers_num[FIRST_PSEUDO_REG], initialized at 0 when we start scanning.
When encountering a call, we increase the call_clobbers_num entries for the hard
registers clobbered by the call.
When encountering a use, we set the call_clobbers_num field of the use to
call_clobbers_num[reg_renumber[original_regno]].
And when looking at a live-range segment, we compare the clobbers_num field of
insn a and insn b, and if it is not equal, the hard register was clobbered by at
least one call between insn a and insn b.
Would that work? WDYT?

> I am going to use ira-improv branch for some my future work for gcc4.9.  
> And I am going to regularly (about once per month) merge trunk into it.  
> So if you want you could use the branch for your work too.  But this is 
> absolutely up to you.  I don't mind if you put this patch directly to 
> the trunk at stage1 when the review is finished.
> 

OK, I'd say stage1 then unless during review a reason pops up why it's better to
use the ira-improv branch.

Thanks,
- Tom


Re: [PATCH][ARM][3/3] Add vectorization support for rounding functions

2013-02-07 Thread Mike Stump
On Feb 7, 2013, at 7:51 AM, Kyrylo Tkachov  wrote:
> Ok to put it in with the other two ARM rounding vectorization patches that
> have been okayed for stage1?

Ok.


Re: [RS6000] Fix PR45053

2013-02-07 Thread Mike Stump
On Feb 7, 2013, at 3:49 AM, Richard Biener  wrote:
> On Thu, Feb 7, 2013 at 11:51 AM, Alan Modra  wrote:
>> On Thu, Feb 07, 2013 at 10:11:02AM +0100, Richard Biener wrote:
>>> On Thu, Feb 7, 2013 at 9:45 AM, Alan Modra  wrote:
 I think this one counts as obvious, but I'll ask for permission anyway.
 Bootstrapped etc. powerpc-linux.  OK everywhere?
>>> 
>>> Isn't there a way to just disable the out-of-line register save/restore
>>> functions?  Adding -O2 looks odd.
>> 
>> There isn't.  See rs6000.c:rs6000_savres_strategy.  I should note too
>> that using -O2 (anything but -Os) is only a solution for powerpc ELF.
>> powerpc-darwin may not be susceptible to the bug, but if it is then
>> some changes will be needed in rs6000_savres_strategy.  AIX doesn't
>> have a problem here since it always uses inline gpr saves/restores.
>> 
>> Also, powerpc64 targets using GNU ld or gold don't have a problem with
>> crtend.o calling save/restore functions as the linker creates these
>> functions.
> 
> It should be possible to add a -msavres-inline switch, right?  The other
> option would be to have a -Ono-s option that turns -Os into -O2
> (optimize == 2 for both) but leaves -O1/-O0 alone (by basically just
> setting optimize_size to 0).  Of course I consider that more ugly than
> a new switch to explicitely disable non-inline saveres code ;)

I like the -O2 approach as a permanent solution…  Having flags adds a burden to 
everyone and should be discouraged in all but the most dire of cases.  This 
isn't dire enough.


Fix PR target/50678

2013-02-07 Thread Eric Botcazou
This is hopefully the final nail in the coffin for PR target/50678, which is 
the failure of ACATS c52104y at -O2 on x86-64/Darwin.  The root cause was 
tracked down to a bug in the unwind info of the system sigtramp and a ticket 
was opened with Apple (radar #10302855).  Pending its resolution, a workaround 
was added in the Ada runtime on all active branches.

Simon reports that the bug has been fixed in Darwin 12.x, which makes c52104y 
fail again on this system because of the workaround.  So he has devised the 
attached patch to disable the workaround at run time.

Tested by Simon on Darwin 12 and Dominique on Darwin 10, applied on all active 
branches.


2013-02-07  Simon Wright  

PR target/50678
* init.c (__darwin_major_version): New function for x86-64/Darwin.
(__gnat_adjust_context_for_raise) [Darwin]: Disable the workaround
on Darwin 12 and above.


-- 
Eric BotcazouIndex: init.c
===
--- init.c	(revision 195841)
+++ init.c	(working copy)
@@ -2056,7 +2056,9 @@ __gnat_install_handler(void)
 #elif defined(__APPLE__)
 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2095,20 +2097,52 @@ __gnat_is_stack_guard (mach_vm_address_t
 
 #define HAVE_GNAT_ADJUST_CONTEXT_FOR_RAISE
 
+#if defined (__x86_64__)
+static int
+__darwin_major_version (void)
+{
+  static int cache = -1;
+  if (cache < 0)
+{
+  int mib[2] = {CTL_KERN, KERN_OSRELEASE};
+  size_t len;
+
+  /* Find out how big the buffer needs to be (and set cache to 0
+ on failure).  */
+  if (sysctl (mib, 2, NULL, &len, NULL, 0) == 0)
+{
+  char release[len];
+  sysctl (mib, 2, release, &len, NULL, 0);
+  /* Darwin releases are of the form L.M.N where L is the major
+ version, so strtol will return L.  */
+  cache = (int) strtol (release, NULL, 10);
+}
+  else
+{
+  cache = 0;
+}
+}
+  return cache;
+}
+#endif
+
 void
 __gnat_adjust_context_for_raise (int signo ATTRIBUTE_UNUSED,
  void *ucontext ATTRIBUTE_UNUSED)
 {
 #if defined (__x86_64__)
-  /* Work around radar #10302855/pr50678, where the unwinders (libunwind or
- libgcc_s depending on the system revision) and the DWARF unwind data for
- the sigtramp have different ideas about register numbering (causing rbx
- and rdx to be transposed)..  */
-  ucontext_t *uc = (ucontext_t *)ucontext ;
-  unsigned long t = uc->uc_mcontext->__ss.__rbx;
-
-  uc->uc_mcontext->__ss.__rbx = uc->uc_mcontext->__ss.__rdx;
-  uc->uc_mcontext->__ss.__rdx = t;
+  if (__darwin_major_version () < 12)
+{
+  /* Work around radar #10302855, where the unwinders (libunwind or
+	 libgcc_s depending on the system revision) and the DWARF unwind
+	 data for sigtramp have different ideas about register numbering,
+	 causing rbx and rdx to be transposed.  */
+  ucontext_t *uc = (ucontext_t *)ucontext;
+  unsigned long t = uc->uc_mcontext->__ss.__rbx;
+
+  uc->uc_mcontext->__ss.__rbx = uc->uc_mcontext->__ss.__rdx;
+  uc->uc_mcontext->__ss.__rdx = t;
+}
 #endif
 }
 

Re: libgo patch committed: Use DejaGNU when testing a cross-compiler

2013-02-07 Thread Ian Lance Taylor
On Thu, Feb 7, 2013 at 9:11 AM, Andreas Schwab  wrote:
> Ian Lance Taylor  writes:
>
>> +dnl Test whether we need to use DejaGNU or whether we can use the
>> +dnl simpler gotest approach.  We can only use gotest for a native
>> +dnl build.
>> +USE_DEJAGNU=no
>> +case ${host} in
>> +  *-*-rtems*) USE_DEJAGNU=yes ;;
>> +  ${target}) ;;
>
> This is a target library, so you need to check build != host to detect
> building with a cross-compiler.

Argh.  Thanks.  Fixed like so.

Ian


foo.patch
Description: Binary data


[committed] Fix parsing of ((type ()) () (PR c++/56239)

2013-02-07 Thread Jakub Jelinek
Hi!

As discussed in the PR, () isn't valid unary expression, so
((type ()) () needs to be parsed as a function call instead.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
approved by Jason in the PR, committed to trunk.

2013-02-07  Jakub Jelinek  

PR c++/56239
* parser.c (cp_parser_token_starts_cast_expression): Renamed to...
(cp_parser_tokens_start_cast_expression): ... this.  Change parameter
to cp_parser *, call cp_lexer_peek_token first.  For CPP_OPEN_PAREN,
return true only if 2nd token isn't CPP_CLOSE_PAREN.
(cp_parser_cast_expression): Adjust caller.

* g++.dg/parse/pr56239.C: New test.

--- gcc/cp/parser.c.jj  2013-02-07 08:59:50.0 +0100
+++ gcc/cp/parser.c 2013-02-07 13:53:16.169450209 +0100
@@ -7091,8 +7091,9 @@ cp_parser_delete_expression (cp_parser*
otherwise.  */
 
 static bool
-cp_parser_token_starts_cast_expression (cp_token *token)
+cp_parser_tokens_start_cast_expression (cp_parser *parser)
 {
+  cp_token *token = cp_lexer_peek_token (parser->lexer);
   switch (token->type)
 {
 case CPP_COMMA:
@@ -7133,6 +7134,12 @@ cp_parser_token_starts_cast_expression (
 case CPP_EOF:
   return false;
 
+case CPP_OPEN_PAREN:
+  /* In ((type ()) () the last () isn't a valid cast-expression,
+so the whole must be parsed as postfix-expression.  */
+  return cp_lexer_peek_nth_token (parser->lexer, 2)->type
+!= CPP_CLOSE_PAREN;
+
   /* '[' may start a primary-expression in obj-c++.  */
 case CPP_OPEN_SQUARE:
   return c_dialect_objc ();
@@ -7225,8 +7232,7 @@ cp_parser_cast_expression (cp_parser *pa
 parenthesized ctor such as `(T ())' that looks like a cast to
 function returning T.  */
   if (!cp_parser_error_occurred (parser)
- && cp_parser_token_starts_cast_expression (cp_lexer_peek_token
-(parser->lexer)))
+ && cp_parser_tokens_start_cast_expression (parser))
{
  cp_parser_parse_definitely (parser);
  expr = cp_parser_cast_expression (parser,
--- gcc/testsuite/g++.dg/parse/pr56239.C.jj 2013-02-07 13:56:04.628448688 
+0100
+++ gcc/testsuite/g++.dg/parse/pr56239.C2013-02-07 13:55:14.0 
+0100
@@ -0,0 +1,13 @@
+// PR c++/56239
+// { dg-do compile }
+
+struct S
+{
+  int operator () () { return 0; }
+};
+
+int
+main ()
+{
+  return (S ()) ();
+}

Jakub


[committed] Fix ICE in push_local_name (PR c++/56237)

2013-02-07 Thread Jakub Jelinek
Hi!

If DECL_LANG_SPECIFIC is created for a local var due to other reason
than push_local_name, it might not have u.base.u2sel bit set and
so DECL_DISCRIMINATOR can't be used on it (instead, should be assumed to be
0).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
approved by Jason in the PR, committed to trunk.

2013-02-07  Jakub Jelinek  

PR c++/56237
* decl.c (push_local_name): Look at DECL_DISCRIMINATOR (t)
only if DECL_DISCRIMINATOR_SET_P (t) rather than just
DECL_LANG_SPECIFIC (t).

* g++.dg/abi/mangle61.C: New test.

--- gcc/cp/decl.c.jj2013-02-06 11:33:05.0 +0100
+++ gcc/cp/decl.c   2013-02-07 11:45:50.754972085 +0100
@@ -920,7 +920,7 @@ push_local_name (tree decl)
  if (!DECL_LANG_SPECIFIC (decl))
retrofit_lang_decl (decl);
  DECL_LANG_SPECIFIC (decl)->u.base.u2sel = 1;
- if (DECL_LANG_SPECIFIC (t))
+ if (DECL_DISCRIMINATOR_SET_P (t))
DECL_DISCRIMINATOR (decl) = DECL_DISCRIMINATOR (t) + 1;
  else
DECL_DISCRIMINATOR (decl) = 1;
--- gcc/testsuite/g++.dg/abi/mangle61.C.jj  2013-02-07 11:56:14.540241809 
+0100
+++ gcc/testsuite/g++.dg/abi/mangle61.C 2013-02-07 11:56:04.0 +0100
@@ -0,0 +1,28 @@
+// PR c++/56237
+// { dg-do compile }
+
+void *p[4];
+
+void
+foo ()
+{
+  static union { } u;
+  p[0] = &u;
+  {
+static union { } u; 
+p[1] = &u;
+{
+  static union { } u;
+  p[2] = &u;
+}
+  }
+  {
+static union { } u;
+p[3] = &u;
+  }
+}
+
+// { dg-final { scan-assembler "_ZZ3foovE1u\[^_\]" } }
+// { dg-final { scan-assembler "_ZZ3foovE1u_0" } }
+// { dg-final { scan-assembler "_ZZ3foovE1u_1" } }
+// { dg-final { scan-assembler "_ZZ3foovE1u_2" } }

Jakub


[PATCH] Fix bootstrap with -O3

2013-02-07 Thread Marek Polacek
When bootstrapping with BOOT_FLAGS='-O3 -g', I get:
/home/polacek/src/gcc/gcc/c/c-parser.c: In function ‘c_expr 
c_parser_postfix_expression_after_primary(c_parser*, location_t, c_expr)’:
/home/polacek/src/gcc/gcc/c/c-parser.c:6908:16: error: ‘origtypes’ may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
So this patch explicitly initializes origtypes to NULL.

Regtested/bootstrapped (with BOOT_FLAGS='-O3 -g') on x86_64-linux,
ok for trunk?

2013-02-07  Marek Polacek  

* c-parser.c (origtypes): Initialize to NULL.

--- gcc/c-parser.c.mp   2013-02-07 17:50:10.286742403 +0100
+++ gcc/c-parser.c  2013-02-07 17:50:23.331781876 +0100
@@ -6864,7 +6864,7 @@ c_parser_postfix_expression_after_primar
   tree sizeof_arg[3];
   unsigned int i;
   vec *exprlist;
-  vec *origtypes;
+  vec *origtypes = NULL;
   while (true)
 {
   location_t op_loc = c_parser_peek_token (parser)->location;

Marek


Re: var-tracking wrt. leaf regs on sparc

2013-02-07 Thread Jakub Jelinek
On Wed, Feb 06, 2013 at 03:18:27PM -0500, David Miller wrote:
> From: Eric Botcazou 
> Date: Wed, 06 Feb 2013 11:13:30 +0100
> 
> > I think testing crtl->uses_only_leaf_regs is sufficient here (and
> > while you're at it, you could also test the value of
> > HAVE_window_save, which can be 0 if -mflat is passed on the SPARC),
> > so
> > 
> > #ifdef HAVE_window_save
> > if (HAVE_window_save && !crtl->uses_only_leaf_regs)
> >   {
> > 
> >   }
> > #endif
> 
> Yes, this works perfectly, Jakub any objections?

Perhaps some progress, but not fully working.  I guess you should start
with deciding when the regs should be remapped.  Consider even
simple testcase like (-O2 -g -dA):

int
foo (int a, int b)
{
  int c = a;
  int d = a + b;
  int e = a + b;
  return e;
}

Before *.vartrack, all debug_insn as well as normal insns refer to
%i0 and %i1, before your patch some NOTE_INSN_VAR_LOCATION were referring
to %o[01] registers, others to %i[01] registers, with your patch all refer
to %i[01] registers.  leaf_renumber_regs isn't performed on notes (so,
neither NOTE_INSN_VAR_LOCATION nor NOTE_INSN_CALL_ARG_LOCATION are
adjusted).  Then supposedly somewhere in dwarf2out we do some adjustment,
but still end up with d/e loclist of:
.LLST2:
.uaxword.LVL0-.Ltext0   ! Location list begin address (*.LLST2)
.uaxword.LVL1-.Ltext0   ! Location list end address (*.LLST2)
.uahalf 0x6 ! Location expression size
.byte   0x88! DW_OP_breg24
.byte   0   ! sleb128 0
.byte   0x89! DW_OP_breg25
.byte   0   ! sleb128 0
.byte   0x22! DW_OP_plus
.byte   0x9f! DW_OP_stack_value
.uaxword.LVL1-.Ltext0   ! Location list begin address (*.LLST2)
.uaxword.LFE0-.Ltext0   ! Location list end address (*.LLST2)
.uahalf 0x1 ! Location expression size
.byte   0x58! DW_OP_reg8
.uaxword0   ! Location list terminator begin (*.LLST2)
.uaxword0   ! Location list terminator end (*.LLST2)
where I'd expect breg8/breg9 instead.

Jakub


patch to fix PR56225

2013-02-07 Thread Vladimir Makarov

The following patch fixes

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

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

Committed as rev. 195856.

2013-02-07  Vladimir Makarov  

PR rtl-optimization/56225
* lra-constraints.c (process_alt_operands): Check that reload hard
reg can hold value for strict_low_part.

2013-02-07  Vladimir Makarov  

PR rtl-optimization/56225
* gcc.target/i386/pr56225.c: New test.

Index: lra-constraints.c
===
--- lra-constraints.c	(revision 195807)
+++ lra-constraints.c	(working copy)
@@ -1895,7 +1895,22 @@ process_alt_operands (int only_alternati
 			? in_hard_reg_set_p (this_alternative_set,
 	 mode, hard_regno[nop])
 			: in_class_p (op, this_alternative, NULL
-		losers++;
+		{
+		  /* Strict_low_part requires reload the register not
+		 the sub-register.  In this case we should check
+		 that a final reload hard reg can hold the
+		 value.  */
+		  if (curr_static_id->operand[nop].strict_low
+		  && REG_P (op)
+		  && hard_regno[nop] < 0
+		  && GET_CODE (*curr_id->operand_loc[nop]) == SUBREG
+		  && ira_class_hard_regs_num[this_alternative] > 0
+		  && ! HARD_REGNO_MODE_OK (ira_class_hard_regs
+	   [this_alternative][0],
+	   GET_MODE (op)))
+		goto fail;
+		  losers++;
+		}
 	  if (operand_reg[nop] != NULL_RTX
 		  /* Output operands and matched input operands are
 		 not inherited.  The following conditions do not
Index: testsuite/gcc.target/i386/pr56225.c
===
--- testsuite/gcc.target/i386/pr56225.c	(revision 0)
+++ testsuite/gcc.target/i386/pr56225.c	(working copy)
@@ -0,0 +1,12 @@
+/* PR target/56225 */
+/* { dg-do compile { target { ia32 } } } */
+/* { dg-options "-O2 -march=pentium3 -mtune=generic" } */
+
+void bar (int);
+
+void
+foo (int x, int y)
+{
+  __attribute__ ((vector_size (8 * sizeof (short short s0 = { x };
+  bar ((short) (long) &s0 + y);
+}


Re: libgo patch committed: Use DejaGNU when testing a cross-compiler

2013-02-07 Thread Andreas Schwab
Ian Lance Taylor  writes:

> +dnl Test whether we need to use DejaGNU or whether we can use the
> +dnl simpler gotest approach.  We can only use gotest for a native
> +dnl build.
> +USE_DEJAGNU=no
> +case ${host} in
> +  *-*-rtems*) USE_DEJAGNU=yes ;;
> +  ${target}) ;;

This is a target library, so you need to check build != host to detect
building with a cross-compiler.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Re: libgo patch committed: Fixes for select based pollster

2013-02-07 Thread Ian Lance Taylor
On Thu, Feb 7, 2013 at 8:51 AM, Rainer Orth  
wrote:
> Ian Lance Taylor  writes:
>
>> On Solaris the libgo networking library uses select.  This patch
>> implements some fixes for that code.  The Close method is changed to
>> actually do something; this is mainly for testing purposes.  More
>> importantly, when a socket is closed, the select needs to be restarted
>> so that the callers see the close.  Bootstrapped and ran Go testsuite on
>> x86_64-unknown-linux-gnu.  Committed to mainline.
>>
>
> Thanks, this got net to almost passing on Solaris: the only remaining
> failure is
>
> pollServer WaitFD: pollster closed
> --- FAIL: TestMulticastListener (0.00 seconds)
> multicast_posix_test.go:70: "224.0.0.254:12345" not found in RIB
> multicast_posix_test.go:75: "224.0.0.254:12345" not found in RIB
> multicast_posix_test.go:70: "224.0.0.254:12345" not found in RIB
> multicast_posix_test.go:75: "224.0.0.254:12345" not found in RIB
> Select unexpected fd=13 for write
> FAIL
> FAIL: net
>
> which is no wonder since Solaris still uses interface_stub.go.  I've
> checked what it takes to implement those interfaces, but it's quite an
> effort, so for the moment we should just skip the test.
>
> The following patch does this and allows the net test to pass.

Thanks.  Committed.

Ian


Re: libgo patch committed: Fixes for select based pollster

2013-02-07 Thread Rainer Orth
Ian Lance Taylor  writes:

> On Solaris the libgo networking library uses select.  This patch
> implements some fixes for that code.  The Close method is changed to
> actually do something; this is mainly for testing purposes.  More
> importantly, when a socket is closed, the select needs to be restarted
> so that the callers see the close.  Bootstrapped and ran Go testsuite on
> x86_64-unknown-linux-gnu.  Committed to mainline.
>

Thanks, this got net to almost passing on Solaris: the only remaining
failure is

pollServer WaitFD: pollster closed
--- FAIL: TestMulticastListener (0.00 seconds)
multicast_posix_test.go:70: "224.0.0.254:12345" not found in RIB
multicast_posix_test.go:75: "224.0.0.254:12345" not found in RIB
multicast_posix_test.go:70: "224.0.0.254:12345" not found in RIB
multicast_posix_test.go:75: "224.0.0.254:12345" not found in RIB
Select unexpected fd=13 for write
FAIL
FAIL: net

which is no wonder since Solaris still uses interface_stub.go.  I've
checked what it takes to implement those interfaces, but it's quite an
effort, so for the moment we should just skip the test.

The following patch does this and allows the net test to pass.

Rainer


2013-02-07  Rainer Orth  

PR go/56172
* go/net/multicast_posix_test.go (TestMulticastListener): Skip on
solaris.

diff --git a/libgo/go/net/multicast_posix_test.go b/libgo/go/net/multicast_posix_test.go
--- a/libgo/go/net/multicast_posix_test.go
+++ b/libgo/go/net/multicast_posix_test.go
@@ -47,7 +47,7 @@ var multicastListenerTests = []struct {
 // listener with same address family, same group address and same port.
 func TestMulticastListener(t *testing.T) {
 	switch runtime.GOOS {
-	case "netbsd", "openbsd", "plan9", "windows":
+	case "netbsd", "openbsd", "plan9", "solaris", "windows":
 		t.Skipf("skipping test on %q", runtime.GOOS)
 	case "linux":
 		if runtime.GOARCH == "arm" || runtime.GOARCH == "alpha" {


-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] Check headers in verify_loop_structure

2013-02-07 Thread Marek Polacek
On Thu, Feb 07, 2013 at 02:56:48PM +0100, Richard Biener wrote:
> > +  /* Check the headers.  */
> > +  FOR_EACH_BB (bb)
> > +{
> > +  /* Skip BBs in the root tree.  */
> > +  if (bb->loop_father == current_loops->tree_root)
> > +   continue;
> 
> You shouldn't need this ... it will miss missing toplevel loops

Done.

> > +  if (bb_loop_header_p (bb))
> > +   if (bb->loop_father->header != bb)
> 
>   && bb->loop_father->header != bb)

Fixed.  Regtested/bootstrapped on x86_64 again (with tailc fix:
http://gcc.gnu.org/ml/gcc-patches/2013-02/msg00310.html), ok now?

2013-02-07  Marek Polacek  

* cfgloop.c (verify_loop_structure): Add more checking
of headers.

--- gcc/cfgloop.c.mp2013-02-07 14:07:24.580864372 +0100
+++ gcc/cfgloop.c   2013-02-07 15:06:19.278571095 +0100
@@ -1353,6 +1353,15 @@ verify_loop_structure (void)
}
 }
 
+  /* Check the headers.  */
+  FOR_EACH_BB (bb)
+if (bb_loop_header_p (bb)
+   && bb->loop_father->header != bb)
+  {
+   error ("loop with header %d not in loop tree", bb->index);
+   err = 1;
+  }
+
   /* Check get_loop_body.  */
   visited = sbitmap_alloc (last_basic_block);
   bitmap_clear (visited);

Marek


Re: [PATCH] Properly make loops from tail-recursion appear

2013-02-07 Thread Marek Polacek
On Thu, Feb 07, 2013 at 04:40:56PM +0100, Richard Biener wrote:
> 
> This fixes fallout from the loops-exist verifier.  And it optimizes
> compile-time of IPA pure-const.
> 
> Not yet tested in any way (but quite obvious).

FYI, I've regtested/bootstrapped this one on x86_64, together with my loop
verifier bits.  All loos fine.  Thanks,

Marek


Re: libgo patch committed: Update to current version of Go library

2013-02-07 Thread Ian Lance Taylor
On Thu, Feb 7, 2013 at 2:26 AM, Uros Bizjak  wrote:
>
> Thanks, I have tested it on CentOS 5.9. However, for some reason, I
> got unrelated linker errors that prevents further testing:
>
> === libgo tests ===
>
> ./a.out: error while loading shared libraries:
> /home/uros/gcc-build/x86_64-unknown-linux-gnu/libgo/.libs/libgo.so.3:
> ELF file OS ABI invalid

This is not, of course, related to Go.

It looks like libgo.so.3 and libatomic.so.1 got created with the
EI_OSABI field set to ELFOSABI_GNU, and it looks like your kernel is
too old and does not know about that.  I assume that you are using a
new version of the binutils, not the one that comes with the system.
Are you using GNU ld or gold?  In general the linker will set EI_OSABI
to ELFOSABI_GNU if it sees a STB_GNU_UNIQUE symbol or a STT_GNU_IFUNC
symbol.  As far as I know neither libgo nor libatomic have either type
of symbol.  So I'm not sure where this is coming from.

If you start again and configure GCC to use the system binutils rather
than a newer binutils, then you should be safe in not getting any
UNIQUE or IFUNC symbols.  I don't know if you might run into other
problems.

Ian


C++ PATCH for c++/56235 (wrong error with bit-field and move constructor)

2013-02-07 Thread Jason Merrill
Converting a bit-field reference from lvalue to xvalue obscures its 
unlowered type, and isn't useful for scalars anyway.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 4351fe77d1cc018b9f84cbc775489336fb295fb5
Author: Jason Merrill 
Date:   Thu Feb 7 11:06:19 2013 -0500

	PR c++/56235
	* method.c (do_build_copy_constructor): Don't bother turning
	scalars from lvalues to xvalues.
	(do_build_copy_assign): Likewise.

diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index d13a0cf..a1bab95 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -610,7 +610,9 @@ do_build_copy_constructor (tree fndecl)
 	}
 
 	  init = build3 (COMPONENT_REF, expr_type, parm, field, NULL_TREE);
-	  if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE)
+	  if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE
+	  /* 'move' breaks bit-fields, and has no effect for scalars.  */
+	  && !scalarish_type_p (expr_type))
 	init = move (init);
 	  init = build_tree_list (NULL_TREE, init);
 
@@ -724,7 +726,9 @@ do_build_copy_assign (tree fndecl)
 	  expr_type = cp_build_qualified_type (expr_type, quals);
 
 	  init = build3 (COMPONENT_REF, expr_type, init, field, NULL_TREE);
-	  if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE)
+	  if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE
+	  /* 'move' breaks bit-fields, and has no effect for scalars.  */
+	  && !scalarish_type_p (expr_type))
 	init = move (init);
 
 	  if (DECL_NAME (field))
diff --git a/gcc/testsuite/g++.dg/init/bitfield4.C b/gcc/testsuite/g++.dg/init/bitfield4.C
new file mode 100644
index 000..30041c4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/bitfield4.C
@@ -0,0 +1,24 @@
+// PR c++/56235
+
+struct A
+{
+  A (const A &);
+};
+
+struct B
+{
+  A a;
+  enum Mode { };
+  Mode m:8;
+};
+
+struct C
+{
+  C();
+  B b;
+};
+
+C fn()
+{
+  return C();
+}


[Patch] Ad PR 56064: Extend fixed_from_double_int input

2013-02-07 Thread Georg-Johann Lay
This patch solves a problem with VIEW_CONVERT_EXPR folding for fixed_cst and
that use fixed-value.c:fixed_from_double_int.

The patch sign/zero extends the double_int input according to the requested
fixed-point mode.

The patch bootstraps on x86-linux-gnu and passes testsuite on avr-unknown one.

Without this patch, the new test case fails because when a SAmode is
constructed in fold-const.c:native_interpret_fixed(), the MSBs are not set
according to the sign of the value.

However, functions dealing with fixed-point constants use all bits of the
underlying double_int, not only those covered by the mode mask.

Moreover, some sanity checking is added for to the incoming machine mode.

Ok for trunk?

gcc/
PR tree-optimization/56064
* fixed-value.c (fixed_from_double_int): Sign/zero extend payload
bits according to mode.
* fixed-value.h (fixed_from_double_int)
(const_fixed_from_double_int): Adjust comments.

gcc/testsuite/
PR tree-optimization/56064
* gcc.dg/fixed-point/view-convert-2.c: New test.


Index: fixed-value.c
===
--- fixed-value.c	(revision 195736)
+++ fixed-value.c	(working copy)
@@ -83,7 +83,7 @@ check_real_for_fixed_mode (REAL_VALUE_TY
 
 
 /* Construct a CONST_FIXED from a bit payload and machine mode MODE.
-   The bits in PAYLOAD are used verbatim.  */
+   The bits in PAYLOAD are sign-extended/zero-extended according to MODE.  */
 
 FIXED_VALUE_TYPE
 fixed_from_double_int (double_int payload, enum machine_mode mode)
@@ -92,7 +92,13 @@ fixed_from_double_int (double_int payloa
 
   gcc_assert (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_DOUBLE_INT);
 
-  value.data = payload;
+  if (SIGNED_SCALAR_FIXED_POINT_MODE_P (mode))
+value.data = payload.sext (1 + GET_MODE_IBIT (mode) + GET_MODE_FBIT (mode));
+  else if (UNSIGNED_SCALAR_FIXED_POINT_MODE_P (mode))
+value.data = payload.zext (GET_MODE_IBIT (mode) + GET_MODE_FBIT (mode));
+  else
+gcc_unreachable();
+
   value.mode = mode;
 
   return value;
Index: fixed-value.h
===
--- fixed-value.h	(revision 195736)
+++ fixed-value.h	(working copy)
@@ -50,12 +50,12 @@ extern FIXED_VALUE_TYPE fconst1[MAX_FCON
 extern rtx const_fixed_from_fixed_value (FIXED_VALUE_TYPE, enum machine_mode);
 
 /* Construct a FIXED_VALUE from a bit payload and machine mode MODE.
-   The bits in PAYLOAD are used verbatim.  */
+   The bits in PAYLOAD are sign-extended/zero-extended according to MODE.  */
 extern FIXED_VALUE_TYPE fixed_from_double_int (double_int,
 		 enum machine_mode);
 
 /* Return a CONST_FIXED from a bit payload and machine mode MODE.
-   The bits in PAYLOAD are used verbatim.  */
+   The bits in PAYLOAD are sign-extended/zero-extended according to MODE.  */
 static inline rtx
 const_fixed_from_double_int (double_int payload,
  enum machine_mode mode)
Index: testsuite/gcc.dg/fixed-point/view-convert-2.c
===
--- testsuite/gcc.dg/fixed-point/view-convert-2.c	(revision 0)
+++ testsuite/gcc.dg/fixed-point/view-convert-2.c	(revision 0)
@@ -0,0 +1,139 @@
+/* PR tree-optimization/56064 */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -O2" } */
+
+extern void abort (void);
+extern void exit (int);
+
+void test_k (void)
+{
+  _Accum a;
+  __INT32_TYPE__ i = -__INT32_MAX__;
+  
+  if (sizeof (a) != sizeof (i))
+return;
+
+  __builtin_memcpy (&a, &i, sizeof (a));
+
+  if (a >= 0k)
+abort();
+}
+
+void test_0k (void)
+{
+  _Accum a;
+  __INT32_TYPE__ i = 0;
+  
+  if (sizeof (a) != sizeof (i))
+return;
+
+  __builtin_memcpy (&a, &i, sizeof (a));
+
+  if (a != 0k)
+abort();
+}
+
+
+void test_hr (void)
+{
+  short _Fract a;
+  __INT8_TYPE__ i = -__INT8_MAX__;
+
+  if (sizeof (a) != sizeof (i))
+return;
+
+  __builtin_memcpy (&a, &i, sizeof (a));
+
+  if (a >= 0hr)
+abort();
+}
+
+void test_0hr (void)
+{
+  short _Fract a;
+  __INT8_TYPE__ i = 0;
+
+  if (sizeof (a) != sizeof (i))
+return;
+
+  __builtin_memcpy (&a, &i, sizeof (a));
+
+  if (a != 0hr)
+abort();
+}
+
+
+void test_si (void)
+{
+  _Accum a = __ACCUM_MIN__;
+  __INT32_TYPE__ i;
+
+  if (sizeof (a) != sizeof (i))
+return;
+
+  __builtin_memcpy (&i, &a, sizeof (i));
+
+  if (i >= 0)
+abort();
+}
+
+void test_0si (void)
+{
+  _Accum a = 0;
+  __INT32_TYPE__ i;
+
+  if (sizeof (a) != sizeof (i))
+return;
+
+  __builtin_memcpy (&i, &a, sizeof (i));
+
+  if (i != 0)
+abort();
+}
+
+
+void test_qi (void)
+{
+  short _Fract a = __SFRACT_MIN__;
+  __INT8_TYPE__ i;
+
+  if (sizeof (a) != sizeof (i))
+return;
+
+  __builtin_memcpy (&i, &a, sizeof (i));
+
+  if (i >= 0)
+abort();
+}
+
+void test_0qi (void)
+{
+  short _Fract a = 0hr;
+  __INT8_TYPE__ i;
+
+  if (sizeof (a) != sizeof (i))
+return;
+
+  __builtin_memcpy (&i, &a, sizeof (i));
+
+  if (i != 0)
+abort();
+}

Re: [PATCH] Make IRA use current_loops and loop_optimizer_init

2013-02-07 Thread Richard Biener
On Thu, 7 Feb 2013, Vladimir Makarov wrote:

> On 02/07/2013 09:56 AM, Richard Biener wrote:
> > The following gets rid of ira_loops (ok, without touching all uses
> > yet but with a #define - I'll finish this if you are ok with it
> > in general).
> > 
> > Bootstrap and regtest running on x86_64-unknown-linux-gnu.
> > 
> > Ok for trunk for the IRA parts?  (well, given I search & replace
> > uses of ira_loops)
> > 
> > 
> IRA parts are ok for me.  Thanks, Richard.

Ok, I'll re-test the following complete transition then:
ira_loops.larray -> get_loops ()
vec_safe_length (ira_loops.larray) -> number_of_loops ()

Richard.

2013-02-07  Richard Biener  

* cfgloop.c (verify_loop_structure): Properly handle
a loop exiting to another loop header.
* ira-int.h (ira_loops): Remove.
* ira.c (ira_loops): Remove.
(ira): Use loop_optimizer_init and loop_optimizer_finalize.
(do_reload): Use loop_optimizer_finalize.
* ira-build.c (create_loop_tree_nodes): Use get_loops and
number_of_loops to access the loop tree.
(more_one_region_p): Likewise.
(finish_loop_tree_nodes): Likewise.
(rebuild_regno_allocno_maps): Likewise.
(mark_loops_for_removal): Likewise.
(mark_all_loops_for_removal): Likewise.
(remove_unnecessary_regions): Likewise.
(ira_build): Likewise.
* ira-emit.c (setup_entered_from_non_parent_p): Likewise.

Index: gcc/cfgloop.c
===
*** gcc/cfgloop.c.orig  2013-02-07 16:44:11.0 +0100
--- gcc/cfgloop.c   2013-02-07 16:48:47.840820001 +0100
*** verify_loop_structure (void)
*** 1550,1556 
eloops++;
  
  for (loop = bb->loop_father;
!  loop != e->dest->loop_father;
   loop = loop_outer (loop))
{
  eloops--;
--- 1550,1561 
eloops++;
  
  for (loop = bb->loop_father;
!  loop != e->dest->loop_father
!  /* When a loop exit is also an entry edge which
! can happen when avoiding CFG manipulations
! then the last loop exited is the outer loop
! of the loop entered.  */
!  && loop != loop_outer (e->dest->loop_father);
   loop = loop_outer (loop))
{
  eloops--;
Index: gcc/ira-int.h
===
*** gcc/ira-int.h.orig  2013-02-07 16:13:56.0 +0100
--- gcc/ira-int.h   2013-02-07 16:44:56.825055085 +0100
*** along with GCC; see the file COPYING3.
*** 47,55 
 ? REG_FREQ_MAX : (freq * REG_FREQ_MAX / BB_FREQ_MAX)   
   \
 ? (freq * REG_FREQ_MAX / BB_FREQ_MAX) : 1)
  
- /* All natural loops.  */
- extern struct loops ira_loops;
- 
  /* A modified value of flag `-fira-verbose' used internally.  */
  extern int internal_flag_ira_verbose;
  
--- 47,52 
Index: gcc/ira.c
===
*** gcc/ira.c.orig  2013-02-07 16:44:11.0 +0100
--- gcc/ira.c   2013-02-07 16:44:51.685993626 +0100
*** allocate_initial_values (void)
*** 4338,4346 
 function.  */
  bool ira_use_lra_p;
  
- /* All natural loops.  */
- struct loops ira_loops;
- 
  /* True if we have allocno conflicts.  It is false for non-optimized
 mode or when the conflict table is too big.  */
  bool ira_conflicts_p;
--- 4338,4343 
*** ira (FILE *f)
*** 4464,4474 
  
ira_assert (current_loops == NULL);
if (flag_ira_region == IRA_REGION_ALL || flag_ira_region == 
IRA_REGION_MIXED)
! {
!   flow_loops_find (&ira_loops);
!   current_loops = &ira_loops;
!   record_loop_exits ();
! }
  
if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
  fprintf (ira_dump_file, "Building IRA IR\n");
--- 4461,4467 
  
ira_assert (current_loops == NULL);
if (flag_ira_region == IRA_REGION_ALL || flag_ira_region == 
IRA_REGION_MIXED)
! loop_optimizer_init (AVOID_CFG_MODIFICATIONS | LOOPS_HAVE_RECORDED_EXITS);
  
if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
  fprintf (ira_dump_file, "Building IRA IR\n");
*** ira (FILE *f)
*** 4526,4536 
  /* ??? Rebuild the loop tree, but why?  Does the loop tree
 change if new insns were generated?  Can that be handled
 by updating the loop tree incrementally?  */
! release_recorded_exits ();
! flow_loops_free (&ira_loops);
! flow_loops_find (&ira_loops);
! current_loops = &ira_loops;
! record_loop_exits ();
  
  if (! ira_use_lra_p)
{
--- 4519,4527 
  /* ??? Rebuild the loop tree, but why?  Does the loop tree
 change if new insns were generated?  Can that be ha

RE: [PATCH][ARM][3/3] Add vectorization support for rounding functions

2013-02-07 Thread Kyrylo Tkachov
Hi all,
This testsuite patch has been okayed at
http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01141.html
but I have not applied it and I'd like to add a couple of things to it.

Currently, add_options_for_arm_v8_neon would explicitly set
-mfloat-abi=softfp which would break
check_effective_target_arm_v8_neon_hw for configurations with hard float
ABI, thus preventing the execution tests that use this check in gcc.dg/vect
from running.
This patch fixes that.

Ok to put it in with the other two ARM rounding vectorization patches that
have been okayed for stage1?

Thanks,
Kyrill

gcc/testuite/ChangeLog

2013-02-07  Kyrylo Tkachov  

* lib/target-supports.exp (check_effective_target_arm_v8_neon_hw):
New procedure.
(check_effective_target_arm_v8_neon_ok_nocache):
Likewise.
(check_effective_target_arm_v8_neon_ok): Change to use
check_effective_target_arm_v8_neon_ok_nocache.
(add_options_for_arm_v8_neon): Use et_arm_v8_neon_flags to set ARMv8
NEON flags.
(check_effective_target_vect_call_btruncf):
Enable for arm and ARMv8 NEON.
(check_effective_target_vect_call_ceilf): Likewise.
(check_effective_target_vect_call_floorf): Likewise.
(check_effective_target_vect_call_roundf): Likewise.
(check_vect_support_and_set_flags): Handle ARMv8 NEON effective
target.

> -Original Message-
> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
> ow...@gcc.gnu.org] On Behalf Of Kyrylo Tkachov
> Sent: 18 December 2012 13:34
> To: gcc-patches@gcc.gnu.org
> Cc: Ramana Radhakrishnan; Richard Earnshaw
> Subject: [PATCH][ARM][3/3] Add vectorization support for rounding
> functions
> 
> Hi all,
> This patch adds arm and v8 NEON to the effective target checks that are
> used
> in the rounding functions vectorisation tests.
> A new effective target check for NEON hardware is added This check is
> used
> to determine
> whether to do runtime tests or just compilation.
> 
> With these changes the following tests now PASS on arm instead of being
> UNSUPPORTED:
> * gcc.dg/vect/vect-rounding-btrunc.c
> * gcc.dg/vect/vect-rounding-ceilf.c
> * gcc.dg/vect/vect-rounding-floorf.c
> * gcc.dg/vect/vect-rounding-roundf.c
> 
> Tested on arm-none-eabi with model and softfp float ABI.
> 
> Ok for trunk?
> 
> Thanks,
> Kyrill
> 
> gcc/testuite/ChangeLog
> 
> 2012-12-18  Kyrylo Tkachov  
> 
>   * lib/target-supports.exp
> (check_effective_target_arm_v8_neon_hw):
> New procedure.
> (check_effective_target_vect_call_btruncf):
> Add check for arm and ARMv8 NEON.
> (check_effective_target_vect_call_ceilf): Likewise.
> (check_effective_target_vect_call_floorf): Likewise.
> (check_effective_target_vect_call_roundf): Likewise.
> (check_vect_support_and_set_flags): Handle ARMv8 NEON effective
> target.diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 0c824b8..3158e87 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2147,22 +2147,6 @@ proc check_effective_target_arm_v8_vfp_ok {} {
 }
 }
 
-# Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
-# -mfloat-abi=softfp
-proc check_effective_target_arm_v8_neon_ok {} {
-if { [check_effective_target_arm32] } {
-   return [check_no_compiler_messages arm_v8_neon_ok object {
- int foo (void)
- {
-__asm__ volatile ("vrintn.f32 q0, q0");
-  return 0;
- }
-   } "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"]
-} else {
-   return 0
-}
-}
-
 # Return 1 if this is an ARM target supporting -mfpu=vfp
 # -mfloat-abi=hard.  Some multilibs may be incompatible with these
 # options.
@@ -2226,7 +2210,8 @@ proc add_options_for_arm_v8_neon { flags } {
 if { ! [check_effective_target_arm_v8_neon_ok] } {
 return "$flags"
 }
-return "$flags -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=softfp"
+global et_arm_v8_neon_flags
+return "$flags $et_arm_v8_neon_flags"
 }
 
 # Add the options needed for NEON.  We need either -mfloat-abi=softfp
@@ -2270,6 +2255,38 @@ proc check_effective_target_arm_neon_ok { } {
check_effective_target_arm_neon_ok_nocache]
 }
 
+# Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
+# -mfloat-abi=softfp or equivalent options.  Some multilibs may be
+# incompatible with these options.  Also set et_arm_v8_neon_flags to the
+# best options to add.
+
+proc check_effective_target_arm_v8_neon_ok_nocache { } {
+global et_arm_v8_neon_flags
+set et_arm_v8_neon_flags ""
+if { [check_effective_target_arm32] } {
+   foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" 
"-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
+   if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
+   #include "arm_neon.h"
+   void
+   foo ()
+   {
+

[PATCH] Properly make loops from tail-recursion appear

2013-02-07 Thread Richard Biener

This fixes fallout from the loops-exist verifier.  And it optimizes
compile-time of IPA pure-const.

Not yet tested in any way (but quite obvious).

Richard.

2013-02-07  Richard Biener  

* Makefile.in (tree-tailcall.o): Add $(CFGLOOP_H) dependency.
* ipa-pure-const.c (analyze_function): Avoid calling
mark_irreducible_loops twice.
* tree-tailcall.c (tree_optimize_tail_calls_1): Mark loops
for fixup.

Index: gcc/Makefile.in
===
*** gcc/Makefile.in (revision 195851)
--- gcc/Makefile.in (working copy)
*** tree-tailcall.o : tree-tailcall.c $(TREE
*** 2391,2397 
 $(TREE_H) $(TM_P_H) $(FUNCTION_H) $(TM_H) coretypes.h \
 $(EXCEPT_H) $(TREE_PASS_H) $(FLAGS_H) langhooks.h \
 $(BASIC_BLOCK_H) $(DBGCNT_H) $(GIMPLE_PRETTY_PRINT_H) $(TARGET_H) \
!$(COMMON_TARGET_H)
  tree-ssa-sink.o : tree-ssa-sink.c $(TREE_FLOW_H) $(CONFIG_H) \
 $(SYSTEM_H) $(TREE_H) $(DIAGNOSTIC_H) \
 $(TM_H) coretypes.h $(TREE_PASS_H) $(FLAGS_H) alloc-pool.h \
--- 2391,2397 
 $(TREE_H) $(TM_P_H) $(FUNCTION_H) $(TM_H) coretypes.h \
 $(EXCEPT_H) $(TREE_PASS_H) $(FLAGS_H) langhooks.h \
 $(BASIC_BLOCK_H) $(DBGCNT_H) $(GIMPLE_PRETTY_PRINT_H) $(TARGET_H) \
!$(COMMON_TARGET_H) $(CFGLOOP_H)
  tree-ssa-sink.o : tree-ssa-sink.c $(TREE_FLOW_H) $(CONFIG_H) \
 $(SYSTEM_H) $(TREE_H) $(DIAGNOSTIC_H) \
 $(TM_H) coretypes.h $(TREE_PASS_H) $(FLAGS_H) alloc-pool.h \
Index: gcc/ipa-pure-const.c
===
*** gcc/ipa-pure-const.c(revision 195851)
--- gcc/ipa-pure-const.c(working copy)
*** end:
*** 779,786 
  {
  /* Preheaders are needed for SCEV to work.
 Simple latches and recorded exits improve chances that loop will
!proved to be finite in testcases such as in loop-15.c and 
loop-24.c  */
! loop_optimizer_init (LOOPS_NORMAL
   | LOOPS_HAVE_RECORDED_EXITS);
  if (dump_file && (dump_flags & TDF_DETAILS))
flow_loops_dump (dump_file, NULL, 0);
--- 779,788 
  {
  /* Preheaders are needed for SCEV to work.
 Simple latches and recorded exits improve chances that loop will
!proved to be finite in testcases such as in loop-15.c
!and loop-24.c  */
! loop_optimizer_init (LOOPS_HAVE_PREHEADERS
!  | LOOPS_HAVE_SIMPLE_LATCHES
   | LOOPS_HAVE_RECORDED_EXITS);
  if (dump_file && (dump_flags & TDF_DETAILS))
flow_loops_dump (dump_file, NULL, 0);
*** end:
*** 799,805 
if (!finite_loop_p (loop))
  {
if (dump_file)
! fprintf (dump_file, "can not prove finiteness of loop 
%i\n", loop->num);
l->looping =true;
FOR_EACH_LOOP_BREAK (li);
  }
--- 801,808 
if (!finite_loop_p (loop))
  {
if (dump_file)
! fprintf (dump_file, "can not prove finiteness of "
!  "loop %i\n", loop->num);
l->looping =true;
FOR_EACH_LOOP_BREAK (li);
  }
Index: gcc/tree-tailcall.c
===
*** gcc/tree-tailcall.c (revision 195851)
--- gcc/tree-tailcall.c (working copy)
*** along with GCC; see the file COPYING3.
*** 33,38 
--- 33,39 
  #include "langhooks.h"
  #include "dbgcnt.h"
  #include "target.h"
+ #include "cfgloop.h"
  #include "common/common-target.h"
  
  /* The file implements the tail recursion elimination.  It is also used to
*** tree_optimize_tail_calls_1 (bool opt_tai
*** 1011,1017 
  }
  
if (changed)
! free_dominance_info (CDI_DOMINATORS);
  
/* Add phi nodes for the virtual operands defined in the function to the
   header of the loop created by tail recursion elimination.  Do so
--- 1012,1023 
  }
  
if (changed)
! {
!   /* We may have created new loops.  Make them magically appear.  */
!   if (current_loops)
!   loops_state_set (LOOPS_NEED_FIXUP);
!   free_dominance_info (CDI_DOMINATORS);
! }
  
/* Add phi nodes for the virtual operands defined in the function to the
   header of the loop created by tail recursion elimination.  Do so


Re: [PATCH, bootstrap]: Fix PR56227, bootstrap failure on MinGW.

2013-02-07 Thread Kai Tietz
2013/2/7 Uros Bizjak :
> Hello!
>
> Attached (trivial) patch substitutes a bunch of "ll" conversion types
> with HOST_LONG_LONG_FORMAT defines. Additionally, it fixes wrong usage
> of HOST_WIDE_INT_PRINT_HEX_PURE in the argument of internal_error.
>
> The patch reportedly fixes bootstrap failures on i686-pc-mingw32.
>
> 2013-02-07  Uros Bizjak  
>
> * ggc-page.c (ggc_print_statistics): Use HOST_LONG_LONG_FORMAT
> instead of "ll".
> * config/i386/i386.c (ix86_print_operand): Ditto.
>
> lto/ChangeLog:
>
> 2013-02-07  Uros Bizjak  
>
> * lto.c (lto_resolution_ready): Use %wx instead of
> HOST_WIDE_INT_PRINT_HEX_PURE in the argument to internal_error.
>
> Bootstrapped on x86_64-pc-linux-gnu.
>
> OK for mainline and 4.7 branch?
>
> Uros.

I have no objections.

Thanks,
Kai


Re: [PATCH] Make IRA use current_loops and loop_optimizer_init

2013-02-07 Thread Vladimir Makarov

On 02/07/2013 09:56 AM, Richard Biener wrote:

The following gets rid of ira_loops (ok, without touching all uses
yet but with a #define - I'll finish this if you are ok with it
in general).

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Ok for trunk for the IRA parts?  (well, given I search & replace
uses of ira_loops)



IRA parts are ok for me.  Thanks, Richard.



[PATCH] Make IRA use current_loops and loop_optimizer_init

2013-02-07 Thread Richard Biener

The following gets rid of ira_loops (ok, without touching all uses
yet but with a #define - I'll finish this if you are ok with it
in general).

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Ok for trunk for the IRA parts?  (well, given I search & replace
uses of ira_loops)

Thanks,
Richard.

2013-02-07  Richard Biener  

* cfgloop.c (verify_loop_structure): Properly handle
a loop exiting to another loop header.
* ira-int.h (ira_loops): Remove.
* ira.c (ira_loops): Remove.
(ira): Use loop_optimizer_init and loop_optimizer_finalize.
(do_reload): Use loop_optimizer_finalize.

Index: gcc/cfgloop.c
===
*** gcc/cfgloop.c   (revision 195846)
--- gcc/cfgloop.c   (working copy)
*** verify_loop_structure (void)
*** 1542,1548 
eloops++;
  
  for (loop = bb->loop_father;
!  loop != e->dest->loop_father;
   loop = loop_outer (loop))
{
  eloops--;
--- 1542,1553 
eloops++;
  
  for (loop = bb->loop_father;
!  loop != e->dest->loop_father
!  /* When a loop exit is also an entry edge which
! can happen when avoiding CFG manipulations
! then the last loop exited is the outer loop
! of the loop entered.  */
!  && loop != loop_outer (e->dest->loop_father);
   loop = loop_outer (loop))
{
  eloops--;
Index: gcc/ira-int.h
===
*** gcc/ira-int.h   (revision 195846)
--- gcc/ira-int.h   (working copy)
*** along with GCC; see the file COPYING3.
*** 48,54 
 ? (freq * REG_FREQ_MAX / BB_FREQ_MAX) : 1)
  
  /* All natural loops.  */
! extern struct loops ira_loops;
  
  /* A modified value of flag `-fira-verbose' used internally.  */
  extern int internal_flag_ira_verbose;
--- 48,54 
 ? (freq * REG_FREQ_MAX / BB_FREQ_MAX) : 1)
  
  /* All natural loops.  */
! #define ira_loops (*current_loops)
  
  /* A modified value of flag `-fira-verbose' used internally.  */
  extern int internal_flag_ira_verbose;
Index: gcc/ira.c
===
*** gcc/ira.c   (revision 195846)
--- gcc/ira.c   (working copy)
*** allocate_initial_values (void)
*** 4338,4346 
 function.  */
  bool ira_use_lra_p;
  
- /* All natural loops.  */
- struct loops ira_loops;
- 
  /* True if we have allocno conflicts.  It is false for non-optimized
 mode or when the conflict table is too big.  */
  bool ira_conflicts_p;
--- 4338,4343 
*** ira (FILE *f)
*** 4464,4474 
  
ira_assert (current_loops == NULL);
if (flag_ira_region == IRA_REGION_ALL || flag_ira_region == 
IRA_REGION_MIXED)
! {
!   flow_loops_find (&ira_loops);
!   current_loops = &ira_loops;
!   record_loop_exits ();
! }
  
if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
  fprintf (ira_dump_file, "Building IRA IR\n");
--- 4461,4467 
  
ira_assert (current_loops == NULL);
if (flag_ira_region == IRA_REGION_ALL || flag_ira_region == 
IRA_REGION_MIXED)
! loop_optimizer_init (AVOID_CFG_MODIFICATIONS | LOOPS_HAVE_RECORDED_EXITS);
  
if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
  fprintf (ira_dump_file, "Building IRA IR\n");
*** ira (FILE *f)
*** 4526,4536 
  /* ??? Rebuild the loop tree, but why?  Does the loop tree
 change if new insns were generated?  Can that be handled
 by updating the loop tree incrementally?  */
! release_recorded_exits ();
! flow_loops_free (&ira_loops);
! flow_loops_find (&ira_loops);
! current_loops = &ira_loops;
! record_loop_exits ();
  
  if (! ira_use_lra_p)
{
--- 4519,4527 
  /* ??? Rebuild the loop tree, but why?  Does the loop tree
 change if new insns were generated?  Can that be handled
 by updating the loop tree incrementally?  */
! loop_optimizer_finalize ();
! loop_optimizer_init (AVOID_CFG_MODIFICATIONS
!  | LOOPS_HAVE_RECORDED_EXITS);
  
  if (! ira_use_lra_p)
{
*** do_reload (void)
*** 4607,4614 
  {
if (current_loops != NULL)
{
! release_recorded_exits ();
! flow_loops_free (&ira_loops);
  free_dominance_info (CDI_DOMINATORS);
}
FOR_ALL_BB (bb)
--- 4598,4604 
  {
if (current_loops != NULL)
{
! loop_optimizer_finalize ();
  free_dominance_info (CDI_DOMINATORS);
}
FOR_ALL_BB (bb)
*** do_reload (void)
*** 4657,4664 
ira_dest

Re: Patch ping

2013-02-07 Thread Jeff Law

On 02/07/2013 01:24 AM, Jakub Jelinek wrote:

Hi!

- http://gcc.gnu.org/ml/gcc-patches/2013-01/msg01477.html
   PR56154
   fix invalid .debug_loc entries if an empty range is emitted
   at .Ltext0 symbol

This is good.  Please install.

jeff


Re: [PATCH, PR56193] - Wrong test operator for basic_ios in C++11

2013-02-07 Thread Ed Smith-Rowland

On 02/07/2013 04:18 AM, Jonathan Wakely wrote:

On 7 February 2013 03:05, Ed Smith-Rowland wrote:

greetings,

On SO someone noticed that g++ still has in the basic_ios class
   operator void*();
instead of
   explicit operator bool() const;
The old C++98 operator allows things like
   std::cout << std::cout;

This patch changes the stream test operator for C++11 and onwards.

This patch builds and tests clean on x86_64-unknown-linux.

Please use -std=gnu++11 in the test's dg-options and CC the
gcc-patches list too.
OK for trunk with that change, thanks.


Attached patch applied.

2013-02-06  Edward Smith-Rowland  <3dw...@verizon.net>

* include/bits/basic_ios.h: Replace operator void*() const
with explicit operator bool() const in C++11 and greater.
* testsuite/27_io/basic_ios/pr56193.cc: New file.

Index: include/bits/basic_ios.h
===
--- include/bits/basic_ios.h(revision 195747)
+++ include/bits/basic_ios.h(working copy)
@@ -112,8 +112,13 @@
*  This allows you to write constructs such as
*  if (!a_stream) ... and while (a_stream) ...
   */
+#if __cplusplus >= 201103L
+  explicit operator bool() const
+  { return !this->fail(); }
+#else
   operator void*() const
   { return this->fail() ? 0 : const_cast(this); }
+#endif
 
   bool
   operator!() const
Index: testsuite/27_io/basic_ios/pr56193.cc
===
--- testsuite/27_io/basic_ios/pr56193.cc(revision 0)
+++ testsuite/27_io/basic_ios/pr56193.cc(revision 0)
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+// Copyright (C) 2013 Free Software Foundation, Inc.
+
+#include 
+
+// PR libstdc++/56193
+
+int
+test01()
+{
+  std::cout << std::cout; // { dg-error "cannot bind" }
+}
+
+// { dg-error "initializing argument" "" { target *-*-* } 602 }


Re: [PATCH] Multiversioning fixes (PR c++/55742, take 2)

2013-02-07 Thread Jason Merrill

On 02/06/2013 08:39 PM, Sriraman Tallam wrote:

+// Test to check if an error is generated when virtual functions
+// are multiversioned.


This seems like a TODO, rather than something to test for.  I don't see 
any reason why we couldn't support multiversioned virtual functions.



 error_at (DECL_SOURCE_LOCATION (decl),
- "Virtual function versioning not supported\n");
+ "Virtual function multiversioning not supported\n");


And so this should be a sorry rather than an error.

Jason



Re: [PATCH] Check headers in verify_loop_structure

2013-02-07 Thread Richard Biener
On Thu, 7 Feb 2013, Marek Polacek wrote:

> On Thu, Feb 07, 2013 at 10:14:14AM +0100, Richard Biener wrote:
> > I'd say "loop with header %d not in loop tree" here.  Eventually
> > the header detection should be shared with the code in flow_loops_find
> > to avoid divergence.  I'm making changes to the flow_loops_find code
> > at the moment and will look at splitting out that part properly to
> > be re-used by the verifier.
> 
> Ok, thanks.  This version, on top of your PR56181 fix, uses
> bb_loop_header_p then.  Regtested/bootstrapped on x86_64-linux,
> ok for trunk after you commit your patch?
> 
> Maybe I should try bootstrap-O3 on it as well...
> 
> 2013-02-07  Marek Polacek  
> 
>   * cfgloop.c (verify_loop_structure): Add more checking
>   of headers.
> 
> --- gcc/cfgloop.c.mp  2013-02-07 14:07:24.580864372 +0100
> +++ gcc/cfgloop.c 2013-02-07 14:11:42.005604064 +0100
> @@ -1353,6 +1353,21 @@ verify_loop_structure (void)
>   }
>  }
>  
> +  /* Check the headers.  */
> +  FOR_EACH_BB (bb)
> +{
> +  /* Skip BBs in the root tree.  */
> +  if (bb->loop_father == current_loops->tree_root)
> + continue;

You shouldn't need this ... it will miss missing toplevel loops

> +  if (bb_loop_header_p (bb))
> + if (bb->loop_father->header != bb)

  && bb->loop_father->header != bb)

Richard.

> +   {
> + error ("loop with header %d not in loop tree", bb->index);
> + err = 1;
> +   }
> +}
> +
>/* Check get_loop_body.  */
>visited = sbitmap_alloc (last_basic_block);
>bitmap_clear (visited);


Re: [PATCH] Check headers in verify_loop_structure

2013-02-07 Thread Marek Polacek
On Thu, Feb 07, 2013 at 10:14:14AM +0100, Richard Biener wrote:
> I'd say "loop with header %d not in loop tree" here.  Eventually
> the header detection should be shared with the code in flow_loops_find
> to avoid divergence.  I'm making changes to the flow_loops_find code
> at the moment and will look at splitting out that part properly to
> be re-used by the verifier.

Ok, thanks.  This version, on top of your PR56181 fix, uses
bb_loop_header_p then.  Regtested/bootstrapped on x86_64-linux,
ok for trunk after you commit your patch?

Maybe I should try bootstrap-O3 on it as well...

2013-02-07  Marek Polacek  

* cfgloop.c (verify_loop_structure): Add more checking
of headers.

--- gcc/cfgloop.c.mp2013-02-07 14:07:24.580864372 +0100
+++ gcc/cfgloop.c   2013-02-07 14:11:42.005604064 +0100
@@ -1353,6 +1353,21 @@ verify_loop_structure (void)
}
 }
 
+  /* Check the headers.  */
+  FOR_EACH_BB (bb)
+{
+  /* Skip BBs in the root tree.  */
+  if (bb->loop_father == current_loops->tree_root)
+   continue;
+
+  if (bb_loop_header_p (bb))
+   if (bb->loop_father->header != bb)
+ {
+   error ("loop with header %d not in loop tree", bb->index);
+   err = 1;
+ }
+}
+
   /* Check get_loop_body.  */
   visited = sbitmap_alloc (last_basic_block);
   bitmap_clear (visited);

Marek


[PATCH][www] Add loop case to non-bugs in bugs.html

2013-02-07 Thread Richard Biener

As promised, a bugs.html entry.

Ok?

Thanks,
Richard.

2013-02-07  Richard Biener  

* bugs/index.html: Add "Loops do not terminate" case to non-bugs.

Index: index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/bugs/index.html,v
retrieving revision 1.109
diff -u -r1.109 index.html
--- index.html  10 Oct 2012 15:52:29 -  1.109
+++ index.html  7 Feb 2013 13:29:39 -
@@ -429,6 +429,32 @@
 article.
 
 
+Loops do not terminate
+This is often caused by out-of-bound array accesses or by signed integer
+overflow which both result in undefined behavior according to the ISO
+C standard.  For example
+
+
+int
+SATD (int* diff, int use_hadamard)
+{
+  int k, satd = 0, m[16], dd, d[16];
+  ...
+for (dd=d[k=0]; k<16; dd=d[++k])
+  satd += (dd < 0 ? -dd : dd);
+
+
+accesses d[16] before the loop is exited with
+the k<16 check.  This causes the compiler to
+optimize away the exit test because the new value of k
+must be in the range [0, 15] according to ISO C.
+
+GCC starting with version 4.8 has a new option
+-fno-aggressive-loop-optimizations that may help here.
+If it does, then this is a clear sign that your code is not conforming
+to ISO C and it is not a GCC bug.
+
+
 Cannot use preprocessor directive in macro arguments.
 Let me guess... you used an older version of GCC to compile code
 that looks something like this:


Re: [RS6000] Fix PR45053

2013-02-07 Thread Alan Modra
On Thu, Feb 07, 2013 at 12:49:03PM +0100, Richard Biener wrote:
> It should be possible to add a -msavres-inline switch, right?

Sure, but doesn't rs6000 have enough options already?

Perhaps the best solution would be to move __do_global_ctors_aux out
of crtend.o for targets that support hidden global symbols, but that
probably isn't appropriate for gcc's current stage of development.
Also, if you're worried about crtbegin.o and crtend.o size, then it
would help to throw away call_frame_dummy, call___do_global_ctors_aux,
and call___do_global_dtors_aux.  Hmm, and we could do that quite
easily by defining CRT_CALL_STATIC_FUNCTION.  Done!  Another 4.9 patch
queued.

-- 
Alan Modra
Australia Development Lab, IBM


Re: [google/main] Generate line tables at -g1 (aka -gmlt)

2013-02-07 Thread Diego Novillo
On Thu, Feb 7, 2013 at 1:34 AM, Cary Coutant  wrote:

> OK for google/main?

OK.


Diego.


[PATCH, bootstrap]: Fix PR56227, bootstrap failure on MinGW.

2013-02-07 Thread Uros Bizjak
Hello!

Attached (trivial) patch substitutes a bunch of "ll" conversion types
with HOST_LONG_LONG_FORMAT defines. Additionally, it fixes wrong usage
of HOST_WIDE_INT_PRINT_HEX_PURE in the argument of internal_error.

The patch reportedly fixes bootstrap failures on i686-pc-mingw32.

2013-02-07  Uros Bizjak  

* ggc-page.c (ggc_print_statistics): Use HOST_LONG_LONG_FORMAT
instead of "ll".
* config/i386/i386.c (ix86_print_operand): Ditto.

lto/ChangeLog:

2013-02-07  Uros Bizjak  

* lto.c (lto_resolution_ready): Use %wx instead of
HOST_WIDE_INT_PRINT_HEX_PURE in the argument to internal_error.

Bootstrapped on x86_64-pc-linux-gnu.

OK for mainline and 4.7 branch?

Uros.
Index: lto/lto.c
===
--- lto/lto.c   (revision 195842)
+++ lto/lto.c   (working copy)
@@ -2225,8 +2225,7 @@ lto_resolution_read (splay_tree file_ids, FILE *re
{
  nd = lto_splay_tree_lookup (file_ids, id);
  if (nd == NULL)
-   internal_error ("resolution sub id " HOST_WIDE_INT_PRINT_HEX_PURE
-   " not in object file", id);
+   internal_error ("resolution sub id %wx not in object file", id);
}
 
   file_data = (struct lto_file_decl_data *)nd->value;
Index: ggc-page.c
===
--- ggc-page.c  (revision 195842)
+++ ggc-page.c  (working copy)
@@ -2170,31 +2170,31 @@ ggc_print_statistics (void)
 {
   fprintf (stderr, "\nTotal allocations and overheads during the 
compilation process\n");
 
-  fprintf (stderr, "Total Overhead:%10lld\n",
+  fprintf (stderr, "Total Overhead:%10" 
HOST_LONG_LONG_FORMAT "d\n",
   G.stats.total_overhead);
-  fprintf (stderr, "Total Allocated:   %10lld\n",
+  fprintf (stderr, "Total Allocated:   %10" 
HOST_LONG_LONG_FORMAT "d\n",
   G.stats.total_allocated);
 
-  fprintf (stderr, "Total Overhead  under  32B:%10lld\n",
+  fprintf (stderr, "Total Overhead  under  32B:%10" 
HOST_LONG_LONG_FORMAT "d\n",
   G.stats.total_overhead_under32);
-  fprintf (stderr, "Total Allocated under  32B:%10lld\n",
+  fprintf (stderr, "Total Allocated under  32B:%10" 
HOST_LONG_LONG_FORMAT "d\n",
   G.stats.total_allocated_under32);
-  fprintf (stderr, "Total Overhead  under  64B:%10lld\n",
+  fprintf (stderr, "Total Overhead  under  64B:%10" 
HOST_LONG_LONG_FORMAT "d\n",
   G.stats.total_overhead_under64);
-  fprintf (stderr, "Total Allocated under  64B:%10lld\n",
+  fprintf (stderr, "Total Allocated under  64B:%10" 
HOST_LONG_LONG_FORMAT "d\n",
   G.stats.total_allocated_under64);
-  fprintf (stderr, "Total Overhead  under 128B:%10lld\n",
+  fprintf (stderr, "Total Overhead  under 128B:%10" 
HOST_LONG_LONG_FORMAT "d\n",
   G.stats.total_overhead_under128);
-  fprintf (stderr, "Total Allocated under 128B:%10lld\n",
+  fprintf (stderr, "Total Allocated under 128B:%10" 
HOST_LONG_LONG_FORMAT "d\n",
   G.stats.total_allocated_under128);
 
   for (i = 0; i < NUM_ORDERS; i++)
if (G.stats.total_allocated_per_order[i])
  {
-   fprintf (stderr, "Total Overhead  page size %7lu: %10lld\n",
+   fprintf (stderr, "Total Overhead  page size %7lu: %10" 
HOST_LONG_LONG_FORMAT "d\n",
 (unsigned long) OBJECT_SIZE (i),
 G.stats.total_overhead_per_order[i]);
-   fprintf (stderr, "Total Allocated page size %7lu: %10lld\n",
+   fprintf (stderr, "Total Allocated page size %7lu: %10" 
HOST_LONG_LONG_FORMAT "d\n",
 (unsigned long) OBJECT_SIZE (i),
 G.stats.total_allocated_per_order[i]);
  }
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 195842)
+++ config/i386/i386.c  (working copy)
@@ -14628,7 +14628,8 @@ ix86_print_operand (FILE *file, rtx x, int code)
putc ('$', file);
   /* Sign extend 32bit SFmode immediate to 8 bytes.  */
   if (code == 'q')
-   fprintf (file, "0x%08llx", (unsigned long long) (int) l);
+   fprintf (file, "0x%08" HOST_LONG_LONG_FORMAT "x",
+(unsigned long long) (int) l);
   else
fprintf (file, "0x%08x", (unsigned int) l);
 }


Re: [RS6000] Fix PR45053

2013-02-07 Thread Richard Biener
On Thu, Feb 7, 2013 at 11:51 AM, Alan Modra  wrote:
> On Thu, Feb 07, 2013 at 10:11:02AM +0100, Richard Biener wrote:
>> On Thu, Feb 7, 2013 at 9:45 AM, Alan Modra  wrote:
>> > I think this one counts as obvious, but I'll ask for permission anyway.
>> > Bootstrapped etc. powerpc-linux.  OK everywhere?
>>
>> Isn't there a way to just disable the out-of-line register save/restore
>> functions?  Adding -O2 looks odd.
>
> There isn't.  See rs6000.c:rs6000_savres_strategy.  I should note too
> that using -O2 (anything but -Os) is only a solution for powerpc ELF.
> powerpc-darwin may not be susceptible to the bug, but if it is then
> some changes will be needed in rs6000_savres_strategy.  AIX doesn't
> have a problem here since it always uses inline gpr saves/restores.
>
> Also, powerpc64 targets using GNU ld or gold don't have a problem with
> crtend.o calling save/restore functions as the linker creates these
> functions.

It should be possible to add a -msavres-inline switch, right?  The other
option would be to have a -Ono-s option that turns -Os into -O2
(optimize == 2 for both) but leaves -O1/-O0 alone (by basically just
setting optimize_size to 0).  Of course I consider that more ugly than
a new switch to explicitely disable non-inline saveres code ;)

Richard.

> --
> Alan Modra
> Australia Development Lab, IBM


[PATCH] Fix PR56181, rewrite fix_loop_structure

2013-02-07 Thread Richard Biener

This rewrites fix_loop_structure to be equivalent to loop
detection from scratch via flow_loops_find with re-using
of existing loop tree entries.

This addresses a few shortcomings of fix_loop_structure. First,
as shown by the testcase in PR56181, fix_loop_structure does
not handle loop nesting changes.  Second, fix_loop_structure
does no attempt to discover new loops (such as when an irreducible
region becomes reducible by a CFG manipulation), nor does it
try to detect when a loop becomes no longer a loop (but it relies
on passes to set loop->header to NULL for this).

The patch changes flow_loops_find to work incrementally on an
existing loop tree so that it can be used by fix_loop_structure
(and we avoid duplicating it).  flow_loops_find after the patch
only assumes that basic-block -> loop association is valid
for loop headers in the loop tree and that there are no dead
loops in the loop tree.  The latter assumption is the reason
that the patch makes fix_loop_structure automatically discover
dead loops (RTL cfg-cleanup removes loops without removing them
on g++.dg/torture/pr54838.C for example).

Loop verification now verifies that there are no "dead" loops
in the loop tree.

With this change in place it would be possible to defer all
loop "fixing" to the point an up-to-date loop tree is required
(thus, to loop_optimizer_init).  The patch doesn't go that far
as doing that reduces the amount of loop checking we can
perform and it would require that all passes touching any
of the loop information (even bb<->loop association for headers)
to properly initialize the loop optimizer.  I'm still considering
this option for 4.9 or for 4.8 if other road-blocks for the
current scheme appear.

Note that a side-effect of this patch is that we no longer
regress in the number of discovered loops as compared to
before preserving of loop structures.  This is especially
true for loops introduced by RTL expansion or loops formed
by formerly irreducible regions.

Another side-effect is that fix_loop_structure now provides
an easy way out for passes to not care about loops.  Which
is probably more bad than good.

Loops incrementally removed / discovered are now reported
in the current dump-file in detailed mode, so it should be
possible to grep for such cases and investigate them
(much as we handle the BB / edge counter mismatches).

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

If there are no comments I plan to install this tomorrow
(double-ICK to the way IRA does not use current_loops).

Thanks,
Richard.

2013-02-07  Richard Biener  

PR middle-end/56181
* cfgloop.h (flow_loops_find): Adjust.
(bb_loop_header_p): Declare.
* cfgloop.c (bb_loop_header_p): New function split out from ...
(flow_loops_find): ... here.  Adjust function signature,
support incremental loop structure update.
(verify_loop_structure): Cleanup.  Verify a loop is a loop.
* cfgloopmanip.c (fix_loop_structure): Move ...
* loop-init.c (fix_loop_structure): ... here.
(apply_loop_flags): Split out from ...
(loop_optimizer_init): ... here.
(fix_loop_structure): Use apply_loop_flags.  Use flow_loops_find
in incremental mode, only remove dead loops here.
* ira.c (ira): Adjust.

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

Index: gcc/cfgloop.h
===
*** gcc/cfgloop.h.orig  2013-02-07 10:14:25.0 +0100
--- gcc/cfgloop.h   2013-02-07 11:19:55.228983431 +0100
*** struct GTY (()) loops {
*** 205,211 
  };
  
  /* Loop recognition.  */
! extern int flow_loops_find (struct loops *);
  extern void disambiguate_loops_with_multiple_latches (void);
  extern void flow_loops_free (struct loops *);
  extern void flow_loops_dump (FILE *,
--- 205,212 
  };
  
  /* Loop recognition.  */
! bool bb_loop_header_p (basic_block);
! extern struct loops *flow_loops_find (struct loops *);
  extern void disambiguate_loops_with_multiple_latches (void);
  extern void flow_loops_free (struct loops *);
  extern void flow_loops_dump (FILE *,
Index: gcc/cfgloop.c
===
*** gcc/cfgloop.c.orig  2013-02-07 10:14:25.0 +0100
--- gcc/cfgloop.c   2013-02-07 11:38:26.168190690 +0100
*** init_loops_structure (struct loops *loop
*** 359,497 
loops->tree_root = root;
  }
  
  /* Find all the natural loops in the function and save in LOOPS structure and
 recalculate loop_father information in basic block structures.
!Return the number of natural loops found.  */
  
! int
  flow_loops_find (struct loops *loops)
  {
!   int b;
!   int num_loops;
!   edge e;
!   sbitmap headers;
!   int *dfs_order;
int *rc_order;
!   basic_block header;
!   basic_block bb;
  
/* Ensure that the dominators are computed.  */
calculate_dominance_info (CDI_DOMINATORS);
  
!   /* Taking c

Re: [Patch, Fortran] PR54339 - Update gfortran.texi's standard refs, status and TS29113 sections

2013-02-07 Thread Tobias Burnus

Now committed as obvious (Rev. 195845).

Tobias

Tobias Burnus wrote:

* ping *
http://gcc.gnu.org/ml/fortran/2013-01/msg00223.html

Tobias Burnus:
As promised: A patch for the "regression" PR54339. I am sure there is 
room for improvement :-)


Everyone: Please feel free to comment on the current documentation, 
http://gcc.gnu.org/onlinedocs/gfortran/ , and on the attached patch.


OK for the trunk?

Tobias







Re: [RS6000] Fix PR45053

2013-02-07 Thread Alan Modra
On Thu, Feb 07, 2013 at 10:11:02AM +0100, Richard Biener wrote:
> On Thu, Feb 7, 2013 at 9:45 AM, Alan Modra  wrote:
> > I think this one counts as obvious, but I'll ask for permission anyway.
> > Bootstrapped etc. powerpc-linux.  OK everywhere?
> 
> Isn't there a way to just disable the out-of-line register save/restore
> functions?  Adding -O2 looks odd.

There isn't.  See rs6000.c:rs6000_savres_strategy.  I should note too
that using -O2 (anything but -Os) is only a solution for powerpc ELF.
powerpc-darwin may not be susceptible to the bug, but if it is then
some changes will be needed in rs6000_savres_strategy.  AIX doesn't
have a problem here since it always uses inline gpr saves/restores.

Also, powerpc64 targets using GNU ld or gold don't have a problem with
crtend.o calling save/restore functions as the linker creates these
functions.

-- 
Alan Modra
Australia Development Lab, IBM


Re: libgo patch committed: Update to current version of Go library

2013-02-07 Thread Uros Bizjak
On Tue, Feb 5, 2013 at 9:00 PM, Ian Lance Taylor  wrote:
> On Thu, Jan 3, 2013 at 1:26 AM, Uros Bizjak  wrote:
>> Hello!
>>
>>> I've committed a patch to upgrade libgo to the current version of the
>>> master Go library.  As usual, this mail message only includes the
>>> changes to files that are specific to gccgo.  Bootstrapped and ran Go
>>> testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.
>>
>> This caused massive testsuite problems on CentOS 5.8 due to missing
>> utimensat.
>
> This should be fixed now.  Please let me know if it is not.

Thanks, I have tested it on CentOS 5.9. However, for some reason, I
got unrelated linker errors that prevents further testing:

=== libgo tests ===

./a.out: error while loading shared libraries:
/home/uros/gcc-build/x86_64-unknown-linux-gnu/libgo/.libs/libgo.so.3:
ELF file OS ABI invalid
FAIL: bufio
../../../gcc-svn/trunk/libgo/testsuite/gotest: line 482:
gotest-timeout: No such file or directory
./a.out: error while loading shared libraries:
/home/uros/gcc-build/x86_64-unknown-linux-gnu/libgo/.libs/libgo.so.3:
ELF file OS ABI invalid
FAIL: bytes
...

where:

$ readelf -h libgo.so.3.0.1
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00
  Class: ELF64
  Data:  2's complement, little endian
  Version:   1 (current)
  OS/ABI:UNIX - Linux
  ABI Version:   0
  Type:  DYN (Shared object file)
  Machine:   Advanced Micro Devices X86-64
  Version:   0x1
  Entry point address:   0x559190
  Start of program headers:  64 (bytes into file)
  Start of section headers:  24466488 (bytes into file)
  Flags: 0x0
  Size of this header:   64 (bytes)
  Size of program headers:   56 (bytes)
  Number of program headers: 6
  Size of section headers:   64 (bytes)
  Number of section headers: 38
  Section header string table index: 35

and

$ readelf -h /lib64/libc-2.5.so
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class: ELF64
  Data:  2's complement, little endian
  Version:   1 (current)
  OS/ABI:UNIX - System V
  ABI Version:   0
  Type:  DYN (Shared object file)
  Machine:   Advanced Micro Devices X86-64
  Version:   0x1
  Entry point address:   0x31c441dac0
  Start of program headers:  64 (bytes into file)
  Start of section headers:  1721392 (bytes into file)
  Flags: 0x0
  Size of this header:   64 (bytes)
  Size of program headers:   56 (bytes)
  Number of program headers: 10
  Size of section headers:   64 (bytes)
  Number of section headers: 77
  Section header string table index: 76

 ld --version
GNU ld (Linux/GNU Binutils) 2.21.52.0.2.20110610
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

I don't know why linker treats "UNIX - Linux" OS/ABI as incompatible...

BTW: The same problem happens with libatomic:

./atomic-compare-exchange-1.exe: error while loading shared libraries:
/home/uros/gcc-build/x86_64-unknown-linux-gnu/./libatomic/.libs/libatomic.so.1:
ELF file OS ABI invalid
FAIL: libatomic.c/atomic-compare-exchange-1.c execution test

Is libatomic library incompatible in some way to libc?

GNU C Library stable release version 2.5, by Roland McGrath et al.
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.1.2 20080704 (Red Hat 4.1.2-52).
Compiled on a Linux 2.6.9 system on 2013-01-08.
Available extensions:
The C stubs add-on version 2.1.2.
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
GNU libio by Per Bothner
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
RT using linux kernel aio
Thread-local storage support included.
For bug reporting instructions, please see:
.

Uros.


[testsuite] Fix g++.dg/debug/dwarf2/thunk1.C (PR debug/53363)

2013-02-07 Thread Rainer Orth
As described in the PR, g++.dg/debug/dwarf2/thunk1.C was failing on
Solaris/x86 (both 32 and 64-bit), as well as 64-bit Linux/i686.  The
following patch implements Jason's suggestions in the PR.

Tested with the appropriate runtest invocations on i386-pc-solaris2.10,
i686-unknown-linux-gnu, and x86_64-unknown-linux-gnu.

Approved by Jason in the PR, installed on mainline.

Rainer


2013-02-04  Rainer Orth  

PR debug/53363
* g++.dg/debug/dwarf2/thunk1.C: Restrict to 32-bit x86.
Add -fno-dwarf2-cfi-asm to dg-options.
Adapt match count.

# HG changeset patch
# Parent cd810edcd772d804921ebe4728ce4fb558bd8cb1
Fix g++.dg/debug/dwarf2/thunk1.C (PR debug/53363)

diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/thunk1.C b/gcc/testsuite/g++.dg/debug/dwarf2/thunk1.C
--- a/gcc/testsuite/g++.dg/debug/dwarf2/thunk1.C
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/thunk1.C
@@ -1,7 +1,7 @@
 // Test that we don't add the x86 PC thunk to .debug_ranges
-// { dg-do compile { target i?86-*-* } }
-// { dg-options "-g -fpic" }
-// { dg-final { scan-assembler-times "LFB3" 1 } }
+// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } }
+// { dg-options "-g -fpic -fno-dwarf2-cfi-asm" }
+// { dg-final { scan-assembler-times "LFB3" 5 } }
 
 template  void f(T t) { }
 

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: Fix inline-1.C and inline-3.C testcases

2013-02-07 Thread Richard Biener
On Thu, 7 Feb 2013, Jakub Jelinek wrote:

> On Tue, Feb 05, 2013 at 04:51:36PM +0100, Jakub Jelinek wrote:
> > On Tue, Feb 05, 2013 at 04:27:15PM +0100, Jan Hubicka wrote:
> > > I managed to get an accidental commit on those two testcases without an 
> > > ChangeLog entry.
> > > I just commit the missing ChangeLog and the following patch that should 
> > > make them pass.
> > > 
> > > just in a case you wonder what are the tests about. I disabled iteration 
> > > on early inliner
> > > that makes it to mis some cases of indirect inlining that are now handled 
> > > by later
> > > inliner. The tree-ssa/inline-?.C testcases tests that early inliner with 
> > > large enough
> > > iteration counts still does the optimization, while ipa/inline-?.C are 
> > > the same
> > > testcases with no iteration and test that late inline picks the 
> > > optimization too.
> > > 
> > > The motivation for the change was early inliner doing funny things on 
> > > non-trivial recursion
> > > especially with early-inlining-insns bumped up.
> > 
> > Doesn't seem to be enough.
> > 
> > gcc/testsuite/g++.dg/ipa/inline-3.C
> > has
> > /* { dg-final { cleanup-tree-dump "inline" } } */
> > while supposedly it should have:
> > /* { dg-final { cleanup-ipa-dump "inline" } } */
> > 
> > Also,
> > gcc/testsuite/gcc.dg/tree-ssa/inline-3.c
> > is now failing, supposedly it should have --param added ?
> 
> Now in a form of patch.  Tested on x86_64-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2013-02-07  Jakub Jelinek  
> 
>   PR tree-optimization/55789
>   * g++.dg/ipa/inline-3.C: Use cleanup-ipa-dump instead of
>   cleanup-tree-dump.
>   * gcc.dg/tree-ssa/inline-3.c: Add
>   --param max-early-inliner-iterations=2 option.
> 
> --- gcc/testsuite/g++.dg/ipa/inline-3.C.jj2013-02-05 12:06:08.0 
> +0100
> +++ gcc/testsuite/g++.dg/ipa/inline-3.C   2013-02-07 10:51:46.619509404 
> +0100
> @@ -26,4 +26,4 @@ int main(int argc, char **argv)
>  
>  /* { dg-final { scan-ipa-dump-times "Considering void inline_me\\(" 1 
> "inline"} } */
>  /* { dg-final { scan-ipa-dump-times "Considering void inline_me_too\\(" 1 
> "inline"} } */
> -/* { dg-final { cleanup-tree-dump "inline" } } */
> +/* { dg-final { cleanup-ipa-dump "inline" } } */
> --- gcc/testsuite/gcc.dg/tree-ssa/inline-3.c.jj   2010-10-07 
> 19:44:57.0 +0200
> +++ gcc/testsuite/gcc.dg/tree-ssa/inline-3.c  2013-02-07 10:51:00.653777552 
> +0100
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options "-O2 -fdump-tree-einline" } */
> +/* { dg-options "-O2 -fdump-tree-einline --param 
> max-early-inliner-iterations=2" } */
>  /* { dg-add-options bind_pic_locally } */
>  
>  extern void inlined ();
> 
> 
>   Jakub
> 
> 

-- 
Richard Biener 
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend


Re: Fix inline-1.C and inline-3.C testcases

2013-02-07 Thread Jakub Jelinek
On Tue, Feb 05, 2013 at 04:51:36PM +0100, Jakub Jelinek wrote:
> On Tue, Feb 05, 2013 at 04:27:15PM +0100, Jan Hubicka wrote:
> > I managed to get an accidental commit on those two testcases without an 
> > ChangeLog entry.
> > I just commit the missing ChangeLog and the following patch that should 
> > make them pass.
> > 
> > just in a case you wonder what are the tests about. I disabled iteration on 
> > early inliner
> > that makes it to mis some cases of indirect inlining that are now handled 
> > by later
> > inliner. The tree-ssa/inline-?.C testcases tests that early inliner with 
> > large enough
> > iteration counts still does the optimization, while ipa/inline-?.C are the 
> > same
> > testcases with no iteration and test that late inline picks the 
> > optimization too.
> > 
> > The motivation for the change was early inliner doing funny things on 
> > non-trivial recursion
> > especially with early-inlining-insns bumped up.
> 
> Doesn't seem to be enough.
> 
> gcc/testsuite/g++.dg/ipa/inline-3.C
> has
> /* { dg-final { cleanup-tree-dump "inline" } } */
> while supposedly it should have:
> /* { dg-final { cleanup-ipa-dump "inline" } } */
> 
> Also,
> gcc/testsuite/gcc.dg/tree-ssa/inline-3.c
> is now failing, supposedly it should have --param added ?

Now in a form of patch.  Tested on x86_64-linux, ok for trunk?

2013-02-07  Jakub Jelinek  

PR tree-optimization/55789
* g++.dg/ipa/inline-3.C: Use cleanup-ipa-dump instead of
cleanup-tree-dump.
* gcc.dg/tree-ssa/inline-3.c: Add
--param max-early-inliner-iterations=2 option.

--- gcc/testsuite/g++.dg/ipa/inline-3.C.jj  2013-02-05 12:06:08.0 
+0100
+++ gcc/testsuite/g++.dg/ipa/inline-3.C 2013-02-07 10:51:46.619509404 +0100
@@ -26,4 +26,4 @@ int main(int argc, char **argv)
 
 /* { dg-final { scan-ipa-dump-times "Considering void inline_me\\(" 1 
"inline"} } */
 /* { dg-final { scan-ipa-dump-times "Considering void inline_me_too\\(" 1 
"inline"} } */
-/* { dg-final { cleanup-tree-dump "inline" } } */
+/* { dg-final { cleanup-ipa-dump "inline" } } */
--- gcc/testsuite/gcc.dg/tree-ssa/inline-3.c.jj 2010-10-07 19:44:57.0 
+0200
+++ gcc/testsuite/gcc.dg/tree-ssa/inline-3.c2013-02-07 10:51:00.653777552 
+0100
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-einline" } */
+/* { dg-options "-O2 -fdump-tree-einline --param 
max-early-inliner-iterations=2" } */
 /* { dg-add-options bind_pic_locally } */
 
 extern void inlined ();


Jakub


Re: [PATCH] Check headers in verify_loop_structure

2013-02-07 Thread Richard Biener
On Wed, 6 Feb 2013, Marek Polacek wrote:

> This patch extends verify_loop_structure by checking that header's
> are really its own headers (this proved as useful in PR56181).
> The bulk of the code is taken from flow_loops_find.
> 
> Bootstrapped on x86_64 linux.  The only fallout now is (for C/C++):
> FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer  (internal compiler 
> error)
> FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer  (test for excess 
> errors)
> FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer -funroll-loops  
> (internal compiler error)
> FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer -funroll-loops  
> (test for excess errors)
> FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer -funroll-all-loops 
> -finline-functions  (internal compiler error)
> FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer -funroll-all-loops 
> -finline-functions  (test for excess errors)
> FAIL: gcc.dg/torture/pr54458.c  -O3 -g  (internal compiler error) 
>  
> FAIL: gcc.dg/torture/pr54458.c  -O3 -g  (test for excess errors)
> 
> which is only because -O3 means -funswitch-loops as well.  What happens
> here is quite interesting situation, we have three analogical loops
> which look like below.  BB7 is marked as IRREDUCIBLE_LOOP.
> 
>   |
>   +---+ |
> |   | |
> |   +---+-+-+
> |   |   6   |
> |   +---+---+
> |   |---|
> |   |  -/   |
> |   +-/-+   |
> |   |   7   |   |
> |   +---+   |
> |/  \   |
> |   /\  |
> |   +--++--+|
> |   |  9   ||   8  ||
> |   +--+---++---+--+|
> |  ||   |
> |  |+---+
> |   +---+
>   |   |   10  |
> |   +---+---+
>   |   |
>   +---+
> 
> Thus, we basically have two headers in a loop.
> So, shall I skip the BB_IRREDUCIBLE_LOOP blocks?  (Although this leads to
> another crash: we get into the same situation in another pass, just
> the BB isn't marked as BB_IRREDUCIBLE_LOOP, so we don't skip it.  Perhaps
> this could be sorted out by just calling mark_irreducible_loops somewhere.)
> 
> Comments?
> 
> 2013-02-06  Marek Polacek  
> 
>   * cfgloop.c (verify_loop_structure): Check that header
>   BBs are really its own headers.
> 
> --- gcc/cfgloop.c.mp  2013-02-06 12:08:01.536918761 +0100
> +++ gcc/cfgloop.c 2013-02-06 18:32:59.957027313 +0100
> @@ -1316,6 +1316,41 @@ verify_loop_structure (void)
>else
>  verify_dominators (CDI_DOMINATORS);
>  
> +  /* Check the loop headers.  */
> +  FOR_EACH_BB (bb)
> +{
> +  edge_iterator ei;
> +
> +  /* If we have an abnormal predecessor, do not consider the
> +  loop (not worth the problems).  */
> +  if (bb_has_abnormal_pred (bb))
> + continue;
> +
> +  if (bb->loop_father == current_loops->tree_root)
> +continue;
> +
> +  FOR_EACH_EDGE (e, ei, bb->preds)
> + {
> +   basic_block latch = e->src;
> +
> +   gcc_assert (!(e->flags & EDGE_ABNORMAL));
> +
> +   /* Look for back edges where a predecessor is dominated
> +  by this block.  A natural loop has a single entry
> +  node (header) that dominates all the nodes in the
> +  loop.  It also has single back edge to the header
> +  from a latch node.  */
> +   if (latch != ENTRY_BLOCK_PTR
> +   && bb != latch
> +   && dominated_by_p (CDI_DOMINATORS, latch, bb))
> + if (bb->loop_father->header != bb)
> +   {
> + error ("header %d is not its own header", bb->index);

I'd say "loop with header %d not in loop tree" here.  Eventually
the header detection should be shared with the code in flow_loops_find
to avoid divergence.  I'm making changes to the flow_loops_find code
at the moment and will look at splitting out that part properly to
be re-used by the verifier.

Richard.

> + err = 1;
> +   }
> + }
> +}
> +
>/* Check sizes.  */
>sizes = XCNEWVEC (unsigned, num);
>sizes[0] = 2;
> 
>   Marek
> 
> 

-- 
Richard Biener 
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend


Re: [RS6000] Fix PR45053

2013-02-07 Thread Richard Biener
On Thu, Feb 7, 2013 at 9:45 AM, Alan Modra  wrote:
> I think this one counts as obvious, but I'll ask for permission anyway.
> Bootstrapped etc. powerpc-linux.  OK everywhere?

Isn't there a way to just disable the out-of-line register save/restore
functions?  Adding -O2 looks odd.

On a related note I see the ppc backend uses optimize_size almost
everywhere instead of optimize_function_for_size_p () or
optimize_insn_for_size_p ().
It seems only the i386 backend was properly transitioned here ...

Richard.

> PR target/45053
> * config/rs6000/t-crtstuff (CRTSTUFF_T_CFLAGS): Add -O2.
>
> Index: libgcc/config/rs6000/t-crtstuff
> ===
> --- libgcc/config/rs6000/t-crtstuff (revision 195839)
> +++ libgcc/config/rs6000/t-crtstuff (working copy)
> @@ -1,3 +1,6 @@
>  # If .sdata is enabled __CTOR_{LIST,END}__ go into .sdata instead of
>  # .ctors.
> -CRTSTUFF_T_CFLAGS = -msdata=none
> +# Do not build crtend.o with -Os as that can result in references to
> +# out-of-line register save/restore functions, which may be unresolved
> +# as crtend.o is linked after libgcc.a.
> +CRTSTUFF_T_CFLAGS = -msdata=none -O2
>
> --
> Alan Modra
> Australia Development Lab, IBM


[RS6000] Fix PR45053

2013-02-07 Thread Alan Modra
I think this one counts as obvious, but I'll ask for permission anyway.
Bootstrapped etc. powerpc-linux.  OK everywhere?

PR target/45053
* config/rs6000/t-crtstuff (CRTSTUFF_T_CFLAGS): Add -O2.

Index: libgcc/config/rs6000/t-crtstuff
===
--- libgcc/config/rs6000/t-crtstuff (revision 195839)
+++ libgcc/config/rs6000/t-crtstuff (working copy)
@@ -1,3 +1,6 @@
 # If .sdata is enabled __CTOR_{LIST,END}__ go into .sdata instead of
 # .ctors.
-CRTSTUFF_T_CFLAGS = -msdata=none
+# Do not build crtend.o with -Os as that can result in references to
+# out-of-line register save/restore functions, which may be unresolved
+# as crtend.o is linked after libgcc.a.
+CRTSTUFF_T_CFLAGS = -msdata=none -O2

-- 
Alan Modra
Australia Development Lab, IBM


Patch ping

2013-02-07 Thread Jakub Jelinek
Hi!

- http://gcc.gnu.org/ml/gcc-patches/2013-01/msg01477.html
  PR56154
  fix invalid .debug_loc entries if an empty range is emitted
  at .Ltext0 symbol

Jakub


[committed] Fix up ppc64 call pattern constraints (PR target/56228)

2013-02-07 Thread Jakub Jelinek
Hi!

As described in the PR, when the ppc64 indirect aix call patterns use
ld insn, we need to use "Y" constraint for the memory operand instead
of "m", otherwise the offset might not be multiple of 4.

Fixed thusly, approved by David in the PR, bootstrapped/regtested
on powerpc-linux and powerpc64-linux, committed to trunk.

2013-02-07  Jakub Jelinek  

PR target/56228
* config/rs6000/rs6000.md (ptrm): New mode attr.
(call_indirect_aix, call_indirect_aix_nor11,
call_value_indirect_aix,
call_value_indirect_aix_nor11): Use  instead of
m in constraints.

* gcc.dg/pr56228.c: New test.

--- gcc/config/rs6000/rs6000.md.jj  2013-02-01 17:52:37.0 +0100
+++ gcc/config/rs6000/rs6000.md 2013-02-06 17:27:07.680250027 +0100
@@ -292,6 +292,9 @@ (define_mode_attr mptrsize [(SI "si")
 (define_mode_attr ptrload [(SI "lwz")
   (DI "ld")])
 
+(define_mode_attr ptrm [(SI "m")
+   (DI "Y")])
+
 (define_mode_attr rreg [(SF   "f")
(DF   "ws")
(V4SF "wf")
@@ -10662,8 +10665,8 @@ (define_insn "*call_value_local64"
 (define_insn "call_indirect_aix"
   [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
 (match_operand 1 "" "g,g"))
-   (use (match_operand:P 2 "memory_operand" "m,m"))
-   (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "m,m"))
+   (use (match_operand:P 2 "memory_operand" ","))
+   (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" 
","))
(use (reg:P STATIC_CHAIN_REGNUM))
(clobber (reg:P LR_REGNO))]
   "DEFAULT_ABI == ABI_AIX && TARGET_POINTERS_TO_NESTED_FUNCTIONS"
@@ -10680,8 +10683,8 @@ (define_insn "call_indirect_aix
 (define_insn "call_indirect_aix_nor11"
   [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
 (match_operand 1 "" "g,g"))
-   (use (match_operand:P 2 "memory_operand" "m,m"))
-   (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "m,m"))
+   (use (match_operand:P 2 "memory_operand" ","))
+   (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" 
","))
(clobber (reg:P LR_REGNO))]
   "DEFAULT_ABI == ABI_AIX && !TARGET_POINTERS_TO_NESTED_FUNCTIONS"
   " 2,%2\;b%T0l\; 2,%3"
@@ -10698,8 +10701,8 @@ (define_insn "call_value_indirect_aix,"))
+   (set (reg:P TOC_REGNUM) (match_operand:P 4 "memory_operand" 
","))
(use (reg:P STATIC_CHAIN_REGNUM))
(clobber (reg:P LR_REGNO))]
   "DEFAULT_ABI == ABI_AIX && TARGET_POINTERS_TO_NESTED_FUNCTIONS"
@@ -10718,8 +10721,8 @@ (define_insn "call_value_indirect_aix,"))
+   (set (reg:P TOC_REGNUM) (match_operand:P 4 "memory_operand" 
","))
(clobber (reg:P LR_REGNO))]
   "DEFAULT_ABI == ABI_AIX && !TARGET_POINTERS_TO_NESTED_FUNCTIONS"
   " 2,%3\;b%T1l\; 2,%4"
--- gcc/testsuite/gcc.dg/pr56228.c.jj   2013-02-06 17:44:33.409303617 +0100
+++ gcc/testsuite/gcc.dg/pr56228.c  2013-02-06 17:44:14.0 +0100
@@ -0,0 +1,16 @@
+/* PR target/56228 */
+/* { dg-do assemble } */
+/* { dg-options "-O2" } */
+
+short a[14] = { 1, 2 };
+short b[15] = { 3, 4 };
+
+int
+foo ()
+{
+  void (*fna) (void) = (void (*) (void)) a;
+  void (*fnb) (void) = (void (*) (void)) b;
+  fna ();
+  fnb ();
+  return a[1] == b[1];
+}

Jakub