public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/52396] New: Gcc failed to hoist loop invariant expression out of loop
@ 2012-02-27  8:26 carrot at google dot com
  2012-02-29 11:46 ` [Bug rtl-optimization/52396] Gcc failed to hoist loop invariant GOT load " ramana at gcc dot gnu.org
  2023-05-26  1:08 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: carrot at google dot com @ 2012-02-27  8:26 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52396
           Summary: Gcc failed to hoist loop invariant expression out of
                    loop
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: carrot@google.com
            Target: arm-linux-gnueabi


Compile the following source code with options -march=armv7-a -mthumb -Os -fpic

extern int array[];

int t0l(int len)
{
  int t = 0;
  int i;
  for (i=0; i<len; i++)
    t = t + array[i];
  return t;
}

ARM gcc 4.7 generates:


t0l:
    ldr    r1, .L4
    movs    r3, #0
    push    {r4, lr}
.LPIC8:
    add    r1, pc
    mov    r2, r3
    b    .L2
.L3:
    ldr    r4, .L4+4                // A
    ldr    r4, [r1, r4]             // B
    ldr    r4, [r4, r3, lsl #2]
    adds    r3, r3, #1
    adds    r2, r2, r4
.L2:
    cmp    r3, r0
    blt    .L3
    mov    r0, r2
    pop    {r4, pc}
.L5:
    .align    2
.L4:
    .word    _GLOBAL_OFFSET_TABLE_-(.LPIC8+4)
    .word    array(GOT)

Instructions AB are loop invariant, could be taken out of the loop without
increase code size.

If I change -Os to -O2, ivopts can successfully do this optimization.


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

* [Bug rtl-optimization/52396] Gcc failed to hoist loop invariant GOT load out of loop
  2012-02-27  8:26 [Bug tree-optimization/52396] New: Gcc failed to hoist loop invariant expression out of loop carrot at google dot com
@ 2012-02-29 11:46 ` ramana at gcc dot gnu.org
  2023-05-26  1:08 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: ramana at gcc dot gnu.org @ 2012-02-29 11:46 UTC (permalink / raw)
  To: gcc-bugs

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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-02-29
                 CC|                            |ramana at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2012-02-29 11:43:31 UTC ---
We manage to hoist this at O2 but not at Os in 4.7 while 4.6 appears to work
fine.


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

* [Bug rtl-optimization/52396] Gcc failed to hoist loop invariant GOT load out of loop
  2012-02-27  8:26 [Bug tree-optimization/52396] New: Gcc failed to hoist loop invariant expression out of loop carrot at google dot com
  2012-02-29 11:46 ` [Bug rtl-optimization/52396] Gcc failed to hoist loop invariant GOT load " ramana at gcc dot gnu.org
@ 2023-05-26  1:08 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-26  1:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52396

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |5.4.0, 6.4.0, 7.5.0
   Target Milestone|---                         |8.0
      Known to work|                            |4.5.4, 4.6.4, 8.2.0
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
IV-OPTS does the correct thing for GCC 8+.

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

end of thread, other threads:[~2023-05-26  1:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-27  8:26 [Bug tree-optimization/52396] New: Gcc failed to hoist loop invariant expression out of loop carrot at google dot com
2012-02-29 11:46 ` [Bug rtl-optimization/52396] Gcc failed to hoist loop invariant GOT load " ramana at gcc dot gnu.org
2023-05-26  1:08 ` pinskia at gcc dot gnu.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).