public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/32283]  New: Missed induction variable optimization
@ 2007-06-11 13:43 pranav dot bhandarkar at gmail dot com
  2007-06-11 13:45 ` [Bug rtl-optimization/32283] " pranav dot bhandarkar at gmail dot com
                   ` (29 more replies)
  0 siblings, 30 replies; 31+ messages in thread
From: pranav dot bhandarkar at gmail dot com @ 2007-06-11 13:43 UTC (permalink / raw)
  To: gcc-bugs

Consider the following code snippet

static volatile short a[(2048)];
short foo (int len, int v)
{
  int i;
  for (i = 0; i < len; i++) {
    a[i] = v;
  }
  return a[0];
}

This should generate a post_inc for accessing elements of a. The problem  seems
to be in the loop optimizer that fails to identify 'i' as an induction
variable. For e.g the dump from 141r.loop2_invariant shows 

(insn 16 15 75 4 (set (reg/v:SI 103 [ i ])
        (const_int 0 [0x0])) 161 {*arm_movsi_insn} (nil))

(insn 75 16 17 4 (set (reg/f:SI 118)
        (symbol_ref:SI ("^a") [flags 0x2] <var_decl 0xb7dc1000 a>)) -1 (nil))

(code_label 17 75 18 5 4 "" [0 uses])

(note 18 17 21 5 [bb 5] NOTE_INSN_BASIC_BLOCK)

(insn 21 18 23 5 (set (reg:SI 110)
        (ashift:SI (reg/v:SI 103 [ i ])
            (const_int 1 [0x1]))) 115 {*arm_shiftsi3} (nil))

(insn 23 21 25 5 (set (mem/s/v:HI (plus:SI (reg:SI 110)
                (reg/f:SI 118)) [3 a S2 A16])
        (subreg/s/u:HI (reg:SI 102 [ pretmp.21 ]) 0)) 171 {*movhi_insn_arch4}
(nil))

(insn 25 23 26 5 (set (reg/v:SI 103 [ i ])
        (plus:SI (reg/v:SI 103 [ i ])
            (const_int 1 [0x1]))) 4 {*arm_addsi3} (nil))

(insn 26 25 27 5 (set (reg:CC 24 cc)
        (compare:CC (reg/v:SI 106 [ len ])
            (reg/v:SI 103 [ i ]))) 214 {*arm_cmpsi_insn} (nil))

(jump_insn 27 26 82 5 (set (pc)
        (if_then_else (gt (reg:CC 24 cc)
                (const_int 0 [0x0]))
            (label_ref:SI 82)
            (pc))) 224 {*arm_cond_branch} (expr_list:REG_BR_PROB (const_int
9900 [0x26ac])
        (nil)))

Here reg 103 i.e 'i' is incremented by 1 always and therefore 110 always
increases by 2 which means that in each iteration the address in INSN 23 is 2
more than what it was in the previous iteration. If the access is converted
into something like
*118 = v
118 += 2, 
then the auto-inc-dec pass will be able to convert this into a post_inc


Version Details:
GNU C version 4.3.0 20070316 (experimental) (arm-none-eabi)
        compiled by GNU C version 3.4.6 (Ubuntu 3.4.6-1ubuntu2).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096


-- 
           Summary: Missed induction variable optimization
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pranav dot bhandarkar at gmail dot com
GCC target triplet: arm-none-eabi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32283


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

end of thread, other threads:[~2010-05-22 18:19 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-11 13:43 [Bug rtl-optimization/32283] New: Missed induction variable optimization pranav dot bhandarkar at gmail dot com
2007-06-11 13:45 ` [Bug rtl-optimization/32283] " pranav dot bhandarkar at gmail dot com
2007-06-11 14:07 ` rguenth at gcc dot gnu dot org
2007-06-11 14:33 ` pranav dot bhandarkar at gmail dot com
2007-06-11 18:46 ` pinskia at gcc dot gnu dot org
2007-06-13 12:36 ` pranav dot bhandarkar at gmail dot com
2007-06-13 17:53 ` pinskia at gcc dot gnu dot org
2007-06-14 20:50 ` pranav dot bhandarkar at gmail dot com
2007-08-24 13:28 ` pranav dot bhandarkar at gmail dot com
2007-09-05 11:46 ` ramana dot radhakrishnan at celunite dot com
2007-09-06 17:57 ` rakdver at gcc dot gnu dot org
2007-09-08 13:19 ` rakdver at gcc dot gnu dot org
2007-09-10 18:29 ` dje at gcc dot gnu dot org
2007-09-20 16:25 ` amonakov at gmail dot com
2007-11-27 11:00 ` ramana dot radhakrishnan at celunite dot com
2007-12-05 16:26 ` amonakov at gmail dot com
2007-12-05 16:43 ` rakdver at kam dot mff dot cuni dot cz
2007-12-16 20:30 ` rakdver at gcc dot gnu dot org
2008-10-30 14:52 ` [Bug rtl-optimization/32283] [4.3/4.4 regression] " dje at gcc dot gnu dot org
2008-10-30 16:33 ` rguenth at gcc dot gnu dot org
2008-10-30 16:48 ` janis at gcc dot gnu dot org
2008-10-30 16:58 ` rguenth at gcc dot gnu dot org
2008-11-01 12:05 ` rguenth at gcc dot gnu dot org
2008-11-17  3:45 ` rakdver at gcc dot gnu dot org
2008-11-20  8:08 ` rakdver at gcc dot gnu dot org
2008-12-22  6:01 ` cnstar9988 at gmail dot com
2009-01-15 10:34 ` ramana at icerasemi dot com
2009-01-24 10:26 ` rguenth at gcc dot gnu dot org
2009-08-04 12:36 ` [Bug rtl-optimization/32283] [4.3/4.4/4.5 " rguenth at gcc dot gnu dot org
2010-03-16 15:26 ` amonakov at gcc dot gnu dot org
2010-05-22 18:19 ` [Bug rtl-optimization/32283] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org

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