From 6f9071656286512360ca22b6668c9c8d823ec907 Mon Sep 17 00:00:00 2001 From: Alan Lawrence Date: Tue, 27 Oct 2015 12:36:55 +0000 Subject: [PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant gcc/: tree-scalar-evolution.c (interpret_rhs_expr): Handle some LSHIFT_EXPRs as equivalent MULT_EXPRs. gcc/testsuite/: gcc.dg/vect/vect-strided-shift.c: New. From-SVN: r229437 --- gcc/ChangeLog | 6 ++++ gcc/testsuite/ChangeLog | 4 +++ .../gcc.dg/vect/vect-strided-shift-1.c | 33 +++++++++++++++++++ gcc/tree-scalar-evolution.c | 14 ++++++++ 4 files changed, 57 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/vect-strided-shift-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 96af75db414..9bee00f56d3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-10-27 Alan Lawrence + + PR tree-optimization/65963 + * tree-scalar-evolution.c (interpret_rhs_expr): Handle some LSHIFT_EXPRs + as equivalent MULT_EXPRs. + 2015-10-27 Kyrylo Tkachov PR target/67929 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 612e52f8929..e693063b4ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-10-27 Alan Lawrence + + * gcc.dg/vect/vect-strided-shift-1.c: New. + 2015-10-27 Kyrylo Tkachov PR target/67929 diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-shift-1.c b/gcc/testsuite/gcc.dg/vect/vect-strided-shift-1.c new file mode 100644 index 00000000000..b1ce2ece170 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-strided-shift-1.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/65963. */ +#include "tree-vect.h" + +#define N 512 + +int in[2*N], out[N]; + +__attribute__ ((noinline)) void +loop (void) +{ + for (int i = 0; i < N; i++) + out[i] = in[i << 1] + 7; +} + +int +main (int argc, char **argv) +{ + check_vect (); + for (int i = 0; i < 2*N; i++) + { + in[i] = i; + __asm__ volatile ("" : : : "memory"); + } + loop (); + __asm__ volatile ("" : : : "memory"); + for (int i = 0; i < N; i++) + { + if (out[i] != i*2 + 7) + abort (); + } + return 0; +} +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 1 "vect" { target { vect_strided2 } } } } */ diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 0753bf3122e..8e95ddd2d6a 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1840,6 +1840,20 @@ interpret_rhs_expr (struct loop *loop, gimple *at_stmt, res = chrec_fold_multiply (type, chrec1, chrec2); break; + case LSHIFT_EXPR: + /* Handle A<