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/101885] [10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu Date: Thu, 20 Jan 2022 17:15:37 +0000 [thread overview] Message-ID: <bug-101885-4-XHsm8Sge73@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-101885-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101885 --- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Seems it goes wrong during combine, before combine we have: (insn 17 16 131 2 (parallel [ (set (reg:QI 124 [ _199 ]) (and:QI (reg:QI 143) (reg:QI 145))) (clobber (reg:CC 17 flags)) ]) "pr101885.c":17:5 534 {*andqi_1} (expr_list:REG_DEAD (reg:QI 145) (expr_list:REG_DEAD (reg:QI 143) (expr_list:REG_UNUSED (reg:CC 17 flags) (nil))))) (insn 131 17 130 2 (set (reg:QI 152) (const_int 0 [0])) "pr101885.c":17:5 83 {*movqi_internal} (nil)) (insn 130 131 132 2 (set (reg:CCZ 17 flags) (compare:CCZ (reg:QI 124 [ _199 ]) (const_int 0 [0]))) "pr101885.c":17:5 5 {*cmpqi_ccno_1} (nil)) (insn 132 130 134 2 (set (reg:QI 82 [ b_lsm_flag.26 ]) (if_then_else:QI (ne (reg:CCZ 17 flags) (const_int 0 [0])) (reg:QI 124 [ _199 ]) (reg:QI 152))) "pr101885.c":17:5 1204 {*movqicc_noc} (expr_list:REG_DEAD (reg:QI 152) (expr_list:REG_DEAD (reg:QI 124 [ _199 ]) (expr_list:REG_EQUAL (if_then_else:QI (ne (reg:CCZ 17 flags) (const_int 0 [0])) (reg:QI 124 [ _199 ]) (const_int 0 [0])) (nil))))) (insn 134 132 135 2 (set (reg:SI 153) (const_int 0 [0])) "pr101885.c":17:5 81 {*movsi_internal} (nil)) (insn 135 134 137 2 (set (reg:SI 90 [ a_lsm.27 ]) (if_then_else:SI (eq (reg:CCZ 17 flags) (const_int 0 [0])) (reg:SI 90 [ a_lsm.27 ]) (reg:SI 153))) "pr101885.c":17:5 1201 {*movsicc_noc} (expr_list:REG_EQUAL (if_then_else:SI (eq (reg:CCZ 17 flags) (const_int 0 [0])) (reg:SI 90 [ a_lsm.27 ]) (const_int 0 [0])) (nil))) and that is in RTL what the optimized dump had: _33 = _31 & _32; if (_33 != 0) goto <bb 7>; [13.50%] else goto <bb 6>; [86.50%] <bb 6> [local count: 12627325]: <bb 7> [local count: 14598063]: # b_lsm_flag.26_11 = PHI <_33(5), b_lsm_flag.26_202(6)> # a_lsm.27_45 = PHI <0(5), a_lsm.27_203(6)> i.e. both the conditional moves consume flags reg set from comparison of x & y result against 0. But combine makes: (note 17 16 131 2 NOTE_INSN_DELETED) (note 131 17 130 2 NOTE_INSN_DELETED) (insn 130 131 132 2 (set (reg:CCZ 17 flags) (compare:CCZ (and:QI (reg:QI 143) (reg:QI 145)) (const_int 0 [0]))) "pr101885.c":17:5 515 {*testqi_1_maybe_si} (nil)) (insn 132 130 134 2 (parallel [ (set (reg:QI 82 [ b_lsm_flag.26 ]) (and:QI (reg:QI 143) (reg:QI 145))) (clobber (reg:CC 17 flags)) ]) "pr101885.c":17:5 534 {*andqi_1} (expr_list:REG_UNUSED (reg:CC 17 flags) (expr_list:REG_DEAD (reg:QI 145) (expr_list:REG_DEAD (reg:QI 143) (nil))))) out of this (followed by the conditional moves). That means it sets flags and then immediately clobbers them by another and. Ideally we want *andqi_2_maybe_si insn for both that (set (reg 17) (compare (and:QI (match_operand:QI 1 ("nonimmediate_operand") ("%0,0,0")) (match_operand:QI 2 ("general_operand") ("qn,m,n"))) (const_int 0 [0]))) (set (match_operand:QI 0 ("nonimmediate_operand") ("=qm,q,r")) (and:QI (match_dup 1) (match_dup 2))) but if that isn't used, at least the flag setting should be after 132 and not before it...
next prev parent reply other threads:[~2022-01-20 17:15 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-12 17:09 [Bug tree-optimization/101885] New: " qrzhang at gatech dot edu 2021-08-12 17:10 ` [Bug tree-optimization/101885] " qrzhang at gatech dot edu 2021-08-12 21:06 ` [Bug rtl-optimization/101885] [10/11/12 Regression] " pinskia at gcc dot gnu.org 2021-08-12 21:22 ` pinskia at gcc dot gnu.org 2021-08-12 21:23 ` pinskia at gcc dot gnu.org 2021-08-16 7:34 ` rguenth at gcc dot gnu.org 2022-01-20 15:29 ` jakub at gcc dot gnu.org 2022-01-20 15:40 ` jakub at gcc dot gnu.org 2022-01-20 16:55 ` jakub at gcc dot gnu.org 2022-01-20 17:15 ` jakub at gcc dot gnu.org [this message] 2022-01-20 17:27 ` jakub at gcc dot gnu.org 2022-01-20 17:29 ` jakub at gcc dot gnu.org 2022-01-20 18:00 ` jakub at gcc dot gnu.org 2022-02-03 11:07 ` roger at nextmovesoftware dot com 2022-02-04 1:03 ` segher at gcc dot gnu.org 2022-02-04 9:38 ` cvs-commit at gcc dot gnu.org 2022-02-10 22:26 ` [Bug rtl-optimization/101885] [10/11 " roger at nextmovesoftware dot com 2022-03-16 7:37 ` roger at nextmovesoftware dot com 2022-03-16 8:10 ` rguenth at gcc dot gnu.org 2022-06-28 10:46 ` jakub at gcc dot gnu.org 2023-07-07 10:40 ` [Bug rtl-optimization/101885] [11 " rguenth 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-101885-4-XHsm8Sge73@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: linkBe 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).