comparison gcc/tree-ssa-dom.c @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents 77e2b8dfacca
children f6334be47118
comparison
equal deleted inserted replaced
56:3c8a44c06a95 63:b7f97abdc517
1 /* SSA Dominator optimizations for trees 1 /* SSA Dominator optimizations for trees
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Contributed by Diego Novillo <dnovillo@redhat.com> 4 Contributed by Diego Novillo <dnovillo@redhat.com>
5 5
6 This file is part of GCC. 6 This file is part of GCC.
7 7
23 #include "system.h" 23 #include "system.h"
24 #include "coretypes.h" 24 #include "coretypes.h"
25 #include "tm.h" 25 #include "tm.h"
26 #include "tree.h" 26 #include "tree.h"
27 #include "flags.h" 27 #include "flags.h"
28 #include "rtl.h"
29 #include "tm_p.h" 28 #include "tm_p.h"
30 #include "ggc.h"
31 #include "basic-block.h" 29 #include "basic-block.h"
32 #include "cfgloop.h" 30 #include "cfgloop.h"
33 #include "output.h" 31 #include "output.h"
34 #include "expr.h" 32 #include "expr.h"
35 #include "function.h" 33 #include "function.h"
36 #include "diagnostic.h" 34 #include "diagnostic.h"
35 #include "tree-pretty-print.h"
36 #include "gimple-pretty-print.h"
37 #include "timevar.h" 37 #include "timevar.h"
38 #include "tree-dump.h" 38 #include "tree-dump.h"
39 #include "tree-flow.h" 39 #include "tree-flow.h"
40 #include "domwalk.h" 40 #include "domwalk.h"
41 #include "real.h"
42 #include "tree-pass.h" 41 #include "tree-pass.h"
43 #include "tree-ssa-propagate.h" 42 #include "tree-ssa-propagate.h"
44 #include "langhooks.h" 43 #include "langhooks.h"
45 #include "params.h" 44 #include "params.h"
46 45
2227 lookup_avail_expr (gimple stmt, bool insert) 2226 lookup_avail_expr (gimple stmt, bool insert)
2228 { 2227 {
2229 void **slot; 2228 void **slot;
2230 tree lhs; 2229 tree lhs;
2231 tree temp; 2230 tree temp;
2232 struct expr_hash_elt *element = XNEW (struct expr_hash_elt); 2231 struct expr_hash_elt element;
2233 2232
2234 /* Get LHS of assignment or call, else NULL_TREE. */ 2233 /* Get LHS of assignment or call, else NULL_TREE. */
2235 lhs = gimple_get_lhs (stmt); 2234 lhs = gimple_get_lhs (stmt);
2236 2235
2237 initialize_hash_element (stmt, lhs, element); 2236 initialize_hash_element (stmt, lhs, &element);
2238 2237
2239 if (dump_file && (dump_flags & TDF_DETAILS)) 2238 if (dump_file && (dump_flags & TDF_DETAILS))
2240 { 2239 {
2241 fprintf (dump_file, "LKUP "); 2240 fprintf (dump_file, "LKUP ");
2242 print_expr_hash_elt (dump_file, element); 2241 print_expr_hash_elt (dump_file, &element);
2243 } 2242 }
2244 2243
2245 /* Don't bother remembering constant assignments and copy operations. 2244 /* Don't bother remembering constant assignments and copy operations.
2246 Constants and copy operations are handled by the constant/copy propagator 2245 Constants and copy operations are handled by the constant/copy propagator
2247 in optimize_stmt. */ 2246 in optimize_stmt. */
2248 if (element->expr.kind == EXPR_SINGLE 2247 if (element.expr.kind == EXPR_SINGLE
2249 && (TREE_CODE (element->expr.ops.single.rhs) == SSA_NAME 2248 && (TREE_CODE (element.expr.ops.single.rhs) == SSA_NAME
2250 || is_gimple_min_invariant (element->expr.ops.single.rhs))) 2249 || is_gimple_min_invariant (element.expr.ops.single.rhs)))
2251 { 2250 return NULL_TREE;
2252 free (element);
2253 return NULL_TREE;
2254 }
2255 2251
2256 /* Finally try to find the expression in the main expression hash table. */ 2252 /* Finally try to find the expression in the main expression hash table. */
2257 slot = htab_find_slot_with_hash (avail_exprs, element, element->hash, 2253 slot = htab_find_slot_with_hash (avail_exprs, &element, element.hash,
2258 (insert ? INSERT : NO_INSERT)); 2254 (insert ? INSERT : NO_INSERT));
2259 if (slot == NULL) 2255 if (slot == NULL)
2260 { 2256 return NULL_TREE;
2261 free (element);
2262 return NULL_TREE;
2263 }
2264 2257
2265 if (*slot == NULL) 2258 if (*slot == NULL)
2266 { 2259 {
2267 *slot = (void *) element; 2260 struct expr_hash_elt *element2 = XNEW (struct expr_hash_elt);
2261 *element2 = element;
2262 element2->stamp = element2;
2263 *slot = (void *) element2;
2268 2264
2269 if (dump_file && (dump_flags & TDF_DETAILS)) 2265 if (dump_file && (dump_flags & TDF_DETAILS))
2270 { 2266 {
2271 fprintf (dump_file, "2>>> "); 2267 fprintf (dump_file, "2>>> ");
2272 print_expr_hash_elt (dump_file, element); 2268 print_expr_hash_elt (dump_file, element2);
2273 } 2269 }
2274 2270
2275 VEC_safe_push (expr_hash_elt_t, heap, avail_exprs_stack, element); 2271 VEC_safe_push (expr_hash_elt_t, heap, avail_exprs_stack, element2);
2276 return NULL_TREE; 2272 return NULL_TREE;
2277 } 2273 }
2278 2274
2279 /* Extract the LHS of the assignment so that it can be used as the current 2275 /* Extract the LHS of the assignment so that it can be used as the current
2280 definition of another variable. */ 2276 definition of another variable. */
2286 { 2282 {
2287 temp = SSA_NAME_VALUE (lhs); 2283 temp = SSA_NAME_VALUE (lhs);
2288 if (temp) 2284 if (temp)
2289 lhs = temp; 2285 lhs = temp;
2290 } 2286 }
2291
2292 free (element);
2293 2287
2294 if (dump_file && (dump_flags & TDF_DETAILS)) 2288 if (dump_file && (dump_flags & TDF_DETAILS))
2295 { 2289 {
2296 fprintf (dump_file, "FIND: "); 2290 fprintf (dump_file, "FIND: ");
2297 print_generic_expr (dump_file, lhs, 0); 2291 print_generic_expr (dump_file, lhs, 0);