public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rjiejie at me dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/97170] New: Wrong optimization in fwprop pass
Date: Wed, 23 Sep 2020 05:36:38 +0000	[thread overview]
Message-ID: <bug-97170-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 97170
           Summary: Wrong optimization in fwprop pass
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rjiejie at me dot com
  Target Milestone: ---

insn seqs:

s1:

        __builtin_set_float_convert_mode(0);
        r1 = __builtin_load(a1, a2);
        r2 = __builtin_float_convert(r1);
        __builtin_store(a3, r2);
        __builtin_set_float_convert_mode(0);

s2:
        __builtin_set_float_convert_mode(1);
        r1 = __builtin_load(a1, a2);
        r2 = __builtin_float_convert(r1);
        __builtin_store(a3, r2);
        __builtin_set_float_convert_mode(0);


the diference of s1 and s2 only is "__builtin_set_float_convert_mode"

from beginning, the s1 mode is set 0, but s2 mode is set 1.

from optimization 'fwprop', the s2 insns seqs is deleted 

as dead code, is it gcc bug ?



builtin patten of __builtin_set_float_convert_mode:


(define_insn "target_fcvtmode"
  [(set (reg:SI FCVTMODE_REGNUM)
        (unspec_volatile:SI [(match_operand:SI 0 "csr_operand" "rK")]
UNSPECV_FCVTMODE))]
  ""
  "fcvtmode\t%1"
)


builtin patten of __builtin_set_float_convert_mode:

(define_insn "target_fcvt"
  [(set (match_operand:SI 0 "register_operand" "=r")
        (unspec:SI [(match_operand:SF 1 "register_operand" "f")]
        UNSPEC_FCVT))
   (use (reg:SI FCVTMODE_REGNUM))]
  ""
  "fcvt\t%0,%1"
)


As far as i know, __builtin_set_float_convert_mode depend on 'FCVTMODE_REGNUM'
which is from
__builtin_set_float_convert_mode, it's not dead code.

or something wrong in my pattens ?

Anyone could give me some hints ?

Thanks

             reply	other threads:[~2020-09-23  5:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23  5:36 rjiejie at me dot com [this message]
2020-09-23  5:49 ` [Bug rtl-optimization/97170] " pinskia at gcc dot gnu.org
2020-09-23  8:08 ` rjiejie at me dot com

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-97170-4@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).