Bug 24814 - unrolling doesn't put loop notes in right place
Summary: unrolling doesn't put loop notes in right place
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-11 20:56 UTC by Jorn Wolfgang Rennecke
Modified: 2006-04-24 22:34 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test case (242 bytes, text/plain)
2005-11-11 20:59 UTC, Jorn Wolfgang Rennecke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jorn Wolfgang Rennecke 2005-11-11 20:56:42 UTC
 
Comment 1 Jorn Wolfgang Rennecke 2005-11-11 20:59:43 UTC
Created attachment 10221 [details]
test case

When compiling this test case with -O2 -funroll-loops for i686 or sh-elf, the NOTE_INSN_LOOP_BEG and NOTE_INSN_LOOP_END notes end up adjacent before the loop,
as can be seen in the .23.loop2_done dump file.
Comment 2 Andrew Pinski 2005-11-11 21:05:41 UTC
LOOP NOTES should be removed in 4.2 when loop.c is removed.
Comment 3 Jorn Wolfgang Rennecke 2005-11-11 21:44:11 UTC
(In reply to comment #2)
> LOOP NOTES should be removed in 4.2 when loop.c is removed.
> 

There is more than loop.c which currently uses LOOP NOTES.
Comment 4 Steven Bosscher 2006-02-27 14:04:08 UTC
Actually there is nothing that uses LOOP_NOTEs other than the old RTL loop optimizer.  At least, nothing that _should_ use it.  Wanna know about loops?  Find natural loops instead of depending on the notes.

But the point is moot, the old RTL loop optimizer is no more.
Comment 5 Jorn Wolfgang Rennecke 2006-03-07 20:52:16 UTC
(In reply to comment #4)
> Actually there is nothing that uses LOOP_NOTEs other than the old RTL loop
> optimizer.  At least, nothing that _should_ use it.  Wanna know about loops? 
> Find natural loops instead of depending on the notes.

So you are saying I should put natural loop detection into the SH backend so
that it can decide if it should save all target registers?

Note that the branch probability estimation machinery does not set estimated
execution counts, so the execution counts are unusable without profile data.
 
> But the point is moot, the old RTL loop optimizer is no more.

It had its weaknesses, but at least it was well-tuned for a wide range of target architectures and operated generally well together with the rest of the compiler.  What we have now is a collection of passes that often work at
cross-purposes.  E.g. web, loop strength reduction/unrolling and
auto-increment generation are completely out of sync.
Comment 6 Daniel Berlin 2006-03-07 21:50:30 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > Actually there is nothing that uses LOOP_NOTEs other than the old RTL loop
> > optimizer.  At least, nothing that _should_ use it.  Wanna know about loops? 
> > Find natural loops instead of depending on the notes.
> 
> So you are saying I should put natural loop detection into the SH backend so
> that it can decide if it should save all target registers?
> 
Yes, if you need to detect loops, call the routine to detect natural loops.
This is the way of the future.
LOOP_NOTES are not.

I agree that this bug should be marked WONTFIX.

> It had its weaknesses, but at least it was well-tuned for a wide range of
> target architectures and operated generally well together with the rest of the
> compiler.  What we have now is a collection of passes that often work at
> cross-purposes.  E.g. web, loop strength reduction/unrolling and
> auto-increment generation are completely out of sync.

Completely irrelevant to this bug.

> 

Comment 7 Jorn Wolfgang Rennecke 2006-03-07 22:42:56 UTC
(In reply to comment #6)
> Yes, if you need to detect loops, call the routine to detect natural loops.
> This is the way of the future.
> LOOP_NOTES are not.

Is flow_loops_find and the data that it initailizes a stable interface, and
can it be safely called from prologue/epilogue generation?
I see no mention of this function in the files in doc/ ; the loop notes
are documented there, though.
Comment 8 Steven Bosscher 2006-04-24 22:34:20 UTC
What are loop notes again?  Ah, yes.  Legacy.  Fixed on mainline.