[gc-improv] Permanent vs function RTL obstack fix

2011-04-07 Thread Laurynas Biveinis
Fixes a bunch of C testsuite failures. Committed to gc-improv.

2011-04-07  Laurynas Biveinis  laurynas.bivei...@gmail.com

* stmt.c (label_rtx): Allocate RTX in permanent RTL memory.
Index: stmt.c
===
--- stmt.c	(revision 170593)
+++ stmt.c	(working copy)
@@ -139,7 +139,10 @@
 
   if (!DECL_RTL_SET_P (label))
 {
-  rtx r = gen_label_rtx ();
+  rtx r;
+  use_rtl_permanent_mem ();
+  r = gen_label_rtx ();
+  use_rtl_function_mem ();
   SET_DECL_RTL (label, r);
   if (FORCED_LABEL (label) || DECL_NONLOCAL (label))
 	LABEL_PRESERVE_P (r) = 1;


Re: [patch, ARM] Make 128 bits the default vector size for NEON

2011-04-07 Thread Ira Rosen
On 6 April 2011 16:07, Hans-Peter Nilsson hans-peter.nils...@axis.com wrote:
 Date: Thu, 31 Mar 2011 13:39:05 +0200
 From: Ira Rosen ira.ro...@linaro.org

 This patch changes NEON's default vector size from 64 to 128 bits.

 I'm wondering, are there NEON-specific measurements to support
 this change?

 A colleague of mine implemented support for 64- and 128-bit NEON
 for RAPP http://savannah.nongnu.org/projects/rapp/, but found
 that the 128-bit version was slower.

The best vector size depends on the particular target (a version of
ARM) and the benchmark. The vectorizer has a cost model that allows it
to fall back to 64-bit vectors if 128-bit version is not profitable
(-fvect-cost-model). We plan to enhance the cost model to estimate
both versions and vectorize with the most profitable vector size. For
now, you can use preferred-vector-size param if needed. Having 64 as a
default doesn't allow us to use different NEON instructions that use
both types of vectors.

Ira


 brgds, H-P



[patch, ARM] Fix PR target/48252

2011-04-07 Thread Ira Rosen
Hi,

This patch makes both outputs of neon_vzip/vuzp/vtrn_internal
explicitly dependent on both inputs, preventing incorrect
optimization:
for
(a,b)- vzip (c,d)
and
(e,f) - vzip (g,d)
CSE decides that b==f, since b and f depend only on d.

Tested on arm-linux-gnueabi. OK for trunk?
OK for 4.6 after testing?

Thanks,
Ira

ChangeLog:

2011-04-07  Ulrich Weigand  ulrich.weig...@linaro.org
  Ira Rosen  ira.ro...@linaro.org

 PR target/48252
 * config/arm/arm.c (neon_emit_pair_result_insn): Swap arguments
 to match neon_vzip/vuzp/vtrn_internal.
 * config/arm/neon.md (neon_vtrnmode_internal): Make both
 outputs explicitly dependent on both inputs.
 (neon_vzipmode_internal, neon_vuzpmode_internal): Likewise.

testsuite/Changelog:

 PR target/48252
 * gcc.target/arm/pr48252.c: New test.
Index: testsuite/gcc.target/arm/pr48252.c
===
--- testsuite/gcc.target/arm/pr48252.c  (revision 0)
+++ testsuite/gcc.target/arm/pr48252.c  (revision 0)
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-require-effective-target arm_neon_hw } */
+/* { dg-options -O2 } */
+/* { dg-add-options arm_neon } */
+
+#include arm_neon.h
+#include stdlib.h
+
+int main(void)
+{
+uint8x8_t v1 = {1, 1, 1, 1, 1, 1, 1, 1};
+uint8x8_t v2 = {2, 2, 2, 2, 2, 2, 2, 2};
+uint8x8x2_t vd1, vd2;
+union {uint8x8_t v; uint8_t buf[8];} d1, d2, d3, d4;
+int i;
+
+vd1 = vzip_u8(v1, vdup_n_u8(0));
+vd2 = vzip_u8(v2, vdup_n_u8(0));
+
+vst1_u8(d1.buf, vd1.val[0]);
+vst1_u8(d2.buf, vd1.val[1]);
+vst1_u8(d3.buf, vd2.val[0]);
+vst1_u8(d4.buf, vd2.val[1]);
+
+for (i = 0; i  8; i++)
+  if ((i % 2 == 0  d4.buf[i] != 2)
+  || (i % 2 == 1  d4.buf[i] != 0))
+ abort ();
+
+return 0;
+}
Index: config/arm/arm.c
===
--- config/arm/arm.c(revision 172019)
+++ config/arm/arm.c(working copy)
@@ -19593,7 +19593,7 @@ neon_emit_pair_result_insn (enum machine
   rtx tmp1 = gen_reg_rtx (mode);
   rtx tmp2 = gen_reg_rtx (mode);
 
-  emit_insn (intfn (tmp1, op1, tmp2, op2));
+  emit_insn (intfn (tmp1, op1, op2, tmp2));
 
   emit_move_insn (mem, tmp1);
   mem = adjust_address (mem, mode, GET_MODE_SIZE (mode));
Index: config/arm/neon.md
===
--- config/arm/neon.md  (revision 172019)
+++ config/arm/neon.md  (working copy)
@@ -4092,13 +4092,14 @@
 
 (define_insn neon_vtrnmode_internal
   [(set (match_operand:VDQW 0 s_register_operand =w)
-   (unspec:VDQW [(match_operand:VDQW 1 s_register_operand 0)]
-UNSPEC_VTRN1))
-   (set (match_operand:VDQW 2 s_register_operand =w)
-(unspec:VDQW [(match_operand:VDQW 3 s_register_operand 2)]
-UNSPEC_VTRN2))]
+(unspec:VDQW [(match_operand:VDQW 1 s_register_operand 0)
+  (match_operand:VDQW 2 s_register_operand w)]
+ UNSPEC_VTRN1))
+   (set (match_operand:VDQW 3 s_register_operand =2)
+ (unspec:VDQW [(match_dup 1) (match_dup 2)]
+ UNSPEC_VTRN2))]
   TARGET_NEON
-  vtrn.V_sz_elem\t%V_reg0, %V_reg2
+  vtrn.V_sz_elem\t%V_reg0, %V_reg3
   [(set (attr neon_type)
   (if_then_else (ne (symbol_ref Is_d_reg) (const_int 0))
 (const_string neon_bp_simple)
@@ -4118,13 +4119,14 @@
 
 (define_insn neon_vzipmode_internal
   [(set (match_operand:VDQW 0 s_register_operand =w)
-   (unspec:VDQW [(match_operand:VDQW 1 s_register_operand 0)]
-UNSPEC_VZIP1))
-   (set (match_operand:VDQW 2 s_register_operand =w)
-(unspec:VDQW [(match_operand:VDQW 3 s_register_operand 2)]
-UNSPEC_VZIP2))]
+(unspec:VDQW [(match_operand:VDQW 1 s_register_operand 0)
+  (match_operand:VDQW 2 s_register_operand w)]
+ UNSPEC_VZIP1))
+   (set (match_operand:VDQW 3 s_register_operand =2)
+(unspec:VDQW [(match_dup 1) (match_dup 2)]
+ UNSPEC_VZIP2))]
   TARGET_NEON
-  vzip.V_sz_elem\t%V_reg0, %V_reg2
+  vzip.V_sz_elem\t%V_reg0, %V_reg3
   [(set (attr neon_type)
   (if_then_else (ne (symbol_ref Is_d_reg) (const_int 0))
 (const_string neon_bp_simple)
@@ -4144,13 +4146,14 @@
 
 (define_insn neon_vuzpmode_internal
   [(set (match_operand:VDQW 0 s_register_operand =w)
-   (unspec:VDQW [(match_operand:VDQW 1 s_register_operand 0)]
+(unspec:VDQW [(match_operand:VDQW 1 s_register_operand 0)
+  (match_operand:VDQW 2 s_register_operand w)]
  UNSPEC_VUZP1))
-   (set (match_operand:VDQW 2 s_register_operand =w)
-(unspec:VDQW [(match_operand:VDQW 3 s_register_operand 2)]
-UNSPEC_VUZP2))]
+   (set (match_operand:VDQW 3 s_register_operand =2)
+(unspec:VDQW [(match_dup 1) (match_dup 2)]
+ UNSPEC_VUZP2))]
   

Re: PATCH: PR middle-end/48440: [4.7 Regression] FAIL: gcc.c-torture/compile/labels-3.c

2011-04-07 Thread Richard Guenther
On Wed, Apr 6, 2011 at 7:03 PM, H.J. Lu hjl.to...@gmail.com wrote:
 On Tue, Apr 5, 2011 at 3:29 AM, Richard Guenther
 richard.guent...@gmail.com wrote:
 On Tue, Apr 5, 2011 at 8:44 AM, Paolo Bonzini bonz...@gnu.org wrote:
 Index: cgraphbuild.c
 ===
 --- cgraphbuild.c.orig  2011-04-03 11:28:45.0 +0200
 +++ cgraphbuild.c       2011-04-03 11:31:21.0 +0200
 @@ -53,6 +53,12 @@ record_reference (tree *tp, int *walk_su
   tree decl;
   struct record_reference_ctx *ctx = (struct record_reference_ctx *)data;

 +  t = canonicalize_constructor_val (t);
 +  if (!t)
 +    t = *tp;
 +  else if (t != *tp)
 +    *tp = t;
 +
   switch (TREE_CODE (t))
     {
     case VAR_DECL:

 This change caused:

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


 This avoids  canonicalizing constructor values for address conversion
 if Pmode != ptr_mode.  OK for trunk?

 Certainly the right place to fix it is in canonicalize_constructor_val 
 itself.

 There should never be any Pmode pointer types in the gimple IL.  The
 proper place to fix it if any is in useless_type_conversion_p.


 We have

 5600      newx = simplify_subreg (outermode, op, innermode, byte);
 (gdb) f 1
 #1  0x00708494 in expand_expr_real_2 (ops=0x7fffb0c0, target=0x0,
    tmode=VOIDmode, modifier=EXPAND_INITIALIZER)
    at /export/gnu/import/git/gcc-x32/gcc/expr.c:7366
 7366                op0 = simplify_gen_subreg (mode, op0, inner_mode,
 (gdb) call debug_tree (treeop0)
  addr_expr 0x70a78d50
    type pointer_type 0x70b83f18
        type void_type 0x70b83e70 void VOID
            align 8 symtab 0 alias set -1 canonical type 0x70b83e70
            pointer_to_this pointer_type 0x70b83f18
        sizes-gimplified public unsigned SI
        size integer_cst 0x70b706e0 constant 32
        unit size integer_cst 0x70b703e8 constant 4
        align 32 symtab 0 alias set -1 canonical type 0x70b83f18
        pointer_to_this pointer_type 0x70b985e8
    constant
    arg 0 label_decl 0x70b7b400 l2 type void_type 0x70b83e70 void
        side-effects VOID file x.i line 8 col 2
        align 1 context function_decl 0x70a68f00 foo initial
 error_mark 0x70b789f0
        (code_label/s 22 0 0 4 4 (l2) [2 uses])

        chain var_decl 0x70a790a0 p type pointer_type 0x70b83f18
            used unsigned SI file x.i line 4 col 9 size integer_cst
 0x70b706e0 32 unit size integer_cst 0x70b703e8 4
            align 32 context function_decl 0x70a68f00 foo
            (mem/f/c/i:SI (plus:DI (reg/f:DI 20 frame)
        (const_int -4 [0xfffc])) [0 p+0 S4 A32])
    x.i:3:44
 (gdb) call debug_rtx (op0)
 (label_ref/v:DI 22)
 (gdb)

 Since ptr_mode != Pmode, the type of op0 != type of treeop0.
 Should we use GET_MODE (op0) instead of TYPE_MODE (inner_type)
 here? Does this patch make any senses?

First I wonder what CONSTANT_P object we arrive with here (it looks like
something unfolded, given that we likely came here with a NOP_EXPR).

Second, no, it doesn't make sense as CONST_INTs are modeless
(which is exactly why we look at tree types here ...)

The above gdb session paste is from a totally different place, so I can't
match the data to the place you are trying to patch.

Richard.


 --
 H.J.
 ---
 diff --git a/gcc/expr.c b/gcc/expr.c
 index d521f64..439f245 100644
 --- a/gcc/expr.c
 +++ b/gcc/expr.c
 @@ -7360,7 +7360,7 @@ expand_expr_real_2 (sepops ops, rtx target, enum 
 machine_m
 ode tmode,
       else if (CONSTANT_P (op0))
        {
          tree inner_type = TREE_TYPE (treeop0);
 -         enum machine_mode inner_mode = TYPE_MODE (inner_type);
 +         enum machine_mode inner_mode = GET_MODE (op0);

          if (modifier == EXPAND_INITIALIZER)
            op0 = simplify_gen_subreg (mode, op0, inner_mode,



Re: [PATCH, ARM] PR47855 Compute attr length for some thumb2 insns

2011-04-07 Thread Carrot Wei
On Thu, Apr 7, 2011 at 5:31 PM, Richard Sandiford
richard.sandif...@linaro.org wrote:
 Hi Carrot,

 Sorry if this has already been reported, but the patch breaks bootstrap
 of arm-linux-gnueabi (or cross builds with --enable-werror).  The problem
 is that this...

 uses a statement expression -- i.e. ({ code; result; }) -- which is
 a GNU extension.

 I suppose a simple fix would be to put the code into an arm.c function.


Thank you for the report, I will add this fix to the second part of the patch.

Carrot


[Patch, committed] Add myself to MAINTAINERS

2011-04-07 Thread Henderson, Stuart
Added myself to MAINTAINERS (write after approval), committed as directed.

Stu


2011-04-07  Stuart Henderson  shend...@gcc.gnu.org

   * MAINTAINERS (Write After Approval): Add myself.




Index: MAINTAINERS
===
--- MAINTAINERS (revision 172094)
+++ MAINTAINERS (revision 172095)
@@ -373,6 +373,7 @@
 Mark Heffernan meh...@google.com
 George Helffrich   geo...@gcc.gnu.org
 Fergus Henderson   f...@cs.mu.oz.au
+Stuart Henderson   shend...@gcc.gnu.org
 Matthew Hiller hil...@redhat.com
 Manfred Hollstein  m...@suse.com
 Falk Hueffner  f...@debian.org


Re: [PATCH, ARM] PR47855 Compute attr length for some thumb2 insns

2011-04-07 Thread Ramana Radhakrishnan

On 07/04/11 12:08, Carrot Wei wrote:

On Thu, Apr 7, 2011 at 5:31 PM, Richard Sandiford
richard.sandif...@linaro.org  wrote:

Hi Carrot,

Sorry if this has already been reported, but the patch breaks bootstrap
of arm-linux-gnueabi (or cross builds with --enable-werror).  The problem
is that this...

uses a statement expression -- i.e. ({ code; result; }) -- which is
a GNU extension.

I suppose a simple fix would be to put the code into an arm.c function.



Thank you for the report, I will add this fix to the second part of the patch.


It would be worth unbreaking bootstrap as a separate patch and not 
conflating it with a different set of improvements.


Ramana



Carrot




Re: [patch, ARM] Fix PR target/48252

2011-04-07 Thread Ramana Radhakrishnan

On 07/04/11 08:42, Ira Rosen wrote:

Hi,

This patch makes both outputs of neon_vzip/vuzp/vtrn_internal
explicitly dependent on both inputs, preventing incorrect
optimization:
for
(a,b)- vzip (c,d)
and
(e,f)- vzip (g,d)
CSE decides that b==f, since b and f depend only on d.

Tested on arm-linux-gnueabi. OK for trunk?


This is OK for trunk.


OK for 4.6 after testing?


I have no objections to this going into 4.5 and 4.6 since it corrects 
the implementation of the neon intrinsics but please check with the 
release managers.


cheers
Ramana



Thanks,
Ira

ChangeLog:

2011-04-07  Ulrich Weigandulrich.weig...@linaro.org
   Ira Rosenira.ro...@linaro.org

  PR target/48252
  * config/arm/arm.c (neon_emit_pair_result_insn): Swap arguments
  to match neon_vzip/vuzp/vtrn_internal.
  * config/arm/neon.md (neon_vtrnmode_internal): Make both
  outputs explicitly dependent on both inputs.
  (neon_vzipmode_internal, neon_vuzpmode_internal): Likewise.

testsuite/Changelog:

  PR target/48252
  * gcc.target/arm/pr48252.c: New test.




Re: [Patch] Bfin: Ensure rotrsi and rotlsi don't accept non-const INTVALS

2011-04-07 Thread Bernd Schmidt
On 04/04/2011 06:04 PM, Henderson, Stuart wrote:
 Yep, I'm seeing this behaviour (getting the error using your patch).
 But I'm confused as to why the define_expand is being considered when
 the predicate doesn't match.

It's just a bug in expand. Your original patch (plus using
const_int_operand as suggested by rth) is OK for all branches where the
problem occurs. I found yesterday that this is PR39768, so make sure to
mention that in the ChangeLog.


Bernd


Re: PATCH: PR middle-end/48440: [4.7 Regression] FAIL: gcc.c-torture/compile/labels-3.c

2011-04-07 Thread Michael Matz
Hi,

On Thu, 7 Apr 2011, Richard Guenther wrote:

  5600      newx = simplify_subreg (outermode, op, innermode, byte);
  (gdb) f 1
  #1  0x00708494 in expand_expr_real_2 (ops=0x7fffb0c0, 
  target=0x0,
     tmode=VOIDmode, modifier=EXPAND_INITIALIZER)
     at /export/gnu/import/git/gcc-x32/gcc/expr.c:7366
  7366                op0 = simplify_gen_subreg (mode, op0, inner_mode,
  (gdb) call debug_tree (treeop0)
   addr_expr 0x70a78d50
     type pointer_type 0x70b83f18
         type void_type 0x70b83e70 void VOID
             align 8 symtab 0 alias set -1 canonical type 0x70b83e70
             pointer_to_this pointer_type 0x70b83f18
         sizes-gimplified public unsigned SI
     arg 0 label_decl 0x70b7b400 l2 type void_type 0x70b83e70 void
  (gdb) call debug_rtx (op0)
  (label_ref/v:DI 22)
  (gdb)
 
 
 First I wonder what CONSTANT_P object we arrive with here (it looks like
 something unfolded, given that we likely came here with a NOP_EXPR).

The CONSTANT_P object is the '(label_ref/v:DI 22)'.  Not only CONST_INT 
are CONSTANT_P, also some others (symbol_ref too).  Those might have a 
mode.  Here the label_ref has DImode, but the pointer type in trees points 
to an SImode.  The latter makes sense, because that's what ptr_mode is for 
HJs target.

HJ: you'll need to tell us what you mean with 'breaks 
gcc.c-torture/compile/labels-3.c' .  What breaks, in which way?


Ciao,
Michael.

[PATCH,c++] fix PR objc++/48479, ICE in cxx_mark_addressable

2011-04-07 Thread Nathan Froyd
My recent patch removing DECL_RTL from CONST_DECLs caused regressions in
the ObjC++ testsuite on Darwin targets.  The problem is that
DECL_REGISTER was being called on CONST_DECLs; DECL_REGISTER says:

/* In VAR_DECL and PARM_DECL nodes, nonzero means declared `register'.  */
#define DECL_REGISTER(NODE) (DECL_WRTL_CHECK (NODE)-decl_common.decl_flag_0)

Previously, the DECL_WRTL_CHECK was succeeding when given CONST_DECLs;
it no longer does.

The suggested fix is to simply move the CONST_DECL case in
cxx_mark_addressable; since DECL_REGISTER would have always returned
false for CONST_DECLs, there's no change in functionality.  Fixing
DECL_REGISTER to accurately reflect its comment would be helpful, but
there are other ICEs to fix if DECL_REGISTER only takes PARM_DECL and
VAR_DECL; I thought it best to submit that as a separate fix, if at all.

Patch was tested on Darwin targets via IainS and Dominique and fixed the
regression. OK to commit?

-Nathan

gcc/cp/
* typeck.c (cxx_mark_addressable) [CONST_DECL]: Mark addressable
and return immediately.

@@ -5373,7 +5373,6 @@ cxx_mark_addressable (tree exp)
|| DECL_EXTERNAL (x));
/* Fall through.  */
 
-  case CONST_DECL:
   case RESULT_DECL:
if (DECL_REGISTER (x)  !TREE_ADDRESSABLE (x)
 !DECL_ARTIFICIAL (x))
@@ -5391,6 +5390,7 @@ cxx_mark_addressable (tree exp)
TREE_ADDRESSABLE (x) = 1;
return true;
 
+  case CONST_DECL:
   case FUNCTION_DECL:
TREE_ADDRESSABLE (x) = 1;
return true;


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

2011-04-07 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

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

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

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

All other PO files for your package are available in:

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

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

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

The following HTML page has been updated:

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

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.
coordina...@translationproject.org



[patch i386]: Cleanup calling convention handling in i386.c and fix PR target/9601 and PR target/11772

2011-04-07 Thread Kai Tietz
Hello,

This patch cleans up a bit the calling convention checking in i386
architecture.  By this
I could fix some pretty old bugs about the -mrtd option. See as reference
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11772
and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9601

For none-prototyped function calls nowadays the linker is able to do
the stdcall fixup
successful (avoiding warning via -Wl,--enable-stdcall-fixup). So we
emit for this case
just the undecorated function's symbol name.

ChangeLog

2011-04-07  Kai Tietz

PR target/9601
PR target/11772
* config/i386/i386-protos.h (ix86_get_callcvt): New prototype.
* config/i386/i386.c (ix86_handle_cconv_attribute): Adjust
comment.
(ix86_is_msabi_thiscall): Removed.
(ix86_is_type_thiscall): Likewise.
(ix86_get_callcvt): New function.
(ix86_comp_type_attributes): Simplify check.
(ix86_function_regparm): Use ix86_get_callcvt for calling
convention attribute checks.
(ix86_return_pops_args): Likewise.
(ix86_static_chain): Likewise.
(x86_this_parameter): Likewise.
(x86_output_mi_thunk): Likewise.
* config/i386/i386.h (IX86_CALLCVT_CDECL, IX86_CALLCVT_STDCALL,
IX86_CALLCVT_FASTCALL, IX86_CALLCVT_THISCALL, IX86_CALLCVT_REGPARM,
IX86_CALLCVT_SSEREGPARM): New macros to represent calling convention
by flag-values.
(IX86_BASE_CALLCVT): Helper macro.
* config/i386/netware.c (i386_nlm_maybe_mangle_decl_assembler_name):
Use ix86_get_callcvt for calling convention attribute checks.
* config/i386/winnt.c (i386_pe_maybe_mangle_decl_assembler_name):
Likewise.
(gen_stdcall_or_fastcall_suffix): Handle TARGET_RTD case for
none-prototyped function calls.

Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
x86_64-pc-linux-gnu. Ok for apply?

Regards,
Kai
Index: gcc/gcc/config/i386/i386-protos.h
===
--- gcc.orig/gcc/config/i386/i386-protos.h  2011-01-13 20:55:30.0 
+0100
+++ gcc/gcc/config/i386/i386-protos.h   2011-04-07 11:02:16.645985200 +0200
@@ -191,6 +191,8 @@ extern tree ix86_handle_shared_attribute
 extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
 extern int x86_field_alignment (tree, int);
 extern tree ix86_valid_target_attribute_tree (tree);
+extern unsigned int ix86_get_callcvt (const_tree);
+
 #endif
 
 extern rtx ix86_tls_get_addr (void);
Index: gcc/gcc/config/i386/i386.c
===
--- gcc.orig/gcc/config/i386/i386.c 2011-04-06 19:13:30.0 +0200
+++ gcc/gcc/config/i386/i386.c  2011-04-07 14:51:22.411975800 +0200
@@ -5312,7 +5312,7 @@ ix86_handle_cconv_attribute (tree *node,
   return NULL_TREE;
 }
 
-  /* Can combine regparm with all attributes but fastcall.  */
+  /* Can combine regparm with all attributes but fastcall, and thiscall.  */
   if (is_attribute_p (regparm, name))
 {
   tree cst;
@@ -5436,38 +5436,50 @@ ix86_handle_cconv_attribute (tree *node,
   return NULL_TREE;
 }
 
-/* This function checks if the method-function has default __thiscall
-   calling-convention for 32-bit msabi.
-   It returns true if TYPE is of kind METHOD_TYPE, no stdarg function,
-   and the MS_ABI 32-bit is used.  Otherwise it returns false.  */
+/* This function determines from TYPE the calling-convention.  */
 
-static bool
-ix86_is_msabi_thiscall (const_tree type)
+unsigned int
+ix86_get_callcvt (const_tree type)
 {
-  if (TARGET_64BIT || ix86_function_type_abi (type) != MS_ABI
-  || TREE_CODE (type) != METHOD_TYPE || stdarg_p (type))
-return false;
-  /* Check for different calling-conventions.  */
-  if (lookup_attribute (cdecl, TYPE_ATTRIBUTES (type))
-  || lookup_attribute (stdcall, TYPE_ATTRIBUTES (type))
-  || lookup_attribute (fastcall, TYPE_ATTRIBUTES (type))
-  || lookup_attribute (regparm, TYPE_ATTRIBUTES (type))
-  || lookup_attribute (sseregparm, TYPE_ATTRIBUTES (type)))
-return false;
-  return true;
-}
+  unsigned int ret = 0;
 
-/* This function checks if the thiscall attribute is set for the TYPE,
-   or if it is an method-type with default thiscall convention.
-   It returns true if function match, otherwise false is returned.  */
+  if (TARGET_64BIT)
+return IX86_CALLCVT_CDECL;
 
-static bool
-ix86_is_type_thiscall (const_tree type)
-{
-  if (lookup_attribute (thiscall, TYPE_ATTRIBUTES (type))
-  || ix86_is_msabi_thiscall (type))
-return true;
-  return false;
+  if (lookup_attribute (cdecl, TYPE_ATTRIBUTES (type)))
+ret |= IX86_CALLCVT_CDECL;
+  else if (lookup_attribute (stdcall, TYPE_ATTRIBUTES (type)))
+ret |= IX86_CALLCVT_STDCALL;
+  else if (lookup_attribute (fastcall, TYPE_ATTRIBUTES (type)))
+ret |= IX86_CALLCVT_FASTCALL;
+  else if (lookup_attribute (thiscall, TYPE_ATTRIBUTES (type)))
+ret |= 

Re: PATCH: PR middle-end/48440: [4.7 Regression] FAIL: gcc.c-torture/compile/labels-3.c

2011-04-07 Thread H.J. Lu
On Thu, Apr 7, 2011 at 5:34 AM, Michael Matz m...@suse.de wrote:
 Hi,

 On Thu, 7 Apr 2011, Richard Guenther wrote:

  5600      newx = simplify_subreg (outermode, op, innermode, byte);
  (gdb) f 1
  #1  0x00708494 in expand_expr_real_2 (ops=0x7fffb0c0, 
  target=0x0,
     tmode=VOIDmode, modifier=EXPAND_INITIALIZER)
     at /export/gnu/import/git/gcc-x32/gcc/expr.c:7366
  7366                op0 = simplify_gen_subreg (mode, op0, inner_mode,
  (gdb) call debug_tree (treeop0)
   addr_expr 0x70a78d50
     type pointer_type 0x70b83f18
         type void_type 0x70b83e70 void VOID
             align 8 symtab 0 alias set -1 canonical type 0x70b83e70
             pointer_to_this pointer_type 0x70b83f18
         sizes-gimplified public unsigned SI
     arg 0 label_decl 0x70b7b400 l2 type void_type 0x70b83e70 void
  (gdb) call debug_rtx (op0)
  (label_ref/v:DI 22)
  (gdb)
 

 First I wonder what CONSTANT_P object we arrive with here (it looks like
 something unfolded, given that we likely came here with a NOP_EXPR).

 The CONSTANT_P object is the '(label_ref/v:DI 22)'.  Not only CONST_INT
 are CONSTANT_P, also some others (symbol_ref too).  Those might have a
 mode.  Here the label_ref has DImode, but the pointer type in trees points
 to an SImode.  The latter makes sense, because that's what ptr_mode is for
 HJs target.

 HJ: you'll need to tell us what you mean with 'breaks
 gcc.c-torture/compile/labels-3.c' .  What breaks, in which way?


I got

#0  fancy_abort (
file=0x12470e0 /export/gnu/import/git/gcc-x32/gcc/simplify-rtx.c,
line=5266, function=0x1248470 simplify_subreg)
at /export/gnu/import/git/gcc-x32/gcc/diagnostic.c:893
#1  0x009d0ab5 in simplify_subreg (outermode=HImode, op=0x70c55dd0,
innermode=SImode, byte=0)
at /export/gnu/import/git/gcc-x32/gcc/simplify-rtx.c:5265
#2  0x009d1e83 in simplify_gen_subreg (outermode=HImode,
op=0x70c55dd0, innermode=SImode, byte=0)
at /export/gnu/import/git/gcc-x32/gcc/simplify-rtx.c:5600
#3  0x00708736 in expand_expr_real_2 (ops=0x7fffb480, target=0x0,
tmode=VOIDmode, modifier=EXPAND_INITIALIZER)
at /export/gnu/import/git/gcc-x32/gcc/expr.c:7366
#4  0x007153e1 in expand_expr_real_1 (exp=0x70a87f30, target=0x0,
tmode=VOIDmode, modifier=EXPAND_INITIALIZER, alt_rtl=0x0)
at /export/gnu/import/git/gcc-x32/gcc/expr.c:9728
..
(gdb) f 3
#3  0x00708736 in expand_expr_real_2 (ops=0x7fffb480, target=0x0,
tmode=VOIDmode, modifier=EXPAND_INITIALIZER)
at /export/gnu/import/git/gcc-x32/gcc/expr.c:7366
7366op0 = simplify_gen_subreg (mode, op0, inner_mode,
(gdb) call debug_rtx (op0)
(label_ref/v:DI 22)
(gdb) p  inner_mode
$2 = SImode
(gdb)

We are calling simplify_gen_subreg with wrong inner_mode.

-- 
H.J.


[PATCH, M68K] Handle -fsched-pressure

2011-04-07 Thread Maxim Kuvyrkov
The following simple patch fixes a corner-case in m68k scheduling when 
-fsched-pressure is used.  Currently m68k scheduling hooks assume that the 
scheduler honors DFA restrictions, which is not always the case when scheduling 
for register pressure (-fsched-pressure).  The patch fixes this corner-case.

I will commit this patch under the trivial rule in 4 days (on Monday) or sooner 
if I get an explicit approval.

Thank you,

--
Maxim Kuvyrkov
Mentor Graphics / CodeSourcery
+7-812-677-6839



fsf-gcc-m68k-sched_pressure.ChangeLog
Description: Binary data


fsf-gcc-m68k-sched_pressure.patch
Description: Binary data


Re: Convert legacy m68k options to .opt aliases

2011-04-07 Thread Gunther Nikl
On Wed, Apr 06, 2011 at 10:04:37PM +, Joseph S. Myers wrote:
 Similar to http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00265.html,
 this patch converts legacy m68k options for non-ColdFire CPUs into
 aliases for the corresponding -mcpu= options.  (Note that -mcpu32 is

While I agree with the CF change, I am sceptical with the m68k case.

 an alias for -mcpu=68332 rather than -mcpu=cpu32, to match the old
 code in m68k_handle_option.)  This significantly simplifies the
 multilibs code in t-mlibs, since it no longer needs to handle those
 old-style options (and all cases where two -mcpu= options get the same
 multilib are already handled by the generic logic there rather than
 needing to be listed specially).  The requirement for binutils 2.17 or
 later (to support these options to the assembler) is documented.

I am using m68k-amigos which is not part of the official sources. Since
this target is only about m68k it was no problem to use old(er) binutils
versions. Especially if a target cares only about m68k I would like to
see the legacy m68k options retained.

Regards,
Gunther Nikl



Re: [PATCH] Cleanup, use add_to_hard_reg_set instead of SET_HARD_REG_BIT loops.

2011-04-07 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 04/06/11 12:21, Anatoly Sokolov wrote:
 Hi.
 
   This patch converts loops of SET_HARD_REG_BIT in to add_to_hard_reg_set 
 functions call.
 
   The patch has been bootstrapped on and regression tested on
 x86_64-unknown-linux-gnu for c.
 
   OK to install?
 
 * expr.c (expand_expr_real_1): Use add_to_hard_reg_set function
 instead of loop.
 * sel-sched.c (mark_unavailable_hard_regs): Likewise.
 * function.c (record_hard_reg_sets): Likewise.
 * ira.c (compute_regs_asm_clobbered): Likewise.
 * sched-deps.c (sched_analyze_1): Likewise.
 * reload1.c (mark_reload_reg_in_use, choose_reload_regs): Likewise.
 
 


 Index: gcc/expr.c
 ===
 --- gcc/expr.c  (revision 172049)
 +++ gcc/expr.c  (working copy)
 @@ -8451,18 +8451,10 @@
gcc_assert (decl_rtl);
decl_rtl = copy_rtx (decl_rtl);
/* Record writes to register variables.  */
 -  if (modifier == EXPAND_WRITE  REG_P (decl_rtl)
 -  REGNO (decl_rtl)  FIRST_PSEUDO_REGISTER)
 -   {
 -   int i = REGNO (decl_rtl);
 -   int nregs = hard_regno_nregs[i][GET_MODE (decl_rtl)];
 -   while (nregs)
 - {
 -   SET_HARD_REG_BIT (crtl-asm_clobbers, i);
 -   i++;
 -   nregs--;
 - }
 -   }
 +  if (modifier == EXPAND_WRITE
 +  REG_P (decl_rtl)  HARD_REGISTER_P (decl_rtl))
 +add_to_hard_reg_set (crtl-asm_clobbers,
 +GET_MODE (decl_rtl), REGNO (decl_rtl));
Minor formatting nit, can you put the  HARD_REGISTER_P (decl_rtl) on a
separate line.  Generally once we have multi-line conditionals we try to
put a single conditional on each line.

OK with that change.

Thanks,
jeff

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNndOsAAoJEBRtltQi2kC7U8kH/34KJ5Rl8tcA6KZTYE8Q+/dq
fekev3UJPXlzpARvbz1L4H8+bZFWNVOfmC1FktsO5slA6I8uxZp6mfFZvKmvWaNh
cJJ/tevjY80NVkaksEPIdvM5nE7RZXHzLvHsBUhHtL0NER1wVUsWlLI06/qlIoCG
/vyM/GUUAzjzkyA6AQPCPvOQPgcJmTLuYNJ5w1o9H7SQlFPXJO/KNUpAblr6Wpiq
veyVSMTd4LU+FjBGUsGLUOWWovOJicbHZlONE7Ti9rOUFepyCevtsSXqdisn0srM
X2PMQ6EdD4wfoVZK0gBFQUKAEEs7c4iN03+Y6oIRq3V/wjxeazExbOHilXnYm2o=
=99Re
-END PGP SIGNATURE-


Re: Convert legacy m68k options to .opt aliases

2011-04-07 Thread Joseph S. Myers
On Thu, 7 Apr 2011, Gunther Nikl wrote:

  an alias for -mcpu=68332 rather than -mcpu=cpu32, to match the old
  code in m68k_handle_option.)  This significantly simplifies the
  multilibs code in t-mlibs, since it no longer needs to handle those
  old-style options (and all cases where two -mcpu= options get the same
  multilib are already handled by the generic logic there rather than
  needing to be listed specially).  The requirement for binutils 2.17 or
  later (to support these options to the assembler) is documented.
 
 I am using m68k-amigos which is not part of the official sources. Since
 this target is only about m68k it was no problem to use old(er) binutils
 versions. Especially if a target cares only about m68k I would like to
 see the legacy m68k options retained.

I don't see out-of-tree targets as providing a relevant case for blocking 
cleanups, and in any case I think GCC should require a reasonably recent 
binutils (more recent than 2.17) on all targets except where it is 
specifically supporting a native system assembler or linker (even there, 
I don't think system assembler support is particularly important except 
where the system tools have features missing from GNU binutils).  The 
legacy options still exist - it's just that they'll be passed to the 
assembler in the canonical -mcpu= form, so you need an assembler 
supporting that form (which any GNU assembler from the past five years 
will do - and I don't think supporting a five-year disparity between GCC 
and binutils versions is productive).

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


[testsuite] Don't XFAIL gcc.target/i386/asm-6.c on 32-bit Solaris 10+/x86

2011-04-07 Thread Rainer Orth
gcc.target/i386/asm-6.c recently started XPASSing on Solaris 10+/x86.
There's evidence in PR rtl-optimization/44174 that this isn't just an
accident, so I'm removing the XFAIL to reduce the noise.

Tested with the appropriate runtest invocation on i386-pc-solaris2.11,
installed on mainline.

Rainer


2011-04-02  Rainer Orth  r...@cebitec.uni-bielefeld.de

* gcc.target/i386/asm-6.c: Remove dg-xfail-if.

diff --git a/gcc/testsuite/gcc.target/i386/asm-6.c 
b/gcc/testsuite/gcc.target/i386/asm-6.c
--- a/gcc/testsuite/gcc.target/i386/asm-6.c
+++ b/gcc/testsuite/gcc.target/i386/asm-6.c
@@ -3,7 +3,6 @@
 
 /* { dg-do compile } */
 /* { dg-options -O2 -fpic { target fpic } } */
-/* { dg-xfail-if  { i?86-pc-solaris2.1[0-9]  ilp32 } } */
 
 int f0 (int, int, int, int, int);
 int f1 (void);


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


[PATCH] sel-sched: Fix an incorrect assert (PR 48442)

2011-04-07 Thread Alexander Monakov
Hi,

This patch fixes an incorrect assert in init_seqno and cleans up adjacent code
a bit by removing an unneeded argument.

Bootstrapped and regtested together with other recent sel-sched fixes on
x86_64-linux with scheduler enabled at -O2.  OK for  trunk?

PR rtl-optimization/48442
* sel-sched.c (init_seqno): Remove number_of_insns argument.  Update
all callers.  Adjust assert.

testsuite:
* gcc.dg/pr48442.c: New.

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 9179249..0e8173b 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -6731,15 +6731,14 @@ init_seqno_1 (basic_block bb, sbitmap visited_bbs, 
bitmap blocks_to_reschedule)
 INSN_SEQNO (insn) = cur_seqno--;
 }
 
-/* Initialize seqnos for the current region.  NUMBER_OF_INSNS is the number
-   of instructions in the region, BLOCKS_TO_RESCHEDULE contains blocks on
-   which we're rescheduling when pipelining, FROM is the block where
+/* Initialize seqnos for the current region.  BLOCKS_TO_RESCHEDULE contains
+   blocks on which we're rescheduling when pipelining, FROM is the block where
traversing region begins (it may not be the head of the region when
pipelining, but the head of the loop instead).
 
Returns the maximal seqno found.  */
 static int
-init_seqno (int number_of_insns, bitmap blocks_to_reschedule, basic_block from)
+init_seqno (bitmap blocks_to_reschedule, basic_block from)
 {
   sbitmap visited_bbs;
   bitmap_iterator bi;
@@ -6762,9 +6761,13 @@ init_seqno (int number_of_insns, bitmap 
blocks_to_reschedule, basic_block from)
   from = EBB_FIRST_BB (0);
 }
 
-  cur_seqno = number_of_insns  0 ? number_of_insns : sched_max_luid - 1;
+  cur_seqno = sched_max_luid - 1;
   init_seqno_1 (from, visited_bbs, blocks_to_reschedule);
-  gcc_assert (cur_seqno == 0 || number_of_insns == 0);
+
+  /* cur_seqno may be positive if the number of instructions is less than
+ sched_max_luid - 1 (when rescheduling or if some instructions have been
+ removed by the call to purge_empty_blocks in sel_sched_region_1).  */
+  gcc_assert (cur_seqno = 0);
 
   sbitmap_free (visited_bbs);
   return sched_max_luid - 1;
@@ -7473,17 +7476,12 @@ sel_sched_region_2 (int orig_max_seqno)
 static void
 sel_sched_region_1 (void)
 {
-  int number_of_insns;
   int orig_max_seqno;
 
-  /* Remove empty blocks that might be in the region from the beginning.
- We need to do save sched_max_luid before that, as it actually shows
- the number of insns in the region, and purge_empty_blocks can
- alter it.  */
-  number_of_insns = sched_max_luid - 1;
+  /* Remove empty blocks that might be in the region from the beginning.  */
   purge_empty_blocks ();
 
-  orig_max_seqno = init_seqno (number_of_insns, NULL, NULL);
+  orig_max_seqno = init_seqno (NULL, NULL);
   gcc_assert (orig_max_seqno = 1);
 
   /* When pipelining outer loops, create fences on the loop header,
@@ -7560,7 +7558,7 @@ sel_sched_region_1 (void)
 {
   flist_tail_init (new_fences);
 
-  orig_max_seqno = init_seqno (0, blocks_to_reschedule, bb);
+  orig_max_seqno = init_seqno (blocks_to_reschedule, bb);
 
   /* Mark BB as head of the new ebb.  */
   bitmap_set_bit (forced_ebb_heads, bb-index);
diff --git a/gcc/testsuite/gcc.dg/pr48442.c b/gcc/testsuite/gcc.dg/pr48442.c
new file mode 100644
index 000..88e3497
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48442.c
@@ -0,0 +1,27 @@
+/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
+/* { dg-options -Os -fselective-scheduling2 --param 
max-sched-extend-regions-iters=100 } */
+void f (void)
+{
+  unsigned *a2;
+  int vertex2;
+  int c, x2, dx2, dy2, s2;
+  long m, b;
+  do
+{
+  if (dx2)
+   dx2 = dx2 % dy2;
+   s2 = (dx2 / dy2);
+}
+  while (vertex2);
+  for (;;)
+{
+  c = x2;
+  a2 = 0;
+  if (c)
+   {
+ m = b  (c);
+ *a2 = (*a2  ~m);
+   }
+  x2 += s2;
+}
+}



[PATCH] sel-sched: Don't clone CALLs (PR48273)

2011-04-07 Thread Alexander Monakov
Hi,

Selective scheduler does not explicitly forbid creating bookkeeping copies of
CALLs, but an assert in create_copy_of_insn_rtx does not expect a CALL.  Since
there's little benefit from aggressive scheduling of CALLs, it makes sense to
restrict it so that CALLs cannot be duplicated.

This patch makes CALLs non-clonable by adding an explicit check in additional
to other non-clonable insns (ASMs, instructions that are a part of
SCHED_GROUPs, etc.).  We also need to forbid pipelining of loops that have no
exit edges, since our check for whether a motion would create bookkeeping does
not work in that case (it's one of the solutions; the other is to fixup
remove_insns_that_need_bookkeeping function, but this one is simpler and
faster).


PR target/48273
* cfgloop.h (loop_has_exit_edges): New helper.
* sel-sched-ir.c (init_global_and_expr_for_insn): Make CALLs
non-clonable.
(sel_setup_region_sched_flags): Don't pipeline loops that have no
exit edges.

testsuite:
* g++.dg/opt/pr48273.C: New.

diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index f7bb134..0ff44de 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -443,6 +443,14 @@ loop_outer (const struct loop *loop)
   return VEC_index (loop_p, loop-superloops, n - 1);
 }
 
+/* Returns true if LOOP has at least one exit edge.  */
+
+static inline bool
+loop_has_exit_edges (const struct loop *loop)
+{
+  return loop-exits-next-e != NULL;
+}
+
 /* Returns the list of loops in current_loops.  */
 
 static inline VEC (loop_p, gc) *
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 67484dd..95c1431 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -2905,6 +2905,7 @@ init_global_and_expr_for_insn (insn_t insn)
   if (CANT_MOVE (insn)
   || INSN_ASM_P (insn)
   || SCHED_GROUP_P (insn)
+ || CALL_P (insn)
   /* Exception handling insns are always unique.  */
   || (cfun-can_throw_non_call_exceptions  can_throw_internal (insn))
   /* TRAP_IF though have an INSN code is control_flow_insn_p ().  */
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 0e8173b..fb1a026 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -6781,7 +6781,8 @@ sel_setup_region_sched_flags (void)
   bookkeeping_p = 1;
   pipelining_p = (bookkeeping_p
(flag_sel_sched_pipelining != 0)
-  current_loop_nest != NULL);
+  current_loop_nest != NULL
+  loop_has_exit_edges (current_loop_nest));
   max_insns_to_rename = PARAM_VALUE (PARAM_SELSCHED_INSNS_TO_RENAME);
   max_ws = MAX_WS;
 }
diff --git a/gcc/testsuite/g++.dg/opt/pr48273.C 
b/gcc/testsuite/g++.dg/opt/pr48273.C
new file mode 100644
index 000..4c5108b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr48273.C
@@ -0,0 +1,10 @@
+// { dg-do compile { target x86_64-*-* } }
+// { dg-options -fschedule-insns2 -fsel-sched-pipelining 
-fselective-scheduling2 -funroll-all-loops -march=core2 }
+
+void bar ();
+
+void foo ()
+{
+  for (;;)
+bar ();
+}


[PATCH] sel-sched: Fix adding of preheader blocks from inner loops (PR48302)

2011-04-07 Thread Alexander Monakov
Hello,

(quoting myself from the PR audit trail)
We call sched_scan for preheader blocks from inner regions twice: first during
sel_add_loop_preheaders, and then during the subsequent call to sel_init_bbs
in setup_current_loop_nest.  As a result, we also call remove_notes for those
blocks twice, and after the second call incorrectly record that the block has
no notes.

The solution is to call sel_add_loop_preheaders after sel_init_bbs.  We need
to add new preheader blocks into 'bbs' vector in setup_current_loop_nest, so
we pass the pointer to the vector to sel_add_loop_preheaders.


PR rtl-optimization/48302
* sel-sched-ir.h (sel_add_loop_preheaders): Update prototype.
* sel-sched-ir.c (sel_add_loop_preheaders): Add 'bbs' argument.  Use
it to record added preheader blocks.
(setup_current_loop_nest): Add 'bbs' argument.  Pass it on to
sel_add_loop_preheaders.
(sel_region_init): Move call to setup_current_loop_nest after
sel_init_bbs.

testsuite:
g++.dg/opt/pr48302.C: New.

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 95c1431..a6daa58 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -6094,11 +6094,11 @@ sel_find_rgns (void)
   bbs_in_loop_rgns = NULL;
 }
 
-/* Adds the preheader blocks from previous loop to current region taking
-   it from LOOP_PREHEADER_BLOCKS (current_loop_nest).
+/* Add the preheader blocks from previous loop to current region taking
+   it from LOOP_PREHEADER_BLOCKS (current_loop_nest) and record them in *BBS.
This function is only used with -fsel-sched-pipelining-outer-loops.  */
 void
-sel_add_loop_preheaders (void)
+sel_add_loop_preheaders (bb_vec_t *bbs)
 {
   int i;
   basic_block bb;
@@ -6109,6 +6109,7 @@ sel_add_loop_preheaders (void)
VEC_iterate (basic_block, preheader_blocks, i, bb);
i++)
 {
+  VEC_safe_push (basic_block, heap, *bbs, bb);
   VEC_safe_push (basic_block, heap, last_added_blocks, bb);
   sel_add_bb (bb);
 }
diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h
index 5516da9..b0c52eb 100644
--- a/gcc/sel-sched-ir.h
+++ b/gcc/sel-sched-ir.h
@@ -1628,7 +1628,7 @@ extern void sel_sched_region (int);
 extern loop_p get_loop_nest_for_rgn (unsigned int);
 extern bool considered_for_pipelining_p (struct loop *);
 extern void make_region_from_loop_preheader (VEC(basic_block, heap) **);
-extern void sel_add_loop_preheaders (void);
+extern void sel_add_loop_preheaders (bb_vec_t *);
 extern bool sel_is_loop_preheader_p (basic_block);
 extern void clear_outdated_rtx_info (basic_block);
 extern void free_data_sets (basic_block);
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index fb1a026..48fb2e0 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -6801,7 +6801,7 @@ current_region_empty_p (void)
 
 /* Prepare and verify loop nest for pipelining.  */
 static void
-setup_current_loop_nest (int rgn)
+setup_current_loop_nest (int rgn, bb_vec_t *bbs)
 {
   current_loop_nest = get_loop_nest_for_rgn (rgn);
 
@@ -6810,7 +6810,7 @@ setup_current_loop_nest (int rgn)
 
   /* If this loop has any saved loop preheaders from nested loops,
  add these basic blocks to the current region.  */
-  sel_add_loop_preheaders ();
+  sel_add_loop_preheaders (bbs);
 
   /* Check that we're starting with a valid information.  */
   gcc_assert (loop_latch_edge (current_loop_nest));
@@ -6849,9 +6849,6 @@ sel_region_init (int rgn)
   if (current_region_empty_p ())
 return true;
 
-  if (flag_sel_sched_pipelining)
-setup_current_loop_nest (rgn);
-
   sel_setup_region_sched_flags ();
 
   bbs = VEC_alloc (basic_block, heap, current_nr_blocks);
@@ -6861,6 +6858,9 @@ sel_region_init (int rgn)
 
   sel_init_bbs (bbs, NULL);
 
+  if (flag_sel_sched_pipelining)
+setup_current_loop_nest (rgn, bbs);
+
   /* Initialize luids and dependence analysis which both sel-sched and haifa
  need.  */
   sched_init_luids (bbs, NULL, NULL, NULL);
diff --git a/gcc/testsuite/g++.dg/opt/pr48302.C 
b/gcc/testsuite/g++.dg/opt/pr48302.C
new file mode 100644
index 000..fd51ba4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr48302.C
@@ -0,0 +1,21 @@
+// { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } }
+// { dg-options -O -fcrossjumping -fgcse -fschedule-insns2 
-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops 
-fselective-scheduling2 --param lim-expensive=320 --param 
min-crossjump-insns=1 }
+
+struct S
+{
+  int i, j;
+  S *s;
+  ~S();
+};
+
+S *gs;
+
+void foo ()
+{
+restart:
+  for (S *s = gs; s; s = s-s)
+if (s-j  s-j != (s-i  1)) {
+   delete s;
+   goto restart;
+  }
+}



[PATCH] sel-sched: Fix erroneous re-use of pointer to last insn in a BB (PR 48235)

2011-04-07 Thread Alexander Monakov
Hello,

This patch fixes a couple of places where code motion machinery wrongly
attempts to re-use a pointer to the last insn in a BB after control flow
following that BB has been changed (so the last jump might have been removed
or replaced).  This is not too frequent, so the solution is to simply
recompute the last instruction if we notice the CFG change.

Bootstrapped and regtested on x86_64-linux together with other recently
submitted sel-sched fixes; OK for trunk?  (I forgot to mention this in two
other e-mails; sorry).


2011-04-07  Dmitry Melnik  d...@ispras.ru

PR rtl-optimization/48235
* sel-sched.c (code_motion_process_successors): Recompute the last
insn in basic block if control flow changed.
(code_motion_path_driver): Ditto.  Recompute the first insn as well.
Update condition for ilist_remove.

testsuite:
gcc.dg/pr48235.c: New.

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 48fb2e0..f409c4f 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -6369,7 +6369,10 @@ code_motion_process_successors (insn_t insn, av_set_t 
orig_ops,
  the iterator becomes invalid.  We need to try again.  */
   if (BLOCK_FOR_INSN (insn)-index != old_index
   || EDGE_COUNT (bb-succs) != old_succs)
-goto rescan;
+{
+  insn = sel_bb_end (BLOCK_FOR_INSN (insn));
+  goto rescan;
+}
 }
 
 #ifdef ENABLE_CHECKING
@@ -6587,21 +6590,37 @@ code_motion_path_driver (insn_t insn, av_set_t 
orig_ops, ilist_t path,
   if (!expr)
 {
   int res;
+  rtx last_insn = PREV_INSN (insn);
+  bool added_to_path;
 
   gcc_assert (insn == sel_bb_end (bb));
 
   /* Add bb tail to PATH (but it doesn't make any sense if it's a bb_head -
 it's already in PATH then).  */
   if (insn != first_insn)
-   ilist_add (path, insn);
+   {
+ ilist_add (path, insn);
+ added_to_path = true;
+   }
+  else
+added_to_path = false;
 
   /* Process_successors should be able to find at least one
 successor for which code_motion_path_driver returns TRUE.  */
   res = code_motion_process_successors (insn, orig_ops,
 path, static_params);
 
+  /* Jump in the end of basic block could have been removed or replaced
+ during code_motion_process_successors, so recompute insn as the
+ last insn in bb.  */
+  if (NEXT_INSN (last_insn) != insn)
+{
+  insn = sel_bb_end (bb);
+  first_insn = sel_bb_head (bb);
+}
+
   /* Remove bb tail from path.  */
-  if (insn != first_insn)
+  if (added_to_path)
ilist_remove (path);
 
   if (res != 1)
diff --git a/gcc/testsuite/gcc.dg/pr48235.c b/gcc/testsuite/gcc.dg/pr48235.c
new file mode 100644
index 000..8ec5edb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48235.c
@@ -0,0 +1,57 @@
+/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
+/* { dg-options -O -fno-guess-branch-probability -fpeel-loops 
-freorder-blocks-and-partition -fschedule-insns2 -fsel-sched-pipelining 
-fselective-scheduling2 } */
+struct intC
+{
+  short x;
+  short y;
+};
+
+int size_x;
+
+static inline int
+TileDiffXY (int x, int y)
+{
+  return (y * size_x) + x;
+}
+
+struct HangarTileTable
+{
+  struct intC ti;
+  int hangar_num;
+};
+
+struct AirportSpec
+{
+  struct HangarTileTable *depot_table;
+  int size;
+};
+
+void Get ();
+struct AirportSpec dummy;
+
+static inline int
+GetRotatedTileFromOffset (int *a, struct intC tidc)
+{
+  if (!*a)
+Get ();
+  switch (*a)
+{
+case 0:
+  return (tidc.y  size_x) + tidc.x;
+case 1:
+  return TileDiffXY (tidc.y, dummy.size - tidc.x);
+case 2:
+  return TileDiffXY (tidc.x, dummy.size - tidc.y);
+case 3:
+  return TileDiffXY (dummy.size - 1, tidc.x);
+}
+}
+
+int
+GetHangarNum (int *a)
+{
+   int i;
+  for (i = 0; i  dummy.size; i++)
+if (GetRotatedTileFromOffset (a, dummy.depot_table[i].ti))
+  return dummy.depot_table[i].hangar_num;
+}



[pph] Macro Validation (issue4379044)

2011-04-07 Thread Lawrence Crowl
In my last PPH change, I eliminated the redundancy in the preprocessor
identifier lookaside table by removing the name of the identifier from
the head of the macro value.  This later led to a buffer overrun in
libcpp/symtab.c cpp_lt_replay.  The buffer was allocated based on the
value string size, which is was no longer large enough to hold the
definition string.

Split cpp_idents_used.max_length and cpp_lookaside.max_length into
max_ident_len and max_value_len.  In cpp_lt_replay, allocate the
buffer based on the sum of max_ident_len and max_value_len.

The simple macro validation scheme for PTH is not sufficient for
PPH.  In particular, in libcpp, even identifiers that are skipped
in preprocessing are entered into the symbol table.  We need to
ignore these.  So, add two macro attributes, used_by_directive and
expanded_to_text.  If neither of these attributes is set, then the
macro is not used and can be ignored for validation and replay.

These changes bring the macro validation to a workable state.  There
may be some fine tuning later.

Make an inability to open a PPH file for reading a plain error rather
than a fatal error.  Fatal errors do not seem to play well with tests.

Adjust tests to reflect changes.  There is still one unexpected
failure, p1mean.cc does not compare equal in assembly.  Not yet
investigated.


gcc/testsuite/ChangeLog.pph

2011-04-06  Lawrence Crowl  cr...@google.com

* g++.dg/pph/p1mean.cc: Now pass validation.
* g++.dg/pph/p1stdlib.cc: Likewise.
* g++.dg/pph/d1symnotinc.cc: Failure to read is now not fatal.
* g++.dg/pph/d1chained.cc: Miscategorized as a failure, ...
* g++.dg/pph/c1chained.cc: so it has been renamed.

gcc/cp/ChangeLog.pph

2011-04-06  Lawrence Crowl  cr...@google.com

* pph.c (pth_dump_identifiers):  Split cpp_idents_used::max_length
into max_ident_length and max_value_length.  Print used_by_directive
and expanded_to_text attributes of macros.
(pth_save_identifiers): Split cpp_idents_used::max_length into
max_ident_length and max_value_length.  Filter out macro that are
neither used_by_directive nor expanded_to_text, which requires
precounting the number of entries remaining.  Save used_by_directive
and expanded_to_text attributes of the macros.
(pth_load_identifiers): Split cpp_idents_used::max_length into
max_ident_length and max_value_length.  Restore used_by_directive and
expanded_to_text attributes of the macros.
(pph_read_file): Make failure to read a pph file a non-fatal error.

libcpp/ChangeLog.pph

2011-04-06  Lawrence Crowl cr...@google.com

* include/cpplib.h (struct cpp_hashnode): Add used_by_directive and
expanded_to_text attributes for macros.  Take their bits from
directive_index, which does not need them.
* include/symtab.h (struct cpp_idents_used): Split max_length into
max_ident_len and max_value_len.  Reorder fields to avoid gaps.
(struct cpp_ident_use): Add used_by_directive and expanded_to_text
attributes for macros.
* internal.h (struct cpp_lookaside): Split max_length into
max_ident_len and max_value_len.
* macro.c (enter_macro_context): Mark expanded_to_text macro attribute.
* directives.c (DIRECTIVE_TABLE): Add sizing comment.
(do_define): Mark used_by_directive macro attribute.
(do_undef): Likewise.
(do_ifdef): Likewise.
* expr.c (parse_defined): Mark used_by_directive macro attribute.
* symtab.c (cpp_lt_create): Split cpp_lookaside::max_length into
max_ident_len and max_value_len.
* (lt_macro_value): Likewise.
* (lt_lookup): Likewise.
* (cpp_lt_capture): Likewise.  Also save used_by_directive and
expanded_to_text attributes of macros.
* (cpp_lt_replay): Split cpp_idents_used::max_lenth into
max_ident_len and max_value_len.  Allocate a buffer with the sum.


Index: gcc/testsuite/g++.dg/pph/p1mean.cc
===
*** gcc/testsuite/g++.dg/pph/p1mean.cc  (revision 172001)
--- gcc/testsuite/g++.dg/pph/p1mean.cc  (working copy)
***
*** 1,9 
! #include stdlib.h // {dg-error fails macro validation  { xfail *-*-* } }
! #include stdio.h // {dg-error fails macro validation  { xfail *-*-* } }
! #include math.h // {dg-error fails macro validation  { xfail *-*-* } }
! #include string.h // {dg-error fails macro validation  { xfail *-*-* } }
! // { dg-excess-errors In file included from { xfail *-*-* } }
! // { dg-excess-errors assembly comparison { xfail *-*-* } }
  
  static unsigned long long MAX_ITEMS = 1;
  
--- 1,7 
! #include stdlib.h
! #include stdio.h
! #include math.h
! #include string.h
  
  static unsigned long long MAX_ITEMS = 1;
  
Index: gcc/testsuite/g++.dg/pph/d1symnotinc.cc

[PATCH] Several backports to 4.5 branch

2011-04-07 Thread Jakub Jelinek
Hi!

I've backported a couple of patches to 4.5 branch and committed them
after bootstrapping/regtesting on x86_64-linux and i686-linux.

Additionally, I've added testcase for PR fortran/48117
to 4.5 (where it is newly fixed) and 4.6/4.7 (where it has been
fixed quite some time ago already by Richard during MEM_REF fixing).

Jakub
2011-04-07  Jakub Jelinek  ja...@redhat.com

Backported from mainline
2010-07-01  Richard Guenther  rguent...@suse.de

* omp-low.c (scan_omp_1_op): Don't change type of INTEGER_CSTs
directly.

--- gcc/omp-low.c   (revision 161654)
+++ gcc/omp-low.c   (revision 161655)
@@ -1916,7 +1916,18 @@ scan_omp_1_op (tree *tp, int *walk_subtr
{
  *walk_subtrees = 1;
  if (ctx)
-   TREE_TYPE (t) = remap_type (TREE_TYPE (t), ctx-cb);
+   {
+ tree tem = remap_type (TREE_TYPE (t), ctx-cb);
+ if (tem != TREE_TYPE (t))
+   {
+ if (TREE_CODE (t) == INTEGER_CST)
+   *tp = build_int_cst_wide (tem,
+ TREE_INT_CST_LOW (t),
+ TREE_INT_CST_HIGH (t));
+ else
+   TREE_TYPE (t) = tem;
+   }
+   }
}
   break;
 }
2011-04-07  Jakub Jelinek  ja...@redhat.com

PR tree-optimization/47391
* tree-ssa-ccp.c (get_symbol_constant_value): Don't optimize
if sym is volatile.

Backport from mainline
2011-01-21  Jakub Jelinek  ja...@redhat.com
 
PR tree-optimization/47391
* gcc.dg/pr47391.c: New test.

--- gcc/tree-ssa-ccp.c.jj   2011-03-09 20:44:38.0 +0100
+++ gcc/tree-ssa-ccp.c  2011-04-07 17:59:48.003808381 +0200
@@ -277,7 +277,7 @@ tree
 get_symbol_constant_value (tree sym)
 {
   if (TREE_STATIC (sym)
-   (TREE_READONLY (sym)
+   ((TREE_READONLY (sym)  !TREE_THIS_VOLATILE (sym))
  || TREE_CODE (sym) == CONST_DECL))
 {
   tree val = DECL_INITIAL (sym);
--- gcc/testsuite/gcc.dg/pr47391.c  (revision 0)
+++ gcc/testsuite/gcc.dg/pr47391.c  (revision 169084)
@@ -0,0 +1,22 @@
+/* PR tree-optimization/47391 */
+/* { dg-do compile } */
+/* { dg-options -O2 -fdump-tree-optimized } */
+
+const volatile int v = 1;
+int i = 0;
+
+void
+foo (void)
+{
+  i = v;
+}
+
+int
+main (void)
+{
+  foo ();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-not i = 1; optimized } } */
+/* { dg-final { cleanup-tree-dump optimized } } */
2011-04-07  Jakub Jelinek  ja...@redhat.com

Backported from mainline
2011-01-26  Jakub Jelinek  ja...@redhat.com

PR c/47473
* c-lex.c (interpret_float): If CPP_N_IMAGINARY, ensure
EXCESS_PRECISION_EXPR is created with COMPLEX_TYPE instead of
REAL_TYPE.

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

--- gcc/c-lex.c (revision 169298)
+++ gcc/c-lex.c (revision 169299)
@@ -752,8 +752,15 @@ interpret_float (const cpp_token *token,
   /* Create a node with determined type and value.  */
   value = build_real (const_type, real);
   if (flags  CPP_N_IMAGINARY)
-value = build_complex (NULL_TREE, convert (const_type, integer_zero_node),
-  value);
+{
+  value = build_complex (NULL_TREE, convert (const_type,
+integer_zero_node), value);
+  if (type != const_type)
+   {
+ const_type = TREE_TYPE (value);
+ type = build_complex_type (type);
+   }
+}
 
   if (type != const_type)
 value = build1 (EXCESS_PRECISION_EXPR, type, value);
--- gcc/testsuite/gcc.dg/torture/pr47473.c  (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr47473.c  (revision 169299)
@@ -0,0 +1,14 @@
+/* PR c/47473 */
+/* { dg-do run } */
+/* { dg-options -std=c99 } */
+
+int
+main (void)
+{
+  long double _Complex w = 0.2L - 0.3iL;
+  w = w * (0.3L - (0.0F + 1.0iF) * 0.9L);
+  if (__builtin_fabsl (__real__ w + 0.21L)  0.001L
+  || __builtin_fabsl (__imag__ w + 0.27L)  0.001L)
+__builtin_abort ();
+  return 0;
+}
2011-04-07  Jakub Jelinek  ja...@redhat.com

Backported from mainline
2011-02-19  Jakub Jelinek  ja...@redhat.com

PR c/47809
* c-common.c (c_fully_fold_internal): Handle VIEW_CONVERT_EXPR.

* gcc.target/i386/pr47809.c: New test.

--- gcc/c-common.c  (revision 170322)
+++ gcc/c-common.c  (revision 170323)
@@ -1213,6 +1213,7 @@ c_fully_fold_internal (tree expr, bool i
 case FIX_TRUNC_EXPR:
 case FLOAT_EXPR:
 CASE_CONVERT:
+case VIEW_CONVERT_EXPR:
 case NON_LVALUE_EXPR:
 case NEGATE_EXPR:
 case BIT_NOT_EXPR:
--- gcc/testsuite/gcc.target/i386/pr47809.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr47809.c (revision 170323)
@@ -0,0 +1,13 @@
+/* PR c/47809 */
+/* { dg-do compile } */
+/* { dg-options -O2 -msse2 } */
+
+#include emmintrin.h
+double bar (double, double);
+
+__m128d
+foo 

[patch, fortran] More control over front end optimization

2011-04-07 Thread Thomas Koenig

Hello world,

following Joost's request, the attached patch gives the user more 
control over front end optimization - it can now be selected or 
deselected independent of normal optimization.  I have also implemented 
a warning for eliminated functions.


Regression-tested.

Once this is in, I will also mention the new options in the changes file.

OK for trunk?

2011-04-07  Thomas Koenig  tkoe...@gcc.gnu.org

PR fortran/48448
* gfortran.h (gfc_option_t):  Add warn_function_elimination and
flag_frontend_optimize.
* lang.opt (Wfunction-elimination):  Add.
(ffrontend-optimize):  Add.
* invoke.texi:  Add documentation for -Wfunction-elimination
and -ffrontend-optimize.  Add -faggressive-function-elimination
to list of code generation options.
* frontend-passes.c (gfc_run_passes):  Run optimizations if
flag_frontend_optimize is set.
(warn_function_elimination):  New function.
(cfe_expr_0):  Call it if requested to do so.
* options.c (gfc_init_options):  Initiate warn_function_elimination
and flag_frontend_optimize.
(gfc_post_options):  Set flag_frontend_optimize if not specified
by user, depending on the optimization level.
(gfc_handle_option):  Handle -Wfunction-elimination and
-ffrontend-optimize.

2011-04-07  Thomas Koenig  tkoe...@gcc.gnu.org

PR fortran/48448
* gfortran.dg/function_optimize_5.f90:  New test.
Index: gfortran.h
===
--- gfortran.h	(Revision 172058)
+++ gfortran.h	(Arbeitskopie)
@@ -2180,6 +2180,7 @@ typedef struct
   int warn_ampersand;
   int gfc_warn_conversion;
   int warn_conversion_extra;
+  int warn_function_elimination;
   int warn_implicit_interface;
   int warn_implicit_procedure;
   int warn_line_truncation;
@@ -2234,6 +2235,7 @@ typedef struct
   int flag_protect_parens;
   int flag_realloc_lhs;
   int flag_aggressive_function_elimination;
+  int flag_frontend_optimize;
 
   int fpe;
   int rtcheck;
Index: lang.opt
===
--- lang.opt	(Revision 172058)
+++ lang.opt	(Arbeitskopie)
@@ -222,6 +222,10 @@ Wconversion-extra
 Fortran Warning
 Warn about most implicit conversions
 
+Wfunction-elimination
+Fortran Warning
+Warn about function call elimination
+
 Wimplicit-interface
 Fortran Warning
 Warn about calls with implicit interface
@@ -414,6 +418,10 @@ ffree-line-length-
 Fortran RejectNegative Joined UInteger
 -ffree-line-length-n	Use n as character line width in free mode
 
+ffrontend-optimize
+Fortran
+Enable front end optimization
+
 fimplicit-none
 Fortran
 Specify that no implicit typing is allowed, unless overridden by explicit IMPLICIT statements
Index: invoke.texi
===
--- invoke.texi	(Revision 172058)
+++ invoke.texi	(Arbeitskopie)
@@ -139,7 +139,7 @@ and warnings}.
 -Wall  -Waliasing  -Wampersand  -Warray-bounds -Wcharacter-truncation @gol
 -Wconversion -Wimplicit-interface  -Wimplicit-procedure  -Wline-truncation @gol
 -Wintrinsics-std  -Wsurprising  -Wno-tabs  -Wunderflow  -Wunused-parameter @gol
--Wintrinsic-shadow  -Wno-align-commons}
+-Wintrinsic-shadow  -Wno-align-commons -Wfunction-elimination}
 
 @item Debugging Options
 @xref{Debugging Options,,Options for debugging your program or GNU Fortran}.
@@ -171,7 +171,8 @@ and warnings}.
 -fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol
 -finit-integer=@var{n} -finit-real=@var{zero|inf|-inf|nan|snan} @gol
 -finit-logical=@var{true|false} -finit-character=@var{n} @gol
--fno-align-commons -fno-protect-parens -frealloc-lhs}
+-fno-align-commons -fno-protect-parens -frealloc-lhs @gol
+-faggressive-function-elimination -ffrontend-optimize}
 @end table
 
 @menu
@@ -859,6 +860,14 @@ By default, @command{gfortran} warns about any occ
 padded for proper alignment inside a @code{COMMON} block. This warning can be turned
 off via @option{-Wno-align-commons}. See also @option{-falign-commons}.
 
+@item -Wfunction-elimination
+@opindex @code{Wfunction-elimination}
+@cindex function elimination
+@cindex warnings, function elimination
+Warn if any calls to functions are eliminated by the
+@option{-ffrontend-optimize} option.
+
+
 @item -Werror
 @opindex @code{Werror}
 @cindex warnings, to errors
@@ -1482,8 +1491,15 @@ statements, regardless of whether these functions
 @smallexample
   a = f(b,c) + f(b,c)
 @end smallexample
-there will only be a single call to @code{f}.
+there will only be a single call to @code{f}.  This option only works
+if @option{-ffrontend-optimize} is in effect.
 
+@item -ffrontend-optimize
+@opindex @code{frontend-optimize}
+@cindex Front-end optimization
+This option performs front-end optimization, based on the Fortran parse
+tree.  Enabled by default by any @option{-O} option.  It can
+be deselcted by specifying @option{-fno-frontend-optimize}.
 @end 

patch to fix PR 48435

2011-04-07 Thread Vladimir Makarov
The following patch should solve problem 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48435.  It might solve other 
latest IRA problems too including performance related ones.  The patch 
is for targets which require some values to be placed in hard registers 
starting with an even (odd) hard registers.


I already addressed an analogous problem recently and the patch I sent 
that time although solved some problems it created even more new 
problems.  I should acknowledge this.


The problem was in that profitable hard regs were used for colorability 
criterion and finding hard registers where allocno values can be resided 
but *also* as starting allocno hard registers.  It resulted in spilling 
allocnos which should be placed in multi-registers starting on a 
specific border because profitable hard registers were only starting 
registers and when we calculated number of available hard registers 
multi-register allocnos can not fit only in their starting hard registers.


The following patch was successfully bootstrapped on x86/x86-64 and on 
i686 with H.J.'s autotester options.


OK to commit?

2011-04-07  Vladimir Makarov vmaka...@redhat.com

PR 4435
* ira-color.c (setup_profitable_hard_regs): Add comments.
Don't take prohibited hard regs into account.
(setup_conflict_profitable_regs): Rename to
get_conflict_profitable_regs.
(check_hard_reg_p): Check prohibited hard regs.



Index: ira-color.c
===
--- ira-color.c (revision 172107)
+++ ira-color.c (working copy)
@@ -1057,6 +1057,8 @@ setup_profitable_hard_regs (void)
   enum reg_class aclass;
   enum machine_mode mode;
 
+  /* Initial set up from allocno classes and explicitly conflicting
+ hard regs.  */
   EXECUTE_IF_SET_IN_BITMAP (coloring_allocno_bitmap, 0, i, bi)
 {
   a = ira_allocnos[i];
@@ -1076,9 +1078,6 @@ setup_profitable_hard_regs (void)
{
  COPY_HARD_REG_SET (obj_data-profitable_hard_regs,
 reg_class_contents[aclass]);
- AND_COMPL_HARD_REG_SET
-   (obj_data-profitable_hard_regs,
-ira_prohibited_class_mode_regs[aclass][mode]);
  AND_COMPL_HARD_REG_SET (obj_data-profitable_hard_regs,
  ira_no_alloc_regs);
  AND_COMPL_HARD_REG_SET (obj_data-profitable_hard_regs,
@@ -1086,6 +1085,7 @@ setup_profitable_hard_regs (void)
}
}
 }
+  /* Exclude hard regs already assigned for conflicting objects.  */
   EXECUTE_IF_SET_IN_BITMAP (consideration_allocno_bitmap, 0, i, bi)
 {
   a = ira_allocnos[i];
@@ -1124,6 +1124,7 @@ setup_profitable_hard_regs (void)
}
}
 }
+  /* Exclude too costly hard regs.  */
   EXECUTE_IF_SET_IN_BITMAP (coloring_allocno_bitmap, 0, i, bi)
 {
   int min_cost = INT_MAX;
@@ -1451,9 +1452,9 @@ update_conflict_hard_regno_costs (int *c
profitable regs exclude hard regs which can not hold value of mode
of allocno A.  */
 static inline void
-setup_conflict_profitable_regs (ira_allocno_t a, bool retry_p,
-   HARD_REG_SET *conflict_regs,
-   HARD_REG_SET *profitable_regs)
+get_conflict_profitable_regs (ira_allocno_t a, bool retry_p,
+ HARD_REG_SET *conflict_regs,
+ HARD_REG_SET *profitable_regs)
 {
   int i, nwords;
   ira_object_t obj;
@@ -1485,8 +1486,15 @@ check_hard_reg_p (ira_allocno_t a, int h
  HARD_REG_SET *conflict_regs, HARD_REG_SET *profitable_regs)
 {
   int j, nwords, nregs;
+  enum reg_class aclass;
+  enum machine_mode mode;
 
-  nregs = hard_regno_nregs[hard_regno][ALLOCNO_MODE (a)];
+  aclass = ALLOCNO_CLASS (a);
+  mode = ALLOCNO_MODE (a);
+  if (TEST_HARD_REG_BIT (ira_prohibited_class_mode_regs[aclass][mode],
+hard_regno))
+return false;
+  nregs = hard_regno_nregs[hard_regno][mode];
   nwords = ALLOCNO_NUM_OBJECTS (a);
   for (j = 0; j  nregs; j++)
 {
@@ -1554,8 +1562,8 @@ assign_hard_reg (ira_allocno_t a, bool r
 #endif
 
   ira_assert (! ALLOCNO_ASSIGNED_P (a));
-  setup_conflict_profitable_regs (a, retry_p,
- conflicting_regs, profitable_hard_regs);
+  get_conflict_profitable_regs (a, retry_p,
+   conflicting_regs, profitable_hard_regs);
   aclass = ALLOCNO_CLASS (a);
   class_size = ira_class_hard_regs_num[aclass];
   best_hard_regno = -1;
@@ -2233,7 +2241,8 @@ setup_allocno_available_regs_num (ira_al
  ira_object_t obj = ALLOCNO_OBJECT (a, k);
  object_color_data_t obj_data = OBJECT_COLOR_DATA (obj);
 
- /* Checking only profitable hard regs.  */
+ /* Checking only profitable hard regs which exclude
+object's conflict hard regs.  */
  if (TEST_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
   

Patch: add {tree,gimple}-pretty-print.h realmpfr.h to PLUGIN_HEADERS

2011-04-07 Thread Basile Starynkevitch

Hello All,

The following tiny patch add some files to PLUGIN_HEADERS. 
Since they are missing in 4.6, I had to copy them in the MELT plugin 
tar ball release candidate 0.

# tiny patch to trunk 172124
Index: gcc/Makefile.in
===
--- gcc/Makefile.in (revision 172124)
+++ gcc/Makefile.in (working copy)
@@ -4534,6 +4534,7 @@
   $(EXCEPT_H) tree-ssa-sccvn.h real.h output.h $(IPA_UTILS_H) \
   $(C_PRAGMA_H)  $(CPPLIB_H)  $(FUNCTION_H) \
   cppdefault.h flags.h $(MD5_H) params.def params.h prefix.h
tree-inline.h \
+  gimple-pretty-print.h tree-pretty-print.h realmpfr.h \
   $(IPA_PROP_H) $(RTL_H) $(TM_P_H) $(CFGLOOP_H) $(EMIT_RTL_H) version.h
 
 # generate the 'build fragment' b-header-vars
## gcc/ChangeLog entry
2011-04-07  Basile Starynkevitch  bas...@starynkevitch.net
* Makefile.in (PLUGIN_HEADERS): Add gimple-pretty-print.h 
tree-pretty-print.h  realmpfr.h.
##


Some more explanations about why I feel these files are badly needed
for plugins (not only for MELT as a plugin, but for other plugins).

Pretty printing routines are very useful to help understand, debug, and
dump any additional passes, so plugin providing passes working on
Gimple or Tree need the gimple-pretty-print.h  tree-pretty-print.h, 
since to call dumping or debug routines like debug_c_tree or 
print_declaration or dump_gimple_stmt you need to include these files.
Please consider that people coding plugins know Gimple  Tree much 
less than GCC top level experts, and they are much more likely to 
need debug or dumping routines!

The realmpfr.h file is needed to operate on tree or gimple containing 
real constants. For instance, a plugin to find all occurrences (in
Gimple) of 3.14159 need it, or also a plugin which constant-fold the
calls to math.h which are not already constant folded in GCC, or a
plugin which constant-fold calls to some other (but less standard)
numerical library.

Ok for trunk?

Cheers.

PS. If I am lucky enough to have this patch accepted for trunk, 
I might even later consider proposing to backport it to gcc 4.6.1.

-- 
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basileatstarynkevitchdotnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


Re: [4.5] Backport various selective scheduler patches to 4.5 branch

2011-04-07 Thread Vladimir Makarov

On 04/06/2011 07:08 AM, Andrey Belevantsev wrote:

Hello,

As we discussed in PR 43603, we need to do another round of sel-sched 
patches' backporting to 4.5 -- there were a few reports about the 
problems already fixed on trunk.  I have successfully bootstrapped and 
tested on x86-64 and ia64 the unified patch (attached) that backports 
fixes for the following PRs:


43603
45352
45354
45570
45652
46204
46518
46521
46522
46585
46602
46649
46875
47036
48144

The only changes outside of sel-sched* files are introducing 
get_reg_base_value function in alias.c for PR 45652 and fixing 
sched_create_recovery_edges in haifa-sched.c for dominator info 
updates in PR 43603.  Both of those are safe.  All patches are in 
trunk for quite some time.


There are 13 separate patches (some of the bugs required several 
patches which were merged in one during the backport), and I plan to 
commit them separately tomorrow unless RMs (or anybody) objects.


The patch for PR 48144 is not yet committed to 4.6, I will do the 
backport separately (it is the only one that requires backporting atm).

It is ok for me.  Thanks for working on gcc-4.5.



Re: Patch: add {tree,gimple}-pretty-print.h realmpfr.h to PLUGIN_HEADERS

2011-04-07 Thread Basile Starynkevitch
On Thu, 7 Apr 2011 21:41:18 +0200
Basile Starynkevitch bas...@starynkevitch.net wrote:

 
 Hello All,
 
 The following tiny patch add some files to PLUGIN_HEADERS. 
 Since they are missing in 4.6, I had to copy them in the MELT plugin 
 tar ball release candidate 0.

Sorry, my mailer wrapped the patch in line. I am attaching it here.

Cheers
-- 
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basileatstarynkevitchdotnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***
Index: gcc/Makefile.in
===
--- gcc/Makefile.in	(revision 172124)
+++ gcc/Makefile.in	(working copy)
@@ -4534,6 +4534,7 @@
   $(EXCEPT_H) tree-ssa-sccvn.h real.h output.h $(IPA_UTILS_H) \
   $(C_PRAGMA_H)  $(CPPLIB_H)  $(FUNCTION_H) \
   cppdefault.h flags.h $(MD5_H) params.def params.h prefix.h tree-inline.h \
+  gimple-pretty-print.h tree-pretty-print.h realmpfr.h \
   $(IPA_PROP_H) $(RTL_H) $(TM_P_H) $(CFGLOOP_H) $(EMIT_RTL_H) version.h
 
 # generate the 'build fragment' b-header-vars


Re: [patch, fortran] More control over front end optimization

2011-04-07 Thread Daniel Kraft

Hi,

On 04/07/11 21:32, Thomas Koenig wrote:

following Joost's request, the attached patch gives the user more
control over front end optimization - it can now be selected or
deselected independent of normal optimization. I have also implemented a
warning for eliminated functions.

Regression-tested.

Once this is in, I will also mention the new options in the changes file.

OK for trunk?


Ok.  Just my opinion (as non-native-speaker), though:

+Wfunction-elimination
+Fortran Warning
+Warn about function call elimination

-Wfunction-elimination sounds misleading to me -- just under the name, 
I would imagine you mean eliminating whole functions; as in never used 
(anymore), remove.  Since you mean elimination of *calls* to functions, 
could you use something like -Wcall-elimination?  (Does not sound that 
much better... but if you have an idea, I would prefer a clearer option 
name.  Otherwise just leave it.)


+Warn if any calls to functions are eliminated by the
+@option{-ffrontend-optimize} option.

I also do not completely like are eliminated by the -ffrontend-optimize 
option -- since to me it is not *the option* which eliminates the 
calls; but the elimination is implied by the option... or something like 
that.  But as before, if you have a good alternative I would love to see 
one, otherwise just leave it.


The code looks good to me.

Yours,
Daniel

--
http://www.pro-vegan.info/
--
Done:  Arc-Bar-Cav-Kni-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Mon-Pri


Re: [PATCH] sel-sched: Don't clone CALLs (PR48273)

2011-04-07 Thread Vladimir Makarov

On 04/07/2011 01:30 PM, Alexander Monakov wrote:

Hi,

Selective scheduler does not explicitly forbid creating bookkeeping copies of
CALLs, but an assert in create_copy_of_insn_rtx does not expect a CALL.  Since
there's little benefit from aggressive scheduling of CALLs, it makes sense to
restrict it so that CALLs cannot be duplicated.

This patch makes CALLs non-clonable by adding an explicit check in additional
to other non-clonable insns (ASMs, instructions that are a part of
SCHED_GROUPs, etc.).  We also need to forbid pipelining of loops that have no
exit edges, since our check for whether a motion would create bookkeeping does
not work in that case (it's one of the solutions; the other is to fixup
remove_insns_that_need_bookkeeping function, but this one is simpler and
faster).


PR target/48273
* cfgloop.h (loop_has_exit_edges): New helper.
* sel-sched-ir.c (init_global_and_expr_for_insn): Make CALLs
non-clonable.
(sel_setup_region_sched_flags): Don't pipeline loops that have no
exit edges.

testsuite:
* g++.dg/opt/pr48273.C: New.


Ok, thanks.




Re: [PATCH] sel-sched: Fix adding of preheader blocks from inner loops (PR48302)

2011-04-07 Thread Vladimir Makarov

On 04/07/2011 01:34 PM, Alexander Monakov wrote:

Hello,

(quoting myself from the PR audit trail)
We call sched_scan for preheader blocks from inner regions twice: first during
sel_add_loop_preheaders, and then during the subsequent call to sel_init_bbs
in setup_current_loop_nest.  As a result, we also call remove_notes for those
blocks twice, and after the second call incorrectly record that the block has
no notes.

The solution is to call sel_add_loop_preheaders after sel_init_bbs.  We need
to add new preheader blocks into 'bbs' vector in setup_current_loop_nest, so
we pass the pointer to the vector to sel_add_loop_preheaders.


PR rtl-optimization/48302
* sel-sched-ir.h (sel_add_loop_preheaders): Update prototype.
* sel-sched-ir.c (sel_add_loop_preheaders): Add 'bbs' argument.  Use
it to record added preheader blocks.
(setup_current_loop_nest): Add 'bbs' argument.  Pass it on to
sel_add_loop_preheaders.
(sel_region_init): Move call to setup_current_loop_nest after
sel_init_bbs.

testsuite:
g++.dg/opt/pr48302.C: New.

Ok, thanks.



[4.5/4.6 PATCH, i386]: Some random fixes in SSE patterns.

2011-04-07 Thread Uros Bizjak
Hello!

2011-04-07  Uros Bizjak  ubiz...@gmail.com

* config/i386/sse.md: Update copyright year.
(avx_cmpssescalarmodesuffixmode3): Add missing output
register constraint.
(*vec_concatv2sf_avx): Fix wrong register constraint in
alternative 3 of operand 1.
(*vec_setmode_0_avx): Avoid combining registers from different
units in a single alternative.
(*vec_setmode_0_sse4_1): Ditto.
(*vec_setmode_0_sse2): Ditto.
(vec_setmode_0): Ditto.
(sse2_storehpd): Ditto.
(sse2_loadhpd): Ditto.
(sse4_1_insertps): Use nonimmediate_operand for operand 2.
* config/i386/predicates.md (sse_comparison_operator): Do not
define as special predicate.

Tested on x86_64-pc-linux-gnu, will be committed to 4.5 and 4.6 branches.

Uros.
Index: predicates.md
===
--- predicates.md   (revision 172124)
+++ predicates.md   (working copy)
@@ -969,13 +969,8 @@
 ;; Return true if OP is a comparison that can be used in the CMPSS/CMPPS insns.
 ;; The first set are supported directly; the second set can't be done with
 ;; full IEEE support, i.e. NaNs.
-;;
-;; ??? It would seem that we have a lot of uses of this predicate that pass
-;; it the wrong mode.  We got away with this because the old function didn't
-;; check the mode at all.  Mirror that for now by calling this a special
-;; predicate.
 
-(define_special_predicate sse_comparison_operator
+(define_predicate sse_comparison_operator
   (match_code eq,lt,le,unordered,ne,unge,ungt,ordered))
 
 ;; Return true if OP is a comparison operator that can be issued by
Index: sse.md
===
--- sse.md  (revision 172124)
+++ sse.md  (working copy)
@@ -1,5 +1,5 @@
 ;; GCC machine description for SSE instructions
-;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
+;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;; Free Software Foundation, Inc.
 ;;
 ;; This file is part of GCC.
@@ -1557,7 +1557,7 @@
(set_attr mode MODE)])
 
 (define_insn avx_cmpssescalarmodesuffixmode3
-  [(set (match_operand:SSEMODEF2P 0 register_operand )
+  [(set (match_operand:SSEMODEF2P 0 register_operand =x)
(vec_merge:SSEMODEF2P
  (unspec:SSEMODEF2P
[(match_operand:SSEMODEF2P 1 register_operand x)
@@ -3846,7 +3846,7 @@
 (define_insn *vec_concatv2sf_avx
   [(set (match_operand:V2SF 0 register_operand =x,x,x,*y ,*y)
(vec_concat:V2SF
- (match_operand:SF 1 nonimmediate_operand  x,x,m, x , m)
+ (match_operand:SF 1 nonimmediate_operand  x,x,m, 0 , m)
  (match_operand:SF 2 vector_move_operand   x,m,C,*ym, C)))]
   TARGET_AVX
   @
@@ -3935,13 +3935,15 @@
   DONE;
 })
 
+;; Avoid combining registers from different units in a single alternative,
+;; see comment above inline_secondary_memory_needed function in i386.c
 (define_insn *vec_setmode_0_avx
-  [(set (match_operand:SSEMODE4S 0 nonimmediate_operand  =x,x, x,x,  x,m)
+  [(set (match_operand:SSEMODE4S 0 nonimmediate_operand  =x,x, x,x,  x,m, 
m,m)
(vec_merge:SSEMODE4S
  (vec_duplicate:SSEMODE4S
(match_operand:ssescalarmode 2
- general_operand 
x,m,*r,x,*rm,x*rfF))
- (match_operand:SSEMODE4S 1 vector_move_operand  C,C, C,x,  x,0)
+ general_operand 
x,m,*r,x,*rm,x,*r,fF))
+ (match_operand:SSEMODE4S 1 vector_move_operand  C,C, C,x,  x,0, 
0,0)
  (const_int 1)))]
   TARGET_AVX
   @
@@ -3950,20 +3952,24 @@
vmovd\t{%2, %0|%0, %2}
vmovss\t{%2, %1, %0|%0, %1, %2}
vpinsrd\t{$0, %2, %1, %0|%0, %1, %2, 0}
+   #
+   #
#
-  [(set_attr type sselog,ssemov,ssemov,ssemov,sselog,*)
-   (set_attr prefix_extra *,*,*,*,1,*)
-   (set_attr length_immediate *,*,*,*,1,*)
+  [(set_attr type sselog,ssemov,ssemov,ssemov,sselog,*,*,*)
+   (set_attr prefix_extra *,*,*,*,1,*,*,*)
+   (set_attr length_immediate *,*,*,*,1,*,*,*)
(set_attr prefix vex)
-   (set_attr mode SF,ssescalarmode,SI,SF,TI,*)])
+   (set_attr mode SF,ssescalarmode,SI,SF,TI,*,*,*)])
 
+;; Avoid combining registers from different units in a single alternative,
+;; see comment above inline_secondary_memory_needed function in i386.c
 (define_insn *vec_setmode_0_sse4_1
-  [(set (match_operand:SSEMODE4S 0 nonimmediate_operand  =x,x, x,x,  x,m)
+  [(set (match_operand:SSEMODE4S 0 nonimmediate_operand  =x,x, x,x,  x, 
m,m)
(vec_merge:SSEMODE4S
  (vec_duplicate:SSEMODE4S
(match_operand:ssescalarmode 2
- general_operand 
x,m,*r,x,*rm,*rfF))
- (match_operand:SSEMODE4S 1 vector_move_operand  C,C, C,0,  0,0)
+ general_operand 
x,m,*r,x,*rm,*r,fF))
+ (match_operand:SSEMODE4S 1 vector_move_operand  C,C, C,0,  0, 0,0)
  (const_int 1)))]
   

Re: [patch, fortran] More control over front end optimization

2011-04-07 Thread Mikael Morin
Hello, 

On Thursday 07 April 2011 21:50:46 Daniel Kraft wrote:
 Ok.  Just my opinion (as non-native-speaker), though:

+@item -ffrontend-optimize
+@opindex @code{frontend-optimize}
+@cindex Front-end optimization
+This option performs front-end optimization, based on the Fortran parse
+tree.  Enabled by default by any @option{-O} option.  It can
+be deselcted by specifying @option{-fno-frontend-optimize}.
 @end table

s/deselcted/deselected/ ?
I think you are not specific enough about frontend optimizations. 
frontend optimization consists of:
 * the trim/trim_len stuff 
 * the duplicate function call removal stuff
This is documented nowhere ( but the C source ;-) ) as far as I know.

 The code looks good to me.

Mikael




fix non-local-goto-5.c

2011-04-07 Thread Mike Stump
This fixes non-local-goto-5.c on targets that don't have trampolines.  Noticed 
in the 4.6.0 release.

2011-04-07  Mike Stump  mikest...@comcast.net

* gcc.dg/torture/stackalign/non-local-goto-5.c: Fix for targets
with no trampolines.

Index: gcc.dg/torture/stackalign/non-local-goto-5.c
===
--- gcc.dg/torture/stackalign/non-local-goto-5.c(revision 172125)
+++ gcc.dg/torture/stackalign/non-local-goto-5.c(working copy)
@@ -1,8 +1,8 @@
 /* { dg-do run } */
 
+extern void exit (int);
 #if !defined (NO_LABEL_VALUES)  !defined (NO_TRAMPOLINES)
 extern void abort (void);
-extern void exit (int);
 int s(i){if(i0){__label__ l1;int f(int i){if(i==2)goto l1;return 0;}return 
f(i);l1:;}return 1;}
 int x(){return s(0)==1s(1)==0s(2)==1;}
 int main(){if(x()!=1)abort();exit(0);}


Re: [RFC] Remove kludge in commit_edge_insertions

2011-04-07 Thread Eric Botcazou
   * basic-block.h (force_nonfallthru): Move to...
   * cfghooks.h (struct cfg_hooks): Add force_nonfallthru hook.
   (force_nonfallthru): ...here.
   * cfghooks.c (force_nonfallthru): New function.
   * cfgrtl.c (force_nonfallthru): Rename into...
   (rtl_force_nonfallthru): ...this.
   (commit_one_edge_insertion): Do not set AUX field.
   (commit_edge_insertions): Do not discover new basic blocks.
   (rtl_cfg_hooks): Add rtl_force_nonfallthru.
   (cfg_layout_rtl_cfg_hooks): Likewise.
   * function.c (thread_prologue_and_epilogue_insns): Remove bogus
   ATTRIBUTE_UNUSED.  Discover new basic blocks in the prologue insns.
   * tree-cfg.c (gimple_cfg_hooks): Add NULL for force_nonfallthru.

Installed after bootstrapping/regtesting on SPARC/Solaris, SPARC64/Solaris, 
IA-64/Linux and re-bootstrapping/regtesting on x86-64/Linux.

-- 
Eric Botcazou


[PATCH] 4.4 backports

2011-04-07 Thread Jakub Jelinek
Hi!

And here are 3 backported patches plus one testcase to 4.4 branch,
committed after bootstrap/regtest on x86_64-linux and i686-linux.

Jakub
2011-04-07  Jakub Jelinek  ja...@redhat.com

PR tree-optimization/46491
Backported from mainline
2010-05-14  Jan Hubicka  j...@suse.cz
* ipa-pure-const.c (check_stmt): Do not use memory_identifier_string.

2011-04-07  Jakub Jelinek  ja...@redhat.com

Backported from mainline
2010-11-15  Jakub Jelinek  ja...@redhat.com

PR tree-optimization/46491
* gcc.target/i386/pr46491.c: New test.

--- gcc/ipa-pure-const.c(revision 166773)
+++ gcc/ipa-pure-const.c(revision 166774)
@@ -360,7 +360,7 @@ get_asm_expr_operands (funct_state local
   for (i = 0; i  gimple_asm_nclobbers (stmt); i++)
 {
   op = gimple_asm_clobber_op (stmt, i);
-  if (simple_cst_equal(TREE_VALUE (op), memory_identifier_string) == 1) 
+  if (strcmp (TREE_STRING_POINTER (TREE_VALUE (op)), memory) == 0)
/* Abandon all hope, ye who enter here. */
local-pure_const_state = IPA_NEITHER;
 }
--- gcc/testsuite/gcc.target/i386/pr46491.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr46491.c (revision 166774)
@@ -0,0 +1,22 @@
+/* PR tree-optimization/46491 */
+/* { dg-do run } */
+/* { dg-options -O2 -fno-ipa-reference } */
+
+extern void abort (void);
+
+__attribute__((noinline)) int
+foo (int *p)
+{
+  int r;
+  asm (movl $6, (%1)\n\txorl %0, %0 : =r (r) : r (p) : memory);
+  return r;
+}
+
+int
+main (void)
+{
+  int p = 8;
+  if ((foo (p) ? : p) != 6)
+abort ();
+  return 0;
+}
2011-04-07  Jakub Jelinek  ja...@redhat.com

Backported from mainline
2011-03-17  Jakub Jelinek  ja...@redhat.com

PR rtl-optimization/48141
* dse.c (record_store): If no positions are needed in an insn
that cannot be deleted, at least unchain it from active_local_stores.

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

--- gcc/dse.c   (revision 171088)
+++ gcc/dse.c   (revision 171089)
@@ -1588,8 +1588,7 @@ record_store (rtx body, bb_info_t bb_inf
 
   /* An insn can be deleted if every position of every one of
 its s_infos is zero.  */
-  if (any_positions_needed_p (s_info)
- || ptr-cannot_delete)
+  if (any_positions_needed_p (s_info))
del = false;
 
   if (del)
@@ -1600,8 +1599,9 @@ record_store (rtx body, bb_info_t bb_inf
last-next_local_store = ptr-next_local_store;
  else
active_local_stores = ptr-next_local_store;
- 
- delete_dead_store_insn (insn_to_delete);
+
+ if (!insn_to_delete-cannot_delete)
+   delete_dead_store_insn (insn_to_delete);
}
   else
last = ptr;
--- gcc/testsuite/gcc.dg/pr48141.c  (revision 0)
+++ gcc/testsuite/gcc.dg/pr48141.c  (revision 171089)
@@ -0,0 +1,17 @@
+/* PR rtl-optimization/48141 */
+/* { dg-do compile } */
+/* { dg-options -O -fno-tree-fre } */
+
+#define A i = 0;
+#define B A A A A A A A A A A
+#define C B B B B B B B B B B
+#define D C C C C C C C C C C
+#define E D D D D D D D D D D
+
+int
+foo (void)
+{
+  volatile int i = 0;
+  E E E E E E E E E E E
+  return 0;
+}
2011-04-07  Jakub Jelinek  ja...@redhat.com

Backported from mainline
2011-04-06  Jakub Jelinek  ja...@redhat.com

PR debug/48466
* dwarf2out.c (based_loc_descr): If drap_reg is INVALID_REGNUM, use
as base_reg whatever register reg has been eliminated to, instead
of hardcoding STACK_POINTER_REGNUM.

--- gcc/dwarf2out.c (revision 172063)
+++ gcc/dwarf2out.c (revision 172064)
@@ -13545,7 +13545,7 @@ based_loc_descr (rtx reg, HOST_WIDE_INT 
  int base_reg
= DWARF_FRAME_REGNUM ((fde  fde-drap_reg != INVALID_REGNUM)
  ? HARD_FRAME_POINTER_REGNUM
- : STACK_POINTER_REGNUM);
+ : REGNO (elim));
  return new_reg_loc_descr (base_reg, offset);
}
 
2011-04-07  Jakub Jelinek  ja...@redhat.com

PR fortran/48117
* gfortran.dg/gomp/pr48117.f90: New test.

--- gcc/testsuite/gfortran.dg/gomp/pr48117.f90.jj   2011-01-16 
05:42:39.626675592 +0100
+++ gcc/testsuite/gfortran.dg/gomp/pr48117.f90  2011-04-07 16:43:20.902808325 
+0200
@@ -0,0 +1,11 @@
+! PR fortran/48117
+! { dg-do compile }
+! { dg-options -O2 -fopenmp }
+
+subroutine foo(x)
+  character(len=*), optional :: x
+  character(len=80) :: v
+  !$omp master
+if (present(x)) v = adjustl(x)
+  !$omp end master
+end subroutine foo


Re: [gc-improv] Permanent vs function RTL obstack fix

2011-04-07 Thread Steven Bosscher
On Thu, Apr 7, 2011 at 8:17 AM, Laurynas Biveinis
laurynas.bivei...@gmail.com wrote:
 Fixes a bunch of C testsuite failures. Committed to gc-improv.

 2011-04-07  Laurynas Biveinis  laurynas.bivei...@gmail.com

        * stmt.c (label_rtx): Allocate RTX in permanent RTL memory.

That looks strange, labels should be function specific, except
non-local labels. Maybe you can get away with allocating DECL_NONLOCAL
labels on the permanent rtl obstack?

Perhaps a third, per-translation-unit obstack is necessary?

Ciao!
Steven


Re: Avoid global state in rx_handle_option

2011-04-07 Thread Joseph S. Myers
There was a bug in how the conversion to Enum was done in this patch; I've 
applied this followup patch to fix it.

Index: ChangeLog
===
--- ChangeLog   (revision 172137)
+++ ChangeLog   (working copy)
@@ -1,5 +1,10 @@
 2011-04-07  Joseph Myers  jos...@codesourcery.com
 
+   * config/rx/rx.opt (rx610, rx200, rx600): Use Enum not Name on
+   EnumValue lines.
+
+2011-04-07  Joseph Myers  jos...@codesourcery.com
+
* config/m68k/m68k.c (m68k_handle_option): Don't handle
OPT_m68000, OPT_mc68000, OPT_m68010, OPT_m68020, OPT_mc68020,
OPT_m68030, OPT_m68040, OPT_m68060, OPT_m68302, OPT_m68332 and
Index: config/rx/rx.opt
===
--- config/rx/rx.opt(revision 172137)
+++ config/rx/rx.opt(working copy)
@@ -53,13 +53,13 @@
 Name(rx_cpu_types) Type(enum rx_cpu_types)
 
 EnumValue
-Name(rx_cpu_types) String(rx610) Value(RX610)
+Enum(rx_cpu_types) String(rx610) Value(RX610)
 
 EnumValue
-Name(rx_cpu_types) String(rx200) Value(RX200)
+Enum(rx_cpu_types) String(rx200) Value(RX200)
 
 EnumValue
-Name(rx_cpu_types) String(rx600) Value(RX600)
+Enum(rx_cpu_types) String(rx600) Value(RX600)
 
 ;---
 

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


new option -Wno-maybe-uninitialized

2011-04-07 Thread Xinliang David Li
Hi,

the following patch implements the option to fine control the emitted
warnings --
1) allow suppressing warnings for use of values that may be
uninitialized.  Definitely uninitialized values that may be used
warning is not affected
2) allow fine grain control on promotion of warnings to errors:
-Wno-error=maybe-uninitialized

This is useful for users who only care about definite uninitialized
variable warnings.

Ok for trunk?

thanks,

David


2011-04-07  Xinliang David Li  davi...@google.com

* tree-ssa-uninit.c (warn_uninitialized_phi): Pass
warning code.
* c-family/c-opts.c (c_common_handle_option): Set
warn_maybe_uninitialized.
* opts.c (common_handle_option): Ditto.
* common.opt:  New option.
* tree-ssa.c (warn_uninit): Add one more parameter.
(warn_uninitialized_var): Pass warning code.
* tree-flow.h: Interface change.



2011-04-07  Xinliang David Li  davi...@google.com

* gcc.dg/uninit-suppress.c: New test.
* gcc.dg/uninit-suppress_2.c: New test.
Index: doc/invoke.texi
===
--- doc/invoke.texi	(revision 171959)
+++ doc/invoke.texi	(working copy)
@@ -246,11 +246,11 @@ Objective-C and Objective-C++ Dialects}.
 -Wformat-security  -Wformat-y2k @gol
 -Wframe-larger-than=@var{len} -Wjump-misses-init -Wignored-qualifiers @gol
 -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int @gol
--Winit-self  -Winline @gol
+-Winit-self  -Winline -Wmaybe-uninitialized @gol
 -Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol
 -Winvalid-pch -Wlarger-than=@var{len}  -Wunsafe-loop-optimizations @gol
 -Wlogical-op -Wlong-long @gol
--Wmain  -Wmissing-braces  -Wmissing-field-initializers @gol
+-Wmain -Wmaybe-uninitialized -Wmissing-braces  -Wmissing-field-initializers @gol
 -Wmissing-format-attribute  -Wmissing-include-dirs @gol
 -Wno-mudflap @gol
 -Wno-multichar  -Wnonnull  -Wno-overflow @gol
@@ -2945,6 +2945,7 @@ Options} and @ref{Objective-C and Object
 -Wcomment  @gol
 -Wformat   @gol
 -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}  @gol
+-Wmaybe-uninitialized @gol
 -Wmissing-braces  @gol
 -Wnonnull  @gol
 -Wparentheses  @gol
@@ -3529,8 +3530,15 @@ to compute a value that itself is never 
 computations may be deleted by data flow analysis before the warnings
 are printed.
 
-These warnings are made optional because GCC is not smart
-enough to see all the reasons why the code might be correct
+@item -Wmaybe-uninitialized
+@opindex Wmaybe-uninitialized
+@opindex Wno-maybe-uninitialized
+For an automatic variable, if there exists a path from the function
+entry to a use of the variable that is initialized, but there exist
+some other paths the variable is not initialized, the compiler will
+emit a warning if it can not prove the uninitialized paths do not
+happen at runtime. These warnings are made optional because GCC is 
+not smart enough to see all the reasons why the code might be correct
 despite appearing to have an error.  Here is one example of how
 this can happen:
 
@@ -3553,20 +3561,9 @@ this can happen:
 
 @noindent
 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
-always initialized, but GCC doesn't know this.  Here is
-another common case:
-
-@smallexample
-@{
-  int save_y;
-  if (change_y) save_y = y, y = new_y;
-  @dots{}
-  if (change_y) y = save_y;
-@}
-@end smallexample
-
-@noindent
-This has no bug because @code{save_y} is used only if it is set.
+always initialized, but GCC doesn't know this. To suppress the
+warning, the user needs to provide a default case with assert(0) or
+similar code.
 
 @cindex @code{longjmp} warnings
 This option also warns when a non-volatile automatic variable might be
Index: tree-ssa-uninit.c
===
--- tree-ssa-uninit.c	(revision 171959)
+++ tree-ssa-uninit.c	(working copy)
@@ -1955,7 +1955,7 @@ warn_uninitialized_phi (gimple phi, VEC(
 return;
 
   uninit_op = gimple_phi_arg_def (phi, MASK_FIRST_SET_BIT (uninit_opnds));
-  warn_uninit (uninit_op,
+  warn_uninit (OPT_Wmaybe_uninitialized, uninit_op,
%qD may be used uninitialized in this function,
uninit_use_stmt);
 
Index: c-family/c-opts.c
===
--- c-family/c-opts.c	(revision 171959)
+++ c-family/c-opts.c	(working copy)
@@ -379,6 +379,7 @@ c_common_handle_option (size_t scode, co
   warn_unknown_pragmas = value;
 
   warn_uninitialized = value;
+  warn_maybe_uninitialized = value;
 
   if (!c_dialect_cxx ())
 	{
Index: testsuite/gcc.dg/uninit-suppress.c
===
--- testsuite/gcc.dg/uninit-suppress.c	(revision 0)
+++ testsuite/gcc.dg/uninit-suppress.c	(revision 0)
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options -fno-tree-ccp -O2 -Wuninitialized -Wno-maybe-uninitialized } */
+void 

[x32] PATCH: Add more x32 support to testsuite

2011-04-07 Thread H.J. Lu
Hi,

This patch has been in my tree for a couple weeks. I am checking it into
x32 branch.

H.J.
---
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index 9bcf223..0081f4c 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,3 +1,18 @@
+2011-03-16  H.J. Lu  hongjiu...@intel.com
+
+   * g++.dg/opt/nrv12.C: Require ia32 instead of ilp32.
+
+   * gcc.c-torture/compile/pr16566-2.c: Also allow x32.
+   * gcc.dg/torture/pr20314-2.c: Likewise.
+   * gfortran.dg/pr33794.f90: Likewise.
+
+   * gcc.dg/lower-subreg-1.c: Don't allow x32.
+
+   * gcc.dg/lto/pr47259_0.c: Don't require lp64.
+
+   * gcc.dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp: Also
+   check x32.
+
 2011-03-15  H.J. Lu  hongjiu...@intel.com
 
* lib/target-supports.exp (check_effective_target_vect_cmdline_needed): 
diff --git a/gcc/testsuite/g++.dg/opt/nrv12.C b/gcc/testsuite/g++.dg/opt/nrv12.C
index 944..ae09ca8 100644
--- a/gcc/testsuite/g++.dg/opt/nrv12.C
+++ b/gcc/testsuite/g++.dg/opt/nrv12.C
@@ -1,7 +1,7 @@
 /* Verify that gimple-level NRV is occurring even for RESULT_DECLs.  *./
 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
 /* { dg-options -O -fdump-tree-optimized } */
-/* { dg-require-effective-target ilp32 } */
+/* { dg-require-effective-target ia32 } */
 
 struct P
 {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr16566-2.c 
b/gcc/testsuite/gcc.c-torture/compile/pr16566-2.c
index 2f7a106..72beb39 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr16566-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr16566-2.c
@@ -1,6 +1,6 @@
 /* ICE with flexible arrays in non-lvalue structures.  Bug 16566
(comment #5).  */
-/* { dg-options -Wno-psabi { target { { i?86-*-* x86_64-*-* }  lp64 } } } 
*/
+/* { dg-options -Wno-psabi { target { { i?86-*-* x86_64-*-* }  { x32 || 
lp64 } } } } */
 
 struct A
 {
diff --git a/gcc/testsuite/gcc.dg/lower-subreg-1.c 
b/gcc/testsuite/gcc.dg/lower-subreg-1.c
index 4de90bd..3400c91 100644
--- a/gcc/testsuite/gcc.dg/lower-subreg-1.c
+++ b/gcc/testsuite/gcc.dg/lower-subreg-1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { { { ! mips64 }  { ! ia64-*-* } }  { ! 
spu-*-* } } } } */
+/* { dg-do compile { target { { { { ! mips64 }  { ! ia64-*-* } }  { ! 
spu-*-* } }  { ! x32 } } } } */
 /* { dg-options -O -fdump-rtl-subreg1 } */
 /* { dg-require-effective-target ilp32 } */
 
diff --git a/gcc/testsuite/gcc.dg/lto/pr47259_0.c 
b/gcc/testsuite/gcc.dg/lto/pr47259_0.c
index b959478..7900e5a 100644
--- a/gcc/testsuite/gcc.dg/lto/pr47259_0.c
+++ b/gcc/testsuite/gcc.dg/lto/pr47259_0.c
@@ -1,7 +1,6 @@
 /* { dg-lto-do link } */
 /* { dg-skip-if  { ! { x86_64-*-* } } { * } {  } } */
 /* { dg-lto-options { { -O2 -flto -w } } } */
-/* { dg-require-effective-target lp64 } */
 
 register int r asm(esi);
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr20314-2.c 
b/gcc/testsuite/gcc.dg/torture/pr20314-2.c
index 8185218..6da0983 100644
--- a/gcc/testsuite/gcc.dg/torture/pr20314-2.c
+++ b/gcc/testsuite/gcc.dg/torture/pr20314-2.c
@@ -1,5 +1,5 @@
 /* PR inline-asm/20314 */
-/* { dg-do compile { target { { i?86-*-* x86_64-*-* }  lp64 } } } */
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* }  { x32 || lp64 } } } } 
*/
 /* { dg-do compile { target ia64-*-* powerpc*-*-* } } */
 
 int a, b, c, d, e, f, g, h, i, j, k, l;
diff --git 
a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp 
b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp
index ff3650c..a11aa3b 100644
--- a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp
@@ -22,7 +22,7 @@ load_lib gcc-dg.exp
 
 # Exit immediately if this isn't a x86 target.
 if { (![istarget x86_64-*-*]  ![istarget i?86-*-*])
- || ![is-effective-target lp64] } then {
+ || (![is-effective-target x32]  ![is-effective-target lp64]) } then {
   return
 }
 
diff --git a/gcc/testsuite/gfortran.dg/pr33794.f90 
b/gcc/testsuite/gfortran.dg/pr33794.f90
index a2425ce..80de044 100644
--- a/gcc/testsuite/gfortran.dg/pr33794.f90
+++ b/gcc/testsuite/gfortran.dg/pr33794.f90
@@ -1,5 +1,5 @@
 ! { dg-do run }
-! { dg-options -O2 -ffast-math -mfpmath=387 { target { { i?86-*-* x86_64-*-* 
}  lp64 } } }
+! { dg-options -O2 -ffast-math -mfpmath=387 { target { { i?86-*-* x86_64-*-* 
}  { x32 || lp64 } } } }
 ! { dg-options -O2 -ffast-math }
 
 module scc_m


C++ PATCH for use of parameter pack in default argument (48451)

2011-04-07 Thread Jason Merrill
Here deduction was failing because when we tried to substitute {int,int} 
for Args in decltype(T(std::declvalArgs()...)) we still had Args 
marked as an incomplete/deducible parameter pack, so the expansion 
wasn't fully resolved.  So now we clear the incomplete flag before 
trying to substitute into later default arguments.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 4a9c6ee1725355c70f76b2bb1c6d501129b768d1
Author: Jason Merrill ja...@redhat.com
Date:   Tue Apr 5 21:56:46 2011 -0400

PR c++/48451
* pt.c (fn_type_unification): Don't clear incomplete pack flag.
(type_unification_real): Clear it here instead.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 66db880..4edd404 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13719,7 +13719,8 @@ fn_type_unification (tree fn,
   template_parm_level_and_index (parm, level, idx);
 
   /* Mark the argument pack as incomplete. We could
- still deduce more arguments during unification.  */
+ still deduce more arguments during unification.
+We remove this mark in type_unification_real.  */
   targ = TMPL_ARG (converted_args, level, idx);
   if (targ)
 {
@@ -13776,22 +13777,6 @@ fn_type_unification (tree fn,
  targs, parms, args, nargs, /*subr=*/0,
  strict, flags);
 
-  if (result == 0  incomplete_argument_packs_p)
-{
-  int i, len = NUM_TMPL_ARGS (targs);
-
-  /* Clear the incomplete flags on all argument packs.  */
-  for (i = 0; i  len; i++)
-{
-  tree arg = TREE_VEC_ELT (targs, i);
-  if (ARGUMENT_PACK_P (arg))
-{
-  ARGUMENT_PACK_INCOMPLETE_P (arg) = 0;
-  ARGUMENT_PACK_EXPLICIT_ARGS (arg) = NULL_TREE;
-}
-}
-}
-
   /* Now that we have bindings for all of the template arguments,
  ensure that the arguments deduced for the template template
  parameters have compatible template parameter lists.  We cannot
@@ -14136,15 +14121,17 @@ type_unification_real (tree tparms,
 return 1;
 
   if (!subr)
-for (i = 0; i  ntparms; i++)
-  if (!TREE_VEC_ELT (targs, i))
+{
+  /* Check to see if we need another pass before we start clearing
+ARGUMENT_PACK_INCOMPLETE_P.  */
+  for (i = 0; i  ntparms; i++)
{
- tree tparm;
+ tree targ = TREE_VEC_ELT (targs, i);
+ tree tparm = TREE_VEC_ELT (tparms, i);
 
-  if (TREE_VEC_ELT (tparms, i) == error_mark_node)
-continue;
-
-  tparm = TREE_VALUE (TREE_VEC_ELT (tparms, i));
+ if (targ || tparm == error_mark_node)
+   continue;
+ tparm = TREE_VALUE (tparm);
 
  /* If this is an undeduced nontype parameter that depends on
 a type parameter, try another pass; its type may have been
@@ -14154,59 +14141,78 @@ type_unification_real (tree tparms,
   uses_template_parms (TREE_TYPE (tparm))
   !saw_undeduced++)
goto again;
+   }
 
-  /* Core issue #226 (C++0x) [temp.deduct]:
+  for (i = 0; i  ntparms; i++)
+   {
+ tree targ = TREE_VEC_ELT (targs, i);
+ tree tparm = TREE_VEC_ELT (tparms, i);
 
-   If a template argument has not been deduced, its
-   default template argument, if any, is used. 
+ /* Clear the incomplete flags on all argument packs now so that
+substituting them into later default arguments works.  */
+ if (targ  ARGUMENT_PACK_P (targ))
+{
+  ARGUMENT_PACK_INCOMPLETE_P (targ) = 0;
+  ARGUMENT_PACK_EXPLICIT_ARGS (targ) = NULL_TREE;
+}
 
- When we are in C++98 mode, TREE_PURPOSE will either
+ if (targ || tparm == error_mark_node)
+   continue;
+ tparm = TREE_VALUE (tparm);
+
+ /* Core issue #226 (C++0x) [temp.deduct]:
+
+If a template argument has not been deduced, its
+default template argument, if any, is used. 
+
+When we are in C++98 mode, TREE_PURPOSE will either
 be NULL_TREE or ERROR_MARK_NODE, so we do not need
 to explicitly check cxx_dialect here.  */
-  if (TREE_PURPOSE (TREE_VEC_ELT (tparms, i)))
-{
+ if (TREE_PURPOSE (TREE_VEC_ELT (tparms, i)))
+   {
  tree parm = TREE_VALUE (TREE_VEC_ELT (tparms, i));
  tree arg = TREE_PURPOSE (TREE_VEC_ELT (tparms, i));
-  arg = tsubst_template_arg (arg, targs, tf_none, NULL_TREE);
+ arg = tsubst_template_arg (arg, targs, tf_none, NULL_TREE);
  arg = convert_template_argument (parm, arg, targs, tf_none,
   i, NULL_TREE);
-  if (arg == error_mark_node)
-return 1;
-  else
-{
-

Merged mainline to gccgo branch

2011-04-07 Thread Ian Lance Taylor
I merged mainline revision 172121 to the gccgo branch.

Ian