wingo pushed a commit to branch lightning
in repository guile.
commit 537c85be274a68a2ecaad92943770ca55739161f
Author: pcpa <[email protected]>
Date: Sat Dec 29 18:55:11 2012 -0200
Correct wrong and confusing reverse float comparison logic
* lib/lightning.c: Correct both, wrong and confusing logic
to compute the reverse of a jump. Now it properly matches
C semantics for "eq" (==) and "ne" (!=) and correct computation
of reverse of "uneq" as "gt".
* check/branch.tst: Update "ne" float branch check that
previously happened to be wrongly tested with a NaN argument.
---
ChangeLog | 10 ++++++++++
TODO | 4 ----
check/branch.tst | 2 +-
lib/lightning.c | 58 +++++++++++++++++++++++++++++++-------------------------
4 files changed, 43 insertions(+), 31 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 052afa6..0211dfc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2012-12-29 Paulo Andrade <[email protected]>
+ * lib/lightning.c: Correct both, wrong and confusing logic
+ to compute the reverse of a jump. Now it properly matches
+ C semantics for "eq" (==) and "ne" (!=) and correct computation
+ of reverse of "uneq" as "gt".
+
+ * check/branch.tst: Update "ne" float branch check that
+ previously happened to be wrongly tested with a NaN argument.
+
+2012-12-29 Paulo Andrade <[email protected]>
+
* check/float.ok, check/float.tst: New test cases implementing
extensive validation of float comparison and branch code
generation as well as integer conversion, involving NaN and
diff --git a/TODO b/TODO
index 22d33b4..8cb2657 100644
--- a/TODO
+++ b/TODO
@@ -9,7 +9,3 @@
* Test and correct the ppc and mips ports, after the import and
adaptation of the code to lightning.
-
- * Add new float/double comparison and branch codes:
- unne: proper inverse of eq (nan/nan == 0)
- eqeq: proper inverse of ltgt (nan/nan == 1)
diff --git a/check/branch.tst b/check/branch.tst
index b8ec071..2252dff 100644
--- a/check/branch.tst
+++ b/check/branch.tst
@@ -517,7 +517,7 @@ xnei_f_f0_f1:
BOPF(eq, 3, 3)
BOPF(ge, 3, 3)
BOPF(gt, 4, 3)
- BOPF(ne, 4, 3)
+ UBOPF(ne, 4, 3)
UBOPF(unlt, 1, 2)
UBOPF(unle, 2, 2)
UBOPF(uneq, 3, 3)
diff --git a/lib/lightning.c b/lib/lightning.c
index 4ee202e..853eb22 100644
--- a/lib/lightning.c
+++ b/lib/lightning.c
@@ -1441,12 +1441,6 @@ _thread_jumps(jit_state_t *_jit)
case jit_code_callr: case jit_code_calli:
/* non optimizable jump like code */
break;
- case jit_code_beqr_f: case jit_code_beqi_f:
- case jit_code_beqr_d: case jit_code_beqi_d:
- case jit_code_bltgtr_f: case jit_code_bltgti_f:
- case jit_code_bltgtr_d: case jit_code_bltgti_d:
- /* non optimizable jump code */
- break;
default:
mask = jit_classify(node->code);
if (mask & jit_cc_a0_jmp) {
@@ -1627,30 +1621,34 @@ reverse_jump_code(jit_code_t code)
case jit_code_blti_f: return (jit_code_bungei_f);
case jit_code_bler_f: return (jit_code_bungtr_f);
case jit_code_blei_f: return (jit_code_bungti_f);
-#if 0
- case jit_code_beqr_f: return (jit_code_bltgtr_f);
- case jit_code_beqi_f: return (jit_code_bltgti_f);
-#endif
+
+ case jit_code_beqr_f: return (jit_code_bner_f);
+ case jit_code_beqi_f: return (jit_code_bnei_f);
+
case jit_code_bger_f: return (jit_code_bunltr_f);
case jit_code_bgei_f: return (jit_code_bunlti_f);
case jit_code_bgtr_f: return (jit_code_bunler_f);
case jit_code_bgti_f: return (jit_code_bunlei_f);
- case jit_code_bner_f: return (jit_code_buneqr_f);
- case jit_code_bnei_f: return (jit_code_buneqi_f);
+
+ case jit_code_bner_f: return (jit_code_beqr_f);
+ case jit_code_bnei_f: return (jit_code_beqr_f);
+
case jit_code_bunltr_f: return (jit_code_bger_f);
case jit_code_bunlti_f: return (jit_code_bgei_f);
case jit_code_bunler_f: return (jit_code_bgtr_f);
case jit_code_bunlei_f: return (jit_code_bgti_f);
- case jit_code_buneqr_f: return (jit_code_bgtr_f);
- case jit_code_buneqi_f: return (jit_code_bgti_f);
+
+ case jit_code_buneqr_f: return (jit_code_bltgtr_f);
+ case jit_code_buneqi_f: return (jit_code_bltgti_f);
+
case jit_code_bunger_f: return (jit_code_bltr_f);
case jit_code_bungei_f: return (jit_code_blti_f);
case jit_code_bungtr_f: return (jit_code_bler_f);
case jit_code_bungti_f: return (jit_code_blei_f);
-#if 0
- case jit_code_bltgtr_f: return (jit_code_beqr_f);
- case jit_code_bltgti_f: return (jit_code_beqi_f);
-#endif
+
+ case jit_code_bltgtr_f: return (jit_code_buneqr_f);
+ case jit_code_bltgti_f: return (jit_code_buneqi_f);
+
case jit_code_bordr_f: return (jit_code_bunordr_f);
case jit_code_bordi_f: return (jit_code_bunordi_f);
case jit_code_bunordr_f:return (jit_code_bordr_f);
@@ -1659,26 +1657,34 @@ reverse_jump_code(jit_code_t code)
case jit_code_blti_d: return (jit_code_bungei_d);
case jit_code_bler_d: return (jit_code_bungtr_d);
case jit_code_blei_d: return (jit_code_bungti_d);
- case jit_code_beqr_d: return (jit_code_bltgtr_d);
- case jit_code_beqi_d: return (jit_code_bltgti_d);
+
+ case jit_code_beqr_d: return (jit_code_bner_d);
+ case jit_code_beqi_d: return (jit_code_bner_d);
+
case jit_code_bger_d: return (jit_code_bunltr_d);
case jit_code_bgei_d: return (jit_code_bunlti_d);
case jit_code_bgtr_d: return (jit_code_bunler_d);
case jit_code_bgti_d: return (jit_code_bunlei_d);
- case jit_code_bner_d: return (jit_code_buneqr_d);
- case jit_code_bnei_d: return (jit_code_buneqi_d);
+
+ case jit_code_bner_d: return (jit_code_beqr_d);
+ case jit_code_bnei_d: return (jit_code_beqi_d);
+
case jit_code_bunltr_d: return (jit_code_bger_d);
case jit_code_bunlti_d: return (jit_code_bgei_d);
case jit_code_bunler_d: return (jit_code_bgtr_d);
case jit_code_bunlei_d: return (jit_code_bgti_d);
- case jit_code_buneqr_d: return (jit_code_bgtr_d);
- case jit_code_buneqi_d: return (jit_code_bgti_d);
+
+ case jit_code_buneqr_d: return (jit_code_bltgtr_d);
+ case jit_code_buneqi_d: return (jit_code_bltgti_d);
+
case jit_code_bunger_d: return (jit_code_bltr_d);
case jit_code_bungei_d: return (jit_code_blti_d);
case jit_code_bungtr_d: return (jit_code_bler_d);
case jit_code_bungti_d: return (jit_code_blei_d);
- case jit_code_bltgtr_d: return (jit_code_beqr_d);
- case jit_code_bltgti_d: return (jit_code_beqi_d);
+
+ case jit_code_bltgtr_d: return (jit_code_buneqr_d);
+ case jit_code_bltgti_d: return (jit_code_buneqi_d);
+
case jit_code_bordr_d: return (jit_code_bunordr_d);
case jit_code_bordi_d: return (jit_code_bunordi_d);
case jit_code_bunordr_d:return (jit_code_bordr_d);