public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/67646] New: [SH] Improve sign extract of bit test
@ 2015-09-20 6:05 olegendo at gcc dot gnu.org
0 siblings, 0 replies; only message in thread
From: olegendo at gcc dot gnu.org @ 2015-09-20 6:05 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-09-20 6:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-20 6:05 [Bug target/67646] New: [SH] Improve sign extract of bit test olegendo at gcc dot gnu.org
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).