ARM patch: Fix an if statement in arm_rtx_costs_1

Bernd Schmidt bernds@codesourcery.com
Tue Jul 27 16:28:00 GMT 2010


In the ARM rtx_costs code, there's an if statement which consists of a
logical or of two conditions, the second of which always implies the
first.  This is nonsensical.  The if statement is intended to increase
the cost of operations involving frame pointer or stack pointer, except
for those where the second operand is constant.  This exception is
broken by the presumably incorrect code, and even (plus (sp) (const)) is
given a high cost.  This prevents some transformations in the new
postreload optimization I added a while ago.  Interestingly it's a
really old bug, the code was added in 1994.

The following patch fixes it; typical effects from postreload:
-       add     r4, sp, #32
-       subs    r6, r4, #4
+       add     r6, sp, #28

It also seems to be beneficial in other ways; I've seen stack frames
shrink for some functions.  Ok if it tests cleanly?


Bernd
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: arm-framecost.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100727/b464d6dc/attachment.ksh>


More information about the Gcc-patches mailing list