summaryrefslogtreecommitdiff
path: root/gcc/loop-doloop.c
diff options
context:
space:
mode:
authorrevitale <revitale@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-28 06:52:16 +0000
committerrevitale <revitale@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-28 06:52:16 +0000
commit7bfc9b7cc90d5fc45847f176852078b1ddd504b1 (patch)
treebc3b2739b170fd0d12aa9aeb627ced2e462e8b9d /gcc/loop-doloop.c
parent3eae2dbf2fea429c07dd5d25a183193faf303175 (diff)
downloadgcc-7bfc9b7cc90d5fc45847f176852078b1ddd504b1.tar.gz
Modulo-scheduling improvements. Patch 2 of 2
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127848 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop-doloop.c')
-rw-r--r--gcc/loop-doloop.c82
1 files changed, 63 insertions, 19 deletions
diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c
index 162ef4ad58a..6e33a4f9ba0 100644
--- a/gcc/loop-doloop.c
+++ b/gcc/loop-doloop.c
@@ -69,35 +69,59 @@ along with GCC; see the file COPYING3. If not see
if it is not a decrement and branch jump insn. */
rtx
-doloop_condition_get (rtx pattern)
+doloop_condition_get (rtx doloop_pat)
{
rtx cmp;
rtx inc;
rtx reg;
rtx inc_src;
rtx condition;
+ rtx pattern;
- /* The canonical doloop pattern we expect is:
+ /* The canonical doloop pattern we expect has one of the following
+ forms:
- (parallel [(set (pc) (if_then_else (condition)
- (label_ref (label))
- (pc)))
- (set (reg) (plus (reg) (const_int -1)))
- (additional clobbers and uses)])
+ 1) (parallel [(set (pc) (if_then_else (condition)
+ (label_ref (label))
+ (pc)))
+ (set (reg) (plus (reg) (const_int -1)))
+ (additional clobbers and uses)])
- Some targets (IA-64) wrap the set of the loop counter in
- an if_then_else too.
+ The branch must be the first entry of the parallel (also required
+ by jump.c), and the second entry of the parallel must be a set of
+ the loop counter register. Some targets (IA-64) wrap the set of
+ the loop counter in an if_then_else too.
- In summary, the branch must be the first entry of the
- parallel (also required by jump.c), and the second
- entry of the parallel must be a set of the loop counter
- register. */
+ 2) (set (reg) (plus (reg) (const_int -1))
+ (set (pc) (if_then_else (reg != 0)
+ (label_ref (label))
+ (pc))). */
+
+ pattern = PATTERN (doloop_pat);
if (GET_CODE (pattern) != PARALLEL)
- return 0;
+ {
+ rtx cond;
+
+ /* We expect the decrement to immediately precede the branch. */
- cmp = XVECEXP (pattern, 0, 0);
- inc = XVECEXP (pattern, 0, 1);
+ if ((PREV_INSN (doloop_pat) == NULL_RTX)
+ || !INSN_P (PREV_INSN (doloop_pat)))
+ return 0;
+
+ cmp = pattern;
+ inc = PATTERN (PREV_INSN (doloop_pat));
+ /* We expect the condition to be of the form (reg != 0) */
+ cond = XEXP (SET_SRC (cmp), 0);
+ if (GET_CODE (cond) != NE || XEXP (cond, 1) != const0_rtx)
+ return 0;
+
+ }
+ else
+ {
+ cmp = XVECEXP (pattern, 0, 0);
+ inc = XVECEXP (pattern, 0, 1);
+ }
/* Check for (set (reg) (something)). */
if (GET_CODE (inc) != SET)
@@ -139,7 +163,29 @@ doloop_condition_get (rtx pattern)
if ((XEXP (condition, 0) == reg)
|| (GET_CODE (XEXP (condition, 0)) == PLUS
&& XEXP (XEXP (condition, 0), 0) == reg))
+ {
+ if (GET_CODE (pattern) != PARALLEL)
+ /* The second form we expect:
+
+ (set (reg) (plus (reg) (const_int -1))
+ (set (pc) (if_then_else (reg != 0)
+ (label_ref (label))
+ (pc))).
+
+ is equivalent to the following:
+
+ (parallel [(set (pc) (if_then_else (reg != 1)
+ (label_ref (label))
+ (pc)))
+ (set (reg) (plus (reg) (const_int -1)))
+ (additional clobbers and uses)])
+
+ So we return that form instead.
+ */
+ condition = gen_rtx_fmt_ee (NE, VOIDmode, inc_src, const1_rtx);
+
return condition;
+ }
/* ??? If a machine uses a funny comparison, we could return a
canonicalized form here. */
@@ -597,9 +643,7 @@ doloop_optimize (struct loop *loop)
{
while (NEXT_INSN (doloop_pat) != NULL_RTX)
doloop_pat = NEXT_INSN (doloop_pat);
- if (JUMP_P (doloop_pat))
- doloop_pat = PATTERN (doloop_pat);
- else
+ if (!JUMP_P (doloop_pat))
doloop_pat = NULL_RTX;
}