public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/9739: With -Os while and for loops can be arranged with one test instead of two
@ 2003-03-04 15:53 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-03-04 15:53 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, lac, nobody

Synopsis: With -Os while and for loops can be arranged with one test instead of two

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Tue Mar  4 15:53:35 2003
State-Changed-Why:
    By request of submitter

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9739


^ permalink raw reply	[flat|nested] 2+ messages in thread

* optimization/9739: With -Os while and for loops can be arranged with one test instead of two
@ 2003-02-18 10:06 lac
  0 siblings, 0 replies; 2+ messages in thread
From: lac @ 2003-02-18 10:06 UTC (permalink / raw)
  To: gcc-gnats

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-03-04 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-04 15:53 optimization/9739: With -Os while and for loops can be arranged with one test instead of two bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-02-18 10:06 lac

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).