re PR target/37168 (ICE: in final_scan_insn, at final.c:2615 (altivec))
authorJakub Jelinek <jakub@redhat.com>
Sun, 31 Aug 2008 12:08:35 +0000 (14:08 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 31 Aug 2008 12:08:35 +0000 (14:08 +0200)
PR target/37168
* config/rs6000/rs6000-protos.h (const_vector_elt_as_int): Add
prototype.
* config/rs6000/rs6000.c (const_vector_elt_as_int): No longer static.
* config/rs6000/altivec.md (easy_vector_constant_add_self splitter):
Also split V4SFmode.
* config/rs6000/predicates.md (easy_vector_constant_add_self): Handle
vector float modes.

* gcc.target/powerpc/pr37168.c: New test.

From-SVN: r139828

gcc/ChangeLog
gcc/config/rs6000/altivec.md
gcc/config/rs6000/predicates.md
gcc/config/rs6000/rs6000-protos.h
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/pr37168.c [new file with mode: 0644]

index 9b7ece0908227c3a095ec09a508a5d9c109b2d93..c5690fcd8e42eb91c1a4b86bb63bc49f53c650a0 100644 (file)
@@ -1,3 +1,14 @@
+2008-08-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/37168
+       * config/rs6000/rs6000-protos.h (const_vector_elt_as_int): Add
+       prototype.
+       * config/rs6000/rs6000.c (const_vector_elt_as_int): No longer static.
+       * config/rs6000/altivec.md (easy_vector_constant_add_self splitter):
+       Also split V4SFmode.
+       * config/rs6000/predicates.md (easy_vector_constant_add_self): Handle
+       vector float modes.
+
 2008-08-31  Jan Hubicka  <jh@suse.cz>
 
        * predict.c (PROB_VERY_LIKELY): Make small enough so things
index f8ed145350e51a0bff99527dccbedca17931b661..e8028edf06719375c337562764b50af8757e2987 100644 (file)
@@ -1,5 +1,5 @@
 ;; AltiVec patterns.
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
 ;; Free Software Foundation, Inc.
 ;; Contributed by Aldy Hernandez (aldy@quesejoda.com)
 
 })
 
 (define_split
-  [(set (match_operand:VI 0 "altivec_register_operand" "")
-       (match_operand:VI 1 "easy_vector_constant_add_self" ""))]
+  [(set (match_operand:V 0 "altivec_register_operand" "")
+       (match_operand:V 1 "easy_vector_constant_add_self" ""))]
   "TARGET_ALTIVEC && reload_completed"
   [(set (match_dup 0) (match_dup 3))
-   (set (match_dup 0) (plus:VI (match_dup 0)
-                              (match_dup 0)))]
+   (set (match_dup 0) (match_dup 4))]
 {
   rtx dup = gen_easy_altivec_constant (operands[1]);
   rtx const_vec;
+  enum machine_mode op_mode = <MODE>mode;
 
   /* Divide the operand of the resulting VEC_DUPLICATE, and use
      simplify_rtx to make a CONST_VECTOR.  */
                                                   XEXP (dup, 0), const1_rtx);
   const_vec = simplify_rtx (dup);
 
-  if (GET_MODE (const_vec) == <MODE>mode)
+  if (op_mode == V4SFmode)
+    {
+      op_mode = V4SImode;
+      operands[0] = gen_lowpart (op_mode, operands[0]);
+    }
+  if (GET_MODE (const_vec) == op_mode)
     operands[3] = const_vec;
   else
-    operands[3] = gen_lowpart (<MODE>mode, const_vec);
+    operands[3] = gen_lowpart (op_mode, const_vec);
+  operands[4] = gen_rtx_PLUS (op_mode, operands[0], operands[0]);
 })
 
 (define_insn "get_vrsave_internal"
index 8e97c79acd21fbec830a74ed802c4af181a3451d..f6929706899068f510f1da714110a310972a6933 100644 (file)
@@ -1,5 +1,5 @@
 ;; Predicate definitions for POWER and PowerPC.
-;; Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 ;;
 ;; This file is part of GCC.
 ;;
        (and (match_test "TARGET_ALTIVEC")
            (match_test "easy_altivec_constant (op, mode)")))
 {
-  rtx last = CONST_VECTOR_ELT (op, GET_MODE_NUNITS (mode) - 1);
-  HOST_WIDE_INT val = ((INTVAL (last) & 0xff) ^ 0x80) - 0x80;
+  HOST_WIDE_INT val = const_vector_elt_as_int (op, GET_MODE_NUNITS (mode) - 1);
+  val = ((val & 0xff) ^ 0x80) - 0x80;
   return EASY_VECTOR_15_ADD_SELF (val);
 })
 
index 762f784ed698fb296a48cafbc40a1e7ff6083cc7..a9fb2ab237f1e6dcb86994e42095a77ff5e5a59d 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler, for IBM RS/6000.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
@@ -31,6 +31,7 @@ extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, int, int, int);
 #endif /* TREE_CODE */
 
 extern bool easy_altivec_constant (rtx, enum machine_mode);
+extern HOST_WIDE_INT const_vector_elt_as_int (rtx, unsigned int);
 extern bool macho_lo_sum_memory_operand (rtx, enum machine_mode);
 extern int num_insns_constant (rtx, enum machine_mode);
 extern int num_insns_constant_wide (HOST_WIDE_INT);
index e2743edce294f8a07b017f544a827e57ac0c5fdc..d3821a8cfa91ca13983eb2cfa46faa483d939fbd 100644 (file)
@@ -2690,7 +2690,7 @@ num_insns_constant (rtx op, enum machine_mode mode)
    corresponding element of the vector, but for V4SFmode and V2SFmode,
    the corresponding "float" is interpreted as an SImode integer.  */
 
-static HOST_WIDE_INT
+HOST_WIDE_INT
 const_vector_elt_as_int (rtx op, unsigned int elt)
 {
   rtx tmp = CONST_VECTOR_ELT (op, elt);
index 3e4a2e9cc271b50792ec0317c276511b64f4f155..c03514ceee01d74b8450d3b88215bbf6a5548ef4 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/37168
+       * gcc.target/powerpc/pr37168.c: New test.
+
 2008-08-31  Jan Hubicka  <jh@suse.cz>
 
        * gcc.target/i386/cold-attribute-1.c: New testcase.
diff --git a/gcc/testsuite/gcc.target/powerpc/pr37168.c b/gcc/testsuite/gcc.target/powerpc/pr37168.c
new file mode 100644 (file)
index 0000000..8d35157
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR target/37168 */
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-O2 -maltivec" } */
+
+#define C 3.68249351546114573519399405666776E-44f
+#define vector __attribute__ ((altivec (vector__)))
+
+vector float
+foo (vector float a)
+{
+  vector float b = __builtin_vec_madd (b, a, (vector float) { C, C, C, C });
+  return b;
+}