From: Uros Bizjak <ubizjak@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [PATCH, RTL opt]: Ensure that equivalent_reg_at_start rejects registers with mismatched mode
Date: Sat, 13 May 2017 21:44:00 -0000 [thread overview]
Message-ID: <CAFULd4aczAEN=izyq_iGRaLZ0LyT1EG_+SvYpztiykFpx8dnXg@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1662 bytes --]
Hello!
-mtune=intel is able to copy SFmode value through general registers,
resulting in the following sequence:
(insn 288 1008 1009 29 (parallel [
(set (reg:DI 4 si [687])
(lshiftrt:DI (reg:DI 4 si [687])
(const_int 32 [0x20])))
(clobber (reg:CC 17 flags))
]) "ttt.c":41 546 {*lshrdi3_1}
(nil))
(insn 1009 288 289 29 (set (reg:DI 2 cx [419])
(reg:DI 4 si [687])) "ttt.c":41 81 {*movdi_internal}
(nil))
(insn 289 1009 291 29 (set (reg:SF 21 xmm0 [425])
(reg:SF 2 cx [419])) "ttt.c":41 127 {*movsf_internal}
(nil))
(insn 291 289 292 29 (set (reg:CCFPU 17 flags)
(compare:CCFPU (reg:SF 21 xmm0 [425])
(reg:SF 27 xmm6 [688]))) "ttt.c":41 51 {*cmpiusf}
(expr_list:REG_EQUAL (compare:CCFPU (reg:SF 21 xmm0 [425])
(const_double:SF 0.0 [0x0.0p+0]))
(nil)))
Looking at compare-elim.c, equivalent_reg_at_start, the function
traces the value in %xmm0 to %rsi. So, try_eliminate_compare tries to
check if the target supports the compare of
(lshiftrt:DI (reg:DI 4 si [687])
(const_int 32 [0x20])))
with
(reg:SF 27 xmm6 [688])
which won't fly, since compare operands must have the same modes.
Attached patch ensures that the mode of register copy, found by
equivalent_reg_at_start equals original mode.
2017-05-13 Uros Bizjak <ubizjak@gmail.com>
* compare-elim.c (equivalent_reg_at_start): Return NULL_RTX
when returned register mode doesn't match original mode.
Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
Committed to mainline SVN as obvious.
Uros.
[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 635 bytes --]
Index: compare-elim.c
===================================================================
--- compare-elim.c (revision 248008)
+++ compare-elim.c (working copy)
@@ -526,6 +526,7 @@ maybe_select_cc_mode (struct comparison *cmp, rtx
static rtx
equivalent_reg_at_start (rtx reg, rtx_insn *end, rtx_insn *start)
{
+ machine_mode orig_mode = GET_MODE (reg);
rtx_insn *bb_head = BB_HEAD (BLOCK_FOR_INSN (end));
for (rtx_insn *insn = PREV_INSN (end);
@@ -572,6 +573,9 @@ equivalent_reg_at_start (rtx reg, rtx_insn *end, r
return NULL_RTX;
}
+ if (GET_MODE (reg) != orig_mode)
+ return NULL_RTX;
+
return reg;
}
reply other threads:[~2017-05-13 21:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='CAFULd4aczAEN=izyq_iGRaLZ0LyT1EG_+SvYpztiykFpx8dnXg@mail.gmail.com' \
--to=ubizjak@gmail.com \
--cc=gcc-patches@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).