Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in src/patchsets/gcc/4.6.1/gentoo: 39_all_cond-store-pr452445.patch README.history
Date: Sun, 25 Nov 2012 03:06:10
Message-Id: 20121125030545.7A0B220C9F@flycatcher.gentoo.org
1 vapier 12/11/25 03:05:45
2
3 Modified: README.history
4 Added: 39_all_cond-store-pr452445.patch
5 Log:
6 add fix from upstream for bad code gen with conditional stores PR52445 #439432
7
8 Revision Changes Path
9 1.12 src/patchsets/gcc/4.6.1/gentoo/README.history
10
11 file : http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/gcc/4.6.1/gentoo/README.history?rev=1.12&view=markup
12 plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/gcc/4.6.1/gentoo/README.history?rev=1.12&content-type=text/plain
13 diff : http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/gcc/4.6.1/gentoo/README.history?r1=1.11&r2=1.12
14
15 Index: README.history
16 ===================================================================
17 RCS file: /var/cvsroot/gentoo/src/patchsets/gcc/4.6.1/gentoo/README.history,v
18 retrieving revision 1.11
19 retrieving revision 1.12
20 diff -u -r1.11 -r1.12
21 --- README.history 22 Nov 2012 04:02:46 -0000 1.11
22 +++ README.history 25 Nov 2012 03:05:45 -0000 1.12
23 @@ -1,5 +1,6 @@
24 1.2 [pending]
25 - 03_all_java-nomulti.patch
26 + + 39_all_cond-store-pr452445.patch
27
28 1.1 27 Sep 2011
29 + 05_all_gcc-4.6.x-siginfo.patch
30
31
32
33 1.1 src/patchsets/gcc/4.6.1/gentoo/39_all_cond-store-pr452445.patch
34
35 file : http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/gcc/4.6.1/gentoo/39_all_cond-store-pr452445.patch?rev=1.1&view=markup
36 plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/gcc/4.6.1/gentoo/39_all_cond-store-pr452445.patch?rev=1.1&content-type=text/plain
37
38 Index: 39_all_cond-store-pr452445.patch
39 ===================================================================
40 https://bugs.gentoo.org/439432
41 http://gcc.gnu.org/PR52445
42
43 From 963aee263572d7e10e1a762de6e8f1725ee393ee Mon Sep 17 00:00:00 2001
44 From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
45 Date: Thu, 1 Mar 2012 14:13:06 +0000
46 Subject: [PATCH] PR tree-optimization/52445 * tree-ssa-phiopt.c
47 (struct name_to_bb): Remove ssa_name field, add
48 ssa_name_ver, offset and size fields and change store field
49 to bool. (name_to_bb_hash, name_to_bb_eq):
50 Adjust for the above changes. (add_or_mark_expr):
51 Likewise. Only consider previous stores with the
52 same size and offset. (nt_init_block): Only look at
53 gimple_assign_single_p stmts, doesn't look at rhs2.
54
55 * gcc.dg/pr52445.c: New test.
56
57
58 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184743 138bc75d-0d04-0410-961f-82ee72b054a4
59 ---
60 gcc/ChangeLog | 12 ++++++++++++
61 gcc/testsuite/ChangeLog | 5 +++++
62 gcc/testsuite/gcc.dg/pr52445.c | 15 +++++++++++++++
63 gcc/tree-ssa-phiopt.c | 42 ++++++++++++++++++++++++++----------------
64 4 files changed, 58 insertions(+), 16 deletions(-)
65 create mode 100644 gcc/testsuite/gcc.dg/pr52445.c
66
67 diff --git a/gcc/testsuite/gcc.dg/pr52445.c b/gcc/testsuite/gcc.dg/pr52445.c
68 new file mode 100644
69 index 0000000..0977821
70 --- /dev/null
71 +++ b/gcc/testsuite/gcc.dg/pr52445.c
72 @@ -0,0 +1,15 @@
73 +/* PR tree-optimization/52445 */
74 +/* { dg-do compile } */
75 +/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim" } */
76 +
77 +void
78 +foo (char *buf, unsigned long len)
79 +{
80 + buf[0] = '\n';
81 + if (len > 1)
82 + buf[1] = '\0'; /* We can't cselim "optimize" this, while
83 + buf[0] doesn't trap, buf[1] could. */
84 +}
85 +
86 +/* { dg-final { scan-tree-dump-not "cstore\." "cselim" } } */
87 +/* { dg-final { cleanup-tree-dump "cselim" } } */
88 diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
89 index b739bbc..0cef8ee 100644
90 --- a/gcc/tree-ssa-phiopt.c
91 +++ b/gcc/tree-ssa-phiopt.c
92 @@ -1122,9 +1122,10 @@ abs_replacement (basic_block cond_bb, basic_block middle_bb,
93 same accesses. */
94 struct name_to_bb
95 {
96 - tree ssa_name;
97 + unsigned int ssa_name_ver;
98 + bool store;
99 + HOST_WIDE_INT offset, size;
100 basic_block bb;
101 - unsigned store : 1;
102 };
103
104 /* The hash table for remembering what we've seen. */
105 @@ -1133,23 +1134,26 @@ static htab_t seen_ssa_names;
106 /* The set of MEM_REFs which can't trap. */
107 static struct pointer_set_t *nontrap_set;
108
109 -/* The hash function, based on the pointer to the pointer SSA_NAME. */
110 +/* The hash function. */
111 static hashval_t
112 name_to_bb_hash (const void *p)
113 {
114 - const_tree n = ((const struct name_to_bb *)p)->ssa_name;
115 - return htab_hash_pointer (n) ^ ((const struct name_to_bb *)p)->store;
116 + const struct name_to_bb *n = (const struct name_to_bb *) p;
117 + return n->ssa_name_ver ^ (((hashval_t) n->store) << 31)
118 + ^ (n->offset << 6) ^ (n->size << 3);
119 }
120
121 -/* The equality function of *P1 and *P2. SSA_NAMEs are shared, so
122 - it's enough to simply compare them for equality. */
123 +/* The equality function of *P1 and *P2. */
124 static int
125 name_to_bb_eq (const void *p1, const void *p2)
126 {
127 const struct name_to_bb *n1 = (const struct name_to_bb *)p1;
128 const struct name_to_bb *n2 = (const struct name_to_bb *)p2;
129
130 - return n1->ssa_name == n2->ssa_name && n1->store == n2->store;
131 + return n1->ssa_name_ver == n2->ssa_name_ver
132 + && n1->store == n2->store
133 + && n1->offset == n2->offset
134 + && n1->size == n2->size;
135 }
136
137 /* We see the expression EXP in basic block BB. If it's an interesting
138 @@ -1161,8 +1165,12 @@ static void
139 add_or_mark_expr (basic_block bb, tree exp,
140 struct pointer_set_t *nontrap, bool store)
141 {
142 + HOST_WIDE_INT size;
143 +
144 if (TREE_CODE (exp) == MEM_REF
145 - && TREE_CODE (TREE_OPERAND (exp, 0)) == SSA_NAME)
146 + && TREE_CODE (TREE_OPERAND (exp, 0)) == SSA_NAME
147 + && host_integerp (TREE_OPERAND (exp, 1), 0)
148 + && (size = int_size_in_bytes (TREE_TYPE (exp))) > 0)
149 {
150 tree name = TREE_OPERAND (exp, 0);
151 struct name_to_bb map;
152 @@ -1172,9 +1180,12 @@ add_or_mark_expr (basic_block bb, tree exp,
153
154 /* Try to find the last seen MEM_REF through the same
155 SSA_NAME, which can trap. */
156 - map.ssa_name = name;
157 + map.ssa_name_ver = SSA_NAME_VERSION (name);
158 map.bb = 0;
159 map.store = store;
160 + map.offset = tree_low_cst (TREE_OPERAND (exp, 1), 0);
161 + map.size = size;
162 +
163 slot = htab_find_slot (seen_ssa_names, &map, INSERT);
164 n2bb = (struct name_to_bb *) *slot;
165 if (n2bb)
166 @@ -1197,9 +1208,11 @@ add_or_mark_expr (basic_block bb, tree exp,
167 else
168 {
169 n2bb = XNEW (struct name_to_bb);
170 - n2bb->ssa_name = name;
171 + n2bb->ssa_name_ver = SSA_NAME_VERSION (name);
172 n2bb->bb = bb;
173 n2bb->store = store;
174 + n2bb->offset = map.offset;
175 + n2bb->size = size;
176 *slot = n2bb;
177 }
178 }
179 @@ -1219,13 +1232,10 @@ nt_init_block (struct dom_walk_data *data ATTRIBUTE_UNUSED, basic_block bb)
180 {
181 gimple stmt = gsi_stmt (gsi);
182
183 - if (is_gimple_assign (stmt))
184 + if (gimple_assign_single_p (stmt))
185 {
186 add_or_mark_expr (bb, gimple_assign_lhs (stmt), nontrap_set, true);
187 add_or_mark_expr (bb, gimple_assign_rhs1 (stmt), nontrap_set, false);
188 - if (get_gimple_rhs_num_ops (gimple_assign_rhs_code (stmt)) > 1)
189 - add_or_mark_expr (bb, gimple_assign_rhs2 (stmt), nontrap_set,
190 - false);
191 }
192 }
193 }
194 --
195 1.7.12.4