aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/simplify.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-29 17:04:45 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-09-01 22:53:30 +0200
commit2da84a231ad09cc7ec5b1c8caa9174ef3d6b957a (patch)
treeea0853ccf2deda52c3a29de510f02183e4295591 /simplify.c
parentef6862deb6e85766f12818ba474c3a122cb2b49a (diff)
downloadsparse-dev-2da84a231ad09cc7ec5b1c8caa9174ef3d6b957a.tar.gz
trivial-phi: use a temp var for the real source
By design, all operands of a phi-node are defined by a OP_PHISRC. So, this phi-source need to be dereferenced to get the real source. Since this value is used in several tests, use a temoparary variable for it. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'simplify.c')
-rw-r--r--simplify.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/simplify.c b/simplify.c
index 5413e1dd..9a2f6c50 100644
--- a/simplify.c
+++ b/simplify.c
@@ -191,16 +191,21 @@ static int trivial_phi(pseudo_t *pseudo, struct instruction *insn)
same = 1;
FOR_EACH_PTR(insn->phi_list, phi) {
struct instruction *def;
+ pseudo_t src;
+
if (phi == VOID)
continue;
def = phi->def;
- if (def->phi_src == VOID || !def->bb)
+ if (!def->bb)
+ continue;
+ src = def->phi_src; // bypass OP_PHISRC & get the real source
+ if (src == VOID)
continue;
if (!last) {
last = def;
continue;
}
- if (last->phi_src == def->phi_src)
+ if (last->phi_src == src)
continue;
return 0;
} END_FOR_EACH_PTR(phi);