public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: lac@rgai.hu
To: gcc-gnats@gcc.gnu.org
Subject: optimization/9739: With -Os while and for loops can be arranged with one test instead of two
Date: Tue, 18 Feb 2003 10:06:00 -0000	[thread overview]
Message-ID: <20030218095423.19097.qmail@sources.redhat.com> (raw)

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


>Number:         9739
>Category:       optimization
>Synopsis:       With -Os while and for loops can be arranged with one test instead of two
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 18 10:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     László Vidács
>Release:        gcc version 3.3 20030210 (prerelease)
>Organization:
>Environment:
BUILD & HOST: Linux 2.4.20 i686 unknown
TARGET: arm-unknown-elf
>Description:
In the case of a while or for loop, gcc first tests whether to enter the loop or not; and at the end of the loop, it tests again whether to jump back to the beginning of the loop or not. One of these two test-and-conditional-jumps should be replaced with an unconditional jump to the other test when optimizing for size. When optimizing for speed this is not a problem.

Example (01.c): The compare and conditional return at lines 24-25 (in 01.s) are not needed, they are replaced by unconditional jump to the test (see 01_modified.s).
>How-To-Repeat:
arm-elf-gcc -S -g0 -Os

// 01.c:

# 1 "/home/alec/gcc/test/issues/_src/lac_5/01.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "/home/alec/gcc/test/issues/_src/lac_5/01.c"
int F()
{
  return 2;
}

int main()
{
  int i=F();
  while (i>0)
  {
        i--;
  }
  return i;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-gzip; name="dup-loop-tests.tar.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="dup-loop-tests.tar.gz"

H4sIAMD9UT4AA+2YUWvbMBDH8+pAvoOWMkggtiXbSSBdy6CQvoztYew5KPbZFZNsI8ndutLvXsl2
zcbWdhskZUO/F0un01l34f62g0nARgcGE4xXKzzCGJP1MrFXTJLuaonXqxFer6IkMsMYW/8kiUcI
H/pglkZpKhEaFSB1JR73oxzSY5znyJwggqbhVSUgtBmGRZqGGpQOmVINqHCnZBpymu6WISZBOp2M
2x1v9g3j2mfl+WBJKyFomSHOShisfxSZlRptZ/PJ+HYyRkiCbmSJotPJ+G4y7lYFZeXgYA3szGw4
tbMvV4wDmrFzPLfT1qOD+X7rcfddVNZFfenqvzym9Orw93iy/0mEk5/7P3H9fwy8IDd94037FvQC
DV+1vVLOitKL7LDg1Z5yb9su39TgbRfodd6UqWZVORlvN2bhLaKyUOgM4QWqTZOBUYJ2kksqwA5b
p3a2KwEy6NcbBWpHy6q8EVVjRn2U1ttIyWfTsQVTGiRS9BoQcCZYSTVkgXER1bUnTZCTqPOXqA+d
V9Ico+JV0UDvV6cL42BzUOxbm0Pgb3+dqZWZIVk7+SFfa/j7lMlTKdtzsnqBVG0mSos881T9aoFu
c2O0C1yae6V3drXZew/Wk8QY9t0vlIq6K4mNxzPBAWjr2MZQdb8/eLfa9FGsd7uD/P52b++ZCEMx
uxoF/kPhWAal9qaXFxcbNLt8/2mO4iBGkXnU44hgNDPlksCBKphPnQq/JJjsRJWxnJmGOtSD4Dn9
J8to0P9lbMYkivHK6f8xcPr/n+m/Feb1o/pu1jZO5R0DEmgm4LD3eO77H9t3/k7/k8j+F0BIFEVO
/48BlcIHnvvm6xz5H5FfYOR/UK5bHQ6Hw+FwOBwOh8PhcDgcDofjX+cexh+FDQAoAAA=


             reply	other threads:[~2003-02-18 10:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-18 10:06 lac [this message]
2003-03-04 15:53 bangerth

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=20030218095423.19097.qmail@sources.redhat.com \
    --to=lac@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).