2010-03-22 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Mar 2010 12:39:04 +0000 (12:39 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Mar 2010 12:39:04 +0000 (12:39 +0000)
PR tree-optimization/43390
* tree-vect-stmts.c (get_vectype_for_scalar_type): Make
sure vector extracts are type correct.

* gfortran.fortran-torture/execute/pr43390.f90: New testcase.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/execute/pr43390.f90 [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 077b6e6..5cff766 100644 (file)
@@ -1,5 +1,11 @@
 2010-03-22  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/43390
+       * tree-vect-stmts.c (get_vectype_for_scalar_type): Make
+       sure vector extracts are type correct.
+
+2010-03-22  Richard Guenther  <rguenther@suse.de>
+
        PR middle-end/40106
        * builtins.c (expand_builtin_pow): Expand pow (x, 1.5) as
        x * sqrt (x) even when optimizing for size if the target
index 73e978a..a036f25 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-22  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/43390
+       * gfortran.fortran-torture/execute/pr43390.f90: New testcase.
+
 2010-03-21  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.target/powerpc/ppc-sdata-1.c: Require nonpic.
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/pr43390.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/pr43390.f90
new file mode 100644 (file)
index 0000000..b54eef9
--- /dev/null
@@ -0,0 +1,9 @@
+   logical :: l1(4)
+   logical :: l2(4)
+   l1 = (/.TRUE.,.FALSE.,.TRUE.,.FALSE./)
+   l2 = (/.FALSE.,.TRUE.,.FALSE.,.TRUE./)
+   if (dot_product (l1, l2)) call abort ()
+   l2 = .TRUE.
+   if (.not.dot_product (l1, l2)) call abort ()
+end
+
index ce604b3..4bce61a 100644 (file)
@@ -4417,6 +4417,14 @@ get_vectype_for_scalar_type (tree scalar_type)
   if (nbytes < TYPE_ALIGN_UNIT (scalar_type))
     return NULL_TREE;
 
+  /* If we'd build a vector type of elements whose mode precision doesn't
+     match their types precision we'll get mismatched types on vector
+     extracts via BIT_FIELD_REFs.  This effectively means we disable
+     vectorization of bool and/or enum types in some languages.  */
+  if (INTEGRAL_TYPE_P (scalar_type)
+      && GET_MODE_BITSIZE (inner_mode) != TYPE_PRECISION (scalar_type))
+    return NULL_TREE;
+
   /* FORNOW: Only a single vector size per mode (UNITS_PER_SIMD_WORD)
      is expected.  */
   nunits = UNITS_PER_SIMD_WORD (inner_mode) / nbytes;