Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-ssa-loop-im.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
24 #include "tm.h" | 24 #include "tm.h" |
25 #include "tree.h" | 25 #include "tree.h" |
26 #include "tm_p.h" | 26 #include "tm_p.h" |
27 #include "basic-block.h" | 27 #include "basic-block.h" |
28 #include "output.h" | 28 #include "output.h" |
29 #include "diagnostic.h" | 29 #include "tree-pretty-print.h" |
30 #include "gimple-pretty-print.h" | 30 #include "gimple-pretty-print.h" |
31 #include "tree-pretty-print.h" | |
32 #include "tree-flow.h" | 31 #include "tree-flow.h" |
33 #include "tree-dump.h" | 32 #include "tree-dump.h" |
34 #include "timevar.h" | 33 #include "timevar.h" |
35 #include "cfgloop.h" | 34 #include "cfgloop.h" |
36 #include "domwalk.h" | 35 #include "domwalk.h" |
271 switch (TREE_CODE (*addr_p)) | 270 switch (TREE_CODE (*addr_p)) |
272 { | 271 { |
273 case SSA_NAME: | 272 case SSA_NAME: |
274 return cbck (*addr_p, addr_p, data); | 273 return cbck (*addr_p, addr_p, data); |
275 | 274 |
276 case MISALIGNED_INDIRECT_REF: | 275 case MEM_REF: |
277 case ALIGN_INDIRECT_REF: | |
278 case INDIRECT_REF: | |
279 nxt = &TREE_OPERAND (*addr_p, 0); | 276 nxt = &TREE_OPERAND (*addr_p, 0); |
280 return cbck (*addr_p, nxt, data); | 277 return cbck (*addr_p, nxt, data); |
281 | 278 |
282 case BIT_FIELD_REF: | 279 case BIT_FIELD_REF: |
283 case VIEW_CONVERT_EXPR: | 280 case VIEW_CONVERT_EXPR: |
324 idx = &TMR_BASE (*addr_p); | 321 idx = &TMR_BASE (*addr_p); |
325 if (*idx | 322 if (*idx |
326 && !cbck (*addr_p, idx, data)) | 323 && !cbck (*addr_p, idx, data)) |
327 return false; | 324 return false; |
328 idx = &TMR_INDEX (*addr_p); | 325 idx = &TMR_INDEX (*addr_p); |
326 if (*idx | |
327 && !cbck (*addr_p, idx, data)) | |
328 return false; | |
329 idx = &TMR_INDEX2 (*addr_p); | |
329 if (*idx | 330 if (*idx |
330 && !cbck (*addr_p, idx, data)) | 331 && !cbck (*addr_p, idx, data)) |
331 return false; | 332 return false; |
332 return true; | 333 return true; |
333 | 334 |
673 | 674 |
674 /* We have to verify that one edge into the PHI node is dominated | 675 /* We have to verify that one edge into the PHI node is dominated |
675 by the true edge of the predicate block and the other edge | 676 by the true edge of the predicate block and the other edge |
676 dominated by the false edge. This ensures that the PHI argument | 677 dominated by the false edge. This ensures that the PHI argument |
677 we are going to take is completely determined by the path we | 678 we are going to take is completely determined by the path we |
678 take from the predicate block. */ | 679 take from the predicate block. |
680 We can only use BB dominance checks below if the destination of | |
681 the true/false edges are dominated by their edge, thus only | |
682 have a single predecessor. */ | |
679 extract_true_false_edges_from_block (dom, &true_edge, &false_edge); | 683 extract_true_false_edges_from_block (dom, &true_edge, &false_edge); |
680 tem = EDGE_PRED (bb, 0); | 684 tem = EDGE_PRED (bb, 0); |
681 if (tem == true_edge | 685 if (tem == true_edge |
682 || tem->src == true_edge->dest | 686 || (single_pred_p (true_edge->dest) |
683 || dominated_by_p (CDI_DOMINATORS, | 687 && (tem->src == true_edge->dest |
684 tem->src, true_edge->dest)) | 688 || dominated_by_p (CDI_DOMINATORS, |
689 tem->src, true_edge->dest)))) | |
685 arg0 = PHI_ARG_DEF (phi, tem->dest_idx); | 690 arg0 = PHI_ARG_DEF (phi, tem->dest_idx); |
686 else if (tem == false_edge | 691 else if (tem == false_edge |
687 || tem->src == false_edge->dest | 692 || (single_pred_p (false_edge->dest) |
688 || dominated_by_p (CDI_DOMINATORS, | 693 && (tem->src == false_edge->dest |
689 tem->src, false_edge->dest)) | 694 || dominated_by_p (CDI_DOMINATORS, |
695 tem->src, false_edge->dest)))) | |
690 arg1 = PHI_ARG_DEF (phi, tem->dest_idx); | 696 arg1 = PHI_ARG_DEF (phi, tem->dest_idx); |
691 else | 697 else |
692 return false; | 698 return false; |
693 tem = EDGE_PRED (bb, 1); | 699 tem = EDGE_PRED (bb, 1); |
694 if (tem == true_edge | 700 if (tem == true_edge |
695 || tem->src == true_edge->dest | 701 || (single_pred_p (true_edge->dest) |
696 || dominated_by_p (CDI_DOMINATORS, | 702 && (tem->src == true_edge->dest |
697 tem->src, true_edge->dest)) | 703 || dominated_by_p (CDI_DOMINATORS, |
704 tem->src, true_edge->dest)))) | |
698 arg0 = PHI_ARG_DEF (phi, tem->dest_idx); | 705 arg0 = PHI_ARG_DEF (phi, tem->dest_idx); |
699 else if (tem == false_edge | 706 else if (tem == false_edge |
700 || tem->src == false_edge->dest | 707 || (single_pred_p (false_edge->dest) |
701 || dominated_by_p (CDI_DOMINATORS, | 708 && (tem->src == false_edge->dest |
702 tem->src, false_edge->dest)) | 709 || dominated_by_p (CDI_DOMINATORS, |
710 tem->src, false_edge->dest)))) | |
703 arg1 = PHI_ARG_DEF (phi, tem->dest_idx); | 711 arg1 = PHI_ARG_DEF (phi, tem->dest_idx); |
704 else | 712 else |
705 return false; | 713 return false; |
706 if (!arg0 || !arg1) | 714 if (!arg0 || !arg1) |
707 return false; | 715 return false; |
907 | 915 |
908 var = create_tmp_var (type, "reciptmp"); | 916 var = create_tmp_var (type, "reciptmp"); |
909 add_referenced_var (var); | 917 add_referenced_var (var); |
910 DECL_GIMPLE_REG_P (var) = 1; | 918 DECL_GIMPLE_REG_P (var) = 1; |
911 | 919 |
912 /* For vectors, create a VECTOR_CST full of 1's. */ | 920 real_one = build_one_cst (type); |
913 if (TREE_CODE (type) == VECTOR_TYPE) | |
914 { | |
915 int i, len; | |
916 tree list = NULL_TREE; | |
917 real_one = build_real (TREE_TYPE (type), dconst1); | |
918 len = TYPE_VECTOR_SUBPARTS (type); | |
919 for (i = 0; i < len; i++) | |
920 list = tree_cons (NULL, real_one, list); | |
921 real_one = build_vector (type, list); | |
922 } | |
923 else | |
924 real_one = build_real (type, dconst1); | |
925 | 921 |
926 stmt1 = gimple_build_assign_with_ops (RDIV_EXPR, | 922 stmt1 = gimple_build_assign_with_ops (RDIV_EXPR, |
927 var, real_one, gimple_assign_rhs2 (stmt)); | 923 var, real_one, gimple_assign_rhs2 (stmt)); |
928 name = make_ssa_name (var, stmt1); | 924 name = make_ssa_name (var, stmt1); |
929 gimple_assign_set_lhs (stmt1, name); | 925 gimple_assign_set_lhs (stmt1, name); |
1442 mem_ref_loc_p loc; | 1438 mem_ref_loc_p loc; |
1443 | 1439 |
1444 if (!accs) | 1440 if (!accs) |
1445 return; | 1441 return; |
1446 | 1442 |
1447 for (i = 0; VEC_iterate (mem_ref_loc_p, accs->locs, i, loc); i++) | 1443 FOR_EACH_VEC_ELT (mem_ref_loc_p, accs->locs, i, loc) |
1448 free (loc); | 1444 free (loc); |
1449 VEC_free (mem_ref_loc_p, heap, accs->locs); | 1445 VEC_free (mem_ref_loc_p, heap, accs->locs); |
1450 free (accs); | 1446 free (accs); |
1451 } | 1447 } |
1452 | 1448 |
1463 BITMAP_FREE (mem->indep_loop); | 1459 BITMAP_FREE (mem->indep_loop); |
1464 BITMAP_FREE (mem->dep_loop); | 1460 BITMAP_FREE (mem->dep_loop); |
1465 BITMAP_FREE (mem->indep_ref); | 1461 BITMAP_FREE (mem->indep_ref); |
1466 BITMAP_FREE (mem->dep_ref); | 1462 BITMAP_FREE (mem->dep_ref); |
1467 | 1463 |
1468 for (i = 0; VEC_iterate (mem_ref_locs_p, mem->accesses_in_loop, i, accs); i++) | 1464 FOR_EACH_VEC_ELT (mem_ref_locs_p, mem->accesses_in_loop, i, accs) |
1469 free_mem_ref_locs (accs); | 1465 free_mem_ref_locs (accs); |
1470 VEC_free (mem_ref_locs_p, heap, mem->accesses_in_loop); | 1466 VEC_free (mem_ref_locs_p, heap, mem->accesses_in_loop); |
1471 | 1467 |
1472 BITMAP_FREE (mem->vops); | 1468 BITMAP_FREE (mem->vops); |
1473 free (mem); | 1469 free (mem); |
1929 > (unsigned) loop->num) | 1925 > (unsigned) loop->num) |
1930 { | 1926 { |
1931 accs = VEC_index (mem_ref_locs_p, ref->accesses_in_loop, loop->num); | 1927 accs = VEC_index (mem_ref_locs_p, ref->accesses_in_loop, loop->num); |
1932 if (accs) | 1928 if (accs) |
1933 { | 1929 { |
1934 for (i = 0; VEC_iterate (mem_ref_loc_p, accs->locs, i, loc); i++) | 1930 FOR_EACH_VEC_ELT (mem_ref_loc_p, accs->locs, i, loc) |
1935 VEC_safe_push (mem_ref_loc_p, heap, *locs, loc); | 1931 VEC_safe_push (mem_ref_loc_p, heap, *locs, loc); |
1936 } | 1932 } |
1937 } | 1933 } |
1938 | 1934 |
1939 for (subloop = loop->inner; subloop != NULL; subloop = subloop->next) | 1935 for (subloop = loop->inner; subloop != NULL; subloop = subloop->next) |
1948 unsigned i; | 1944 unsigned i; |
1949 mem_ref_loc_p loc; | 1945 mem_ref_loc_p loc; |
1950 VEC (mem_ref_loc_p, heap) *locs = NULL; | 1946 VEC (mem_ref_loc_p, heap) *locs = NULL; |
1951 | 1947 |
1952 get_all_locs_in_loop (loop, ref, &locs); | 1948 get_all_locs_in_loop (loop, ref, &locs); |
1953 for (i = 0; VEC_iterate (mem_ref_loc_p, locs, i, loc); i++) | 1949 FOR_EACH_VEC_ELT (mem_ref_loc_p, locs, i, loc) |
1954 rewrite_mem_ref_loc (loc, tmp_var); | 1950 rewrite_mem_ref_loc (loc, tmp_var); |
1955 VEC_free (mem_ref_loc_p, heap, locs); | 1951 VEC_free (mem_ref_loc_p, heap, locs); |
1956 } | 1952 } |
1957 | 1953 |
1958 /* The name and the length of the currently generated variable | 1954 /* The name and the length of the currently generated variable |
1982 { | 1978 { |
1983 const char *name; | 1979 const char *name; |
1984 | 1980 |
1985 switch (TREE_CODE (ref)) | 1981 switch (TREE_CODE (ref)) |
1986 { | 1982 { |
1987 case MISALIGNED_INDIRECT_REF: | 1983 case MEM_REF: |
1988 case ALIGN_INDIRECT_REF: | |
1989 case INDIRECT_REF: | |
1990 gen_lsm_tmp_name (TREE_OPERAND (ref, 0)); | 1984 gen_lsm_tmp_name (TREE_OPERAND (ref, 0)); |
1991 lsm_tmp_name_add ("_"); | 1985 lsm_tmp_name_add ("_"); |
1986 break; | |
1987 | |
1988 case ADDR_EXPR: | |
1989 gen_lsm_tmp_name (TREE_OPERAND (ref, 0)); | |
1992 break; | 1990 break; |
1993 | 1991 |
1994 case BIT_FIELD_REF: | 1992 case BIT_FIELD_REF: |
1995 case VIEW_CONVERT_EXPR: | 1993 case VIEW_CONVERT_EXPR: |
1996 case ARRAY_RANGE_REF: | 1994 case ARRAY_RANGE_REF: |
2110 | 2108 |
2111 /* Put this into the latch, so that we are sure it will be processed after | 2109 /* Put this into the latch, so that we are sure it will be processed after |
2112 all dependencies. */ | 2110 all dependencies. */ |
2113 gsi_insert_on_edge (loop_latch_edge (loop), load); | 2111 gsi_insert_on_edge (loop_latch_edge (loop), load); |
2114 | 2112 |
2115 for (i = 0; VEC_iterate (edge, exits, i, ex); i++) | 2113 FOR_EACH_VEC_ELT (edge, exits, i, ex) |
2116 { | 2114 { |
2117 store = gimple_build_assign (unshare_expr (ref->mem), tmp_var); | 2115 store = gimple_build_assign (unshare_expr (ref->mem), tmp_var); |
2118 gsi_insert_on_edge (ex, store); | 2116 gsi_insert_on_edge (ex, store); |
2119 } | 2117 } |
2120 } | 2118 } |
2149 bool ret = false; | 2147 bool ret = false; |
2150 struct loop *must_exec; | 2148 struct loop *must_exec; |
2151 tree base; | 2149 tree base; |
2152 | 2150 |
2153 base = get_base_address (ref->mem); | 2151 base = get_base_address (ref->mem); |
2154 if (INDIRECT_REF_P (base)) | 2152 if (INDIRECT_REF_P (base) |
2153 || TREE_CODE (base) == MEM_REF) | |
2155 base = TREE_OPERAND (base, 0); | 2154 base = TREE_OPERAND (base, 0); |
2156 | 2155 |
2157 get_all_locs_in_loop (loop, ref, &locs); | 2156 get_all_locs_in_loop (loop, ref, &locs); |
2158 for (i = 0; VEC_iterate (mem_ref_loc_p, locs, i, loc); i++) | 2157 FOR_EACH_VEC_ELT (mem_ref_loc_p, locs, i, loc) |
2159 { | 2158 { |
2160 if (!get_lim_data (loc->stmt)) | 2159 if (!get_lim_data (loc->stmt)) |
2161 continue; | 2160 continue; |
2162 | 2161 |
2163 /* If we require an always executed store make sure the statement | 2162 /* If we require an always executed store make sure the statement |
2168 if (!gimple_get_lhs (loc->stmt)) | 2167 if (!gimple_get_lhs (loc->stmt)) |
2169 continue; | 2168 continue; |
2170 lhs = get_base_address (gimple_get_lhs (loc->stmt)); | 2169 lhs = get_base_address (gimple_get_lhs (loc->stmt)); |
2171 if (!lhs) | 2170 if (!lhs) |
2172 continue; | 2171 continue; |
2173 if (INDIRECT_REF_P (lhs)) | 2172 if (INDIRECT_REF_P (lhs) |
2173 || TREE_CODE (lhs) == MEM_REF) | |
2174 lhs = TREE_OPERAND (lhs, 0); | 2174 lhs = TREE_OPERAND (lhs, 0); |
2175 if (lhs != base) | 2175 if (lhs != base) |
2176 continue; | 2176 continue; |
2177 } | 2177 } |
2178 | 2178 |
2321 | 2321 |
2322 /* It should be movable. */ | 2322 /* It should be movable. */ |
2323 if (!is_gimple_reg_type (TREE_TYPE (ref->mem)) | 2323 if (!is_gimple_reg_type (TREE_TYPE (ref->mem)) |
2324 || TREE_THIS_VOLATILE (ref->mem) | 2324 || TREE_THIS_VOLATILE (ref->mem) |
2325 || !for_each_index (&ref->mem, may_move_till, loop)) | 2325 || !for_each_index (&ref->mem, may_move_till, loop)) |
2326 return false; | |
2327 | |
2328 /* If it can throw fail, we do not properly update EH info. */ | |
2329 if (tree_could_throw_p (ref->mem)) | |
2326 return false; | 2330 return false; |
2327 | 2331 |
2328 /* If it can trap, it must be always executed in LOOP. | 2332 /* If it can trap, it must be always executed in LOOP. |
2329 Readonly memory locations may trap when storing to them, but | 2333 Readonly memory locations may trap when storing to them, but |
2330 tree_could_trap_p is a predicate for rvalues, so check that | 2334 tree_could_trap_p is a predicate for rvalues, so check that |
2373 VEC (edge, heap) *exits) | 2377 VEC (edge, heap) *exits) |
2374 { | 2378 { |
2375 unsigned i; | 2379 unsigned i; |
2376 edge ex; | 2380 edge ex; |
2377 | 2381 |
2378 for (i = 0; VEC_iterate (edge, exits, i, ex); i++) | 2382 FOR_EACH_VEC_ELT (edge, exits, i, ex) |
2379 if (ex->flags & EDGE_ABNORMAL) | 2383 if (ex->flags & (EDGE_ABNORMAL | EDGE_EH)) |
2380 return false; | 2384 return false; |
2381 | 2385 |
2382 return true; | 2386 return true; |
2383 } | 2387 } |
2384 | 2388 |
2540 pointer_map_destroy (lim_aux_data_map); | 2544 pointer_map_destroy (lim_aux_data_map); |
2541 | 2545 |
2542 VEC_free (mem_ref_p, heap, memory_accesses.refs_list); | 2546 VEC_free (mem_ref_p, heap, memory_accesses.refs_list); |
2543 htab_delete (memory_accesses.refs); | 2547 htab_delete (memory_accesses.refs); |
2544 | 2548 |
2545 for (i = 0; VEC_iterate (bitmap, memory_accesses.refs_in_loop, i, b); i++) | 2549 FOR_EACH_VEC_ELT (bitmap, memory_accesses.refs_in_loop, i, b) |
2546 BITMAP_FREE (b); | 2550 BITMAP_FREE (b); |
2547 VEC_free (bitmap, heap, memory_accesses.refs_in_loop); | 2551 VEC_free (bitmap, heap, memory_accesses.refs_in_loop); |
2548 | 2552 |
2549 for (i = 0; VEC_iterate (bitmap, memory_accesses.all_refs_in_loop, i, b); i++) | 2553 FOR_EACH_VEC_ELT (bitmap, memory_accesses.all_refs_in_loop, i, b) |
2550 BITMAP_FREE (b); | 2554 BITMAP_FREE (b); |
2551 VEC_free (bitmap, heap, memory_accesses.all_refs_in_loop); | 2555 VEC_free (bitmap, heap, memory_accesses.all_refs_in_loop); |
2552 | 2556 |
2553 for (i = 0; VEC_iterate (bitmap, memory_accesses.clobbered_vops, i, b); i++) | 2557 FOR_EACH_VEC_ELT (bitmap, memory_accesses.clobbered_vops, i, b) |
2554 BITMAP_FREE (b); | 2558 BITMAP_FREE (b); |
2555 VEC_free (bitmap, heap, memory_accesses.clobbered_vops); | 2559 VEC_free (bitmap, heap, memory_accesses.clobbered_vops); |
2556 | 2560 |
2557 for (i = 0; VEC_iterate (htab_t, memory_accesses.vop_ref_map, i, h); i++) | 2561 FOR_EACH_VEC_ELT (htab_t, memory_accesses.vop_ref_map, i, h) |
2558 htab_delete (h); | 2562 htab_delete (h); |
2559 VEC_free (htab_t, heap, memory_accesses.vop_ref_map); | 2563 VEC_free (htab_t, heap, memory_accesses.vop_ref_map); |
2560 | 2564 |
2561 if (memory_accesses.ttae_cache) | 2565 if (memory_accesses.ttae_cache) |
2562 pointer_map_destroy (memory_accesses.ttae_cache); | 2566 pointer_map_destroy (memory_accesses.ttae_cache); |