https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85598

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
While it might look too specialized, it actually triggered (i.e. narrowed the
range info) in 105473 cases during x86_64-linux bootstrap + regtest.
--- gcc/tree-ssa-phiopt.c.jj    2018-11-22 18:45:54.670669434 +0100
+++ gcc/tree-ssa-phiopt.c       2018-11-22 18:49:01.225590302 +0100
@@ -266,7 +266,14 @@ tree_ssa_phiopt_worker (bool do_store_el
                            min2 = wi::add (min2, 1);
                          else
                            max2 = wi::sub (max2, 1);
+{
+FILE *f = fopen ("/tmp/phiopt", "a");
+fprintf (f, "@ %d %s %s\n", (int) BITS_PER_WORD, main_input_filename ?
main_input_filename : "-", current_function_name ());
+dump_ssaname_info_to_file (f, phi_lhs, 0);
                          set_range_info (phi_lhs, VR_RANGE, min2, max2);
+dump_ssaname_info_to_file (f, phi_lhs, 0);
+fclose (f);
+}
                        }
                    }
            }
hack is what I've used to gather this info.
Thinking about it, it might be better to stick it somewhere else, where we walk
PHI arguments (it would be cheaper to look for all phi arguments constants
except one SSA_NAME from edge that ends in GIMPLE_COND comparison of that
against constant).
That said, I'm not really familiar with the evrp analyzers and how expensive
they are, ideally this should be kept as something super cheap.  And don't
really understand how union_ would be helpful, what we want here is not union,
but narrowing the range.  Recomputing the range from scratch is possible but it
would be still better to compare it against the already recorded range and only
narrow it, never extend.

Reply via email to