comparison gcc/tree-predcom.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 /* Predictive commoning. 1 /* Predictive commoning.
2 Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc. 2 Copyright (C) 2005, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
3 4
4 This file is part of GCC. 5 This file is part of GCC.
5 6
6 GCC is free software; you can redistribute it and/or modify it 7 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
196 #include "tree-data-ref.h" 197 #include "tree-data-ref.h"
197 #include "tree-scalar-evolution.h" 198 #include "tree-scalar-evolution.h"
198 #include "tree-chrec.h" 199 #include "tree-chrec.h"
199 #include "params.h" 200 #include "params.h"
200 #include "diagnostic.h" 201 #include "diagnostic.h"
202 #include "tree-pretty-print.h"
203 #include "gimple-pretty-print.h"
201 #include "tree-pass.h" 204 #include "tree-pass.h"
202 #include "tree-affine.h" 205 #include "tree-affine.h"
203 #include "tree-inline.h" 206 #include "tree-inline.h"
204 207
205 /* The maximum number of iterations between the considered memory 208 /* The maximum number of iterations between the considered memory
1178 VEC (chain_p, heap) **chains) 1181 VEC (chain_p, heap) **chains)
1179 { 1182 {
1180 unsigned i; 1183 unsigned i;
1181 dref a; 1184 dref a;
1182 chain_p chain = NULL; 1185 chain_p chain = NULL;
1186 double_int last_ofs = double_int_zero;
1183 1187
1184 /* Invariants are handled specially. */ 1188 /* Invariants are handled specially. */
1185 if (comp->comp_step == RS_INVARIANT) 1189 if (comp->comp_step == RS_INVARIANT)
1186 { 1190 {
1187 chain = make_invariant_chain (comp); 1191 chain = make_invariant_chain (comp);
1192 qsort (VEC_address (dref, comp->refs), VEC_length (dref, comp->refs), 1196 qsort (VEC_address (dref, comp->refs), VEC_length (dref, comp->refs),
1193 sizeof (dref), order_drefs); 1197 sizeof (dref), order_drefs);
1194 1198
1195 for (i = 0; VEC_iterate (dref, comp->refs, i, a); i++) 1199 for (i = 0; VEC_iterate (dref, comp->refs, i, a); i++)
1196 { 1200 {
1197 if (!chain || !DR_IS_READ (a->ref)) 1201 if (!chain || !DR_IS_READ (a->ref)
1202 || double_int_ucmp (uhwi_to_double_int (MAX_DISTANCE),
1203 double_int_add (a->offset,
1204 double_int_neg (last_ofs))) <= 0)
1198 { 1205 {
1199 if (nontrivial_chain_p (chain)) 1206 if (nontrivial_chain_p (chain))
1200 VEC_safe_push (chain_p, heap, *chains, chain); 1207 {
1208 add_looparound_copies (loop, chain);
1209 VEC_safe_push (chain_p, heap, *chains, chain);
1210 }
1201 else 1211 else
1202 release_chain (chain); 1212 release_chain (chain);
1203 chain = make_rooted_chain (a); 1213 chain = make_rooted_chain (a);
1214 last_ofs = a->offset;
1204 continue; 1215 continue;
1205 } 1216 }
1206 1217
1207 add_ref_to_chain (chain, a); 1218 add_ref_to_chain (chain, a);
1208 } 1219 }
1336 return NULL_TREE; 1347 return NULL_TREE;
1337 } 1348 }
1338 else if (!INDIRECT_REF_P (ref)) 1349 else if (!INDIRECT_REF_P (ref))
1339 return unshare_expr (ref); 1350 return unshare_expr (ref);
1340 1351
1341 if (TREE_CODE (ref) == INDIRECT_REF) 1352 if (INDIRECT_REF_P (ref))
1342 { 1353 {
1343 ret = build1 (INDIRECT_REF, TREE_TYPE (ref), NULL_TREE); 1354 /* Take care for INDIRECT_REF and MISALIGNED_INDIRECT_REF at
1355 the same time. */
1356 ret = copy_node (ref);
1344 idx = TREE_OPERAND (ref, 0); 1357 idx = TREE_OPERAND (ref, 0);
1345 idx_p = &TREE_OPERAND (ret, 0); 1358 idx_p = &TREE_OPERAND (ret, 0);
1346 } 1359 }
1347 else if (TREE_CODE (ref) == COMPONENT_REF) 1360 else if (TREE_CODE (ref) == COMPONENT_REF)
1348 { 1361 {
1447 1460
1448 static tree 1461 static tree
1449 predcom_tmp_var (tree ref, unsigned i, bitmap tmp_vars) 1462 predcom_tmp_var (tree ref, unsigned i, bitmap tmp_vars)
1450 { 1463 {
1451 tree type = TREE_TYPE (ref); 1464 tree type = TREE_TYPE (ref);
1452 tree var = create_tmp_var (type, get_lsm_tmp_name (ref, i));
1453
1454 /* We never access the components of the temporary variable in predictive 1465 /* We never access the components of the temporary variable in predictive
1455 commoning. */ 1466 commoning. */
1456 if (TREE_CODE (type) == COMPLEX_TYPE 1467 tree var = create_tmp_reg (type, get_lsm_tmp_name (ref, i));
1457 || TREE_CODE (type) == VECTOR_TYPE)
1458 DECL_GIMPLE_REG_P (var) = 1;
1459 1468
1460 add_referenced_var (var); 1469 add_referenced_var (var);
1461 bitmap_set_bit (tmp_vars, DECL_UID (var)); 1470 bitmap_set_bit (tmp_vars, DECL_UID (var));
1462 return var; 1471 return var;
1463 } 1472 }
1877 static void 1886 static void
1878 base_names_in_chain_on (struct loop *loop, tree name, tree var) 1887 base_names_in_chain_on (struct loop *loop, tree name, tree var)
1879 { 1888 {
1880 gimple stmt, phi; 1889 gimple stmt, phi;
1881 imm_use_iterator iter; 1890 imm_use_iterator iter;
1882 edge e;
1883 1891
1884 SSA_NAME_VAR (name) = var; 1892 SSA_NAME_VAR (name) = var;
1885 1893
1886 while (1) 1894 while (1)
1887 { 1895 {
1895 BREAK_FROM_IMM_USE_STMT (iter); 1903 BREAK_FROM_IMM_USE_STMT (iter);
1896 } 1904 }
1897 } 1905 }
1898 if (!phi) 1906 if (!phi)
1899 return; 1907 return;
1900
1901 if (gimple_bb (phi) == loop->header)
1902 e = loop_latch_edge (loop);
1903 else
1904 e = single_pred_edge (gimple_bb (stmt));
1905 1908
1906 name = PHI_RESULT (phi); 1909 name = PHI_RESULT (phi);
1907 SSA_NAME_VAR (name) = var; 1910 SSA_NAME_VAR (name) = var;
1908 } 1911 }
1909 } 1912 }
2202 remove_name_from_operation (stmt1, name1); 2205 remove_name_from_operation (stmt1, name1);
2203 remove_name_from_operation (stmt2, name2); 2206 remove_name_from_operation (stmt2, name2);
2204 2207
2205 /* Insert the new statement combining NAME1 and NAME2 before S1, and 2208 /* Insert the new statement combining NAME1 and NAME2 before S1, and
2206 combine it with the rhs of S1. */ 2209 combine it with the rhs of S1. */
2207 var = create_tmp_var (type, "predreastmp"); 2210 var = create_tmp_reg (type, "predreastmp");
2208 add_referenced_var (var); 2211 add_referenced_var (var);
2209 new_name = make_ssa_name (var, NULL); 2212 new_name = make_ssa_name (var, NULL);
2210 new_stmt = gimple_build_assign_with_ops (code, new_name, name1, name2); 2213 new_stmt = gimple_build_assign_with_ops (code, new_name, name1, name2);
2211 2214
2212 var = create_tmp_var (type, "predreastmp"); 2215 var = create_tmp_reg (type, "predreastmp");
2213 add_referenced_var (var); 2216 add_referenced_var (var);
2214 tmp_name = make_ssa_name (var, NULL); 2217 tmp_name = make_ssa_name (var, NULL);
2215 2218
2216 /* Rhs of S1 may now be either a binary expression with operation 2219 /* Rhs of S1 may now be either a binary expression with operation
2217 CODE, or gimple_val (in case that stmt1 == s1 or stmt2 == s1, 2220 CODE, or gimple_val (in case that stmt1 == s1 or stmt2 == s1,
2265 unsigned i; 2268 unsigned i;
2266 gimple root_stmt; 2269 gimple root_stmt;
2267 tree rslt_type = NULL_TREE; 2270 tree rslt_type = NULL_TREE;
2268 2271
2269 if (ch1 == ch2) 2272 if (ch1 == ch2)
2270 return false; 2273 return NULL;
2271 if (ch1->length != ch2->length) 2274 if (ch1->length != ch2->length)
2272 return NULL; 2275 return NULL;
2273 2276
2274 if (VEC_length (dref, ch1->refs) != VEC_length (dref, ch2->refs)) 2277 if (VEC_length (dref, ch1->refs) != VEC_length (dref, ch2->refs))
2275 return NULL; 2278 return NULL;