Hi,
In evaluate_conditions_for_known_args we use range_fold_unary_expr and
range_fold_binary_expr to produce value ranges of the expression.
However the expression also may contain ternary COND_EXPR on which we
ICE.  I did not find interface to do similar folding easily on ternary
exprs and since it is so rare case, i guess we can just punt and give up
on producing it.

Bootstrapped/regtsted x86_64-linux, OK?

gcc/ChangeLog:

2021-12-12  Jan Hubicka  <hubi...@ucw.cz>

        * ipa-fnsummary.c (evaluate_conditions_for_known_args): Do not ICE
        on ternary expression.

gcc/testsuite/ChangeLog:

2021-12-12  Jan Hubicka  <hubi...@ucw.cz>

        * gcc.c-torture/compile/pr103513.c: New test.

diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
index 6c1cdf17e47..cb3c198ec0c 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -513,7 +513,7 @@ evaluate_conditions_for_known_args (struct cgraph_node 
*node,
                                              op->index ? &vr : &op0);
                    }
                  else
-                   gcc_unreachable ();
+                   res.set_varying (op->type);
                  type = op->type;
                  vr = res;
                }
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr103513.c 
b/gcc/testsuite/gcc.c-torture/compile/pr103513.c
new file mode 100644
index 00000000000..ca876a9816c
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr103513.c
@@ -0,0 +1,8 @@
+int a;
+void b(int c) {
+  int d = 3;
+  d ^= c < 2;
+  if (d < 3 && a)
+    while (1)
+      b(!a);
+}

Reply via email to