Patchwork Fix PR46036: if-conversion problem

login
register
mail settings
Submitter Sebastian Pop
Date Nov. 8, 2010, 9:22 p.m.
Message ID <AANLkTimtrwaYyrETBjMFZSz003MCP6C7oFi2Sc6e1skx@mail.gmail.com>
Download mbox | patch
Permalink /patch/70461/
State New
Headers show

Comments

Sebastian Pop - Nov. 8, 2010, 9:22 p.m.
Hi,

Here is a fix for PR46036 bootstrapped and tested on amd64-linux.
Ok for trunk?

Thanks,
Sebastian
Richard Guenther - Nov. 9, 2010, 10:20 a.m.
On Mon, 8 Nov 2010, Sebastian Pop wrote:

> Hi,
> 
> Here is a fix for PR46036 bootstrapped and tested on amd64-linux.
> Ok for trunk?

Ok.

Thanks,
Richard.

Patch

From ee9d3095a33df9aa6956c9a7d8782d9bb3fad85e Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Fri, 5 Nov 2010 16:57:00 -0500
Subject: [PATCH] Fix PR46036.

2010-11-04  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/46036
	* tree-if-conv.c (predicate_bbs): Call unshare_expr before
	add_to_dst_predicate_list.

	* gfortran.dg/lto/pr46036_0.f90: New.
---
 gcc/ChangeLog                               |    6 ++++++
 gcc/testsuite/ChangeLog                     |    5 +++++
 gcc/testsuite/gfortran.dg/lto/pr46036_0.f90 |   14 ++++++++++++++
 gcc/tree-if-conv.c                          |    2 +-
 4 files changed, 26 insertions(+), 1 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/lto/pr46036_0.f90

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b0618ac..d0b178a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@ 
+2010-11-04  Sebastian Pop  <sebastian.pop@amd.com>
+
+	PR tree-optimization/46036
+	* tree-if-conv.c (predicate_bbs): Call unshare_expr before
+	add_to_dst_predicate_list.
+
 2010-11-03  Uros Bizjak  <ubizjak@gmail.com>
 
 	PR middle-end/46292
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 89a0535..f296193 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@ 
+2010-11-04  Sebastian Pop  <sebastian.pop@amd.com>
+
+	PR tree-optimization/46036
+	* gfortran.dg/lto/pr46036_0.f90: New.
+
 2010-11-04  Jason Merrill  <jason@redhat.com>
 
 	* g++.dg/cpp0x/constexpr-access.C: New.
diff --git a/gcc/testsuite/gfortran.dg/lto/pr46036_0.f90 b/gcc/testsuite/gfortran.dg/lto/pr46036_0.f90
new file mode 100644
index 0000000..558c7ed
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/lto/pr46036_0.f90
@@ -0,0 +1,14 @@ 
+! { dg-lto-do link }
+! { dg-lto-options {{ -O -flto -ftree-vectorize }} }
+
+function no_of_edges(self) result(res)
+  integer(kind=kind(1)) :: edge_bit_string
+  integer(kind=kind(1)) :: res
+  integer(kind=kind(1)) :: e
+  do e = 0, 11
+     if (.not. btest(edge_bit_string,e)) cycle
+     res = res + 1
+  end do
+end function no_of_edges
+
+end program
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 2c334d9..5ee0a45 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -942,7 +942,7 @@  predicate_bbs (loop_p loop)
 						     &true_edge, &false_edge);
 
 		/* If C is true, then TRUE_EDGE is taken.  */
-		add_to_dst_predicate_list (loop, true_edge, cond, c);
+		add_to_dst_predicate_list (loop, true_edge, cond, unshare_expr (c));
 
 		/* If C is false, then FALSE_EDGE is taken.  */
 		c2 = invert_truthvalue_loc (loc, unshare_expr (c));
-- 
1.7.0.4