public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "stevenbaker94 at rocketmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/55372] MIPS: Loading integer constants to floating-pointer registers generates suboptimal code Date: Wed, 01 May 2013 10:17:00 -0000 [thread overview] Message-ID: <bug-55372-4-4QdhTGFYgb@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55372-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55372 --- Comment #1 from stevenbaker94 at rocketmail dot com 2013-05-01 10:16:56 UTC --- This version handles negative numbers as well: static inline float _fpos(const float f) { union { float f; uint32_t i; } x; x.f = f; uint32_t r; float f_out; asm ("lui %0, %1" : "=d" (r) : "K" (x.i >> 16)); asm ("mtc1 %1, %0" : "=f" (f_out) : "d" (r)); return f_out; } static inline float _fneg(const float f) { union { float f; uint32_t i; } x; x.f = f; uint32_t r; float f_out; asm ("lui %0, %1" : "=d" (r) : "K" (0x8000 ^ (x.i >> 16))); asm ("mtc1 %1, %0" : "=f" (f_out) : "d" (r)); return f_out; } static inline float f(const float f) { return f >= 0 ? _fpos(f) : _fneg(-f); } Actually, it doesn't always discard fractional bits. It works for e.g. f(0.25) as well, since the floating-point representation still only has 0s in the lower 16 bits.
prev parent reply other threads:[~2013-05-01 10:17 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-18 0:15 [Bug target/55372] New: " stevenbaker94 at rocketmail dot com 2013-05-01 10:17 ` stevenbaker94 at rocketmail dot com [this message]
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-55372-4-4QdhTGFYgb@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).