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]

teach simplify_rtx to simplify unordered compares


Hi
The simplify-rtx is not knowind about unordered comparisons.  I am now
emitting them early that effectivly disables any chance to optimize
out the fp conditionals.

I am not IEEE expert, but hope that this code does what expected.

Honza

Thu Jan  4 21:50:23 MET 2001  Jan Hubicka  <jh@suse.cz>
	* simplify-rtx.c (cfc_args): add "unordered" field.
	(check_fold_consts): Set unordered field.
	(simplify_relational_operation): Simplify the unordered
	comparisons.

*** simplify-rtx.c.old	Wed Aug  9 23:00:29 2000
--- simplify-rtx.c	Wed Aug  9 23:38:35 2000
*************** struct cfc_args
*** 1676,1681 ****
--- 1676,1682 ----
  {
    rtx op0, op1;			/* Input */
    int equal, op0lt, op1lt;	/* Output */
+   int unordered;
  };
  
  static void
*************** check_fold_consts (data)
*** 1685,1692 ****
--- 1686,1700 ----
    struct cfc_args *args = (struct cfc_args *) data;
    REAL_VALUE_TYPE d0, d1;
  
+   args->unordered = 1;
+ 
    REAL_VALUE_FROM_CONST_DOUBLE (d0, args->op0);
    REAL_VALUE_FROM_CONST_DOUBLE (d1, args->op1);
+   if (REAL_VALUE_ISNAN (d0)
+       || REAL_VALUE_ISNAN (d1))
+     args->unordered = 1;
+   else
+     args->unordered = 0;
    args->equal = REAL_VALUES_EQUAL (d0, d1);
    args->op0lt = REAL_VALUES_LESS (d0, d1);
    args->op1lt = REAL_VALUES_LESS (d1, d0);
*************** simplify_relational_operation (code, mod
*** 1772,1780 ****
        args.op0 = op0;
        args.op1 = op1;
        
!       if (do_float_handler(check_fold_consts, (PTR) &args) == 0)
! 	/* We got an exception from check_fold_consts() */
! 	return 0;
  
        /* Receive output from check_fold_consts() */
        equal = args.equal;
--- 1780,1809 ----
        args.op0 = op0;
        args.op1 = op1;
        
!       do_float_handler(check_fold_consts, (PTR) &args);
! 
!       if (args.unordered)
! 	switch (code)
! 	  {
! 	  case UNEQ:
! 	  case UNLT:
! 	  case UNGT:
! 	  case UNLE:
! 	  case UNGE:
! 	  case NE:
! 	  case UNORDERED:
! 	    return const_true_rtx;
! 	  case EQ:
! 	  case LT:
! 	  case GT:
! 	  case LE:
! 	  case GE:
! 	  case LTGT:
! 	  case ORDERED:
! 	    return const0_rtx;
! 	  default:
! 	    return 0;
! 	  }
  
        /* Receive output from check_fold_consts() */
        equal = args.equal;
*************** simplify_relational_operation (code, mod
*** 1905,1916 ****
--- 1934,1949 ----
    switch (code)
      {
      case EQ:
+     case UNEQ:
        return equal ? const_true_rtx : const0_rtx;
      case NE:
+     case LTGT:
        return ! equal ? const_true_rtx : const0_rtx;
      case LT:
+     case UNLT:
        return op0lt ? const_true_rtx : const0_rtx;
      case GT:
+     case UNGT:
        return op1lt ? const_true_rtx : const0_rtx;
      case LTU:
        return op0ltu ? const_true_rtx : const0_rtx;
*************** simplify_relational_operation (code, mod
*** 1924,1929 ****
--- 1957,1966 ----
        return equal || op0ltu ? const_true_rtx : const0_rtx;
      case GEU:
        return equal || op1ltu ? const_true_rtx : const0_rtx;
+     case ORDERED:
+       return const_true_rtx;
+     case UNORDERED:
+       return const0_rtx;
      default:
        abort ();
      }

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