diff --git a/tccgen.c b/tccgen.c
index af4ea899..c582c4ad 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -2461,7 +2461,7 @@ void gen_negf(int op)
 /* generate a floating point operation with constant propagation */
 static void gen_opif(int op)
 {
-    int c1, c2;
+    int c1, c2, cast_int = 0;
     SValue *v1, *v2;
 #if defined _MSC_VER && defined __x86_64__
     /* avoid bad optimization with f1 -= f2 for f1:-0.0, f2:0.0 */
@@ -2519,6 +2519,26 @@ static void gen_opif(int op)
         case TOK_NEG:
             f1 = -f1;
             goto unary_result;
+        case TOK_EQ:
+            f1 = f1 == f2;
+	make_int:
+	    cast_int = 1;
+            break;
+        case TOK_NE:
+            f1 = f1 != f2;
+	    goto make_int;
+        case TOK_LT:
+            f1 = f1 < f2;
+	    goto make_int;
+        case TOK_GE:
+            f1 = f1 >= f2;
+	    goto make_int;
+        case TOK_LE:
+            f1 = f1 <= f2;
+	    goto make_int;
+        case TOK_GT:
+            f1 = f1 > f2;
+	    goto make_int;
             /* XXX: also handles tests ? */
         default:
             goto general_case;
@@ -2533,6 +2553,8 @@ static void gen_opif(int op)
         } else {
             v1->c.ld = f1;
         }
+	if (cast_int)
+	    gen_cast_s(VT_INT);
     } else {
     general_case:
         if (op == TOK_NEG) {
diff --git a/tests/tests2/22_floating_point.c b/tests/tests2/22_floating_point.c
index 2eb062c3..5dc7b746 100644
--- a/tests/tests2/22_floating_point.c
+++ b/tests/tests2/22_floating_point.c
@@ -16,6 +16,12 @@ test()
 
 int main()
 {
+   static int e1 = -1.0 == 0.0;
+   static int e2 = -1.0 != 0.0;
+   static int e3 = -1.0 < 0.0;
+   static int e4 = -1.0 >= 0.0;
+   static int e5 = -1.0 <= 0.0;
+   static int e6 = -1.0 > 0.0;
    // variables
    float a = 12.34 + 56.78;
    printf("%f\n", a);
@@ -30,6 +36,7 @@ int main()
    printf("%d %d %d %d %d %d\n", 12.34 < 56.78, 12.34 <= 56.78, 12.34 == 56.78, 12.34 >= 56.78, 12.34 > 56.78, 12.34 != 56.78);
    printf("%d %d %d %d %d %d\n", 12.34 < 12.34, 12.34 <= 12.34, 12.34 == 12.34, 12.34 >= 12.34, 12.34 > 12.34, 12.34 != 12.34);
    printf("%d %d %d %d %d %d\n", 56.78 < 12.34, 56.78 <= 12.34, 56.78 == 12.34, 56.78 >= 12.34, 56.78 > 12.34, 56.78 != 12.34);
+   printf("%d %d %d %d %d %d\n", e1, e2, e3, e4, e5, e6);
 
    // assignment operators
    a = 12.34;
diff --git a/tests/tests2/22_floating_point.expect b/tests/tests2/22_floating_point.expect
index 75ea3a7e..a989eca1 100644
--- a/tests/tests2/22_floating_point.expect
+++ b/tests/tests2/22_floating_point.expect
@@ -6,6 +6,7 @@
 1 1 0 0 0 1
 0 1 1 1 0 0
 0 0 0 1 1 1
+0 1 1 0 1 0
 69.120003
 -44.439999
 700.665222