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/67646] New: [SH] Improve sign extract of bit test Date: Sun, 20 Sep 2015 06:05:00 -0000 [thread overview] Message-ID: <bug-67646-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67646 Bug ID: 67646 Summary: [SH] Improve sign extract of bit test Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: olegendo at gcc dot gnu.org Target Milestone: --- Target: sh*-*-* The following: unsigned int test (unsigned int x) { return (x & 0x30) ? ~0 : 0; } compiled with -m4 -ml -O2 results in: mov r4,r0 tst #48,r0 subc r0,r0 rts not r0,r0 This is already minimal, but in some cases addc can be used: mov r4,r0 tst #48,r0 mov #0,r1 mov #-1,r0 addc r1,r0 r0 = 0 + (-1) + T T = 0: r0 = 0 + (-1) + 0 = -1 T = 1: r0 = 0 + (-1) + 1 = 0 If the constant 0 can be shared with some other insn, this would result in a mov #imm8, addc sequence, which is good for SH4A, because mov #imm8 is an MT group insn. If the test constant is only one bit: unsigned int test (unsigned int x) { return (x & 0x20) ? ~0 : 0; } -m4 -ml -O2: mov r4,r0 tst #32,r0 mov #-1,r0 negc r0,r0 rts neg r0,r0 This should result in the same code as for the constant 0x30.
reply other threads:[~2015-09-20 6:05 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=bug-67646-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).