diff mbox

[PR80153] Part2, Check base pointer directly

Message ID VI1PR0802MB21763067A799362C9E186994E7010@VI1PR0802MB2176.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Bin Cheng April 10, 2017, 2:35 p.m. UTC
Hi,
This is part 2 patch fixing PR80153, because we now explicitly rely on behavior that the first element being base pointer of pointer type aff_tree.  The original code removes base pointer from aff_tree without updating aff_tree's type.  Actually, we don't need to use tree-affine at all, we can directly look into pointer_plus_expr.

Bootstrap and test on x86_64 and AArch64 ongoing.  Is it OK if no failures?

Thanks,
bin

2017-04-07  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/80153
	* tree-ssa-loop-ivopts.c (add_iv_candidate_for_use): Check and 
	remove POINTER_PLUS_EXPR's base part directly, rather than through
	aff_tree.

Comments

Richard Biener April 10, 2017, 3:38 p.m. UTC | #1
On Mon, Apr 10, 2017 at 4:35 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This is part 2 patch fixing PR80153, because we now explicitly rely on behavior that the first element being base pointer of pointer type aff_tree.  The original code removes base pointer from aff_tree without updating aff_tree's type.  Actually, we don't need to use tree-affine at all, we can directly look into pointer_plus_expr.
>
> Bootstrap and test on x86_64 and AArch64 ongoing.  Is it OK if no failures?

Ok.

Thanks,
Richard.

> Thanks,
> bin
>
> 2017-04-07  Bin Cheng  <bin.cheng@arm.com>
>
>         PR tree-optimization/80153
>         * tree-ssa-loop-ivopts.c (add_iv_candidate_for_use): Check and
>         remove POINTER_PLUS_EXPR's base part directly, rather than through
>         aff_tree.
diff mbox

Patch

diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 036e041..4fc35fa 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -3335,41 +3335,20 @@  add_iv_candidate_for_use (struct ivopts_data *data, struct iv_use *use)
     }
 
   /* Record common candidate with base_object removed in base.  */
-  if (iv->base_object != NULL)
+  base = iv->base;
+  STRIP_NOPS (base);
+  if (iv->base_object != NULL && TREE_CODE (base) == POINTER_PLUS_EXPR)
     {
-      unsigned i;
-      aff_tree aff_base;
-      tree step, base_object = iv->base_object;
+      tree step = iv->step;
 
-      base = iv->base;
-      step = iv->step;
-      STRIP_NOPS (base);
       STRIP_NOPS (step);
-      STRIP_NOPS (base_object);
-      tree_to_aff_combination (base, TREE_TYPE (base), &aff_base);
-      for (i = 0; i < aff_base.n; i++)
-	{
-	  if (aff_base.elts[i].coef != 1)
-	    continue;
-
-	  if (operand_equal_p (aff_base.elts[i].val, base_object, 0))
-	    break;
-	}
-      if (i < aff_base.n)
-	{
-	  aff_combination_remove_elt (&aff_base, i);
-	  base = aff_combination_to_tree (&aff_base);
-	  basetype = TREE_TYPE (base);
-	  if (POINTER_TYPE_P (basetype))
-	    basetype = sizetype;
-
-	  step = fold_convert (basetype, step);
-	  record_common_cand (data, base, step, use);
-	  /* Also record common candidate with offset stripped.  */
-	  base = strip_offset (base, &offset);
-	  if (offset)
-	    record_common_cand (data, base, step, use);
-	}
+      base = TREE_OPERAND (base, 1);
+      step = fold_convert (sizetype, step);
+      record_common_cand (data, base, step, use);
+      /* Also record common candidate with offset stripped.  */
+      base = strip_offset (base, &offset);
+      if (offset)
+	record_common_cand (data, base, step, use);
     }
 
   /* At last, add auto-incremental candidates.  Make such variables