+2016-04-29 Ilya Enkovich <ilya.enkovich@intel.com>
+
+ * tree-vect-loop.c (vect_transform_loop): Fix
+ nb_iterations_upper_bound computation for vectorized loop.
+
2016-04-29 Marek Polacek <polacek@redhat.com>
Jakub Jelinek <jakub@redhat.com>
+2016-04-29 Ilya Enkovich <ilya.enkovich@intel.com>
+
+ * gcc.target/i386/vect-unpack-2.c (avx512bw_test): Avoid
+ optimization of vector loop.
+ * gcc.target/i386/vect-unpack-3.c: New test.
+ * gcc.dg/vect/vect-nb-iter-ub-1.c: New test.
+ * gcc.dg/vect/vect-nb-iter-ub-2.c: New test.
+ * gcc.dg/vect/vect-nb-iter-ub-3.c: New test.
+
2016-04-29 Marek Polacek <polacek@redhat.com>
PR sanitizer/70342
--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target sse2 { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-additional-options "-msse2 -fdump-tree-cunroll-details" { target { i?86-*-* x86_64-*-* } } } */
+
+int ii[31];
+char cc[31] =
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 };
+
+void __attribute__((noinline,noclone))
+foo (int s)
+{
+ int i;
+ for (i = 0; i < s; i++)
+ ii[i] = (int) cc[i];
+}
+
+int main (int argc, const char **argv)
+{
+ int i;
+ foo (31);
+ for (i = 0; i < 31; i++)
+ if (ii[i] != i)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-tree-dump "loop turned into non-loop; it never loops" "cunroll" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-tree-dump-not "loop with 2 iterations completely unrolled" "cunroll" { target { i?86-*-* x86_64-*-* } } } } */
--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target sse2 { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-additional-options "-msse2 -fdump-tree-cunroll-details" { target { i?86-*-* x86_64-*-* } } } */
+
+int ii[32];
+char cc[66] =
+ { 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0,
+ 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0,
+ 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0,
+ 30, 0, 31, 0 };
+
+void __attribute__((noinline,noclone))
+foo (int s)
+{
+ int i;
+ for (i = 0; i < s; i++)
+ ii[i] = (int) cc[i*2];
+}
+
+int main (int argc, const char **argv)
+{
+ int i;
+ foo (32);
+ for (i = 0; i < 32; i++)
+ if (ii[i] != i)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-tree-dump "loop turned into non-loop; it never loops" "cunroll" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-tree-dump-not "loop with 2 iterations completely unrolled" "cunroll" { target { i?86-*-* x86_64-*-* } } } } */
--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target sse2 { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-additional-options "-msse2 -fdump-tree-cunroll-details" { target { i?86-*-* x86_64-*-* } } } */
+
+int ii[33];
+char cc[66] =
+ { 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0,
+ 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0,
+ 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0,
+ 30, 0, 31, 0, 32, 0 };
+
+void __attribute__((noinline,noclone))
+foo (int s)
+{
+ int i;
+ for (i = 0; i < s; i++)
+ ii[i] = (int) cc[i*2];
+}
+
+int main (int argc, const char **argv)
+{
+ int i;
+ foo (33);
+ for (i = 0; i < 33; i++)
+ if (ii[i] != i)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-tree-dump-not "loop turned into non-loop; it never loops" "cunroll" { target { i?86-*-* x86_64-*-* } } } } */
#define N 120
signed int yy[10000];
+signed char zz[10000];
void
-__attribute__ ((noinline)) foo (signed char s)
+__attribute__ ((noinline,noclone)) foo (int s)
{
- signed char i;
+ int i;
for (i = 0; i < s; i++)
- yy[i] = (signed int) i;
+ yy[i] = zz[i];
}
void
avx512bw_test ()
{
signed char i;
+ for (i = 0; i < N; i++)
+ zz[i] = i;
foo (N);
for (i = 0; i < N; i++)
if ( (signed int)i != yy [i] )
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2 -fdump-tree-vect-details -ftree-vectorize -ffast-math -mavx512bw -save-temps" } */
+/* { dg-require-effective-target avx512bw } */
+
+#include "avx512bw-check.h"
+
+#define N 120
+signed int yy[10000];
+
+void
+__attribute__ ((noinline)) foo (signed char s)
+{
+ signed char i;
+ for (i = 0; i < s; i++)
+ yy[i] = (signed int) i;
+}
+
+void
+avx512bw_test ()
+{
+ signed char i;
+ foo (N);
+ for (i = 0; i < N; i++)
+ if ( (signed int)i != yy [i] )
+ abort ();
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-assembler-not "vpmovsxbw\[ \\t\]+\[^\n\]*%zmm" } } */
/* Reduce loop iterations by the vectorization factor. */
scale_loop_profile (loop, GCOV_COMPUTE_SCALE (1, vectorization_factor),
expected_iterations / vectorization_factor);
- loop->nb_iterations_upper_bound
- = wi::udiv_floor (loop->nb_iterations_upper_bound, vectorization_factor);
if (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)
&& loop->nb_iterations_upper_bound != 0)
loop->nb_iterations_upper_bound = loop->nb_iterations_upper_bound - 1;
+ loop->nb_iterations_upper_bound
+ = wi::udiv_floor (loop->nb_iterations_upper_bound + 1,
+ vectorization_factor) - 1;
+
if (loop->any_estimate)
{
loop->nb_iterations_estimate