[Bug c/12038] New: more optimization with -Os option for arm
vittasoft at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Fri Aug 22 23:39:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12038
Summary: more optimization with -Os option for arm
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: vittasoft at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686
GCC host triplet: i686
GCC target triplet: arm-thumb-elf
If function contains any branches (generated by if/for/do/while), compiler saves
lr register into stack. You can see it in this example:
unsigned int my(char *s){
if(s == NULL)
return 1;
return 0;
};
try to compile it with -mthumb -Os -S and you will see code like this:
.align 2
.global my
.thumb_func
.type my,function
my:
push {lr} @ <------ It's because function have a branch
cmp r0, #0
beq .L11
mov r0, #0
.L9:
@ sp needed for prologue
pop {pc}
.L11:
mov r0, #1
b .L9
.Lfe2:
.size my,.Lfe2-my
@ <--- gcc-3.3.1/gcc/config/arm/arm.c:thumb_far_jump_used_p
@ always returns 1 if branch command founds.
@ in this case get_attr_far_jump (insn) always returns FAR_JUMP_YES on branch,
@ because it's check length of attribute and attribute length always equal 8
More information about the Gcc-bugs
mailing list