aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-11 11:37:19 +0100
committerlemon <lsof@mailbox.org>2026-03-11 11:37:19 +0100
commit1f3ebe69478f245f69cd6f77db946226557085d2 (patch)
treeedb5ec23153d7f769de4ab318847248399a4bdf2 /test
parent1529b5221389c75371d0f3f181957a77a158a53c (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 'test')
-rw-r--r--test/12-flt.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/12-flt.c b/test/12-flt.c
index 36f4e90..5077026 100644
--- a/test/12-flt.c
+++ b/test/12-flt.c
@@ -40,6 +40,11 @@ double nummod(double a, double b) {
return m;
}
+double branch(double a) {
+ if (a + 1.1) return 0.0;
+ return -a;
+}
+
int main() {
NAN/=0.0;
assert(_(1.0) < _(2.0));