aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/simplify.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-03-29 18:42:50 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-03-19 23:56:44 +0100
commitffa92f53257da38844e9f6f7ffbd71a777c6e54c (patch)
treeb00120716b9392e1865d8ee4e4ff445ec73406b5 /simplify.c
parent1331214c003027c7b8af0af9bb9d8e040f8e3b4e (diff)
downloadsparse-dev-ffa92f53257da38844e9f6f7ffbd71a777c6e54c.tar.gz
let insert_branch() return a status
insert_branch() modifies the CFG and the usage of pseudos so these changes must be, in a way or another, notify to the upper layers. Currently this is done by setting 'repeat_phase' in the function itself. Let this function to also report the changes via its return value since this is usually useful for the caller to know and tend to leaner code too. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'simplify.c')
-rw-r--r--simplify.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/simplify.c b/simplify.c
index 930c0fa7..0bc201e8 100644
--- a/simplify.c
+++ b/simplify.c
@@ -2440,10 +2440,8 @@ static int simplify_branch(struct instruction *insn)
pseudo_t cond = insn->cond;
/* Constant conditional */
- if (constant(cond)) {
- insert_branch(insn, cond->value ? insn->bb_true : insn->bb_false);
- return REPEAT_CSE;
- }
+ if (constant(cond))
+ return insert_branch(insn, cond->value ? insn->bb_true : insn->bb_false);
/* Same target? */
if (insn->bb_true == insn->bb_false) {
@@ -2472,14 +2470,10 @@ static int simplify_branch(struct instruction *insn)
if (constant(def->src2) && constant(def->src3)) {
long long val1 = def->src2->value;
long long val2 = def->src3->value;
- if (!val1 && !val2) {
- insert_branch(insn, insn->bb_false);
- return REPEAT_CSE;
- }
- if (val1 && val2) {
- insert_branch(insn, insn->bb_true);
- return REPEAT_CSE;
- }
+ if (!val1 && !val2)
+ return insert_branch(insn, insn->bb_false);
+ if (val1 && val2)
+ return insert_branch(insn, insn->bb_true);
if (val2) {
struct basic_block *tmp = insn->bb_true;
insn->bb_true = insn->bb_false;
@@ -2515,8 +2509,7 @@ static int simplify_switch(struct instruction *insn)
return 0;
found:
- insert_branch(insn, jmp->target);
- return REPEAT_CSE;
+ return insert_branch(insn, jmp->target);
}
static struct basic_block *is_label(pseudo_t pseudo)