]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Always do PHI analysis and before loop analysis.
authorAndrew MacLeod <amacleod@redhat.com>
Wed, 13 Sep 2023 14:09:16 +0000 (10:09 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Fri, 15 Sep 2023 14:08:25 +0000 (10:08 -0400)
PHI analysis wasn't being done if loop analysis found a value.  Always
do the PHI analysis, and run it for an iniital value before invoking
loop analysis.

* gimple-range-fold.cc (fold_using_range::range_of_phi): Always
run phi analysis, and do it before loop analysis.

gcc/gimple-range-fold.cc

index 03805d88d9b33cbe78d4511a89b8bb9ebcaf6c4a..d1945ccb554f93c6f076176063bce7e6194c31ce 100644 (file)
@@ -939,7 +939,32 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src)
        }
     }
 
-  bool loop_info_p = false;
+  // If PHI analysis is available, see if there is an iniital range.
+  if (phi_analysis_available_p ()
+      && irange::supports_p (TREE_TYPE (phi_def)))
+    {
+      phi_group *g = (phi_analysis())[phi_def];
+      if (g && !(g->range ().varying_p ()))
+       {
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           {
+             fprintf (dump_file, "PHI GROUP query for ");
+             print_generic_expr (dump_file, phi_def, TDF_SLIM);
+             fprintf (dump_file, " found : ");
+             g->range ().dump (dump_file);
+             fprintf (dump_file, " and adjusted original range from :");
+             r.dump (dump_file);
+           }
+         r.intersect (g->range ());
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           {
+             fprintf (dump_file, " to :");
+             r.dump (dump_file);
+             fprintf (dump_file, "\n");
+           }
+       }
+    }
+
   // If SCEV is available, query if this PHI has any known values.
   if (scev_initialized_p ()
       && !POINTER_TYPE_P (TREE_TYPE (phi_def)))
@@ -962,32 +987,6 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src)
                  fprintf (dump_file, "\n");
                }
              r.intersect (loop_range);
-             loop_info_p = true;
-           }
-       }
-    }
-
-  if (!loop_info_p && phi_analysis_available_p ()
-      && irange::supports_p (TREE_TYPE (phi_def)))
-    {
-      phi_group *g = (phi_analysis())[phi_def];
-      if (g && !(g->range ().varying_p ()))
-       {
-         if (dump_file && (dump_flags & TDF_DETAILS))
-           {
-             fprintf (dump_file, "PHI GROUP query for ");
-             print_generic_expr (dump_file, phi_def, TDF_SLIM);
-             fprintf (dump_file, " found : ");
-             g->range ().dump (dump_file);
-             fprintf (dump_file, " and adjusted original range from :");
-             r.dump (dump_file);
-           }
-         r.intersect (g->range ());
-         if (dump_file && (dump_flags & TDF_DETAILS))
-           {
-             fprintf (dump_file, " to :");
-             r.dump (dump_file);
-             fprintf (dump_file, "\n");
            }
        }
     }