Hi,

in propagate_vr_accross_jump_function, drop_tree_overflow should be after fold_convert. Attached patch changes this.

Bootstrapped and regression tested on x86_64-linux-gnu with no new regressions. Is this OK for trunk?

Thanks,
Kugan

gcc/testsuite/ChangeLog:

2016-12-09  Kugan Vivekanandarajah  <kug...@linaro.org>

        PR ipa/78721
        * gcc.dg/pr78721.c: New test.


gcc/ChangeLog:

2016-12-09  Kugan Vivekanandarajah  <kug...@linaro.org>

        PR ipa/78721
        * ipa-cp.c (propagate_vr_accross_jump_function): drop_tree_overflow
        after fold_convert.










diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 2ec671f..4ec7cc5 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -1895,9 +1895,9 @@ propagate_vr_accross_jump_function (cgraph_edge *cs,
       tree val = ipa_get_jf_constant (jfunc);
       if (TREE_CODE (val) == INTEGER_CST)
        {
+         val = fold_convert (param_type, val);
          if (TREE_OVERFLOW_P (val))
            val = drop_tree_overflow (val);
-         val = fold_convert (param_type, val);
          jfunc->vr_known = true;
          jfunc->m_vr.type = VR_RANGE;
          jfunc->m_vr.min = val;
diff --git a/gcc/testsuite/gcc.dg/pr78721.c b/gcc/testsuite/gcc.dg/pr78721.c
index e69de29..fb2ffc3 100644
--- a/gcc/testsuite/gcc.dg/pr78721.c
+++ b/gcc/testsuite/gcc.dg/pr78721.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+int a, b, c;
+
+int fn1 (char e, char f)
+{
+  return !f || (e && f == 1);
+}
+
+void fn2 (char e)
+{
+  while (b)
+    e = 0;
+  a = 128;
+  c = fn1 (e, a == e);
+}
+
+int main ()
+{
+  fn2 (0);
+  return 0;
+}

Reply via email to