re PR tree-optimization/71230 (ICE : in zero_one_operation, at tree-ssa-reassoc.c...
authorRichard Biener <rguenther@suse.de>
Mon, 23 May 2016 14:09:35 +0000 (14:09 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 23 May 2016 14:09:35 +0000 (14:09 +0000)
2016-05-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71230
* tree-ssa-reassoc.c (acceptable_pow_call): Move initial condition...
(try_special_add_to_ops): ... here.  Always test for single-use.

* gfortran.dg/pr71230-1.f90: New testcase.
* gfortran.dg/pr71230-2.f90: Likewise.

From-SVN: r236591

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr71230-1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr71230-2.f90 [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index 4218dab37bb9a77ef0313518ccb468576b3ad411..d85700a6bb4636e0f76e87b3eb78fedaa69bef1c 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71230
+       * tree-ssa-reassoc.c (acceptable_pow_call): Move initial condition...
+       (try_special_add_to_ops): ... here.  Always test for single-use.
+
 2016-05-23  Martin Jambor  <mjambor@suse.cz>
 
        * hsa-gen.c (gen_hsa_insns_for_switch_stmt): Create an empty
index b0ba70f85c79ad72caec2e8df90cbe5d74f4fd45..2cffaa1a85b6ada7d6de9851b46562491233c625 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71230
+       * gfortran.dg/pr71230-1.f90: New testcase.
+       * gfortran.dg/pr71230-2.f90: Likewise.
+
 2016-05-23  Venkataramanan Kumar  <venkataramanan.kumar@amd.com>
 
        * gcc.dg/vect/bb-slp-19.c:  Remove XFAIL. 
diff --git a/gcc/testsuite/gfortran.dg/pr71230-1.f90 b/gcc/testsuite/gfortran.dg/pr71230-1.f90
new file mode 100644 (file)
index 0000000..6acfea1
--- /dev/null
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! { dg-options "-O2 -fbounds-check -ffast-math" }
+  FUNCTION pw_integral_aa ( cc ) RESULT ( integral_value )
+    COMPLEX(KIND=8), DIMENSION(:), POINTER :: cc
+    integral_value = accurate_sum ( CONJG ( cc (:) ) * cc (:) )
+  END FUNCTION pw_integral_aa
diff --git a/gcc/testsuite/gfortran.dg/pr71230-2.f90 b/gcc/testsuite/gfortran.dg/pr71230-2.f90
new file mode 100644 (file)
index 0000000..78df649
--- /dev/null
@@ -0,0 +1,67 @@
+! { dg-do compile }
+! { dg-options "-O2 -ffast-math" }
+
+MODULE xc_b97
+  INTEGER, PARAMETER :: dp=8
+  PRIVATE
+  PUBLIC :: b97_lsd_eval
+CONTAINS
+  SUBROUTINE b97_lsd_eval(rho_set,deriv_set,grad_deriv,b97_params)
+    INTEGER, INTENT(in)                      :: grad_deriv
+    INTEGER                                  :: handle, npoints, param, stat
+    LOGICAL                                  :: failure
+    REAL(kind=dp)                            :: epsilon_drho, epsilon_rho, &
+                                                scale_c, scale_x
+    REAL(kind=dp), DIMENSION(:, :, :), POINTER :: dummy, e_0, e_ndra, &
+      e_ndra_ndra, e_ndra_ndrb, e_ndra_ra, e_ndra_rb, e_ndrb, e_ndrb_ndrb, &
+      e_ndrb_ra, e_ndrb_rb, e_ra, e_ra_ra, e_ra_rb, e_rb, e_rb_rb, &
+      norm_drhoa, norm_drhob, rhoa, rhob
+    IF (.NOT. failure) THEN
+       CALL b97_lsd_calc(&
+            rhoa=rhoa, rhob=rhob, norm_drhoa=norm_drhoa,&
+            norm_drhob=norm_drhob, e_0=e_0, &
+            e_ra=e_ra, e_rb=e_rb, &
+            e_ndra=e_ndra, e_ndrb=e_ndrb, &
+            e_ra_ra=e_ra_ra, e_ra_rb=e_ra_rb, e_rb_rb=e_rb_rb,&
+            e_ra_ndra=e_ndra_ra, e_ra_ndrb=e_ndrb_ra, &
+            e_rb_ndrb=e_ndrb_rb, e_rb_ndra=e_ndra_rb,&
+            e_ndra_ndra=e_ndra_ndra, e_ndrb_ndrb=e_ndrb_ndrb,&
+            e_ndra_ndrb=e_ndra_ndrb,&
+            grad_deriv=grad_deriv, npoints=npoints, &
+            epsilon_rho=epsilon_rho,epsilon_drho=epsilon_drho,&
+            param=param,scale_c_in=scale_c,scale_x_in=scale_x)
+    END IF
+  END SUBROUTINE b97_lsd_eval
+  SUBROUTINE b97_lsd_calc(rhoa, rhob, norm_drhoa, norm_drhob,&
+       e_0, e_ra, e_rb, e_ndra, e_ndrb, &
+       e_ra_ndra,e_ra_ndrb, e_rb_ndra, e_rb_ndrb,&
+       e_ndra_ndra, e_ndrb_ndrb, e_ndra_ndrb, &
+       e_ra_ra, e_ra_rb, e_rb_rb,&
+       grad_deriv,npoints,epsilon_rho,epsilon_drho, &
+       param, scale_c_in, scale_x_in)
+    REAL(kind=dp), DIMENSION(*), INTENT(in)  :: rhoa, rhob, norm_drhoa, &
+                                                norm_drhob
+    REAL(kind=dp), DIMENSION(*), INTENT(inout) :: e_0, e_ra, e_rb, e_ndra, &
+      e_ndrb, e_ra_ndra, e_ra_ndrb, e_rb_ndra, e_rb_ndrb, e_ndra_ndra, &
+      e_ndrb_ndrb, e_ndra_ndrb, e_ra_ra, e_ra_rb, e_rb_rb
+    INTEGER, INTENT(in)                      :: grad_deriv, npoints
+    REAL(kind=dp), INTENT(in)                :: epsilon_rho, epsilon_drho
+    INTEGER, INTENT(in)                      :: param
+    REAL(kind=dp), INTENT(in)                :: scale_c_in, scale_x_in
+    REAL(kind=dp) :: A_1, A_2, A_3, alpha_1_1, alpha_1_2, alpha_1_3, alpha_c, &
+      rs_b, rs_brhob, rs_brhobrhob, rsrhoa, rsrhoarhoa, rsrhoarhob, rsrhob, &
+      t1014, t102, t1047, t1049, t105, t106, t107
+      rsrhoa = -t4 * t212 * t208 / 0.12e2_dp
+      t235 = t224 * rsrhoa / 0.2e1_dp + beta_2_1 * rsrhoa + & 
+          0.3e1_dp / 0.2e1_dp * t228 * rsrhoa + t50 * t48 * rsrhoa * t232
+      t237 = t235 * t236
+      e_c_u_0rhoa = -0.2e1_dp * t216 * rsrhoa * t56 + t222 * t237
+      epsilon_c_unifrhoa = e_c_u_0rhoa + t285 * t110 + t287 * t110 - &
+          t293 + t295 * t108 + t297 * t108 + t301
+      e_lsda_c_abrhoa = epsilon_c_unifrhoa * rho + epsilon_c_unif - e_lsda_c_arhoa
+      exc_rhoa = scale_x * (e_lsda_x_arhoa * gx_a + e_lsda_x_a * gx_arhoa) + &
+          scale_c * (e_lsda_c_abrhoa * gc_ab + e_lsda_c_ab * gc_abrhoa + &
+          e_lsda_c_arhoa * gc_a + e_lsda_c_a * gc_arhoa)
+      e_ra(ii)=e_ra(ii)+exc_rhoa
+  END SUBROUTINE b97_lsd_calc
+END MODULE xc_b97
index 798931fee7a3909d04806228327cb9390022647b..596920f5197ab20663e8bb7c50698352e78c1fec 100644 (file)
@@ -4271,17 +4271,11 @@ break_up_subtract (gimple *stmt, gimple_stmt_iterator *gsip)
    If any of these conditions does not hold, return FALSE.  */
 
 static bool
-acceptable_pow_call (gimple *stmt, tree *base, HOST_WIDE_INT *exponent)
+acceptable_pow_call (gcall *stmt, tree *base, HOST_WIDE_INT *exponent)
 {
   tree arg1;
   REAL_VALUE_TYPE c, cint;
 
-  if (!reassoc_insert_powi_p
-      || !flag_unsafe_math_optimizations
-      || !is_gimple_call (stmt)
-      || !has_single_use (gimple_call_lhs (stmt)))
-    return false;
-
   switch (gimple_call_combined_fn (stmt))
     {
     CASE_CFN_POW:
@@ -4340,11 +4334,15 @@ try_special_add_to_ops (vec<operand_entry *> *ops,
   tree base = NULL_TREE;
   HOST_WIDE_INT exponent = 0;
 
-  if (TREE_CODE (op) != SSA_NAME)
+  if (TREE_CODE (op) != SSA_NAME
+      || ! has_single_use (op))
     return false;
 
   if (code == MULT_EXPR
-      && acceptable_pow_call (def_stmt, &base, &exponent))
+      && reassoc_insert_powi_p
+      && flag_unsafe_math_optimizations
+      && is_gimple_call (def_stmt)
+      && acceptable_pow_call (as_a <gcall *> (def_stmt), &base, &exponent))
     {
       add_repeat_to_ops_vec (ops, base, exponent);
       gimple_set_visited (def_stmt, true);