Re: [Patch,AVR]: Fix PR50447

2011-09-23 Thread Paolo Bonzini

On 09/22/2011 07:43 PM, Georg-Johann Lay wrote:

This patch adds the PLUS part to fix the PR.

addsi3 has a 8-bit scratch register now so that constants that are not covered
by the constraints won't force a reload of the constant.

The output routine tries adding the constant and subtracting the negated
constant and then chooses the shortest sequence.  Moreover, if the lower bytes
of the constant are zero, there is no need to add them.

Besides that, the patch adds some add-and-zero-extend patterns.

Passed without regressions.

Ok to commit?


The same can be done for cmp, no?

Paolo


Re: Ping: [libiberty patch] Add demangler support for cloned function symbols (PR 40831)

2011-09-23 Thread Jakub Jelinek
On Thu, Sep 22, 2011 at 05:40:15PM -0700, Cary Coutant wrote:
> > Ping?
> >
> > http://gcc.gnu.org/ml/gcc-patches/2011-08/msg01626.html

It looks good to me, but I'd prefer if Ian with his demangler author
and libiberty maintainer hats looked at it too.

> > include/ChangeLog:
> >
> >        PR 40831
> >        * demangle.h (enum demangle_component_type): Add
> >        DEMANGLE_COMPONENT_CLONE.
> >
> > libiberty/ChangeLog:
> >
> >        PR 40831
> >        * cp-demangle.c (d_make_comp): Add new component type.
> >        (cplus_demangle_mangled_name): Check for clone suffixes.
> >        (d_parmlist): Don't error out if we see '.'.
> >        (d_clone_suffix): New function.
> >        (d_print_comp): Print info for clone suffixes.
> >        * testsuite/demangle-expected: Add new testcases.

Maybe the testcase should test also
_Z2f1IiEvT_S0_S0_._omp_fn.2
_Z3fooi._omp_cpyfn.6
as examples of OpenMP suffixing - the former is an example of name
used for outlined #pragma omp {parallel,task} region from a function
and the latter is for copy constructors needed for #pragma omp task.

Jakub


Re: [Patch] PR c++/26256

2011-09-23 Thread Fabien Chêne
2011/9/23 Jason Merrill :
> On 09/22/2011 05:11 PM, Fabien Chêne wrote:
>>
>> 2011/9/22 Jason Merrill:
>
>>> I don't, it just seemed strange to handle functions differently from
>>> other
>>> decls here.  But when I look more closely I see that we're in
>>> lookup_field_1, which isn't interested in functions, so I guess we do
>>> want
>>> to ignore function using-declarations here.
>>
>> That's strange because if we do return FUNCTION_DECL, PR c++/30195 seems
>> solved.
>
> It works for that testcase, but we need to handle functions in
> lookup_fnfields_1 since it's also called from other places.

Aha, hence, I'll tackle this issue in another patch, one PR at a time !

>>> But check for is_overloaded_fn rather than just OVERLOAD.  Also, it looks
>>> like the new code doesn't respect want_type.
>>
>> Er, I'm a bit lost, do you mean something like that ?
>>
>> if (TREE_CODE (field) == USING_DECL)
>>        {
>>          tree target_field = strip_using_decl (field);
>>          if (target_field != field)
>>            {
>>              if (DECL_P (target_field)&&  DECL_NAME (target_field) == name
>>                  || (is_overloaded_fn (target_field)
>>                &&  DECL_NAME (get_first_fn (target_field)) == name))
>>                {
>>                  if (!want_type
>>                      || TREE_CODE (target_field) == TYPE_DECL)
>>                    return target_field;
>>                }
>>
>>              continue;
>>            }
>>        }
>
> I was thinking more like
>
> tree decl = field;
> if (TREE_CODE (decl) == USING_DECL)
>  {
>    decl = strip_using_decl (decl);
>    if (is_overloaded_fn (decl)) continue;
>  }
> if (DECL_NAME (decl) == name
>  ...

I should have got it... Thank you anyway.
I will update the patch accordingly at the begining of the next week, I hope.

-- 
Fabien


Re: [PATCH] Ensure vcond* expansion doesn't fail on x86 (PR target/50310)

2011-09-23 Thread Jakub Jelinek
On Fri, Sep 23, 2011 at 12:09:18AM +0200, Uros Bizjak wrote:
> > --- gcc/config/i386/i386.c.jj   2011-09-02 16:29:38.0 +0200
> > +++ gcc/config/i386/i386.c      2011-09-07 21:57:52.0 +0200
> > @@ -18304,6 +18304,11 @@ ix86_prepare_sse_fp_compare_args (rtx de
> >  {
> >   rtx tmp;
> >
> > +  /* AVX supports all the needed comparisons, no need to swap arguments
> > +     nor help reload.  */
> > +  if (TARGET_AVX)
> > +    return code;
> > +
> 
> Unfortunately, this part prevents generation of vmin/vmax instructions
> for TARGET_AVX. In ix86_expand_fp_movcc, we call
> ix86_prepare_sse_fp_compare_args, where we previously converted GT
> into LT. LT is recognized in ix86_expand_sse_fp_minmax as valid
> operand for MIN/MAX, whereas GT is not.
> 
> I'm not sure if we can swap operands in ix86_expand_sse_fp_minmax,
> there is a scary comment  in front of ix86_expand_sse_fp_minmax w.r.t.
> to IEEE safety.

swap_condition is documented to be IEEE safe:
/* Similar, but return the code when two operands of a comparison are swapped.
   This IS safe for IEEE floating-point.  */

So, do you prefer this?

2011-09-23  Jakub Jelinek  

* config/i386/i386.c (ix86_prepare_sse_fp_compare_args): For
GE/GT/UNLE/UNLT swap arguments and condition even for TARGET_AVX.

* gcc.target/i386/avxfp-1.c: New test.
* gcc.target/i386/avxfp-2.c: New test.

--- gcc/config/i386/i386.c.jj   2011-09-22 18:55:45.0 +0200
+++ gcc/config/i386/i386.c  2011-09-23 10:04:35.0 +0200
@@ -18739,15 +18739,13 @@ ix86_prepare_sse_fp_compare_args (rtx de
 {
   rtx tmp;
 
-  /* AVX supports all the needed comparisons, no need to swap arguments
- nor help reload.  */
-  if (TARGET_AVX)
-return code;
-
   switch (code)
 {
 case LTGT:
 case UNEQ:
+  /* AVX supports all the needed comparisons.  */
+  if (TARGET_AVX)
+   break;
   /* We have no LTGT as an operator.  We could implement it with
 NE & ORDERED, but this requires an extra temporary.  It's
 not clear that it's worth it.  */
@@ -18764,6 +18762,9 @@ ix86_prepare_sse_fp_compare_args (rtx de
 case NE:
 case UNORDERED:
 case ORDERED:
+  /* AVX has 3 operand comparisons, no need to swap anything.  */
+  if (TARGET_AVX)
+   break;
   /* For commutative operators, try to canonicalize the destination
 operand to be first in the comparison - this helps reload to
 avoid extra moves.  */
@@ -18775,8 +18776,10 @@ ix86_prepare_sse_fp_compare_args (rtx de
 case GT:
 case UNLE:
 case UNLT:
-  /* These are not supported directly.  Swap the comparison operands
-to transform into something that is supported.  */
+  /* These are not supported directly before AVX, and furthermore
+ix86_expand_sse_fp_minmax only optimizes LT/UNGE.  Swap the
+comparison operands to transform into something that is
+supported.  */
   tmp = *pop0;
   *pop0 = *pop1;
   *pop1 = tmp;
--- gcc/testsuite/gcc.target/i386/avxfp-1.c.jj  2011-09-23 10:07:48.0 
+0200
+++ gcc/testsuite/gcc.target/i386/avxfp-1.c 2011-09-23 10:08:02.0 
+0200
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx -mfpmath=sse" } */
+/* { dg-final { scan-assembler "vmaxsd" } } */
+/* { dg-final { scan-assembler "vminsd" } } */
+double x;
+t()
+{
+  x=x>5?x:5;
+}
+
+double x;
+q()
+{
+  x=x<5?x:5;
+}
--- gcc/testsuite/gcc.target/i386/avxfp-2.c.jj  2011-09-23 10:07:51.0 
+0200
+++ gcc/testsuite/gcc.target/i386/avxfp-2.c 2011-09-23 10:08:17.0 
+0200
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx -mfpmath=sse" } */
+/* { dg-final { scan-assembler "vmaxsd" } } */
+/* { dg-final { scan-assembler "vminsd" } } */
+double x;
+q()
+{
+  x=x<5?5:x;
+}
+
+double x;
+q1()
+{
+  x=x>5?5:x;
+}

Jakub


Re: [PATCH] Make the pass of 941014-1.c as a normal pass.

2011-09-23 Thread Richard Earnshaw
On 20/09/11 02:52, Terry Guo wrote:
> Hello,
> 
> This is an old case written in 1997. Perhaps it intends to cover an old gcc
> bug. In fact the case itself passed on QEMU for cortex-m3. So I am proposing
> a patch here to remove the test script to make this pass as a normal pass.
> Otherwise the pass is regarded as XPASS. Is it ok to trunk?
> 
> BR,
> Terry
> 
> 2011-09-20  Terry Guo  
> 
> * gcc.c-torture/execute/941014-1.x: Deleted.
> 

OK.

R.

> 
> diff --git a/gcc/testsuite/gcc.c-torture/execute/941014-1.x
> b/gcc/testsuite/gcc.c-torture/execute/941014-1.x
> deleted file mode 100644
> index bbe060e..000
> --- a/gcc/testsuite/gcc.c-torture/execute/941014-1.x
> +++ /dev/null
> @@ -1,15 +0,0 @@
> -# This doesn't always work for Thumb.
> - 
> -if { [istarget arm*-*-*] } {
> -set torture_eval_before_execute {
> -   global compiler_conditional_xfail_data
> -   set compiler_conditional_xfail_data {
> -   "Thumb sets the last bit of function relocations" \
> -   { "arm*-*-*" } \
> -   { { "-mthumb" "-O0" } } \
> -   { "" }
> -   }
> -}
> -}
> -
> -return 0
> 
> 
> 
> 
> 




Re: [Patch,AVR]: Fix PR50447

2011-09-23 Thread Georg-Johann Lay
Denis Chertykov schrieb:
> 2011/9/22 Georg-Johann Lay :
>> This patch adds the PLUS part to fix the PR.
>>
>> addsi3 has a 8-bit scratch register now so that constants that are not 
>> covered
>> by the constraints won't force a reload of the constant.
>>
>> The output routine tries adding the constant and subtracting the negated
>> constant and then chooses the shortest sequence.  Moreover, if the lower 
>> bytes
>> of the constant are zero, there is no need to add them.
>>
>> Besides that, the patch adds some add-and-zero-extend patterns.
>>
>> Passed without regressions.
> 
> 
> Why you removed immediate operand from subsi3:
> 
>  (define_insn "subsi3"
> -  [(set (match_operand:SI 0 "register_operand" "=r,d")
> -(minus:SI (match_operand:SI 1 "register_operand" "0,0")
> - (match_operand:SI 2 "nonmemory_operand" "r,i")))]
> +  [(set (match_operand:SI 0 "register_operand"  "=r")
> +(minus:SI (match_operand:SI 1 "register_operand" "0")
> +  (match_operand:SI 2 "register_operand" "r")))]
>""
> -  "@
> - sub %0,%2\;sbc %B0,%B2\;sbc %C0,%C2\;sbc %D0,%D2
> - subi %A0,lo8(%2)\;sbci %B0,hi8(%2)\;sbci %C0,hlo8(%2)\;sbci 
> %D0,hhi8(%2)"
> -  [(set_attr "length" "4,4")
> -   (set_attr "cc" "set_czn,set_czn")])
> +  "sub %0,%2\;sbc %B0,%B2\;sbc %C0,%C2\;sbc %D0,%D2"
> +  [(set_attr "length" "4")
> +   (set_attr "cc" "set_czn")])

A = B - const

is canonizalized to

A = B + (-const)

For compile time constants. And for SImode there are no symbols so that the
immediate part of memory_operand is dead code and I cleaned it up.

> Denis.

Johann




Re: [Patch,AVR]: Fix PR50447 (2/n)

2011-09-23 Thread Georg-Johann Lay
Paolo Bonzini schrieb:
> On 09/22/2011 07:43 PM, Georg-Johann Lay wrote:
>> This patch adds the PLUS part to fix the PR.
>>
>> addsi3 has a 8-bit scratch register now so that constants that are not
>> covered
>> by the constraints won't force a reload of the constant.
>>
>> The output routine tries adding the constant and subtracting the negated
>> constant and then chooses the shortest sequence.  Moreover, if the
>> lower bytes
>> of the constant are zero, there is no need to add them.
>>
>> Besides that, the patch adds some add-and-zero-extend patterns.
>>
>> Passed without regressions.
>>
>> Ok to commit?
> 
> The same can be done for cmp, no?

Yes, can be done for comparisons, too.  I'd prefer a separate patch for it. The
subject is bit misleading; should be (2/n).

> Paolo



Re: [Patch,AVR]: Fix PR50447 (2/n)

2011-09-23 Thread Paolo Bonzini

On 09/23/2011 10:41 AM, Georg-Johann Lay wrote:

Yes, can be done for comparisons, too.  I'd prefer a separate patch for it. The
subject is bit misleading; should be (2/n).


Also, I am curious about one thing: while this is of course a very 
pragmatic solution, you could also convert AVR to get rid of CC0, do 
this at expansion time, and get split-wide-types to work as intended.


compare-elim.c makes it relatively easy to remove CC0 nowadays.

Paolo


Re: [Patch, testsuite, arm] Skip the arch conflict to enable case neon-thumb2-move pass on more targets.

2011-09-23 Thread Richard Earnshaw
On 20/09/11 10:35, Terry Guo wrote:
> Hello,
> 
>>>
>>> I suppose you want a torture that excercises different -march/-mtune
>>> combinations then.
>>>
>>> But can't you do the pruning somewhere in an .exp file then instead
>>> of sprinkling it all over the tests itself?
>>>
>>
>> It seems not.  At present the multilib options are all added
>> automatically by the dejagnu infrastructure.
>>
>> R.
>>
> 
> Thanks for both of you and I did tried to address Richard Guenther's
> comments but I failed. I couldn't figure out a better way to solve such
> cases for the reason like what Richard Earnshaw says. So I will wait for a
> while. Can I assume no objection or no better proposal as OK?
> 
> BR,
> Terry
> 
> 
So not withstanding Richi's comment that there ought to be a better way
to do this, I don't think that should prevent this going in.  It's using
the same method that many other tests use already.

So OK.

R.



Re: [Patch,AVR]: Fix PR50447 (2/n)

2011-09-23 Thread Paolo Bonzini

On 09/23/2011 10:56 AM, Paolo Bonzini wrote:

Also, I am curious about one thing: while this is of course a very
pragmatic solution, you could also convert AVR to get rid of CC0, do
this at expansion time, and get split-wide-types to work as intended.

compare-elim.c makes it relatively easy to remove CC0 nowadays.


For example, a two-byte add can be written as

   (set (reg:QI L1) (plus:QI (reg:QI L2) (reg:QI L3)))
   (set (reg:QI H1) (plus:QI
(plus:QI (req:QI H2) (reg:QI H3))
(ltu:QI  (reg:QI L1) (reg:QI L3

After reload the second instruction can be split to

  (set (reg:CC_C CC) (compare:QI (reg:QI L1) (reg:QI L3)))
  (set (reg:QI   H1) (plus:QI
 (plus:QI(req:QI   H2) (reg:QI H3))
 (lt:QI  (reg:CC_C CC) (const_int 0

(i.e. cp+adc).  compare-elim will then be able to turn this into add+adc:

  [parallel
(set (reg:QI   L1) (plus:QI(reg:QI L2) (reg:QI L3)))
(set (reg:CC_C CC) (compare:QI
   (plus:QI(reg:QI L2) (reg:QI L3))
   (reg:QI L3]
  (set (reg:QI H1) (plus:QI
   (plus:QI (req:QI   H2) (reg:QI H3))
   (lt:QI   (reg:CC_C CC) (const_int 0

Paolo



Re: [ARM] Optimise handling of neon_vget_high/low

2011-09-23 Thread Ramana Radhakrishnan
On 14 September 2011 13:30, Richard Sandiford
 wrote:
> neon_vget_high and neon_vget_low extract one half of a vector.
> The patterns look like:
>
> (define_insn "neon_vget_highv16qi"
>  [(set (match_operand:V8QI 0 "s_register_operand" "=w")
>        (vec_select:V8QI (match_operand:V16QI 1 "s_register_operand" "w")
>                         (parallel [(const_int 8) (const_int 9)
>                                    (const_int 10) (const_int 11)
>                                    (const_int 12) (const_int 13)
>                                    (const_int 14) (const_int 15)])))]
>  "TARGET_NEON"
> {
>  int dest = REGNO (operands[0]);
>  int src = REGNO (operands[1]);
>
>  if (dest != src + 2)
>    return "vmov\t%P0, %f1";
>  else
>    return "";
> }
>  [(set_attr "neon_type" "neon_bp_simple")]
> )
>
> But there's nothing here to tell the register allocator what's expected
> of it, so we do often get the move.  The patch below makes the patterns
> expand to normal subreg moves instead.
>
> Unfortunately, when I first tried this, I ran across some bugs in
> simplify-rtx.c.  They should be fixed now.  Of course, I can't
> guarantee that there are other similar bugs elsewhere, but I'll
> try to fix any that crop up.
>
> The new patterns preserve the current treatment on big-endian targets.
> Namely, the "low" half is always in the lower-numbered registers
> (subreg byte offset 0).
>
> Tested on arm-linux-gnueabi.  OK to install?


This is OK . Please watch out for any fallout that comes as a result
of this . It would be useful to do some big endian testing at some
point but I'm not going to let that hold up this patch.

While you are here can you look at the quad_halves_v4si etc.
patterns neon_move_lo_quad_ and neon_move_hi_quad_
patterns which seem to have the same problem ? And then I remembered
this ancient FIXME:

> ; FIXME: We wouldn't need the following insns if we could write subregs of
> ; vector registers. Make an attempt at removing unnecessary moves, though
> ; we're really at the mercy of the register allocator.
>


But that can be a follow-up patch.

And it's nice to be able to remove such FIXME's :)


cheers
Ramana


Re: [build] Move gthr to toplevel libgcc

2011-09-23 Thread Rainer Orth
Rainer Orth  writes:

> John David Anglin  writes:
>
>>> I could find no indication that HP-UX 10 supported anything but DCE
>>> threads (especially no POSIX threads), so _REENTRANT being defined must
>>> meant DCE threads, unless I'm mistaken.
>>
>> _REENTRANT doesn't imply DCE threads.  The reentrant routines were added
>> to the non threaded version of libc in HP-UX 10 in preparation for the
>> transition
>> to POSIX threads in HP-UX 11.  We define _REENTRANT under other
>> circumstances in pa-hpux10.h as the reentrant routines are needed for
>> libgfortran,
>> etc.
>
> One could argue that it's the responsibility of libgfortran to do so if
> necessary, though.
>
> But ok, I'll restore the definition and use of _DCE_THREADS in
> pa-hpux10.h and gthr-dce.h.

Here's the updated patch with that change.  I haven't yet rebased it
to current mainline (will do so for the whole patch series over the
weekend), and it still requires the previous libgcc patches to apply
cleanly.

Rainer


2011-08-06  Rainer Orth  

gcc:
* gthr-posix.h, gthr-single.h, gthr.h: Move to ../libgcc.
* gthr-aix.h: Move to ../libgcc/config/rs6000.
* gthr-dce.h: Move to ../libgcc/config/pa.
* gthr-lynx.h: Move to ../libgcc/config.
* gthr-mipssde.h: Move to ../libgcc/config/mips.
* gthr-rtems.h: Move to ../libgcc/config.
* gthr-tpf.h: Move to ../libgcc/config/s390.
* gthr-vxworks.h: Move to ../libgcc/config.
* gthr-win32.h: Move to ../libgcc/config/i386.
* configure.ac (gthread_flags): Remove
(gthr-default.h): Don't create.
(thread_file): Don't substitute.
* configure: Regenerate.
* Makefile.in (GCC_THREAD_FILE): Remove.
(GTHREAD_FLAGS): Remove.
(libgcc.mvars): Remove GTHREAD_FLAGS.
* config/m32r/linux.h (SUBTARGET_CPP_SPEC): Don't define _PTHREADS
if -pthread.
* config/mn10300/linux.h (CPP_SPEC): Likewise.
* config/netbsd.h (NETBSD_CPP_SPEC): Likewise.
* config/sh/linux.h (SUBTARGET_CPP_SPEC): Likewise.
* config/sol2.h (CPP_SUBTARGET_SPEC): Likewise.
* config/t-vxworks (EXTRA_HEADERS): Remove.

gcc/po:
* EXCLUDES (gthr-aix.h, gthr-dce.h, gthr-posix.c, gthr-posix.h)
(gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h)
(gthr-win32.h, gthr.h): Remove.

libgcc:
* gthr-posix.h, gthr-single.h, gthr.h: New files.
* config/gthr-lynx.h, config/gthr-rtems.h, config/gthr-vxworks.h,
config/i386/gthr-win32.h, config/mips/gthr-mipssde.h,
config/pa/gthr-dce.h, config/rs6000/gthr-aix.h,
config/s390/gthr-tpf.h: New files.
* config/i386/gthr-win32.c: Include "gthr-win32.h".
* config.host (thread_header, thread_dir): New variables.
Set it depending on target_thread_file.
* configure.ac (gthr-default.h): Link from $thread_header.
* configure: Regenerate.
* Makefile.in (LIBGCC2_CFLAGS): Remove $(GTHREAD_FLAGS).

libgfortran:
* Makefile.am (AM_CPPFLAGS): Add
-I$(srcdir)/$(MULTISRCTOP)../libgcc, -I$(MULTIBUILDTOP)../libgcc.
* Makefile.in: Regenerate.
* acinclude.m4 (LIBGFOR_CHECK_GTHR_DEFAULT): Remove.
* configure.ac (LIBGFOR_CHECK_GTHR_DEFAULT): Likewise.
* configure: Regenerate.
* config.h.in: Regenerate.

libobjc:
* Makefile.in (INCLUDES): Add -I$(MULTIBUILDTOP)../libgcc.
* configure.ac (target_thread_file, HAVE_GTHR_DEFAULT): Remove.
* configure: Regenerate.
* config.h.in: Regenerate.

libstdc++-v3:
* acinclude.m4 (GLIBCXX_CONFIGURE): Determine and substitute
toplevel_builddir.
(GLIBCXX_ENABLE_THREADS): Remove glibcxx_thread_h,
HAVE_GTHR_DEFAULT, enable_thread.
(GLIBCXX_CHECK_GTHREADS): Reflect gthr move to libgcc.
* include/Makefile.am (thread_host_headers): Remove
${host_builddir}/gthr-tpf.h.
(${host_builddir}/gthr.h): Reflect gthr move to libgcc.
Use $<.
(${host_builddir}/gthr-single.h): Likewise.
(${host_builddir}/gthr-posix.h): Likewise.
(${host_builddir}/gthr-tpf.h): Remove.
(${host_builddir}/gthr-default.h): Likewise.
* configure, config.h.in: Regenerate.
* Makefile.in, doc/Makefile.in, include/Makefile.in,
libsupc++/Makefile.in, po/Makefile.in, python/Makefile.in,
src/Makefile.intestsuite/Makefile.in: Regenerate.

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -529,9 +529,7 @@ lang_opt_files=@lang_opt_files@ $(srcdir
 lang_specs_files=@lang_specs_files@
 lang_tree_files=@lang_tree_files@
 target_cpu_default=@target_cpu_default@
-GCC_THREAD_FILE=@thread_file@
 OBJC_BOEHM_GC=@objc_boehm_gc@
-GTHREAD_FLAGS=@gthread_flags@
 extra_modes_file=@extra_modes_file@
 extra_opt_files=@extra_opt_files@
 host_hook_obj=@out_host_hook_obj@
@@ -18

Re: [Patch,AVR]: Fix PR50447 (2/n)

2011-09-23 Thread Georg-Johann Lay
Paolo Bonzini schrieb:
> On 09/23/2011 10:56 AM, Paolo Bonzini wrote:
>> Also, I am curious about one thing: while this is of course a very
>> pragmatic solution, you could also convert AVR to get rid of CC0, do
>> this at expansion time, and get split-wide-types to work as intended.

My changes are just micro-optimizations to print things in a smarter way.  I
don't know enough of CCmode to do that transition.

>> compare-elim.c makes it relatively easy to remove CC0 nowadays.
> 
> For example, a two-byte add can be written as
> 
>(set (reg:QI L1) (plus:QI (reg:QI L2) (reg:QI L3)))
>(set (reg:QI H1) (plus:QI
> (plus:QI (req:QI H2) (reg:QI H3))
> (ltu:QI  (reg:QI L1) (reg:QI L3
> 
> After reload the second instruction can be split to
> 
>   (set (reg:CC_C CC) (compare:QI (reg:QI L1) (reg:QI L3)))
>   (set (reg:QI   H1) (plus:QI
>  (plus:QI(req:QI   H2) (reg:QI H3))
>  (lt:QI  (reg:CC_C CC) (const_int 0

What happens if L1=L3?  AVR just has two-operand instructions so there are many
insns with "0" constraint.

How goes the LTU -> LT transition?

Ans reloading from memory might change Carry. How is that handled? Read
somewhere about that problem in some PR-chat and that this blocked the cc0 ->
CCmode transition (don't know if that's actually a restriction).

> (i.e. cp+adc).  compare-elim will then be able to turn this into add+adc:
> 
>   [parallel
> (set (reg:QI   L1) (plus:QI(reg:QI L2) (reg:QI L3)))
> (set (reg:CC_C CC) (compare:QI
>(plus:QI(reg:QI L2) (reg:QI L3))
>(reg:QI L3]
>   (set (reg:QI H1) (plus:QI
>(plus:QI (req:QI   H2) (reg:QI H3))
>(lt:QI   (reg:CC_C CC) (const_int 0

What about the other flags like Z (zero) and N (negative)? They are not as
important as Carry but are still usable to avoid comparisons.  Describing all
that explicitly in RTL will be quite tedious...

> Paolo

Johann



Re: [Mingw-users] [patch] --enable-dynamic-string default for mingw-w64

2011-09-23 Thread JonY
On 9/21/2011 17:08, xunxun wrote:
> 于 2011/9/21 10:56, Cesar Strauss 写道:
>> Please let me present an opposing view.
>>
>> On the one hand, according to comment 4 of [1], by using
>> --enable-fully-dynamic-string, all other users will miss a very good
>> optimization. On the other hand, these users of -static-libstdc++ are
>> mixing shared and static libraries, which isn't a good idea in general
>> anyway, is it?
>>
>> [1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196 
> 
> I think we can ask TDM, his release is built with
> "--enable-fully-dynamic-string".
> 
> ( I forgot his Email...  )
> 

Ping, any updates?



signature.asc
Description: OpenPGP digital signature


Re: [build] Move gthr to toplevel libgcc

2011-09-23 Thread Paolo Bonzini

On 09/23/2011 11:23 AM, Rainer Orth wrote:

Rainer Orth  writes:


John David Anglin  writes:


I could find no indication that HP-UX 10 supported anything but DCE
threads (especially no POSIX threads), so _REENTRANT being defined must
meant DCE threads, unless I'm mistaken.


_REENTRANT doesn't imply DCE threads.  The reentrant routines were added
to the non threaded version of libc in HP-UX 10 in preparation for the
transition
to POSIX threads in HP-UX 11.  We define _REENTRANT under other
circumstances in pa-hpux10.h as the reentrant routines are needed for
libgfortran,
etc.


One could argue that it's the responsibility of libgfortran to do so if
necessary, though.

But ok, I'll restore the definition and use of _DCE_THREADS in
pa-hpux10.h and gthr-dce.h.


Here's the updated patch with that change.  I haven't yet rebased it
to current mainline (will do so for the whole patch series over the
weekend), and it still requires the previous libgcc patches to apply
cleanly.

Rainer


Ok with a couple of changes:


gcc:
* gthr-posix.h, gthr-single.h, gthr.h: Move to ../libgcc.


Move gthr-posix.h to config/


   * config/m32r/linux.h (SUBTARGET_CPP_SPEC): Don't define _PTHREADS
   if -pthread.
   * config/mn10300/linux.h (CPP_SPEC): Likewise.
   * config/netbsd.h (NETBSD_CPP_SPEC): Likewise.
   * config/sh/linux.h (SUBTARGET_CPP_SPEC): Likewise.
   * config/sol2.h (CPP_SUBTARGET_SPEC): Likewise.


Don't commit these, not yet at least (well, for Solaris it's your choice).


* config.host (thread_header, thread_dir): New variables.
Set it depending on target_thread_file.


Move to configure.ac, and remove the indirection on thread_dir (i.e. 
just set thread_header).


Paolo



Re: [PATCH] Ensure vcond* expansion doesn't fail on x86 (PR target/50310)

2011-09-23 Thread Uros Bizjak
On Fri, Sep 23, 2011 at 10:12 AM, Jakub Jelinek  wrote:
>> > --- gcc/config/i386/i386.c.jj   2011-09-02 16:29:38.0 +0200
>> > +++ gcc/config/i386/i386.c      2011-09-07 21:57:52.0 +0200
>> > @@ -18304,6 +18304,11 @@ ix86_prepare_sse_fp_compare_args (rtx de
>> >  {
>> >   rtx tmp;
>> >
>> > +  /* AVX supports all the needed comparisons, no need to swap arguments
>> > +     nor help reload.  */
>> > +  if (TARGET_AVX)
>> > +    return code;
>> > +
>>
>> Unfortunately, this part prevents generation of vmin/vmax instructions
>> for TARGET_AVX. In ix86_expand_fp_movcc, we call
>> ix86_prepare_sse_fp_compare_args, where we previously converted GT
>> into LT. LT is recognized in ix86_expand_sse_fp_minmax as valid
>> operand for MIN/MAX, whereas GT is not.
>>
>> I'm not sure if we can swap operands in ix86_expand_sse_fp_minmax,
>> there is a scary comment  in front of ix86_expand_sse_fp_minmax w.r.t.
>> to IEEE safety.
>
> swap_condition is documented to be IEEE safe:
> /* Similar, but return the code when two operands of a comparison are swapped.
>   This IS safe for IEEE floating-point.  */
>
> So, do you prefer this?


Yes, since the operands can be swapped, this looks OK to me. Also, the
comments are very informative.

> 2011-09-23  Jakub Jelinek  
>
>        * config/i386/i386.c (ix86_prepare_sse_fp_compare_args): For
>        GE/GT/UNLE/UNLT swap arguments and condition even for TARGET_AVX.
>
>        * gcc.target/i386/avxfp-1.c: New test.
>        * gcc.target/i386/avxfp-2.c: New test.

OK.

Thanks,
Uros.


[ada] Restore Ada bootstrap on Solaris 8, 9/x86

2011-09-23 Thread Rainer Orth
Mainline Ada bootstrap is currently broken on Solaris 8 and 9/x86 with
Sun as:

Assembler: a-strunb.adb
"/var/tmp//cc6ZxWWa.s", line 2395 : Syntax error
"/var/tmp//cc6ZxWWa.s", line 2591 : Syntax error
make[7]: *** [a-strunb.o] Error 1

The problem is that s-atocou-x86.adb uses lock incl resp. lock decl,
where older Sun as requires lock; incl.  This is exactly what %; was
introduced for, which is already used in i386/sync.md.

The following patch uses it and allowed i386-pc-solaris2.[89] bootstraps
to complete.  Testing is currently running, and I'll also bootstrap with
gas instead of as once that's finished.

Ok for mainline if those tests pass?

Thanks.
Rainer


2011-09-23  Rainer Orth  

* s-atocou-x86.adb (Decrement): Use %;.
(Increment): Likewise.

# HG changeset patch
# Parent 66b8372f5970a73e9957914fae8bfbeced71a512
Restore Ada bootstrap on Solaris 8, 9/x86

diff --git a/gcc/ada/s-atocou-x86.adb b/gcc/ada/s-atocou-x86.adb
--- a/gcc/ada/s-atocou-x86.adb
+++ b/gcc/ada/s-atocou-x86.adb
@@ -50,7 +50,7 @@ package body System.Atomic_Counters is
begin
   System.Machine_Code.Asm
 (Template =>
-   "lock decl" & ASCII.HT & "%0" & ASCII.LF & ASCII.HT
+   "lock%; decl" & ASCII.HT & "%0" & ASCII.LF & ASCII.HT
  & "sete %1",
  Outputs  =>
(Unsigned_32'Asm_Output ("=m", Item.Value),
@@ -68,7 +68,7 @@ package body System.Atomic_Counters is
procedure Increment (Item : in out Atomic_Counter) is
begin
   System.Machine_Code.Asm
-(Template => "lock incl" & ASCII.HT & "%0",
+(Template => "lock%; incl" & ASCII.HT & "%0",
  Outputs  => Unsigned_32'Asm_Output ("=m", Item.Value),
  Inputs   => Unsigned_32'Asm_Input ("m", Item.Value),
  Volatile => True);

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


Re: [ada] Restore Ada bootstrap on Solaris 8, 9/x86

2011-09-23 Thread Arnaud Charlet
> Mainline Ada bootstrap is currently broken on Solaris 8 and 9/x86 with
> Sun as:
> 
> Assembler: a-strunb.adb
>   "/var/tmp//cc6ZxWWa.s", line 2395 : Syntax error
>   "/var/tmp//cc6ZxWWa.s", line 2591 : Syntax error
> make[7]: *** [a-strunb.o] Error 1
> 
> The problem is that s-atocou-x86.adb uses lock incl resp. lock decl,
> where older Sun as requires lock; incl.  This is exactly what %; was
> introduced for, which is already used in i386/sync.md.
> 
> The following patch uses it and allowed i386-pc-solaris2.[89] bootstraps
> to complete.  Testing is currently running, and I'll also bootstrap with
> gas instead of as once that's finished.
> 
> Ok for mainline if those tests pass?

Assuming it does not break x86 linux, OK.

Arno


Re: [Patch,AVR]: Fix PR50447 (2/n)

2011-09-23 Thread Paolo Bonzini

On 09/23/2011 11:36 AM, Georg-Johann Lay wrote:

Paolo Bonzini schrieb:

On 09/23/2011 10:56 AM, Paolo Bonzini wrote:

Also, I am curious about one thing: while this is of course a very
pragmatic solution, you could also convert AVR to get rid of CC0, do
this at expansion time, and get split-wide-types to work as intended.


My changes are just micro-optimizations to print things in a smarter way.


Yes, understood.  There are two relatively large changes that we're 
talking about.


One is changing cc0 to CCmode.  By itself it does not have large 
rewards.  It is just an enabler.  With CCmode, most of your algorithms 
would be usable anyway, so very little code would go away.


The second would be a large change instead: since AVR is not 
schedulable, it got by very well with complex patterns that produce 
multiple instructions.  Changing that and doing the expansion early 
would be harder than introducing CCmode, but would have a relatively big 
reward: split-wide-types would actually provide improvements rather than 
getting in the way most of the time; 8-bit registers could be allocated 
independently.  (There is one notable pessimization, 16-bit add/sub 
would be used quite rarely).  Also, fwprop would be able to perform all 
the simplifications you're doing in these patches.



compare-elim.c makes it relatively easy to remove CC0 nowadays.


For example, a two-byte add can be written as

(set (reg:QI L1) (plus:QI (reg:QI L2) (reg:QI L3)))
(set (reg:QI H1) (plus:QI
 (plus:QI (req:QI H2) (reg:QI H3))
 (ltu:QI  (reg:QI L1) (reg:QI L3

After reload the second instruction can be split to

   (set (reg:CC_C CC) (compare:QI (reg:QI L1) (reg:QI L3)))
   (set (reg:QI   H1) (plus:QI
  (plus:QI(req:QI   H2) (reg:QI H3))
  (lt:QI  (reg:CC_C CC) (const_int 0


What happens if L1=L3?  AVR just has two-operand instructions so there are many
insns with "0" constraint.


You can use L2 instead of L3, it is the same.  If L1=L2=L3, you have a 
problem.  If L1=L2=L3 it's actually an in-place left-shift; you could 
probably represent it as a PARALLEL and split it after reload to insns 
for lsl and rol.


You could also represent the 16-bit and 32-bit operations as PARALLELs 
and split them after reload, but I think it's worse.  Using PARALLELs 
has the advantage that you have access to values of the registers before 
the instruction; however, it prevents fwprop from doing your 
simplifications (because fwprop would not find a matching insn for "set 
the low byte to ~0 and OR the other three bytes").



How goes the LTU ->  LT transition?


Typo.


Ans reloading from memory might change Carry. How is that handled? Read
somewhere about that problem in some PR-chat and that this blocked the cc0 ->
CCmode transition (don't know if that's actually a restriction).


You represent everything without CC registers until after reload, so 
that reload can insert move instructions freely.  See the head comment 
in compare-elim.c.



(i.e. cp+adc).  compare-elim will then be able to turn this into add+adc:

   [parallel
 (set (reg:QI   L1) (plus:QI(reg:QI L2) (reg:QI L3)))
 (set (reg:CC_C CC) (compare:QI
(plus:QI(reg:QI L2) (reg:QI L3))
(reg:QI L3]
   (set (reg:QI H1) (plus:QI
(plus:QI (req:QI   H2) (reg:QI H3))
(lt:QI   (reg:CC_C CC) (const_int 0


What about the other flags like Z (zero) and N (negative)? They are not as
important as Carry but are still usable to avoid comparisons.  Describing all
that explicitly in RTL will be quite tedious...


If add sets other flags correctly, it would just use a different mode. 
I wasn't sure, so I was conservative in my example.  You may want to 
look at the mn10300 port, which in fact only has three modes: CCmode 
requires the arithmetic instruction to set all of N/Z/V/C, while 
CCZNCmode and CCZNmode are for subsets.


Paolo


Re: MIPS Fix PR18141

2011-09-23 Thread Dinar Temirbulatov
hi, Richard,
This version of patch showed no regressions on mipsel-unknown-linux-gnu.
 Thanks, Dinar.


On Wed, Sep 21, 2011 at 4:59 PM, Richard Sandiford
 wrote:
> Dinar Temirbulatov  writes:
>> @@ -14696,7 +14696,11 @@ mips_avoid_hazard (rtx after, rtx insn,
>>       clobber hi and lo.  */
>>    if (*hilo_delay < 2 && reg_set_p (lo_reg, pattern))
>>      nops = 2 - *hilo_delay;
>> -  else if (*delayed_reg != 0 && reg_referenced_p (*delayed_reg, pattern))
>> +  else if ((*delayed_reg != 0 && reg_referenced_p (*delayed_reg, pattern))
>> +         && !((GET_MODE (*delayed_reg) == DFmode && set_after != 0
>> +            && (set = single_set (insn)) != NULL_RTX && GET_MODE 
>> (SET_DEST(set)) == DFmode
>> +            && XINT((XEXP (pattern, 1)), 1) == UNSPEC_LOAD_HIGH
>> +            && XINT((XEXP (*set_after, 1)), 1) == UNSPEC_LOAD_LOW)))
>
> This isn't safe because the patterns might not be UNSPECs (so XINT (...)
> would be meaningless).  It's better to check the insn code instead.
> Something like:
>
>  else if (*delayed_reg != 0
>           && reg_referenced_p (*delayed_reg, pattern)
>           && !(recog_memoized (insn) == CODE_FOR_load_highdf
>                && recog_memoized (*set_after) == CODE_FOR_load_lowdf))
>
> (untested).  Note that *set_after should always be nonnull if
> *delayed_reg is.
>
> Looks good otherwise.
>
> Richard
>
diff -ruNp gcc-20110912-orig/gcc/config/mips/mips.c gcc-20110912-fixed/gcc/config/mips/mips.c
--- gcc-20110912-orig/gcc/config/mips/mips.c	2011-09-12 17:22:27.576457121 +0400
+++ gcc-20110912-fixed/gcc/config/mips/mips.c	2011-09-23 14:24:45.379778834 +0400
@@ -14659,20 +14659,20 @@ mips_orphaned_high_part_p (htab_t htab,
INSN and a previous instruction, avoid it by inserting nops after
instruction AFTER.
 
-   *DELAYED_REG and *HILO_DELAY describe the hazards that apply at
-   this point.  If *DELAYED_REG is non-null, INSN must wait a cycle
-   before using the value of that register.  *HILO_DELAY counts the
-   number of instructions since the last hilo hazard (that is,
-   the number of instructions since the last MFLO or MFHI).
+   *DELAYED_REG, *SET_AFTER and *HILO_DELAY describe the hazards that 
+   apply at this point.  If *DELAYED_REG and *SET_AFTER is non-null, 
+   INSN must wait a cycle before using the value of that register.  
+   *HILO_DELAY counts the number of instructions since the last hilo hazard 
+   (that is, the number of instructions since the last MFLO or MFHI).
 
-   After inserting nops for INSN, update *DELAYED_REG and *HILO_DELAY
-   for the next instruction.
+   After inserting nops for INSN, update *DELAYED_REG, *SET_AFTER
+   and *HILO_DELAY for the next instruction.
 
LO_REG is an rtx for the LO register, used in dependence checking.  */
 
 static void
 mips_avoid_hazard (rtx after, rtx insn, int *hilo_delay,
-		   rtx *delayed_reg, rtx lo_reg)
+		   rtx *delayed_reg, rtx lo_reg, rtx *set_after)
 {
   rtx pattern, set;
   int nops, ninsns;
@@ -14696,7 +14696,9 @@ mips_avoid_hazard (rtx after, rtx insn,
  clobber hi and lo.  */
   if (*hilo_delay < 2 && reg_set_p (lo_reg, pattern))
 nops = 2 - *hilo_delay;
-  else if (*delayed_reg != 0 && reg_referenced_p (*delayed_reg, pattern))
+  else if ((*delayed_reg != 0 && set_after != 0 && reg_referenced_p (*delayed_reg, pattern))
+	&& !(recog_memoized (insn) == CODE_FOR_load_highdf
+	&& recog_memoized (*set_after) == CODE_FOR_load_lowdf))
 nops = 1;
   else
 nops = 0;
@@ -14710,6 +14712,7 @@ mips_avoid_hazard (rtx after, rtx insn,
   /* Set up the state for the next instruction.  */
   *hilo_delay += ninsns;
   *delayed_reg = 0;
+  *set_after = 0;
   if (INSN_CODE (insn) >= 0)
 switch (get_attr_hazard (insn))
   {
@@ -14724,6 +14727,7 @@ mips_avoid_hazard (rtx after, rtx insn,
 	set = single_set (insn);
 	gcc_assert (set);
 	*delayed_reg = SET_DEST (set);
+	*set_after = insn;
 	break;
   }
 }
@@ -14736,7 +14740,7 @@ mips_avoid_hazard (rtx after, rtx insn,
 static void
 mips_reorg_process_insns (void)
 {
-  rtx insn, last_insn, subinsn, next_insn, lo_reg, delayed_reg;
+  rtx insn, last_insn, subinsn, next_insn, lo_reg, delayed_reg, set_after;
   int hilo_delay;
   htab_t htab;
 
@@ -14811,7 +14815,7 @@ mips_reorg_process_insns (void)
 			INSN_CODE (subinsn) = CODE_FOR_nop;
 		  }
 		mips_avoid_hazard (last_insn, subinsn, &hilo_delay,
-   &delayed_reg, lo_reg);
+   &delayed_reg, lo_reg, &set_after);
 		  }
 	  last_insn = insn;
 	}
@@ -14832,7 +14836,7 @@ mips_reorg_process_insns (void)
 	  else
 		{
 		  mips_avoid_hazard (last_insn, insn, &hilo_delay,
- &delayed_reg, lo_reg);
+ &delayed_reg, lo_reg, &set_after);
 		  last_insn = insn;
 		}
 	}


ChangeLog
Description: Binary data


Re: Go patch committed: Update libgo to Go release r60

2011-09-23 Thread Rainer Orth
Ian Lance Taylor  writes:

>> * The Solaris 11/x86 libgo bootstrap dies like this:
>>
>> /vol/gcc/src/hg/trunk/local/libgo/syscalls/exec.go:11:14: error: imported 
>> and not used: unsafe
>
> That is odd since the file clearly does use unsafe.  Perhaps it is
> somehow a consequence of the other errors.

Perhaps, we'll see.

>> /vol/gcc/src/hg/trunk/local/libgo/syscalls/exec.go:172:20: error: reference 
>> to undefined name 'TIOCNOTTY'
>> /vol/gcc/src/hg/trunk/local/libgo/syscalls/exec.go:179:20: error: reference 
>> to undefined name 'TIOCSCTTY'
>>
>>   Don't know about the first one, but the two ioctl's are missing from
>>   sysinfo.go.  They are defined in , but if I include
>>   that in mksysinfo.sh, they only show up as 
>>
>> // unknowndefine TIOCNOTTY (tIOC|113)
>>
>>   in gen-sysinfo.go.  No idea why yet.
>
> Is tIOC defined in gen-sysinfo.go?  In ?  Does some other

Only as

// unknowndefine tIOC ('t'<<8)

> header file need to be #included first?

No,  is self-contained.

>> * IRIX will be worse: while it has TIOCNOTTY, it completely lacks
>>   TIOCSCTTY.
>>
>> Suggestions?
>
> For a missing TIOCSCTTY I think the simplest solution will be to set it
> in syscall_irix.go to some innocuous value if there is one.  E.g.,
> TIOCNXCL if Irix supports that.  If there is no innocuous value, let's

Yep, IRIX has that.

> just set it to 0 and test for 0 in exec.go before calling ioctl.
>
> Similarly, if we can't get TIOCNOTTY defined in sysinfo.go, then I think
> it's OK to just define it directly in syscall_irix.go and
> syscall_solaris.go.  Those values are not going to change with different
> versions of the OS.

That certainly works as a fallback, but I'd rather avoid the hardcoding
if it can be reasonably avoided.

Rainer

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


Re: Fix testsuite profiling support checks

2011-09-23 Thread Rainer Orth
Bernd Schmidt  writes:

> The following change
>
>   2011-05-26  Rainer Orth  
>   PR gcov-profile/48845
>
> causes testsuite failures on C6X. Specifically,
>
> @@ -495,11 +495,16 @@ proc check_profiling_available { test_wh
>  # These conditions depend on the argument so examine them before
>  # looking at the cache variable.
>
> +# Tree profiling requires TLS runtime support.
> +if { $test_what == "-fprofile-generate" } {
> +   return [check_effective_target_tls_runtime]
> +}
> +
>
> skips all the further tests in that function if
> check_effective_target_tls_runtime returns true. (I'm not sure why it
> does that on C6X - it seems to link in emutls stuff?) We then fail with

Right, this is always present and satisfies the tls_runtime test.  The
check was primarily meant for targets that have native TLS, but need
special switches to enable it.

Rainer

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


Re: Fix testsuite profiling support checks

2011-09-23 Thread Rainer Orth
Mike Stump  writes:

> On Sep 1, 2011, at 6:20 AM, Bernd Schmidt wrote:
>> The following change
>> 
>>  2011-05-26  Rainer Orth  
>>  PR gcov-profile/48845
>> 
>> causes testsuite failures on C6X.
>
> I was hoping that Rainer would comment...  or a profiling person, or an avr 
> person

I've just returned from a 3-week vacation and am slowly working through
my mail.

>> Ok?
>
> Ok.  Watch for any hate mail from the avr folks.  :-)

Looks good.  I'm just running a Solaris 8/x86 bootstrap, which will
notice if something's amiss for that target.

Thanks.
Rainer

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


Re: [PATCH] Do not store/stream binfos in jump functions

2011-09-23 Thread Martin Jambor
Hi,

On Fri, Sep 16, 2011 at 04:29:44PM +0200, Jan Hubicka wrote:
> > 
> > * ipa-prop.h (jump_func_type): Updated comments.
> > (ipa_known_type_data): New type.
> > (ipa_jump_func): Use it to describe known type jump functions.
> > * ipa-prop.c (ipa_print_node_jump_functions_for_edge): Updated to
> > reflect the new known type jump function contents.
> > (compute_known_type_jump_func): Likewise.
> > (combine_known_type_and_ancestor_jfs): Likewise.
> > (try_make_edge_direct_virtual_call): Likewise.
> > (ipa_write_jump_function): Likewise.
> > (ipa_read_jump_function): Likewise.
> > * ipa-cp.c (ipa_value_from_known_type_jfunc): New function.
> > (ipa_value_from_jfunc): Use ipa_value_from_known_type_jfunc.
> > (propagate_accross_jump_function): Likewise.
> 
> OK. If we saved just one pointer to the actual type (i.e. not
> BINFO), would it be any sanier?
> 

When C and C++ code is linked together, the prevailing representation
of shared types might come from the C land and thus lack BINFOs.  This
then might then falsely trigger the assert I added to
ipa_value_from_known_type_jfunc.  Therefore I have committed a
slightly different version with that assert replaced by a test.

Thanks,

Martin


2011-09-23  Martin Jambor  

* ipa-prop.h (jump_func_type): Updated comments.
(ipa_known_type_data): New type.
(ipa_jump_func): Use it to describe known type jump functions.
* ipa-prop.c (ipa_print_node_jump_functions_for_edge): Updated to
reflect the new known type jump function contents.
(compute_known_type_jump_func): Likewise.
(combine_known_type_and_ancestor_jfs): Likewise.
(try_make_edge_direct_virtual_call): Likewise.
(ipa_write_jump_function): Likewise.
(ipa_read_jump_function): Likewise.
* ipa-cp.c (ipa_value_from_known_type_jfunc): New function.
(ipa_value_from_jfunc): Use ipa_value_from_known_type_jfunc.
(propagate_accross_jump_function): Likewise.

Index: src/gcc/ipa-cp.c
===
--- src.orig/gcc/ipa-cp.c
+++ src/gcc/ipa-cp.c
@@ -674,6 +674,20 @@ ipa_get_jf_ancestor_result (struct ipa_j
 return NULL_TREE;
 }
 
+/* Extract the acual BINFO being described by JFUNC which must be a known type
+   jump function.  */
+
+static tree
+ipa_value_from_known_type_jfunc (struct ipa_jump_func *jfunc)
+{
+  tree base_binfo = TYPE_BINFO (jfunc->value.known_type.base_type);
+  if (!base_binfo)
+return NULL_TREE;
+  return get_binfo_at_offset (base_binfo,
+ jfunc->value.known_type.offset,
+ jfunc->value.known_type.component_type);
+}
+
 /* Determine whether JFUNC evaluates to a known value (that is either a
constant or a binfo) and if so, return it.  Otherwise return NULL. INFO
describes the caller node so that pass-through jump functions can be
@@ -685,7 +699,7 @@ ipa_value_from_jfunc (struct ipa_node_pa
   if (jfunc->type == IPA_JF_CONST)
 return jfunc->value.constant;
   else if (jfunc->type == IPA_JF_KNOWN_TYPE)
-return jfunc->value.base_binfo;
+return ipa_value_from_known_type_jfunc (jfunc);
   else if (jfunc->type == IPA_JF_PASS_THROUGH
   || jfunc->type == IPA_JF_ANCESTOR)
 {
@@ -991,7 +1005,11 @@ propagate_accross_jump_function (struct
   tree val;
 
   if (jfunc->type == IPA_JF_KNOWN_TYPE)
-   val = jfunc->value.base_binfo;
+   {
+ val = ipa_value_from_known_type_jfunc (jfunc);
+ if (!val)
+   return set_lattice_contains_variable (dest_lat);
+   }
   else
val = jfunc->value.constant;
   return add_value_to_lattice (dest_lat, val, cs, NULL, 0);
Index: src/gcc/ipa-prop.c
===
--- src.orig/gcc/ipa-prop.c
+++ src/gcc/ipa-prop.c
@@ -164,10 +164,12 @@ ipa_print_node_jump_functions_for_edge (
fprintf (f, "UNKNOWN\n");
   else if (type == IPA_JF_KNOWN_TYPE)
{
- tree binfo_type = TREE_TYPE (jump_func->value.base_binfo);
- fprintf (f, "KNOWN TYPE, type in binfo is: ");
- print_generic_expr (f, binfo_type, 0);
- fprintf (f, " (%u)\n", TYPE_UID (binfo_type));
+ fprintf (f, "KNOWN TYPE: base  ");
+ print_generic_expr (f, jump_func->value.known_type.base_type, 0);
+ fprintf (f, ", offset "HOST_WIDE_INT_PRINT_DEC", component ",
+  jump_func->value.known_type.offset);
+ print_generic_expr (f, jump_func->value.known_type.component_type, 0);
+ fprintf (f, "\n");
}
   else if (type == IPA_JF_CONST)
{
@@ -638,7 +640,7 @@ compute_known_type_jump_func (tree op, s
  gimple call)
 {
   HOST_WIDE_INT offset, size, max_size;
-  tree base, binfo;
+  tree base;
 
   if (!flag_devirtualize
   || TREE_CODE (op) != ADDR_EXPR
@@ -654,18 +656,14 @@ compute_known_type

[C++ Patch] PR 50258

2011-09-23 Thread Paolo Carlini

Hi,

so this is what I'm finishing testing on x86_64-linux. Ok?

Thanks,
Paolo.


/cp
2011-09-23  Paolo Carlini  

PR c++/50258
* decl.c (check_static_variable_definition): Allow in-class
initialization of static data member of non-integral type in
permissive mode.

/testsuite
2011-09-23  Paolo Carlini  

PR c++/50258
* g++.dg/cpp0x/constexpr-static8.C: New.

Index: testsuite/g++.dg/cpp0x/constexpr-static8.C
===
--- testsuite/g++.dg/cpp0x/constexpr-static8.C  (revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-static8.C  (revision 0)
@@ -0,0 +1,7 @@
+// PR c++/50258
+// { dg-options "-std=c++0x -fpermissive" }
+
+struct Foo {
+  static const double d = 3.14; // { dg-warning "constexpr" }
+};
+const double Foo::d;// { dg-warning "constexpr" }
Index: cp/decl.c
===
--- cp/decl.c   (revision 179116)
+++ cp/decl.c   (working copy)
@@ -7716,8 +7716,9 @@ check_static_variable_definition (tree decl, tree
   else if (cxx_dialect >= cxx0x && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
 {
   if (literal_type_p (type))
-   error ("% needed for in-class initialization of static "
-  "data member %q#D of non-integral type", decl);
+   permerror (input_location,
+  "% needed for in-class initialization of "
+  "static data member %q#D of non-integral type", decl);
   else
error ("in-class initialization of static data member %q#D of "
   "non-literal type", decl);


Re: [Mingw-users] [patch] --enable-dynamic-string default for mingw-w64

2011-09-23 Thread Paolo Carlini

On 09/23/2011 11:39 AM, JonY wrote:
Ping, any updates? 
I'm wondering if it wouldn't be cleaner to handle this in the 
appropriate config/os/ headers, something like (with a good comment 
before!):


#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
#define _GLIBCXX_FULLY_DYNAMIC_STRING
#endif

Paolo.


Re: [Mingw-users] [patch] --enable-dynamic-string default for mingw-w64

2011-09-23 Thread JonY
On 9/23/2011 21:46, Paolo Carlini wrote:
> On 09/23/2011 11:39 AM, JonY wrote:
>> Ping, any updates? 
> I'm wondering if it wouldn't be cleaner to handle this in the
> appropriate config/os/ headers, something like (with a good comment
> before!):
> 
> #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
> #define _GLIBCXX_FULLY_DYNAMIC_STRING
> #endif
> 
> Paolo.
> 

Wouldn't that force it on no matter what the user sets in configure?
IMHO, that would be breaking the --disable option.




signature.asc
Description: OpenPGP digital signature


Re: [Mingw-users] [patch] --enable-dynamic-string default for mingw-w64

2011-09-23 Thread Paolo Carlini

On 09/23/2011 03:46 PM, Paolo Carlini wrote:

On 09/23/2011 11:39 AM, JonY wrote:
Ping, any updates? 
I'm wondering if it wouldn't be cleaner to handle this in the 
appropriate config/os/ headers, something like (with a good comment 
before!):


#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
#define _GLIBCXX_FULLY_DYNAMIC_STRING
#endif
Even better would be changing the current infrastructure for this to 
have a default (not fully dynamic) of zero, a set value of one, 
undefined otherwise. Then in the mingw config/os we do the above and the 
configuring user is always happy. In that case the basic_string.* bits 
must be changed from


#ifdef _GLIBCXX_FULLY_DYNAMIC_STRING

to

#if _GLIBCXX_FULLY_DYNAMIC_STRING == 1

of course.

Paolo.


Re: [Mingw-users] [patch] --enable-dynamic-string default for mingw-w64

2011-09-23 Thread Paolo Carlini

On 09/23/2011 03:59 PM, Paolo Carlini wrote:

On 09/23/2011 03:46 PM, Paolo Carlini wrote:

On 09/23/2011 11:39 AM, JonY wrote:
Ping, any updates? 
I'm wondering if it wouldn't be cleaner to handle this in the 
appropriate config/os/ headers, something like (with a good comment 
before!):


#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
#define _GLIBCXX_FULLY_DYNAMIC_STRING
#endif
Even better would be changing the current infrastructure for this to 
have a default (not fully dynamic) of zero, a set value of one, 
undefined otherwise.

I hope you got the basic point anyway, sorry about the confusion ;)

I meant that if the user configuring doesn't pass anything to configure, 
then _GLIBCXX_FULLY_DYNAMIC_STRING remains undefined. Otherwise, zero is 
set in the acinclude.m4 procedure for no fully dynamic string and one 
for fully dynamic string. Then we have


#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
#define _GLIBCXX_FULLY_DYNAMIC_STRING 1
#endif

in the mingw config/os (with a good comment before!) and, in the 
basic_string.* headers we use:


#if _GLIBCXX_FULLY_DYNAMIC_STRING == 1

This is a standard pattern in configuries, anyway...

Paolo.


Re: [PR 47382] We cannot simply fold OBJ_TYPE_REF at all in 4.6

2011-09-23 Thread Martin Jambor
Hi,

On Thu, Sep 22, 2011 at 06:36:43PM +1200, Maxim Kuvyrkov wrote:
> On 9/02/2011, at 6:53 AM, Martin Jambor wrote:
> 
> > 
> > This patch basically disables all intraprocedural devirtualization
> > simply because that transformation relies on assumptions that no
> > longer hold true.  That leaves only devirtualization within inlining
> > and IPA-CP but those do not work intraprocedurally (i.e. when the
> > object is within the same function as the call).  And in your
> > testcase, early inlining puts all virtual calls to main() where the
> > objects are.
> > 
> >> 
> >> GCC mainline just before your patch was optimizing the following
> >> testcase to have no virtual calls.  I wonder how this can be fixed
> >> non-intrusively to qualify for Stage 4.
> > 
> > I have patches for this and hope I will post them soon (probably only as an
> > RFC, however).  They in fact are in the gcc-patches archives:
> > http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01033.html and 
> > http://gcc.gnu.org/ml/gcc-patches/2010-12/msg01214.html 
> > 
> > Unfortunately, I am afraid we would need to make a _very_ compelling
> > case for them to be included at this point.
> 
> Martin,
> 
> Ping.
> 
> I am about to submit improvements to inlining that take devirtualization 
> opportunities into account and your two above patches help improve 
> devirtualization quite a bit.  Do you plan to commit them some time soon?
> 
> For reference, I'm attaching the patch that adds several new devirtualization 
> testcases.  Not optimizing the very simple inline-devirt-1.C is just 
> embarrassing. 
> 

Well, we have tried the patches when LTO-building Firefox in spring
and they did not really bring about much improvement.  Therefore we
concluded that more is needed - such as try to track malloced objects
and do devirtualization on them whenever possible because the
automatically allocated objects are not enough.

Also, because for other reasons (mainly Fortran array info) I plan to
implement jump functions for structure components, I planned to
eventually replace the new-dynamic-type-identification patch with a
jump function for the actual vptr value.

However, both of these are really 4.8 material and since the patches
probably need only minor updates, it might be worthwhile to do that so
that gcc can handle the "embarrassing" simple cases.  So I will do
that (though it might need to wait for about a week), re-try them on
Firefox and probably propose them for submission.

By the way, do you evaluate (your) devirtualization by compiling any
real software (other than Firefox)?  Do the patches make any
difference there?

Thanks,

Martin


Re: Go patch committed: Update libgo to Go release r60

2011-09-23 Thread Ian Lance Taylor
Rainer Orth  writes:

>> Is tIOC defined in gen-sysinfo.go?  In ?  Does some other
>
> Only as
>
> // unknowndefine tIOC ('t'<<8)

Ah.

I committed this patch which may fix this problem.  Bootstrapped and ran
Go testsuite on x86_64-unknown-linux-gnu.  You'll have to remove
TARGET/libgo/s-sysinfo to force sysinfo.go to be rebuilt.

Ian


2011-09-23  Ian Lance Taylor  

* godump.c (go_define): Treat a single character in single quotes,
or a string, as an operand.


Index: godump.c
===
--- godump.c	(revision 178784)
+++ godump.c	(working copy)
@@ -301,11 +301,13 @@ go_define (unsigned int lineno, const ch
 	case '\'':
 	  {
 	char quote;
+	int count;
 
 	if (saw_operand)
 	  goto unknown;
 	quote = *p;
 	*q++ = *p++;
+	count = 0;
 	while (*p != quote)
 	  {
 		int c;
@@ -313,6 +315,8 @@ go_define (unsigned int lineno, const ch
 		if (*p == '\0')
 		  goto unknown;
 
+		++count;
+
 		if (*p != '\\')
 		  {
 		*q++ = *p++;
@@ -358,7 +362,15 @@ go_define (unsigned int lineno, const ch
 		goto unknown;
 		  }
 	  }
+
 	*q++ = *p++;
+
+	if (quote == '\'' && count != 1)
+	  goto unknown;
+
+	saw_operand = true;
+	need_operand = false;
+
 	break;
 	  }
 


Re: Go patch committed: Update libgo to Go release r60

2011-09-23 Thread Rainer Orth
Ian,

>>> Is tIOC defined in gen-sysinfo.go?  In ?  Does some other
>>
>> Only as
>>
>> // unknowndefine tIOC ('t'<<8)
>
> Ah.
>
> I committed this patch which may fix this problem.  Bootstrapped and ran
> Go testsuite on x86_64-unknown-linux-gnu.  You'll have to remove
> TARGET/libgo/s-sysinfo to force sysinfo.go to be rebuilt.

that does the trick to correctly define TIOCNOTTY and TIOCSCTTY on
Solaris.  I'm currently running a i386-pc-solaris2.10 bootstrap with a
single-line change to mksysinfo.sh:

diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
--- a/libgo/mksysinfo.sh
+++ b/libgo/mksysinfo.sh
@@ -43,6 +43,7 @@ cat > sysinfo.c <
 #include 
 #include 
+#include 
 #if defined(HAVE_SYSCALL_H)
 #include 
 #endif

I'm undecided if I need to add an autoconf check for that file.  At
least on Linux, IRIX, Solaris and Tru64 UNIX, it is present.  I'll deal
with the replacement of TIOCSCTTY by TIOCNXCL on IRIX separately.

Thanks.
Rainer

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


[PATCH] v{extract,insert,broadcast,perm2}{i,f}128

2011-09-23 Thread Jakub Jelinek
On Tue, Sep 20, 2011 at 04:10:56PM +0200, Uros Bizjak wrote:
> >> I can surely do that (or e.g.
> >> (define_mode_attr i128 [(V4DI "%~128") (V4DF "f128") ...])
> >> and
> >> "vextract\t{$0x1, %1, %0|%0, %1, 0x1}"
> >> )
> >> if you prefer it that way, but that is a functional alternative
> >> to the patch I've just posted.  What I don't know how to express

> Oh, and you can use  to set mode attribute statically.

This patch implements that, bootstrapped/regtested on x86_64-linux
and i686-linux, tested on SandyBridge additionally, eyeballed some
-mavx2 assembly files.  Ok for trunk?

2011-09-23  Jakub Jelinek  

* config/i386/i386.c (ix86_print_operand): Handle %~.
(ix86_print_operand_punct_valid_p): Return true also for '~'.
* config/i386/sse.md (i128): New mode_attr.
(vec_extract_hi_, vec_extract_hi_,
avx_vbroadcastf128_, *avx_vperm2f128_full,
*avx_vperm2f128_nozero, vec_set_lo_, 
vec_set_hi_, *vec_concat_avx): Use  in the
patterns, use "" for "mode" attribute.
(vec_extract_hi_v16hi, vec_extract_hi_v32qi, vec_set_lo_v16hi,
vec_set_hi_v16hi, vec_set_lo_v32qi, vec_set_hi_v32qi): Use
%~128 in the patterns, use "OI" for "mode" attribute.

--- gcc/config/i386/i386.c.jj   2011-09-23 10:04:35.0 +0200
+++ gcc/config/i386/i386.c  2011-09-23 13:12:11.0 +0200
@@ -13513,6 +13513,7 @@ get_some_local_dynamic_name (void)
Y -- print condition for XOP pcom* instruction.
+ -- print a branch hint as 'cs' or 'ds' prefix
; -- print a semicolon (after prefixes due to bug in older gas).
+   ~ -- print "i" if TARGET_AVX2, "f" otherwise.
@ -- print a segment register of thread base pointer load
  */
 
@@ -14006,6 +14007,10 @@ ix86_print_operand (FILE *file, rtx x, i
fputs ("gs", file);
  return;
 
+   case '~':
+ putc (TARGET_AVX2 ? 'i' : 'f', file);
+ return;
+
default:
output_operand_lossage ("invalid operand code '%c'", code);
}
@@ -14141,7 +14146,7 @@ static bool
 ix86_print_operand_punct_valid_p (unsigned char code)
 {
   return (code == '@' || code == '*' || code == '+'
- || code == '&' || code == ';');
+ || code == '&' || code == ';' || code == '~');
 }
 
 /* Print a memory operand whose address is ADDR.  */
--- gcc/config/i386/sse.md.jj   2011-09-22 15:40:48.0 +0200
+++ gcc/config/i386/sse.md  2011-09-23 12:59:12.0 +0200
@@ -297,6 +297,11 @@ (define_mode_attr castmode [(V8SI "si") 
 ;; Instruction suffix for sign and zero extensions.
 (define_code_attr extsuffix [(sign_extend "sx") (zero_extend "zx")])
 
+;; i128 for integer vectors and TARGET_AVX2, f128 otherwise.
+(define_mode_attr i128
+  [(V8SF "f128") (V4DF "f128") (V32QI "%~128") (V16HI "%~128")
+   (V8SI "%~128") (V4DI "%~128")])
+
 ;; Mix-n-match
 (define_mode_iterator AVX256MODE2P [V8SI V8SF V4DF])
 
@@ -3872,23 +3877,13 @@ (define_insn "vec_extract_hi_"
  (match_operand:VI8F_256 1 "register_operand" "x,x")
  (parallel [(const_int 2) (const_int 3)])))]
   "TARGET_AVX"
-{
-  if (get_attr_mode (insn) == MODE_OI)
-return "vextracti128\t{$0x1, %1, %0|%0, %1, 0x1}";
-  else
-return "vextractf128\t{$0x1, %1, %0|%0, %1, 0x1}";
-}
+  "vextract\t{$0x1, %1, %0|%0, %1, 0x1}"
   [(set_attr "type" "sselog")
(set_attr "prefix_extra" "1")
(set_attr "length_immediate" "1")
(set_attr "memory" "none,store")
(set_attr "prefix" "vex")
-   (set (attr "mode")
- (if_then_else
-   (and (match_test "TARGET_AVX2")
-   (eq (const_string "mode") (const_string "V4DImode")))
- (const_string "OI")
- (const_string "V4DF")))])
+   (set_attr "mode" "")])
 
 (define_insn_and_split "vec_extract_lo_"
   [(set (match_operand: 0 "nonimmediate_operand" "=x,m")
@@ -3917,23 +3912,13 @@ (define_insn "vec_extract_hi_"
  (parallel [(const_int 4) (const_int 5)
 (const_int 6) (const_int 7)])))]
   "TARGET_AVX"
-{
-  if (get_attr_mode (insn) == MODE_OI)
-return "vextracti128\t{$0x1, %1, %0|%0, %1, 0x1}";
-  else
-return "vextractf128\t{$0x1, %1, %0|%0, %1, 0x1}";
-}
+  "vextract\t{$0x1, %1, %0|%0, %1, 0x1}"
   [(set_attr "type" "sselog")
(set_attr "prefix_extra" "1")
(set_attr "length_immediate" "1")
(set_attr "memory" "none,store")
(set_attr "prefix" "vex")
-   (set (attr "mode")
- (if_then_else
-   (and (match_test "TARGET_AVX2")
-   (eq (const_string "mode") (const_string "V8SImode")))
- (const_string "OI")
- (const_string "V8SF")))])
+   (set_attr "mode" "")])
 
 (define_insn_and_split "vec_extract_lo_v16hi"
   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=x,m")
@@ -3966,21 +3951,13 @@ (define_insn "vec_extract_hi_v16hi"
 (const_int 12) (const_int 13)
 (const_int 14) (const_int 15)])))]
   "TARGET_AVX"
-{
-  if (get_attr_mode (insn) == MODE_OI)
-return "vextracti128\t{$0x1, %1, %0|%0, %1, 0x1}

Re: Preserve callee cgraph edges when callgraph profiles sections are requested. (issue5101042)

2011-09-23 Thread Martin Jambor
Hi,

On Thu, Sep 22, 2011 at 04:24:47PM -0700, Xinliang David Li wrote:
> ok for google branches.
> 
> (Did a little digging -- the remove pass is added because ipa-inline
> did not do a good job updating the call graph so there might be some
> inconsistency. However the affinity information needs to be computed
> after inline transformation, so some more work may be needed in the
> future to fix those inconsistencies -- or perhaps rebuild cgraph edges
> if profile-cgraph-section option is specified).

the main reason why we remove all call graph edges at a few
compilation points is that we do not keep them up to date when
manipulating GIMPLE.  That for example means that when DCE eliminates
a call statement, neither it nor the gimple infrastructure attempts to
locate the associated call graph edge and remove it.  Similarly, when
some form of propagation discovers a target of a call statement, it
updates the statement but that does not bring the associated call
graph edge (if it exists) from the indirect ones to the direct.

Therefore, if call graph edges were kept, they could increasingly get
out of sync with the gimple code which naturally might lead to all
sorts of surprises.  The solution has so far been to re-calculate all
the cgraph edges before they are needed and throw them away before
doing intraprocedural optimization (mainly to avoid confusion).

Inlining and all other IPA passes in fact update call graph edges
meticulously because that is all they have in LTO.  The problem IIRC
was that inlining was also supposed to remove the edges for the
reasons described above but was not doing it consistently.  So it was
moved to a different simple pass.

Removing the edges allowed a quick initial implementation of the call
graph and has certainly been good enough for a long time but recently
people increasingly bump into limitations it poses so we might
consider making them permanent now (or soon).  That is also what you
may want because what you have with the patch is the state of the
edges after inlining (which might be good enough, I admit I don't
know).

HTH,

Martin

> 
> David
> 
> On Thu, Sep 22, 2011 at 4:01 PM, Sriraman Tallam  wrote:
> > This patch preserves cgraph callee edges till pass_final if callgraph
> > edge profiles sections are requested.  It also renames callgraph edge
> > profile sections to be .gnu.callgraph instead of .note.callgraph
> >
> >
> > Index: cgraphbuild.c
> > ===
> > --- cgraphbuild.c       (revision 179098)
> > +++ cgraphbuild.c       (working copy)
> > @@ -697,10 +697,18 @@ struct gimple_opt_pass pass_rebuild_cgraph_edges =
> >  }
> >  };
> >
> > +/* Defined in tree-optimize.c  */
> > +extern bool cgraph_callee_edges_final_cleanup;
> >
> >  static unsigned int
> >  remove_cgraph_callee_edges (void)
> >  {
> > +  /* The -fcallgraph-profiles-sections flag needs the call-graph preserved
> > +     till pass_final.  */
> > +  if (cgraph_callee_edges_final_cleanup
> > +      && flag_callgraph_profiles_sections)
> > +      return 0;
> > +
> >   cgraph_node_remove_callees (cgraph_node (current_function_decl));
> >   return 0;
> >  }
> > Index: final.c
> > ===
> > --- final.c     (revision 179098)
> > +++ final.c     (working copy)
> > @@ -4425,10 +4425,11 @@ rest_of_handle_final (void)
> >      profiling information. */
> >   if (flag_callgraph_profiles_sections
> >       && flag_profile_use
> > -      && cgraph_node (current_function_decl) != NULL)
> > +      && cgraph_node (current_function_decl) != NULL
> > +      && (cgraph_node (current_function_decl))->callees != NULL)
> >     {
> >       flags = SECTION_DEBUG;
> > -      asprintf (&profile_fnname, ".note.callgraph.text.%s", fnname);
> > +      asprintf (&profile_fnname, ".gnu.callgraph.text.%s", fnname);
> >       switch_to_section (get_section (profile_fnname, flags, NULL));
> >       fprintf (asm_out_file, "\t.string \"Function %s\"\n", fnname);
> >       dump_cgraph_profiles ();
> > Index: testsuite/g++.dg/tree-prof/callgraph-profiles.C
> > ===
> > --- testsuite/g++.dg/tree-prof/callgraph-profiles.C     (revision 0)
> > +++ testsuite/g++.dg/tree-prof/callgraph-profiles.C     (revision 0)
> > @@ -0,0 +1,29 @@
> > +/* Verify if call-graph profile sections are created
> > +   with -fcallgraph-profiles-sections. */
> > +/* { dg-options "-O2 -fcallgraph-profiles-sections -ffunction-sections 
> > --save-temps" } */
> > +
> > +int __attribute__ ((noinline))
> > +foo ()
> > +{
> > +  return 1;
> > +}
> > +
> > +int __attribute__ ((noinline))
> > +bar ()
> > +{
> > +  return 0;
> > +}
> > +
> > +int main ()
> > +{
> > +  int sum;
> > +  for (int i = 0; i< 1000; i++)
> > +    {
> > +      sum = foo () + bar();
> > +    }
> > +  return sum * bar ();
> > +}
> > +
> > +/* { dg-final-use { scan-assembler "\.gnu\.callgraph\.text\.main" } } */
>

Re: Ping: [libiberty patch] Add demangler support for cloned function symbols (PR 40831)

2011-09-23 Thread Ian Lance Taylor
Jakub Jelinek  writes:

> On Thu, Sep 22, 2011 at 05:40:15PM -0700, Cary Coutant wrote:
>> > Ping?
>> >
>> > http://gcc.gnu.org/ml/gcc-patches/2011-08/msg01626.html
>
> It looks good to me, but I'd prefer if Ian with his demangler author
> and libiberty maintainer hats looked at it too.

This patch is OK, with or without the testsuite additions Jakub
mentions.

Thanks.

Ian


Re: Go patch committed: Update libgo to Go release r60

2011-09-23 Thread Rainer Orth
Rainer Orth  writes:

> Ian,
>
 Is tIOC defined in gen-sysinfo.go?  In ?  Does some other
>>>
>>> Only as
>>>
>>> // unknowndefine tIOC ('t'<<8)
>>
>> Ah.
>>
>> I committed this patch which may fix this problem.  Bootstrapped and ran
>> Go testsuite on x86_64-unknown-linux-gnu.  You'll have to remove
>> TARGET/libgo/s-sysinfo to force sysinfo.go to be rebuilt.
>
> that does the trick to correctly define TIOCNOTTY and TIOCSCTTY on
> Solaris.  I'm currently running a i386-pc-solaris2.10 bootstrap with a
> single-line change to mksysinfo.sh:

Unfortunately, the

/vol/gcc/src/hg/trunk/local/libgo/syscalls/exec.go:11:14: error: imported and 
not used: unsafe

error remains.  I've no idea what triggers it.

Rainer

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


Re: Go patch committed: Update libgo to Go release r60

2011-09-23 Thread Ian Lance Taylor
Rainer Orth  writes:

> that does the trick to correctly define TIOCNOTTY and TIOCSCTTY on
> Solaris.  I'm currently running a i386-pc-solaris2.10 bootstrap with a
> single-line change to mksysinfo.sh:
>
> diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
> --- a/libgo/mksysinfo.sh
> +++ b/libgo/mksysinfo.sh
> @@ -43,6 +43,7 @@ cat > sysinfo.c <  #include 
>  #include 
>  #include 
> +#include 
>  #if defined(HAVE_SYSCALL_H)
>  #include 
>  #endif
>
> I'm undecided if I need to add an autoconf check for that file.  At
> least on Linux, IRIX, Solaris and Tru64 UNIX, it is present.  I'll deal
> with the replacement of TIOCSCTTY by TIOCNXCL on IRIX separately.

Thanks, I went ahead and committed this patch.   was in
POSIX.1 from 1986 or thereabouts, so I think it is safe to use today.

Ian


[PATCH] Fixup fortran type_for_size langhook

2011-09-23 Thread Jakub Jelinek
Hi!

I've noticed with the
2009-05-29  Eric Botcazou  

* tree-ssa-loop-ivopts.c (strip_offset_1) : New case.
(force_expr_to_var_cost) : Likewise.
(ptr_difference_cost): Use affine combinations to compute it.
(difference_cost): Likewise.
(get_computation_cost_at): Compute more accurate cost for addresses
if the ratio is a multiplier allowed in addresses.
For non-addresses, consider that an additional offset or symbol is
added only once.
patch backported to 4.4-RH branch an ICE on PowerPC, where difference_cost
calls signed_type_for, which for a BOOLEAN_TYPE returns NULL, but
difference_cost isn't prepared for it.  Can't reproduce it on 4.6 nor trunk,
but most probably just because some other optimizations made the problem
latent.  Looking at signed_type_for and the type_for_size langhook it uses
(yeah, I know, it isn't very much desirable to use langhooks in the
middle-end), the langhook is documented to return a signed resp. unsigned
type that can hold AT LEAST the requested bits and most frontends implement
it that way, with the exception of Fortran and Go.  And it seems lots of
places all around the middle-end assume that for not excessively large types
signed_type_for/unsigned_type_for will always succeed.
This patch fixes up the Fortran FE, so that even if there is no exact match
with a TYPE_PRECISION, if there is a wider type, the smallest of them will
be used.  The type_for_mode langhook on the other side must return a type
with the requested mode exactly, so if it uses gfc_type_for_size which now
can return wider type, it needs to check whether the returned type's
TYPE_MODE is the requested one.

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

2011-09-23  Jakub Jelinek  

* trans-types.c (gfc_type_for_size): Return wider type
if no suitable narrower type has been found.
(gfc_type_for_mode): Return NULL_TREE if gfc_type_for_size
returned type doesn't have expected TYPE_MODE.

--- gcc/fortran/trans-types.c.jj2011-09-05 12:28:53.0 +0200
+++ gcc/fortran/trans-types.c   2011-09-23 11:34:44.0 +0200
@@ -2791,18 +2791,29 @@ gfc_type_for_size (unsigned bits, int un
   if (bits == TYPE_PRECISION (intTI_type_node))
return intTI_type_node;
 #endif
+
+  if (bits <= TYPE_PRECISION (intQI_type_node))
+   return intQI_type_node;
+  if (bits <= TYPE_PRECISION (intHI_type_node))
+   return intHI_type_node;
+  if (bits <= TYPE_PRECISION (intSI_type_node))
+   return intSI_type_node;
+  if (bits <= TYPE_PRECISION (intDI_type_node))
+   return intDI_type_node;
+  if (bits <= TYPE_PRECISION (intTI_type_node))
+   return intTI_type_node;
 }
   else
 {
-  if (bits == TYPE_PRECISION (unsigned_intQI_type_node))
+  if (bits <= TYPE_PRECISION (unsigned_intQI_type_node))
 return unsigned_intQI_type_node;
-  if (bits == TYPE_PRECISION (unsigned_intHI_type_node))
+  if (bits <= TYPE_PRECISION (unsigned_intHI_type_node))
return unsigned_intHI_type_node;
-  if (bits == TYPE_PRECISION (unsigned_intSI_type_node))
+  if (bits <= TYPE_PRECISION (unsigned_intSI_type_node))
return unsigned_intSI_type_node;
-  if (bits == TYPE_PRECISION (unsigned_intDI_type_node))
+  if (bits <= TYPE_PRECISION (unsigned_intDI_type_node))
return unsigned_intDI_type_node;
-  if (bits == TYPE_PRECISION (unsigned_intTI_type_node))
+  if (bits <= TYPE_PRECISION (unsigned_intTI_type_node))
return unsigned_intTI_type_node;
 }
 
@@ -2823,7 +2834,10 @@ gfc_type_for_mode (enum machine_mode mod
   else if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
 base = gfc_complex_types;
   else if (SCALAR_INT_MODE_P (mode))
-return gfc_type_for_size (GET_MODE_PRECISION (mode), unsignedp);
+{
+  tree type = gfc_type_for_size (GET_MODE_PRECISION (mode), unsignedp);
+  return type != NULL_TREE && mode == TYPE_MODE (type) ? type : NULL_TREE;
+}
   else if (VECTOR_MODE_P (mode))
 {
   enum machine_mode inner_mode = GET_MODE_INNER (mode);

Jakub


Re: [C++ Patch] PR 50258

2011-09-23 Thread Jason Merrill

OK.

Jason


Re: [PATCH] v{extract,insert,broadcast,perm2}{i,f}128

2011-09-23 Thread Uros Bizjak
On Fri, Sep 23, 2011 at 4:47 PM, Jakub Jelinek  wrote:
>> >> I can surely do that (or e.g.
>> >> (define_mode_attr i128 [(V4DI "%~128") (V4DF "f128") ...])
>> >> and
>> >> "vextract\t{$0x1, %1, %0|%0, %1, 0x1}"
>> >> )
>> >> if you prefer it that way, but that is a functional alternative
>> >> to the patch I've just posted.  What I don't know how to express
>
>> Oh, and you can use  to set mode attribute statically.
>
> This patch implements that, bootstrapped/regtested on x86_64-linux
> and i686-linux, tested on SandyBridge additionally, eyeballed some
> -mavx2 assembly files.  Ok for trunk?
>
> 2011-09-23  Jakub Jelinek  
>
>        * config/i386/i386.c (ix86_print_operand): Handle %~.
>        (ix86_print_operand_punct_valid_p): Return true also for '~'.
>        * config/i386/sse.md (i128): New mode_attr.
>        (vec_extract_hi_, vec_extract_hi_,
>        avx_vbroadcastf128_, *avx_vperm2f128_full,
>        *avx_vperm2f128_nozero, vec_set_lo_,
>        vec_set_hi_, *vec_concat_avx): Use  in the
>        patterns, use "" for "mode" attribute.
>        (vec_extract_hi_v16hi, vec_extract_hi_v32qi, vec_set_lo_v16hi,
>        vec_set_hi_v16hi, vec_set_lo_v32qi, vec_set_hi_v32qi): Use
>        %~128 in the patterns, use "OI" for "mode" attribute.

OK.

Thanks,
Uros.


[Patch,AVR]: Fix PR50447 (3/n)

2011-09-23 Thread Georg-Johann Lay
This is the compare part to fix PR50447.

Just like the preceding changes to fix PR50447 it's a micro-optimization to
smarter print-out of instructions.

The patch covers comparisons against HI and SI integers.

The byte-wide comparison allows reusing the value in the scratch register and
individual treatment of zero.  Moreover, ADIW can be used in some rare 
situations.

And there is a bit of code clean-up.

Tested without regressions.

Ok to commit?

Johann

PR target/50447
* config/avr/avr.md (adjust_len): Add alternatives "tsthi",
"tstsi", "compare".
(*cmpqi_sign_extend): Use s8_operand.
(*cmphi, *cmpsi): Rewrite using avr_out_compare.
* config/avr/avr-protos.h (compare_diff_p, compare_eq_p): Remove
prototypes.
(out_tsthi, out_tstsi): Remove prototypes.
(avr_out_tsthi, avr_out_tstsi): New prototypes.
* config/avr/avr.c (out_tsthi, out_tstsi): Remove functions.
(avr_asm_len): Negative length now sets *plen to -length.
(compare_sign_p): Return bool instead of int.
(compare_diff_p, compare_eq_p): Ditto and make static.
(avr_out_tsthi): New function.
(avr_out_tstsi): New function.
(avr_out_compare): New function.
(adjust_insn_length): Handle ADJUST_LEN_TSTHI, ADJUST_LEN_TSTSI,
ADJUST_LEN_COMPARE.

Index: config/avr/avr.md
===
--- config/avr/avr.md	(revision 179116)
+++ config/avr/avr.md	(working copy)
@@ -136,7 +136,7 @@ (define_attr "length" ""
 ;; Otherwise do special processing depending on the attribute.
 
 (define_attr "adjust_len"
-  "yes,no,reload_in32,out_bitop"
+  "yes,no,reload_in32,out_bitop,tsthi,tstsi,compare"
   (const_string "yes"))
 
 ;; Define mode iterators
@@ -3328,125 +3328,62 @@ (define_insn "*cmpqi"
 
 (define_insn "*cmpqi_sign_extend"
   [(set (cc0)
-(compare (sign_extend:HI
-		  (match_operand:QI 0 "register_operand"  "d"))
-		 (match_operand:HI 1 "const_int_operand" "n")))]
-  "INTVAL (operands[1]) >= -128 && INTVAL (operands[1]) <= 127"
+(compare (sign_extend:HI (match_operand:QI 0 "register_operand" "d"))
+ (match_operand:HI 1 "s8_operand"   "n")))]
+  ""
   "cpi %0,lo8(%1)"
   [(set_attr "cc" "compare")
(set_attr "length" "1")])
 
 (define_insn "*cmphi"
   [(set (cc0)
-	(compare (match_operand:HI 0 "register_operand"  "!w,r,r,d,d,r,r")
-		 (match_operand:HI 1 "nonmemory_operand" "L,L,r,M,i,M,i")))
-   (clobber (match_scratch:QI 2 "=X,X,X,X,&d,&d,&d"))]
+(compare (match_operand:HI 0 "register_operand"  "!w,r,r,d ,r  ,d,r")
+ (match_operand:HI 1 "nonmemory_operand" "L ,L,r,s ,s  ,M,n")))
+   (clobber (match_scratch:QI 2 "=X ,X,X,&d,&d ,X,&d"))]
   ""
-  "*{
-  switch (which_alternative)
-{
-case 0: case 1:
-  return out_tsthi (insn, operands[0], NULL);
-
-case 2:
-  return (AS2 (cp,%A0,%A1) CR_TAB
-  AS2 (cpc,%B0,%B1));
-case 3:
-  if (reg_unused_after (insn, operands[0])
-  && INTVAL (operands[1]) >= 0 && INTVAL (operands[1]) <= 63
-  && test_hard_reg_class (ADDW_REGS, operands[0]))
-return AS2 (sbiw,%0,%1);
-   else
-return (AS2 (cpi,%0,%1) CR_TAB
-AS2 (cpc,%B0,__zero_reg__));
-case 4:
-  if (reg_unused_after (insn, operands[0]))
-return (AS2 (subi,%0,lo8(%1))  CR_TAB
-AS2 (sbci,%B0,hi8(%1)));
-  else
-return (AS2 (ldi, %2,hi8(%1))  CR_TAB
-	AS2 (cpi, %A0,lo8(%1)) CR_TAB
-	AS2 (cpc, %B0,%2));
-   case 5:
-  return (AS2 (ldi, %2,lo8(%1))  CR_TAB
-	  AS2 (cp, %A0,%2) CR_TAB
-	  AS2 (cpc, %B0,__zero_reg__));
-
-   case 6:
-  return (AS2 (ldi, %2,lo8(%1))  CR_TAB
-  AS2 (cp, %A0,%2)   CR_TAB
-  AS2 (ldi, %2,hi8(%1)) CR_TAB
-	  AS2 (cpc, %B0,%2));
-}
-  return \"bug\";
-}" 
-  [(set_attr "cc" "compare,compare,compare,compare,compare,compare,compare")
-   (set_attr "length" "1,2,2,2,3,3,4")])
+  {
+switch (which_alternative)
+  {
+  case 0:
+  case 1:
+return avr_out_tsthi (insn, operands, NULL);
+
+  case 2:
+return "cp %A0,%A1\;cpc %B0,%B1";
+
+  case 3:
+return reg_unused_after (insn, operands[0])
+   ? "subi %A0,lo8(%1)\;sbci %B0,hi8(%1)"
+   : "ldi %2,hi8(%1)\;cpi %A0,lo8(%1)\;cpc %B0,%2";
+   
+  case 4:
+return "ldi %2,lo8(%1)\;cp %A0,%2\;ldi %2,hi8(%1)\;cpc %B0,%2";
+  }
+  
+return avr_out_compare (insn, operands, NULL);
+  } 
+  [(set_attr "cc" "compare")
+   (set_attr "length" "1,2,2,3,4,2,4")
+   (set_attr "adjust_len" "tsthi,tsthi,no,no,no,compare,compare")])
 
 
 (define_insn "*cmpsi"
   [(set (cc0)
-	(compare (match_operand:SI 0 "register_operand"  "r,r,d,d,r,r")
-		 (match_operand:SI 1 "nonmemory_operand" "L,r,M,i,M,i")))
-   (clobber (match_scratch

Re: [patch, arm] Fix PR target/50305 (arm_legitimize_reload_address problem)

2011-09-23 Thread Ulrich Weigand
Michael Hope wrote:
> On Sat, Sep 10, 2011 at 5:04 AM, Ulrich Weigand  wrote:
> > the problem in PR 50305 turned out to be caused by the ARM back-end
> > LEGITIMIZE_RELOAD_ADDRESS implementation.
> 
> Interesting the fault goes away with -mfpu=neon, perhaps due to the DI
> mode operations getting pushed out into NEON registers.  You might
> want to be explicit about the FPU in dg-options.

Hmm, reload problems tend to be very difficult to reproduce in general,
everything need to line up just so ...   For some reason, I didn't see
the -mfpu=neon effect you describe; I'm seeing the reload failure with
that setting as well.

Nevertheless, I've updated the dg-options as suggested.  I've also added
a dg-skip-if line to prevent problems when using a -march multilib (as
currently discussed in other threads ...).

Richard/Ramana, any thoughts on this?  Is this OK?

Thanks,
Ulrich


ChangeLog:

gcc/
PR target/50305
* config/arm/arm.c (arm_legitimize_reload_address): Recognize
output of a previous pass through legitimize_reload_address.
Do not attempt to optimize addresses if the base register is
equivalent to a constant.

gcc/testsuite/
PR target/50305
* gcc.target/arm/pr50305.c: New test.


Index: gcc/testsuite/gcc.target/arm/pr50305.c
===
--- gcc/testsuite/gcc.target/arm/pr50305.c  (revision 0)
+++ gcc/testsuite/gcc.target/arm/pr50305.c  (revision 0)
@@ -0,0 +1,60 @@
+/* { dg-do compile } */
+/* { dg-skip-if "incompatible options" { arm*-*-* } { "-march=*" } { 
"-march=armv7-a" } } */
+/* { dg-options "-O2 -fno-omit-frame-pointer -marm -march=armv7-a -mfpu=vfp3" 
} */
+
+struct event {
+ unsigned long long id;
+ unsigned int flag;
+};
+
+void dummy(void)
+{
+  /* This is here to ensure that the offset of perf_event_id below
+ relative to the LANCHOR symbol exceeds the allowed displacement.  */
+  static int __warned[300];
+ __warned[0] = 1;
+}
+
+extern void *kmem_cache_alloc_trace (void *cachep);
+extern void *cs_cachep;
+extern int nr_cpu_ids;
+
+struct event *
+event_alloc (int cpu)
+{
+ static unsigned long long __attribute__((aligned(8))) perf_event_id;
+ struct event *event;
+ unsigned long long result;
+ unsigned long tmp;
+
+ if (cpu >= nr_cpu_ids)
+  return 0;
+
+ event = kmem_cache_alloc_trace (cs_cachep);
+
+ __asm__ __volatile__ ("dmb" : : : "memory");
+
+ __asm__ __volatile__("@ atomic64_add_return\n"
+"1:ldrexd  %0, %H0, [%3]\n"
+"  adds%0, %0, %4\n"
+"  adc %H0, %H0, %H4\n"
+"  strexd  %1, %0, %H0, [%3]\n"
+"  teq %1, #0\n"
+"  bne 1b"
+ : "=&r" (result), "=&r" (tmp), "+Qo" (perf_event_id)
+ : "r" (&perf_event_id), "r" (1LL)
+ : "cc");
+
+ __asm__ __volatile__ ("dmb" : : : "memory");
+
+ event->id = result;
+
+ if (cpu)
+  event->flag = 1;
+
+ for (cpu = 0; cpu < nr_cpu_ids; cpu++)
+   kmem_cache_alloc_trace (cs_cachep);
+
+ return event;
+}
+
Index: gcc/config/arm/arm.c
===
--- gcc/config/arm/arm.c(revision 179082)
+++ gcc/config/arm/arm.c(working copy)
@@ -6550,9 +6550,26 @@
   int opnum, int type,
   int ind_levels ATTRIBUTE_UNUSED)
 {
+  /* We must recognize output that we have already generated ourselves.  */
   if (GET_CODE (*p) == PLUS
+  && GET_CODE (XEXP (*p, 0)) == PLUS
+  && GET_CODE (XEXP (XEXP (*p, 0), 0)) == REG
+  && GET_CODE (XEXP (XEXP (*p, 0), 1)) == CONST_INT
+  && GET_CODE (XEXP (*p, 1)) == CONST_INT)
+{
+  push_reload (XEXP (*p, 0), NULL_RTX, &XEXP (*p, 0), NULL,
+  MODE_BASE_REG_CLASS (mode), GET_MODE (*p),
+  VOIDmode, 0, 0, opnum, (enum reload_type) type);
+  return true;
+}
+
+  if (GET_CODE (*p) == PLUS
   && GET_CODE (XEXP (*p, 0)) == REG
   && ARM_REGNO_OK_FOR_BASE_P (REGNO (XEXP (*p, 0)))
+  /* If the base register is equivalent to a constant, let the generic
+code handle it.  Otherwise we will run into problems if a future
+reload pass decides to rematerialize the constant.  */
+  && !reg_equiv_constant (ORIGINAL_REGNO (XEXP (*p, 0)))
   && GET_CODE (XEXP (*p, 1)) == CONST_INT)
 {
   HOST_WIDE_INT val = INTVAL (XEXP (*p, 1));



-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com


Re: Preserve callee cgraph edges when callgraph profiles sections are requested. (issue5101042)

2011-09-23 Thread Xinliang David Li
Martin,

thanks for the explanation.

I knew inliner did a good job of maintaining callgraph and profile
information, but did not know about removing dead edges etc.

However the situation you described (unwanted edges, post-ipa DCE
eliminating calls without updating cg etc) won't be a big issue for
Sri's use case as the edges that needed to be written to the note
section are those with non-zero count -- which means they are 'live'
and won't be eliminated.

However, making cg permanent would be even better :) -- there are
definitely other use cases (post-ipa) of it in the future.

thanks,

David


On Fri, Sep 23, 2011 at 7:49 AM, Martin Jambor  wrote:
> Hi,
>
> On Thu, Sep 22, 2011 at 04:24:47PM -0700, Xinliang David Li wrote:
>> ok for google branches.
>>
>> (Did a little digging -- the remove pass is added because ipa-inline
>> did not do a good job updating the call graph so there might be some
>> inconsistency. However the affinity information needs to be computed
>> after inline transformation, so some more work may be needed in the
>> future to fix those inconsistencies -- or perhaps rebuild cgraph edges
>> if profile-cgraph-section option is specified).
>
> the main reason why we remove all call graph edges at a few
> compilation points is that we do not keep them up to date when
> manipulating GIMPLE.  That for example means that when DCE eliminates
> a call statement, neither it nor the gimple infrastructure attempts to
> locate the associated call graph edge and remove it.  Similarly, when
> some form of propagation discovers a target of a call statement, it
> updates the statement but that does not bring the associated call
> graph edge (if it exists) from the indirect ones to the direct.
>
> Therefore, if call graph edges were kept, they could increasingly get
> out of sync with the gimple code which naturally might lead to all
> sorts of surprises.  The solution has so far been to re-calculate all
> the cgraph edges before they are needed and throw them away before
> doing intraprocedural optimization (mainly to avoid confusion).
>
> Inlining and all other IPA passes in fact update call graph edges
> meticulously because that is all they have in LTO.  The problem IIRC
> was that inlining was also supposed to remove the edges for the
> reasons described above but was not doing it consistently.  So it was
> moved to a different simple pass.
>
> Removing the edges allowed a quick initial implementation of the call
> graph and has certainly been good enough for a long time but recently
> people increasingly bump into limitations it poses so we might
> consider making them permanent now (or soon).  That is also what you
> may want because what you have with the patch is the state of the
> edges after inlining (which might be good enough, I admit I don't
> know).
>
> HTH,
>
> Martin
>
>>
>> David
>>
>> On Thu, Sep 22, 2011 at 4:01 PM, Sriraman Tallam  wrote:
>> > This patch preserves cgraph callee edges till pass_final if callgraph
>> > edge profiles sections are requested.  It also renames callgraph edge
>> > profile sections to be .gnu.callgraph instead of .note.callgraph
>> >
>> >
>> > Index: cgraphbuild.c
>> > ===
>> > --- cgraphbuild.c       (revision 179098)
>> > +++ cgraphbuild.c       (working copy)
>> > @@ -697,10 +697,18 @@ struct gimple_opt_pass pass_rebuild_cgraph_edges =
>> >  }
>> >  };
>> >
>> > +/* Defined in tree-optimize.c  */
>> > +extern bool cgraph_callee_edges_final_cleanup;
>> >
>> >  static unsigned int
>> >  remove_cgraph_callee_edges (void)
>> >  {
>> > +  /* The -fcallgraph-profiles-sections flag needs the call-graph preserved
>> > +     till pass_final.  */
>> > +  if (cgraph_callee_edges_final_cleanup
>> > +      && flag_callgraph_profiles_sections)
>> > +      return 0;
>> > +
>> >   cgraph_node_remove_callees (cgraph_node (current_function_decl));
>> >   return 0;
>> >  }
>> > Index: final.c
>> > ===
>> > --- final.c     (revision 179098)
>> > +++ final.c     (working copy)
>> > @@ -4425,10 +4425,11 @@ rest_of_handle_final (void)
>> >      profiling information. */
>> >   if (flag_callgraph_profiles_sections
>> >       && flag_profile_use
>> > -      && cgraph_node (current_function_decl) != NULL)
>> > +      && cgraph_node (current_function_decl) != NULL
>> > +      && (cgraph_node (current_function_decl))->callees != NULL)
>> >     {
>> >       flags = SECTION_DEBUG;
>> > -      asprintf (&profile_fnname, ".note.callgraph.text.%s", fnname);
>> > +      asprintf (&profile_fnname, ".gnu.callgraph.text.%s", fnname);
>> >       switch_to_section (get_section (profile_fnname, flags, NULL));
>> >       fprintf (asm_out_file, "\t.string \"Function %s\"\n", fnname);
>> >       dump_cgraph_profiles ();
>> > Index: testsuite/g++.dg/tree-prof/callgraph-profiles.C
>> > ===
>> > --- testsuit

Re: [Patch][Cilkplus] Change C++ testsuite extensions from CPP to CC

2011-09-23 Thread H.J. Lu
On Wed, Sep 21, 2011 at 11:51 AM, Iyer, Balaji V
 wrote:
> Hello Everyone,
>     This patch is for the Cilkplus branch.This patch will change the 
> cilk-plus testsuite file extensions from ".cpp" to ".cc". In addition, some 
> of the long filenames are shortened. The script file is also modified to 
> reflect this change.
>
> Thanks,
>

I checked it in.

-- 
H.J.


Re: [Patch,AVR]: Fix PR50447 (3/n)

2011-09-23 Thread Denis Chertykov
2011/9/23 Georg-Johann Lay :
> This is the compare part to fix PR50447.
>
> Just like the preceding changes to fix PR50447 it's a micro-optimization to
> smarter print-out of instructions.
>
> The patch covers comparisons against HI and SI integers.
>
> The byte-wide comparison allows reusing the value in the scratch register and
> individual treatment of zero.  Moreover, ADIW can be used in some rare 
> situations.
>
> And there is a bit of code clean-up.
>
> Tested without regressions.
>
> Ok to commit?
>
> Johann
>
>        PR target/50447
>        * config/avr/avr.md (adjust_len): Add alternatives "tsthi",
>        "tstsi", "compare".
>        (*cmpqi_sign_extend): Use s8_operand.
>        (*cmphi, *cmpsi): Rewrite using avr_out_compare.
>        * config/avr/avr-protos.h (compare_diff_p, compare_eq_p): Remove
>        prototypes.
>        (out_tsthi, out_tstsi): Remove prototypes.
>        (avr_out_tsthi, avr_out_tstsi): New prototypes.
>        * config/avr/avr.c (out_tsthi, out_tstsi): Remove functions.
>        (avr_asm_len): Negative length now sets *plen to -length.
>        (compare_sign_p): Return bool instead of int.
>        (compare_diff_p, compare_eq_p): Ditto and make static.
>        (avr_out_tsthi): New function.
>        (avr_out_tstsi): New function.
>        (avr_out_compare): New function.
>        (adjust_insn_length): Handle ADJUST_LEN_TSTHI, ADJUST_LEN_TSTSI,
>        ADJUST_LEN_COMPARE.
>

Please commit it with previous patch.

Denis.


[PATCH] Handle &__restrict parameters in tree-ssa-structalias.c like DECL_BY_REFERENCE parameters

2011-09-23 Thread Jakub Jelinek
Hi!

This simple patch improves the f3 function in the testcase below,
a parameter with TYPE_RESTRICT REFERENCE_TYPE IMHO can be safely treated
like the DECL_BY_REFERENCE case where the source actually didn't contain
a reference, but compiler created it anyway.  If source contains &__restrict
parameter, the parameter again points to a chunk of (for the function
global) restrict memory that nothing inside of the function should access
otherwise than through this parameter or pointers derived from it.

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

2011-09-23  Jakub Jelinek  

* tree-ssa-structalias.c (intra_create_variable_infos): Treat
TYPE_RESTRICT REFERENCE_TYPE parameters like restricted
DECL_BY_REFERENCE parameters.

* g++.dg/tree-ssa/restrict2.C: New test.

--- gcc/tree-ssa-structalias.c.jj   2011-09-15 12:18:37.0 +0200
+++ gcc/tree-ssa-structalias.c  2011-09-23 15:36:23.0 +0200
@@ -5589,10 +5589,11 @@ intra_create_variable_infos (void)
   varinfo_t p;
 
   /* For restrict qualified pointers to objects passed by
- reference build a real representative for the pointed-to object.  */
-  if (DECL_BY_REFERENCE (t)
- && POINTER_TYPE_P (TREE_TYPE (t))
- && TYPE_RESTRICT (TREE_TYPE (t)))
+ reference build a real representative for the pointed-to object.
+Treat restrict qualified references the same.  */
+  if (TYPE_RESTRICT (TREE_TYPE (t))
+ && ((DECL_BY_REFERENCE (t) && POINTER_TYPE_P (TREE_TYPE (t)))
+ || TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE))
{
  struct constraint_expr lhsc, rhsc;
  varinfo_t vi;
--- gcc/testsuite/g++.dg/tree-ssa/restrict2.C.jj2011-09-23 
16:11:27.0 +0200
+++ gcc/testsuite/g++.dg/tree-ssa/restrict2.C   2011-09-23 16:10:28.0 
+0200
@@ -0,0 +1,62 @@
+// { dg-do compile }
+// { dg-options "-O2 -fdump-tree-optimized" }
+
+struct S { int *__restrict p; int q; };
+S s;
+
+int
+f1 (S x, S y)
+{
+  x.p[0] = 1;
+  y.p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 1" 1 "optimized" } }
+  return x.p[0];
+}
+
+int
+f2 (S x)
+{
+  x.p[0] = 2;
+  s.p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 2" 1 "optimized" } }
+  return x.p[0];
+}
+
+int
+f3 (S &__restrict x, S &__restrict y)
+{
+  x.p[0] = 3;
+  y.p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 3" 1 "optimized" } }
+  return x.p[0];
+}
+
+int
+f4 (S &x, S &y)
+{
+  x.p[0] = 4;
+  y.p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 4" 0 "optimized" } }
+  return x.p[0];
+}
+
+int
+f5 (S *__restrict x, S *__restrict y)
+{
+  x->p[0] = 5;
+  y->p[0] = 0;
+// We might handle this some day
+// { dg-final { scan-tree-dump-times "return 5" 0 "optimized" } }
+  return x->p[0];
+}
+
+int
+f6 (S *x, S *y)
+{
+  x->p[0] = 6;
+  y->p[0] = 0;
+// { dg-final { scan-tree-dump-times "return 6" 0 "optimized" } }
+  return x->p[0];
+}
+
+// { dg-final { cleanup-tree-dump "optimized" } }

Jakub


Re: MIPS Fix PR18141

2011-09-23 Thread Dinar Temirbulatov
Hi,
I found typo in the patch instead of checking *set_after != 0 it was
set_after != 0,  here is corrected version of patch. I retested the
patch without typo on mipsel-unknown-linux-gnu with no new
regressions.
  thanks, Dinar.


On Fri, Sep 23, 2011 at 3:11 PM, Dinar Temirbulatov
 wrote:
> hi, Richard,
> This version of patch showed no regressions on mipsel-unknown-linux-gnu.
>                         Thanks, Dinar.
>
>
> On Wed, Sep 21, 2011 at 4:59 PM, Richard Sandiford
>  wrote:
>> Dinar Temirbulatov  writes:
>>> @@ -14696,7 +14696,11 @@ mips_avoid_hazard (rtx after, rtx insn,
>>>       clobber hi and lo.  */
>>>    if (*hilo_delay < 2 && reg_set_p (lo_reg, pattern))
>>>      nops = 2 - *hilo_delay;
>>> -  else if (*delayed_reg != 0 && reg_referenced_p (*delayed_reg, pattern))
>>> +  else if ((*delayed_reg != 0 && reg_referenced_p (*delayed_reg, pattern))
>>> +         && !((GET_MODE (*delayed_reg) == DFmode && set_after != 0
>>> +            && (set = single_set (insn)) != NULL_RTX && GET_MODE 
>>> (SET_DEST(set)) == DFmode
>>> +            && XINT((XEXP (pattern, 1)), 1) == UNSPEC_LOAD_HIGH
>>> +            && XINT((XEXP (*set_after, 1)), 1) == UNSPEC_LOAD_LOW)))
>>
>> This isn't safe because the patterns might not be UNSPECs (so XINT (...)
>> would be meaningless).  It's better to check the insn code instead.
>> Something like:
>>
>>  else if (*delayed_reg != 0
>>           && reg_referenced_p (*delayed_reg, pattern)
>>           && !(recog_memoized (insn) == CODE_FOR_load_highdf
>>                && recog_memoized (*set_after) == CODE_FOR_load_lowdf))
>>
>> (untested).  Note that *set_after should always be nonnull if
>> *delayed_reg is.
>>
>> Looks good otherwise.
>>
>> Richard
>>
>
diff -ruNp gcc-20110912-orig/gcc/config/mips/mips.c gcc-20110912-fixed/gcc/config/mips/mips.c
--- gcc-20110912-orig/gcc/config/mips/mips.c	2011-09-12 17:22:27.576457121 +0400
+++ gcc-20110912-fixed/gcc/config/mips/mips.c	2011-09-23 18:59:33.329771992 +0400
@@ -14659,20 +14659,20 @@ mips_orphaned_high_part_p (htab_t htab,
INSN and a previous instruction, avoid it by inserting nops after
instruction AFTER.
 
-   *DELAYED_REG and *HILO_DELAY describe the hazards that apply at
-   this point.  If *DELAYED_REG is non-null, INSN must wait a cycle
-   before using the value of that register.  *HILO_DELAY counts the
-   number of instructions since the last hilo hazard (that is,
-   the number of instructions since the last MFLO or MFHI).
+   *DELAYED_REG, *SET_AFTER and *HILO_DELAY describe the hazards that 
+   apply at this point.  If *DELAYED_REG and *SET_AFTER is non-null, 
+   INSN must wait a cycle before using the value of that register.  
+   *HILO_DELAY counts the number of instructions since the last hilo hazard 
+   (that is, the number of instructions since the last MFLO or MFHI).
 
-   After inserting nops for INSN, update *DELAYED_REG and *HILO_DELAY
-   for the next instruction.
+   After inserting nops for INSN, update *DELAYED_REG, *SET_AFTER
+   and *HILO_DELAY for the next instruction.
 
LO_REG is an rtx for the LO register, used in dependence checking.  */
 
 static void
 mips_avoid_hazard (rtx after, rtx insn, int *hilo_delay,
-		   rtx *delayed_reg, rtx lo_reg)
+		   rtx *delayed_reg, rtx lo_reg, rtx *set_after)
 {
   rtx pattern, set;
   int nops, ninsns;
@@ -14696,7 +14696,9 @@ mips_avoid_hazard (rtx after, rtx insn,
  clobber hi and lo.  */
   if (*hilo_delay < 2 && reg_set_p (lo_reg, pattern))
 nops = 2 - *hilo_delay;
-  else if (*delayed_reg != 0 && reg_referenced_p (*delayed_reg, pattern))
+  else if ((*delayed_reg != 0 && *set_after != 0 && reg_referenced_p (*delayed_reg, pattern))
+	&& !(recog_memoized (insn) == CODE_FOR_load_highdf
+	&& recog_memoized (*set_after) == CODE_FOR_load_lowdf))
 nops = 1;
   else
 nops = 0;
@@ -14710,6 +14712,7 @@ mips_avoid_hazard (rtx after, rtx insn,
   /* Set up the state for the next instruction.  */
   *hilo_delay += ninsns;
   *delayed_reg = 0;
+  *set_after = 0;
   if (INSN_CODE (insn) >= 0)
 switch (get_attr_hazard (insn))
   {
@@ -14724,6 +14727,7 @@ mips_avoid_hazard (rtx after, rtx insn,
 	set = single_set (insn);
 	gcc_assert (set);
 	*delayed_reg = SET_DEST (set);
+	*set_after = insn;
 	break;
   }
 }
@@ -14736,7 +14740,7 @@ mips_avoid_hazard (rtx after, rtx insn,
 static void
 mips_reorg_process_insns (void)
 {
-  rtx insn, last_insn, subinsn, next_insn, lo_reg, delayed_reg;
+  rtx insn, last_insn, subinsn, next_insn, lo_reg, delayed_reg, set_after;
   int hilo_delay;
   htab_t htab;
 
@@ -14811,7 +14815,7 @@ mips_reorg_process_insns (void)
 			INSN_CODE (subinsn) = CODE_FOR_nop;
 		  }
 		mips_avoid_hazard (last_insn, subinsn, &hilo_delay,
-   &delayed_reg, lo_reg);
+   &delayed_reg, lo_reg, &set_after);
 		  }
 	  last_insn = insn;
 	}
@@ -14832,7 +14836,7 @@ mips_reorg_process_insns (void)
 	  else
 		{
 		  mips_avoid_hazard (las

Re: Preserve callee cgraph edges when callgraph profiles sections are requested. (issue5101042)

2011-09-23 Thread Jan Hubicka
Hi,

> Martin,
> 
> thanks for the explanation.
> 
> I knew inliner did a good job of maintaining callgraph and profile
> information, but did not know about removing dead edges etc.

This was fixed with introduction of virtual clones, where the edges are still
needed post inlining.  We however do not maintain them longer.
It should not be that hard to do so - we already maintain EH tables on side
of the statements themselves, so one would just hook at the same places as EH
updating is done.
So far it was not neccesary.
> 
> However the situation you described (unwanted edges, post-ipa DCE
> eliminating calls without updating cg etc) won't be a big issue for
> Sri's use case as the edges that needed to be written to the note
> section are those with non-zero count -- which means they are 'live'
> and won't be eliminated.
> 
> However, making cg permanent would be even better :) -- there are
> definitely other use cases (post-ipa) of it in the future.

I would not be opposed to that, it just need some work ;)

Honza


Extend ipa-inline-analysis to recognize functoin/loop invariant parameters

2011-09-23 Thread Jan Hubicka
Hi,
this patch extends inliner's predicate infrastructure to track optimization
oppurtunities that depends on properties of call site parameters that are
not readilly available (and do not belong to) jump functions.

For this new inline_param_summary is introduced that is filled in
estimate_function_body_sizes used at predicate evaulation time and maintained
over inlining and cloning.

I now use it to track probability that parameter will change.  Probability
of 0 means invaraint values, while probabilities in range 1...REG_BR_PROB_BASE
means that parameter will be recomputed in between function calls with
the known probability.

The motivation for it comes from testcases like c-ray raytracer, where function
raysphere has two parameters (ray and sphere). It is called from loop that for
given ray iterates across all spheres in the scene.
Large benefits from inlining raysphere are due to fact that good portion of the
function is loop invariant and thus it is subsequentely lifted out of the loop
by PRE.

The patch splits NOT_CONSTANT predicate into NOT_CONSTANT and CHANGED.
NOT_CONSTANT is true always when parameters is not a know IP invaraint (in
sense of jump functions), while CHANGED is true when parameter change
probaiblity is >= 1 (i.e. it is not function level invariant). NOT_CONSTANT is
used when evaulating builtin_constant_p that is never true for loop invariant.
CHANGED is used when deciding whether given statment will be executed per
invocation of the particula rfunction call.  Moreover predicates can now be
evaulated into execution probablity that correspond to the probability of
parameter change.

As implemented now, the patch is good enough to analyze c-ray and work out that
raysphere is cool to inline, it however won't inline it because of the hard
size limits.

Some guesswork is obviously needed. Most magic is in param_change_prob and the
way it handles non-SSA parameters where it is quite non-obvious how much of code
motion will be possible after inlining.  Also predicate_probability can really
only evaulate simple predicated like (op0 changed) into op0's change 
probability.
It makes simple estiamtes so (op0 changed || op1 changed) is maximum of op0 and 
op1
change probability while (op0 changed && op1 changed) is minimum.
The second is quite rare, so this should work relatively well in practice.

There are other simple things I would like to add incrementally. I.e. tracking
whether parameter is address of automatic variable (and thus inlining likely
enables SRA).  This should help C++ inlining and move us closer to be able to
analyze fortran testcases.  Fortran is particularly difficult because most of
stuff is passed by reference and we will probably need to introduce jump 
functions
for values passed in aggregates and values passed by reference to understand
things like array descriptors.

The patch has little effect on spec2000 or our C++ benchmark suite at least
with current inline limits. Most tests are small enough so we usully do all
inlining allowed and thus saner priority queue makes little difference.  It
however helps some of Mozilla inner loops and increase amount of inlining done
there by about 8% while keeping same code size.

Bootstrapped/regtsted x86_64-linux.

Honza

* gcc.dg/ipa/inline-1.c: new testcase.
* gcc.dg/ipa/inline-2.c: new testcase.
* gcc.dg/ipa/inline-3.c: new testcase.
* gcc.dg/ipa/inline-4.c: new testcase.

* ipa-inline-transform.c (inline_call): Add comment.
* ipa-inline.h (inline_param_summary): New structure and vector.
(struct inline_edge_summary): Add param field.
* ipa-inline-analysis.c (CHANGED): New constant.
(add_clause): Handle CHANGED and NOT_CONSTANT.
(predicate_probability): New function.
(dump_condition): Dump CHANGED predicate.
(evaluate_conditions_for_known_args): Handle ERROR_MARK as marker
of unknown function wide invariant.
(evaluate_conditions_for_edge): Handle change probabilities.
(inline_edge_duplication_hook): Copy param summaries.
(inline_edge_removal_hook): Free param summaries.
(dump_inline_edge_summary): Fix dumping of indirect edges and callee 
sizes;
dump param summaries.
(will_be_nonconstant_predicate): Use CHANGED predicate.
(record_modified_bb_info): New structure.
(record_modified): New function.
(param_change_prob): New function.
(estimate_function_body_sizes): Compute param summaries.
(estimate_edge_size_and_time): Add probability argument.
(estimate_node_size_and_time): Add inline_param_summary argument;
handle predicate probabilities.
(remap_predicate): Fix formating.
(remap_edge_change_prob): New function.
(remap_edge_summaries): Rename from ...; use remap_edge_change_prob.
(remap_edge_predicates): ... this one.
(inline_merge_summary): Remap edge summaries; handle predicate 
prob

Re: Go patch committed: Update libgo to Go release r60

2011-09-23 Thread Ian Lance Taylor
Rainer Orth  writes:

> Unfortunately, the
>
> /vol/gcc/src/hg/trunk/local/libgo/syscalls/exec.go:11:14: error: imported and 
> not used: unsafe
>
> error remains.  I've no idea what triggers it.

Bother.  Neither do I.  I just looked through the code and it all looks
fine.  The reference to unsafe.Pointer will be parsed by
Parse::operand.  On one of the lines which uses unsafe.Pointer, it will
see "unsafe", see that it is a package, and call package->set_used().
That will set the flag which is later tested by Gogo::clear_file_scope
to prevent the warning.

I tried compiling the set of files which will be compiled on Solaris,
but still couldn't recreate the problem.

Ian


Re: Go patch committed: Update libgo to Go release r60

2011-09-23 Thread Rainer Orth
Ian Lance Taylor  writes:

> Rainer Orth  writes:
>
>> Unfortunately, the
>>
>> /vol/gcc/src/hg/trunk/local/libgo/syscalls/exec.go:11:14: error: imported 
>> and not used: unsafe
>>
>> error remains.  I've no idea what triggers it.
>
> Bother.  Neither do I.  I just looked through the code and it all looks
> fine.  The reference to unsafe.Pointer will be parsed by
> Parse::operand.  On one of the lines which uses unsafe.Pointer, it will
> see "unsafe", see that it is a package, and call package->set_used().
> That will set the flag which is later tested by Gogo::clear_file_scope
> to prevent the warning.
>
> I tried compiling the set of files which will be compiled on Solaris,
> but still couldn't recreate the problem.

Ok, I'll do some digging over the weekend.  Perhaps I can figure it out.

Thanks.
Rainer

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


Re: misbehaviour with md5_process_bytes and maybe in optimization

2011-09-23 Thread Ian Lance Taylor
Pierre Vittet  writes:

> Thanks for your interest,
>
> I just checked revision 179127 of GCC. Last revision is 177700, it has
> not been change for 6 weeks.
>
> My file is the same as this one:
> http://gcc.gnu.org/viewcvs/trunk/libiberty/md5.c?revision=177700&view=markup
>
> in libiberty/md5.c, function md5_process_bytes start line 203.
>
> On 23/09/2011 17:13, Ian Lance Taylor wrote:
>> Pierre Vittet  writes:
>> 
>>> The bug appears when:
>>> 1) We use libiberty compiled with -O0
>>> 2) We first call md5_process_bytes with a less than 64 bits buffer (we
>>> call his size len1).
>>> 3) We make a new call of md5_process_bytes with a buffer which has a
>>> size len2 such as:
>>> len2 > 127 + 65 (so test in line 228 of md5.C will be true)
> line 228 is the following:if (len > 64)
>>> 128 -len1 != Mulint with Mulint %  __alignof__ (md5_uint32) != 0 (so
>>> condition on line 238 is true)
> line 238 is the following: if (UNALIGNED_P (buffer))
>>> len2 - (128 - len1) = Mul64 and Mul64 such as Mul %64=0 (so the loop of
>>> line 239 is broken with len = 64, this leads to the bug as, line 249,
>>> (len & ~63) = 64 and we shift the buffer without processing the data).
>
> line 239 is the following: while (len > 64)
> line 249: buffer = (const void *) ((const char *) buffer + (len & ~63));
>> 
>> The line numbers you mention do not correspond to any version of
>> libiberty/md5.c that I can see.  Can you list the exact line for each
>> line number you mention, so that your explanation is easier to follow?
>> Thanks.
>
> I give about the same explanation in the README (which is in the
> attached archive of my previous mail) but I does not use line number but
> direct quote of the code. It mights be more easy to try the plugin with
> gdb but it needs to compile libiberty.a with -O0.

Thanks, I think I have it sorted out now.

It does not happen on x86 glibc-based systems at -O2 because at -O2
 #defines STRING_ARCH_unaligned, so the problematic code is
not compiled or executed.

The error was introduced by this change:

2005-07-03  Steve Ellcey  

PR other/13906
* md5.c (md5_process_bytes): Check alignment.

Thanks for noticing this problem, analyzing it, and reporting it.

I committed this patch to mainline to fix the problem.  Bootstrapped on
x86_64-unknown-linux-gnu.

Ian


2011-09-23  Ian Lance Taylor  

* md5.c (md5_process_bytes): Correct handling of unaligned
buffer.


Index: md5.c
===
--- md5.c	(revision 179127)
+++ md5.c	(working copy)
@@ -1,6 +1,6 @@
 /* md5.c - Functions to compute MD5 message digest of files or memory blocks
according to the definition of MD5 in RFC 1321 from April 1992.
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2011 Free Software Foundation, Inc.
 
NOTE: This source is derived from an old version taken from the GNU C
Library (glibc).
@@ -245,9 +245,11 @@ md5_process_bytes (const void *buffer, s
   }
   else
 #endif
-  md5_process_block (buffer, len & ~63, ctx);
-  buffer = (const void *) ((const char *) buffer + (len & ~63));
-  len &= 63;
+	{
+	  md5_process_block (buffer, len & ~63, ctx);
+	  buffer = (const void *) ((const char *) buffer + (len & ~63));
+	  len &= 63;
+	}
 }
 
   /* Move remaining bytes in internal buffer.  */


Re: [PATCH][config]Add missing crt*.o in start and end file specs for linux-android.h

2011-09-23 Thread 關振德
ping?

On Thu, Aug 25, 2011 at 5:44 PM, Doug Kwan (關振德)  wrote:
> Hi,
>
>    We received this from Intel and would like to check in the trunk.
> Could the maintainers of gcc/config take a look?
>
> Thanks.
>
> -Doug
>
>
> 2011-08-25  Mark D Horn 
>
>        config/linux-android.h (ANDROID_STARTFILE_SPEC, ANDROID_ENDFILE_SPEC):
>        Add missing crt*.o objects for shared building a library.
>


Re: [patch] Allow not simple ivs in SLP

2011-09-23 Thread Richard Guenther
On Wed, Sep 14, 2011 at 2:01 PM, Ira Rosen  wrote:
> Hi,
>
> This patch makes data-refs analysis to not fail if simple_iv returns
> false in basic block SLP.
>
> Bootstrapped and tested on powerpc64-suse-linux.
> OK for mainline?

Ok if you instead of wrapping dr_analyze_innermost change the remaining
callers to pass the loop nest parameter instead.

Thanks,
Richard.

> Thanks,
> Ira
>
> ChangeLog:
>
>     * tree-data-ref.c (dr_analyze_innermost): Rename to...
>     (dr_analyze_innermost_1): ... this.  Add new argument.
>     Allow not simple iv if analyzing basic block.
>     (dr_analyze_innermost): Call dr_analyze_innermost_1.
>     (create_data_ref): Call dr_analyze_innermost_1.
>
> testsuite/ChangeLog:
>
>     * gcc.dg/vect/bb-slp-24.c: New test.
>
> Index: tree-data-ref.c
> ===
> --- tree-data-ref.c     (revision 178755)
> +++ tree-data-ref.c     (working copy)
> @@ -722,11 +722,11 @@ canonicalize_base_object_address (tree addr)
>  }
>
>  /* Analyzes the behavior of the memory reference DR in the innermost loop or
> -   basic block that contains it. Returns true if analysis succeed or false
> +   basic block that contains it.  Returns true if analysis succeed or false
>    otherwise.  */
>
> -bool
> -dr_analyze_innermost (struct data_reference *dr)
> +static bool
> +dr_analyze_innermost_1 (struct data_reference *dr, struct loop *nest)
>  {
>   gimple stmt = DR_STMT (dr);
>   struct loop *loop = loop_containing_stmt (stmt);
> @@ -769,14 +769,25 @@ canonicalize_base_object_address (tree addr)
>     }
>   else
>     base = build_fold_addr_expr (base);
> +
>   if (in_loop)
>     {
>       if (!simple_iv (loop, loop_containing_stmt (stmt), base, &base_iv,
>                       false))
>         {
> -          if (dump_file && (dump_flags & TDF_DETAILS))
> -           fprintf (dump_file, "failed: evolution of base is not affine.\n");
> -          return false;
> +          if (nest)
> +            {
> +              if (dump_file && (dump_flags & TDF_DETAILS))
> +               fprintf (dump_file, "failed: evolution of base is not"
> +                                    " affine.\n");
> +                return false;
> +            }
> +          else
> +            {
> +              base_iv.base = base;
> +              base_iv.step = ssize_int (0);
> +              base_iv.no_overflow = true;
> +            }
>         }
>     }
>   else
> @@ -801,10 +812,18 @@ canonicalize_base_object_address (tree addr)
>       else if (!simple_iv (loop, loop_containing_stmt (stmt),
>                            poffset, &offset_iv, false))
>         {
> -          if (dump_file && (dump_flags & TDF_DETAILS))
> -            fprintf (dump_file, "failed: evolution of offset is not"
> -                                " affine.\n");
> -          return false;
> +          if (nest)
> +            {
> +              if (dump_file && (dump_flags & TDF_DETAILS))
> +                fprintf (dump_file, "failed: evolution of offset is not"
> +                                    " affine.\n");
> +              return false;
> +            }
> +          else
> +            {
> +              offset_iv.base = poffset;
> +              offset_iv.step = ssize_int (0);
> +            }
>         }
>     }
>
> @@ -832,6 +851,19 @@ canonicalize_base_object_address (tree addr)
>   return true;
>  }
>
> +/* Analyzes the behavior of the memory reference DR in the innermost loop or
> +   basic block that contains it.  Returns true if analysis succeed or false
> +   otherwise.  */
> +
> +bool
> +dr_analyze_innermost (struct data_reference *dr)
> +{
> +  gimple stmt = DR_STMT (dr);
> +  struct loop *loop = loop_containing_stmt (stmt);
> +
> +  return dr_analyze_innermost_1 (dr, loop);
> +}
> +
>  /* Determines the base object and the list of indices of memory reference
>    DR, analyzed in LOOP and instantiated in loop nest NEST.  */
>
> @@ -972,7 +1004,7 @@ create_data_ref (loop_p nest, loop_p loop, tree me
>   DR_REF (dr) = memref;
>   DR_IS_READ (dr) = is_read;
>
> -  dr_analyze_innermost (dr);
> +  dr_analyze_innermost_1 (dr, nest);
>   dr_analyze_indices (dr, nest, loop);
>   dr_analyze_alias (dr);
>
> Index: testsuite/gcc.dg/vect/bb-slp-24.c
> ===
> --- testsuite/gcc.dg/vect/bb-slp-24.c   (revision 0)
> +++ testsuite/gcc.dg/vect/bb-slp-24.c   (revision 0)
> @@ -0,0 +1,55 @@
> +/* { dg-require-effective-target vect_int } */
> +
> +#include 
> +#include "tree-vect.h"
> +
> +#define A 3
> +#define N 256
> +
> +short src[N], dst[N];
> +
> +void foo (short * __restrict dst, short * __restrict src, int h, int stride)
> +{
> +    int i;
> +    h /= 8;
> +    for (i = 0; i < h; i++) {
> +        dst[0] += A*src[0];
> +        dst[1] += A*src[1];
> +        dst[2] += A*src[2];
> +        dst[3] += A*src[3];
> +        dst[4] += A*src[4];
> +        dst[5] += A*src[5];
> +        dst[6] += A*src[6];
> +        dst[7] +

Re: [patch] Fix PR tree-optimization/50412

2011-09-23 Thread Richard Guenther
On Sun, Sep 18, 2011 at 11:00 AM, Ira Rosen  wrote:
> Hi,
>
> Strided accesses of single element or with gaps may require creation
> of epilogue loop. At the moment we don't support peeling for outer
> loops, therefore, we should not allow such strided accesses in outer
> loops.
>
> Bootstrapped and tested on powerpc64-suse-linux.
> Committed to trunk.
>
> Now testing for 4.6.
> OK for 4.6 when the testing completes?

Ok.

Thanks,
Richard.

> Thanks,
> Ira
>
> ChangeLog:
>
>        PR tree-optimization/50412
>        * tree-vect-data-refs.c (vect_analyze_group_access): Fail for
>        acceses that require epilogue loop if vectorizing outer loop.
>
> testsuite/ChangeLog:
>
>        PR tree-optimization/50412
>        * gfortran.dg/vect/pr50412.f90: New.
>
>
>
> Index: tree-vect-data-refs.c
> ===
> --- tree-vect-data-refs.c       (revision 178939)
> +++ tree-vect-data-refs.c       (working copy)
> @@ -2060,7 +2060,11 @@ vect_analyze_group_access (struct data_reference *
>   HOST_WIDE_INT dr_step = TREE_INT_CST_LOW (step);
>   HOST_WIDE_INT stride, last_accessed_element = 1;
>   bool slp_impossible = false;
> +  struct loop *loop = NULL;
>
> +  if (loop_vinfo)
> +    loop = LOOP_VINFO_LOOP (loop_vinfo);
> +
>   /* For interleaving, STRIDE is STEP counted in elements, i.e., the
> size of the
>      interleaving group (including gaps).  */
>   stride = dr_step / type_size;
> @@ -2090,11 +2094,18 @@ vect_analyze_group_access (struct data_reference *
>
>          if (loop_vinfo)
>            {
> -             LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true;
> -
>              if (vect_print_dump_info (REPORT_DETAILS))
>                fprintf (vect_dump, "Data access with gaps requires scalar "
>                                    "epilogue loop");
> +              if (loop->inner)
> +                {
> +                  if (vect_print_dump_info (REPORT_DETAILS))
> +                    fprintf (vect_dump, "Peeling for outer loop is not"
> +                                        " supported");
> +                  return false;
> +                }
> +
> +              LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true;
>            }
>
>          return true;
> @@ -2277,10 +2288,17 @@ vect_analyze_group_access (struct data_reference *
>       /* There is a gap in the end of the group.  */
>       if (stride - last_accessed_element > 0 && loop_vinfo)
>        {
> -         LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true;
>          if (vect_print_dump_info (REPORT_DETAILS))
>            fprintf (vect_dump, "Data access with gaps requires scalar "
>                                "epilogue loop");
> +          if (loop->inner)
> +            {
> +              if (vect_print_dump_info (REPORT_DETAILS))
> +                fprintf (vect_dump, "Peeling for outer loop is not 
> supported");
> +              return false;
> +            }
> +
> +          LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true;
>        }
>     }
> Index: testsuite/gfortran.dg/vect/pr50412.f90
> ===
> --- testsuite/gfortran.dg/vect/pr50412.f90      (revision 0)
> +++ testsuite/gfortran.dg/vect/pr50412.f90      (revision 0)
> @@ -0,0 +1,12 @@
> +! { dg-do compile }
> +
> +      DOUBLE PRECISION AK,AI,AAE
> +      COMMON/com/AK(36),AI(4,4),AAE(8,4),ii,jj
> +      DO 20 II=1,4
> +        DO 21 JJ=1,4
> +          AK(n)=AK(n)-AAE(I,II)*AI(II,JJ)
> +   21   CONTINUE
> +   20 CONTINUE
> +      END
> +
> +! { dg-final { cleanup-tree-dump "vect" } }
>


Re: [PATCH] GNU/kFreeBSD systems running on MIPS

2011-09-23 Thread Robert Millan
Hi there,

2011/8/17 Rainer Orth :
> Hi Robert,
>
>> My patch still applies cleanly to current HEAD, has this migration
>> happened already?  If not, what's the current ETA?  I'll have almost
>> no spare time after this week, I'd like to sort this out before/during
>> the weekend if possible.
>
> all the relevant patches have been posted by now.  One needs a bit work,
> the others are awaiting review.

Is there any news about this?

-- 
Robert Millan


Re: Ping: [libiberty patch] Add demangler support for cloned function symbols (PR 40831)

2011-09-23 Thread Cary Coutant
> This patch is OK, with or without the testsuite additions Jakub
> mentions.

Thanks, I added the new tests, and tweaked the clone suffix parsing to
allow the leading "_".

Committed as r179132.

-cary


[lra] patch mostly to simplify work with bound pseudos.

2011-09-23 Thread Vladimir Makarov
The following pretty big patch is to remove complicated support of bound 
pseudos (pseudos which should be always assigned to the same location).  
It should make code more clear and speed LRA up.


The patch also
 o improves inheritance by fixes some typos and using attribute value 
(instead of just original regno) to ignore some conflicts.
 o fixes an arm bug by implementing matching more one input operands to 
an output operand in one alternative.

 o fixes ppc64 SPEC2000 sixtrack build failure.
 o makes other different changes for speeding LRA up.

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

2011-09-23  Vladimir Makarov 

* ira-int.h (struct target_ira_int): Remove
x_ira_reg_classes_intersect_p.
(ira_reg_classes_intersect_p): Remove.

* ira.h (struct target_ira): Add x_ira_reg_classes_intersect_p.
(ira_reg_classes_intersect_p): New macro.

* lra-int.h (struct lra_reg): Remove members first and next.  Add
restore_regno and val.
(lra_create_new_reg_with_unique_value): New.
(lra_set_regno_unique_value): New.
(lra_update_dup): Change prototype.
(lra_dont_inherit_pseudos): Remove.
(lra_matched_pseudos, lra_bound_pseudos): Remove.
(lra_update_dup): New function.

* lra.c (get_new_reg_value): New function.
(lra_create_new_reg_with_unique_value): Extract from ...
(lra_create_new_reg): Set up value from the pseudo.
(lra_set_regno_unique_value): New function.
(lra_update_dups): Use array as nops.
(last_reg_value): New static variable.
(init_reg_info): Initialize it.  Initialize restore_regno and val
for pseudos.
(expand_reg_info): Initialize restore_regno and val
for new pseudos.
(lra_bind_pseudos, lra_bound_pseudo_freq): Remove.
(remove_scratches): Use lra_update_dup instead of lra_update_dups.
(lra): Use lra_constraint_iter instead of first.  Clear
lra_matched_pseudos after the spill subpass.  Clear
lra_inheritance_pseudos before the spill subpass. Remove code with
lra_dont_inherit_pseudos.

* lra-spills.c (regno_freq_compare): Don't use
lra_bound_pseudo_freq.
(assign_stack_slot_num_and_sort_pseudos): Remove processing bound
pseudos.
(lra_spill): Ditto.  Use lra_update_dup instead of
lra_update_dups.

* lra-lives.c (process_bb_lives): Check lra_bound_pseudos for
subreg dying.

* lra-coalesce.c (lra_coalesce): Check lra_bound_pseudos instead
of lra_reg_info.

* lra-constraints.c (new_insn_uid_start): New static variable.
(get_reg_class): Don't check lra_inheritance_pseudos.
(in_class_p): Ditto.  Check new_insn_uid_start instead.
(change_class): Remove processing bound pseudos.
(lra_dont_inherit_pseudos): Rename to lra_matched_pseudos.
(lra_bound_pseudos): New global var.
(match_reload): Change prototype by using array of inputs.  Don't
create bound pseudos.  Set up lra_bound_pseudos instead.  Use
lra_create_new_reg_with_unique_value instead of
lra_create_new_reg.  Use lra_update_dup for output.
(check_and_process_move): Don't check lra_inheritance_pseudos.
(curr_insn_transform): Make goal_alt_matched as two-dimensional
array.  Use lra_update_dup instead of lra_update_dups.  Use
lra_set_regno_unique_value instead of setting
lra_dont_inherit_pseudos.
(lra_constraints): Initialize new_insn_uid_start.
(lra_constraints_init): Initialize lra_bound_pseudos.
(lra_constraints_finish): Clear lra_bound_pseudos.
(inherit_reload_reg): Set up restore_regno.  Inherit only spilled
pseudos.
(remove_inheritance_pseudos): Extract from ...
(lra_undo_inheritance): Clear and use restore_regno.

* lra-assigns.c (get_biggest_bound_mode_pseudo): Remove.
(get_biggest_bound_mode): Ditto.
(regno_allocno_class_array): New.
(reload_pseudo_compare_func, pseudo_compare_func): Use it.
(update_lives): Remove processing bound pseudos.
(get_allocation_profit): Remove.
(find_hard_regno_for): Remove processing bound pseudos.  Look only
at intersected class pseudos.  Use pseudo values for conflicts.
Use regno_allocno_class_array.
(lra_setup_reg_renumber): Remove processing bound pseudos.
(setup_try_hard_regno_pseudos): Don't use first bound pseudos.
(assign_temporarily): Remove processing bound pseudos.
(spill_for): Ditto.  Use regno_allocno_class_array.
(setup_live_pseudos_and_spill_after_equiv_moves): Remove
processing bound pseudos.  Use pseudo values for conflicts.
(assign_by_spills): Remove processing bound pseudos. Don't assign
hard registers to pseudos whose inheritance pseudos did not get a
hard register.  Use regno_allocno_class_array.
(lra_assign): Allocate, free, and initialize
regno_allocno_class_array.  Ignore spilling inheritance pseudos as
a change.

* emit-rtl.c (validate_subreg): Make any fp-mode subreg valid for LRA.




bound-pseudos.patch.gz
Description: GNU Zip compressed data


Re: Ping: [libiberty patch] Add demangler support for cloned function symbols (PR 40831)

2011-09-23 Thread Cary Coutant
>> This patch is OK, with or without the testsuite additions Jakub
>> mentions.
>
> Thanks, I added the new tests, and tweaked the clone suffix parsing to
> allow the leading "_".
>
> Committed as r179132.

Should I backport this patch to gcc-4_6-branch?

-cary


[google] Linker plugin to do function reordering using callgraph edge profiles (issue5124041)

2011-09-23 Thread Sriraman Tallam
This patch adds a new linker plugin to re-order functions.  The plugin 
constructs an annotated callgraph with edge profile information and then 
repeatedly groups sections that are connected by  hot edges and passes the new 
function layout to the linker.  The grouping is done similar to the Pettis 
Hansen procedure ordering scheme. 

I had earlier reverted a patch for a plugin that was written in C++. I have 
re-written the same plugin in C.

How to use the plugin:

During Profile use build stage of Feedback-directed builds, use the flags:
-fcallgraph-profiles-sections
-Wl,--plugin,/libfunction_reordering_plugin.so

The first flag generates special .gnu.callgraph.text sections which contain the 
callgraph profiles that are read by the plugin and an new function layout is 
generated. The ordering of sections is dumped in file final_layout.txt along 
with the callgraph edge profile information.

The plugin itself is implemented in the three files: 
function_ordering_plugin.c, callgraph.c, and callgraph.h. The file 
include/plugin-api.h has changes which has already been submitted to trunk. The 
rest is related to Makefiles and configure scripts to build and install the 
plugin. I have not attached any of the auto-generated files.


Index: configure.ac
===
--- configure.ac(revision 178891)
+++ configure.ac(working copy)
@@ -1738,6 +1738,8 @@
 
 ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
   build_lto_plugin=yes
+  # Allow ELF platforms to build the function_reordering_plugin always.
+  build_function_reordering_plugin=yes
 ],[if test x"$default_enable_lto" = x"yes" ; then
 case $target in
   *-apple-darwin9 | *-cygwin* | *-mingw*) ;;
@@ -1865,6 +1867,11 @@
   extra_host_libiberty_configure_flags=--enable-shared
 fi
   fi
+  if test "${build_function_reordering_plugin}" = "yes" ; then
+configdirs="$configdirs function_reordering_plugin"
+extra_host_libiberty_configure_flags=--enable-shared
+  fi
+
   AC_SUBST(extra_host_libiberty_configure_flags)
 
   missing_languages=`echo ",$enable_languages," | sed -e s/,all,/,/ -e 
s/,c,/,/ `
Index: include/plugin-api.h
===
--- include/plugin-api.h(revision 178891)
+++ include/plugin-api.h(working copy)
@@ -93,6 +93,14 @@
   int resolution;
 };
 
+/* An object's section.  */
+
+struct ld_plugin_section
+{
+  const void* handle;
+  unsigned int shndx;
+};
+
 /* Whether the symbol is a definition, reference, or common, weak or not.  */
 
 enum ld_plugin_symbol_kind
@@ -203,6 +211,10 @@
 (*ld_plugin_get_input_file) (const void *handle,
  struct ld_plugin_input_file *file);
 
+typedef
+enum ld_plugin_status
+(*ld_plugin_get_view) (const void *handle, const void **viewp);
+
 /* The linker's interface for releasing the input file.  */
 
 typedef
@@ -240,6 +252,65 @@
 enum ld_plugin_status
 (*ld_plugin_message) (int level, const char *format, ...);
 
+/* The linker's interface for retrieving the number of sections in an object.
+   The handle is obtained in the claim_file handler.  This interface should
+   only be invoked in the claim_file handler.   This function sets *COUNT to
+   the number of sections in the object.  */
+
+typedef
+enum ld_plugin_status
+(*ld_plugin_get_input_section_count) (const void* handle, unsigned int *count);
+
+/* The linker's interface for retrieving the section type of a specific
+   section in an object.  This interface should only be invoked in the
+   claim_file handler.  This function sets *TYPE to an ELF SHT_xxx value.  */
+
+typedef
+enum ld_plugin_status
+(*ld_plugin_get_input_section_type) (const struct ld_plugin_section section,
+ unsigned int *type);
+
+/* The linker's interface for retrieving the name of a specific section in
+   an object. This interface should only be invoked in the claim_file handler.
+   This function sets *SECTION_NAME_PTR to a null-terminated buffer allocated
+   by malloc.  The plugin must free *SECTION_NAME_PTR.  */
+
+typedef
+enum ld_plugin_status
+(*ld_plugin_get_input_section_name) (const struct ld_plugin_section section,
+ char **section_name_ptr);
+
+/* The linker's interface for retrieving the contents of a specific section
+   in an object.  This interface should only be invoked in the claim_file
+   handler.  This function sets *SECTION_CONTENTS to point to a buffer that is
+   valid until clam_file handler returns.  It sets *LEN to the size of the
+   buffer.  */
+
+typedef
+enum ld_plugin_status
+(*ld_plugin_get_input_section_contents) (const struct ld_plugin_section 
section,
+ const unsigned char 
**section_contents,
+ size_t* len);
+
+/* The linker's interface for specifying the desired order of sections.
+   The se

C++ PATCH for core issue 253: const objects and explicit initializers

2011-09-23 Thread Jason Merrill
Issue 253 was raised in 2000, but was considered low priority at the 
time; it pointed out that classes with no actual data don't really need 
an initializer, so we shouldn't require one.  This becomes more 
important now that we have non-static data member initializers that can 
initialize all the members without a user-provided constructor.


Tested x86_64-pc-linux-gnu, applied to trunk.  I'm also considering 
applying it to 4.6 since we got more strict about the pre-253 rule in 4.6.
commit f8bbf6bb2853ef073807b5e275fa40edae3d8aa0
Author: Jason Merrill 
Date:   Thu Sep 15 17:15:34 2011 -0400

	Core 253 - allow const objects with no initializer or
	user-provided default constructor if the defaulted constructor
	initializes all the subobjects.
	PR c++/20039
	PR c++/42844
	* class.c (default_init_uninitialized_part): New.
	* cp-tree.h: Declare it.
	* decl.c (check_for_uninitialized_const_var): Use it.
	* init.c (perform_member_init): Likewise.
	(build_new_1): Likewise.
	* method.c (walk_field_subobs): Likewise.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index e398416..1887526 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -4356,6 +4356,40 @@ type_has_user_provided_default_constructor (tree t)
   return false;
 }
 
+/* If default-initialization leaves part of TYPE uninitialized, returns
+   a DECL for the field or TYPE itself (DR 253).  */
+
+tree
+default_init_uninitialized_part (tree type)
+{
+  tree t, r, binfo;
+  int i;
+
+  type = strip_array_types (type);
+  if (!CLASS_TYPE_P (type))
+return type;
+  if (type_has_user_provided_default_constructor (type))
+return NULL_TREE;
+  for (binfo = TYPE_BINFO (type), i = 0;
+   BINFO_BASE_ITERATE (binfo, i, t); ++i)
+{
+  r = default_init_uninitialized_part (BINFO_TYPE (t));
+  if (r)
+	return r;
+}
+  for (t = TYPE_FIELDS (type); t; t = DECL_CHAIN (t))
+if (TREE_CODE (t) == FIELD_DECL
+	&& !DECL_ARTIFICIAL (t)
+	&& !DECL_INITIAL (t))
+  {
+	r = default_init_uninitialized_part (TREE_TYPE (t));
+	if (r)
+	  return DECL_P (r) ? r : t;
+  }
+
+  return NULL_TREE;
+}
+
 /* Returns true iff for class T, a trivial synthesized default constructor
would be constexpr.  */
 
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index bcfc3b3..573c166 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4838,6 +4838,7 @@ extern tree in_class_defaulted_default_constructor (tree);
 extern bool user_provided_p			(tree);
 extern bool type_has_user_provided_constructor  (tree);
 extern bool type_has_user_provided_default_constructor (tree);
+extern tree default_init_uninitialized_part (tree);
 extern bool trivial_default_constructor_is_constexpr (tree);
 extern bool type_has_constexpr_default_constructor (tree);
 extern bool type_has_virtual_destructor		(tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 709deca..495d8a0 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4899,15 +4899,16 @@ check_for_uninitialized_const_var (tree decl)
   if (TREE_CODE (decl) == VAR_DECL
   && TREE_CODE (type) != REFERENCE_TYPE
   && CP_TYPE_CONST_P (type)
-  && (!TYPE_NEEDS_CONSTRUCTING (type)
-	  || !type_has_user_provided_default_constructor (type))
   && !DECL_INITIAL (decl))
 {
+  tree field = default_init_uninitialized_part (type);
+  if (!field)
+	return;
+
   permerror (DECL_SOURCE_LOCATION (decl),
 		 "uninitialized const %qD", decl);
 
-  if (CLASS_TYPE_P (type)
-	  && !type_has_user_provided_default_constructor (type))
+  if (CLASS_TYPE_P (type))
 	{
 	  tree defaulted_ctor;
 
@@ -4918,6 +4919,8 @@ check_for_uninitialized_const_var (tree decl)
 	inform (DECL_SOURCE_LOCATION (defaulted_ctor),
 		"constructor is not user-provided because it is "
 		"explicitly defaulted in the class body");
+	  inform (0, "and the implicitly-defined constructor does not "
+		  "initialize %q+#D", field);
 	}
 }
 }
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index ff1884b..68d4e68 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -579,7 +579,7 @@ perform_member_init (tree member, tree init)
 	flags |= LOOKUP_DEFAULTED;
 	  if (CP_TYPE_CONST_P (type)
 	  && init == NULL_TREE
-	  && !type_has_user_provided_default_constructor (type))
+	  && default_init_uninitialized_part (type))
 	/* TYPE_NEEDS_CONSTRUCTING can be set just because we have a
 	   vtable; still give this diagnostic.  */
 	permerror (DECL_SOURCE_LOCATION (current_function_decl),
@@ -2088,7 +2088,7 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts,
 }
 
   if (CP_TYPE_CONST_P (elt_type) && *init == NULL
-  && !type_has_user_provided_default_constructor (elt_type))
+  && default_init_uninitialized_part (elt_type))
 {
   if (complain & tf_error)
 error ("uninitialized const in % of %q#T", elt_type);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 5b24f8f..757e711 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ 

Go patch committed: Better parses

2011-09-23 Thread Ian Lance Taylor
This patch to the Go frontend improves the parsing of a non-identifier
on the left hand side of :=, and of a non-type in a type switch.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r ffdb8cbbc880 go/parse.cc
--- a/go/parse.cc	Fri Sep 23 08:28:44 2011 -0700
+++ b/go/parse.cc	Fri Sep 23 14:51:52 2011 -0700
@@ -3506,7 +3506,21 @@
   else if (return_exp != NULL)
 return this->verify_not_sink(exp);
   else
-this->expression_stat(this->verify_not_sink(exp));
+{
+  exp = this->verify_not_sink(exp);
+
+  if (token->is_op(OPERATOR_COLONEQ))
+	{
+	  if (!exp->is_error_expression())
+	error_at(token->location(), "non-name on left side of %<:=%>");
+	  while (!token->is_op(OPERATOR_SEMICOLON)
+		 && !token->is_eof())
+	token = this->advance_token();
+	  return NULL;
+	}
+
+  this->expression_stat(exp);
+}
 
   return NULL;
 }
@@ -4287,8 +4301,19 @@
   while (true)
 	{
 	  Type* t = this->type();
+
 	  if (!t->is_error_type())
 	types->push_back(t);
+	  else
+	{
+	  token = this->peek_token();
+	  while (!token->is_op(OPERATOR_COLON)
+		 && !token->is_op(OPERATOR_COMMA)
+		 && !token->is_op(OPERATOR_RCURLY)
+		 && !token->is_eof())
+		token = this->advance_token();
+	}
+
 	  if (!this->peek_token()->is_op(OPERATOR_COMMA))
 	break;
 	  this->advance_token();


Re: Ping: [libiberty patch] Add demangler support for cloned function symbols (PR 40831)

2011-09-23 Thread Ian Lance Taylor
Cary Coutant  writes:

>>> This patch is OK, with or without the testsuite additions Jakub
>>> mentions.
>>
>> Thanks, I added the new tests, and tweaked the clone suffix parsing to
>> allow the leading "_".
>>
>> Committed as r179132.
>
> Should I backport this patch to gcc-4_6-branch?

Since you offer, that would be nice.

Ian


[google] Add SECTION_EXCLUDE flag and exclude .gnu.callgraph sections (issue5126041)

2011-09-23 Thread Sriraman Tallam
This patch adds a new flag to mark sections as exclude sections. Such
sections will be discarded by the linker. Also, mark .gnu.callgraph
sections which store the callgraph edge profile info as exclude
sections. 

I also want the SECTION_EXCLUDE part alone to be considered for trunk.


Index: final.c
===
--- final.c (revision 179104)
+++ final.c (working copy)
@@ -4428,7 +4428,7 @@ rest_of_handle_final (void)
   && cgraph_node (current_function_decl) != NULL
   && (cgraph_node (current_function_decl))->callees != NULL)
 {
-  flags = SECTION_DEBUG;
+  flags = SECTION_DEBUG | SECTION_EXCLUDE;
   asprintf (&profile_fnname, ".gnu.callgraph.text.%s", fnname);
   switch_to_section (get_section (profile_fnname, flags, NULL));
   fprintf (asm_out_file, "\t.string \"Function %s\"\n", fnname);
Index: varasm.c
===
--- varasm.c(revision 179098)
+++ varasm.c(working copy)
@@ -6191,6 +6191,8 @@ default_elf_asm_named_section (const char *name, u
 
   if (!(flags & SECTION_DEBUG))
 *f++ = 'a';
+  if (flags & SECTION_EXCLUDE)
+*f++ = 'e';
   if (flags & SECTION_WRITE)
 *f++ = 'w';
   if (flags & SECTION_CODE)
Index: output.h
===
--- output.h(revision 179098)
+++ output.h(working copy)
@@ -443,6 +443,7 @@ extern void no_asm_to_stream (FILE *);
 #define SECTION_COMMON   0x80  /* contains common data */
 #define SECTION_RELRO   0x100  /* data is readonly after relocation 
processing */
 #define SECTION_MACH_DEP 0x200 /* subsequent bits reserved for target 
*/
+#define SECTION_EXCLUDE  0x400  /* discarded by the linker */
 
 /* This SECTION_STYLE is used for unnamed sections that we can switch
to using a special assembler directive.  */

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


[C++ Patch] PR 44267

2011-09-23 Thread Paolo Carlini

Hi,

as agreed on the audit trail. Tested x86_64-linux.

Ok for mainline?

Thanks,
Paolo.


/cp
2011-09-23  Paolo Carlini  

PR c++/44267
* class.c (build_base_path): Add a tsubst_flags_t parameter.
(convert_to_base): Adjust call.
* typeck.c (build_class_member_access_expr,
get_member_function_from_ptrfunc, build_static_cast_1): Likewise.
* init.c (dfs_initialize_vtbl_ptrs, emit_mem_initializers): Likewise.
* method.c (do_build_copy_constructor, do_build_copy_assign): Likewise.
* rtti.c (build_dynamic_cast_1): Likewise.
* typeck2.c (build_scoped_ref, build_m_component_ref): Likewise.
* call.c (build_over_call, build_special_member_call): Likewise.
* cvt.c (cp_convert_to_pointer, convert_to_pointer_force,
build_up_reference): Likewise.
* cp-tree.h (build_base_path): Adjust declaration.

/testsuite
2011-09-23  Paolo Carlini  

PR c++/44267
* g++.dg/template/sfinae28.C: New.
Index: testsuite/g++.dg/template/sfinae28.C
===
--- testsuite/g++.dg/template/sfinae28.C(revision 0)
+++ testsuite/g++.dg/template/sfinae28.C(revision 0)
@@ -0,0 +1,24 @@
+// Origin: PR c++/44267
+
+struct B {};
+struct D : B {};
+struct VD : virtual B {};
+
+template  T create();
+
+typedef char one[1];
+typedef char two[2];
+
+template 
+one& f(char (*)[sizeof(static_cast(create()))]);
+
+template 
+two& f(...);
+
+int main()
+{
+   f(0);
+   f(0);
+   f(0);
+   return 0;
+}
Index: cp/typeck.c
===
--- cp/typeck.c (revision 179128)
+++ cp/typeck.c (working copy)
@@ -2221,7 +2221,7 @@ build_class_member_access_expr (tree object, tree
 
  /* Convert to the base.  */
  object = build_base_path (PLUS_EXPR, object, binfo,
-   /*nonnull=*/1);
+   /*nonnull=*/1, complain);
  /* If we found the base successfully then we should be able
 to convert to it successfully.  */
  gcc_assert (object != error_mark_node);
@@ -3073,7 +3073,7 @@ get_member_function_from_ptrfunc (tree *instance_p
  basetype = lookup_base (TREE_TYPE (TREE_TYPE (instance_ptr)),
  basetype, ba_check, NULL);
  instance_ptr = build_base_path (PLUS_EXPR, instance_ptr, basetype,
- 1);
+ 1, tf_warning_or_error);
  if (instance_ptr == error_mark_node)
return error_mark_node;
}
@@ -5772,7 +5772,7 @@ build_static_cast_1 (tree type, tree expr, bool c_
   /* Convert from "B*" to "D*".  This function will check that "B"
 is not a virtual base of "D".  */
   expr = build_base_path (MINUS_EXPR, build_address (expr),
- base, /*nonnull=*/false);
+ base, /*nonnull=*/false, complain);
   /* Convert the pointer to a reference -- but then remember that
 there are no expressions with reference type in C++.
 
@@ -5874,7 +5874,8 @@ build_static_cast_1 (tree type, tree expr, bool c_
   base = lookup_base (TREE_TYPE (type), TREE_TYPE (intype),
  c_cast_p ? ba_unique : ba_check,
  NULL);
-  expr = build_base_path (MINUS_EXPR, expr, base, /*nonnull=*/false);
+  expr = build_base_path (MINUS_EXPR, expr, base, /*nonnull=*/false,
+ complain);
   return cp_fold_convert(type, expr);
 }
 
Index: cp/init.c
===
--- cp/init.c   (revision 179128)
+++ cp/init.c   (working copy)
@@ -100,7 +100,8 @@ dfs_initialize_vtbl_ptrs (tree binfo, void *data)
 {
   tree base_ptr = TREE_VALUE ((tree) data);
 
-  base_ptr = build_base_path (PLUS_EXPR, base_ptr, binfo, /*nonnull=*/1);
+  base_ptr = build_base_path (PLUS_EXPR, base_ptr, binfo, /*nonnull=*/1,
+ tf_warning_or_error);
 
   expand_virtual_init (binfo, base_ptr);
 }
@@ -963,7 +964,7 @@ emit_mem_initializers (tree mem_inits)
  tree base_addr;
 
  base_addr = build_base_path (PLUS_EXPR, current_class_ptr,
-  subobject, 1);
+  subobject, 1, tf_warning_or_error);
  expand_aggr_init_1 (subobject, NULL_TREE,
  cp_build_indirect_ref (base_addr, RO_NULL,
  tf_warning_or_error),
Index: cp/class.c
===
--- cp/class.c  (revision 179128)
+++ cp/class.c  (working copy)
@@ -235,7 +235,8 @@ tree
 build_base_path (enum tree_code code,
 tree expr,
 tree binfo,
-int non

Go patch committed: Fix up a few test cases

2011-09-23 Thread Ian Lance Taylor
I missed the fact that some of the updated Go tests were getting Tcl
errors leading to an unresolved state, rather than actually failing.
The errors were because the regular expressions which appear in the file
need to be translated into expressions which can be used with dg-error,
which is mainly a matter of appropriate Tcl quoting.  Of course the
regexps used to do quoting must themselves be quoted correctly, so the
results are rather arcane.  This patch updates the quoting so the tests
are actually tested, and updates the regexps to match the output of
gccgo.  Ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian


2011-09-23  Ian Lance Taylor  

* go.test/go-test.exp (errchk): Handle more cases of getting
correct Tcl backslash quoting in regular expressions in test file.


Index: test/fixedbugs/bug340.go
===
--- test/fixedbugs/bug340.go	(revision 179063)
+++ test/fixedbugs/bug340.go	(working copy)
@@ -10,8 +10,8 @@ package main
 
 func main() {
 	var x interface{}
-	switch t := x.(type) { // ERROR "0 is not a type"
-	case 0:
-		t.x = 1 // ERROR "type interface \{ \}"
+	switch t := x.(type) { // GC_ERROR "0 is not a type"
+	case 0:		// GCCGO_ERROR "expected type"
+		t.x = 1 // ERROR "type interface \{ \}|reference to undefined field or method"
 	}
 }
Index: test/fixedbugs/bug350.go
===
--- test/fixedbugs/bug350.go	(revision 179063)
+++ test/fixedbugs/bug350.go	(working copy)
@@ -8,8 +8,8 @@ package main
 
 type T int
 
-func (T) m() {}
-func (T) m() {} // ERROR "T[.]m redeclared"
+func (T) m() {} // GCCGO_ERROR "previous"
+func (T) m() {} // ERROR "T[.]m redeclared|redefinition"
 
-func (*T) p() {}
-func (*T) p() {} // ERROR "[(][*]T[)][.]p redeclared"
+func (*T) p() {} // GCCGO_ERROR "previous"
+func (*T) p() {} // ERROR "[(][*]T[)][.]p redeclared|redefinition"
Index: test/fixedbugs/bug351.go
===
--- test/fixedbugs/bug351.go	(revision 179063)
+++ test/fixedbugs/bug351.go	(working copy)
@@ -9,5 +9,5 @@ package main
 var x int
 
 func main() {
-	(x) := 0  // ERROR "non-name [(]x[)]"
+	(x) := 0  // ERROR "non-name [(]x[)]|non-name on left side"
 }
Index: go-test.exp
===
--- go-test.exp	(revision 179063)
+++ go-test.exp	(working copy)
@@ -61,13 +61,17 @@ proc errchk { test opts } {
 	# experimentation, not analysis.
 	regsub -all "\\.\\*" $out_line "\[ -~\]*" out_line
 	}
+	if [string match "*dg-error*\\\[?\\\]*" $out_line] {
+	set index [string first "dg-error" $out_line]
+	regsub -all "\\\[\(.\)\\\]" $out_line "\[\\1\]" out_line
+	}
 	if [string match "*dg-error*\{*" $out_line] {
 	set index [string first "dg-error" $out_line]
-	regsub -start $index -all "\{" $out_line "\[\\\{\]" out_line
+	regsub -start $index -all "\(\[^]\)\{" $out_line "\\1\[\\\{\]" out_line
 	}
 	if [string match "*dg-error*\}*\}" $out_line] {
 	set index [string first "dg-error" $out_line]
-	regsub -start $index -all "\}\(.\)" $out_line "\[\\\}\]\\1" out_line
+	regsub -start $index -all "\(\[^]\)\}\(.\)" $out_line "\\1\[\\\}\]\\2" out_line
 	}
 	if [string match "*dg-error*\(*" $out_line] {
 	set index [string first "dg-error" $out_line]
@@ -77,10 +81,6 @@ proc errchk { test opts } {
 	set index [string first "dg-error" $out_line]
 	regsub -start $index -all "\\\)\(.\)" $out_line "\[\\\)\]\\1" out_line
 	}
-	if [string match "*dg-error*\[.\]*" $out_line] {
-	set index [string first "dg-error" $out_line]
-	regsub -all "\\\[\\.\\\]" $out_line "\[.\]" out_line
-	}
 	# Special case for bug332, in which the error message wants to
 	# match the file name, which is not what dg-error expects.
 	if [string match "*dg-error*bug332*" $out_line] {


Re: [C++ Patch] PR 44267

2011-09-23 Thread Jason Merrill

OK.

Jason


Re: [PATCH] Add VIS intrinsics header for sparc.

2011-09-23 Thread David Miller

Hans, here is what I'm playing with right now against current
trunk.

I looked at the use cases for making use of the scale factor in the
VIS %gsr register and it's used similar to how rounding modes are
modified in the FPU control register.

You have a function, or family of functions, that want to operate with
a certain scale factor.  And at the top level the first thing you do
is set the %gsr as you want it to be set.

So I've added a GSR register to the sparc backend and then added
__vis_write_gsr() and __vis_read_gsr() functions to facilitate the
use cases I've seen.

This allowed me to describe to the compiler exactly what the alignaddr
instructions do, and thus the unspecs for them are now gone.

The pack and faligndata intrinsics still need to be unspec, and thus I
merely added GSR uses to those patterns which is enough to let the
compiler get the dataflow right.

This all seems sufficient for what things like Sun's medialib and your
RAPP project want to do.

I'll look into your other suggestion in PR48974, namely making use of
fone VIS instructions.

Thanks.

diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index d62d5a1..f38ecda 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -329,7 +329,7 @@ char leaf_reg_remap[] =
   72, 73, 74, 75, 76, 77, 78, 79,
   80, 81, 82, 83, 84, 85, 86, 87,
   88, 89, 90, 91, 92, 93, 94, 95,
-  96, 97, 98, 99, 100};
+  96, 97, 98, 99, 100, 101, 102};
 
 /* Vector, indexed by hard register number, which contains 1
for a register that is allowable in a candidate for leaf
@@ -347,7 +347,7 @@ char sparc_leaf_regs[] =
   1, 1, 1, 1, 1, 1, 1, 1,
   1, 1, 1, 1, 1, 1, 1, 1,
   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1};
+  1, 1, 1, 1, 1, 1, 1};
 
 struct GTY(()) machine_function
 {
@@ -4036,8 +4036,8 @@ static const int hard_32bit_mode_classes[] = {
   /* %fcc[0123] */
   CCFP_MODES, CCFP_MODES, CCFP_MODES, CCFP_MODES,
 
-  /* %icc */
-  CC_MODES
+  /* %icc, %sfp, %gsr */
+  CC_MODES, 0, S_MODES
 };
 
 static const int hard_64bit_mode_classes[] = {
@@ -4061,8 +4061,8 @@ static const int hard_64bit_mode_classes[] = {
   /* %fcc[0123] */
   CCFP_MODES, CCFP_MODES, CCFP_MODES, CCFP_MODES,
 
-  /* %icc */
-  CC_MODES
+  /* %icc, %sfp, %gsr */
+  CC_MODES, 0, S_MODES
 };
 
 int sparc_mode_class [NUM_MACHINE_MODES];
@@ -9168,14 +9168,18 @@ sparc_vis_init_builtins (void)
  v4hi, v4hi, 0);
   tree si_ftype_v2si_v2si = build_function_type_list (intSI_type_node,
  v2si, v2si, 0);
+  tree void_ftype_si = build_function_type_list (void_type_node,
+intSI_type_node, 0);
+  tree si_ftype_void = build_function_type_list (intSI_type_node,
+void_type_node, 0);
 
   /* Packing and expanding vectors.  */
-  def_builtin ("__builtin_vis_fpack16", CODE_FOR_fpack16_vis,
-  v4qi_ftype_v4hi);
-  def_builtin ("__builtin_vis_fpack32", CODE_FOR_fpack32_vis,
-  v8qi_ftype_v2si_v8qi);
-  def_builtin ("__builtin_vis_fpackfix", CODE_FOR_fpackfix_vis,
-  v2hi_ftype_v2si);
+  def_builtin_const ("__builtin_vis_fpack16", CODE_FOR_fpack16_vis,
+v4qi_ftype_v4hi);
+  def_builtin_const ("__builtin_vis_fpack32", CODE_FOR_fpack32_vis,
+v8qi_ftype_v2si_v8qi);
+  def_builtin_const ("__builtin_vis_fpackfix", CODE_FOR_fpackfix_vis,
+v2hi_ftype_v2si);
   def_builtin_const ("__builtin_vis_fexpand", CODE_FOR_fexpand_vis,
 v4hi_ftype_v4qi);
   def_builtin_const ("__builtin_vis_fpmerge", CODE_FOR_fpmerge_vis,
@@ -9198,27 +9202,33 @@ sparc_vis_init_builtins (void)
 v2si_ftype_v4qi_v2hi);
 
   /* Data aligning.  */
-  def_builtin ("__builtin_vis_faligndatav4hi", CODE_FOR_faligndatav4hi_vis,
-  v4hi_ftype_v4hi_v4hi);
-  def_builtin ("__builtin_vis_faligndatav8qi", CODE_FOR_faligndatav8qi_vis,
-  v8qi_ftype_v8qi_v8qi);
-  def_builtin ("__builtin_vis_faligndatav2si", CODE_FOR_faligndatav2si_vis,
-  v2si_ftype_v2si_v2si);
-  def_builtin ("__builtin_vis_faligndatadi", CODE_FOR_faligndatadi_vis,
-  di_ftype_di_di);
+  def_builtin_const ("__builtin_vis_faligndatav4hi", 
CODE_FOR_faligndatav4hi_vis,
+v4hi_ftype_v4hi_v4hi);
+  def_builtin_const ("__builtin_vis_faligndatav8qi", 
CODE_FOR_faligndatav8qi_vis,
+v8qi_ftype_v8qi_v8qi);
+  def_builtin_const ("__builtin_vis_faligndatav2si", 
CODE_FOR_faligndatav2si_vis,
+v2si_ftype_v2si_v2si);
+  def_builtin_const ("__builtin_vis_faligndatadi", CODE_FOR_faligndatadi_vis,
+di_ftype_di_di);
+
+  def_builtin ("__builtin_vis_write_gsr", CODE_FOR_wrgsr_vis,
+  void_ftype_si);
+  def_builtin ("__builtin_vis_read_gsr", CODE_FOR_rdgsr_vis,
+  si_ftype_void);
+
   if (TARGET_ARCH64)