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