comparison gcc/loop-doloop.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Perform doloop optimizations 1 /* Perform doloop optimizations
2 Copyright (C) 2004-2018 Free Software Foundation, Inc. 2 Copyright (C) 2004-2020 Free Software Foundation, Inc.
3 Based on code by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz) 3 Based on code by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz)
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify it under 7 GCC is free software; you can redistribute it and/or modify it under
30 #include "emit-rtl.h" 30 #include "emit-rtl.h"
31 #include "dojump.h" 31 #include "dojump.h"
32 #include "expr.h" 32 #include "expr.h"
33 #include "cfgloop.h" 33 #include "cfgloop.h"
34 #include "cfgrtl.h" 34 #include "cfgrtl.h"
35 #include "params.h"
36 #include "dumpfile.h" 35 #include "dumpfile.h"
37 #include "loop-unroll.h" 36 #include "loop-unroll.h"
38 #include "regs.h" 37 #include "regs.h"
39 #include "df.h" 38 #include "df.h"
40 39
261 /* Return nonzero if the loop specified by LOOP is suitable for 260 /* Return nonzero if the loop specified by LOOP is suitable for
262 the use of special low-overhead looping instructions. DESC 261 the use of special low-overhead looping instructions. DESC
263 describes the number of iterations of the loop. */ 262 describes the number of iterations of the loop. */
264 263
265 static bool 264 static bool
266 doloop_valid_p (struct loop *loop, struct niter_desc *desc) 265 doloop_valid_p (class loop *loop, class niter_desc *desc)
267 { 266 {
268 basic_block *body = get_loop_body (loop), bb; 267 basic_block *body = get_loop_body (loop), bb;
269 rtx_insn *insn; 268 rtx_insn *insn;
270 unsigned i; 269 unsigned i;
271 bool result = true; 270 bool result = true;
403 loop, and DOLOOP_INSN is the low-overhead looping insn to emit at the 402 loop, and DOLOOP_INSN is the low-overhead looping insn to emit at the
404 end of the loop. CONDITION is the condition separated from the 403 end of the loop. CONDITION is the condition separated from the
405 DOLOOP_SEQ. COUNT is the number of iterations of the LOOP. */ 404 DOLOOP_SEQ. COUNT is the number of iterations of the LOOP. */
406 405
407 static void 406 static void
408 doloop_modify (struct loop *loop, struct niter_desc *desc, 407 doloop_modify (class loop *loop, class niter_desc *desc,
409 rtx_insn *doloop_seq, rtx condition, rtx count) 408 rtx_insn *doloop_seq, rtx condition, rtx count)
410 { 409 {
411 rtx counter_reg; 410 rtx counter_reg;
412 rtx tmp, noloop = NULL_RTX; 411 rtx tmp, noloop = NULL_RTX;
413 rtx_insn *sequence; 412 rtx_insn *sequence;
601 conversion to use a low overhead looping instruction, replacing the jump 600 conversion to use a low overhead looping instruction, replacing the jump
602 insn where suitable. Returns true if the loop was successfully 601 insn where suitable. Returns true if the loop was successfully
603 modified. */ 602 modified. */
604 603
605 static bool 604 static bool
606 doloop_optimize (struct loop *loop) 605 doloop_optimize (class loop *loop)
607 { 606 {
608 scalar_int_mode mode; 607 scalar_int_mode mode;
609 rtx doloop_reg; 608 rtx doloop_reg;
610 rtx count; 609 rtx count;
611 widest_int iterations, iterations_max; 610 widest_int iterations, iterations_max;
612 rtx_code_label *start_label; 611 rtx_code_label *start_label;
613 rtx condition; 612 rtx condition;
614 unsigned level; 613 unsigned level;
615 HOST_WIDE_INT est_niter; 614 HOST_WIDE_INT est_niter;
616 int max_cost; 615 int max_cost;
617 struct niter_desc *desc; 616 class niter_desc *desc;
618 unsigned word_mode_size; 617 unsigned word_mode_size;
619 unsigned HOST_WIDE_INT word_mode_max; 618 unsigned HOST_WIDE_INT word_mode_max;
620 int entered_at_top; 619 int entered_at_top;
621 620
622 if (dump_file) 621 if (dump_file)
649 (unsigned int)est_niter); 648 (unsigned int)est_niter);
650 return false; 649 return false;
651 } 650 }
652 651
653 max_cost 652 max_cost
654 = COSTS_N_INSNS (PARAM_VALUE (PARAM_MAX_ITERATIONS_COMPUTATION_COST)); 653 = COSTS_N_INSNS (param_max_iterations_computation_cost);
655 if (set_src_cost (desc->niter_expr, mode, optimize_loop_for_speed_p (loop)) 654 if (set_src_cost (desc->niter_expr, mode, optimize_loop_for_speed_p (loop))
656 > max_cost) 655 > max_cost)
657 { 656 {
658 if (dump_file) 657 if (dump_file)
659 fprintf (dump_file, 658 fprintf (dump_file,
729 is live at the end of the block. */ 728 is live at the end of the block. */
730 { 729 {
731 bitmap modified = BITMAP_ALLOC (NULL); 730 bitmap modified = BITMAP_ALLOC (NULL);
732 731
733 for (rtx_insn *i = doloop_seq; i != NULL; i = NEXT_INSN (i)) 732 for (rtx_insn *i = doloop_seq; i != NULL; i = NEXT_INSN (i))
734 note_stores (PATTERN (i), record_reg_sets, modified); 733 note_stores (i, record_reg_sets, modified);
735 734
736 basic_block loop_end = desc->out_edge->src; 735 basic_block loop_end = desc->out_edge->src;
737 bool fail = bitmap_intersect_p (df_get_live_out (loop_end), modified); 736 bool fail = bitmap_intersect_p (df_get_live_out (loop_end), modified);
738 BITMAP_FREE (modified); 737 BITMAP_FREE (modified);
739 738
752 /* This is the main entry point. Process all loops using doloop_optimize. */ 751 /* This is the main entry point. Process all loops using doloop_optimize. */
753 752
754 void 753 void
755 doloop_optimize_loops (void) 754 doloop_optimize_loops (void)
756 { 755 {
757 struct loop *loop; 756 class loop *loop;
758 757
759 if (optimize == 1) 758 if (optimize == 1)
760 { 759 {
761 df_live_add_problem (); 760 df_live_add_problem ();
762 df_live_set_all_dirty (); 761 df_live_set_all_dirty ();