From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26509 invoked by alias); 18 Feb 2003 10:06:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 26473 invoked by uid 71); 18 Feb 2003 10:06:00 -0000 Resent-Date: 18 Feb 2003 10:06:00 -0000 Resent-Message-ID: <20030218100600.26472.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, lac@rgai.hu Received: (qmail 19098 invoked by uid 48); 18 Feb 2003 09:54:23 -0000 Message-Id: <20030218095423.19097.qmail@sources.redhat.com> Date: Tue, 18 Feb 2003 10:06:00 -0000 From: lac@rgai.hu Reply-To: lac@rgai.hu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: optimization/9739: With -Os while and for loops can be arranged with one test instead of two X-SW-Source: 2003-02/txt/msg00782.txt.bz2 List-Id: >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 "" # 1 "" # 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=