1 Upstream-Status: Inappropriate [Backport]
2 From 2631216d2fedc5339a5edcac64db1ab5d9269498 Mon Sep 17 00:00:00 2001
3 From: rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Mon, 28 Mar 2011 10:14:34 +0000
5 Subject: [PATCH 014/200] 2011-03-28 Richard Guenther <rguenther@suse.de>
8 2011-03-24 Richard Guenther <rguenther@suse.de>
11 * tree-object-size.c (addr_object_size): Do not double-account
14 * gcc.dg/builtin-object-size-10.c: New testcase.
16 2011-03-22 Richard Guenther <rguenther@suse.de>
18 PR tree-optimization/48228
19 * tree-vrp.c (vrp_visit_phi_node): Do not stop propagating
22 * gcc.dg/Wstrict-overflow-23.c: New testcase.
24 2011-03-17 Richard Guenther <rguenther@suse.de>
27 * tree-ssa.c (insert_debug_temp_for_var_def): If we propagated
28 a value make sure to fold the statement.
30 * gcc.dg/pr48134.c: New testcase.
32 2011-03-15 Richard Guenther <rguenther@suse.de>
35 * fold-const.c (fold_indirect_ref_1): Do not create new variable-sized
36 or variable-indexed array accesses when in gimple form.
39 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@171595 138bc75d-0d04-0410-961f-82ee72b054a4
41 index 957049c..9a2f31f 100644
42 --- a/gcc/fold-const.c
43 +++ b/gcc/fold-const.c
44 @@ -15554,12 +15554,17 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
46 /* *(foo *)&fooarray => fooarray[0] */
47 else if (TREE_CODE (optype) == ARRAY_TYPE
48 - && type == TREE_TYPE (optype))
49 + && type == TREE_TYPE (optype)
51 + || TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST))
53 tree type_domain = TYPE_DOMAIN (optype);
54 tree min_val = size_zero_node;
55 if (type_domain && TYPE_MIN_VALUE (type_domain))
56 min_val = TYPE_MIN_VALUE (type_domain);
58 + && TREE_CODE (min_val) != INTEGER_CST)
60 return build4_loc (loc, ARRAY_REF, type, op, min_val,
61 NULL_TREE, NULL_TREE);
63 @@ -15633,7 +15638,9 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
65 /* *(foo *)fooarrptr => (*fooarrptr)[0] */
66 if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
67 - && type == TREE_TYPE (TREE_TYPE (subtype)))
68 + && type == TREE_TYPE (TREE_TYPE (subtype))
70 + || TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST))
73 tree min_val = size_zero_node;
74 @@ -15641,6 +15648,9 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
75 type_domain = TYPE_DOMAIN (TREE_TYPE (sub));
76 if (type_domain && TYPE_MIN_VALUE (type_domain))
77 min_val = TYPE_MIN_VALUE (type_domain);
79 + && TREE_CODE (min_val) != INTEGER_CST)
81 return build4_loc (loc, ARRAY_REF, type, sub, min_val, NULL_TREE,
85 index 0000000..16014bb
87 +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-23.c
89 +/* { dg-do compile } */
90 +/* { dg-options "-O2 -Wstrict-overflow" } */
93 +do_scrolling (unsigned int window_size, unsigned int writecost)
95 + unsigned int i = window_size;
97 + int terminal_window_p = 0;
98 + unsigned int queue = 0;
100 + for (i = window_size; i; i--)
104 + else if (writecost & 1)
105 + terminal_window_p = 1;
110 + if (!terminal_window_p)
112 + terminal_window_p = 1;
116 + if (terminal_window_p)
120 diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-10.c b/gcc/testsuite/gcc.dg/builtin-object-size-10.c
122 index 0000000..6c7ed45
124 +++ b/gcc/testsuite/gcc.dg/builtin-object-size-10.c
126 +/* { dg-do compile } */
127 +/* { dg-options "-O2 -fdump-tree-objsz-details" } */
136 +} drone_source_packet;
140 + drone_packet *dpkt = __builtin_malloc(sizeof(drone_packet)
141 + + sizeof(drone_source_packet));
142 + drone_source_packet *spkt = (drone_source_packet *) dpkt->data;
143 + __builtin___snprintf_chk (spkt->type_str, 16,
144 + 1, __builtin_object_size (spkt->type_str, 1),
149 +/* { dg-final { scan-tree-dump "maximum object size 21" "objsz" } } */
150 +/* { dg-final { scan-tree-dump "maximum subobject size 16" "objsz" } } */
151 +/* { dg-final { cleanup-tree-dump "objsz" } } */
152 diff --git a/gcc/testsuite/gcc.dg/pr48134.c b/gcc/testsuite/gcc.dg/pr48134.c
154 index 0000000..8dc5a6d
156 +++ b/gcc/testsuite/gcc.dg/pr48134.c
158 +/* { dg-do compile } */
159 +/* { dg-options "-O2 -fstack-check=specific -fno-tree-dse -fno-tree-fre -fno-tree-loop-optimize -g" } */
172 +static inline struct S
180 +foo (struct T t, struct S s)
189 diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
190 index 6a74d19..043b445 100644
191 --- a/gcc/tree-object-size.c
192 +++ b/gcc/tree-object-size.c
193 @@ -348,8 +348,6 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
194 tree bytes2 = compute_object_offset (TREE_OPERAND (ptr, 0), pt_var);
195 if (bytes2 != error_mark_node)
197 - bytes2 = size_binop (PLUS_EXPR, bytes2,
198 - TREE_OPERAND (pt_var, 1));
199 if (TREE_CODE (bytes2) == INTEGER_CST
200 && tree_int_cst_lt (pt_var_size, bytes2))
201 bytes2 = size_zero_node;
202 diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
203 index 5c9e0d8..eaf3ef9 100644
206 @@ -455,13 +455,19 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var)
210 - FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
211 - /* unshare_expr is not needed here. vexpr is either a
212 - SINGLE_RHS, that can be safely shared, some other RHS
213 - that was unshared when we found it had a single debug
214 - use, or a DEBUG_EXPR_DECL, that can be safely
216 - SET_USE (use_p, value);
218 + FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
219 + /* unshare_expr is not needed here. vexpr is either a
220 + SINGLE_RHS, that can be safely shared, some other RHS
221 + that was unshared when we found it had a single debug
222 + use, or a DEBUG_EXPR_DECL, that can be safely
224 + SET_USE (use_p, value);
225 + /* If we didn't replace uses with a debug decl fold the
226 + resulting expression. Otherwise we end up with invalid IL. */
227 + if (TREE_CODE (value) != DEBUG_EXPR_DECL)
228 + fold_stmt_inplace (stmt);
231 gimple_debug_bind_reset_value (stmt);
233 diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
234 index 65d249f..280e6da 100644
237 @@ -6619,6 +6619,7 @@ vrp_visit_phi_node (gimple phi)
238 edge; this helps us avoid an overflow infinity for conditionals
239 which are not in a loop. */
241 + && gimple_phi_num_args (phi) > 1
242 && edges == old_edges)
244 int cmp_min = compare_values (lhs_vr->min, vr_result.min);