Fix phi arg location in find_implicit_erroneous_behavior
authorTom de Vries <tom@codesourcery.com>
Thu, 20 Jul 2017 07:16:01 +0000 (07:16 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Thu, 20 Jul 2017 07:16:01 +0000 (07:16 +0000)
2017-07-20  Tom de Vries  <tom@codesourcery.com>

PR tree-optimization/81489
* gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior): Move
read of phi arg location to before loop that modifies phi.

From-SVN: r250378

gcc/ChangeLog
gcc/gimple-ssa-isolate-paths.c

index 499249b7d757707c7aee7108095e29664b0d8e4f..b6750e8401384828a4eea9f792246c3d999feabc 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-20  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/81489
+       * gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior): Move
+       read of phi arg location to before loop that modifies phi.
+
 2017-07-20  Naveen H.S  <Naveen.Hurugalawadi@cavium.com>
 
        * match.pd (((m1 >/</>=/<= m2) * d -> (m1 >/</>=/<= m2) ? d : 0):
index 7ad39b4e09bb9f69189ba3d40c270bb116725709..fbc41057463c18c40e446fa4f1b99d11326c3305 100644 (file)
@@ -442,6 +442,8 @@ find_implicit_erroneous_behavior (void)
              if (!integer_zerop (op))
                continue;
 
+             location_t phi_arg_loc = gimple_phi_arg_location (phi, i);
+
              /* We've got a NULL PHI argument.  Now see if the
                 PHI's result is dereferenced within BB.  */
              FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs)
@@ -454,7 +456,7 @@ find_implicit_erroneous_behavior (void)
 
                  location_t loc = gimple_location (use_stmt)
                    ? gimple_location (use_stmt)
-                   : gimple_phi_arg_location (phi, i);
+                   : phi_arg_loc;
 
                  if (stmt_uses_name_in_undefined_way (use_stmt, lhs, loc))
                    {