Hi Diego,

        This is a backport of this patch to fix an ICE on PowerPC64.

        http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00829.html

-Doug


2012-05-31   Doug Kwan  <dougk...@google.com>

        Backport r171031 from upstream trunk in gcc/.
        2011-03-16  Alan Modra  <amo...@gmail.com>

                PR target/45844
                * config/rs6000/rs6000.c (rs6000_legitimize_reload_address):
                Don't create invalid offset address for vsx splat insn.
                * config/rs6000/predicates.md (splat_input_operand): New.
                * config/rs6000/vsx.md (vsx_splat_*): Use it.

        * contrib/testsuite-management/powerpc64-grtev2-linux-gnu.xfail:
        Remove expected failures because now the bug is fixed by the above.

Index: contrib/testsuite-management/powerpc64-grtev2-linux-gnu.xfail
===================================================================
--- contrib/testsuite-management/powerpc64-grtev2-linux-gnu.xfail       
(revision 188083)
+++ contrib/testsuite-management/powerpc64-grtev2-linux-gnu.xfail       
(working copy)
@@ -69,8 +69,6 @@ FAIL: gcc.target/powerpc/pr47755-2.c execution tes
 
 # *** gfortran:
 XPASS: gfortran.dg/nint_2.f90  -O0  execution test
-FAIL: gfortran.dg/vect/pr45714-b.f  -O  (internal compiler error)
-FAIL: gfortran.dg/vect/pr45714-b.f  -O  (test for excess errors)
 FAIL: gfortran.dg/vect/fast-math-pr38968.f90 execution test
 
 # *** g++:
Index: gcc/config/rs6000/predicates.md
===================================================================
--- gcc/config/rs6000/predicates.md     (revision 188083)
+++ gcc/config/rs6000/predicates.md     (working copy)
@@ -1,5 +1,5 @@
 ;; Predicate definitions for POWER and PowerPC.
-;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
+;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;; Free Software Foundation, Inc.
 ;;
 ;; This file is part of GCC.
@@ -871,6 +871,23 @@
   return 0;
 })
 
+;; Return 1 if this operand is a valid input for a vsx_splat insn.
+(define_predicate "splat_input_operand"
+  (match_code "label_ref,symbol_ref,const,high,reg,subreg,mem,
+              const_double,const_vector,const_int,plus")
+{
+  if (MEM_P (op))
+    {
+      if (mode == DFmode)
+       mode = V2DFmode;
+      else if (mode == DImode)
+       mode = V2DImode;
+      else
+       gcc_unreachable ();        
+    }
+  return input_operand (op, mode);
+})
+
 ;; Return true if OP is an invalid SUBREG operation on the e500.
 (define_predicate "rs6000_nonimmediate_operand"
   (match_code "reg,subreg,mem")
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c  (revision 188083)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -6703,6 +6703,14 @@ rs6000_legitimize_reload_address (rtx x, enum mach
 {
   bool reg_offset_p = reg_offset_addressing_ok_p (mode);
 
+  /* Nasty hack for vsx_splat_V2DF/V2DI load from mem, which takes a
+     DFmode/DImode MEM.  */
+  if (reg_offset_p
+      && opnum == 1
+      && ((mode == DFmode && recog_data.operand_mode[0] == V2DFmode)
+         || (mode == DImode && recog_data.operand_mode[0] == V2DImode)))
+    reg_offset_p = false;
+
   /* We must recognize output that we have already generated ourselves.  */
   if (GET_CODE (x) == PLUS
       && GET_CODE (XEXP (x, 0)) == PLUS
Index: gcc/config/rs6000/vsx.md
===================================================================
--- gcc/config/rs6000/vsx.md    (revision 188083)
+++ gcc/config/rs6000/vsx.md    (working copy)
@@ -1076,7 +1076,7 @@
 (define_insn "vsx_splat_<mode>"
   [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wd,wd,wd,?wa,?wa,?wa")
        (vec_duplicate:VSX_D
-        (match_operand:<VS_scalar> 1 "input_operand" "ws,f,Z,wa,wa,Z")))]
+        (match_operand:<VS_scalar> 1 "splat_input_operand" "ws,f,Z,wa,wa,Z")))]
   "VECTOR_MEM_VSX_P (<MODE>mode)"
   "@
    xxpermdi %x0,%x1,%x1,0

--
This patch is available for review at http://codereview.appspot.com/6255070

Reply via email to