Skip to content

Commit

Permalink
extract nbr_users() from unssa.c
Browse files Browse the repository at this point in the history
This small helper was used in unssa.c but is useful elsewhere too.

Move it as an inline function to linearize.h and rename it to
'nbr_users()' since it is close to the existing 'has_users()'.

Signed-off-by: Luc Van Oostenryck <[email protected]>
  • Loading branch information
lucvoo committed Jul 23, 2018
1 parent 68e6728 commit 90cc270
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 5 additions & 0 deletions linearize.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ static inline int has_users(pseudo_t p)
return pseudo_user_list_size(p->users) != 0;
}

static inline int nbr_users(pseudo_t p)
{
return pseudo_user_list_size(p->users);
}

static inline struct pseudo_user *alloc_pseudo_user(struct instruction *insn, pseudo_t *pp)
{
struct pseudo_user *user = __alloc_pseudo_user(0);
Expand Down
2 changes: 1 addition & 1 deletion simplify.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ static int simplify_associative_binop(struct instruction *insn)
return 0;
if (!simple_pseudo(def->src2))
return 0;
if (pseudo_user_list_size(def->target->users) != 1)
if (nbr_users(def->target) != 1)
return 0;
switch_pseudo(def, &def->src1, insn, &insn->src2);
return REPEAT_CSE;
Expand Down
7 changes: 1 addition & 6 deletions unssa.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
#include <assert.h>


static inline int nbr_pseudo_users(pseudo_t p)
{
return ptr_list_size((struct ptr_list *)p->users);
}

static int simplify_phi_node(struct instruction *phi, pseudo_t tmp)
{
pseudo_t target = phi->target;
Expand Down Expand Up @@ -95,7 +90,7 @@ static void replace_phi_node(struct instruction *phi)
src = def->phi_src;
if (src->type != PSEUDO_REG)
continue;
switch (nbr_pseudo_users(src)) {
switch (nbr_users(src)) {
struct instruction *insn;
case 1:
insn = src->def;
Expand Down

0 comments on commit 90cc270

Please sign in to comment.