From: Yuri Rumyantsev Date: Wed, 6 Jul 2016 14:37:26 +0000 (+0000) Subject: re PR tree-optimization/71518 (wrong code at -O3 on x86_64-linux-gnu in 64-bit mode... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=651afdb2d2e2896fc600e76cf5ce113ba835e55f;p=gcc.git re PR tree-optimization/71518 (wrong code at -O3 on x86_64-linux-gnu in 64-bit mode (not in 32-bit mode)) gcc/ 2016-07-06 Yuri Rumyantsev PR tree-optimization/71518 * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Adjust misalign also for outer loops with negative step. gcc/testsuite/ 2016-07-06 Yuri Rumyantsev PR tree-optimization/71518 * gcc.dg/pr71518.c: New test. From-SVN: r238055 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 348b0bb2453..fb611213cb1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-07-06 Yuri Rumyantsev + + PR tree-optimization/71518 + * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Adjust + misalign also for outer loops with negative step. + 2016-07-06 Wilco Dijkstra * config/arm/cortex-a53.md: Use final_presence_set for in-order. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5dca6f73199..fa5f1c16945 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-06 Yuri Rumyantsev + + PR tree-optimization/71518 + * gcc.dg/pr71518.c: New test. + 2016-07-06 Wilco Dijkstra * gcc.target/arm/vst1Q_laneu64-1.c (foo): Use unsigned char*. diff --git a/gcc/testsuite/gcc.dg/pr71518.c b/gcc/testsuite/gcc.dg/pr71518.c new file mode 100644 index 00000000000..6240ca8f2bf --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71518.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/71518 */ +/* { dg-options "-O3" } */ + +int a, *b[9], c, d, e; + +static int +fn1 () +{ + for (c = 6; c >= 0; c--) + for (d = 0; d < 2; d++) + { + b[d * 2 + c] = 0; + e = a > 1 ? : 0; + if (e == 2) + return 0; + } + return 0; +} + +int +main () +{ + fn1 (); + return 0; +} diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index f2f0dc50bbd..6fddd3a1c68 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -698,6 +698,7 @@ vect_compute_data_ref_alignment (struct data_reference *dr) tree base, base_addr; tree misalign = NULL_TREE; tree aligned_to; + tree step; unsigned HOST_WIDE_INT alignment; if (dump_enabled_p ()) @@ -828,16 +829,20 @@ vect_compute_data_ref_alignment (struct data_reference *dr) DR_VECT_AUX (dr)->base_element_aligned = true; } + if (loop && nested_in_vect_loop_p (loop, stmt)) + step = STMT_VINFO_DR_STEP (stmt_info); + else + step = DR_STEP (dr); /* If this is a backward running DR then first access in the larger vectype actually is N-1 elements before the address in the DR. Adjust misalign accordingly. */ - if (tree_int_cst_sgn (DR_STEP (dr)) < 0) + if (tree_int_cst_sgn (step) < 0) { tree offset = ssize_int (TYPE_VECTOR_SUBPARTS (vectype) - 1); /* DR_STEP(dr) is the same as -TYPE_SIZE of the scalar type, otherwise we wouldn't be here. */ - offset = fold_build2 (MULT_EXPR, ssizetype, offset, DR_STEP (dr)); - /* PLUS because DR_STEP was negative. */ + offset = fold_build2 (MULT_EXPR, ssizetype, offset, step); + /* PLUS because STEP was negative. */ misalign = size_binop (PLUS_EXPR, misalign, offset); }