/* Loop unswitching for GNU compiler.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GCC.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA. */
#include "config.h"
#include "system.h"
#include "tm.h"
#include "rtl.h"
#include "hard-reg-set.h"
+#include "obstack.h"
#include "basic-block.h"
#include "cfgloop.h"
#include "cfglayout.h"
{
/* A hack -- there seems to be no easy generic way how to make a
conditional jump from a ccmode comparison. */
- if (!cinsn)
- abort ();
+ gcc_assert (cinsn);
cond = XEXP (SET_SRC (pc_set (cinsn)), 0);
- if (GET_CODE (cond) != comp
- || !rtx_equal_p (op0, XEXP (cond, 0))
- || !rtx_equal_p (op1, XEXP (cond, 1)))
- abort ();
+ gcc_assert (GET_CODE (cond) == comp);
+ gcc_assert (rtx_equal_p (op0, XEXP (cond, 0)));
+ gcc_assert (rtx_equal_p (op1, XEXP (cond, 1)));
emit_jump_insn (copy_insn (PATTERN (cinsn)));
jump = get_last_insn ();
JUMP_LABEL (jump) = JUMP_LABEL (cinsn);
}
else
{
- if (cinsn)
- abort ();
+ gcc_assert (!cinsn);
op0 = force_operand (op0, NULL_RTX);
op1 = force_operand (op1, NULL_RTX);
if (at != BB_END (bb))
return NULL_RTX;
- *cinsn = BB_END (bb);
if (!rtx_equal_p (op[0], XEXP (test, 0))
|| !rtx_equal_p (op[1], XEXP (test, 1)))
return NULL_RTX;
+ *cinsn = BB_END (bb);
return test;
}
basic_block *bbs;
struct loop *nloop;
unsigned i;
- rtx cond, rcond = NULL_RTX, conds, rconds, acond, cinsn = NULL_RTX;
+ rtx cond, rcond = NULL_RTX, conds, rconds, acond, cinsn;
int repeat;
edge e;
do
{
repeat = 0;
+ cinsn = NULL_RTX;
/* Find a bb to unswitch on. */
bbs = get_loop_body (loop);
/* Unswitch the loop on this condition. */
nloop = unswitch_loop (loops, loop, bbs[i], cond, cinsn);
- if (!nloop)
- abort ();
+ gcc_assert (nloop);
/* Invoke itself on modified loops. */
unswitch_single_loop (loops, nloop, rconds, num + 1);
rtx cond, rtx cinsn)
{
edge entry, latch_edge, true_edge, false_edge, e;
- basic_block switch_bb, unswitch_on_alt, src;
+ basic_block switch_bb, unswitch_on_alt;
struct loop *nloop;
sbitmap zero_bitmap;
int irred_flag, prob;
rtx seq;
/* Some sanity checking. */
- if (!flow_bb_inside_loop_p (loop, unswitch_on))
- abort ();
- if (EDGE_COUNT (unswitch_on->succs) != 2)
- abort ();
- if (!just_once_each_iteration_p (loop, unswitch_on))
- abort ();
- if (loop->inner)
- abort ();
- if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (unswitch_on, 0)->dest))
- abort ();
- if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (unswitch_on, 1)->dest))
- abort ();
+ gcc_assert (flow_bb_inside_loop_p (loop, unswitch_on));
+ gcc_assert (EDGE_COUNT (unswitch_on->succs) == 2);
+ gcc_assert (just_once_each_iteration_p (loop, unswitch_on));
+ gcc_assert (!loop->inner);
+ gcc_assert (flow_bb_inside_loop_p (loop, EDGE_SUCC (unswitch_on, 0)->dest));
+ gcc_assert (flow_bb_inside_loop_p (loop, EDGE_SUCC (unswitch_on, 1)->dest));
entry = loop_preheader_edge (loop);
/* Make a copy. */
- src = entry->src;
irred_flag = entry->flags & EDGE_IRREDUCIBLE_LOOP;
entry->flags &= ~EDGE_IRREDUCIBLE_LOOP;
zero_bitmap = sbitmap_alloc (2);
entry->flags |= irred_flag;
/* Record the block with condition we unswitch on. */
- unswitch_on_alt = unswitch_on->rbi->copy;
+ unswitch_on_alt = get_bb_copy (unswitch_on);
true_edge = BRANCH_EDGE (unswitch_on_alt);
false_edge = FALLTHRU_EDGE (unswitch_on);
- latch_edge = EDGE_SUCC (loop->latch->rbi->copy, 0);
+ latch_edge = single_succ_edge (get_bb_copy (loop->latch));
/* Create a block with the condition. */
prob = true_edge->probability;
/* Loopify from the copy of LOOP body, constructing the new loop. */
nloop = loopify (loops, latch_edge,
- EDGE_PRED (loop->header->rbi->copy, 0), switch_bb, true);
+ single_pred_edge (get_bb_copy (loop->header)), switch_bb,
+ BRANCH_EDGE (switch_bb), FALLTHRU_EDGE (switch_bb), true);
/* Remove branches that are now unreachable in new loops. */
remove_path (loops, true_edge);