diff options
| author | 2026-03-11 11:37:19 +0100 | |
|---|---|---|
| committer | 2026-03-11 11:37:19 +0100 | |
| commit | 1f3ebe69478f245f69cd6f77db946226557085d2 (patch) | |
| tree | edb5ec23153d7f769de4ab318847248399a4bdf2 /x86_64 | |
| parent | 1529b5221389c75371d0f3f181957a77a158a53c (diff) | |
x86_64/isel: fix edge case with branch on float add result
In `if (x + 1)` the implicit `!= 0` can be omitted for integers, because
the x86 `add` instruction sets the zero flag accordingly. But for floats
it doesn't, so applying that optimization there was wrong. Luckily it
was caught by a nullptr dereference later in `emit::Xjcc()` for the
(missing) unordered branch target, instead of miscompiling.
Diffstat (limited to 'x86_64')
| -rw-r--r-- | x86_64/isel.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/x86_64/isel.c b/x86_64/isel.c index 3a753e6..ded1a52 100644 --- a/x86_64/isel.c +++ b/x86_64/isel.c @@ -577,7 +577,7 @@ seljmp(struct function *fn, struct block *blk) && (oiscmp(instrtab[c.i].op) || instrtab[c.i].op == Oand || instrtab[c.i].op == Osub)) { instrtab[c.i].keep = 1; } else { - if (!(opflags[instrtab[c.i].op] & ZF) || blk->ins.n == 0 || c.i != blk->ins.p[blk->ins.n - 1]) { + if (kisflt(instrtab[c.i].cls) || !(opflags[instrtab[c.i].op] & ZF) || blk->ins.n == 0 || c.i != blk->ins.p[blk->ins.n - 1]) { struct instr *ins; int curi = blk->ins.n; blk->jmp.arg[0] = insertinstr(blk, blk->ins.n, mkinstr(Oneq, insrescls(instrtab[c.i]), c, ZEROREF)); |