[backport from gcc-4.7/trunk ] gcc/ 2011-04-08 Michael Matz PR middle-end/48389 * jump.c (rebuild_jump_labels_1, rebuild_jump_labels_chain): New functions. (rebuild_jump_labels): Call rebuild_jump_labels_1. * rtl.h (rebuild_jump_labels_chain): Declare. * cfgexpand.c (gimple_expand_cfg): Initialize JUMP_LABEL also on insns inserted on edges. gcc/testsuite/ 2011-04-08 Michael Matz PR middle-end/48389 * gcc.target/i386/pr48389.c: New test. --- gcc-4.6.0/gcc/cfgexpand.c.~1~ 2011-03-03 17:06:33.000000000 +0100 +++ gcc-4.6.0/gcc/cfgexpand.c 2011-05-15 15:26:42.000000000 +0200 @@ -4127,6 +4127,8 @@ gimple_expand_cfg (void) /* Zap the tree EH table. */ set_eh_throw_stmt_table (cfun, NULL); + /* We need JUMP_LABEL be set in order to redirect jumps, and hence + split edges which edge insertions might do. */ rebuild_jump_labels (get_insns ()); FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb) @@ -4137,6 +4139,7 @@ gimple_expand_cfg (void) { if (e->insns.r) { + rebuild_jump_labels_chain (e->insns.r); /* Avoid putting insns before parm_birth_insn. */ if (e->src == ENTRY_BLOCK_PTR && single_succ_p (ENTRY_BLOCK_PTR) --- gcc-4.6.0/gcc/jump.c.~1~ 2010-12-13 04:08:24.000000000 +0100 +++ gcc-4.6.0/gcc/jump.c 2011-05-15 15:26:42.000000000 +0200 @@ -72,12 +72,9 @@ static void redirect_exp_1 (rtx *, rtx, static int invert_exp_1 (rtx, rtx); static int returnjump_p_1 (rtx *, void *); -/* This function rebuilds the JUMP_LABEL field and REG_LABEL_TARGET - notes in jumping insns and REG_LABEL_OPERAND notes in non-jumping - instructions and jumping insns that have labels as operands - (e.g. cbranchsi4). */ -void -rebuild_jump_labels (rtx f) +/* Worker for rebuild_jump_labels and rebuild_jump_labels_chain. */ +static void +rebuild_jump_labels_1 (rtx f, bool count_forced) { rtx insn; @@ -89,11 +86,31 @@ rebuild_jump_labels (rtx f) closely enough to delete them here, so make sure their reference count doesn't drop to zero. */ - for (insn = forced_labels; insn; insn = XEXP (insn, 1)) - if (LABEL_P (XEXP (insn, 0))) - LABEL_NUSES (XEXP (insn, 0))++; + if (count_forced) + for (insn = forced_labels; insn; insn = XEXP (insn, 1)) + if (LABEL_P (XEXP (insn, 0))) + LABEL_NUSES (XEXP (insn, 0))++; timevar_pop (TV_REBUILD_JUMP); } + +/* This function rebuilds the JUMP_LABEL field and REG_LABEL_TARGET + notes in jumping insns and REG_LABEL_OPERAND notes in non-jumping + instructions and jumping insns that have labels as operands + (e.g. cbranchsi4). */ +void +rebuild_jump_labels (rtx f) +{ + rebuild_jump_labels_1 (f, true); +} + +/* This function is like rebuild_jump_labels, but doesn't run over + forced_labels. It can be used on insn chains that aren't the + main function chain. */ +void +rebuild_jump_labels_chain (rtx chain) +{ + rebuild_jump_labels_1 (chain, false); +} /* Some old code expects exactly one BARRIER as the NEXT_INSN of a non-fallthru insn. This is not generally true, as multiple barriers --- gcc-4.6.0/gcc/rtl.h.~1~ 2011-03-09 21:49:00.000000000 +0100 +++ gcc-4.6.0/gcc/rtl.h 2011-05-15 15:26:42.000000000 +0200 @@ -2311,6 +2311,7 @@ extern int redirect_jump_1 (rtx, rtx); extern void redirect_jump_2 (rtx, rtx, rtx, int, int); extern int redirect_jump (rtx, rtx, int); extern void rebuild_jump_labels (rtx); +extern void rebuild_jump_labels_chain (rtx); extern rtx reversed_comparison (const_rtx, enum machine_mode); extern enum rtx_code reversed_comparison_code (const_rtx, const_rtx); extern enum rtx_code reversed_comparison_code_parts (enum rtx_code, const_rtx, --- gcc-4.6.0/gcc/testsuite/gcc.target/i386/pr48389.c.~1~ 1970-01-01 01:00:00.000000000 +0100 +++ gcc-4.6.0/gcc/testsuite/gcc.target/i386/pr48389.c 2011-05-15 15:26:42.000000000 +0200 @@ -0,0 +1,13 @@ +/* PR middle-end/48389 */ +/* { dg-do compile } */ +/* { dg-options "-O -mtune=pentiumpro -Wno-abi" } */ +/* { dg-require-effective-target ilp32 } */ +typedef float V2SF __attribute__ ((vector_size (128))); +V2SF foo (int x, V2SF a) +{ + V2SF b = {}; + if (x & 42) + b = a; + a += b; + return a; +}