From: Mike Stump <mikestump@comcast.net>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: fix up hot/cold partitioning on ports that don't have long conditional branches
Date: Fri, 22 Apr 2011 22:54:00 -0000 [thread overview]
Message-ID: <25BE4659-21B4-4662-9AFA-211522A29F60@comcast.net> (raw)
In-Reply-To: <201104221228.12111.ebotcazou@adacore.com>
[-- Attachment #1: Type: text/plain, Size: 858 bytes --]
On Apr 22, 2011, at 3:28 AM, Eric Botcazou wrote:
>> This patch fixes up hot/cold partitioning on ports that don't have long
>> conditional branches. I'll note that the entire file has lots of other
>> jump optimizations that are suspect.
>
> Do you have a testcase for one of the ports in the tree?
Nope. Found via an out of tree port with tree-prof.exp=pr34999.c.
> Note that parameters of function must be documented in the head comment.
Fixed.
> The patch contains long lines.
Didn't know we had switched over to caring that much. Want me to fix all of gcc/*.[ch]?
> The ChangeLog entry doesn't look correct (relax_delay_slots mentioned
> twice, no mention of the new parameter of follow_jumps, etc).
Fixed.
> How was the patch tested?
make check-gcc.
> Please generate patches with diff -p.
Done.
Ok?
[-- Attachment #2: reorg-cold-jumps.diffs.txt --]
[-- Type: text/plain, Size: 3807 bytes --]
2011-04-21 Mike Stump <mikestump@comcast.net>
* reorg.c (relax_delay_slots): Don't delete a jump that
crosses a section boundary. Pass insn to follow_jumps.
(follow_jumps): Add jump parameter. Don't replace a short
conditional jump with a long conditional jump when the port
doesn't have long conditional jumps.
(fill_slots_from_thread): Pass insn to follow_jumps.
Index: reorg.c
===================================================================
--- reorg.c (revision 1301)
+++ reorg.c (working copy)
@@ -2501,15 +2501,18 @@ fill_simple_delay_slots (int non_jumps_p
#endif
}
\f
-/* Follow any unconditional jump at LABEL;
- return the ultimate label reached by any such chain of jumps.
- Return null if the chain ultimately leads to a return instruction.
- If LABEL is not followed by a jump, return LABEL.
- If the chain loops or we can't find end, return LABEL,
- since that tells caller to avoid changing the insn. */
+/* Follow any unconditional jump at LABEL; return the ultimate label
+ reached by any such chain of jumps. Return null if the chain
+ ultimately leads to a return instruction. If LABEL is not followed
+ by a jump, return LABEL. If the chain loops or we can't find end,
+ return LABEL, since that tells caller to avoid changing the insn.
+ If the chain of jumps ever crosses a section boundary, and the port
+ doesn't have long condition branches and the JUMP that we are
+ performing this analysis for was a conditional branch, return the
+ first such label before any such crossing. */
static rtx
-follow_jumps (rtx label)
+follow_jumps (rtx label, rtx jump)
{
rtx insn;
rtx next;
@@ -2529,6 +2532,16 @@ follow_jumps (rtx label)
{
rtx tem;
+ /* If a label crosses a section boundary and we're thinking
+ about changing a conditional jump to be a conditional jump
+ across that boundary, don't do it if the port doesn't have
+ long conditional branches. We can however jump to the label
+ just before we cross such a boundary. */
+ if (!HAS_LONG_COND_BRANCH
+ && find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)
+ && any_condjump_p (jump))
+ return value;
+
/* If we have found a cycle, make the insn jump to itself. */
if (JUMP_LABEL (insn) == label)
return label;
@@ -2991,7 +3004,7 @@ fill_slots_from_thread (rtx insn, rtx co
&& redirect_with_delay_list_safe_p (insn,
JUMP_LABEL (new_thread),
delay_list))
- new_thread = follow_jumps (JUMP_LABEL (new_thread));
+ new_thread = follow_jumps (JUMP_LABEL (new_thread), new_thread);
if (new_thread == 0)
label = find_end_label ();
@@ -3342,12 +3355,14 @@ relax_delay_slots (rtx first)
&& (condjump_p (insn) || condjump_in_parallel_p (insn))
&& (target_label = JUMP_LABEL (insn)) != 0)
{
- target_label = skip_consecutive_labels (follow_jumps (target_label));
+ target_label = skip_consecutive_labels (follow_jumps (target_label,
+ insn));
if (target_label == 0)
target_label = find_end_label ();
if (target_label && next_active_insn (target_label) == next
- && ! condjump_in_parallel_p (insn))
+ && ! condjump_in_parallel_p (insn)
+ && find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX) == NULL_RTX)
{
delete_jump (insn);
continue;
@@ -3492,7 +3507,8 @@ relax_delay_slots (rtx first)
{
/* If this jump goes to another unconditional jump, thread it, but
don't convert a jump into a RETURN here. */
- trial = skip_consecutive_labels (follow_jumps (target_label));
+ trial = skip_consecutive_labels (follow_jumps (target_label,
+ delay_insn));
if (trial == 0)
trial = find_end_label ();
next prev parent reply other threads:[~2011-04-22 22:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-22 2:54 Mike Stump
2011-04-22 13:23 ` Eric Botcazou
2011-04-22 22:54 ` Mike Stump [this message]
2011-04-27 14:56 ` Mike Stump
2011-05-09 10:34 ` Eric Botcazou
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=25BE4659-21B4-4662-9AFA-211522A29F60@comcast.net \
--to=mikestump@comcast.net \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@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: link
Be 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).