summaryrefslogtreecommitdiff
path: root/gcc/loop.c
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-06 18:27:35 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-06 18:27:35 +0000
commite9350468d1b00050bfbb74850a3c97e711b92a16 (patch)
tree1284532d79574aa97537f07b98681c409f9ae900 /gcc/loop.c
parentd92fe3e03f4db0125d343d785d7d323fb1ddade6 (diff)
downloadgcc-e9350468d1b00050bfbb74850a3c97e711b92a16.tar.gz
PR rtl-optimization/16380
* loop.c (check_dbra_loop): Sink comparison instructions if they do something other than set cc0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84161 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop.c')
-rw-r--r--gcc/loop.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/loop.c b/gcc/loop.c
index 17955b49dea..e0af19dd45e 100644
--- a/gcc/loop.c
+++ b/gcc/loop.c
@@ -8284,6 +8284,7 @@ check_dbra_loop (struct loop *loop, int insn_count)
enum rtx_code cmp_code;
int comparison_const_width;
unsigned HOST_WIDE_INT comparison_sign_mask;
+ bool keep_first_compare;
add_val = INTVAL (bl->biv->add_val);
comparison_value = XEXP (comparison, 1);
@@ -8476,13 +8477,26 @@ check_dbra_loop (struct loop *loop, int insn_count)
not delete the label. */
LABEL_NUSES (XEXP (jump_label, 0))++;
+ /* If we have a separate comparison insn that does more
+ than just set cc0, the result of the comparison might
+ be used outside the loop. */
+ keep_first_compare = (compare_and_branch == 2
+#ifdef HAVE_CC0
+ && sets_cc0_p (first_compare) <= 0
+#endif
+ );
+
/* Emit an insn after the end of the loop to set the biv's
proper exit value if it is used anywhere outside the loop. */
- if ((REGNO_LAST_UID (bl->regno) != INSN_UID (first_compare))
+ if (keep_first_compare
+ || (REGNO_LAST_UID (bl->regno) != INSN_UID (first_compare))
|| ! bl->init_insn
|| REGNO_FIRST_UID (bl->regno) != INSN_UID (bl->init_insn))
loop_insn_sink (loop, gen_load_of_final_value (reg, final_value));
+ if (keep_first_compare)
+ loop_insn_sink (loop, PATTERN (first_compare));
+
/* Delete compare/branch at end of loop. */
delete_related_insns (PREV_INSN (loop_end));
if (compare_and_branch == 2)