This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

target/10242: ARM: peephole for effective use of plus and minus operators


>Number:         10242
>Category:       target
>Synopsis:       ARM: peephole for effective use of plus and minus operators
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 27 13:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Gábor Lóki
>Release:        GCC: (GNU) 3.3 20030324 (prerelease)
>Organization:
>Environment:
BUILD & HOST: Linux 2.4.20 i686 unknown
TARGET: arm-unknown-elf
>Description:
In some cases the generated code contains (for arm target) a plus operator with positive constant which is followed by another plus operator with a negative constant and both operate on the same register (eg: "add rD, rB, #c0" and "sub rD, rD, #c1" ).
This makes an opportunity for effective use of these operators if c0+c1 can be stored in the Immediate Operand filed. Specifically, in this case "add rD, rB, #c2" where c2 = c0 + c1 and c2 >= 0, or "sub rD, rB, #c2" where c2 = -(c0 + c1) and c2 < 0.
This problem generally occurs when storing local variables on the stack.
The same can be applied for all four combinations of plus and minus operators.
In the example attached, in function foo there is a "sub r0,r0,#12" and "sub r0,r0,#4" which can be replaced by "sub r0,r0,#16".
>How-To-Repeat:
arm-elf-gcc -S -g0 -Os plus-minus.c

void func(char*);
void foo()
{
  char buf[1028];
  func(buf);
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-compressed; name="plus-minus.tgz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="plus-minus.tgz"

H4sICIjTgj4AAHBsdXMtbWludXMudGFyAO1VwWrcMBDNVYL8w3RDYLfYRrZlb0goFHLIrT2UnkoJ
Wlt2DLJsJDs0Dfn3juQtu7SBHMpuIfED45mnsWY0+I16NdqwbfRoo+LkQGCM5ZzDc7xHzNgJW+ec
ZVmcpdzHrzm+D1XQPkY7CAN/F/dGcN81JVSjLpbFnTDvV1d0YrpuuaKPFMDRsBmrbzFLLr5fIeOj
kcHYJ/q/65/xb+h3+reHyvGS/vMk2+k/Z5P+1+tZ/0cAiapGSbLY+w+KBSXRIH8M+BKqqTVJ0KpV
txGK4GBwqw+9dGYA524aDE2nKbqXlHwEYWoLH4AF0Bs5SF1OTmVEK9F0Y8SFef9WS1lKFxEHMFpp
b4Xu9EPbjWht96Gk7e5J0wdge0rs0FYlsf27AB4r5ByvDOYqnnBx3JDf5BmffONyOx8Tbynr93qe
2vvKPWdx8geBARtsA56aElW2UviMvha3ga8jss3PbX+icOpYU0o9kMXN9fUlLG8+fV1BGqWQMJay
NOGwxF4ZqaSwcrU45lA1UuAhDpvjJf0zvtN/nPj7P8v5rP9jQJg2lKoK66KA8AuENYPws4X9cXA6
X/IzZrxO/AIEvCdTAA4AAA==


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]