public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "carrot at google dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/45098] New: Missed induction variable optimization Date: Wed, 28 Jul 2010 02:39:00 -0000 [thread overview] Message-ID: <bug-45098-17659@http.gcc.gnu.org/bugzilla/> (raw) Compile the following code with options -march=armv7-a -mthumb -Os extern void foo(int*); void tr(int array[], int n) { int i; for (i=0; i<n; i++) foo(&array[i]); } GCC 4.6 generates: push {r4, r5, r6, lr} mov r6, r1 mov r5, r0 movs r4, #0 b .L2 .L3: mov r0, r5 adds r4, r4, #1 bl foo adds r5, r5, #4 .L2: cmp r4, r6 blt .L3 pop {r4, r5, r6, pc} We can see that both r4 and r5 are loop induction variables, and r4 is used for loop counter only. So we can transform it to push {r4, r5, r6, lr} mov r5, r0 add r6, r5, r1 << 2 b .L2 .L3: mov r0, r5 bl foo adds r5, r5, #4 .L2: cmp r5, r6 blt .L3 pop {r4, r5, r6, pc} This new code is shorter and faster than original result, it uses one less register at the same time. Both tree-ssa and rtl loop optimizations missed this optimization. -- Summary: Missed induction variable optimization Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: carrot at google dot com GCC build triplet: i686-linux GCC host triplet: i686-linux GCC target triplet: arm-eabi http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45098
next reply other threads:[~2010-07-28 2:39 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-07-28 2:39 carrot at google dot com [this message] 2010-07-30 17:23 ` [Bug middle-end/45098] " davidxl at gcc dot gnu dot org 2010-08-02 7:55 ` ramana at gcc dot gnu dot org
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=bug-45098-17659@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).