aboutsummaryrefslogtreecommitdiff
path: root/gcc/rtlanal.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-09-19 16:04:01 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-09-19 16:04:01 +0000
commit3b10cf4be76c929ba27a62c3dfd70b8017155635 (patch)
tree07f4f7a539e15cea1a65dc0b43285692ada2a516 /gcc/rtlanal.c
parent47d7090eeb4503fa6123cf1089a560b6379bff56 (diff)
downloadgcc-3b10cf4be76c929ba27a62c3dfd70b8017155635.zip
gcc-3b10cf4be76c929ba27a62c3dfd70b8017155635.tar.gz
gcc-3b10cf4be76c929ba27a62c3dfd70b8017155635.tar.bz2
rtl.h (insns_safe_to_move_p): New function.
* rtl.h (insns_safe_to_move_p): New function. * loop.c (find_and_verify_loops): Use it. * rtlanal.c (insns_safe_to_move_p): Define it. From-SVN: r29509
Diffstat (limited to 'gcc/rtlanal.c')
-rw-r--r--gcc/rtlanal.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index d1b2322..b02be3e 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -2293,3 +2293,73 @@ auto_inc_p (x)
}
return 0;
}
+
+/* Return 1 if the sequence of instructions beginning with FROM and up
+ to and including TO is safe to move. If NEW_TO is non-NULL, and
+ the sequence is not already safe to move, but can be easily
+ extended to a sequence which is safe, then NEW_TO will point to the
+ end of the extended sequence. */
+
+int
+insns_safe_to_move_p (from, to, new_to)
+ rtx from;
+ rtx to;
+ rtx *new_to;
+{
+ int eh_region_count = 0;
+ int past_to_p = 0;
+ rtx r = from;
+
+ while (r)
+ {
+ if (GET_CODE (r) == NOTE)
+ {
+ switch (NOTE_LINE_NUMBER (r))
+ {
+ case NOTE_INSN_EH_REGION_BEG:
+ ++eh_region_count;
+ break;
+
+ case NOTE_INSN_EH_REGION_END:
+ if (eh_region_count == 0)
+ /* This sequence of instructions contains the end of
+ an exception region, but not he beginning. Moving
+ it will cause chaos. */
+ return 0;
+
+ --eh_region_count;
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (past_to_p)
+ /* If we've passed TO, and we see a non-note instruction, we
+ can't extend the sequence to a movable sequence. */
+ return 0;
+
+ if (r == to)
+ {
+ if (!new_to)
+ /* It's OK to move the sequence if there were matched sets of
+ exception region notes. */
+ return eh_region_count == 0;
+
+ past_to_p = 1;
+ }
+
+ /* It's OK to move the sequence if there were matched sets of
+ exception region notes. */
+ if (past_to_p && eh_region_count == 0)
+ {
+ *new_to = r;
+ return 1;
+ }
+
+ /* Go to the next instruction. */
+ r = NEXT_INSN (r);
+ }
+
+ return 0;
+}