1 From 2631216d2fedc5339a5edcac64db1ab5d9269498 Mon Sep 17 00:00:00 2001
2 From: rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
3 Date: Mon, 28 Mar 2011 10:14:34 +0000
4 Subject: [PATCH 014/200] 2011-03-28 Richard Guenther <rguenther@suse.de>
7 2011-03-24 Richard Guenther <rguenther@suse.de>
10 * tree-object-size.c (addr_object_size): Do not double-account
13 * gcc.dg/builtin-object-size-10.c: New testcase.
15 2011-03-22 Richard Guenther <rguenther@suse.de>
17 PR tree-optimization/48228
18 * tree-vrp.c (vrp_visit_phi_node): Do not stop propagating
21 * gcc.dg/Wstrict-overflow-23.c: New testcase.
23 2011-03-17 Richard Guenther <rguenther@suse.de>
26 * tree-ssa.c (insert_debug_temp_for_var_def): If we propagated
27 a value make sure to fold the statement.
29 * gcc.dg/pr48134.c: New testcase.
31 2011-03-15 Richard Guenther <rguenther@suse.de>
34 * fold-const.c (fold_indirect_ref_1): Do not create new variable-sized
35 or variable-indexed array accesses when in gimple form.
38 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@171595 138bc75d-0d04-0410-961f-82ee72b054a4
40 index 957049c..9a2f31f 100644
41 --- a/gcc/fold-const.c
42 +++ b/gcc/fold-const.c
43 @@ -15554,12 +15554,17 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
45 /* *(foo *)&fooarray => fooarray[0] */
46 else if (TREE_CODE (optype) == ARRAY_TYPE
47 - && type == TREE_TYPE (optype))
48 + && type == TREE_TYPE (optype)
50 + || TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST))
52 tree type_domain = TYPE_DOMAIN (optype);
53 tree min_val = size_zero_node;
54 if (type_domain && TYPE_MIN_VALUE (type_domain))
55 min_val = TYPE_MIN_VALUE (type_domain);
57 + && TREE_CODE (min_val) != INTEGER_CST)
59 return build4_loc (loc, ARRAY_REF, type, op, min_val,
60 NULL_TREE, NULL_TREE);
62 @@ -15633,7 +15638,9 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
64 /* *(foo *)fooarrptr => (*fooarrptr)[0] */
65 if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
66 - && type == TREE_TYPE (TREE_TYPE (subtype)))
67 + && type == TREE_TYPE (TREE_TYPE (subtype))
69 + || TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST))
72 tree min_val = size_zero_node;
73 @@ -15641,6 +15648,9 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
74 type_domain = TYPE_DOMAIN (TREE_TYPE (sub));
75 if (type_domain && TYPE_MIN_VALUE (type_domain))
76 min_val = TYPE_MIN_VALUE (type_domain);
78 + && TREE_CODE (min_val) != INTEGER_CST)
80 return build4_loc (loc, ARRAY_REF, type, sub, min_val, NULL_TREE,
84 index 0000000..16014bb
86 +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-23.c
88 +/* { dg-do compile } */
89 +/* { dg-options "-O2 -Wstrict-overflow" } */
92 +do_scrolling (unsigned int window_size, unsigned int writecost)
94 + unsigned int i = window_size;
96 + int terminal_window_p = 0;
97 + unsigned int queue = 0;
99 + for (i = window_size; i; i--)
103 + else if (writecost & 1)
104 + terminal_window_p = 1;
109 + if (!terminal_window_p)
111 + terminal_window_p = 1;
115 + if (terminal_window_p)
119 diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-10.c b/gcc/testsuite/gcc.dg/builtin-object-size-10.c
121 index 0000000..6c7ed45
123 +++ b/gcc/testsuite/gcc.dg/builtin-object-size-10.c
125 +/* { dg-do compile } */
126 +/* { dg-options "-O2 -fdump-tree-objsz-details" } */
135 +} drone_source_packet;
139 + drone_packet *dpkt = __builtin_malloc(sizeof(drone_packet)
140 + + sizeof(drone_source_packet));
141 + drone_source_packet *spkt = (drone_source_packet *) dpkt->data;
142 + __builtin___snprintf_chk (spkt->type_str, 16,
143 + 1, __builtin_object_size (spkt->type_str, 1),
148 +/* { dg-final { scan-tree-dump "maximum object size 21" "objsz" } } */
149 +/* { dg-final { scan-tree-dump "maximum subobject size 16" "objsz" } } */
150 +/* { dg-final { cleanup-tree-dump "objsz" } } */
151 diff --git a/gcc/testsuite/gcc.dg/pr48134.c b/gcc/testsuite/gcc.dg/pr48134.c
153 index 0000000..8dc5a6d
155 +++ b/gcc/testsuite/gcc.dg/pr48134.c
157 +/* { dg-do compile } */
158 +/* { dg-options "-O2 -fstack-check=specific -fno-tree-dse -fno-tree-fre -fno-tree-loop-optimize -g" } */
171 +static inline struct S
179 +foo (struct T t, struct S s)
188 diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
189 index 6a74d19..043b445 100644
190 --- a/gcc/tree-object-size.c
191 +++ b/gcc/tree-object-size.c
192 @@ -348,8 +348,6 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
193 tree bytes2 = compute_object_offset (TREE_OPERAND (ptr, 0), pt_var);
194 if (bytes2 != error_mark_node)
196 - bytes2 = size_binop (PLUS_EXPR, bytes2,
197 - TREE_OPERAND (pt_var, 1));
198 if (TREE_CODE (bytes2) == INTEGER_CST
199 && tree_int_cst_lt (pt_var_size, bytes2))
200 bytes2 = size_zero_node;
201 diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
202 index 5c9e0d8..eaf3ef9 100644
205 @@ -455,13 +455,19 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var)
209 - FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
210 - /* unshare_expr is not needed here. vexpr is either a
211 - SINGLE_RHS, that can be safely shared, some other RHS
212 - that was unshared when we found it had a single debug
213 - use, or a DEBUG_EXPR_DECL, that can be safely
215 - SET_USE (use_p, value);
217 + FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
218 + /* unshare_expr is not needed here. vexpr is either a
219 + SINGLE_RHS, that can be safely shared, some other RHS
220 + that was unshared when we found it had a single debug
221 + use, or a DEBUG_EXPR_DECL, that can be safely
223 + SET_USE (use_p, value);
224 + /* If we didn't replace uses with a debug decl fold the
225 + resulting expression. Otherwise we end up with invalid IL. */
226 + if (TREE_CODE (value) != DEBUG_EXPR_DECL)
227 + fold_stmt_inplace (stmt);
230 gimple_debug_bind_reset_value (stmt);
232 diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
233 index 65d249f..280e6da 100644
236 @@ -6619,6 +6619,7 @@ vrp_visit_phi_node (gimple phi)
237 edge; this helps us avoid an overflow infinity for conditionals
238 which are not in a loop. */
240 + && gimple_phi_num_args (phi) > 1
241 && edges == old_edges)
243 int cmp_min = compare_values (lhs_vr->min, vr_result.min);