This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

i386 floating point conditional move patch


Hello,

This change corrects i386 float point conditional moves.

ChangeLog:

Wed Jun  3 23:41:24 EDT 1998  John Wehle  (john@feith.com)

	* i386.md (movsfcc, movdfcc, movxfcc): The floating point
	conditional move instructions don't support signed integer
	comparisons.

Notes:

  1) Without this change the following program prints the wrong answer.

     #include <stdio.h>
     #include <stdlib.h>

     int a = 1;
     int b = -1;

     int c = 1;
     int d = 0;

     main ()
       {
       double e;
       double f;
       double g;

       f = c;
       g = d;
       e = (a < b) ? f : g;
       printf("%d < %d = %g\n", a, b, e);
       exit(0);
       }

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/config/i386/i386.md.ORIGINAL	Thu May 28 01:08:21 1998
--- gcc/config/i386/i386.md	Wed Jun  3 23:34:48 1998
***************
*** 7451,7456 ****
--- 7451,7473 ----
    if (GET_MODE_CLASS (GET_MODE (i386_compare_op0)) != MODE_INT)
      FAIL;
  
+   /* The floating point conditional move instructions don't support
+      signed integer comparisons. */
+ 
+   switch (GET_CODE (operands[1]))
+     {
+     case LT:
+     case LE:
+     case GE:
+     case GT:
+       FAIL;
+     /* NOTREACHED */
+       break;
+ 
+     default:
+       break;
+     }
+ 
    operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
  			GET_MODE (i386_compare_op0),
  			i386_compare_op0, i386_compare_op1);
***************
*** 7553,7558 ****
--- 7570,7592 ----
    if (GET_MODE_CLASS (GET_MODE (i386_compare_op0)) != MODE_INT)
      FAIL;
  
+   /* The floating point conditional move instructions don't support
+      signed integer comparisons. */
+ 
+   switch (GET_CODE (operands[1]))
+     {
+     case LT:
+     case LE:
+     case GE:
+     case GT:
+       FAIL;
+     /* NOTREACHED */
+       break;
+ 
+     default:
+       break;
+     }
+ 
    operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
  			GET_MODE (i386_compare_op0),
  			i386_compare_op0, i386_compare_op1);
***************
*** 7654,7659 ****
--- 7688,7710 ----
  {
    if (GET_MODE_CLASS (GET_MODE (i386_compare_op0)) != MODE_INT)
      FAIL;
+ 
+   /* The floating point conditional move instructions don't support
+      signed integer comparisons. */
+ 
+   switch (GET_CODE (operands[1]))
+     {
+     case LT:
+     case LE:
+     case GE:
+     case GT:
+       FAIL;
+     /* NOTREACHED */
+       break;
+ 
+     default:
+       break;
+     }
  
    operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
  			GET_MODE (i386_compare_op0),
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]