Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
3bf4d088
Commit
3bf4d088
authored
Apr 04, 2013
by
yb9976
Browse files
Added peephole optimization for AddCC and SubCC.
parent
6d6ad9f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/be/sparc/sparc_finish.c
View file @
3bf4d088
...
...
@@ -554,6 +554,47 @@ static void finish_sparc_Return(ir_node *node)
}
}
/**
* Check whether the flags of the node are used.
*/
static
bool
has_flags_user
(
ir_node
*
node
)
{
foreach_out_edge
(
node
,
edge
)
{
ir_node
*
src
=
get_edge_src_irn
(
edge
);
if
(
is_Proj
(
src
)
&&
get_Proj_proj
(
src
)
==
pn_sparc_AddCC_flags
)
return
true
;
}
return
false
;
}
/*
* Transform AddCC into Add if flags output is unused.
*/
static
void
peephole_sparc_AddCC
(
ir_node
*
node
)
{
if
(
has_flags_user
(
node
))
return
;
set_irn_op
(
node
,
op_sparc_Add
);
arch_set_irn_register_out
(
node
,
pn_sparc_AddCC_flags
,
NULL
);
}
/*
* Transform SubCC into Sub if flags output is unused.
*/
static
void
peephole_sparc_SubCC
(
ir_node
*
node
)
{
assert
((
int
)
pn_sparc_AddCC_flags
==
(
int
)
pn_sparc_SubCC_flags
);
if
(
has_flags_user
(
node
))
return
;
set_irn_op
(
node
,
op_sparc_Sub
);
arch_set_irn_register_out
(
node
,
pn_sparc_SubCC_flags
,
NULL
);
}
static
void
register_peephole_optimisation
(
ir_op
*
op
,
peephole_opt_func
func
)
{
assert
(
op
->
ops
.
generic
==
NULL
);
...
...
@@ -627,6 +668,8 @@ void sparc_finish_graph(ir_graph *irg)
register_peephole_optimisation
(
op_sparc_RestoreZero
,
peephole_sparc_RestoreZero
);
register_peephole_optimisation
(
op_sparc_Ldf
,
split_sparc_ldf
);
register_peephole_optimisation
(
op_sparc_AddCC
,
peephole_sparc_AddCC
);
register_peephole_optimisation
(
op_sparc_SubCC
,
peephole_sparc_SubCC
);
be_peephole_opt
(
irg
);
/* perform legalizations (mostly fix nodes with too big immediates) */
...
...
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