aboutsummaryrefslogtreecommitdiff
path: root/gcc/final.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1996-04-16 08:53:07 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1996-04-16 08:53:07 -0400
commit30f5e9f517eee66f7b18b804bfedd3e120457e7c (patch)
treeeb1f039e38582db96b5040549b3b8f269eb41c25 /gcc/final.c
parentb089937ac0257754ccc1eb0e9c9c88e4b77f610c (diff)
downloadgcc-30f5e9f517eee66f7b18b804bfedd3e120457e7c.zip
gcc-30f5e9f517eee66f7b18b804bfedd3e120457e7c.tar.gz
gcc-30f5e9f517eee66f7b18b804bfedd3e120457e7c.tar.bz2
(final_scan_insn): Allow removal of redundant test and compare
instructions that use clobbers. From-SVN: r11806
Diffstat (limited to 'gcc/final.c')
-rw-r--r--gcc/final.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/gcc/final.c b/gcc/final.c
index 882850f..70aa819 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -1756,35 +1756,39 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
and the next statement should reexamine the variable
to compute the condition codes. */
- if (optimize
- && GET_CODE (body) == SET
- && GET_CODE (SET_DEST (body)) == CC0
- && insn != last_ignored_compare)
+ if (optimize)
{
- if (GET_CODE (SET_SRC (body)) == SUBREG)
- SET_SRC (body) = alter_subreg (SET_SRC (body));
- else if (GET_CODE (SET_SRC (body)) == COMPARE)
- {
- if (GET_CODE (XEXP (SET_SRC (body), 0)) == SUBREG)
- XEXP (SET_SRC (body), 0)
- = alter_subreg (XEXP (SET_SRC (body), 0));
- if (GET_CODE (XEXP (SET_SRC (body), 1)) == SUBREG)
- XEXP (SET_SRC (body), 1)
- = alter_subreg (XEXP (SET_SRC (body), 1));
- }
- if ((cc_status.value1 != 0
- && rtx_equal_p (SET_SRC (body), cc_status.value1))
- || (cc_status.value2 != 0
- && rtx_equal_p (SET_SRC (body), cc_status.value2)))
+ rtx set = single_set(insn);
+
+ if (set
+ && GET_CODE (SET_DEST (set)) == CC0
+ && insn != last_ignored_compare)
{
- /* Don't delete insn if it has an addressing side-effect. */
- if (! FIND_REG_INC_NOTE (insn, 0)
- /* or if anything in it is volatile. */
- && ! volatile_refs_p (PATTERN (insn)))
+ if (GET_CODE (SET_SRC (set)) == SUBREG)
+ SET_SRC (set) = alter_subreg (SET_SRC (set));
+ else if (GET_CODE (SET_SRC (set)) == COMPARE)
{
- /* We don't really delete the insn; just ignore it. */
- last_ignored_compare = insn;
- break;
+ if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
+ XEXP (SET_SRC (set), 0)
+ = alter_subreg (XEXP (SET_SRC (set), 0));
+ if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
+ XEXP (SET_SRC (set), 1)
+ = alter_subreg (XEXP (SET_SRC (set), 1));
+ }
+ if ((cc_status.value1 != 0
+ && rtx_equal_p (SET_SRC (set), cc_status.value1))
+ || (cc_status.value2 != 0
+ && rtx_equal_p (SET_SRC (set), cc_status.value2)))
+ {
+ /* Don't delete insn if it has an addressing side-effect. */
+ if (! FIND_REG_INC_NOTE (insn, 0)
+ /* or if anything in it is volatile. */
+ && ! volatile_refs_p (PATTERN (insn)))
+ {
+ /* We don't really delete the insn; just ignore it. */
+ last_ignored_compare = insn;
+ break;
+ }
}
}
}