[Committed] S/390: PR57609 fix - use next_active_insn instead of next_real_insn

Andreas Krebbel krebbel@linux.vnet.ibm.com
Wed Jun 19 12:18:00 GMT 2013


On 18/06/13 19:06, Steven Bosscher wrote:
> BTW I don't understand how a label satisfying the following can be
> true for a label before a jump table:
> 
>       if (LABEL_P (insn)
>           && (LABEL_PRESERVE_P (insn) || LABEL_NAME (insn)))
> 
> LABEL_PRESERVE_P should never be set on a label before a
> JUMP_TABLE_DATA, and LABEL_NAME should be NULL.

Actually LABEL_PRESERVE_P appears to be set on quite many of the jump table data labels.  Example
from compiling fold-const.c:

(code_label/s 1285 1284 1286 9315 "" [3 uses])

(jump_table_data 1286 1285 1287 (addr_vec:SI [
            (label_ref:SI 54875)
            (label_ref:SI 63283)
            (label_ref:SI 63283)
            (label_ref:SI 63283)
            (label_ref:SI 63283)
            (label_ref:SI 63283)
            (label_ref:SI 63283) ...

Hardware watchpoint 5: table_label->in_struct

Old value = 0
New value = 1
force_const_mem (mode=SImode, x=0x7c0c27c0) at /build/gcc-head/gcc/varasm.c:3699
3699      return copy_rtx (def);
(gdb) bt
#0  force_const_mem (mode=SImode, x=0x7c0c27c0) at /build/gcc-head/gcc/varasm.c:3699
#1  0x009ada54 in emit_move_insn (x=0x7bdf44b0, y=0x7c0c27c0) at /build/gcc-head/gcc/expr.c:3499
#2  0x010b3e6a in gen_casesi (operand0=0x7bdf42d0, operand1=0x7d7e24e0, operand2=0x7c0c20e0,
    operand3=0x7b3c4488, operand4=0x7b3c43c0) at /build/gcc-head/gcc/config/s390/s390.md:8588
#3  0x00c0c70e in maybe_gen_insn (icode=CODE_FOR_casesi, nops=5, ops=0x7fffe3a8)
    at /build/gcc-head/gcc/optabs.c:8219
#4  0x00c0c92a in maybe_expand_jump_insn (icode=CODE_FOR_casesi, nops=5, ops=0x7fffe3a8)
    at /build/gcc-head/gcc/optabs.c:8257
#5  0x00c0c9ee in expand_jump_insn (icode=CODE_FOR_casesi, nops=5, ops=0x7fffe3a8)
    at /build/gcc-head/gcc/optabs.c:8283
#6  0x009ca5ec in try_casesi (index_type=0x7d7e6420, index_expr=0x7bca4168, minval=0x7d889300,
    range=0x7d156920, table_label=0x7b3c4488, default_label=0x7b3c43c0, fallback_label=0x7b3c43e8,
    default_probability=3333) at /build/gcc-head/gcc/expr.c:10967
#7  0x00d18016 in emit_case_dispatch_table (index_expr=0x7bca4168, index_type=0x7d7e6420,
    case_list=0x1a31d58, default_label=0x7b3c43c0, minval=0x7d889300, maxval=0x7d0ad180,
    range=0x7d156920, stmt_bb=0x7bf96000) at /build/gcc-head/gcc/stmt.c:1933
#8  0x00d18ef4 in expand_case (stmt=0x7d7dc800) at /build/gcc-head/gcc/stmt.c:2207

> Better yet would be to use tablejump_p instead of examining the
> pattern by hand, e.g.:

Ok. Better. I've applied your patch after testing it. Thanks!

Bye,

-Andreas-

> 
> Index: s390.c
> ===================================================================
> --- s390.c      (revision 200173)
> +++ s390.c      (working copy)
> @@ -7023,7 +7023,7 @@ s390_chunkify_start (void)
>        if (LABEL_P (insn)
>           && (LABEL_PRESERVE_P (insn) || LABEL_NAME (insn)))
>         {
> -         rtx vec_insn = next_active_insn (insn);
> +         rtx vec_insn = NEXT_INSN (insn);
>           if (! vec_insn || ! JUMP_TABLE_DATA_P (vec_insn))
>             bitmap_set_bit (far_labels, CODE_LABEL_NUMBER (insn));
>         }
> @@ -7033,6 +7033,8 @@ s390_chunkify_start (void)
>        else if (JUMP_P (insn))
>         {
>            rtx pat = PATTERN (insn);
> +          rtx table;
> +
>           if (GET_CODE (pat) == PARALLEL && XVECLEN (pat, 0) > 2)
>             pat = XVECEXP (pat, 0, 0);
> 
> @@ -7046,28 +7048,18 @@ s390_chunkify_start (void)
>                     bitmap_set_bit (far_labels, CODE_LABEL_NUMBER (label));
>                 }
>              }
> -         else if (GET_CODE (pat) == PARALLEL
> -                  && XVECLEN (pat, 0) == 2
> -                  && GET_CODE (XVECEXP (pat, 0, 0)) == SET
> -                  && GET_CODE (XVECEXP (pat, 0, 1)) == USE
> -                  && GET_CODE (XEXP (XVECEXP (pat, 0, 1), 0)) == LABEL_REF)
> -           {
> -             /* Find the jump table used by this casesi jump.  */
> -             rtx vec_label = XEXP (XEXP (XVECEXP (pat, 0, 1), 0), 0);
> -             rtx vec_insn = next_active_insn (vec_label);
> -             if (vec_insn && JUMP_TABLE_DATA_P (vec_insn))
> -               {
> -                 rtx vec_pat = PATTERN (vec_insn);
> -                 int i, diff_p = GET_CODE (vec_pat) == ADDR_DIFF_VEC;
> -
> -                 for (i = 0; i < XVECLEN (vec_pat, diff_p); i++)
> -                   {
> -                     rtx label = XEXP (XVECEXP (vec_pat, diff_p, i), 0);
> -
> -                     if (s390_find_pool (pool_list, label)
> -                         != s390_find_pool (pool_list, insn))
> -                       bitmap_set_bit (far_labels, CODE_LABEL_NUMBER (label));
> -                   }
> +         else if (tablejump_p (insn, NULL, &table))
> +           {
> +             rtx vec_pat = PATTERN (table);
> +             int i, diff_p = GET_CODE (vec_pat) == ADDR_DIFF_VEC;
> +
> +             for (i = 0; i < XVECLEN (vec_pat, diff_p); i++)
> +               {
> +                 rtx label = XEXP (XVECEXP (vec_pat, diff_p, i), 0);
> +
> +                 if (s390_find_pool (pool_list, label)
> +                     != s390_find_pool (pool_list, insn))
> +                   bitmap_set_bit (far_labels, CODE_LABEL_NUMBER (label));
>                 }
>             }
>          }
> 
> Ciao!
> Steven
> 



More information about the Gcc-patches mailing list