OSDN Git Service

PR tree-optimization/19590
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jun 2007 17:06:05 +0000 (17:06 +0000)
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jun 2007 17:06:05 +0000 (17:06 +0000)
* tree-vrp.c (adjust_range_with_scev): Set the range when the result
of scev is a constant.
* gcc/testsuite/gcc.dg/tree-ssa/pr19590.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125925 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr19590.c [new file with mode: 0644]
gcc/tree-vrp.c

index 781a421..17997e9 100644 (file)
@@ -1,3 +1,10 @@
+2007-06-21  Sebastian Pop  <sebpop@gmail.com>
+
+       PR tree-optimization/19590
+       * tree-vrp.c (adjust_range_with_scev): Set the range when the result
+       of scev is a constant.
+       * gcc/testsuite/gcc.dg/tree-ssa/pr19590.c: New.
+
 2007-06-21  Kenneth Zadeck <zadeck@naturalbridge.com>
 
         * df-problems.c (df_note_bb_compute): Made computation of live
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c
new file mode 100644 (file)
index 0000000..1be1119
--- /dev/null
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-ivopts" } */
+
+void vnum_test8(int *data) 
+{ 
+  int i; 
+  int stop = data[3]; 
+  int m = data[4]; 
+  int n = m; 
+  for (i=1; i<stop; i++) { 
+    int k = data[2]; 
+    data[k] = 2; 
+    data[0] = m - n; 
+    k = data[1]; 
+    m = m + k; 
+    n = n + k; 
+  } 
+} 
+
+/* Using the SCEV analysis, this loop should be transformed to:
+
+   | void vnum_result8(int *data) 
+   |{ 
+   |  int i; 
+   |  int stop = data[3]; 
+   |  for (i=1; i<stop; i++) { 
+   |    int k = data[2]; 
+   |    data[k] = 2; 
+   |    data[0] = 0; 
+   |  } 
+   |}
+
+*/
+
+/* { dg-final { scan-tree-dump-times "= 0;" 1 "ivopts"} } */
+/* { dg-final { scan-tree-dump-times "= 2;" 1 "ivopts"} } */
+/* { dg-final { cleanup-tree-dump "ivopts" } }  */
index 937a76b..06931f1 100644 (file)
@@ -2638,6 +2638,14 @@ adjust_range_with_scev (value_range_t *vr, struct loop *loop, tree stmt,
     return;
 
   chrec = instantiate_parameters (loop, analyze_scalar_evolution (loop, var));
+
+  /* Like in PR19590, scev can return a constant function.  */
+  if (is_gimple_min_invariant (chrec))
+    {
+      set_value_range (vr, VR_RANGE, chrec, chrec, vr->equiv);
+      return;
+    }
+
   if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
     return;