public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH PR71518] Adjust misalign for outer loops also.
@ 2016-07-06 12:59 Yuri Rumyantsev
  2016-07-06 13:28 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Yuri Rumyantsev @ 2016-07-06 12:59 UTC (permalink / raw)
  To: gcc-patches, Richard Biener, Igor Zamyatin,
	Илья
	Энкович

[-- Attachment #1: Type: text/plain, Size: 444 bytes --]

Hi All,

Here is a simple patch which add missed misalign adjustment for outer loop.

Bootstrapping and regression testing did not show any new failures.

Is it OK for trunk?

ChangeLog:
2016-07-06  Yuri Rumyantsev  <ysrumyan@gmail.com>

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/ChangeLog:
        * gcc.dg/pr71518.c: New test.

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 1951 bytes --]

diff --git a/gcc/testsuite/gcc.dg/pr71518.c b/gcc/testsuite/gcc.dg/pr71518.c
new file mode 100644
index 0000000..6240ca8
--- /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 5ac34be..3777464 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);
     }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH PR71518] Adjust misalign for outer loops also.
  2016-07-06 12:59 [PATCH PR71518] Adjust misalign for outer loops also Yuri Rumyantsev
@ 2016-07-06 13:28 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-07-06 13:28 UTC (permalink / raw)
  To: Yuri Rumyantsev
  Cc: gcc-patches, Igor Zamyatin,
	Илья
	Энкович

On Wed, Jul 6, 2016 at 2:58 PM, Yuri Rumyantsev <ysrumyan@gmail.com> wrote:
> Hi All,
>
> Here is a simple patch which add missed misalign adjustment for outer loop.
>
> Bootstrapping and regression testing did not show any new failures.
>
> Is it OK for trunk?

Ok.

Richard.

> ChangeLog:
> 2016-07-06  Yuri Rumyantsev  <ysrumyan@gmail.com>
>
> 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/ChangeLog:
>         * gcc.dg/pr71518.c: New test.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-06 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-06 12:59 [PATCH PR71518] Adjust misalign for outer loops also Yuri Rumyantsev
2016-07-06 13:28 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).