public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/54682] [SH] Replace constant loads with reg-reg copies Date: Tue, 30 Jul 2013 20:36:00 -0000 [thread overview] Message-ID: <bug-54682-4-ADZHjrpoJ0@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-54682-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54682 --- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> --- A related case, but the other way around: #include <bitset> std::bitset<32> make_bits (void) { std::bitset<32> r; for (auto&& i : { 4, 5, 6, 10 }) if (i < r.size ()) r.set (i); return r; } results in the following code (-O2): mov.l .L8,r1 mov #0,r0 mov #31,r7 mov #1,r6 // load constant '1' for '1 << x' mov #4,r2 .L2: mov.l @r1,r3 cmp/hi r7,r3 bf/s .L7 mov r6,r5 // copy constant '1' to r5 .L3: dt r2 bf/s .L2 add #4,r1 rts nop .align 1 .L7: shld r3,r5 // r5 <<= r3 bra .L3 or r5,r0 In this case one register is used to hold an imm8 constant that can be loaded with a single insn. Even though the insn 'mov Rm,Rn' is a zero-latency on SH4 and SH2A, freeing one register might result in better overall code.
next prev parent reply other threads:[~2013-07-30 20:36 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-09-23 13:34 [Bug target/54682] New: " olegendo at gcc dot gnu.org 2012-10-10 22:17 ` [Bug target/54682] " olegendo at gcc dot gnu.org 2013-07-30 20:36 ` olegendo at gcc dot gnu.org [this message] 2013-10-03 23:02 ` olegendo 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-54682-4-ADZHjrpoJ0@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).