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  <meiss...@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  <meiss...@linux.vnet.ibm.com>

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

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
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);
+}

Reply via email to