OSDN Git Service

2010-04-19 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 19 Apr 2010 15:17:26 +0000 (15:17 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 19 Apr 2010 15:17:26 +0000 (15:17 +0000)
PR tree-optimization/43796
* tree-vrp.c (adjust_range_with_scev): Lookup init and step
from SCEV in the lattice.
(vrp_visit_phi_node): Dump change.

* gfortran.dg/pr43796.f90: New testcase.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr43796.f90 [new file with mode: 0644]
gcc/tree-vrp.c

index a198056..273d492 100644 (file)
@@ -1,5 +1,12 @@
 2010-04-19  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/43796
+       * tree-vrp.c (adjust_range_with_scev): Lookup init and step
+       from SCEV in the lattice.
+       (vrp_visit_phi_node): Dump change.
+
+2010-04-19  Richard Guenther  <rguenther@suse.de>
+
        * configure.ac: Fix quoting around elf_getshstrndx ABI check.
        * configure: Re-generated.
 
index d13ba3a..c553fe0 100644 (file)
@@ -1,5 +1,10 @@
 2010-04-19  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/43796
+       * gfortran.dg/pr43796.f90: New testcase.
+
+2010-04-19  Richard Guenther  <rguenther@suse.de>
+
        PR tree-optimization/43783
        * gcc.c-torture/execute/pr43783.c: New testcase.
 
diff --git a/gcc/testsuite/gfortran.dg/pr43796.f90 b/gcc/testsuite/gfortran.dg/pr43796.f90
new file mode 100644 (file)
index 0000000..2e98d7c
--- /dev/null
@@ -0,0 +1,51 @@
+! { dg-do compile }
+! { dg-options "-O2 -fcheck=bounds" }
+
+    FUNCTION F06FKFN(N,W,INCW,X,INCX)
+       IMPLICIT NONE
+       INTEGER, PARAMETER :: WP = KIND(0.0D0)
+       REAL (KIND=WP)                  :: F06FKFN
+       REAL (KIND=WP), PARAMETER       :: ONE = 1.0E+0_WP
+       REAL (KIND=WP), PARAMETER       :: ZERO = 0.0E+0_WP
+       INTEGER, INTENT (IN)            :: INCW, INCX, N
+       REAL (KIND=WP), INTENT (IN)     :: W(*), X(*)
+       REAL (KIND=WP)                  :: ABSYI, NORM, SCALE, SSQ
+       INTEGER                         :: I, IW, IX
+       REAL (KIND=WP), EXTERNAL        :: F06BMFN
+       INTRINSIC                          ABS, SQRT
+       IF (N<1) THEN
+          NORM = ZERO
+       ELSE IF (N==1) THEN
+          NORM = SQRT(W(1))*ABS(X(1))
+       ELSE
+          IF (INCW>0) THEN
+             IW = 1
+          ELSE
+             IW = 1 - (N-1)*INCW
+          END IF
+          IF (INCX>0) THEN
+             IX = 1
+          ELSE
+             IX = 1 - (N-1)*INCX
+          END IF
+          SCALE = ZERO
+          SSQ = ONE
+          DO I = 1, N
+             IF ((W(IW)/=ZERO) .AND. (X(IX)/=ZERO)) THEN
+                ABSYI = SQRT(W(IW))*ABS(X(IX))
+                IF (SCALE<ABSYI) THEN
+                   SSQ = 1 + SSQ*(SCALE/ABSYI)**2
+                   SCALE = ABSYI
+                ELSE
+                   SSQ = SSQ + (ABSYI/SCALE)**2
+                END IF
+             END IF
+             IW = IW + INCW
+             IX = IX + INCX
+          END DO
+          NORM = F06BMFN(SCALE,SSQ)
+       END IF
+       F06FKFN = NORM
+       RETURN
+    END FUNCTION F06FKFN
+
index 3b22948..b23132c 100644 (file)
@@ -3153,7 +3153,7 @@ static void
 adjust_range_with_scev (value_range_t *vr, struct loop *loop,
                        gimple stmt, tree var)
 {
-  tree init, step, chrec, tmin, tmax, min, max, type;
+  tree init, step, chrec, tmin, tmax, min, max, type, tem;
   enum ev_direction dir;
 
   /* TODO.  Don't adjust anti-ranges.  An anti-range may provide
@@ -3174,7 +3174,13 @@ adjust_range_with_scev (value_range_t *vr, struct loop *loop,
     return;
 
   init = initial_condition_in_loop_num (chrec, loop->num);
+  tem = op_with_constant_singleton_value_range (init);
+  if (tem)
+    init = tem;
   step = evolution_part_in_loop_num (chrec, loop->num);
+  tem = op_with_constant_singleton_value_range (step);
+  if (tem)
+    step = tem;
 
   /* If STEP is symbolic, we can't know whether INIT will be the
      minimum or maximum value in the range.  Also, unless INIT is
@@ -6432,7 +6438,18 @@ vrp_visit_phi_node (gimple phi)
   /* If the new range is different than the previous value, keep
      iterating.  */
   if (update_value_range (lhs, &vr_result))
-    return SSA_PROP_INTERESTING;
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       {
+         fprintf (dump_file, "Found new range for ");
+         print_generic_expr (dump_file, lhs, 0);
+         fprintf (dump_file, ": ");
+         dump_value_range (dump_file, &vr_result);
+         fprintf (dump_file, "\n\n");
+       }
+
+      return SSA_PROP_INTERESTING;
+    }
 
   /* Nothing changed, don't add outgoing edges.  */
   return SSA_PROP_NOT_INTERESTING;