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

2018-02-09 Thread Richard Biener
On Fri, Feb 9, 2018 at 11:28 AM, Eric Botcazou  wrote:
> Hi,
>
> the change
>
> 2016-05-02  Marc Glisse  
>
> * 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  
>
> * optabs.c (prepare_cmp_insn): Try harder to emit a direct comparison
> instead of a libcall for UNORDERED.
>
> --
> Eric Botcazou


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

2018-02-09 Thread Eric Botcazou
Hi,

the change

2016-05-02  Marc Glisse  

* 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  

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

-- 
Eric BotcazouIndex: 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;