Hi!

(I have no idea why this PR is a P1).

On Tue, Mar 31, 2020 at 09:04:18AM +0200, Jakub Jelinek wrote:
> The following testcase ICEs on armv7hl-linux-gnueabi.

Also on default arm-linux-gnueabi.  It needs -Og.

> try_combine is called on:
> (gdb) p debug_rtx (i3)
> (insn 20 12 22 2 (set (mem/c:SI (plus:SI (reg/f:SI 102 sfp)
>                 (const_int -4 [0xfffffffffffffffc])) [1 x+0 S4 A32])
>         (reg:SI 125)) "pr94291.c":7:8 241 {*arm_movsi_insn}
>      (expr_list:REG_DEAD (reg:SI 125)
>         (nil)))
> (gdb) p debug_rtx (i2)
> (insn 12 7 20 2 (parallel [
>             (set (reg:CC 100 cc)
>                 (compare:CC (reg:SI 121 [ <retval> ])
>                     (const_int 0 [0])))
>             (set (reg:SI 125)
>                 (reg:SI 121 [ <retval> ]))
>         ]) "pr94291.c":7:8 248 {*movsi_compare0}
>      (expr_list:REG_UNUSED (reg:CC 100 cc)
>         (nil)))
> and tries to recognize cc = r121 cmp 0; [sfp-4] = r121 parallel,
> but that isn't recognized,

Trying 12 -> 20:
   12: {cc:CC=cmp(r118:SI,0);r122:SI=r118:SI;}
      REG_UNUSED cc:CC
   20: [sfp:SI-0x4]=r122:SI
      REG_DEAD r122:SI
Failed to match this instruction:
(parallel [
        (set (reg:CC 100 cc)
            (compare:CC (reg:SI 118 [ <retval> ])
                (const_int 0 [0])))
        (set (mem/c:SI (plus:SI (reg/f:SI 102 sfp)
                    (const_int -4 [0xfffffffffffffffc])) [1 x+0 S4 A32])
            (reg:SI 118 [ <retval> ]))
    ])
(twice)

> so it splits it into two: split_i2i3

(That variable does not *control* the splitting: it registers that we
did split a parallel into newi2pat and newpat).

Successfully matched this instruction:
(set (mem/c:SI (plus:SI (reg/f:SI 102 sfp)
            (const_int -4 [0xfffffffffffffffc])) [1 x+0 S4 A32])
    (reg:SI 118 [ <retval> ]))
Successfully matched this instruction:
(set (reg:CC 100 cc)
    (compare:CC (reg:SI 118 [ <retval> ])
        (const_int 0 [0])))
allowing combination of insns 12 and 20
original costs 4 + 4 = 8
replacement costs 4 + 4 = 8

> [sfp-4] = r121 followed by cc = r121 cmp 0 which is recognized, but
> ICEs because the code below insist that the SET_DEST of newi2pat
> (or first set in PARALLEL thereof) must be a REG or SUBREG of REG,
> but it is a MEM in this case.  I don't see any condition that would
> guarantee that, perhaps for the swap_i2i3 case it was somehow guaranteed.

I don't see how it was guaranteed for that case, either.

> As the code just wants to update LOG_LINKS and LOG_LINKS are only for
> registers, not for MEM or anything else, the patch just doesn't update those
> if it isn't a REG or SUBREG of REG.

That is correct.

> 2020-03-31  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR rtl-optimization/94291

Please mention PR rtl-optimization/84169 as well.

>       * combine.c (try_combine): For split_i2i3, don't assume SET_DEST
>       must be a REG or SUBREG of REG; if it is not one of these, don't
>       update LOG_LINKs.
> 
>       * gcc.dg/pr94291.c: New test.

Okay for trunk, and for backports as well (after soaking it for a bit).
Thanks!


Segher

Reply via email to