diff mbox

Fix PR51867, in which gcc generates inconsistent code for same functions

Message ID 001501cce2e7$83f13e90$8bd3bbb0$@cheng@arm.com
State New
Headers show

Commit Message

Bin Cheng Feb. 4, 2012, 2:48 a.m. UTC
Hi,

Here is the patch fixing pr51867 by removing the redundant check on
DECL_ASSEMBLER_NAME_SET_P.
I also changed '-O0' to '-O1' in signbit-2.c and added a new test.
The new test case won't bite if target cpu does not support hardware sqrtf
instruction.

Tested on arm-eabi and x86, Is it OK?

Thanks.

gcc/ChangeLog:
2012-02-04  Bin Cheng  <bin.cheng@arm.com>

	PR target/51867
	* builtins.c (expand_builtin): Don't check
DECL_ASSEMBLER_NAME_SET_P.

gcc/testsuite/ChangeLog:
2012-02-04  Bin Cheng  <bin.cheng@arm.com>

	PR target/51867
	* testsuite/c-c++-common/dfp/signbit-2.c: Change '-O0' to '-O1'.
	* testsuite/gcc.dg/pr51867.c: New test.
diff mbox

Patch

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 183205)
+++ gcc/builtins.c	(working copy)
@@ -5745,10 +5745,12 @@ 
     return targetm.expand_builtin (exp, target, subtarget, mode, ignore);
 
   /* When not optimizing, generate calls to library functions for a certain
-     set of builtins.  */
+     set of builtins.
+
+     See PR51867.
+     Don't check "DECL_ASSEMBLER_NAME_SET_P (fndecl)" here any more.  */
   if (!optimize
       && !called_as_built_in (fndecl)
-      && DECL_ASSEMBLER_NAME_SET_P (fndecl)
       && fcode != BUILT_IN_ALLOCA
       && fcode != BUILT_IN_ALLOCA_WITH_ALIGN
       && fcode != BUILT_IN_FREE)
Index: gcc/testsuite/gcc.dg/pr51867.c
===================================================================
--- gcc/testsuite/gcc.dg/pr51867.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr51867.c	(revision 0)
@@ -0,0 +1,16 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O0 -fno-math-errno -fdump-rtl-expand" } */
+#include <math.h>
+
+float a(float x)
+{
+    return sqrtf(x);
+}
+float b(float x)
+{
+    return sqrtf(x);
+}
+/* Here the calls to sqrtf should be expanded into CALL_INSNs, rather than
+   fpu sqrtf rtl patterns.  */
+/* { dg-final { scan-rtl-dump-times "call_insn" 2 "expand" } } */
+/* { dg-final { cleanup-rtl-dump "expand" } } */
Index: gcc/testsuite/c-c++-common/dfp/signbit-2.c
===================================================================
--- gcc/testsuite/c-c++-common/dfp/signbit-2.c	(revision 183205)
+++ gcc/testsuite/c-c++-common/dfp/signbit-2.c	(working copy)
@@ -1,7 +1,10 @@ 
-/* { dg-options "-O0" } */
+/* { dg-options "-O1" } */
 
 /* Check that the compiler uses builtins for signbit; if not the link
    will fail because library functions are in libm.  */
+/* See PR51867.
+   Since GCC uses library call when optimizing for "-O0", this test
+   case requires at least "-O1" level optimization now.  */
 
 #include "dfp-dbg.h"