[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  
  Ira Rosen  

 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_vtrn_internal): Make both
 outputs explicitly dependent on both inputs.
 (neon_vzip_internal, neon_vuzp_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 
+
+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_vtrn_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.\t%0, %2"
+  "vtrn.\t%0, %3"
   [(set (attr "neon_type")
   (if_then_else (ne (symbol_ref "") (const_int 0))
 (const_string "neon_bp_simple")
@@ -4118,13 +4119,14 @@
 
 (define_insn "neon_vzip_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.\t%0, %2"
+  "vzip.\t%0, %3"
   [(set (attr "neon_type")
   (if_then_else (ne (symbol_ref "") (const_int 0))
 (const_string "neon_bp_simple")
@@ -4144,13 +4146,14 @@
 
 (define_insn "neon_vuzp_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))]
   "TARGET_NEON"
-  "vuzp.\t%0, %2"
+  "vuzp.\t%0,

Re: [MIPS] Remove REG_OK_FOR_BASE_P and REG_OK_FOR_INDEX_P macros

2011-04-07 Thread Richard Sandiford
Anatoly Sokolov  writes:
> * config/mips/mips.h (REG_MODE_OK_FOR_BASE_P, REG_OK_FOR_INDEX_P):
> Remove macros.

OK, thanks.

Richard


[wwwdocs] CSS speaks American English, not Her Majesty's.

2011-04-07 Thread Gerald Pfeifer
'nough said. :-)

Thanks to Tobias for the hint, and I have now extended my verifier
to also cover CSS.

Gerald


Index: gcc.css
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc.css,v
retrieving revision 1.15
diff -u -r1.15 gcc.css
--- gcc.css 6 Apr 2011 00:26:57 -   1.15
+++ gcc.css 6 Apr 2011 23:05:15 -
@@ -9,10 +9,10 @@
 a:visited { color: #99; text-decoration: none; }
 a:hover   { color: orange;  text-decoration: none; }
 
-h1{ color: grey; text-align:center; }
-h2{ color: grey; }
+h1{ color: gray; text-align:center; }
+h2{ color: gray; }
 
-.highlight{ color: grey; }
+.highlight{ color: gray; }
 
 dl.news  { margin-top:0; }
 dl.news dt   { font-weight:bold; }


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  wrote:
> On Tue, Apr 5, 2011 at 3:29 AM, Richard Guenther
>  wrote:
>> On Tue, Apr 5, 2011 at 8:44 AM, Paolo Bonzini  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)
>      type         type             align 8 symtab 0 alias set -1 canonical type 0x70b83e70
>            pointer_to_this >
>        sizes-gimplified public unsigned SI
>        size 
>        unit size 
>        align 32 symtab 0 alias set -1 canonical type 0x70b83f18
>        pointer_to_this >
>    constant
>    arg 0 
>        side-effects VOID file x.i line 8 col 2
>        align 1 context  initial
> 
>        (code_label/s 22 0 0 4 4 ("l2") [2 uses])
>
>        chain 
>            used unsigned SI file x.i line 4 col 9 size  0x70b706e0 32> unit size 
>            align 32 context 
>            (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] Remove ASM_OUTPUT_BSS macro.

2011-04-07 Thread Richard Guenther
2011/4/6 Anatoly Sokolov :
> Hi.
>
>  No one back end does not use ASM_OUTPUT_BSS macro now, this patch remove it.
> The GCC have more flexible ASM_OUTPUT_ALIGNED_BSS macro.
>
>  The patch has been bootstrapped on and regression tested on
> x86_64-unknown-linux-gnu for c.
>
>  OK to install?

Ok.

Thanks,
Richard.

>        * doc/tm.texi.in (ASM_OUTPUT_BSS): Remove documentation.
>        (BSS_SECTION_ASM_OP, ASM_OUTPUT_ALIGNED_BSS): Update documentation.
>        * doc/tm.texi: Regenerate.
>        * system.h (ASM_OUTPUT_BSS): Poison.
>        * varasm.c (asm_output_bss): Remove function.
>        (emit_bss, init_varasm_once): Don't use ASM_OUTPUT_BSS macro.
>
>        * config/frv/frv.h (BSS_SECTION_ASM_OP): Remove comment.
>        * config/frv/fr30.h (BSS_SECTION_ASM_OP): Likewise.
>        * config/i386/djgpp.h (BSS_SECTION_ASM_OP): Likewise.
>        * config/i386/i386elf.h (BSS_SECTION_ASM_OP, ASM_OUTPUT_ALIGNED_BSS):
>        Likewise.
>        * config/sh/sh.h (BSS_SECTION_ASM_OP, ASM_OUTPUT_ALIGNED_BSS):
>        Likewise.
>        * config/m68k/m68kelf.h (BSS_SECTION_ASM_OP, ASM_OUTPUT_ALIGNED_BSS):
>        Likewise.
>        * config/m68k/netbsd-elf.h (ASM_OUTPUT_ALIGNED_BSS): Likewise.
>
>
> Index: gcc/doc/tm.texi
> ===
> --- gcc/doc/tm.texi     (revision 172058)
> +++ gcc/doc/tm.texi     (working copy)
> @@ -6821,8 +6821,8 @@
>  @defmac BSS_SECTION_ASM_OP
>  If defined, a C expression whose value is a string, including spacing,
>  containing the assembler operation to identify the following data as
> -uninitialized global data.  If not defined, and neither
> -@code{ASM_OUTPUT_BSS} nor @code{ASM_OUTPUT_ALIGNED_BSS} are defined,
> +uninitialized global data.  If not defined, and
> +@code{ASM_OUTPUT_ALIGNED_BSS} not defined,
>  uninitialized global data will be output in the data section if
>  @option{-fno-common} is passed, otherwise @code{ASM_OUTPUT_COMMON} will be
>  used.
> @@ -7598,20 +7598,19 @@
>  the variable's decl in order to chose what to output.
>  @end defmac
>
> -@defmac ASM_OUTPUT_BSS (@var{stream}, @var{decl}, @var{name}, @var{size}, 
> @var{rounded})
> +@defmac ASM_OUTPUT_ALIGNED_BSS (@var{stream}, @var{decl}, @var{name}, 
> @var{size}, @var{alignment})
>  A C statement (sans semicolon) to output to the stdio stream
>  @var{stream} the assembler definition of uninitialized global @var{decl} 
> named
> -@var{name} whose size is @var{size} bytes.  The variable @var{rounded}
> -is the size rounded up to whatever alignment the caller wants.
> +@var{name} whose size is @var{size} bytes.  The variable @var{alignment}
> +is the alignment specified as the number of bits.
>
> -Try to use function @code{asm_output_bss} defined in @file{varasm.c} when
> -defining this macro.  If unable, use the expression
> +Try to use function @code{asm_output_aligned_bss} defined in file
> +@file{varasm.c} when defining this macro.  If unable, use the expression
>  @code{assemble_name (@var{stream}, @var{name})} to output the name itself;
>  before and after that, output the additional assembler syntax for defining
>  the name, and a newline.
>
> -There are two ways of handling global BSS@.  One is to define either
> -this macro or its aligned counterpart, @code{ASM_OUTPUT_ALIGNED_BSS}.
> +There are two ways of handling global BSS@.  One is to define this macro.
>  The other is to have @code{TARGET_ASM_SELECT_SECTION} return a
>  switchable BSS section (@pxref{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS}).
>  You do not need to do both.
> @@ -7623,17 +7622,6 @@
>  common in order to save space in the object file.
>  @end defmac
>
> -@defmac ASM_OUTPUT_ALIGNED_BSS (@var{stream}, @var{decl}, @var{name}, 
> @var{size}, @var{alignment})
> -Like @code{ASM_OUTPUT_BSS} except takes the required alignment as a
> -separate, explicit argument.  If you define this macro, it is used in
> -place of @code{ASM_OUTPUT_BSS}, and gives you more flexibility in
> -handling the required alignment of the variable.  The alignment is specified
> -as the number of bits.
> -
> -Try to use function @code{asm_output_aligned_bss} defined in file
> -@file{varasm.c} when defining this macro.
> -@end defmac
> -
>  @defmac ASM_OUTPUT_LOCAL (@var{stream}, @var{name}, @var{size}, 
> @var{rounded})
>  A C statement (sans semicolon) to output to the stdio stream
>  @var{stream} the assembler definition of a local-common-label named
> Index: gcc/doc/tm.texi.in
> ===
> --- gcc/doc/tm.texi.in  (revision 172058)
> +++ gcc/doc/tm.texi.in  (working copy)
> @@ -6799,8 +6799,8 @@
>  @defmac BSS_SECTION_ASM_OP
>  If defined, a C expression whose value is a string, including spacing,
>  containing the assembler operation to identify the following data as
> -uninitialized global data.  If not defined, and neither
> -@code{ASM_OUTPUT_BSS} nor @code{ASM_OUTPUT_ALIGNED_BSS} are defined,
> +uninitialized global data.  If not defined, an

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

2011-04-07 Thread Richard Sandiford
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...

Carrot Wei  writes:
> @@ -10256,7 +10281,29 @@
>
>  return \"\";
>}"
> -  [(set_attr "type" "store4")]
> +  [(set_attr "type" "store4")
> +   (set (attr "length")
> + (if_then_else
> +(and (ne (symbol_ref "TARGET_THUMB2") (const_int 0))
> + (ne (symbol_ref "{
> + /* Check if there are any high register (except lr)
> +references in the list. KEEP the following iteration
> +in sync with the template above.  */
> + int i, regno, hi_reg;
> + int num_saves = XVECLEN (operands[2], 0);
> + regno = REGNO (operands[1]);
> + hi_reg = (REGNO_REG_CLASS (regno) == HI_REGS)
> +  && (regno != LR_REGNUM);
> + for (i = 1; i < num_saves && !hi_reg; i++)
> +   {
> + regno = REGNO (XEXP (XVECEXP (operands[2], 0, i), 0));
> + hi_reg |= (REGNO_REG_CLASS (regno) == HI_REGS)
> +   && (regno != LR_REGNUM);
> +   }
> + !hi_reg;}")
> +   (const_int 0)))
> +(const_int 2)
> +(const_int 4)))]

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.

Richard


Fix PR47976

2011-04-07 Thread Bernd Schmidt
PR47976 is a followup to PR47166; the patch there caused this problem.

The problem occurs in reload. There are two autoinc addresses which
inherit from one another, and we delete an insn that is necessary.

We reach this code when reloading the second autoinc address:

6821  if (optimize && REG_P (oldequiv)
6822  && REGNO (oldequiv) < FIRST_PSEUDO_REGISTER
6823  && spill_reg_store[REGNO (oldequiv)]
6824  && REG_P (old)
(gdb)
6825  && (dead_or_set_p (insn,
6826 spill_reg_stored_to[REGNO (oldequiv)])
6827  || rtx_equal_p (spill_reg_stored_to[REGNO (oldequiv)],
6828  old)))
6829delete_output_reload (insn, j, REGNO (oldequiv), reloadreg);

reload_inherited[j] is 1 at this point, so oldequiv == reloadreg.

(gdb) p debug_rtx (spill_reg_store[7])
(insn 719 718 232 10 (set (reg:SI 7 r7)
(reg:SI 3 r3 [orig:339 ivtmp.79 ] [339])) -1 (nil))
(gdb) p debug_rtx (spill_reg_stored_to[7])
(reg:SI 3 r3)

Prior to the PR47166 patch, we had spill_reg_store[7] equal to insn 718,
which doesn't involve register 7 at all:

(insn 718 221 719 10 (set (reg:SI 3 r3 [orig:339 ivtmp.79 ] [339])
(plus:SI (reg:SI 3 r3 [orig:339 ivtmp.79 ] [339])
(const_int 8 [0x8]))) 4 {*arm_addsi3} (nil))

That was sufficient to generate enough confusion to make the compiler
think it couldn't delete the output reload.

I think the problem is simply that the (set (r7) (r3)) is the opposite
direction of a normal spill_reg_store - normally you write a spill reg
to its destination, but autoinc reloads are somewhat special.

If delete_output_reload isn't valid for (at least some) autoincs, we can
simply not record them in spill_reg_store. That's part of the patch
below; it seems to fix the problem. I've also deleted the code quoted
above since it's pointless to have reload deleting dead stores to
registers: that's what DCE is for. I've observed no code generation
changes other than for the testcase from either of these changes, with
both an ARM and an sh compiler.

Comments?


Bernd

PR fortran/47976
* reload1.c (inc_for_reload): Return void. All callers changed.
(emit_input_reload_insns): Don't try to delete previous output
reloads to a register, or record spill_reg_store for autoincs.

Index: reload1.c
===
--- reload1.c   (revision 170053)
+++ reload1.c   (working copy)
@@ -457,7 +457,7 @@ static void emit_reload_insns (struct in
 static void delete_output_reload (rtx, int, int, rtx);
 static void delete_address_reloads (rtx, rtx);
 static void delete_address_reloads_1 (rtx, rtx, rtx);
-static rtx inc_for_reload (rtx, rtx, rtx, int);
+static void inc_for_reload (rtx, rtx, rtx, int);
 #ifdef AUTO_INC_DEC
 static void add_auto_inc_notes (rtx, rtx);
 #endif
@@ -6818,22 +6818,12 @@ emit_input_reload_insns (struct insn_cha
 
   old = XEXP (rl->in_reg, 0);
 
-  if (optimize && REG_P (oldequiv)
- && REGNO (oldequiv) < FIRST_PSEUDO_REGISTER
- && spill_reg_store[REGNO (oldequiv)]
- && REG_P (old)
- && (dead_or_set_p (insn,
-spill_reg_stored_to[REGNO (oldequiv)])
- || rtx_equal_p (spill_reg_stored_to[REGNO (oldequiv)],
- old)))
-   delete_output_reload (insn, j, REGNO (oldequiv), reloadreg);
-
   /* Prevent normal processing of this reload.  */
   special = 1;
-  /* Output a special code sequence for this case.  */
-  new_spill_reg_store[REGNO (reloadreg)]
-   = inc_for_reload (reloadreg, oldequiv, rl->out,
- rl->inc);
+  /* Output a special code sequence for this case, and forget about
+spill reg information.  */
+  new_spill_reg_store[REGNO (reloadreg)] = NULL;
+  inc_for_reload (reloadreg, oldequiv, rl->out, rl->inc);
 }
 
   /* If we are reloading a pseudo-register that was set by the previous
@@ -8643,11 +8633,9 @@ delete_address_reloads_1 (rtx dead_insn,
IN is either identical to VALUE, or some cheaper place to reload from.
 
INC_AMOUNT is the number to increment or decrement by (always positive).
-   This cannot be deduced from VALUE.
-
-   Return the instruction that stores into RELOADREG.  */
+   This cannot be deduced from VALUE.  */
 
-static rtx
+static void
 inc_for_reload (rtx reloadreg, rtx in, rtx value, int inc_amount)
 {
   /* REG or MEM to be copied and incremented.  */
@@ -8707,9 +8695,8 @@ inc_for_reload (rtx reloadreg, rtx in, r
 be used as an address.  */
 
  if (! post)
-   add_insn = emit_insn (gen_move_insn (reloadreg, incloc));
-
- return add_insn;
+   emit_insn (gen_move_insn (reloadreg, incloc));
+ return;
}
}
   delete_insns_since (last);
@@ -8745,8 +8732,6 @@ inc_for_reload (rtx reload

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
 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  

   * 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
  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




[Patch,AVR]: Fix PR target/44643

2011-04-07 Thread Georg-Johann Lay
This is fix of PR44643 which is triggerd by

http://savannah.nongnu.org/bugs/?32988

i.e. include/avr/pgmspace.h:PSTR has to be changed, too: PSTR has to
generate __c as "static const char[]", not as "static char[]". Note
that avr-libc has to be changed anyway, no matter if or if not this
patch is applied or not.


2011-04-07  Georg-Johann Lay  

PR target/44643
* config/avr/avr.c (avr_insert_attributes): Error if non-const
data has attribute progmem.
Index: config/avr/avr.c
===
--- config/avr/avr.c	(Revision 172046)
+++ config/avr/avr.c	(Arbeitskopie)
@@ -5149,14 +5149,20 @@ avr_insert_attributes (tree node, tree *
   && (TREE_STATIC (node) || DECL_EXTERNAL (node))
   && avr_progmem_p (node, *attributes))
 {
-  static const char dsec[] = ".progmem.data";
-  *attributes = tree_cons (get_identifier ("section"),
-		build_tree_list (NULL, build_string (strlen (dsec), dsec)),
-		*attributes);
+  if (TREE_READONLY (node)) 
+{
+  static const char dsec[] = ".progmem.data";
 
-  /* ??? This seems sketchy.  Why can't the user declare the
-	 thing const in the first place?  */
-  TREE_READONLY (node) = 1;
+  *attributes = tree_cons (get_identifier ("section"),
+   build_tree_list (NULL, build_string (strlen (dsec), dsec)),
+   *attributes);
+}
+  else
+{
+  error ("variable %q+D must be const in order to be put into"
+ " read-only section by means of %<__attribute__((progmem))%>",
+ node);
+}
 }
 }
 


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 Weigand
   Ira Rosen

  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_vtrn_internal): Make both
  outputs explicitly dependent on both inputs.
  (neon_vzip_internal, neon_vuzp_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)
> >   >    type  >        type  >            align 8 symtab 0 alias set -1 canonical type 0x70b83e70
> >            pointer_to_this >
> >        sizes-gimplified public unsigned SI
> >    arg 0 
> > (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.




[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)))
+ 

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  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)
>> >  > >    type > >        type > >            align 8 symtab 0 alias set -1 canonical type 0x70b83e70
>> >            pointer_to_this >
>> >        sizes-gimplified public unsigned SI
>> >    arg 0 
>> > (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


[PATCH, testsuite, committed] Fix test for odd-TLS targets

2011-04-07 Thread Maxim Kuvyrkov
The attached patch fixes gcc.dg/lto/20090210_0.c link test for targets that 
require C library support for TLS, e.g., m68k [*].  The patch changes the 
condition on the test from requiring theoretical TLS support, to requiring the 
toolchain to be able to link a program which uses TLS.

[*] M68k TLS ABI defines __m68k_read_tp() function to access thread-local 
storage, and to my knowledge, only GLIBC implements this, which makes the test 
fail on m68k-uclinux.

Thanks,

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



fsf-gcc-odd-tls-fix.ChangeLog
Description: Binary data


fsf-gcc-odd-tls-fix.patch
Description: Binary data


Re: [PATCH, M68K] Handle -fsched-pressure

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

On 04/07/11 08:29, Maxim Kuvyrkov wrote:
> 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.
I guess my only concern would be whether or not this problem (buffer not
being filled enough causing other problems) exists in any other backend.
 If it's not too much trouble, could you do a quick looksie at other
backends that defining these hooks to see if they are obviously correct
or incorrect?

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

iQEcBAEBAgAGBQJNndBdAAoJEBRtltQi2kC7EBcIALYE0Rc34g/Wn0i3jnwIhTDk
DTm119YwLRqp82dJ6JIs2as+Q/W4zi3U8Bp3wlB1yqj2srea/dtXguBg5Muso4MV
GP5GfAqlXmpdFZqfJswwf8mLqEuGYxt5D3uZ8oCYLPK+Yz6jZwhWOAVrdrqWICG3
++OR6WApCi2IP8WKmJFxqYERpwFnC/3FFPDQ+3gA77U00aCeymM6hUwgoVgqDheM
WOw1M+OUebG/TNrAF40necw76TqDlimsyaWaGQBMQA1o9FWKKW9rDdq+XPCnw7gY
zw6HLF1t3Drqfk5LJp/lpMY+6KPpYQbnnQD3Ymc2FcAh39BLCITjRVHavAxiiWc=
=QV1T
-END PGP SIGNATURE-


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 ,
> 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, M68K] Handle -fsched-pressure

2011-04-07 Thread Maxim Kuvyrkov
On Apr 7, 2011, at 6:55 PM, Jeff Law wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> On 04/07/11 08:29, Maxim Kuvyrkov wrote:
>> 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.
> I guess my only concern would be whether or not this problem (buffer not
> being filled enough causing other problems) exists in any other backend.
> If it's not too much trouble, could you do a quick looksie at other
> backends that defining these hooks to see if they are obviously correct
> or incorrect?

The sched_ib buffer is an invention of mine specific to m68k backend to model 
bottleneck of ColdFire's memory bus, which is shared between data and 
instructions.  This buffer does not exist outside of m68k back-end.

Jeff, does this answer your concern?

Thank you,

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



Re: [PATCH, M68K] Handle -fsched-pressure

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

On 04/07/11 09:02, Maxim Kuvyrkov wrote:
> On Apr 7, 2011, at 6:55 PM, Jeff Law wrote:
> 
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA1
>>
>> On 04/07/11 08:29, Maxim Kuvyrkov wrote:
>>> 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.
>> I guess my only concern would be whether or not this problem (buffer not
>> being filled enough causing other problems) exists in any other backend.
>> If it's not too much trouble, could you do a quick looksie at other
>> backends that defining these hooks to see if they are obviously correct
>> or incorrect?
> 
> The sched_ib buffer is an invention of mine specific to m68k backend to model 
> bottleneck of ColdFire's memory bus, which is shared between data and 
> instructions.  This buffer does not exist outside of m68k back-end.
> 
> Jeff, does this answer your concern?
It does.  Thanks.

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

iQEcBAEBAgAGBQJNndKoAAoJEBRtltQi2kC75JsIALk74COZXUiIpM3tKH9TrB8D
I8t2FfczdlmvUOsh80fkUBJTUVy6500WlShUq+FxDO8k0PJ2Qo0Xzgl/ecKd6CBY
8hCKw95EiUel60iYxQDG1DJTX/a2Q+7uKVNrWGwxsrQ8FdriIvfNBbO7r3mZLbeW
Y5sXfOyZdm+6KMcTH+tRcVtFzH3kyXDo0mnkNXSw2MLW2cboEcxdtjb4xCR00fOm
9QpMG163IpOGpJNR7CbHoAvVyCZDqA8HS3rrwc2MgpOMr5bbTvBI+7zPNUovzgs0
EMLcNotyiIEWbiSVTUGdlmlbE8pnSjXzUUlTcMtae8geVQe734l2luPCfbxZXzE=
=f47z
-END PGP SIGNATURE-


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-


gcc-patches@gcc.gnu.org

2011-04-07 Thread Gunther Nikl
On Fri, Oct 08, 2010 at 09:58:14AM -0400, Nathan Froyd wrote:
> The patch below hookizes FUNCTION_ARG and related macros for the m68k
> backend.  Nothing special here.

With the old macro approach it was easy for a subtarget to override
these target properties. That doesn't work anymore for target hooks.
Is there a (recommended) way how a subtarget can override hook
functions?

Thanks,
Gunther



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


gcc-patches@gcc.gnu.org

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

> On Fri, Oct 08, 2010 at 09:58:14AM -0400, Nathan Froyd wrote:
> > The patch below hookizes FUNCTION_ARG and related macros for the m68k
> > backend.  Nothing special here.
> 
> With the old macro approach it was easy for a subtarget to override
> these target properties. That doesn't work anymore for target hooks.
> Is there a (recommended) way how a subtarget can override hook
> functions?

The implementation of the hook should contain "if" (preferred over #if) 
conditions on the particular ABI in use, which could be determined by a 
macro in subtarget headers.  (The key difference from the old system is 
that the macro is one only used within target code rather than being used 
in the target-independent compiler.)

-- 
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  

* 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  

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  

* 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  

* 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 

* 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  // {dg-error fails macro validation "" { xfail *-*-* } }
! #include  // {dg-error fails macro validation "" { xfail *-*-* } }
! #include  // {dg-error fails macro validation "" { xfail *-*-* } }
! #include  // {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 
! #include 
! #include 
! #include 
  
  static unsigned long long MAX_ITEMS = 1;
  
Index: gcc/testsuite/g++.dg/pph/d1symnotinc.cc
===
*** gcc/testsuite/g++.dg/pph/d1symnotinc.cc (revision 172001)
--- gcc/testsuite/g++.dg/pp

[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  

Backported from mainline
2010-07-01  Richard Guenther  

* 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  

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  
 
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  

Backported from mainline
2011-01-26  Jakub Jelinek  

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  

Backported from mainline
2011-02-19  Jakub Jelinek  

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 
+double bar (double, double);
+
+__m128d
+foo (__m128d x)
+{
+  x *= (__m128d) { bar (1.0, 1.0), 0.0 };
+  return (__m128d) ((__m128i) x ^ (__m128i) { 0, 0});
+}

Re: [RFC PATCH, go]: Port to ALPHA arch - sysinfo.go fixup

2011-04-07 Thread Rainer Orth
Ian,

> Rainer Orth  writes:
>
>> I've got a similar issue on IRIX 6.5:  has
>>
>> struct timeval {
>> #if _MIPS_SZLONG == 64
>>  __int32_t :32;
>> #endif
>>  time_t  tv_sec; /* seconds */
>>  longtv_usec;/* and microseconds */
>> };
>>
>> which causes the 64-bit libgo build to break.
>
> I don't immediately see why that would break anything.  For a case like
> this I would expect layout_decl to turn the first field into an ordinary
> non-bit-field anyhow.

Here's the error I run into:

/vol/gcc/src/hg/trunk/irix/libgo/go/os/file.go:432:12: error: incompatible 
types in assignment (implicit assignment of 'syscall.Timeval' hidden field 
'_f0')
/vol/gcc/src/hg/trunk/irix/libgo/go/os/file.go:433:12: error: incompatible 
types in assignment (implicit assignment of 'syscall.Timeval' hidden field 
'_f0')
/vol/gcc/src/hg/trunk/irix/libgo/go/os/file.go:434:37: error: argument 2 has 
incompatible type (implicit assignment of 'syscall.Timeval' hidden field '_f0')
make[8]: *** [os/os.lo] Error 1

> What does the line for timeval look like in gen-sysinfo.go?

I get

type Timeval struct { _f0 int32; Sec Timeval_sec_t; Usec Timeval_usec_t; }

Rainer

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


[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  

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  

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-	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{} @gol
 -finit-logical=@var{} -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 table
 
 @xref{Code Gen Options,,Options for Code Generation Conventions

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 

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  
* 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  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: basilestarynkevitchnet 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  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: basilestarynkevitchnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***
Index: gcc/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: Fix an incorrect assert (PR 48442)

2011-04-07 Thread Vladimir Makarov

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

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?


Ok, thanks.

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.





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.



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

2011-04-07 Thread Vladimir Makarov

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

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

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.


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  

* config/i386/sse.md: Update copyright year.
(avx_cmp3): Add missing output
register constraint.
(*vec_concatv2sf_avx): Fix wrong register constraint in
alternative 3 of operand 1.
(*vec_set_0_avx): Avoid combining registers from different
units in a single alternative.
(*vec_set_0_sse4_1): Ditto.
(*vec_set_0_sse2): Ditto.
(vec_set_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" "")])
 
 (define_insn "avx_cmp3"
-  [(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_set_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: 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,,SI,SF,TI,*")])
+   (set_attr "mode" "SF,,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_set_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: 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)))]
   "TARGET_SSE4_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  

* 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(i>0){__label__ l1;int f(int i){if(i==2)goto l1;return 0;}return 
f(i);l1:;}return 1;}
 int x(){return s(0)==1&&s(1)==0&&s(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  

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

2011-04-07  Jakub Jelinek  

Backported from mainline
2010-11-15  Jakub Jelinek  

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  

Backported from mainline
2011-03-17  Jakub Jelinek  

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  

Backported from mainline
2011-04-06  Jakub Jelinek  

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  

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
 wrote:
> Fixes a bunch of C testsuite failures. Committed to gc-improv.
>
> 2011-04-07  Laurynas Biveinis  
>
>        * 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


C++/c-common PATCH to conversion from scoped enum to bool (part of 48450)

2011-04-07 Thread Jason Merrill
PR 48450 has to do with SFINAE bugs, but one of them turns out to be a 
different sort of bug: we were failing to convert from a non-constant 
value of scoped enum type to bool, because that conversion was doing a 
!= 0, which requires an implicit conversion to int.  So now we 
explicitly convert to the underlying integral type first, and prevent 
c-common from helpfully removing it again.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 87823d7d9dab304517871340e7b3aba6b73afe16
Author: Jason Merrill 
Date:   Tue Apr 5 15:02:14 2011 -0400

PR c++/48450
* c-family/c-common.c (c_common_truthvalue_conversion): Don't ignore
conversion from C++0x scoped enum.
* cp/cvt.c (ocp_convert): Handle converting scoped enum to bool.

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 1252b18..e0acfea 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3939,16 +3939,25 @@ c_common_truthvalue_conversion (location_t location, 
tree expr)
}
 
 CASE_CONVERT:
-  /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
-since that affects how `default_conversion' will behave.  */
-  if (TREE_CODE (TREE_TYPE (expr)) == REFERENCE_TYPE
- || TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == REFERENCE_TYPE)
-   break;
-  /* If this is widening the argument, we can ignore it.  */
-  if (TYPE_PRECISION (TREE_TYPE (expr))
- >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0
-   return c_common_truthvalue_conversion (location,
-  TREE_OPERAND (expr, 0));
+  {
+   tree totype = TREE_TYPE (expr);
+   tree fromtype = TREE_TYPE (TREE_OPERAND (expr, 0));
+
+   /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
+  since that affects how `default_conversion' will behave.  */
+   if (TREE_CODE (totype) == REFERENCE_TYPE
+   || TREE_CODE (fromtype) == REFERENCE_TYPE)
+ break;
+   /* Don't strip a conversion from C++0x scoped enum, since they
+  don't implicitly convert to other types.  */
+   if (TREE_CODE (fromtype) == ENUMERAL_TYPE
+   && ENUM_IS_SCOPED (fromtype))
+ break;
+   /* If this isn't narrowing the argument, we can ignore it.  */
+   if (TYPE_PRECISION (totype) >= TYPE_PRECISION (fromtype))
+ return c_common_truthvalue_conversion (location,
+TREE_OPERAND (expr, 0));
+  }
   break;
 
 case MODIFY_EXPR:
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 8ab0001..290b926 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -727,7 +727,13 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
  return error_mark_node;
}
   if (code == BOOLEAN_TYPE)
-   return cp_truthvalue_conversion (e);
+   {
+ /* We can't implicitly convert a scoped enum to bool, so convert
+to the underlying type first.  */
+ if (SCOPED_ENUM_P (intype) && (convtype & CONV_STATIC))
+   e = convert (ENUM_UNDERLYING_TYPE (intype), e);
+ return cp_truthvalue_conversion (e);
+   }
 
   converted = fold_if_not_in_template (convert_to_integer (type, e));
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/enum9.C 
b/gcc/testsuite/g++.dg/cpp0x/enum9.C
new file mode 100644
index 000..10e510b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/enum9.C
@@ -0,0 +1,5 @@
+// { dg-options -std=c++0x }
+
+enum class E { };
+E f();
+bool b2 = static_cast(f());


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  
 
+   * config/rx/rx.opt (rx610, rx200, rx600): Use Enum not Name on
+   EnumValue lines.
+
+2011-04-07  Joseph Myers  
+
* 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


[lipo] merge from trunk

2011-04-07 Thread Raksit Ashok
Merged lw-ipo branch from trunk 163718:170935, committed as revision 172131.

Tested spec2k-int with lipo.

thanks,
raksit


Avoid global state in arm_handle_option

2011-04-07 Thread Joseph S. Myers
This patch stops the ARM handle_option hook from using global state -
in fact removing the hook altogether by using .opt Enum facilities for
what it did.

The -march, -mcpu and -mtune option values are made to use Enum.  The
Enum definitions go in a new generated file arm-tables.opt; for
-mcpu/-mtune these are generated from the existing arm-cores.def.  For
-march, since there was no enum for architecture values nor any
apparent need for one, and given the .def arrangements already used
for core names, I added a new arm-arches.def with the architecture
table.  In both cases, giving a help text on the Enum definitions
meant that generic code could do what arm_target_help previously did,
so that hook is also removed (the only implementation of the
TARGET_HELP hook is now for AVR).

arm_selected_* are now set at the start of arm_option_override.  When
I turn to dealing with global state in those hooks (and splitting the
parts needing global state into a separate hook) I expect to make
arm_selected_* purely local variables of arm_option_override, rather
than moving them to the gcc_options structure.  The only place they
are used outside that function is arm_file_start, and const char *
fields in the gcc_options structure can be added for those particular
uses.

Tested building cc1 and xgcc for cross to arm-eabi.  Will commit to
trunk in the absence of target maintainer objections.

contrib:
2011-04-07  Joseph Myers  

* gcc_update (gcc/config/arm/arm-tables.opt): New dependencies.

gcc:
2011-04-07  Joseph Myers  

* config.gcc (arm*-*-*): Add arm/arm-tables.opt to extra_options.
* config/arm/arm-arches.def: New.
* config/arm/arm-opts.h: New.
* config/arm/genopt.sh: New.
* config/arm/arm-tables.opt: New (generated).
* config/arm/arm.c (arm_handle_option, arm_target_help,
TARGET_HANDLE_OPTION, TARGET_HELP, arm_find_cpu): Remove.
(all_architectures): Get most table contents from arm-arches.def.
(arm_option_override): Set arm_selected_arch, arm_selected_cpu and
arm_selected_tune here.
* config/arm/arm.h (enum processor_type): Move to arm-opts.h.
* config/arm/arm.opt (config/arm/arm-opts.h): New HeaderInclude.
(march=, mcpu=, mtune=): Use Enum and Var.
* config/arm/t-arm ($(srcdir)/config/arm/arm-tables.opt): New.
(arm.o): Update dependencies.

Index: contrib/gcc_update
===
--- contrib/gcc_update  (revision 172035)
+++ contrib/gcc_update  (working copy)
@@ -4,8 +4,8 @@
 # repository, with an emphasis on treating generated files correctly, so
 # that autoconf, gperf et al are not required for the ``end'' user.
 #
-# (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
-# Free Software Foundation
+# (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
+# 2011 Free Software Foundation
 # Originally by Gerald Pfeifer , August 1998.
 #
 # This script is Free Software, and it can be copied, distributed and
@@ -80,6 +80,7 @@ gcc/cstamp-h.in: gcc/configure.ac
 gcc/config.in: gcc/cstamp-h.in
 gcc/fixinc/fixincl.x: gcc/fixinc/fixincl.tpl gcc/fixinc/inclhack.def
 gcc/config/arm/arm-tune.md: gcc/config/arm/arm-cores.def 
gcc/config/arm/gentune.sh
+gcc/config/arm/arm-tables.opt: gcc/config/arm/arm-arches.def 
gcc/config/arm/arm-cores.def gcc/config/arm/genopt.sh
 # And then, language-specific files
 gcc/cp/cfns.h: gcc/cp/cfns.gperf
 gcc/java/keyword.h: gcc/java/keyword.gperf
Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 172035)
+++ gcc/config.gcc  (working copy)
@@ -296,6 +296,7 @@ arm*-*-*)
extra_headers="mmintrin.h arm_neon.h"
c_target_objs="arm-c.o"
cxx_target_objs="arm-c.o"
+   extra_options="${extra_options} arm/arm-tables.opt"
;;
 avr-*-*)
cpu_type=avr
Index: gcc/config/arm/arm-tables.opt
===
--- gcc/config/arm/arm-tables.opt   (revision 0)
+++ gcc/config/arm/arm-tables.opt   (revision 0)
@@ -0,0 +1,341 @@
+; -*- buffer-read-only: t -*-
+; Generated automatically by genopt.sh from arm-cores.def and arm-arches.def.
+
+; Copyright (C) 2011 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; 

FDO usability patch -- correct insane profile data

2011-04-07 Thread Xinliang David Li
Hi please review the attached patch.

Ok when bootstrap and test finish?

Thanks,

David



2011-04-07  Xinliang David Li  

* ipa-cp.c (ipcp_update_profiling): Correct
negative scale factor due to insane profile data.
Index: ipa-cp.c
===
--- ipa-cp.c	(revision 171917)
+++ ipa-cp.c	(working copy)
@@ -1113,6 +1113,29 @@ ipcp_update_profiling (void)
 	  scale = ipcp_get_node_scale (orig_node);
 	  node->count = orig_node->count * scale / REG_BR_PROB_BASE;
 	  scale_complement = REG_BR_PROB_BASE - scale;
+
+  /* Negative scale complement can result from insane profile data
+ in which the total incoming edge counts in this module is
+ larger than the callee's entry count. The insane profile data
+ usually gets generated due to the following reasons:
+
+ 1) in multithreaded programs, when profile data is dumped
+ to gcda files in gcov_exit, some other threads are still running.
+ The profile counters are dumped in bottom up order (call graph).
+ The caller's BB counters may still be updated while the callee's
+ counter data is already saved to disk.
+
+ 2) Comdat functions: comdat functions' profile data are not
+ allocated in comdat. When a comdat callee function gets inlined
+ at some callsites after instrumentation, and the remaining calls
+ to this function resolves to a comdat copy in another module,
+ the profile counters for this function are split. This can
+ result in sum of incoming edge counts from this module being
+ larger than callee instance's entry count.  */
+
+  if (scale_complement < 0 && flag_profile_correction)
+scale_complement = 0;
+
 	  orig_node->count =
 	orig_node->count * scale_complement / REG_BR_PROB_BASE;
 	  for (cs = node->callees; cs; cs = cs->next_callee)


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  

* 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  

* 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 blah();
+int gflag;
+
+void foo()
+{
+

[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  
+
+   * 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  
 
* 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::declval()...)) 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 
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
-{
-

C++ PATCH for c++/48500 (C++0x crash on non-type-dependent but non-constant call in template)

2011-04-07 Thread Jason Merrill
constexpr fallout.  In fold_non_dependent_expr, we determined that the 
expression is not type-dependent, is potentially constant, and is not 
value-dependent, so we try to fold it.  But it isn't potentially 
constant.  So this patch fixes that determination.


Tested x86_64-pc-linux-gnu, applying to trunk and 4.6 (regression).
commit e49c0a722ad7226f7dabfc4a2fea9e47f8fc235f
Author: Jason Merrill 
Date:   Thu Apr 7 14:52:08 2011 -0400

PR c++/48500
* semantics.c (potential_constant_expression_1) [CALL_EXPR]: Check
arguments even if we don't know the function.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 2184a53..0b4d1ec 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7358,6 +7358,8 @@ potential_constant_expression_1 (tree t, bool want_rval, 
tsubst_flags_t flags)
 class member access expression, including the result of the
 implicit transformation in the body of the non-static
 member function (9.3.1);  */
+  /* FIXME this restriction seems pointless since the standard dropped
+"potential constant expression".  */
   if (is_this_parameter (t))
 {
   if (flags & tf_error)
@@ -7373,51 +7375,63 @@ potential_constant_expression_1 (tree t, bool 
want_rval, tsubst_flags_t flags)
   {
 tree fun = get_function_named_in_call (t);
 const int nargs = call_expr_nargs (t);
-if (TREE_CODE (fun) != FUNCTION_DECL)
+   i = 0;
+
+   if (is_overloaded_fn (fun))
+ {
+   if (TREE_CODE (fun) == FUNCTION_DECL)
+ {
+   if (builtin_valid_in_constant_expr_p (fun))
+ return true;
+   if (!DECL_DECLARED_CONSTEXPR_P (fun)
+   && !morally_constexpr_builtin_function_p (fun))
+ {
+   if (flags & tf_error)
+ error ("%qD is not %", fun);
+   return false;
+ }
+   /* A call to a non-static member function takes the address
+  of the object as the first argument.  But in a constant
+  expression the address will be folded away, so look
+  through it now.  */
+   if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fun)
+   && !DECL_CONSTRUCTOR_P (fun))
+ {
+   tree x = get_nth_callarg (t, 0);
+   if (is_this_parameter (x))
+ /* OK.  */;
+   else if (!potential_constant_expression_1 (x, rval, flags))
+ {
+   if (flags & tf_error)
+ error ("object argument is not a potential "
+"constant expression");
+   return false;
+ }
+   i = 1;
+ }
+ }
+   else
+ fun = get_first_fn (fun);
+   /* Skip initial arguments to base constructors.  */
+   if (DECL_BASE_CONSTRUCTOR_P (fun))
+ i = num_artificial_parms_for (fun);
+   fun = DECL_ORIGIN (fun);
+ }
+   else
   {
if (potential_constant_expression_1 (fun, rval, flags))
- /* Might end up being a constant function pointer.  */
- return true;
-if (flags & tf_error)
-  error ("%qE is not a function name", fun);
-return false;
-  }
-   /* Skip initial arguments to base constructors.  */
-   if (DECL_BASE_CONSTRUCTOR_P (fun))
- i = num_artificial_parms_for (fun);
-   else
- i = 0;
-   fun = DECL_ORIGIN (fun);
-if (builtin_valid_in_constant_expr_p (fun))
-  return true;
-if (!DECL_DECLARED_CONSTEXPR_P (fun)
-&& !morally_constexpr_builtin_function_p (fun))
-  {
-if (flags & tf_error)
-  error ("%qD is not %", fun);
-return false;
+ /* Might end up being a constant function pointer.  */;
+   else
+ {
+   if (flags & tf_error)
+ error ("%qE is not a function name", fun);
+   return false;
+ }
   }
 for (; i < nargs; ++i)
   {
 tree x = get_nth_callarg (t, i);
-/* A call to a non-static member function takes the
-   address of the object as the first argument.
-   But in a constant expression the address will be folded
-  away, so look through it now.  */
-if (i == 0 && DECL_NONSTATIC_MEMBER_P (fun)
-&& !DECL_CONSTRUCTOR_P (fun))
- {
-   if (is_this_parameter (x))
- /* OK.  */;
-else if (!potential_constant_expression_1 (x, rval, flags))
- {
-   if (flags & tf_error)
- error ("object argument is not a pot

Merged mainline to gccgo branch

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

Ian


Re: PATCH [trunk] gengtype should generate ggc_alloc macros in plugin mode.

2011-04-07 Thread Basile Starynkevitch
On Thu, 7 Apr 2011 05:45:42 +0300
Laurynas Biveinis  wrote:
> The patch is correct in general. 

You didn't say "Ok with changes", so attached here is the patch to trunk 172161

 gcc/ChangeLog entry ##
2011-04-08  Basile Starynkevitch  
* gengtype.c (write_typed_alloc_def): New argument f. Use it instead
  of header_file.
  (write_typed_struct_alloc_def, write_typed_typedef_alloc_def)
  (write_typed_alloc_defns): Likewise.
  (main): Calls write_typed_alloc_defns with output_header.
### end of gcc/ChangeLog entry ##

Ok for trunk?

By the way, this patch is enough for the MELT plugin (which probably 
is the only plugin needing GTY). But if an hypothetical plugin is made 
of several source files plugin1.c plugin2.c and a common header plugin.h
and if GTY-ed allocation appears in several files plugin1.c plugin2.c,
gengtype should perhaps better generate a header file (containing the 
generated ggc_alloc_* macros) and a body file (contains the marking 
routines).  This could be future work.

Cheers
-- 
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basilestarynkevitchnet mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***
Index: gcc/gengtype.c
===
--- gcc/gengtype.c	(revision 172161)
+++ gcc/gengtype.c	(working copy)
@@ -4189,104 +4189,112 @@ enum alloc_quantity
 enum alloc_zone
 { any_zone, specific_zone };
 
-/* Writes one typed allocator definition for type identifier TYPE_NAME with
-   optional type specifier TYPE_SPECIFIER.  The allocator name will contain
-   ALLOCATOR_TYPE.  If VARIABLE_SIZE is true, the allocator will have an extra
-   parameter specifying number of bytes to allocate.  If QUANTITY is set to
-   VECTOR, a vector allocator will be output, if ZONE is set to SPECIFIC_ZONE,
+/* Writes one typed allocator definition into output F for type
+   identifier TYPE_NAME with optional type specifier TYPE_SPECIFIER.
+   The allocator name will contain ALLOCATOR_TYPE.  If VARIABLE_SIZE
+   is true, the allocator will have an extra parameter specifying
+   number of bytes to allocate.  If QUANTITY is set to VECTOR, a
+   vector allocator will be output, if ZONE is set to SPECIFIC_ZONE,
the allocator will be zone-specific.  */
 
 static void
-write_typed_alloc_def (bool variable_size, const char *type_specifier,
+write_typed_alloc_def (outf_p f, 
+   bool variable_size, const char *type_specifier,
 		   const char *type_name, const char *allocator_type,
 		   enum alloc_quantity quantity, enum alloc_zone zone)
 {
   bool two_args = variable_size && (quantity == vector);
   bool third_arg = ((zone == specific_zone)
 		&& (variable_size || (quantity == vector)));
-
-  oprintf (header_file, "#define ggc_alloc_%s%s", allocator_type, type_name);
-  oprintf (header_file, "(%s%s%s%s%s) ",
+  gcc_assert (f != NULL);
+  oprintf (f, "#define ggc_alloc_%s%s", allocator_type, type_name);
+  oprintf (f, "(%s%s%s%s%s) ",
 	   (variable_size ? "SIZE" : ""),
 	   (two_args ? ", " : ""),
 	   (quantity == vector) ? "n" : "",
 	   (third_arg ? ", " : ""), (zone == specific_zone) ? "z" : "");
-  oprintf (header_file, "((%s%s *)", type_specifier, type_name);
-  oprintf (header_file, "(ggc_internal_%salloc_stat (", allocator_type);
+  oprintf (f, "((%s%s *)", type_specifier, type_name);
+  oprintf (f, "(ggc_internal_%salloc_stat (", allocator_type);
   if (zone == specific_zone)
-oprintf (header_file, "z, ");
+oprintf (f, "z, ");
   if (variable_size)
-oprintf (header_file, "SIZE");
+oprintf (f, "SIZE");
   else
-oprintf (header_file, "sizeof (%s%s)", type_specifier, type_name);
+oprintf (f, "sizeof (%s%s)", type_specifier, type_name);
   if (quantity == vector)
-oprintf (header_file, ", n");
-  oprintf (header_file, " MEM_STAT_INFO)))\n");
+oprintf (f, ", n");
+  oprintf (f, " MEM_STAT_INFO)))\n");
 }
 
-/* Writes a typed allocator definition for a struct or union S.  */
+/* Writes a typed allocator definition into output F for a struct or
+   union S, with a given ALLOCATOR_TYPE and QUANTITY for ZONE.  */
 
 static void
-write_typed_struct_alloc_def (const type_p s, const char *allocator_type,
+write_typed_struct_alloc_def (outf_p f,
+			  const type_p s, const char *allocator_type,
 			  enum alloc_quantity quantity,
 			  enum alloc_zone zone)
 {
-  write_typed_alloc_def (variable_size_p (s), get_type_specifier (s),
+  write_typed_alloc_def (f, variable_size_p (s), get_type_specifier (s),
 			 s->u.s.tag, allocator_type, quantity, zone);
 }
 
-/* Writes a typed allocator definition for a typedef P.  */
+/* Writes a typed allocator definition into output F for a typedef P,
+   with a given ALLOCATOR_TYPE and QUANTITY for ZONE.  */
 
 static void
-write_typed_typedef_alloc_def (const pair_p p, const

FDO usability -- sanity check indirect call target

2011-04-07 Thread Xinliang David Li
Hi, due to race conditions, it is common that the value profile
information for an indirect call site is 'corrupted' -- resulting in
false target function to be recorded. The value profile transformation
won't cause runtime problem as the path will never be executed,
however it may cause compile time ICE because of the incompatible
signature of the callee target. The attached patch does minimal sanity
check to make compiler happy in such cases. The fix was tested with
lots of MT programs and works really well in practice.

Ok for trunk after testing?

Thanks,

David

2011-04-07  Xinliang David Li  

* value-profile.c (function_decl_num_args): New function.
(check_ic_target): New function.
(gimple_ic_transform): Sanity check indirect call target.


check_ic.p
Description: Binary data


Re: Simple enhancement to -dA dump

2011-04-07 Thread Xinliang David Li
Ping?


On Sun, Apr 3, 2011 at 5:54 PM, Xinliang David Li  wrote:
> For an assembly dump, it is very useful to examine the control flow
> graph with frequency and profile count information. This requires
> dumping the .s file with more control flow annotations. This patch
> does just that. The format of the annotation is the same as gimple
> basic block dump with -fdump-tree-xxx-blocks so the same
> post-processing tools can be shared to generate the .dot file. To see
> bb layout, the BB sequence number is also dumped.
>
> Bootstrapped on x86-64/linux. Regression test is on going.
>
> Ok for checkin?
>
> Thanks,
> David
>
>
> 2011-04-03  Xinliang David Li  
>
>        * final.c (dump_basic_block_info): New function.
>        (final): Dump basic block.
>        (final_scan_insn): Remove old dump.
>


C++ PATCHes for c++/48481 (overload resolution memory hog)

2011-04-07 Thread Jason Merrill
48481 involves a huge function involving calls to functions taking class 
arguments.  Detailed memory statistics pointed to three primary sources 
of garbage:


1) BASELINKs from lookup of constructors for considering a user-defined 
conversion sequence.  We can just avoid creating these in the first 
place, since we always find constructors in the type itself.


2) VEC(tree)s created in build_user_type_conversion_1 and then not 
freed.  So we release the vec if we don't actually end up needing it.


3) OVERLOADs from argument-dependent lookup.  We allocate some of these 
whenever we do argument-dependent lookup, which is pretty wasteful in 
the common case that unqualified lookup finds all the interesting 
functions, because we end up looking at every function twice -- once 
from unqualified lookup, once from argument-dependent.  We used to try 
to avoid this in the common case, but stopped to get 2-phase name lookup 
right.  It seems to me that we could still do the optimization in the 
non-template case, but that will be a later patch.


This patch marks the OVERLOADs as coming from arg-dependent lookup so 
that we can free them again once we're done with the call.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit fe4fd71bfe5c968261c332c2792047dcfe36da3c
Author: Jason Merrill 
Date:   Wed Apr 6 15:09:09 2011 -0400

PR c++/48481
* call.c (build_user_type_conversion_1): Use lookup_fnfields_slot.
Release unused vector.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f283bd1..096fbbc 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3249,7 +3249,9 @@ build_user_type_conversion_1 (tree totype, tree expr, int 
flags)
  || !DERIVED_FROM_P (totype, fromtype));
 
   if (MAYBE_CLASS_TYPE_P (totype))
-ctors = lookup_fnfields (totype, complete_ctor_identifier, 0);
+/* Use lookup_fnfields_slot instead of lookup_fnfields to avoid
+   creating a garbage BASELINK; constructors can't be inherited.  */
+ctors = lookup_fnfields_slot (totype, complete_ctor_identifier);
 
   if (MAYBE_CLASS_TYPE_P (fromtype))
 {
@@ -3281,7 +3283,6 @@ build_user_type_conversion_1 (tree totype, tree expr, int 
flags)
   if (ctors)
 {
   int ctorflags = flags;
-  ctors = BASELINK_FUNCTIONS (ctors);
 
   first_arg = build_int_cst (build_pointer_type (totype), 0);
 
@@ -3389,7 +3390,11 @@ build_user_type_conversion_1 (tree totype, tree expr, 
int flags)
 
   candidates = splice_viable (candidates, pedantic, &any_viable_p);
   if (!any_viable_p)
-return NULL;
+{
+  if (args)
+   release_tree_vector (args);
+  return NULL;
+}
 
   cand = tourney (candidates);
   if (cand == 0)

commit 88c1fe424f19e08870fb6d2b5e54eee9d354095f
Author: Jason Merrill 
Date:   Thu Apr 7 11:48:09 2011 -0400

PR c++/48481
* cp-tree.h (OVL_ARG_DEPENDENT): New.
* name-lookup.c (add_function): Set it.
* semantics.c (finish_call_expr): Free OVERLOADs if it's set.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index ea251a8..885b31c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -317,6 +317,9 @@ typedef struct ptrmem_cst * ptrmem_cst_t;
This is not to confuse with being used somewhere, which
is not important for this node.  */
 #define OVL_USED(NODE) TREE_USED (NODE)
+/* If set, this OVERLOAD was created for argument-dependent lookup
+   and can be freed afterward.  */
+#define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
 
 struct GTY(()) tree_overload {
   struct tree_common common;
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 18e3441..696a8f5 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -4725,7 +4725,11 @@ add_function (struct arg_lookup *k, tree fn)
   else if (fn == k->functions)
 ;
   else
-k->functions = build_overload (fn, k->functions);
+{
+  k->functions = build_overload (fn, k->functions);
+  if (TREE_CODE (k->functions) == OVERLOAD)
+   OVL_ARG_DEPENDENT (k->functions) = true;
+}
 
   return false;
 }
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 30175af..2184a53 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2160,6 +2160,25 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool 
disallow_virtual,
   result = convert_from_reference (result);
 }
 
+  if (koenig_p)
+{
+  /* Free garbage OVERLOADs from arg-dependent lookup.  */
+  tree next = NULL_TREE;
+  for (fn = orig_fn;
+  fn && TREE_CODE (fn) == OVERLOAD && OVL_ARG_DEPENDENT (fn);
+  fn = next)
+   {
+ if (processing_template_decl)
+   /* In a template, we'll re-use them at instantiation time.  */
+   OVL_ARG_DEPENDENT (fn) = false;
+ else
+   {
+ next = OVL_CHAIN (fn);
+ ggc_free (fn);
+   }
+   }
+}
+
   return result;
 }
 

commit e57283fb9a55c107cc924ed9c3afa1866adcbe5e
Author: Jason Merrill 
Date:   Thu Apr 7 12

Re: PATCH [trunk] gengtype should generate ggc_alloc macros in plugin mode.

2011-04-07 Thread Duncan Sands

Hi Basile,


By the way, this patch is enough for the MELT plugin (which probably
is the only plugin needing GTY).


the dragonegg plugin also uses GTY, but only in a very mild way.

Ciao, Duncan.