diff mbox

Fix PR 47755 on powerpc, make vector constant of all 0's not generate a load instruction

Message ID 20110215174926.GA6507@hungry-tiger.westford.ibm.com
State New
Headers show

Commit Message

Michael Meissner Feb. 15, 2011, 5:49 p.m. UTC
This patch was discovered when we tried to build glibc with -O3 and
-mcpu=power7.  The initialization function _dl_start sets an auto array to all
0's, but it is done before the TOC pointer is setup.  The compiler was assuming
that vector long long constants weren't easy, so it pushed them to the constant
pool.  The vectorizer converts the DImode 0 into V2DI mode { 0, 0 } for the
loop.

I have done a bootstrap to the compiler and side by side make check's with no
regressions.  Is it ok to apply the patch?

[gcc]
2011-02-15  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/47755
	* config/rs6000/predicates.md (easy_vector_constant): Allow V2DI
	mode for vector constants.

[gcc/testsuite]
2011-02-15  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/47755
	* gcc.target/powerpc/pr47755.c: New file, test all 0 vector
	constant does not generate a load from memory.
diff mbox

Patch

Index: gcc/config/rs6000/predicates.md
===================================================================
--- gcc/config/rs6000/predicates.md	(revision 170149)
+++ gcc/config/rs6000/predicates.md	(working copy)
@@ -328,13 +328,11 @@  (define_predicate "easy_vector_constant"
   if (TARGET_PAIRED_FLOAT)
     return false;
 
-  if ((VSX_VECTOR_MODE (mode) || mode == TImode) && zero_constant (op, mode))
-    return true;
-
-  if (ALTIVEC_VECTOR_MODE (mode))
+  if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode))
     {
       if (zero_constant (op, mode))
-        return true;
+	return true;
+
       return easy_altivec_constant (op, mode);
     }
 
Index: gcc/testsuite/gcc.target/powerpc/pr47755.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr47755.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr47755.c	(revision 0)
@@ -0,0 +1,16 @@ 
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O3 -mcpu=power7" } */
+/* { dg-final { scan-assembler "xxlxor" } } */
+/* { dg-final { scan-assembler-not "lxvd2x" } } */
+/* { dg-final { scan-assembler-not "lxvw4x" } } */
+/* { dg-final { scan-assembler-not "lvx" } } */
+
+/* PR 47755: Compiler loads vector constant of 0 from TOC instead of using
+   xxlxor.  */
+void
+func (vector long long *p)
+{
+  *p = (vector long long) { 0LL, 0LL };
+}