public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/34160] New: Useful loop invariant motion missing @ 2007-11-20 12:05 amonakov at gmail dot com 2007-11-20 12:06 ` [Bug tree-optimization/34160] " amonakov at gmail dot com ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: amonakov at gmail dot com @ 2007-11-20 12:05 UTC (permalink / raw) To: gcc-bugs int main() { static int i, n; static double a[200], b[200]; ... (more variables and control flow) for (i = 0; i < n; i++) a[i] = b[i]; ... } Tree-level optimisations do not pull out loads of i and n and store to i out of loop. As a result, GCC generates five memory accesses on ia64 for each iteration (4.3.0 20071112): .L9: .mii nop 0 sxt4 r14 = r16 nop 0 .mmi ld4 r15 = [r32] ld4 r58 = [r33] nop 0 ;; .mii shladd r14 = r14, 3, r0 adds r16 = 1, r15 ;; add r15 = r35, r14 .mmi add r14 = r34, r14 st4 [r32] = r16 cmp4.lt p6, p7 = r16, r58 ;; .mmi nop 0 ldfd f6 = [r15] nop 0 ;; .mib stfd [r14] = f6 nop 0 (p6) br.cond.dptk .L9 On x86_64 situation is better (4.3.0 20070930), but not good: .L13: movslq %eax,%rdx movq b.3894(,%rdx,8), %rax movq %rax, x.3895(,%rdx,8) leal 1(%rcx), %eax cmpl %eax, %edi movl %eax, %ecx movl %eax, i.3912(%rip) jg .L13 but the optimization happened on RTL level, as final_cleanup dump reads: <bb 13>: # MPT.140_429 = VDEF <MPT.140_645> x[i.265] = b[i.265]; # VUSE <MPT.140_429> i.23 = i; i.265 = i.23 + 1; # MPT.140_430 = VDEF <MPT.140_429> i = i.265; # VUSE <MPT.140_430> n.274 = n; if (n.274 > i.265) goto <bb 13>; else goto <bb 14>; -- Summary: Useful loop invariant motion missing Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: amonakov at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34160 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/34160] Useful loop invariant motion missing 2007-11-20 12:05 [Bug tree-optimization/34160] New: Useful loop invariant motion missing amonakov at gmail dot com @ 2007-11-20 12:06 ` amonakov at gmail dot com 2007-11-20 15:43 ` rguenth at gcc dot gnu dot org 2009-04-03 12:28 ` rguenth at gcc dot gnu dot org 2 siblings, 0 replies; 4+ messages in thread From: amonakov at gmail dot com @ 2007-11-20 12:06 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from amonakov at gmail dot com 2007-11-20 12:06 ------- Created an attachment (id=14584) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14584&action=view) Preprocessed source Testcase attached. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34160 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/34160] Useful loop invariant motion missing 2007-11-20 12:05 [Bug tree-optimization/34160] New: Useful loop invariant motion missing amonakov at gmail dot com 2007-11-20 12:06 ` [Bug tree-optimization/34160] " amonakov at gmail dot com @ 2007-11-20 15:43 ` rguenth at gcc dot gnu dot org 2009-04-03 12:28 ` rguenth at gcc dot gnu dot org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu dot org @ 2007-11-20 15:43 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from rguenth at gcc dot gnu dot org 2007-11-20 15:43 ------- Alias got in the way here. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Keywords| |alias, missed-optimization http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34160 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/34160] Useful loop invariant motion missing 2007-11-20 12:05 [Bug tree-optimization/34160] New: Useful loop invariant motion missing amonakov at gmail dot com 2007-11-20 12:06 ` [Bug tree-optimization/34160] " amonakov at gmail dot com 2007-11-20 15:43 ` rguenth at gcc dot gnu dot org @ 2009-04-03 12:28 ` rguenth at gcc dot gnu dot org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu dot org @ 2009-04-03 12:28 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from rguenth at gcc dot gnu dot org 2009-04-03 12:27 ------- <bb 10>: # i.21_754 = PHI <i.21_1090(10), 0(9)> # i.21_484 = PHI <i.21_1090(10), 0(9)> D.4090_71 = b[i.21_754]; x[i.21_754] = D.4090_71; D.4345_1088 = (unsigned int) i.21_484; D.4346_1089 = D.4345_1088 + 1; i.21_1090 = (int) D.4346_1089; if (n.17_753 > i.21_1090) goto <bb 10>; else goto <bb 11>; seems to work with 4.4. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Known to fail| |4.3.3 Resolution| |FIXED Target Milestone|--- |4.4.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34160 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-03 12:28 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-11-20 12:05 [Bug tree-optimization/34160] New: Useful loop invariant motion missing amonakov at gmail dot com 2007-11-20 12:06 ` [Bug tree-optimization/34160] " amonakov at gmail dot com 2007-11-20 15:43 ` rguenth at gcc dot gnu dot org 2009-04-03 12:28 ` 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).