public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/42501] New: Code bloating on operations with bit fields
@ 2009-12-25 13:05 sliao at google dot com
2009-12-30 0:19 ` [Bug middle-end/42501] [4.4 only] " ramana at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: sliao at google dot com @ 2009-12-25 13:05 UTC (permalink / raw)
To: gcc-bugs
Alexvod tried pr31849-patch from
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31849. It changed result size from
72 to 68 below, but still didn't eliminated the loop counter below.
See the following code
// compilation options: -march=armv5te -mthumb -Os
struct tree_block
{
unsigned handler_block_flag:2;
unsigned block_num:30;
};
static int next_block_index = 2;
void number_blocks (int n_blocks, struct tree_block **block_vector)
{
int i;
for (i = 0; i < n_blocks; ++i)
((block_vector[i])->block_num) = next_block_index++;
}
is compiled by gcc 4.4.0 in very inefficient way. gcc 4.2.1 compiles it to 48
bytes, and gcc 4.4.0 to 72 bytes (1.5 times bigger).
Analysis of assembly files shows the following problems:
1) operations with bitfields are done inefficiently. gcc-4.2.1 sets block_num
by LSLing the value and ORRing it.gcc-4.4.0 loads an extra constant 0x3fffffff
from memory and does AND in addition to that LSL and ORR.
2) gcc-4.4.0 doesn't eliminate loop counter i. It increments both block_vector
and i. Instead gcc-4.2.1 computes the end of the loop and increments only
block_vector
3) register allocation performs badly, it spills some registers to stack, which
causes extra LDR, STR operations in the loop body
The code was taken from GCC SPEC benchmark.
--
Summary: Code bloating on operations with bit fields
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sliao at google dot com
GCC build triplet: i686-linux
GCC host triplet: i686-linux
GCC target triplet: arm-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42501
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/42501] [4.4 only] Code bloating on operations with bit fields
2009-12-25 13:05 [Bug middle-end/42501] New: Code bloating on operations with bit fields sliao at google dot com
@ 2009-12-30 0:19 ` ramana at gcc dot gnu dot org
2009-12-31 15:28 ` rguenth at gcc dot gnu dot org
2010-01-08 0:29 ` sliao at google dot com
2 siblings, 0 replies; 4+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-12-30 0:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ramana at gcc dot gnu dot org 2009-12-30 00:19 -------
This appears to be a 4.4 only size regression and this appears to be fixed on
trunk.
With -Os -march=armv5te -mthumb size is 44 bytes on trunk as of today. gcc
version 4.5.0 20091229 (experimental) (GCC)
00000000 <number_blocks>:
0: b5f0 push {r4, r5, r6, r7, lr}
2: 4b09 ldr r3, [pc, #36] ; (28 <number_blocks+0x28>)
4: 2200 movs r2, #0
6: 681b ldr r3, [r3, #0]
8: 2503 movs r5, #3
a: e007 b.n 1c <number_blocks+0x1c>
c: c910 ldmia r1!, {r4}
e: 009f lsls r7, r3, #2
10: 6826 ldr r6, [r4, #0]
12: 3201 adds r2, #1
14: 402e ands r6, r5
16: 433e orrs r6, r7
18: 3301 adds r3, #1
1a: 6026 str r6, [r4, #0]
1c: 4282 cmp r2, r0
1e: dbf5 blt.n c <number_blocks+0xc>
20: 4a01 ldr r2, [pc, #4] ; (28 <number_blocks+0x28>)
22: 6013 str r3, [r2, #0]
24: bdf0 pop {r4, r5, r6, r7, pc}
26: 46c0 nop ; (mov r8, r8)
28: 00000000 .word 0x00000000
--
ramana at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-12-30 00:19:26
date| |
Summary|Code bloating on operations |[4.4 only] Code bloating on
|with bit fields |operations with bit fields
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42501
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/42501] [4.4 only] Code bloating on operations with bit fields
2009-12-25 13:05 [Bug middle-end/42501] New: Code bloating on operations with bit fields sliao at google dot com
2009-12-30 0:19 ` [Bug middle-end/42501] [4.4 only] " ramana at gcc dot gnu dot org
@ 2009-12-31 15:28 ` rguenth at gcc dot gnu dot org
2010-01-08 0:29 ` sliao at google dot com
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-12-31 15:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2009-12-31 15:28 -------
Fixed in 4.5.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to work| |4.5.0
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42501
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/42501] [4.4 only] Code bloating on operations with bit fields
2009-12-25 13:05 [Bug middle-end/42501] New: Code bloating on operations with bit fields sliao at google dot com
2009-12-30 0:19 ` [Bug middle-end/42501] [4.4 only] " ramana at gcc dot gnu dot org
2009-12-31 15:28 ` rguenth at gcc dot gnu dot org
@ 2010-01-08 0:29 ` sliao at google dot com
2 siblings, 0 replies; 4+ messages in thread
From: sliao at google dot com @ 2010-01-08 0:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from sliao at google dot com 2010-01-08 00:29 -------
Yes, I generated the code from the trunk and got the same code as Ramana got,
except for the last line below. (Sorry that I filed this bug right before the
Christmas flight and couldn't check the trunk at that time.)
815c: b5f0 push {r4, r5, r6, r7, lr}
815e: 4b09 ldr r3, [pc, #36] ; (8184 <main+0x28>)
8160: 2200 movs r2, #0
8162: 681b ldr r3, [r3, #0]
8164: 2503 movs r5, #3
8166: e007 b.n 8178 <main+0x1c>
8168: c910 ldmia r1!, {r4}
816a: 009f lsls r7, r3, #2
816c: 6826 ldr r6, [r4, #0]
816e: 3201 adds r2, #1
8170: 402e ands r6, r5
8172: 433e orrs r6, r7
8174: 3301 adds r3, #1
8176: 6026 str r6, [r4, #0]
8178: 4282 cmp r2, r0
817a: dbf5 blt.n 8168 <main+0xc>
817c: 4a01 ldr r2, [pc, #4] ; (8184 <main+0x28>)
817e: 6013 str r3, [r2, #0]
8180: bdf0 pop {r4, r5, r6, r7, pc}
8182: 46c0 nop ; (mov r8, r8)
8184: 00011b04 .word 0x00011b04
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42501
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-01-08 0:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-25 13:05 [Bug middle-end/42501] New: Code bloating on operations with bit fields sliao at google dot com
2009-12-30 0:19 ` [Bug middle-end/42501] [4.4 only] " ramana at gcc dot gnu dot org
2009-12-31 15:28 ` rguenth at gcc dot gnu dot org
2010-01-08 0:29 ` sliao at google dot com
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).