This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/41705] New: missed if conversion optimization
- From: "carrot at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Oct 2009 09:29:10 -0000
- Subject: [Bug target/41705] New: missed if conversion optimization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compile the attached source code with options -Os -march=armv5te -mthumb, gcc
generates:
push {lr}
ldr r3, [r0]
cmp r3, #0 // B
bne .L3
ldr r3, [r0, #4]
b .L2
.L3:
mov r3, #0 // A
.L2:
ldr r2, [r0, #8]
@ sp needed for prologue
ldr r0, [r2]
add r0, r3, r0
pop {pc}
Instruction A can be moved before instruction B, which should be handled by
ifcvt.c:find_if_case_2. Notice the following code in find_if_header:
if (dom_info_state (CDI_POST_DOMINATORS) >= DOM_NO_FAST_QUERY
&& (! HAVE_conditional_execution || reload_completed))
{
if (find_if_case_1 (test_bb, then_edge, else_edge))
goto success;
if (find_if_case_2 (test_bb, then_edge, else_edge))
goto success;
}
After reload_completed, the target of conditional assignment is happened to be
allocated to the same physical register as the condition variable. This prevent
it from moving to the front of compare and branch instructions.
Before reload_completed, HAVE_conditional_execution prevent find_if_case_2 to
be called. So we missed this optimization chance.
Target ARM has conditional execution capability, but thumb actually can't do
conditional execution. Do we have any method to let the compiler know this?
--
Summary: missed if conversion optimization
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: carrot 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=41705