This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/43462] New: Suboptimal switch table jump generation
- From: "mirq-gccboogs at rere dot qmqm dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Mar 2010 03:26:52 -0000
- Subject: [Bug target/43462] New: Suboptimal switch table jump generation
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
code:
extern int a;
void b();
main()
{
switch (a & 7) {
case 0: b(); break;
case 1: b(); break;
case 2: b(); break;
case 3: b(); break;
case 4: b(); break;
case 5: b(); break;
case 6: b(); break;
case 7: b(); break;
}
}
generates:
[...]
and r3, r3, #7
subs r3, r3, #1
cmp r3, #6
bhi .L9
tbb [pc, r3]
.L10:
.byte (.L9-.L10)/2
.byte (.L9-.L10)/2
.byte (.L9-.L10)/2
.byte (.L9-.L10)/2
.byte (.L9-.L10)/2
.byte (.L9-.L10)/2
.byte (.L9-.L10)/2
.align 1
.L9:
[...]
This could be better implemented as:
and r3, r3, #7
tbb [pc, r3]
(jump table with 8 entries)
[...]
Please ignore that all branches are the same in this example.
--
Summary: Suboptimal switch table jump generation
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mirq-gccboogs at rere dot qmqm dot pl
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-none-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43462