public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: alga@rgai.hu
To: gcc-gnats@gcc.gnu.org
Subject: target/10242: ARM: peephole for effective use of plus and minus operators
Date: Thu, 27 Mar 2003 14:01:00 -0000	[thread overview]
Message-ID: <20030327135313.8207.qmail@sources.redhat.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2346 bytes --]


>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==


             reply	other threads:[~2003-03-27 13:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-27 14:01 alga [this message]
2003-03-27 14:56 Gábor Lóki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030327135313.8207.qmail@sources.redhat.com \
    --to=alga@rgai.hu \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).