public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/56110] New: Sub-optimal code: unnecessary CMP after AND
@ 2013-01-25 17:12 tilman@code-monkey.de
2013-02-16 16:49 ` [Bug target/56110] " tilman@code-monkey.de
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: tilman@code-monkey.de @ 2013-01-25 17:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56110
Bug #: 56110
Summary: Sub-optimal code: unnecessary CMP after AND
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: tilman@code-monkey.de
Target: arm
Compiling this code
unsigned f1 (unsigned x, unsigned m)
{
if (m & 0x008080)
x >>= 8;
return x;
}
with gcc 4.7.2 gives this code for ARMv5:
$ armv5tel-softfloat-linux-gnueabi-gcc -O2 -S -o- f1.c
[...]
ldr r3, .L6
and r3, r1, r3 @ XXX
cmp r3, #0 @ XXX
movne r0, r0, lsr #8
bx lr
[...]
AFAICS we could get rid of the CMP if we used ANDS instead of AND:
ldr r3, .L6
ands r3, r1, r3
movne r0, r0, lsr #8
bx lr
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/56110] Sub-optimal code: unnecessary CMP after AND
2013-01-25 17:12 [Bug target/56110] New: Sub-optimal code: unnecessary CMP after AND tilman@code-monkey.de
@ 2013-02-16 16:49 ` tilman@code-monkey.de
2013-03-16 9:01 ` tilman@code-monkey.de
2013-08-05 19:36 ` ramana at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: tilman@code-monkey.de @ 2013-02-16 16:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56110
--- Comment #1 from Tilman Sauerbeck <tilman@code-monkey.de> 2013-02-16 16:49:34 UTC ---
Changing the literal in the test function so that it fits in 8 bits makes gcc
go with the TST instruction instead of AND+CMP:
unsigned f2 (unsigned x, unsigned m)
{
if (m & 0x80)
x >>= 8;
return x;
}
=>
tst r1, #128
movne r0, r0, lsr #8
bx lr
So I guess I shouldn't ask why gcc generates AND+CMP instead of ANDS, but why
it chooses not to use TST.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/56110] Sub-optimal code: unnecessary CMP after AND
2013-01-25 17:12 [Bug target/56110] New: Sub-optimal code: unnecessary CMP after AND tilman@code-monkey.de
2013-02-16 16:49 ` [Bug target/56110] " tilman@code-monkey.de
@ 2013-03-16 9:01 ` tilman@code-monkey.de
2013-08-05 19:36 ` ramana at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: tilman@code-monkey.de @ 2013-03-16 9:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56110
--- Comment #2 from Tilman Sauerbeck <tilman@code-monkey.de> 2013-03-16 09:01:17 UTC ---
Created attachment 29677
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29677
WIP patch
I'm not really sure if this patch is good or bad. The discussion on the ML died
off eventually (maybe because I asked one too many silly questions).
Anyway, without guidance I won't be able to finish this, but I want to post my
WIP here at least.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/56110] Sub-optimal code: unnecessary CMP after AND
2013-01-25 17:12 [Bug target/56110] New: Sub-optimal code: unnecessary CMP after AND tilman@code-monkey.de
2013-02-16 16:49 ` [Bug target/56110] " tilman@code-monkey.de
2013-03-16 9:01 ` tilman@code-monkey.de
@ 2013-08-05 19:36 ` ramana at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: ramana at gcc dot gnu.org @ 2013-08-05 19:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56110
Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-08-05
CC| |ramana at gcc dot gnu.org
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-05 19:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-25 17:12 [Bug target/56110] New: Sub-optimal code: unnecessary CMP after AND tilman@code-monkey.de
2013-02-16 16:49 ` [Bug target/56110] " tilman@code-monkey.de
2013-03-16 9:01 ` tilman@code-monkey.de
2013-08-05 19:36 ` ramana 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).