Mercurial > hg > CbC > CbC_gcc
comparison gcc/gimple-ssa-strength-reduction.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Straight-line strength reduction. | 1 /* Straight-line strength reduction. |
2 Copyright (C) 2012-2018 Free Software Foundation, Inc. | 2 Copyright (C) 2012-2020 Free Software Foundation, Inc. |
3 Contributed by Bill Schmidt, IBM <wschmidt@linux.ibm.com> | 3 Contributed by Bill Schmidt, IBM <wschmidt@linux.ibm.com> |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
50 #include "gimplify-me.h" | 50 #include "gimplify-me.h" |
51 #include "stor-layout.h" | 51 #include "stor-layout.h" |
52 #include "cfgloop.h" | 52 #include "cfgloop.h" |
53 #include "tree-cfg.h" | 53 #include "tree-cfg.h" |
54 #include "domwalk.h" | 54 #include "domwalk.h" |
55 #include "params.h" | |
56 #include "tree-ssa-address.h" | 55 #include "tree-ssa-address.h" |
57 #include "tree-affine.h" | 56 #include "tree-affine.h" |
58 #include "tree-eh.h" | 57 #include "tree-eh.h" |
59 #include "builtins.h" | 58 #include "builtins.h" |
60 | 59 |
224 CAND_ADD, | 223 CAND_ADD, |
225 CAND_REF, | 224 CAND_REF, |
226 CAND_PHI | 225 CAND_PHI |
227 }; | 226 }; |
228 | 227 |
229 struct slsr_cand_d | 228 class slsr_cand_d |
230 { | 229 { |
230 public: | |
231 /* The candidate statement S1. */ | 231 /* The candidate statement S1. */ |
232 gimple *cand_stmt; | 232 gimple *cand_stmt; |
233 | 233 |
234 /* The base expression B: often an SSA name, but not always. */ | 234 /* The base expression B: often an SSA name, but not always. */ |
235 tree base_expr; | 235 tree base_expr; |
294 /* We sometimes have to cache a phi basis with a phi candidate to | 294 /* We sometimes have to cache a phi basis with a phi candidate to |
295 avoid processing it twice. Valid only if visited==1. */ | 295 avoid processing it twice. Valid only if visited==1. */ |
296 tree cached_basis; | 296 tree cached_basis; |
297 }; | 297 }; |
298 | 298 |
299 typedef struct slsr_cand_d slsr_cand, *slsr_cand_t; | 299 typedef class slsr_cand_d slsr_cand, *slsr_cand_t; |
300 typedef const struct slsr_cand_d *const_slsr_cand_t; | 300 typedef const class slsr_cand_d *const_slsr_cand_t; |
301 | 301 |
302 /* Pointers to candidates are chained together as part of a mapping | 302 /* Pointers to candidates are chained together as part of a mapping |
303 from base expressions to the candidates that use them. */ | 303 from base expressions to the candidates that use them. */ |
304 | 304 |
305 struct cand_chain_d | 305 struct cand_chain_d |
327 When we are not going to generate address arithmetic we treat | 327 When we are not going to generate address arithmetic we treat |
328 increments that differ only in sign as the same, allowing sharing | 328 increments that differ only in sign as the same, allowing sharing |
329 of the cost of initializers. The absolute value of the increment | 329 of the cost of initializers. The absolute value of the increment |
330 is stored in the incr_info. */ | 330 is stored in the incr_info. */ |
331 | 331 |
332 struct incr_info_d | 332 class incr_info_d |
333 { | 333 { |
334 public: | |
334 /* The increment that relates a candidate to its basis. */ | 335 /* The increment that relates a candidate to its basis. */ |
335 widest_int incr; | 336 widest_int incr; |
336 | 337 |
337 /* How many times the increment occurs in the candidate tree. */ | 338 /* How many times the increment occurs in the candidate tree. */ |
338 unsigned count; | 339 unsigned count; |
350 /* If the initializer was found to already exist, this is the block | 351 /* If the initializer was found to already exist, this is the block |
351 where it was found. */ | 352 where it was found. */ |
352 basic_block init_bb; | 353 basic_block init_bb; |
353 }; | 354 }; |
354 | 355 |
355 typedef struct incr_info_d incr_info, *incr_info_t; | 356 typedef class incr_info_d incr_info, *incr_info_t; |
356 | 357 |
357 /* Candidates are maintained in a vector. If candidate X dominates | 358 /* Candidates are maintained in a vector. If candidate X dominates |
358 candidate Y, then X appears before Y in the vector; but the | 359 candidate Y, then X appears before Y in the vector; but the |
359 converse does not necessarily hold. */ | 360 converse does not necessarily hold. */ |
360 static vec<slsr_cand_t> cand_vec; | 361 static vec<slsr_cand_t> cand_vec; |
416 /* Produce a pointer to the IDX'th candidate in the candidate vector. */ | 417 /* Produce a pointer to the IDX'th candidate in the candidate vector. */ |
417 | 418 |
418 static slsr_cand_t | 419 static slsr_cand_t |
419 lookup_cand (cand_idx idx) | 420 lookup_cand (cand_idx idx) |
420 { | 421 { |
421 return cand_vec[idx - 1]; | 422 return cand_vec[idx]; |
422 } | 423 } |
423 | 424 |
424 /* Helper for hashing a candidate chain header. */ | 425 /* Helper for hashing a candidate chain header. */ |
425 | 426 |
426 struct cand_chain_hasher : nofree_ptr_hash <cand_chain> | 427 struct cand_chain_hasher : nofree_ptr_hash <cand_chain> |
542 cand_chain_t chain; | 543 cand_chain_t chain; |
543 slsr_cand_t basis = NULL; | 544 slsr_cand_t basis = NULL; |
544 | 545 |
545 // Limit potential of N^2 behavior for long candidate chains. | 546 // Limit potential of N^2 behavior for long candidate chains. |
546 int iters = 0; | 547 int iters = 0; |
547 int max_iters = PARAM_VALUE (PARAM_MAX_SLSR_CANDIDATE_SCAN); | 548 int max_iters = param_max_slsr_candidate_scan; |
548 | 549 |
549 mapping_key.base_expr = base_expr; | 550 mapping_key.base_expr = base_expr; |
550 chain = base_cand_map->find (&mapping_key); | 551 chain = base_cand_map->find (&mapping_key); |
551 | 552 |
552 for (; chain && iters < max_iters; chain = chain->next, ++iters) | 553 for (; chain && iters < max_iters; chain = chain->next, ++iters) |
686 c->stride = stride; | 687 c->stride = stride; |
687 c->index = index; | 688 c->index = index; |
688 c->cand_type = ctype; | 689 c->cand_type = ctype; |
689 c->stride_type = stype; | 690 c->stride_type = stype; |
690 c->kind = kind; | 691 c->kind = kind; |
691 c->cand_num = cand_vec.length () + 1; | 692 c->cand_num = cand_vec.length (); |
692 c->next_interp = 0; | 693 c->next_interp = 0; |
693 c->first_interp = c->cand_num; | 694 c->first_interp = c->cand_num; |
694 c->dependent = 0; | 695 c->dependent = 0; |
695 c->sibling = 0; | 696 c->sibling = 0; |
696 c->def_phi = kind == CAND_MULT ? find_phi_def (base) : 0; | 697 c->def_phi = kind == CAND_MULT ? find_phi_def (base) : 0; |
803 slsr_process_phi (gphi *phi, bool speed) | 804 slsr_process_phi (gphi *phi, bool speed) |
804 { | 805 { |
805 unsigned i; | 806 unsigned i; |
806 tree arg0_base = NULL_TREE, base_type; | 807 tree arg0_base = NULL_TREE, base_type; |
807 slsr_cand_t c; | 808 slsr_cand_t c; |
808 struct loop *cand_loop = gimple_bb (phi)->loop_father; | 809 class loop *cand_loop = gimple_bb (phi)->loop_father; |
809 unsigned savings = 0; | 810 unsigned savings = 0; |
810 | 811 |
811 /* A CAND_PHI requires each of its arguments to have the same | 812 /* A CAND_PHI requires each of its arguments to have the same |
812 derived base name. (See the module header commentary for a | 813 derived base name. (See the module header commentary for a |
813 definition of derived base names.) Furthermore, all feeding | 814 definition of derived base names.) Furthermore, all feeding |
931 /* X = B + (i * S), S is integer one. */ | 932 /* X = B + (i * S), S is integer one. */ |
932 *pbase = base_cand->base_expr; | 933 *pbase = base_cand->base_expr; |
933 return base_cand->index; | 934 return base_cand->index; |
934 } | 935 } |
935 | 936 |
936 if (base_cand->next_interp) | 937 base_cand = lookup_cand (base_cand->next_interp); |
937 base_cand = lookup_cand (base_cand->next_interp); | |
938 else | |
939 base_cand = NULL; | |
940 } | 938 } |
941 | 939 |
942 return 0; | 940 return 0; |
943 } | 941 } |
944 | 942 |
1122 if (has_single_use (base_in)) | 1120 if (has_single_use (base_in)) |
1123 savings = (base_cand->dead_savings | 1121 savings = (base_cand->dead_savings |
1124 + stmt_cost (base_cand->cand_stmt, speed)); | 1122 + stmt_cost (base_cand->cand_stmt, speed)); |
1125 } | 1123 } |
1126 | 1124 |
1127 if (base_cand->next_interp) | 1125 base_cand = lookup_cand (base_cand->next_interp); |
1128 base_cand = lookup_cand (base_cand->next_interp); | |
1129 else | |
1130 base_cand = NULL; | |
1131 } | 1126 } |
1132 | 1127 |
1133 if (!base) | 1128 if (!base) |
1134 { | 1129 { |
1135 /* No interpretations had anything useful to propagate, so | 1130 /* No interpretations had anything useful to propagate, so |
1212 if (has_single_use (base_in)) | 1207 if (has_single_use (base_in)) |
1213 savings = (base_cand->dead_savings | 1208 savings = (base_cand->dead_savings |
1214 + stmt_cost (base_cand->cand_stmt, speed)); | 1209 + stmt_cost (base_cand->cand_stmt, speed)); |
1215 } | 1210 } |
1216 | 1211 |
1217 if (base_cand->next_interp) | 1212 base_cand = lookup_cand (base_cand->next_interp); |
1218 base_cand = lookup_cand (base_cand->next_interp); | |
1219 else | |
1220 base_cand = NULL; | |
1221 } | 1213 } |
1222 | 1214 |
1223 if (!base) | 1215 if (!base) |
1224 { | 1216 { |
1225 /* No interpretations had anything useful to propagate, so | 1217 /* No interpretations had anything useful to propagate, so |
1266 is the stride and RHS2 is the base expression. */ | 1258 is the stride and RHS2 is the base expression. */ |
1267 c2 = create_mul_ssa_cand (gs, rhs2, rhs1, speed); | 1259 c2 = create_mul_ssa_cand (gs, rhs2, rhs1, speed); |
1268 c->next_interp = c2->cand_num; | 1260 c->next_interp = c2->cand_num; |
1269 c2->first_interp = c->cand_num; | 1261 c2->first_interp = c->cand_num; |
1270 } | 1262 } |
1271 else if (TREE_CODE (rhs2) == INTEGER_CST) | 1263 else if (TREE_CODE (rhs2) == INTEGER_CST && !integer_zerop (rhs2)) |
1272 { | 1264 { |
1273 /* Record an interpretation for the multiply-immediate. */ | 1265 /* Record an interpretation for the multiply-immediate. */ |
1274 c = create_mul_imm_cand (gs, rhs1, rhs2, speed); | 1266 c = create_mul_imm_cand (gs, rhs1, rhs2, speed); |
1275 | 1267 |
1276 /* Add the interpretation to the statement-candidate mapping. */ | 1268 /* Add the interpretation to the statement-candidate mapping. */ |
1318 if (has_single_use (addend_in)) | 1310 if (has_single_use (addend_in)) |
1319 savings = (addend_cand->dead_savings | 1311 savings = (addend_cand->dead_savings |
1320 + stmt_cost (addend_cand->cand_stmt, speed)); | 1312 + stmt_cost (addend_cand->cand_stmt, speed)); |
1321 } | 1313 } |
1322 | 1314 |
1323 if (addend_cand->next_interp) | 1315 addend_cand = lookup_cand (addend_cand->next_interp); |
1324 addend_cand = lookup_cand (addend_cand->next_interp); | |
1325 else | |
1326 addend_cand = NULL; | |
1327 } | 1316 } |
1328 | 1317 |
1329 while (base_cand && !base && base_cand->kind != CAND_PHI) | 1318 while (base_cand && !base && base_cand->kind != CAND_PHI) |
1330 { | 1319 { |
1331 if (base_cand->kind == CAND_ADD | 1320 if (base_cand->kind == CAND_ADD |
1369 stype = subtrahend_cand->cand_type; | 1358 stype = subtrahend_cand->cand_type; |
1370 if (has_single_use (addend_in)) | 1359 if (has_single_use (addend_in)) |
1371 savings = (subtrahend_cand->dead_savings | 1360 savings = (subtrahend_cand->dead_savings |
1372 + stmt_cost (subtrahend_cand->cand_stmt, speed)); | 1361 + stmt_cost (subtrahend_cand->cand_stmt, speed)); |
1373 } | 1362 } |
1374 | 1363 |
1375 if (subtrahend_cand->next_interp) | 1364 subtrahend_cand = lookup_cand (subtrahend_cand->next_interp); |
1376 subtrahend_cand = lookup_cand (subtrahend_cand->next_interp); | |
1377 else | |
1378 subtrahend_cand = NULL; | |
1379 } | 1365 } |
1380 } | 1366 } |
1381 | 1367 |
1382 if (base_cand->next_interp) | 1368 base_cand = lookup_cand (base_cand->next_interp); |
1383 base_cand = lookup_cand (base_cand->next_interp); | |
1384 else | |
1385 base_cand = NULL; | |
1386 } | 1369 } |
1387 | 1370 |
1388 if (!base) | 1371 if (!base) |
1389 { | 1372 { |
1390 /* No interpretations had anything useful to propagate, so | 1373 /* No interpretations had anything useful to propagate, so |
1444 if (has_single_use (base_in)) | 1427 if (has_single_use (base_in)) |
1445 savings = (base_cand->dead_savings | 1428 savings = (base_cand->dead_savings |
1446 + stmt_cost (base_cand->cand_stmt, speed)); | 1429 + stmt_cost (base_cand->cand_stmt, speed)); |
1447 } | 1430 } |
1448 | 1431 |
1449 if (base_cand->next_interp) | 1432 base_cand = lookup_cand (base_cand->next_interp); |
1450 base_cand = lookup_cand (base_cand->next_interp); | |
1451 else | |
1452 base_cand = NULL; | |
1453 } | 1433 } |
1454 | 1434 |
1455 if (!base) | 1435 if (!base) |
1456 { | 1436 { |
1457 /* No interpretations had anything useful to propagate, so | 1437 /* No interpretations had anything useful to propagate, so |
1650 first_cand = c; | 1630 first_cand = c; |
1651 | 1631 |
1652 if (first_cand != c) | 1632 if (first_cand != c) |
1653 c->first_interp = first_cand->cand_num; | 1633 c->first_interp = first_cand->cand_num; |
1654 | 1634 |
1655 if (base_cand->next_interp) | 1635 base_cand = lookup_cand (base_cand->next_interp); |
1656 base_cand = lookup_cand (base_cand->next_interp); | |
1657 else | |
1658 base_cand = NULL; | |
1659 } | 1636 } |
1660 } | 1637 } |
1661 else | 1638 else |
1662 { | 1639 { |
1663 /* If nothing is known about the RHS, create fresh CAND_ADD and | 1640 /* If nothing is known about the RHS, create fresh CAND_ADD and |
1717 first_cand = c; | 1694 first_cand = c; |
1718 | 1695 |
1719 if (first_cand != c) | 1696 if (first_cand != c) |
1720 c->first_interp = first_cand->cand_num; | 1697 c->first_interp = first_cand->cand_num; |
1721 | 1698 |
1722 if (base_cand->next_interp) | 1699 base_cand = lookup_cand (base_cand->next_interp); |
1723 base_cand = lookup_cand (base_cand->next_interp); | |
1724 else | |
1725 base_cand = NULL; | |
1726 } | 1700 } |
1727 } | 1701 } |
1728 else | 1702 else |
1729 { | 1703 { |
1730 /* If nothing is known about the RHS, create fresh CAND_ADD and | 1704 /* If nothing is known about the RHS, create fresh CAND_ADD and |
1931 slsr_cand_t c; | 1905 slsr_cand_t c; |
1932 | 1906 |
1933 fprintf (dump_file, "\nStrength reduction candidate vector:\n\n"); | 1907 fprintf (dump_file, "\nStrength reduction candidate vector:\n\n"); |
1934 | 1908 |
1935 FOR_EACH_VEC_ELT (cand_vec, i, c) | 1909 FOR_EACH_VEC_ELT (cand_vec, i, c) |
1936 dump_candidate (c); | 1910 if (c != NULL) |
1911 dump_candidate (c); | |
1937 } | 1912 } |
1938 | 1913 |
1939 /* Callback used to dump the candidate chains hash table. */ | 1914 /* Callback used to dump the candidate chains hash table. */ |
1940 | 1915 |
1941 int | 1916 int |
2021 copy_ref_info (mem_ref, *expr); | 1996 copy_ref_info (mem_ref, *expr); |
2022 *expr = mem_ref; | 1997 *expr = mem_ref; |
2023 update_stmt (c->cand_stmt); | 1998 update_stmt (c->cand_stmt); |
2024 } | 1999 } |
2025 | 2000 |
2001 /* Return true if CAND_REF candidate C is a valid memory reference. */ | |
2002 | |
2003 static bool | |
2004 valid_mem_ref_cand_p (slsr_cand_t c) | |
2005 { | |
2006 if (TREE_CODE (TREE_OPERAND (c->stride, 1)) != INTEGER_CST) | |
2007 return false; | |
2008 | |
2009 struct mem_address addr | |
2010 = { NULL_TREE, c->base_expr, TREE_OPERAND (c->stride, 0), | |
2011 TREE_OPERAND (c->stride, 1), wide_int_to_tree (sizetype, c->index) }; | |
2012 | |
2013 return | |
2014 valid_mem_ref_p (TYPE_MODE (c->cand_type), TYPE_ADDR_SPACE (c->cand_type), | |
2015 &addr); | |
2016 } | |
2017 | |
2026 /* Replace CAND_REF candidate C, each sibling of candidate C, and each | 2018 /* Replace CAND_REF candidate C, each sibling of candidate C, and each |
2027 dependent of candidate C with an equivalent strength-reduced data | 2019 dependent of candidate C with an equivalent strength-reduced data |
2028 reference. */ | 2020 reference. */ |
2029 | 2021 |
2030 static void | 2022 static void |
2031 replace_refs (slsr_cand_t c) | 2023 replace_refs (slsr_cand_t c) |
2032 { | 2024 { |
2025 /* Replacing a chain of only 2 candidates which are valid memory references | |
2026 is generally counter-productive because you cannot recoup the additional | |
2027 calculation added in front of them. */ | |
2028 if (c->basis == 0 | |
2029 && c->dependent | |
2030 && !lookup_cand (c->dependent)->dependent | |
2031 && valid_mem_ref_cand_p (c) | |
2032 && valid_mem_ref_cand_p (lookup_cand (c->dependent))) | |
2033 return; | |
2034 | |
2033 if (dump_file && (dump_flags & TDF_DETAILS)) | 2035 if (dump_file && (dump_flags & TDF_DETAILS)) |
2034 { | 2036 { |
2035 fputs ("Replacing reference: ", dump_file); | 2037 fputs ("Replacing reference: ", dump_file); |
2036 print_gimple_stmt (dump_file, c->cand_stmt, 0); | 2038 print_gimple_stmt (dump_file, c->cand_stmt, 0); |
2037 } | 2039 } |
2179 gimple_set_location (copy_stmt, gimple_location (c->cand_stmt)); | 2181 gimple_set_location (copy_stmt, gimple_location (c->cand_stmt)); |
2180 gsi_replace (&gsi, copy_stmt, false); | 2182 gsi_replace (&gsi, copy_stmt, false); |
2181 while (cc) | 2183 while (cc) |
2182 { | 2184 { |
2183 cc->cand_stmt = copy_stmt; | 2185 cc->cand_stmt = copy_stmt; |
2184 cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL; | 2186 cc = lookup_cand (cc->next_interp); |
2185 } | 2187 } |
2186 if (dump_file && (dump_flags & TDF_DETAILS)) | 2188 if (dump_file && (dump_flags & TDF_DETAILS)) |
2187 stmt_to_print = copy_stmt; | 2189 stmt_to_print = copy_stmt; |
2188 } | 2190 } |
2189 else | 2191 else |
2212 gimple_assign_set_rhs_with_ops (&gsi, code, basis_name, bump_tree); | 2214 gimple_assign_set_rhs_with_ops (&gsi, code, basis_name, bump_tree); |
2213 update_stmt (gsi_stmt (gsi)); | 2215 update_stmt (gsi_stmt (gsi)); |
2214 while (cc) | 2216 while (cc) |
2215 { | 2217 { |
2216 cc->cand_stmt = gsi_stmt (gsi); | 2218 cc->cand_stmt = gsi_stmt (gsi); |
2217 cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL; | 2219 cc = lookup_cand (cc->next_interp); |
2218 } | 2220 } |
2219 if (dump_file && (dump_flags & TDF_DETAILS)) | 2221 if (dump_file && (dump_flags & TDF_DETAILS)) |
2220 stmt_to_print = gsi_stmt (gsi); | 2222 stmt_to_print = gsi_stmt (gsi); |
2221 } | 2223 } |
2222 } | 2224 } |
3652 gimple_assign_set_rhs_with_ops (&gsi, new_code, new_rhs1, new_rhs2); | 3654 gimple_assign_set_rhs_with_ops (&gsi, new_code, new_rhs1, new_rhs2); |
3653 update_stmt (gsi_stmt (gsi)); | 3655 update_stmt (gsi_stmt (gsi)); |
3654 while (cc) | 3656 while (cc) |
3655 { | 3657 { |
3656 cc->cand_stmt = gsi_stmt (gsi); | 3658 cc->cand_stmt = gsi_stmt (gsi); |
3657 cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL; | 3659 cc = lookup_cand (cc->next_interp); |
3658 } | 3660 } |
3659 | 3661 |
3660 if (dump_file && (dump_flags & TDF_DETAILS)) | 3662 if (dump_file && (dump_flags & TDF_DETAILS)) |
3661 return gsi_stmt (gsi); | 3663 return gsi_stmt (gsi); |
3662 } | 3664 } |
3768 gimple_assign_set_rhs_with_ops (&gsi, MINUS_EXPR, basis_name, rhs2); | 3770 gimple_assign_set_rhs_with_ops (&gsi, MINUS_EXPR, basis_name, rhs2); |
3769 update_stmt (gsi_stmt (gsi)); | 3771 update_stmt (gsi_stmt (gsi)); |
3770 while (cc) | 3772 while (cc) |
3771 { | 3773 { |
3772 cc->cand_stmt = gsi_stmt (gsi); | 3774 cc->cand_stmt = gsi_stmt (gsi); |
3773 cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL; | 3775 cc = lookup_cand (cc->next_interp); |
3774 } | 3776 } |
3775 | 3777 |
3776 if (dump_file && (dump_flags & TDF_DETAILS)) | 3778 if (dump_file && (dump_flags & TDF_DETAILS)) |
3777 stmt_to_print = gsi_stmt (gsi); | 3779 stmt_to_print = gsi_stmt (gsi); |
3778 } | 3780 } |
3794 gimple_set_location (copy_stmt, gimple_location (c->cand_stmt)); | 3796 gimple_set_location (copy_stmt, gimple_location (c->cand_stmt)); |
3795 gsi_replace (&gsi, copy_stmt, false); | 3797 gsi_replace (&gsi, copy_stmt, false); |
3796 while (cc) | 3798 while (cc) |
3797 { | 3799 { |
3798 cc->cand_stmt = copy_stmt; | 3800 cc->cand_stmt = copy_stmt; |
3799 cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL; | 3801 cc = lookup_cand (cc->next_interp); |
3800 } | 3802 } |
3801 | 3803 |
3802 if (dump_file && (dump_flags & TDF_DETAILS)) | 3804 if (dump_file && (dump_flags & TDF_DETAILS)) |
3803 stmt_to_print = copy_stmt; | 3805 stmt_to_print = copy_stmt; |
3804 } | 3806 } |
3810 gimple_set_location (cast_stmt, gimple_location (c->cand_stmt)); | 3812 gimple_set_location (cast_stmt, gimple_location (c->cand_stmt)); |
3811 gsi_replace (&gsi, cast_stmt, false); | 3813 gsi_replace (&gsi, cast_stmt, false); |
3812 while (cc) | 3814 while (cc) |
3813 { | 3815 { |
3814 cc->cand_stmt = cast_stmt; | 3816 cc->cand_stmt = cast_stmt; |
3815 cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL; | 3817 cc = lookup_cand (cc->next_interp); |
3816 } | 3818 } |
3817 | 3819 |
3818 if (dump_file && (dump_flags & TDF_DETAILS)) | 3820 if (dump_file && (dump_flags & TDF_DETAILS)) |
3819 stmt_to_print = cast_stmt; | 3821 stmt_to_print = cast_stmt; |
3820 } | 3822 } |
3900 slsr_cand_t c; | 3902 slsr_cand_t c; |
3901 | 3903 |
3902 /* Each candidate that has a null basis and a non-null | 3904 /* Each candidate that has a null basis and a non-null |
3903 dependent is the root of a tree of related statements. | 3905 dependent is the root of a tree of related statements. |
3904 Analyze each tree to determine a subset of those | 3906 Analyze each tree to determine a subset of those |
3905 statements that can be replaced with maximum benefit. */ | 3907 statements that can be replaced with maximum benefit. |
3906 FOR_EACH_VEC_ELT (cand_vec, i, c) | 3908 |
3909 Note the first NULL element is skipped. */ | |
3910 FOR_EACH_VEC_ELT_FROM (cand_vec, i, c, 1) | |
3907 { | 3911 { |
3908 slsr_cand_t first_dep; | 3912 slsr_cand_t first_dep; |
3909 | 3913 |
3910 if (c->basis != 0 || c->dependent == 0) | 3914 if (c->basis != 0 || c->dependent == 0) |
3911 continue; | 3915 continue; |
4008 pass_strength_reduction::execute (function *fun) | 4012 pass_strength_reduction::execute (function *fun) |
4009 { | 4013 { |
4010 /* Create the obstack where candidates will reside. */ | 4014 /* Create the obstack where candidates will reside. */ |
4011 gcc_obstack_init (&cand_obstack); | 4015 gcc_obstack_init (&cand_obstack); |
4012 | 4016 |
4013 /* Allocate the candidate vector. */ | 4017 /* Allocate the candidate vector and initialize the first NULL element. */ |
4014 cand_vec.create (128); | 4018 cand_vec.create (128); |
4019 cand_vec.safe_push (NULL); | |
4015 | 4020 |
4016 /* Allocate the mapping from statements to candidate indices. */ | 4021 /* Allocate the mapping from statements to candidate indices. */ |
4017 stmt_cand_map = new hash_map<gimple *, slsr_cand_t>; | 4022 stmt_cand_map = new hash_map<gimple *, slsr_cand_t>; |
4018 | 4023 |
4019 /* Create the obstack where candidate chains will reside. */ | 4024 /* Create the obstack where candidate chains will reside. */ |