On 7/2/2021 2:13 AM, Aldy Hernandez wrote:
On 7/2/21 12:20 AM, Jeff Law wrote:
On 6/28/2021 10:21 AM, Aldy Hernandez wrote:
+// Internal construct to help facilitate debugging of solver.
+#define DEBUG_SOLVER getenv("DEBUG")
Shouldn't this really be a property of what pass is using the solver
and whether or not the appropriate dump flag is on for that pass?
Whoops. This was a private construct used for debugging the solver.
I've changed it to:
+#define DEBUG_SOLVER (0 && dump_file)
I would probably argue that the #define should disappear and the code
should be checking the current dump state for the current pass. If you
don't want to keep the debugging output, then remove it :-) I think
that can be handled in a follow-up patch.
+
+// Return the range of the result of PHI in R.
+
+void
+path_solver::ssa_range_in_phi (irange &r, gphi *phi)
+{
+ tree name = gimple_phi_result (phi);
+ basic_block bb = gimple_bb (phi);
+
+ // We experimented with querying ranger's range_on_entry here, but
+ // the performance penalty was too high, for hardly any
improvements.
+ if (at_entry ())
+ {
+ r.set_varying (TREE_TYPE (name));
+ return;
+ }
+
+ basic_block prev = prev_bb ();
+ edge e_in = find_edge (prev, bb);
+ for (size_t i = 0; i < gimple_phi_num_args (phi); ++i)
It's probably not important in practice, but you're going to end up
calling gimple_phi_num_args every iteration of this loop. It's value
isn't generally subject to LICM.
I was just following standard practice:
Yea. I doubt we're at all consistent with that. In fact, I'd bet I'm a
serial offender. We should probably try to do better through since
we're going to get a function call every loop iteration when the value
is invariant. FIxing other instances should be considered
pre-approved. ISTM a separate patch for fix that up would be fine.
Oh, and showing the # of instances in FOR statements is useful, but you
didn't show the other cases (ie, where we shove it into a variable and
use that as a loop bound). I'd estimate there's probably 40-50 of
those. So it's really a mixed bag.
OK.
Jeff