gofast.h (GOFAST_RENAME_LIBCALLS): Set gt and ge as NULL_RTX.
authorAlexandre Oliva <aoliva@redhat.com>
Fri, 8 Mar 2002 02:57:13 +0000 (02:57 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Fri, 8 Mar 2002 02:57:13 +0000 (02:57 +0000)
* config/gofast.h (GOFAST_RENAME_LIBCALLS): Set gt and ge as
NULL_RTX.  Set all HFmode operations as NULL_RTX.
* optabs.c (prepare_float_lib_cmp) <GT, GE, LT, LE>: If libfunc is
NULL_RTX, try reversing the comparison and the operands.

From-SVN: r50422

gcc/ChangeLog
gcc/config/gofast.h
gcc/optabs.c

index ea31da8016b7983c33f3f6ca9c0944af6042d818..fa565f77dbdfa86c02ddc284daabcdfd9a8a8822 100644 (file)
@@ -1,3 +1,10 @@
+2002-03-07  Alexandre Oliva  <aoliva@redhat.com>
+
+       * config/gofast.h (GOFAST_RENAME_LIBCALLS): Set gt and ge as
+       NULL_RTX.  Set all HFmode operations as NULL_RTX.
+       * optabs.c (prepare_float_lib_cmp) <GT, GE, LT, LE>: If libfunc is
+       NULL_RTX, try reversing the comparison and the operands.
+
 2002-03-06  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * genextract.c (walk_rtx): Recurse into MATCH_PAR_DUP.
index 4c3c0ea9ae8cd9bcae21895c4fa96b77ceb94e8d..84e9018784f81a82260761917cc04a3b87759082 100644 (file)
@@ -1,5 +1,5 @@
 /* US Software GOFAST floating point library support.
-   Copyright (C) 1994, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1998, 1999, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -43,6 +43,11 @@ Boston, MA 02111-1307, USA.  */
       neg_optab->handlers[(int) mode].libfunc = NULL_RTX; \
   } while (0)
 
+/* GCC does not use fpcmp/dpcmp for gt or ge because its own
+   FP-emulation library returns +1 for both > and unord.  So we leave
+   gt and ge unset, such that, instead of fpcmp(a,b) >[=], we generate
+   fpcmp(b,a) <[=] 0, which is unambiguous.  For unord libfuncs, we
+   use our own functions, since GOFAST doesn't supply them.  */
 #define GOFAST_RENAME_LIBCALLS \
   add_optab->handlers[(int) SFmode].libfunc = init_one_libfunc ("fpadd"); \
   add_optab->handlers[(int) DFmode].libfunc = init_one_libfunc ("dpadd"); \
@@ -57,18 +62,25 @@ Boston, MA 02111-1307, USA.  */
 \
   extendsfdf2_libfunc = init_one_libfunc ("fptodp"); \
   truncdfsf2_libfunc = init_one_libfunc ("dptofp"); \
+\
+  eqhf2_libfunc = NULL_RTX; \
+  nehf2_libfunc = NULL_RTX; \
+  gthf2_libfunc = NULL_RTX; \
+  gehf2_libfunc = NULL_RTX; \
+  lthf2_libfunc = NULL_RTX; \
+  lehf2_libfunc = NULL_RTX; \
 \
   eqsf2_libfunc = init_one_libfunc ("fpcmp"); \
   nesf2_libfunc = init_one_libfunc ("fpcmp"); \
-  gtsf2_libfunc = init_one_libfunc ("fpcmp"); \
-  gesf2_libfunc = init_one_libfunc ("fpcmp"); \
+  gtsf2_libfunc = NULL_RTX; \
+  gesf2_libfunc = NULL_RTX; \
   ltsf2_libfunc = init_one_libfunc ("fpcmp"); \
   lesf2_libfunc = init_one_libfunc ("fpcmp"); \
 \
   eqdf2_libfunc = init_one_libfunc ("dpcmp"); \
   nedf2_libfunc = init_one_libfunc ("dpcmp"); \
-  gtdf2_libfunc = init_one_libfunc ("dpcmp"); \
-  gedf2_libfunc = init_one_libfunc ("dpcmp"); \
+  gtdf2_libfunc = NULL_RTX; \
+  gedf2_libfunc = NULL_RTX; \
   ltdf2_libfunc = init_one_libfunc ("dpcmp"); \
   ledf2_libfunc = init_one_libfunc ("dpcmp"); \
 \
index 0db33ca06679d99a456d05a989dc10320247492e..94927b9b2fe66982a88c47bf3cdb350aea4eb846 100644 (file)
@@ -3399,6 +3399,7 @@ prepare_float_lib_cmp (px, py, pcomparison, pmode, punsignedp)
      int *punsignedp;
 {
   enum rtx_code comparison = *pcomparison;
+  rtx tmp;
   rtx x = *px = protect_from_queue (*px, 0);
   rtx y = *py = protect_from_queue (*py, 0);
   enum machine_mode mode = GET_MODE (x);
@@ -3418,18 +3419,42 @@ prepare_float_lib_cmp (px, py, pcomparison, pmode, punsignedp)
 
       case GT:
        libfunc = gthf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LT;
+           libfunc = lthf2_libfunc;
+         }
        break;
 
       case GE:
        libfunc = gehf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LE;
+           libfunc = lehf2_libfunc;
+         }
        break;
 
       case LT:
        libfunc = lthf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GT;
+           libfunc = gthf2_libfunc;
+         }
        break;
 
       case LE:
        libfunc = lehf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GE;
+           libfunc = gehf2_libfunc;
+         }
        break;
 
       case UNORDERED:
@@ -3452,18 +3477,42 @@ prepare_float_lib_cmp (px, py, pcomparison, pmode, punsignedp)
 
       case GT:
        libfunc = gtsf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LT;
+           libfunc = ltsf2_libfunc;
+         }
        break;
 
       case GE:
        libfunc = gesf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LE;
+           libfunc = lesf2_libfunc;
+         }
        break;
 
       case LT:
        libfunc = ltsf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GT;
+           libfunc = gtsf2_libfunc;
+         }
        break;
 
       case LE:
        libfunc = lesf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GE;
+           libfunc = gesf2_libfunc;
+         }
        break;
 
       case UNORDERED:
@@ -3486,18 +3535,42 @@ prepare_float_lib_cmp (px, py, pcomparison, pmode, punsignedp)
 
       case GT:
        libfunc = gtdf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LT;
+           libfunc = ltdf2_libfunc;
+         }
        break;
 
       case GE:
        libfunc = gedf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LE;
+           libfunc = ledf2_libfunc;
+         }
        break;
 
       case LT:
        libfunc = ltdf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GT;
+           libfunc = gtdf2_libfunc;
+         }
        break;
 
       case LE:
        libfunc = ledf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GE;
+           libfunc = gedf2_libfunc;
+         }
        break;
 
       case UNORDERED:
@@ -3520,18 +3593,42 @@ prepare_float_lib_cmp (px, py, pcomparison, pmode, punsignedp)
 
       case GT:
        libfunc = gtxf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LT;
+           libfunc = ltxf2_libfunc;
+         }
        break;
 
       case GE:
        libfunc = gexf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LE;
+           libfunc = lexf2_libfunc;
+         }
        break;
 
       case LT:
        libfunc = ltxf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GT;
+           libfunc = gtxf2_libfunc;
+         }
        break;
 
       case LE:
        libfunc = lexf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GE;
+           libfunc = gexf2_libfunc;
+         }
        break;
 
       case UNORDERED:
@@ -3554,18 +3651,42 @@ prepare_float_lib_cmp (px, py, pcomparison, pmode, punsignedp)
 
       case GT:
        libfunc = gttf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LT;
+           libfunc = lttf2_libfunc;
+         }
        break;
 
       case GE:
        libfunc = getf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = LE;
+           libfunc = letf2_libfunc;
+         }
        break;
 
       case LT:
        libfunc = lttf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GT;
+           libfunc = gttf2_libfunc;
+         }
        break;
 
       case LE:
        libfunc = letf2_libfunc;
+       if (libfunc == NULL_RTX)
+         {
+           tmp = x; x = y; y = tmp;
+           *pcomparison = GE;
+           libfunc = getf2_libfunc;
+         }
        break;
 
       case UNORDERED: