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
c3e2e1ea
Commit
c3e2e1ea
authored
Aug 29, 2012
by
Matthias Braun
Browse files
ldstopt: don't count keepalives as users
parent
db56911d
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/opt/ldstopt.c
View file @
c3e2e1ea
...
...
@@ -165,9 +165,6 @@ static unsigned update_exc(ldst_info_t *info, ir_node *block, int pos)
return
0
;
}
/* update_exc */
/** Return the number of uses of an address node */
#define get_irn_n_uses(adr) get_irn_n_edges(adr)
/**
* walker, collects all Load/Store/Proj nodes
*
...
...
@@ -1046,7 +1043,7 @@ static unsigned optimize_load(ir_node *load)
/* Check, if the address of this load is used more than once.
* If not, more load cannot be removed in any case. */
if
(
get_irn_n_
us
es
(
ptr
)
<=
1
&&
get_irn_n_
us
es
(
get_base_and_offset
(
ptr
,
&
dummy
))
<=
1
)
if
(
get_irn_n_
edg
es
(
ptr
)
<=
1
&&
get_irn_n_
edg
es
(
get_base_and_offset
(
ptr
,
&
dummy
))
<=
1
)
return
res
;
/*
...
...
@@ -1278,7 +1275,7 @@ static unsigned optimize_store(ir_node *store)
/* Check, if the address of this Store is used more than once.
* If not, this Store cannot be removed in any case. */
if
(
get_irn_n_
us
es
(
ptr
)
<=
1
)
if
(
get_irn_n_
edg
es
(
ptr
)
<=
1
)
return
0
;
mem
=
get_Store_mem
(
store
);
...
...
@@ -1289,6 +1286,22 @@ static unsigned optimize_store(ir_node *store)
return
follow_Mem_chain_for_Store
(
store
,
skip_Proj
(
mem
));
}
/* optimize_store */
/* check if a node has more than one real user. Keepalive edges do not count as
* real users */
static
bool
has_multiple_users
(
const
ir_node
*
node
)
{
unsigned
real_users
=
0
;
foreach_out_edge
(
node
,
edge
)
{
ir_node
*
user
=
get_edge_src_irn
(
edge
);
if
(
is_End
(
user
))
continue
;
++
real_users
;
if
(
real_users
>
1
)
return
true
;
}
return
false
;
}
/**
* walker, optimizes Phi after Stores to identical places:
* Does the following optimization:
...
...
@@ -1333,7 +1346,7 @@ static unsigned optimize_phi(ir_node *phi, walk_env_t *wenv)
/* must be only one user */
projM
=
get_Phi_pred
(
phi
,
0
);
if
(
get_irn_n_edge
s
(
projM
)
!=
1
)
if
(
has_multiple_user
s
(
projM
))
return
0
;
store
=
skip_Proj
(
projM
);
...
...
@@ -1364,7 +1377,7 @@ static unsigned optimize_phi(ir_node *phi, walk_env_t *wenv)
for
(
i
=
1
;
i
<
n
;
++
i
)
{
ir_node
*
pred
=
get_Phi_pred
(
phi
,
i
);
if
(
get_irn_n_edge
s
(
pred
)
!=
1
)
if
(
has_multiple_user
s
(
pred
))
return
0
;
pred
=
skip_Proj
(
pred
);
...
...
@@ -1492,7 +1505,7 @@ static int optimize_conv_load(ir_node *conv)
ir_node
*
op
=
get_Conv_op
(
conv
);
if
(
!
is_Proj
(
op
))
return
0
;
if
(
get_irn_n_edge
s
(
op
)
>
1
)
if
(
has_multiple_user
s
(
op
))
return
0
;
/* shrink mode of load if possible. */
ir_node
*
load
=
get_Proj_pred
(
op
);
...
...
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