OSDN Git Service

2005-09-14 Uros Bizjak <uros@kss-loka.si>
authordorit <dorit@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Sep 2005 09:27:01 +0000 (09:27 +0000)
committerdorit <dorit@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Sep 2005 09:27:01 +0000 (09:27 +0000)
        PR middle-end/22480
        * tree-vect-transform.c (vectorizable_operation): Return false for
        scalar shift operations and for vector shift operations with
        non-invariant shift arguments.  Use scalar tree operand op1 as
        a shift operand when vector shift insn pattern uses scalar shift
        operand.
        * Makefile.in (tree-vect-transform.o): Depend on recog.h.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104264 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/Makefile.in
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr22480.c [new file with mode: 0755]
gcc/tree-vect-transform.c

index a0da848..191cdc2 100644 (file)
@@ -1,3 +1,13 @@
+2005-09-14  Uros Bizjak  <uros@kss-loka.si>
+
+       PR middle-end/22480
+       * tree-vect-transform.c (vectorizable_operation): Return false for
+       scalar shift operations and for vector shift operations with
+       non-invariant shift arguments.  Use scalar tree operand op1 as
+       a shift operand when vector shift insn pattern uses scalar shift
+       operand.
+       * Makefile.in (tree-vect-transform.o): Depend on recog.h.
+
 2005-09-14  Olivier Hainque  <hainque@adacore.com>
 
        * gimplify.c (gimplify_init_ctor_eval): Don't discard a zero-sized
index f260f37..fded53d 100644 (file)
@@ -1959,7 +1959,7 @@ tree-vect-analyze.o: tree-vect-analyze.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(DIAGNOSTIC_H) $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) $(CFGLOOP_H) \
    tree-vectorizer.h $(TREE_DATA_REF_H) $(SCEV_H) $(EXPR_H) tree-chrec.h
 tree-vect-transform.o: tree-vect-transform.c $(CONFIG_H) $(SYSTEM_H) \
-   coretypes.h $(TM_H) $(GGC_H) $(OPTABS_H) $(TREE_H) $(RTL_H) \
+   coretypes.h $(TM_H) $(GGC_H) $(OPTABS_H) $(RECOG_H) $(TREE_H) $(RTL_H) \
    $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) $(TREE_FLOW_H) $(TREE_DUMP_H) \
    $(TIMEVAR_H) $(CFGLOOP_H) $(TARGET_H) tree-pass.h $(EXPR_H) \
    tree-vectorizer.h $(TREE_DATA_REF_H) $(SCEV_H) langhooks.h toplev.h \
index fda2fb3..271f368 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-14  Uros Bizjak  <uros@kss-loka.si>
+
+       PR middle-end/22480
+       * gcc.dg/vect/pr22480.c: New test.
+
 2005-09-13  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/19358
diff --git a/gcc/testsuite/gcc.dg/vect/pr22480.c b/gcc/testsuite/gcc.dg/vect/pr22480.c
new file mode 100755 (executable)
index 0000000..ddf657f
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+void
+test_1 (void)
+{
+  static unsigned int bm[16];
+  int j;
+  for (j = 0; j < 16; j++)
+    bm[j] <<= 8;
+}
+
+void
+test_2 (int a)
+{
+  static unsigned int bm[16];
+  int j;
+  for (j = 0; j < 16; j++)
+    bm[j] <<= a;
+}
+
+void
+test_3 (void)
+{
+ static unsigned bm[16];
+ int am[16];
+ int j;
+ for (j = 0; j < 16;j++)
+   bm[j] <<= am[j];
+}
index f498adb..4084e5a 100644 (file)
@@ -35,6 +35,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #include "cfgloop.h"
 #include "expr.h"
 #include "optabs.h"
+#include "recog.h"
 #include "tree-data-ref.h"
 #include "tree-chrec.h"
 #include "tree-scalar-evolution.h"
@@ -1409,6 +1410,8 @@ vectorizable_operation (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
   int op_type;
   tree op;
   optab optab;
+  int icode;
+  enum machine_mode optab_op2_mode;
   tree def, def_stmt;
   enum vect_def_type dt;
 
@@ -1464,7 +1467,8 @@ vectorizable_operation (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
       return false;
     }
   vec_mode = TYPE_MODE (vectype);
-  if (optab->handlers[(int) vec_mode].insn_code == CODE_FOR_nothing)
+  icode = (int) optab->handlers[(int) vec_mode].insn_code;
+  if (icode == CODE_FOR_nothing)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
        fprintf (vect_dump, "op not supported by target.");
@@ -1486,6 +1490,25 @@ vectorizable_operation (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
       return false;
     }
 
+  if (code == LSHIFT_EXPR || code == RSHIFT_EXPR)
+    {
+      /* FORNOW: not yet supported.  */
+      if (!VECTOR_MODE_P (vec_mode))
+       return false;
+
+      /* Invariant argument is needed for a vector shift
+        by a scalar shift operand.  */
+      optab_op2_mode = insn_data[icode].operand[2].mode;
+      if (! (VECTOR_MODE_P (optab_op2_mode)
+            || dt == vect_constant_def
+            || dt == vect_invariant_def))
+       {
+         if (vect_print_dump_info (REPORT_DETAILS))
+           fprintf (vect_dump, "operand mode requires invariant argument.");
+         return false;
+       }
+    }
+
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = op_vec_info_type;
@@ -1508,7 +1531,25 @@ vectorizable_operation (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
   if (op_type == binary_op)
     {
       op1 = TREE_OPERAND (operation, 1);
-      vec_oprnd1 = vect_get_vec_def_for_operand (op1, stmt, NULL); 
+
+      if (code == LSHIFT_EXPR || code == RSHIFT_EXPR)
+       {
+         /* Vector shl and shr insn patterns can be defined with
+            scalar operand 2 (shift operand).  In this case, use
+            constant or loop invariant op1 directly, without
+            extending it to vector mode first.  */
+
+         optab_op2_mode = insn_data[icode].operand[2].mode;
+         if (!VECTOR_MODE_P (optab_op2_mode))
+           {
+             if (vect_print_dump_info (REPORT_DETAILS))
+               fprintf (vect_dump, "operand 1 using scalar mode.");
+             vec_oprnd1 = op1;
+           }
+       }
+
+      if (!vec_oprnd1)
+       vec_oprnd1 = vect_get_vec_def_for_operand (op1, stmt, NULL); 
     }
 
   /* Arguments are ready. create the new vector stmt.  */