26 |
26 |
27 // Optimization - Graph Style |
27 // Optimization - Graph Style |
28 |
28 |
29 #include "incls/_precompiled.incl" |
29 #include "incls/_precompiled.incl" |
30 #include "incls/_gcm.cpp.incl" |
30 #include "incls/_gcm.cpp.incl" |
|
31 |
|
32 // To avoid float value underflow |
|
33 #define MIN_BLOCK_FREQUENCY 1.e-35f |
31 |
34 |
32 //----------------------------schedule_node_into_block------------------------- |
35 //----------------------------schedule_node_into_block------------------------- |
33 // Insert node n into block b. Look for projections of n and make sure they |
36 // Insert node n into block b. Look for projections of n and make sure they |
34 // are in b also. |
37 // are in b also. |
35 void PhaseCFG::schedule_node_into_block( Node *n, Block *b ) { |
38 void PhaseCFG::schedule_node_into_block( Node *n, Block *b ) { |
1875 // Do a top down traversal of loop tree (visit outer loops first.) |
1885 // Do a top down traversal of loop tree (visit outer loops first.) |
1876 void CFGLoop::scale_freq() { |
1886 void CFGLoop::scale_freq() { |
1877 float loop_freq = _freq * trip_count(); |
1887 float loop_freq = _freq * trip_count(); |
1878 for (int i = 0; i < _members.length(); i++) { |
1888 for (int i = 0; i < _members.length(); i++) { |
1879 CFGElement* s = _members.at(i); |
1889 CFGElement* s = _members.at(i); |
1880 s->_freq *= loop_freq; |
1890 float block_freq = s->_freq * loop_freq; |
|
1891 if (block_freq < MIN_BLOCK_FREQUENCY) block_freq = MIN_BLOCK_FREQUENCY; |
|
1892 s->_freq = block_freq; |
1881 } |
1893 } |
1882 CFGLoop* ch = _child; |
1894 CFGLoop* ch = _child; |
1883 while (ch != NULL) { |
1895 while (ch != NULL) { |
1884 ch->scale_freq(); |
1896 ch->scale_freq(); |
1885 ch = ch->_sibling; |
1897 ch = ch->_sibling; |