diff mbox

, PR target/79947, Fix compiler segmentation fault with -Ofast -mno-powerpc-gfxopt

Message ID 20170314210153.GA7326@ibm-tiger.the-meissners.org
State New
Headers show

Commit Message

Michael Meissner March 14, 2017, 9:01 p.m. UTC
In PR target/79947, the code for using the float reciprocal square root
estimate instruction did not check if the -mpowerpc-gfxopt option was enabled.
The code needs this option to generate a conditional floating point move.

I have checked this patch on the trunk, and it fixes the problem and it does
not cause any regressions.  Is it ok to apply to the trunk?  Assuming there are
no additional problems, can I apply the patch to the GCC 5 and 6 branches as
well?

[gcc]
2017-03-14  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/79947
	* config/rs6000/rs6000.h (TARGET_FRSQRTES): Add check for
	-mpowerpc-gfxopt.

[gcc/testsuite]
2017-03-14  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/79947
	* gcc.target/powerpc/pr79947.c: New test.

Comments

Segher Boessenkool March 14, 2017, 10:25 p.m. UTC | #1
Hi Mike,

On Tue, Mar 14, 2017 at 05:01:53PM -0400, Michael Meissner wrote:
> In PR target/79947, the code for using the float reciprocal square root
> estimate instruction did not check if the -mpowerpc-gfxopt option was enabled.
> The code needs this option to generate a conditional floating point move.
> 
> I have checked this patch on the trunk, and it fixes the problem and it does
> not cause any regressions.  Is it ok to apply to the trunk?  Assuming there are
> no additional problems, can I apply the patch to the GCC 5 and 6 branches as
> well?

All CPUs that have the reciprocal estimate insns also have the gfxopt
insns (and this will not change), so this is okay (also for the branches).
Thanks!


Segher
diff mbox

Patch

Index: gcc/config/rs6000/rs6000.h
===================================================================
--- gcc/config/rs6000/rs6000.h	(revision 246137)
+++ gcc/config/rs6000/rs6000.h	(working copy)
@@ -752,7 +752,8 @@  extern int rs6000_vector_align[];
 			 && (TARGET_POPCNTB || VECTOR_UNIT_VSX_P (DFmode)))
 
 #define TARGET_FRSQRTES	(TARGET_HARD_FLOAT && TARGET_POPCNTB \
-			 && TARGET_FPRS && TARGET_SINGLE_FLOAT)
+			 && TARGET_PPC_GFXOPT && TARGET_FPRS \
+			 && TARGET_SINGLE_FLOAT)
 
 #define TARGET_FRSQRTE	(TARGET_HARD_FLOAT && TARGET_FPRS \
 			 && TARGET_DOUBLE_FLOAT \
Index: gcc/testsuite/gcc.target/powerpc/pr79947.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr79947.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr79947.c	(working copy)
@@ -0,0 +1,12 @@ 
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-options "-Ofast -mno-powerpc-gfxopt -mcmpb -mno-vsx" } */
+
+/* PR 79949: Compiler segmentation fault due to not having conditional move
+   support for the target if the -mno-powerpc-gfxopt option is used.  */
+
+float a, b;
+void
+c ()
+{
+  a = __builtin_sqrtf (b);
+}