Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
6786ba1a
Commit
6786ba1a
authored
Nov 16, 2017
by
Jan Hubicka
Committed by
Jan Hubicka
Nov 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* final.c (compute_alignments): Use counts rather than frequencies.
From-SVN: r254809
parent
debc8f4a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
27 deletions
+37
-27
gcc/ChangeLog
+4
-0
gcc/final.c
+33
-27
No files found.
gcc/ChangeLog
View file @
6786ba1a
2017
-
11
-
14
Jan
Hubicka
<
hubicka
@
ucw
.
cz
>
*
final
.
c
(
compute_alignments
):
Use
counts
rather
than
frequencies
.
2017
-
11
-
14
Jan
Hubicka
<
hubicka
@
ucw
.
cz
>
*
cfgloopanal
.
c
:
Include
sreal
.
h
(
average_num_loop_insns
):
Use
counts
and
sreal
for
accounting
.
gcc/final.c
View file @
6786ba1a
...
...
@@ -661,16 +661,13 @@ insn_current_reference_address (rtx_insn *branch)
}
}
/* Compute branch alignments based on frequency information in the
CFG. */
/* Compute branch alignments based on CFG profile. */
unsigned
int
compute_alignments
(
void
)
{
int
log
,
max_skip
,
max_log
;
basic_block
bb
;
int
freq_max
=
0
;
int
freq_threshold
=
0
;
if
(
label_align
)
{
...
...
@@ -693,17 +690,19 @@ compute_alignments (void)
flow_loops_dump
(
dump_file
,
NULL
,
1
);
}
loop_optimizer_init
(
AVOID_CFG_MODIFICATIONS
);
FOR_EACH_BB_FN
(
bb
,
cfun
)
if
(
bb
->
count
.
to_frequency
(
cfun
)
>
freq_max
)
freq_max
=
bb
->
count
.
to_frequency
(
cfun
);
freq_threshold
=
freq_max
/
PARAM_VALUE
(
PARAM_ALIGN_THRESHOLD
);
profile_count
count_threshold
=
cfun
->
cfg
->
count_max
.
apply_scale
(
1
,
PARAM_VALUE
(
PARAM_ALIGN_THRESHOLD
));
if
(
dump_file
)
fprintf
(
dump_file
,
"freq_max: %i
\n
"
,
freq_max
);
{
fprintf
(
dump_file
,
"count_max: "
);
cfun
->
cfg
->
count_max
.
dump
(
dump_file
);
fprintf
(
dump_file
,
"
\n
"
);
}
FOR_EACH_BB_FN
(
bb
,
cfun
)
{
rtx_insn
*
label
=
BB_HEAD
(
bb
);
int
fallthru_frequency
=
0
,
branch_frequency
=
0
,
has_fallthru
=
0
;
bool
has_fallthru
=
0
;
edge
e
;
edge_iterator
ei
;
...
...
@@ -712,35 +711,41 @@ compute_alignments (void)
{
if
(
dump_file
)
fprintf
(
dump_file
,
"BB %4i
freq %4i
loop %2i loop_depth %2i skipped.
\n
"
,
bb
->
index
,
bb
->
count
.
to_frequency
(
cfun
),
"BB %4i loop %2i loop_depth %2i skipped.
\n
"
,
bb
->
index
,
bb
->
loop_father
->
num
,
bb_loop_depth
(
bb
));
continue
;
}
max_log
=
LABEL_ALIGN
(
label
);
max_skip
=
targetm
.
asm_out
.
label_align_max_skip
(
label
);
profile_count
fallthru_count
=
profile_count
::
zero
();
profile_count
branch_count
=
profile_count
::
zero
();
FOR_EACH_EDGE
(
e
,
ei
,
bb
->
preds
)
{
if
(
e
->
flags
&
EDGE_FALLTHRU
)
has_fallthru
=
1
,
fallthru_
frequency
+=
EDGE_FREQUENCY
(
e
);
has_fallthru
=
1
,
fallthru_
count
+=
e
->
count
(
);
else
branch_
frequency
+=
EDGE_FREQUENCY
(
e
);
branch_
count
+=
e
->
count
(
);
}
if
(
dump_file
)
{
fprintf
(
dump_file
,
"BB %4i freq %4i loop %2i loop_depth"
" %2i fall %4i branch %4i"
,
bb
->
index
,
bb
->
count
.
to_frequency
(
cfun
),
bb
->
loop_father
->
num
,
bb_loop_depth
(
bb
),
fallthru_frequency
,
branch_frequency
);
fprintf
(
dump_file
,
"BB %4i loop %2i loop_depth"
" %2i fall "
,
bb
->
index
,
bb
->
loop_father
->
num
,
bb_loop_depth
(
bb
));
fallthru_count
.
dump
(
dump_file
);
fprintf
(
dump_file
,
" branch "
);
branch_count
.
dump
(
dump_file
);
if
(
!
bb
->
loop_father
->
inner
&&
bb
->
loop_father
->
num
)
fprintf
(
dump_file
,
" inner_loop"
);
if
(
bb
->
loop_father
->
header
==
bb
)
fprintf
(
dump_file
,
" loop_header"
);
fprintf
(
dump_file
,
"
\n
"
);
}
if
(
!
fallthru_count
.
initialized_p
()
||
!
branch_count
.
initialized_p
())
continue
;
/* There are two purposes to align block with no fallthru incoming edge:
1) to avoid fetch stalls when branch destination is near cache boundary
...
...
@@ -753,11 +758,11 @@ compute_alignments (void)
when function is called. */
if
(
!
has_fallthru
&&
(
branch_
frequency
>
freq
_threshold
||
(
bb
->
count
.
to_frequency
(
cfun
)
>
bb
->
prev_bb
->
count
.
to_frequency
(
cfun
)
*
10
&&
(
bb
->
prev_bb
->
count
.
to_frequency
(
cfun
)
<=
ENTRY_BLOCK_PTR_FOR_FN
(
cfun
)
->
count
.
to_frequency
(
cfun
)
/
2
))))
&&
(
branch_
count
>
count
_threshold
||
(
bb
->
count
>
bb
->
prev_bb
->
count
.
apply_scale
(
10
,
1
)
&&
(
bb
->
prev_bb
->
count
<=
ENTRY_BLOCK_PTR_FOR_FN
(
cfun
)
->
count
.
apply_scale
(
1
,
2
)
))))
{
log
=
JUMP_ALIGN
(
label
);
if
(
dump_file
)
...
...
@@ -774,9 +779,10 @@ compute_alignments (void)
&&
!
(
single_succ_p
(
bb
)
&&
single_succ
(
bb
)
==
EXIT_BLOCK_PTR_FOR_FN
(
cfun
))
&&
optimize_bb_for_speed_p
(
bb
)
&&
branch_frequency
+
fallthru_frequency
>
freq_threshold
&&
(
branch_frequency
>
fallthru_frequency
*
PARAM_VALUE
(
PARAM_ALIGN_LOOP_ITERATIONS
)))
&&
branch_count
+
fallthru_count
>
count_threshold
&&
(
branch_count
>
fallthru_count
.
apply_scale
(
PARAM_VALUE
(
PARAM_ALIGN_LOOP_ITERATIONS
),
1
)))
{
log
=
LOOP_ALIGN
(
label
);
if
(
dump_file
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment