public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: hongtao Liu <liuhongt@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3368] Avoid FROM being overwritten in expand_fix. Date: Mon, 6 Sep 2021 10:58:14 +0000 (GMT) [thread overview] Message-ID: <20210906105814.64A4B3858414@sourceware.org> (raw) https://gcc.gnu.org/g:93e6809459f34ca7b5928f1729246b2e9dfb3eb4 commit r12-3368-g93e6809459f34ca7b5928f1729246b2e9dfb3eb4 Author: liuhongt <hongtao.liu@intel.com> Date: Mon Sep 6 17:09:38 2021 +0800 Avoid FROM being overwritten in expand_fix. For the conversion from _Float16 to int, if the corresponding optab does not exist, the compiler will try the wider mode (SFmode here), but when floatsfsi exists but FAIL, FROM will be rewritten, which leads to a PR runtime error. gcc/ChangeLog: PR middle-end/102182 * optabs.c (expand_fix): Add from1 to avoid from being overwritten. gcc/testsuite/ChangeLog: PR middle-end/102182 * gcc.target/i386/pr101282.c: New test. Diff: --- gcc/optabs.c | 11 ++++++----- gcc/testsuite/gcc.target/i386/pr101282.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/gcc/optabs.c b/gcc/optabs.c index ebed78fda3f..019bbb62882 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -5488,20 +5488,21 @@ expand_fix (rtx to, rtx from, int unsignedp) if (icode != CODE_FOR_nothing) { rtx_insn *last = get_last_insn (); + rtx from1 = from; if (fmode != GET_MODE (from)) - from = convert_to_mode (fmode, from, 0); + from1 = convert_to_mode (fmode, from, 0); if (must_trunc) { - rtx temp = gen_reg_rtx (GET_MODE (from)); - from = expand_unop (GET_MODE (from), ftrunc_optab, from, - temp, 0); + rtx temp = gen_reg_rtx (GET_MODE (from1)); + from1 = expand_unop (GET_MODE (from1), ftrunc_optab, from1, + temp, 0); } if (imode != GET_MODE (to)) target = gen_reg_rtx (imode); - if (maybe_emit_unop_insn (icode, target, from, + if (maybe_emit_unop_insn (icode, target, from1, doing_unsigned ? UNSIGNED_FIX : FIX)) { if (target != to) diff --git a/gcc/testsuite/gcc.target/i386/pr101282.c b/gcc/testsuite/gcc.target/i386/pr101282.c new file mode 100644 index 00000000000..2148b9294ef --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr101282.c @@ -0,0 +1,18 @@ +/* { dg-do run { target { ia32 } } } */ +/* { dg-options "-Os -march=i686 -mfpmath=sse -msse2" } */ + +#include<stdlib.h> +int +main (void) +{ + static volatile unsigned int ivin, ivout; + static volatile _Float16 fv1, fv2; + ivin = ((unsigned int)1); + fv1 = ((unsigned int)1); + fv2 = ivin; + ivout = fv2; + if (ivout != ((unsigned int)1)) + abort (); + + exit (0); +}
reply other threads:[~2021-09-06 10:58 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=20210906105814.64A4B3858414@sourceware.org \ --to=liuhongt@gcc.gnu.org \ --cc=gcc-cvs@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).