On Sat, Dec 02, 2023 at 11:04:04AM +0000, Richard Sandiford wrote:
> I still maintain that so much stuff relies on the lack of false-positive
> REG_UNUSED notes that (whatever the intention might have been) we need
> to prevent the false positive.  Like Andrew says, any use of single_set
> is suspect if there's a REG_UNUSED note for something that is in fact used.

The false positive REG_UNUSED in that case comes from
(insn 15 14 35 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg:DI 0 ax [111])
            (reg:DI 1 dx [112]))) "pr112760.c":11:22 12 {*cmpdi_1}
     (expr_list:REG_UNUSED (reg:CCZ 17 flags)
        (nil)))
(insn 35 15 36 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg:DI 0 ax [111])
            (reg:DI 1 dx [112]))) "pr112760.c":11:22 12 {*cmpdi_1}
     (expr_list:REG_DEAD (reg:DI 1 dx [112])
        (expr_list:REG_DEAD (reg:DI 0 ax [111])
            (nil))))
...
use of flags
Haven't verified what causes the redundant comparison, but postreload cse
then does:
110           if (!count && cselib_redundant_set_p (body))
111             {
112               if (check_for_inc_dec (insn))
113                 delete_insn_and_edges (insn);
114               /* We're done with this insn.  */
115               goto done;
116             }
So, we'd in such cases need to look up what instruction was the earlier
setter and if it has REG_UNUSED note, drop it.

        Jakub

Reply via email to