diff mbox

Fix PR78721

Message ID d9f511d1-844b-086f-9f60-26280a46e2ae@linaro.org
State New
Headers show

Commit Message

Kugan Vivekanandarajah Dec. 9, 2016, 4:25 a.m. UTC
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  <kuganv@linaro.org>

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


gcc/ChangeLog:

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

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

Comments

Richard Biener Dec. 9, 2016, 10:11 a.m. UTC | #1
On Fri, Dec 9, 2016 at 5:25 AM, kugan <kugan.vivekanandarajah@linaro.org> wrote:
> 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?


Ok.

Richard.

> Thanks,

> Kugan

>

> gcc/testsuite/ChangeLog:

>

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

>

>         PR ipa/78721

>         * gcc.dg/pr78721.c: New test.

>

>

> gcc/ChangeLog:

>

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

>

>         PR ipa/78721

>         * ipa-cp.c (propagate_vr_accross_jump_function): drop_tree_overflow

>         after fold_convert.

>

>

>

>

>

>

>

>

>

>
diff mbox

Patch

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;
+}