diff mbox series

Do not generate libcalls to __unord[sd]f2 on PowerPC SPE

Message ID 5523688.bpAWfy1Iex@polaris
State New
Headers show
Series Do not generate libcalls to __unord[sd]f2 on PowerPC SPE | expand

Commit Message

Eric Botcazou Feb. 9, 2018, 10:28 a.m. UTC
Hi,

the change

2016-05-02  Marc Glisse  <marc.glisse@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  <ebotcazou@adacore.com>

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

Comments

Richard Biener Feb. 9, 2018, 11:07 a.m. UTC | #1
On Fri, Feb 9, 2018 at 11:28 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> the change
>
> 2016-05-02  Marc Glisse  <marc.glisse@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?

Ok.

Richard.

>
> 2018-02-09  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * optabs.c (prepare_cmp_insn): Try harder to emit a direct comparison
>         instead of a libcall for UNORDERED.
>
> --
> Eric Botcazou
diff mbox series

Patch

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);
 
   return;