Floating point branches

View: New views
3 Messages — Rating Filter:   Alert me  

Floating point branches

by Mike Spivey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I encountered three problems with floating point branches on i386 with
the GIT version of lightning.  The patches shown below seem to work for
me, but I haven't made extensive tests.

-- Mike

(i) Instructions beqr_f, ... are not defined, but only beqr_d, ...  On
i386, they are the same, but maybe not on other architectures.
Solution:

#ifndef jit_beqr_f
#define jit_beqr_f(lab, a, b) jit_beqr_d(lab, a, b)
#define jit_bner_f(lab, a, b) jit_bner_d(lab, a, b)
#define jit_bgtr_f(lab, a, b) jit_bgtr_d(lab, a, b)
#define jit_bger_f(lab, a, b) jit_bger_d(lab, a, b)
#define jit_bltr_f(lab, a, b) jit_bltr_d(lab, a, b)
#define jit_bler_f(lab, a, b) jit_bler_d(lab, a, b)
#endif

(ii) The floating point branches depend on the existence of operations
JCm and JNCm that don't exist.  They should be synonyms for JBm and
JNBm.  Solution:

#ifndef JCm
#define JCm JBm
#define JNCm JNBm
#endif

(iii) The macro jit_fp_btest wrongly ends with a call to
res ((d), 0, 0, 0).  This should read res (d).  Solution:

#undef jit_fp_btest

#define jit_fp_btest(d, s1, s2, n, _and, cmp, res)             \
       (((s1) == 0 ? FUCOMr((s2)) : (FLDr((s1)), FUCOMPr((s2) + 1))),    \
        PUSHLr(_EAX),                                          \
        FNSTSWr(_EAX),                                         \
        SHRLir(n, _EAX),                                       \
        ((_and) ? ANDLir ((_and), _EAX) : 0),                  \
        ((cmp) ? CMPLir ((cmp), _AL) : 0),                     \
        POPLr(_EAX),                                           \
        res (d),       \
        _jit.x.pc)



_______________________________________________
Lightning mailing list
Lightning@...
http://lists.gnu.org/mailman/listinfo/lightning

Re: Floating point branches

by Paolo Bonzini-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mike Spivey wrote:
> I encountered three problems with floating point branches on i386 with
> the GIT version of lightning.  The patches shown below seem to work for
> me, but I haven't made extensive tests.

Great, thanks.  I attach what I applied.

Paolo

diff --git a/ChangeLog b/ChangeLog
index bda065e..a842218 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-02-17  Paolo Bonzini  <bonzini@...>
+
+ * lightning/fp-common.h: Define double branches if missing.
+ * lightning/i386/asm.h: Define JC and JNC mnemonics.
+ * lightning/i386/fp-32.h: Fix jit_fp_btest.  All reported
+ by Mike Spivey.
+
 2008-10-09  Paolo Bonzini  <bonzini@...>
 
  * lightning/ppc/funcs.h (jit_flush_code): Subtract 1 from end.
diff --git a/THANKS b/THANKS
index 0276167..fe8ad1e 100644
--- a/THANKS
+++ b/THANKS
@@ -5,6 +5,7 @@ Eli Barzilay                    <eli@...>
 Ludovic Courtes                 <ludo@...>
 Matthew Flatt <mflatt@...>
 Laurent Michel                  <ldm@...>
+Mike Spivey                     <mike@...>
 Basile Starynkevitch            <basile@...>
 Sam Steingold <sds@...>
 Jens Troeger                    <savage@...>
diff --git a/doc/version.texi b/doc/version.texi
index bbcbdc5..a763770 100644
--- a/doc/version.texi
+++ b/doc/version.texi
@@ -1,4 +1,4 @@
-@set UPDATED 9 January 2008
-@set UPDATED-MONTH January 2008
+@set UPDATED 13 June 2008
+@set UPDATED-MONTH June 2008
 @set EDITION 1.2c
 @set VERSION 1.2c
diff --git a/lightning/fp-common.h b/lightning/fp-common.h
index d65d160..0847ceb 100644
--- a/lightning/fp-common.h
+++ b/lightning/fp-common.h
@@ -85,6 +85,23 @@
 #define jit_retval_f(rs) jit_retval_d(rs)
 #endif
 
+#ifndef jit_beqr_f
+#define jit_beqr_f(lab, a, b) jit_beqr_d(lab, a, b)
+#define jit_bner_f(lab, a, b) jit_bner_d(lab, a, b)
+#define jit_bgtr_f(lab, a, b) jit_bgtr_d(lab, a, b)
+#define jit_bger_f(lab, a, b) jit_bger_d(lab, a, b)
+#define jit_bltr_f(lab, a, b) jit_bltr_d(lab, a, b)
+#define jit_bler_f(lab, a, b) jit_bler_d(lab, a, b)
+#define jit_buneqr_f(lab, a, b) jit_buneqr_d(lab, a, b)
+#define jit_bltgtr_f(lab, a, b) jit_bltgtr_d(lab, a, b)
+#define jit_bungtr_f(lab, a, b) jit_bungtr_d(lab, a, b)
+#define jit_bunger_f(lab, a, b) jit_bunger_d(lab, a, b)
+#define jit_bunltr_f(lab, a, b) jit_bunltr_d(lab, a, b)
+#define jit_bunler_f(lab, a, b) jit_bunler_d(lab, a, b)
+#define jit_bordr_f(lab, a, b) jit_bordr_d(lab, a, b)
+#define jit_bunordr_f(lab, a, b) jit_bunordr_d(lab, a, b)
+#endif
+
 #ifndef jit_retval_f
 #define jit_retval_f(op1)            jit_movr_f((op1), JIT_FPRET)
 #endif
diff --git a/lightning/i386/asm.h b/lightning/i386/asm.h
index ad404fc..2dec4b9 100644
--- a/lightning/i386/asm.h
+++ b/lightning/i386/asm.h
@@ -915,8 +915,10 @@ enum {
 #define JOSm(D) JCCSim(0x0, D)
 #define JNOSm(D) JCCSim(0x1, D)
 #define JBSm(D) JCCSim(0x2, D)
+#define JCSm(D) JCCSim(0x2, D)
 #define JNAESm(D) JCCSim(0x2, D)
 #define JNBSm(D) JCCSim(0x3, D)
+#define JNCSm(D) JCCSim(0x3, D)
 #define JAESm(D) JCCSim(0x3, D)
 #define JESm(D) JCCSim(0x4, D)
 #define JZSm(D) JCCSim(0x4, D)
@@ -946,8 +948,10 @@ enum {
 #define JOm(D) JCCim(0x0, D)
 #define JNOm(D) JCCim(0x1, D)
 #define JBm(D) JCCim(0x2, D)
+#define JCm(D) JCCim(0x2, D)
 #define JNAEm(D) JCCim(0x2, D)
 #define JNBm(D) JCCim(0x3, D)
+#define JNCm(D) JCCim(0x3, D)
 #define JAEm(D) JCCim(0x3, D)
 #define JEm(D) JCCim(0x4, D)
 #define JZm(D) JCCim(0x4, D)
diff --git a/lightning/i386/fp-32.h b/lightning/i386/fp-32.h
index ff59631..71e5677 100644
--- a/lightning/i386/fp-32.h
+++ b/lightning/i386/fp-32.h
@@ -261,7 +261,7 @@ union jit_double_imm {
         ((_and) ? ANDLir ((_and), _EAX) : 0),                  \
         ((cmp) ? CMPLir ((cmp), _AL) : 0),                     \
         POPLr(_EAX),                                           \
-        res ((d), 0, 0, 0),       \
+        res ((d)),       \
  _jit.x.ppc)
 
 #define jit_nothing_needed(x)

_______________________________________________
Lightning mailing list
Lightning@...
http://lists.gnu.org/mailman/listinfo/lightning

Re: Floating point branches

by Mike Spivey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paolo Bonzini wrote:
> Mike Spivey wrote:
>> I encountered three problems with floating point branches on i386 with
>> the GIT version of lightning.  The patches shown below seem to work for
>> me, but I haven't made extensive tests.
>
> Great, thanks.  I attach what I applied.
>
> Paolo
>

Sorry, one more correction that you missed in your patch.  In the
jit_fp_btest macro:

diff --git a/lightning/i386/fp-32.h b/lightning/i386/fp-32.h
index 71e5677..b957b69 100644
--- a/lightning/i386/fp-32.h
+++ b/lightning/i386/fp-32.h
@@ -262,7 +262,7 @@ union jit_double_imm {
         ((cmp) ? CMPLir ((cmp), _AL) : 0),                     \
         POPLr(_EAX),                                           \
         res ((d)),       \
- _jit.x.ppc)
+ _jit.x.pc)

 #define jit_nothing_needed(x)

-- Mike


_______________________________________________
Lightning mailing list
Lightning@...
http://lists.gnu.org/mailman/listinfo/lightning