https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128905
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
it starts with fold_using_range::range_of_range_op
if (src.get_operand (range1, op1))
{
if (!op2)
...
else if (src.get_operand (range2, op2))
{
a simple
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 5e8ef0af1b7..6c94c86bf56 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -836,8 +836,11 @@ fold_using_range::range_of_range_op (vrange &r,
src.register_relation (s, rel, lhs, op1);
}
}
- else if (src.get_operand (range2, op2))
+ else if (op1 == op2
+ || src.get_operand (range2, op2))
{
+ if (op1 == op2)
+ range2 = range1;
relation_kind rel = src.query_relation (op1, op2);
if (dump_file && (dump_flags & TDF_DETAILS) && rel != VREL_VARYING)
{
helps, but I guess the relation query can also be short-cut/simplified.
Leaving to Andrew.
The above might not be enough when changing the testcase to
d = (d + 1) * d or so, there's still going to be many paths through
the SSA web and there doesn't seem to be a limit in place tracking this
or a way where the recursive processing of operands above get a fast
"cache hit" or so.