public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "crazylht at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/99930] Failure to optimize floating point -abs(x) in nontrivial code at -O2/3 Date: Wed, 07 Apr 2021 10:27:05 +0000 [thread overview] Message-ID: <bug-99930-4-eQ3jcBRRil@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99930-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99930 --- Comment #7 from Hongtao.liu <crazylht at gmail dot com> --- i'm testing 1 file changed, 30 insertions(+) gcc/combine.c | 30 ++++++++++++++++++++++++++++++ modified gcc/combine.c @@ -1811,6 +1811,33 @@ set_nonzero_bits_and_sign_copies (rtx x, const_rtx set, void *data) } } } + +/* Return true is reg is only defined by loading from constant pool. */ +static int +single_ref_from_constant_pool (rtx reg) +{ + gcc_assert (REG_P (reg)); + rtx_insn* insn; + rtx src, set; + + if (DF_REG_DEF_COUNT (REGNO (reg)) != 1) + return 0; + insn = DF_REF_INSN (DF_REG_DEF_CHAIN (REGNO (reg))); + if (!insn) + return 0; + set = single_set (insn); + if (!set) + return 0; + src = SET_SRC (set); + + /* Constant pool. */ + if (!MEM_P (src) + || !SYMBOL_REF_P (XEXP (src, 0)) + || !CONSTANT_POOL_ADDRESS_P (XEXP (src, 0))) + return 0; + + return 1; +} /* See if INSN can be combined into I3. PRED, PRED2, SUCC and SUCC2 are optionally insns that were previously combined into I3 or that will be @@ -1895,7 +1922,10 @@ can_combine_p (rtx_insn *insn, rtx_insn *i3, rtx_insn *pred ATTRIBUTE_UNUSED, something to tell them apart, e.g. different modes. For now, we forgo such complicated tests and simply disallow combining of USES of pseudo registers with any other USE. */ + /* If the USE in INSN is only defined by loading from constant + pool, it must have identical value. */ if (REG_P (XEXP (elt, 0)) + && !single_ref_from_constant_pool (XEXP (elt, 0)) && GET_CODE (PATTERN (i3)) == PARALLEL) { rtx i3pat = PATTERN (i3);
next prev parent reply other threads:[~2021-04-07 10:27 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-06 10:38 [Bug target/99930] New: " core13 at gmx dot net 2021-04-06 11:57 ` [Bug rtl-optimization/99930] " rguenth at gcc dot gnu.org 2021-04-06 12:00 ` rguenth at gcc dot gnu.org 2021-04-06 17:31 ` segher at gcc dot gnu.org 2021-04-07 10:04 ` jakub at gcc dot gnu.org 2021-04-07 10:06 ` jakub at gcc dot gnu.org 2021-04-07 10:14 ` ubizjak at gmail dot com 2021-04-07 10:27 ` crazylht at gmail dot com [this message] 2021-04-07 16:32 ` segher at gcc dot gnu.org 2021-04-08 9:48 ` crazylht at gmail dot com 2021-04-08 22:46 ` segher at gcc dot gnu.org 2021-07-25 1:30 ` pinskia at gcc dot gnu.org 2023-12-24 23:16 ` [Bug middle-end/99930] " 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-99930-4-eQ3jcBRRil@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).