public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jay.foad at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/61563] New: better 387 code for float x == (int)x Date: Thu, 19 Jun 2014 15:47:00 -0000 [thread overview] Message-ID: <bug-61563-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61563 Bug ID: 61563 Summary: better 387 code for float x == (int)x Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jay.foad at gmail dot com I get this with GCC 4.10.0 20140619 (experimental): $ gcc -mno-sse -O3 -S -o - -x c - <<<"int f(float x) { return x == (int)x; }" ... f: fnstcw -2(%rsp) movzwl -2(%rsp), %eax flds 8(%rsp) movl $0, %edx orb $12, %ah movw %ax, -4(%rsp) xorl %eax, %eax fldcw -4(%rsp) fistl -12(%rsp) fldcw -2(%rsp) fildl -12(%rsp) fucomip %st(1), %st fstp %st(0) setnp %al cmovne %edx, %eax ret All the fnstcw and fldcw stuff is unnecessary, because when we convert x to int, it doesn't matter what rounding mode we use; all that matters is whether it is already an exact int value or not. I think the x == (int)x pattern is fairly common, and it would be nice if GCC generated better 387 code for it.
next reply other threads:[~2014-06-19 15:47 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-06-19 15:47 jay.foad at gmail dot com [this message] 2014-06-19 16:22 ` [Bug target/61563] " joseph at codesourcery dot com 2014-06-19 20:16 ` jay.foad at gmail dot com 2014-06-21 8:45 ` ubizjak at gmail dot com 2021-08-02 20:08 ` 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-61563-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: 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).