aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir/simpl.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-01-11 11:44:22 +0100
committerlemon <lsof@mailbox.org>2026-01-11 11:44:22 +0100
commitc024799bd6c38d79d34a0b103d1b26f21b0345b1 (patch)
tree2c9e7680c28b4efd51eab0283947ce4fc1b9eb04 /ir/simpl.c
parentd42a6b1a5d14f1d1d0d19b222e3b0ce11d009c4e (diff)
simpl: fix simplifying known cond branches
Diffstat (limited to 'ir/simpl.c')
-rw-r--r--ir/simpl.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/ir/simpl.c b/ir/simpl.c
index 2b3870c..c52f809 100644
--- a/ir/simpl.c
+++ b/ir/simpl.c
@@ -260,22 +260,17 @@ simpl(struct function *fn)
inschange += ins(&instrtab[blk->ins.p[curi]], blk, &curi);
}
-#if 0 // FIXME
if (blk->s2 && isintcon(blk->jmp.arg[0])) {
/* simplify known conditional branch */
struct block *s = intconval(blk->jmp.arg[0]) ? blk->s1 : blk->s2;
- delpred(blk->s2, blk);
- if (blk->s2->npred == 0) {
- freeblk(fn, blk->s2);
- }
+ delpred(s == blk->s1 ? blk->s2 : blk->s1, blk);
blk->s1 = s, blk->s2 = NULL;
blk->jmp.arg[0] = NOREF;
- while (blk->s1 && !blk->s2 && blk->s1->npred == 1 && blk->s1->phi.n == 0) {
+ if (blk->s1 && !blk->s2 && blk->s1->npred == 1 && blk->s1->phi.n == 0) {
mergeblks(fn, blk, blk->s1);
+ goto DoIns;
}
- goto DoIns;
}
-#endif
/* thread jumps.. */
if (!blk->phi.n && !blk->ins.n) {