optimization/10122: Unnecessary move before use of function call return value
alga@rgai.hu
alga@rgai.hu
Mon Mar 17 14:34:00 GMT 2003
>Number: 10122
>Category: optimization
>Synopsis: Unnecessary move before use of function call return value
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: pessimizes-code
>Submitter-Id: net
>Arrival-Date: Mon Mar 17 13:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Gábor Lóki
>Release: GCC: (GNU) 3.3 20030303 (prerelease)
>Organization:
>Environment:
BUILD & HOST: Linux 2.4.20 i686 unknown
TARGET: arm-unknown-elf
>Description:
After a function call where the return value is stored in a hard register, GCC moves this value into a soft register. After that if an instruction uses this value, the soft register will be used.
In some cases the optimization algorithms aren't able to recognize that the soft and hard registers which hold the return value are the same. This results in an unnecessary move instruction for each arithmetic instruction that uses the return value. (In some other cases the unnecessary move is optimized out by some of the algorithms.)
In the expamle_1.i attached, in function foo there is an unnecessary move (mov r2,r0). In the example_2.i attached, in function foo there is an unnecessary move (mov r3,r0).
>How-To-Repeat:
arm-elf-gcc -S -g0 -Os example_1.i
arm-elf-gcc -S -g0 -Os example_2.i
--- example_1: ---
int bongo(int);
int j;
int foo()
{
j=bongo(44);
return bongo(35);
}
--- example_2: ---
int bongo(int);
int bar();
void foo()
{
if(bar())
bongo(44);
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-compressed; name="function-call-return-value.tgz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="function-call-return-value.tgz"
H4sICBLHdT4AAGZ1bmN0aW9uLWNhbGwtcmV0dXJuLXZhbHVlLnRhcgDtlVFr2zAQx/sqw77DLWGQ
gG1kyXahW8egD30p28PY0xhFtuWgYMuebHftSr/7JNlZ3K4jrCwpY/6/+O50p7OV/E6Ks6zkR3sV
xjgOQ3gsbhUE+AgfxzSiIaVRaOJRHOnYfl+rV9e0TMGvL/efiKnS40XurdIUvI/grTB4Hxrg16ys
C34Z+OKFsyOHmJzn/o5JT9Poh95bj138E0J+8k+OY5sfkXDi/wCaQwCz7Z8gnTk28ibpRNF6Qr7d
BNKqLJnMoBCSb4L36oRsIankqlpoa/na+uv+kVfVYuncOgDr0z4lDHUGgOJtp+RQRiMdu5smyUE1
GuJ767GT/+B4xD8Z+I8m/g+gexyTJ/JPfsd/wtRCm1eVyEZDQOQLu7DUNsBoIEzwH1zbEd7srccu
/uM43vIfDfyH0/1/CCE/FwVH969y5Lf8utUPVoiVRERbq6JKWIE0xGb1pubGdOFV3sm0FZV0tHvi
oHfA1KqBU8Au1Pp253piWCdXrOTGNDnWuZScZ9wsBy50DW8umazkTVl12ho2cVBZXSFRu9DUDmra
Ms9QU7904TbXMRMvlG6U3vWJSjeah6HO7BK0yZhrPymQHTMOKjKFFHXBvyBDDXFB4VE9jUwnZRc+
m9Q5/mLqSs7snrZ1Y1vrtsmwsX9BT0YHprc37rdKZWitjUZ8H07M9/ozNPMUrV0IXaDmgEXGZYtm
52dnJ7A4f/9pCdSnQDCmmAYYFvo0FS84a/hy9hfH5HaEPyP/OBjxH/b804n/Q+gh/+Rf5f8x5Jka
uKY942lZo57oB/PC0P31Id92213cP4b2M6E8adIf6weKmgyiABYAAA==
More information about the Gcc-bugs
mailing list