]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Some more predicate analysis TLC
authorRichard Biener <rguenther@suse.de>
Wed, 24 Aug 2022 08:08:17 +0000 (10:08 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 24 Aug 2022 09:47:05 +0000 (11:47 +0200)
This limits the simple control dep also to the cd_root plus avoids
filling the lazily computed PHI def predicate in the early out path
which would leave it not simplified and normalized if it were
re-used.  It also avoids computing the use predicates when the
post-dominance early out doesn't need it.  It also syncs
predicate::use_cannot_happen with init_from_phi_def, adding the
missing PHI edge to the computed chains (the simple control dep
code already adds it).

* gimple-predicate-analysis.cc (predicate::use_cannot_happen):
Do simple_control_dep_chain only up to cd_root, add the PHI
operand edge to the chains like init_from_phi_def does.
(predicate::is_use_guarded): Speedup early out, avoid half-way
initializing the PHI def predicate.

gcc/gimple-predicate-analysis.cc

index ea81daacd4f6ad78b20b59a98c6c63c2c4d7a52e..f7170a8d068269f6c63e6d51ad6f5c48273ebf4b 100644 (file)
@@ -1322,10 +1322,15 @@ predicate::use_cannot_happen (gphi *phi, unsigned opnds)
          /* If compute_control_dep_chain bailed out due to limits
             build a partial sparse path using dominators.  Collect
             only edges whose predicates are always true when reaching E.  */
-         simple_control_dep_chain (dep_chains[0],
-                                   ENTRY_BLOCK_PTR_FOR_FN (cfun), e);
+         simple_control_dep_chain (dep_chains[0], cd_root, e);
          num_chains++;
        }
+      /* Update the chains with the phi operand edge.  */
+      else if (EDGE_COUNT (e->src->succs) > 1)
+       {
+         for (unsigned j = 0; j < num_chains; j++)
+           dep_chains[j].safe_push (e);
+       }
 
       if (DEBUG_PREDICATE_ANALYZER && dump_file)
        {
@@ -1916,24 +1921,14 @@ predicate::is_use_guarded (gimple *use_stmt, basic_block use_bb,
   /* The basic block where the PHI is defined.  */
   basic_block def_bb = gimple_bb (phi);
 
+  if (dominated_by_p (CDI_POST_DOMINATORS, def_bb, use_bb))
+    /* The use is not guarded.  */
+    return false;
+
   /* Try to build the predicate expression under which the PHI flows
      into its use.  This will be empty if the PHI is defined and used
      in the same bb.  */
   predicate use_preds (def_bb, use_bb, m_eval);
-
-  if (dominated_by_p (CDI_POST_DOMINATORS, def_bb, use_bb))
-    {
-      if (is_empty ())
-       {
-         /* Lazily initialize *THIS from the PHI and build its use
-            expression.  */
-         init_from_phi_def (phi);
-       }
-
-      /* The use is not guarded.  */
-      return false;
-    }
-
   if (use_preds.is_empty ())
     return false;
 
@@ -1955,9 +1950,7 @@ predicate::is_use_guarded (gimple *use_stmt, basic_block use_bb,
     {
       /* Lazily initialize *THIS from PHI.  */
       if (!init_from_phi_def (phi))
-       {
-         return false;
-       }
+       return false;
 
       simplify (phi);
       normalize (phi);