summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0287-PR-tree-optimization-49073.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0287-PR-tree-optimization-49073.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0287-PR-tree-optimization-49073.patch121
1 files changed, 121 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0287-PR-tree-optimization-49073.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0287-PR-tree-optimization-49073.patch
new file mode 100644
index 0000000000..98667d4438
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0287-PR-tree-optimization-49073.patch
@@ -0,0 +1,121 @@
1From 354414452478a90309fc78d4cec353cce51ac36d Mon Sep 17 00:00:00 2001
2From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
3Date: Fri, 20 May 2011 14:35:20 +0000
4Subject: [PATCH] PR tree-optimization/49073
5 * gimple-fold.c (and_comparisons_1, or_comparisons_1): Return
6 NULL if PHI argument is SSA_NAME, whose def_stmt is dominated
7 by the PHI.
8 * tree-ssa-ifcombine.c (tree_ssa_ifcombine): Calculate dominators.
9
10 * gcc.c-torture/execute/pr49073.c: New test.
11
12
13git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173951 138bc75d-0d04-0410-961f-82ee72b054a4
14
15index 1b82e12..6ff6f81 100644
16--- a/gcc/gimple-fold.c
17+++ b/gcc/gimple-fold.c
18@@ -1,5 +1,5 @@
19 /* Statement simplification on GIMPLE.
20- Copyright (C) 2010 Free Software Foundation, Inc.
21+ Copyright (C) 2010, 2011 Free Software Foundation, Inc.
22 Split out from tree-ssa-ccp.c.
23
24 This file is part of GCC.
25@@ -2185,8 +2185,19 @@ and_comparisons_1 (enum tree_code code1, tree op1a, tree op1b,
26 }
27 else if (TREE_CODE (arg) == SSA_NAME)
28 {
29- tree temp = and_var_with_comparison (arg, invert,
30- code2, op2a, op2b);
31+ tree temp;
32+ gimple def_stmt = SSA_NAME_DEF_STMT (arg);
33+ /* In simple cases we can look through PHI nodes,
34+ but we have to be careful with loops.
35+ See PR49073. */
36+ if (! dom_info_available_p (CDI_DOMINATORS)
37+ || gimple_bb (def_stmt) == gimple_bb (stmt)
38+ || dominated_by_p (CDI_DOMINATORS,
39+ gimple_bb (def_stmt),
40+ gimple_bb (stmt)))
41+ return NULL_TREE;
42+ temp = and_var_with_comparison (arg, invert, code2,
43+ op2a, op2b);
44 if (!temp)
45 return NULL_TREE;
46 else if (!result)
47@@ -2635,8 +2646,19 @@ or_comparisons_1 (enum tree_code code1, tree op1a, tree op1b,
48 }
49 else if (TREE_CODE (arg) == SSA_NAME)
50 {
51- tree temp = or_var_with_comparison (arg, invert,
52- code2, op2a, op2b);
53+ tree temp;
54+ gimple def_stmt = SSA_NAME_DEF_STMT (arg);
55+ /* In simple cases we can look through PHI nodes,
56+ but we have to be careful with loops.
57+ See PR49073. */
58+ if (! dom_info_available_p (CDI_DOMINATORS)
59+ || gimple_bb (def_stmt) == gimple_bb (stmt)
60+ || dominated_by_p (CDI_DOMINATORS,
61+ gimple_bb (def_stmt),
62+ gimple_bb (stmt)))
63+ return NULL_TREE;
64+ temp = or_var_with_comparison (arg, invert, code2,
65+ op2a, op2b);
66 if (!temp)
67 return NULL_TREE;
68 else if (!result)
69new file mode 100644
70index 0000000..92b923b
71--- /dev/null
72+++ b/gcc/testsuite/gcc.c-torture/execute/pr49073.c
73@@ -0,0 +1,26 @@
74+/* PR tree-optimization/49073 */
75+
76+extern void abort (void);
77+int a[] = { 1, 2, 3, 4, 5, 6, 7 }, c;
78+
79+int
80+main ()
81+{
82+ int d = 1, i = 1;
83+ _Bool f = 0;
84+ do
85+ {
86+ d = a[i];
87+ if (f && d == 4)
88+ {
89+ ++c;
90+ break;
91+ }
92+ i++;
93+ f = (d == 3);
94+ }
95+ while (d < 7);
96+ if (c != 1)
97+ abort ();
98+ return 0;
99+}
100diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c
101index e23bb76..9063bfd 100644
102--- a/gcc/tree-ssa-ifcombine.c
103+++ b/gcc/tree-ssa-ifcombine.c
104@@ -1,5 +1,5 @@
105 /* Combining of if-expressions on trees.
106- Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
107+ Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
108 Contributed by Richard Guenther <rguenther@suse.de>
109
110 This file is part of GCC.
111@@ -625,6 +625,7 @@ tree_ssa_ifcombine (void)
112 int i;
113
114 bbs = blocks_in_phiopt_order ();
115+ calculate_dominance_info (CDI_DOMINATORS);
116
117 for (i = 0; i < n_basic_blocks - NUM_FIXED_BLOCKS; ++i)
118 {
119--
1201.7.0.4
121