https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123070

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So cse1 is where the major difference shows up first.


Before cse1 we have:
(insn 22 21 23 5 (set (reg/f:DI 103 [ <retval> ])
        (reg:DI 99 [ ivtmp.7D.2982 ])) "t.c":9:12 99 {*movdi_internal}
     (nil))
(insn 23 22 24 5 (set (reg:CCZ 17 flags)
        (compare:CCZ (mem:SI (reg/f:DI 103 [ <retval> ]) [1 MEM[(intD.6 *)_3]+0
S4 A32])
            (reg/v:SI 106 [ valD.2960 ]))) "t.c":9:8 15 {*cmpsi_1}
     (nil))

(in both before and after make_forwarders_with_degenerate_phis ).


Before make_forwarders_with_degenerate_phis, cse does:
```
(insn 19 18 20 4 (set (reg/f:DI 103 [ <retval> ])
        (reg:DI 99 [ ivtmp.7D.2982 ])) "t.c":9:12 99 {*movdi_internal}
     (nil))
(insn 20 19 21 4 (set (reg:CCZ 17 flags)
        (compare:CCZ (mem:SI (reg/f:DI 103 [ <retval> ]) [1 MEM[(intD.6 *)_3]+0
S4 A32])
            (reg/v:SI 106 [ valD.2960 ]))) "t.c":9:8 15 {*cmpsi_1}
     (nil))
...
(insn 23 22 25 5 (parallel [
            (set (reg:DI 99 [ ivtmp.7D.2982 ])
                (plus:DI (reg/f:DI 103 [ <retval> ])
                    (const_int 4 [0x4])))
            (clobber (reg:CC 17 flags))
        ]) "t.c":8:3 discrim 3 289 {*adddi_1}
     (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))
```


While after make_forwarders_with_degenerate_phis cse1 does:
```
(insn 22 21 23 5 (set (reg/f:DI 103 [ <retval> ])
        (reg:DI 99 [ ivtmp.7D.2982 ])) "t.c":9:12 99 {*movdi_internal}
     (nil))
(insn 23 22 24 5 (set (reg:CCZ 17 flags)
        (compare:CCZ (mem:SI (reg:DI 99 [ ivtmp.7D.2982 ]) [1 MEM[(intD.6
*)_3]+0 S4 A32])
            (reg/v:SI 106 [ valD.2960 ]))) "t.c":9:8 15 {*cmpsi_1}
     (nil))
...
(insn 26 25 28 6 (parallel [
            (set (reg:DI 99 [ ivtmp.7D.2982 ])
                (plus:DI (reg:DI 99 [ ivtmp.7D.2982 ])
                    (const_int 4 [0x4])))
            (clobber (reg:CC 17 flags))
        ]) "t.c":8:3 discrim 3 289 {*adddi_1}
     (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))
```

that is now there is an overlap of reg 99 and reg 103.
But why does it do it?
There is not much difference and register 103 is not alive in the out case both
cases since it is written to right away in both cases (in the second loop exit
that is).

Reply via email to