public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/112760] [14 Regression] wrong code with -O2 -fno-dce -fno-guess-branch-probability -m8bit-idiv -mavx --param=max-cse-insns=0 and __builtin_add_overflow_p() since r14-5355
Date: Fri, 01 Dec 2023 12:45:19 +0000	[thread overview]
Message-ID: <bug-112760-4-cvfToOaPJB@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112760-4@http.gcc.gnu.org/bugzilla/>

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
In reload dump I see no changes (except function_decl/var_decl addresses), in
vzeroupper, postreload, split2, ree and cmpelim dumps a bunch of extra REG_DEAD
notes
here and there in r14-5355 compared to r14-5354, and finally pro_and_epilogue
deletes
(insn 20 19 62 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg:SI 0 ax [110])
            (reg:SI 1 dx [111]))) "pr112760.c":6:22 11 {*cmpsi_1}
     (expr_list:REG_UNUSED (reg:CCZ 17 flags)
        (nil)))
insn.
In reload dump there is:
(insn 20 19 44 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg:SI 0 ax [110])
            (reg:SI 1 dx [111]))) "pr112760.c":6:22 11 {*cmpsi_1}
     (nil))
(insn 44 20 62 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg:SI 0 ax [110])
            (reg:SI 1 dx [111]))) "pr112760.c":6:22 11 {*cmpsi_1}
     (nil))
(insn 62 44 46 2 (set (reg:HI 0 ax [118])
        (const_int 1 [0x1])) "pr112760.c":6:22 86 {*movhi_internal}
     (expr_list:REG_EQUIV (const_int 1 [0x1])
        (nil)))
(insn 46 62 25 2 (set (reg:HI 3 bx [orig:103 _8+2 ] [103])
        (if_then_else:HI (eq (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (reg:HI 3 bx [orig:103 _8+2 ] [103])
            (reg:HI 0 ax [118]))) "pr112760.c":6:22 1381 {*movhicc_noc}
     (nil))
so the insn 20 is indeed useless and in vzeroupper pass that was correctly
marked in
the notes:
(insn 20 19 44 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg:SI 0 ax [110])
            (reg:SI 1 dx [111]))) "pr112760.c":6:22 11 {*cmpsi_1}
     (expr_list:REG_UNUSED (reg:CCZ 17 flags)
        (nil)))
(insn 44 20 62 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg:SI 0 ax [110])
            (reg:SI 1 dx [111]))) "pr112760.c":6:22 11 {*cmpsi_1}
     (expr_list:REG_DEAD (reg:SI 1 dx [111])
        (expr_list:REG_DEAD (reg:SI 0 ax [110])
            (nil))))
(insn 62 44 46 2 (set (reg:HI 0 ax [118])
        (const_int 1 [0x1])) "pr112760.c":6:22 86 {*movhi_internal}
     (expr_list:REG_EQUIV (const_int 1 [0x1])
        (nil)))
(insn 46 62 25 2 (set (reg:HI 3 bx [orig:103 _8+2 ] [103])
        (if_then_else:HI (eq (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (reg:HI 3 bx [orig:103 _8+2 ] [103])
            (reg:HI 0 ax [118]))) "pr112760.c":6:22 1381 {*movhicc_noc}
     (expr_list:REG_DEAD (reg:CCZ 17 flags)
        (expr_list:REG_DEAD (reg:HI 0 ax [118])
            (nil))))
But then postreload deletes insn 44 rather than 20 and keeps the notes around
unchanged.
Insn 20 is deleted in
#2  0x0000000000cce9df in copyprop_hardreg_forward_1 (bb=<basic_block
0x7fffea2f7c60 (2)>, vd=0x3bd2be0) at ../../gcc/regcprop.cc:829
#3  0x0000000000ccfe1c in copyprop_hardreg_forward_bb_without_debug_insn
(bb=<basic_block 0x7fffea2f7c60 (2)>) at ../../gcc/regcprop.cc:1235
#4  0x0000000000d5b371 in prepare_shrink_wrap (entry_block=<basic_block
0x7fffea2f7c60 (2)>) at ../../gcc/shrink-wrap.cc:451
#5  0x0000000000d5bb70 in try_shrink_wrapping (entry_edge=0x7fffffffd900,
prologue_seq=0x7fffe9f25240) at ../../gcc/shrink-wrap.cc:674
#6  0x00000000008b4320 in thread_prologue_and_epilogue_insns () at
../../gcc/function.cc:6056
and regcprop.cc documents it relies on up to date REG_DEAD/REG_UNUSED notes;
after all
the removal happens in
      /* Detect obviously dead sets (via REG_UNUSED notes) and remove them.  */
      if (set
          && !RTX_FRAME_RELATED_P (insn)
          && NONJUMP_INSN_P (insn)
          && !may_trap_p (set)
          && find_reg_note (insn, REG_UNUSED, SET_DEST (set))
          && !side_effects_p (SET_SRC (set))
          && !side_effects_p (SET_DEST (set)))
        {
          bool last = insn == BB_END (bb);
          delete_insn (insn);
          if (last)
            break;
          continue;
        }
and regcprop.cc calls df_note_add_problem (); before calling df_analyze (). 
Except
in the pro_and_epilogue case it is done elsewhere and it just calls into the
regcprop.cc functions.

  parent reply	other threads:[~2023-12-01 12:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29  7:42 [Bug target/112760] New: [14 Regression] wrong code with -O2 -fno-dce -fno-guess-branch-probability -m8bit-idiv -mavx --param=max-cse-insns=0 and __builtin_add_overflow_p() zsojka at seznam dot cz
2023-11-29  8:02 ` [Bug target/112760] " zsojka at seznam dot cz
2023-11-29 10:45 ` [Bug rtl-optimization/112760] " ubizjak at gmail dot com
2023-12-01 12:22 ` [Bug rtl-optimization/112760] [14 Regression] wrong code with -O2 -fno-dce -fno-guess-branch-probability -m8bit-idiv -mavx --param=max-cse-insns=0 and __builtin_add_overflow_p() since r14-5355 jakub at gcc dot gnu.org
2023-12-01 12:45 ` jakub at gcc dot gnu.org [this message]
2023-12-01 12:55 ` jakub at gcc dot gnu.org
2023-12-06  8:59 ` cvs-commit at gcc dot gnu.org
2023-12-06  9:01 ` jakub at gcc dot gnu.org
2023-12-06 18:33 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-112760-4-cvfToOaPJB@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).