X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=gcc%2Fhw-doloop.c;h=fe031257179a90eb6ce832d425ad3e705aa9a654;hb=7adcbafe45f8001b698967defe682687b52c0007;hp=b6184a26d87f3e9333c1411c3ec358bfd42602af;hpb=11cd3bed28f13a1a0254d00c4b4d799d08cc266c;p=thirdparty%2Fgcc.git diff --git a/gcc/hw-doloop.c b/gcc/hw-doloop.c index b6184a26d87f..fe031257179a 100644 --- a/gcc/hw-doloop.c +++ b/gcc/hw-doloop.c @@ -1,6 +1,6 @@ /* Code to analyze doloop loops in order for targets to perform late optimizations converting doloops to other forms of hardware loops. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2022 Free Software Foundation, Inc. This file is part of GCC. @@ -21,23 +21,18 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" -#include "tm.h" +#include "backend.h" #include "rtl.h" -#include "flags.h" -#include "expr.h" -#include "hard-reg-set.h" -#include "regs.h" -#include "basic-block.h" -#include "tm_p.h" #include "df.h" -#include "cfgloop.h" +#include "insn-config.h" +#include "regs.h" +#include "memmodel.h" +#include "emit-rtl.h" #include "recog.h" -#include "target.h" +#include "cfgrtl.h" #include "hw-doloop.h" #include "dumpfile.h" -#ifdef HAVE_doloop_end - /* Dump information collected in LOOPS. */ static void dump_hwloops (hwloop_info loops) @@ -94,7 +89,7 @@ scan_loop (hwloop_info loop) for (ix = 0; loop->blocks.iterate (ix, &bb); ix++) { - rtx insn; + rtx_insn *insn; edge e; edge_iterator ei; @@ -119,7 +114,7 @@ scan_loop (hwloop_info loop) insn != NEXT_INSN (BB_END (bb)); insn = NEXT_INSN (insn)) { - df_ref *def_rec; + df_ref def; HARD_REG_SET set_this_insn; if (!NONDEBUG_INSN_P (insn)) @@ -131,9 +126,9 @@ scan_loop (hwloop_info loop) loop->has_asm = true; CLEAR_HARD_REG_SET (set_this_insn); - for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++) + FOR_EACH_INSN_DEF (def, insn) { - rtx dreg = DF_REF_REG (*def_rec); + rtx dreg = DF_REF_REG (def); if (!REG_P (dreg)) continue; @@ -146,7 +141,7 @@ scan_loop (hwloop_info loop) CLEAR_HARD_REG_BIT (set_this_insn, REGNO (loop->iter_reg)); else if (reg_mentioned_p (loop->iter_reg, PATTERN (insn))) loop->iter_reg_used = true; - IOR_HARD_REG_SET (loop->regs_set_in_loop, set_this_insn); + loop->regs_set_in_loop |= set_this_insn; } } } @@ -232,7 +227,7 @@ add_forwarder_blocks (hwloop_info loop) the expected use; targets that call into this code usually replace the loop counter with a different special register. */ static void -discover_loop (hwloop_info loop, basic_block tail_bb, rtx tail_insn, rtx reg) +discover_loop (hwloop_info loop, basic_block tail_bb, rtx_insn *tail_insn, rtx reg) { bool found_tail; unsigned dwork = 0; @@ -242,7 +237,7 @@ discover_loop (hwloop_info loop, basic_block tail_bb, rtx tail_insn, rtx reg) loop->loop_end = tail_insn; loop->iter_reg = reg; vec_alloc (loop->incoming, 2); - loop->start_label = JUMP_LABEL (tail_insn); + loop->start_label = as_a (JUMP_LABEL (tail_insn)); if (EDGE_COUNT (tail_bb->succs) != 2) { @@ -252,7 +247,7 @@ discover_loop (hwloop_info loop, basic_block tail_bb, rtx tail_insn, rtx reg) loop->head = BRANCH_EDGE (tail_bb)->dest; loop->successor = FALLTHRU_EDGE (tail_bb)->dest; - stack_vec works; + auto_vec works; works.safe_push (loop->head); found_tail = false; @@ -359,8 +354,9 @@ discover_loops (bitmap_obstack *loop_stack, struct hw_doloop_hooks *hooks) structure and add the head block to the work list. */ FOR_EACH_BB_FN (bb, cfun) { - rtx tail = BB_END (bb); - rtx insn, reg; + rtx_insn *tail = BB_END (bb); + rtx_insn *insn; + rtx reg; while (tail && NOTE_P (tail) && tail != BB_HEAD (bb)) tail = PREV_INSN (tail); @@ -378,7 +374,7 @@ discover_loops (bitmap_obstack *loop_stack, struct hw_doloop_hooks *hooks) /* There's a degenerate case we can handle - an empty loop consisting of only a back branch. Handle that by deleting the branch. */ - insn = JUMP_LABEL (tail); + insn = JUMP_LABEL_AS_INSN (tail); while (insn && !NONDEBUG_INSN_P (insn)) insn = NEXT_INSN (insn); if (insn == tail) @@ -585,7 +581,7 @@ optimize_loop (hwloop_info loop, struct hw_doloop_hooks *hooks) inner_depth = inner->depth; /* The set of registers may be changed while optimizing the inner loop. */ - IOR_HARD_REG_SET (loop->regs_set_in_loop, inner->regs_set_in_loop); + loop->regs_set_in_loop |= inner->regs_set_in_loop; } loop->depth = inner_depth + 1; @@ -636,7 +632,9 @@ reorg_loops (bool do_reorder, struct hw_doloop_hooks *hooks) loops = discover_loops (&loop_stack, hooks); - if (do_reorder) + /* We can't enter cfglayout mode anymore if basic block partitioning + already happened. */ + if (do_reorder && !crtl->has_bb_partition) { reorder_loops (loops); free_loops (loops); @@ -661,8 +659,8 @@ reorg_loops (bool do_reorder, struct hw_doloop_hooks *hooks) } free_loops (loops); + bitmap_obstack_release (&loop_stack); if (dump_file) print_rtl (dump_file, get_insns ()); } -#endif