comparison gcc/modulo-sched.c @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children 1830386684a0
comparison
equal deleted inserted replaced
130:e108057fa461 132:d34655255c78
1 /* Swing Modulo Scheduling implementation. 1 /* Swing Modulo Scheduling implementation.
2 Copyright (C) 2004-2017 Free Software Foundation, Inc. 2 Copyright (C) 2004-2018 Free Software Foundation, Inc.
3 Contributed by Ayal Zaks and Mustafa Hagog <zaks,mustafa@il.ibm.com> 3 Contributed by Ayal Zaks and Mustafa Hagog <zaks,mustafa@il.ibm.com>
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
685 int distances[2]; 685 int distances[2];
686 sbitmap distance1_uses; 686 sbitmap distance1_uses;
687 rtx set = single_set (u->insn); 687 rtx set = single_set (u->insn);
688 688
689 /* Skip instructions that do not set a register. */ 689 /* Skip instructions that do not set a register. */
690 if ((set && !REG_P (SET_DEST (set)))) 690 if (set && !REG_P (SET_DEST (set)))
691 continue; 691 continue;
692 692
693 /* Compute the number of reg_moves needed for u, by looking at life 693 /* Compute the number of reg_moves needed for u, by looking at life
694 ranges started at u (excluding self-loops). */ 694 ranges started at u (excluding self-loops). */
695 distances[0] = distances[1] = false; 695 distances[0] = distances[1] = false;
696 for (e = u->out; e; e = e->next_out) 696 for (e = u->out; e; e = e->next_out)
697 if (e->type == TRUE_DEP && e->dest != e->src) 697 if (e->type == TRUE_DEP && e->dest != e->src)
741 741
742 /* Record the moves associated with this node. */ 742 /* Record the moves associated with this node. */
743 first_move += ps->g->num_nodes; 743 first_move += ps->g->num_nodes;
744 744
745 /* Generate each move. */ 745 /* Generate each move. */
746 old_reg = prev_reg = SET_DEST (single_set (u->insn)); 746 old_reg = prev_reg = SET_DEST (set);
747 if (HARD_REGISTER_P (old_reg))
748 return false;
749
747 for (i_reg_move = 0; i_reg_move < nreg_moves; i_reg_move++) 750 for (i_reg_move = 0; i_reg_move < nreg_moves; i_reg_move++)
748 { 751 {
749 ps_reg_move_info *move = ps_reg_move (ps, first_move + i_reg_move); 752 ps_reg_move_info *move = ps_reg_move (ps, first_move + i_reg_move);
750 753
751 move->def = i_reg_move > 0 ? first_move + i_reg_move - 1 : i; 754 move->def = i_reg_move > 0 ? first_move + i_reg_move - 1 : i;
1344 partial_schedule_ptr ps; 1347 partial_schedule_ptr ps;
1345 basic_block bb = NULL; 1348 basic_block bb = NULL;
1346 struct loop *loop; 1349 struct loop *loop;
1347 basic_block condition_bb = NULL; 1350 basic_block condition_bb = NULL;
1348 edge latch_edge; 1351 edge latch_edge;
1349 gcov_type trip_count = 0; 1352 HOST_WIDE_INT trip_count, max_trip_count;
1350 1353
1351 loop_optimizer_init (LOOPS_HAVE_PREHEADERS 1354 loop_optimizer_init (LOOPS_HAVE_PREHEADERS
1352 | LOOPS_HAVE_RECORDED_EXITS); 1355 | LOOPS_HAVE_RECORDED_EXITS);
1353 if (number_of_loops (cfun) <= 1) 1356 if (number_of_loops (cfun) <= 1)
1354 { 1357 {
1420 bb = loop->header; 1423 bb = loop->header;
1421 1424
1422 get_ebb_head_tail (bb, bb, &head, &tail); 1425 get_ebb_head_tail (bb, bb, &head, &tail);
1423 latch_edge = loop_latch_edge (loop); 1426 latch_edge = loop_latch_edge (loop);
1424 gcc_assert (single_exit (loop)); 1427 gcc_assert (single_exit (loop));
1425 if (single_exit (loop)->count () > profile_count::zero ()) 1428 trip_count = get_estimated_loop_iterations_int (loop);
1426 trip_count = latch_edge->count ().to_gcov_type () 1429 max_trip_count = get_max_loop_iterations_int (loop);
1427 / single_exit (loop)->count ().to_gcov_type ();
1428 1430
1429 /* Perform SMS only on loops that their average count is above threshold. */ 1431 /* Perform SMS only on loops that their average count is above threshold. */
1430 1432
1431 if ( latch_edge->count () > profile_count::zero () 1433 if ( latch_edge->count () > profile_count::zero ()
1432 && (latch_edge->count() 1434 && (latch_edge->count()
1442 fprintf (dump_file, "SMS loop-count "); 1444 fprintf (dump_file, "SMS loop-count ");
1443 fprintf (dump_file, "%" PRId64, 1445 fprintf (dump_file, "%" PRId64,
1444 (int64_t) bb->count.to_gcov_type ()); 1446 (int64_t) bb->count.to_gcov_type ());
1445 fprintf (dump_file, "\n"); 1447 fprintf (dump_file, "\n");
1446 fprintf (dump_file, "SMS trip-count "); 1448 fprintf (dump_file, "SMS trip-count ");
1447 fprintf (dump_file, "%" PRId64, 1449 fprintf (dump_file, "%" PRId64 "max %" PRId64,
1448 (int64_t) trip_count); 1450 (int64_t) trip_count, (int64_t) max_trip_count);
1449 fprintf (dump_file, "\n"); 1451 fprintf (dump_file, "\n");
1450 fprintf (dump_file, "SMS profile-sum-max ");
1451 fprintf (dump_file, "%" PRId64,
1452 (int64_t) profile_info->sum_max);
1453 fprintf (dump_file, "\n");
1454 } 1452 }
1455 } 1453 }
1456 continue; 1454 continue;
1457 } 1455 }
1458 1456
1550 1548
1551 get_ebb_head_tail (loop->header, loop->header, &head, &tail); 1549 get_ebb_head_tail (loop->header, loop->header, &head, &tail);
1552 1550
1553 latch_edge = loop_latch_edge (loop); 1551 latch_edge = loop_latch_edge (loop);
1554 gcc_assert (single_exit (loop)); 1552 gcc_assert (single_exit (loop));
1555 if (single_exit (loop)->count ()> profile_count::zero ()) 1553 trip_count = get_estimated_loop_iterations_int (loop);
1556 trip_count = latch_edge->count ().to_gcov_type () 1554 max_trip_count = get_max_loop_iterations_int (loop);
1557 / single_exit (loop)->count ().to_gcov_type ();
1558 1555
1559 if (dump_file) 1556 if (dump_file)
1560 { 1557 {
1561 dump_insn_location (tail); 1558 dump_insn_location (tail);
1562 fprintf (dump_file, "\nSMS single-bb-loop\n"); 1559 fprintf (dump_file, "\nSMS single-bb-loop\n");
1563 if (profile_info && flag_branch_probabilities) 1560 if (profile_info && flag_branch_probabilities)
1564 { 1561 {
1565 fprintf (dump_file, "SMS loop-count "); 1562 fprintf (dump_file, "SMS loop-count ");
1566 fprintf (dump_file, "%" PRId64, 1563 fprintf (dump_file, "%" PRId64,
1567 (int64_t) bb->count.to_gcov_type ()); 1564 (int64_t) bb->count.to_gcov_type ());
1568 fprintf (dump_file, "\n");
1569 fprintf (dump_file, "SMS profile-sum-max ");
1570 fprintf (dump_file, "%" PRId64,
1571 (int64_t) profile_info->sum_max);
1572 fprintf (dump_file, "\n"); 1565 fprintf (dump_file, "\n");
1573 } 1566 }
1574 fprintf (dump_file, "SMS doloop\n"); 1567 fprintf (dump_file, "SMS doloop\n");
1575 fprintf (dump_file, "SMS built-ddg %d\n", g->num_nodes); 1568 fprintf (dump_file, "SMS built-ddg %d\n", g->num_nodes);
1576 fprintf (dump_file, "SMS num-loads %d\n", g->num_loads); 1569 fprintf (dump_file, "SMS num-loads %d\n", g->num_loads);
1646 /* The default value of PARAM_SMS_MIN_SC is 2 as stage count of 1639 /* The default value of PARAM_SMS_MIN_SC is 2 as stage count of
1647 1 means that there is no interleaving between iterations thus 1640 1 means that there is no interleaving between iterations thus
1648 we let the scheduling passes do the job in this case. */ 1641 we let the scheduling passes do the job in this case. */
1649 if (stage_count < PARAM_VALUE (PARAM_SMS_MIN_SC) 1642 if (stage_count < PARAM_VALUE (PARAM_SMS_MIN_SC)
1650 || (count_init && (loop_count <= stage_count)) 1643 || (count_init && (loop_count <= stage_count))
1651 || (flag_branch_probabilities && (trip_count <= stage_count))) 1644 || (max_trip_count >= 0 && max_trip_count <= stage_count)
1645 || (trip_count >= 0 && trip_count <= stage_count))
1652 { 1646 {
1653 if (dump_file) 1647 if (dump_file)
1654 { 1648 {
1655 fprintf (dump_file, "SMS failed... \n"); 1649 fprintf (dump_file, "SMS failed... \n");
1656 fprintf (dump_file, "SMS sched-failed (stage-count=%d," 1650 fprintf (dump_file, "SMS sched-failed (stage-count=%d,"
1657 " loop-count=", stage_count); 1651 " loop-count=", stage_count);
1658 fprintf (dump_file, "%" PRId64, loop_count); 1652 fprintf (dump_file, "%" PRId64, loop_count);
1659 fprintf (dump_file, ", trip-count="); 1653 fprintf (dump_file, ", trip-count=");
1660 fprintf (dump_file, "%" PRId64, trip_count); 1654 fprintf (dump_file, "%" PRId64 "max %" PRId64,
1655 (int64_t) trip_count, (int64_t) max_trip_count);
1661 fprintf (dump_file, ")\n"); 1656 fprintf (dump_file, ")\n");
1662 } 1657 }
1663 break; 1658 break;
1664 } 1659 }
1665 1660