public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/43908] New: Very poor code generation (unnecessary conditionals and reloads) for ARM
@ 2010-04-27 12:06 tobias at ringis dot se
2010-04-28 10:10 ` [Bug rtl-optimization/43908] [4.5 only] Unnecessary conditionals ramana at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: tobias at ringis dot se @ 2010-04-27 12:06 UTC (permalink / raw)
To: gcc-bugs
The following code:
struct A { int r0; int r1; };
void sigh(struct A *a, const int d)
{
int i;
for (i = 0; i < 8; ++i) {
if (d & (1U << i))
a->r0 = 1;
else
a->r1 = 1;
}
}
compiled using
arm-none-eabi-gcc -mcpu=arm7tdmi -marm -O3 -S -o- tmp2.c
produces very poor code:
sigh:
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
tst r1, #1
moveq r3, #1
movne r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #2
moveq r3, #1
movne r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #4
moveq r3, #1
movne r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #8
moveq r3, #1
movne r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #16
moveq r3, #1
movne r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #32
moveq r3, #1
movne r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #64
moveq r3, #1
movne r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #128
movne r3, #1
moveq r3, #1
strne r3, [r0, #0]
streq r3, [r0, #4]
bx lr
Note the silly occurrences of:
moveq r1, #1
movne r1, #1
More importantly, there is no need to load the constant 1 into r3 in every
iteration. It should be loaded only once before the (unrolled) loop.
--
Summary: Very poor code generation (unnecessary conditionals and
reloads) for ARM
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tobias at ringis dot se
GCC host triplet: x86_64-redhat-linux
GCC target triplet: arm-none-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43908
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug rtl-optimization/43908] [4.5 only] Unnecessary conditionals
2010-04-27 12:06 [Bug rtl-optimization/43908] New: Very poor code generation (unnecessary conditionals and reloads) for ARM tobias at ringis dot se
@ 2010-04-28 10:10 ` ramana at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: ramana at gcc dot gnu dot org @ 2010-04-28 10:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ramana at gcc dot gnu dot org 2010-04-28 10:10 -------
On trunk I don't see the movne / moveq problem but the extra mov r3, #1 could
be removed. (I think one of Bernd's recent fixes to ifcvt.c fixed these
issues).
tst r1, #1
mov r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #2
mov r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #4
mov r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #8
mov r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #16
mov r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #32
mov r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #64
mov r3, #1
streq r3, [r0, #4]
strne r3, [r0, #0]
tst r1, #128
mov r3, #1
strne r3, [r0, #0]
streq r3, [r0, #4]
bx lr
--
ramana at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |missed-optimization
Known to fail| |4.5.0
Last reconfirmed|0000-00-00 00:00:00 |2010-04-28 10:10:19
date| |
Summary|Very poor code generation |[4.5 only] Unnecessary
|(unnecessary conditionals |conditionals
|and reloads) for ARM |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43908
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-04-28 10:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-27 12:06 [Bug rtl-optimization/43908] New: Very poor code generation (unnecessary conditionals and reloads) for ARM tobias at ringis dot se
2010-04-28 10:10 ` [Bug rtl-optimization/43908] [4.5 only] Unnecessary conditionals ramana at gcc dot gnu dot 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).