the change

2016-05-02  Marc Glisse  <marc.gli...@inria.fr>

        * match.pd (X u< X, X u> X): New transformations.

has an annoying effect on targets implementing (most) unordered comparisons in 
hardware but not the UNORDERED operator itself, e.g. PowerPC SPE, because it 
makes the compiler generate unnecessary libcalls to __unord[sd]f2.

The attached patch contains a trick to undo the effect of the change at the 
RTL level for such targets.  It was tested on PowerPC SPE with a certified 
version of VxWorks (which provides a minimal certified libgcc) where it fixes 
the link failure of ACATS c45242b with optimization enabled.

OK for the mainline?

2018-02-09  Eric Botcazou  <ebotca...@adacore.com>

        * optabs.c (prepare_cmp_insn): Try harder to emit a direct comparison
        instead of a libcall for UNORDERED.

Eric Botcazou
Index: optabs.c
--- optabs.c	(revision 257404)
+++ optabs.c	(working copy)
@@ -3935,7 +3935,20 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx
   if (methods != OPTAB_LIB_WIDEN)
     goto fail;
-  if (!SCALAR_FLOAT_MODE_P (mode))
+  if (SCALAR_FLOAT_MODE_P (mode))
+    {
+      /* Small trick if UNORDERED isn't implemented by the hardware.  */
+      if (comparison == UNORDERED && rtx_equal_p (x, y))
+	{
+	  prepare_cmp_insn (x, y, UNLT, NULL_RTX, unsignedp, OPTAB_WIDEN,
+			    ptest, pmode);
+	  if (*ptest)
+	    return;
+	}
+      prepare_float_lib_cmp (x, y, comparison, ptest, pmode);
+    }
+  else
       rtx result;
       machine_mode ret_mode;
@@ -3982,8 +3995,6 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx
       prepare_cmp_insn (x, y, comparison, NULL_RTX, unsignedp, methods,
 			ptest, pmode);
-  else
-    prepare_float_lib_cmp (x, y, comparison, ptest, pmode);

Reply via email to