The following addresses PTA quadratic compile-time in basically
random cases, namely if constraints are ordered in a way that
we unify ESCAPED to a regular variable. That drops is_artificial_var
handling from solving and bleeds the ESCAPED results everywhere.
Simply refuse merging artificial vars elsewhere.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/127758
* pta-andersen.cc (unite): Refuse to merge an artificial
variable into another.
---
gcc/pta-andersen.cc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/gcc/pta-andersen.cc b/gcc/pta-andersen.cc
index e8cb77020a6..464c54b3f76 100644
--- a/gcc/pta-andersen.cc
+++ b/gcc/pta-andersen.cc
@@ -149,7 +149,11 @@ static bool
unite (unsigned int to, unsigned int from)
{
gcc_checking_assert (to < graph->size && from < graph->size);
- if (to != from && graph->rep[from] != to)
+ if (to != from
+ && graph->rep[from] != to
+ /* Do not merge an artificial variable into another, this will
+ explode solution sets unnecessarily. */
+ && (from >= FIRST_REF_NODE || !get_varinfo (from)->is_artificial_var))
{
graph->rep[from] = to;
return true;
--
2.51.0