1 /* Single entry single exit control flow regions.
2 Copyright (C) 2008-2015 Free Software Foundation, Inc.
3 Contributed by Jan Sjodin <jan.sjodin@amd.com> and
4 Sebastian Pop <sebastian.pop@amd.com>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
29 #include "tree-pass.h"
31 #include "tree-pretty-print.h"
32 #include "fold-const.h"
33 #include "gimple-fold.h"
36 #include "gimple-iterator.h"
37 #include "gimplify-me.h"
39 #include "tree-ssa-loop.h"
40 #include "tree-into-ssa.h"
42 #include "tree-data-ref.h"
43 #include "tree-scalar-evolution.h"
44 #include "value-prof.h"
46 #include "tree-ssa-propagate.h"
47 #include "tree-hash-traits.h"
49 /* Helper function for debug_rename_map. */
52 debug_rename_map_1 (tree_node
*const &old_name
, tree_node
*const &expr
,
55 fprintf (stderr
, "(");
56 print_generic_expr (stderr
, old_name
, 0);
57 fprintf (stderr
, ", ");
58 print_generic_expr (stderr
, expr
, 0);
59 fprintf (stderr
, ")\n");
63 typedef hash_map
<tree_ssa_name_hash
, tree
> rename_map_type
;
66 /* Print to stderr all the elements of RENAME_MAP. */
69 debug_rename_map (rename_map_type
*rename_map
)
71 rename_map
->traverse
<void *, debug_rename_map_1
> (NULL
);
75 /* Record LOOP as occurring in REGION. */
78 sese_record_loop (sese_info_p region
, loop_p loop
)
80 if (sese_contains_loop (region
, loop
))
83 bitmap_set_bit (SESE_LOOPS (region
), loop
->num
);
84 SESE_LOOP_NEST (region
).safe_push (loop
);
87 /* Build the loop nests contained in REGION. Returns true when the
88 operation was successful. */
91 build_sese_loop_nests (sese_info_p region
)
95 struct loop
*loop0
, *loop1
;
97 FOR_EACH_BB_FN (bb
, cfun
)
98 if (bb_in_sese_p (bb
, region
->region
))
100 struct loop
*loop
= bb
->loop_father
;
102 /* Only add loops if they are completely contained in the SCoP. */
103 if (loop
->header
== bb
104 && bb_in_sese_p (loop
->latch
, region
->region
))
105 sese_record_loop (region
, loop
);
108 /* Make sure that the loops in the SESE_LOOP_NEST are ordered. It
109 can be the case that an inner loop is inserted before an outer
110 loop. To avoid this, semi-sort once. */
111 FOR_EACH_VEC_ELT (SESE_LOOP_NEST (region
), i
, loop0
)
113 if (SESE_LOOP_NEST (region
).length () == i
+ 1)
116 loop1
= SESE_LOOP_NEST (region
)[i
+ 1];
117 if (loop0
->num
> loop1
->num
)
119 SESE_LOOP_NEST (region
)[i
] = loop1
;
120 SESE_LOOP_NEST (region
)[i
+ 1] = loop0
;
125 /* For a USE in BB, if BB is outside REGION, mark the USE in the
129 sese_build_liveouts_use (sese_info_p region
, bitmap liveouts
, basic_block bb
,
132 gcc_assert (!bb_in_sese_p (bb
, region
->region
));
133 if (TREE_CODE (use
) != SSA_NAME
)
136 basic_block def_bb
= gimple_bb (SSA_NAME_DEF_STMT (use
));
138 if (!def_bb
|| !bb_in_sese_p (def_bb
, region
->region
))
141 unsigned ver
= SSA_NAME_VERSION (use
);
142 bitmap_set_bit (liveouts
, ver
);
145 /* Marks for rewrite all the SSA_NAMES defined in REGION and that are
146 used in BB that is outside of the REGION. */
149 sese_build_liveouts_bb (sese_info_p region
, bitmap liveouts
, basic_block bb
)
156 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
157 for (gphi_iterator bsi
= gsi_start_phis (e
->dest
); !gsi_end_p (bsi
);
159 sese_build_liveouts_use (region
, liveouts
, bb
,
160 PHI_ARG_DEF_FROM_EDGE (bsi
.phi (), e
));
162 for (gimple_stmt_iterator bsi
= gsi_start_bb (bb
); !gsi_end_p (bsi
);
165 gimple
*stmt
= gsi_stmt (bsi
);
167 if (is_gimple_debug (stmt
))
170 FOR_EACH_SSA_USE_OPERAND (use_p
, stmt
, iter
, SSA_OP_ALL_USES
)
171 sese_build_liveouts_use (region
, liveouts
, bb
, USE_FROM_PTR (use_p
));
175 /* For a USE in BB, return true if BB is outside REGION and it's not
176 in the LIVEOUTS set. */
179 sese_bad_liveouts_use (sese_info_p region
, bitmap liveouts
, basic_block bb
,
182 gcc_assert (!bb_in_sese_p (bb
, region
->region
));
184 if (TREE_CODE (use
) != SSA_NAME
)
187 unsigned ver
= SSA_NAME_VERSION (use
);
189 /* If it's in liveouts, the variable will get a new PHI node, and
190 the debug use will be properly adjusted. */
191 if (bitmap_bit_p (liveouts
, ver
))
194 basic_block def_bb
= gimple_bb (SSA_NAME_DEF_STMT (use
));
196 if (!def_bb
|| !bb_in_sese_p (def_bb
, region
->region
))
202 /* Reset debug stmts that reference SSA_NAMES defined in REGION that
203 are not marked as liveouts. */
206 sese_reset_debug_liveouts_bb (sese_info_p region
, bitmap liveouts
, basic_block bb
)
208 gimple_stmt_iterator bsi
;
212 for (bsi
= gsi_start_bb (bb
); !gsi_end_p (bsi
); gsi_next (&bsi
))
214 gimple
*stmt
= gsi_stmt (bsi
);
216 if (!is_gimple_debug (stmt
))
219 FOR_EACH_SSA_USE_OPERAND (use_p
, stmt
, iter
, SSA_OP_ALL_USES
)
220 if (sese_bad_liveouts_use (region
, liveouts
, bb
,
221 USE_FROM_PTR (use_p
)))
223 gimple_debug_bind_reset_value (stmt
);
230 /* Build the LIVEOUTS of REGION: the set of variables defined inside
231 and used outside the REGION. */
234 sese_build_liveouts (sese_info_p region
, bitmap liveouts
)
238 /* FIXME: We could start iterating form the successor of sese. */
239 FOR_EACH_BB_FN (bb
, cfun
)
240 if (!bb_in_sese_p (bb
, region
->region
))
241 sese_build_liveouts_bb (region
, liveouts
, bb
);
243 /* FIXME: We could start iterating form the successor of sese. */
244 if (MAY_HAVE_DEBUG_STMTS
)
245 FOR_EACH_BB_FN (bb
, cfun
)
246 if (!bb_in_sese_p (bb
, region
->region
))
247 sese_reset_debug_liveouts_bb (region
, liveouts
, bb
);
250 /* Builds a new SESE region from edges ENTRY and EXIT. */
253 new_sese_info (edge entry
, edge exit
)
255 sese_info_p region
= XNEW (struct sese_info_t
);
257 region
->region
.entry
= entry
;
258 region
->region
.exit
= exit
;
259 SESE_LOOPS (region
) = BITMAP_ALLOC (NULL
);
260 SESE_LOOP_NEST (region
).create (3);
261 SESE_PARAMS (region
).create (3);
262 region
->parameter_rename_map
= new parameter_rename_map_t
;
263 region
->bbs
.create (3);
268 /* Deletes REGION. */
271 free_sese_info (sese_info_p region
)
273 if (SESE_LOOPS (region
))
274 SESE_LOOPS (region
) = BITMAP_ALLOC (NULL
);
276 SESE_PARAMS (region
).release ();
277 SESE_LOOP_NEST (region
).release ();
278 delete region
->parameter_rename_map
;
279 region
->parameter_rename_map
= NULL
;
284 /* Add exit phis for USE on EXIT. */
287 sese_add_exit_phis_edge (basic_block exit
, tree use
, edge false_e
, edge true_e
)
289 gphi
*phi
= create_phi_node (NULL_TREE
, exit
);
290 create_new_def_for (use
, phi
, gimple_phi_result_ptr (phi
));
291 add_phi_arg (phi
, use
, false_e
, UNKNOWN_LOCATION
);
292 add_phi_arg (phi
, use
, true_e
, UNKNOWN_LOCATION
);
296 /* Insert in the block BB phi nodes for variables defined in REGION
297 and used outside the REGION. The code generation moves REGION in
298 the else clause of an "if (1)" and generates code in the then
299 clause that is at this point empty:
308 sese_insert_phis_for_liveouts (sese_info_p region
, basic_block bb
,
309 edge false_e
, edge true_e
)
313 bitmap liveouts
= BITMAP_ALLOC (NULL
);
315 update_ssa (TODO_update_ssa
);
317 sese_build_liveouts (region
, liveouts
);
318 EXECUTE_IF_SET_IN_BITMAP (liveouts
, 0, i
, bi
)
319 sese_add_exit_phis_edge (bb
, ssa_name (i
), false_e
, true_e
);
320 BITMAP_FREE (liveouts
);
322 update_ssa (TODO_update_ssa
);
325 /* Returns the first successor edge of BB with EDGE_TRUE_VALUE flag set. */
328 get_true_edge_from_guard_bb (basic_block bb
)
333 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
334 if (e
->flags
& EDGE_TRUE_VALUE
)
341 /* Returns the first successor edge of BB with EDGE_TRUE_VALUE flag cleared. */
344 get_false_edge_from_guard_bb (basic_block bb
)
349 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
350 if (!(e
->flags
& EDGE_TRUE_VALUE
))
357 /* Returns the expression associated to OLD_NAME in RENAME_MAP. */
360 get_rename (rename_map_type
*rename_map
, tree old_name
)
362 gcc_assert (TREE_CODE (old_name
) == SSA_NAME
);
363 tree
*expr
= rename_map
->get (old_name
);
370 /* Register in RENAME_MAP the rename tuple (OLD_NAME, EXPR). */
373 set_rename (rename_map_type
*rename_map
, tree old_name
, tree expr
,
376 if (old_name
== expr
)
379 rename_map
->put (old_name
, expr
);
383 /* For a parameter of a scop we dont want to rename it. */
384 FOR_EACH_VEC_ELT (SESE_PARAMS (region
), i
, t
)
386 region
->parameter_rename_map
->put(old_name
, expr
);
389 /* Renames the scalar uses of the statement COPY, using the
390 substitution map RENAME_MAP, inserting the gimplification code at
391 GSI_TGT, for the translation REGION, with the original copied
392 statement in LOOP, and using the induction variable renaming map
393 IV_MAP. Returns true when something has been renamed. GLOOG_ERROR
394 is set when the code generation cannot continue. */
397 rename_uses (gimple
*copy
, rename_map_type
*rename_map
,
398 gimple_stmt_iterator
*gsi_tgt
,
399 sese_info_p region
, loop_p loop
, vec
<tree
> iv_map
,
404 bool changed
= false;
406 if (is_gimple_debug (copy
))
408 if (gimple_debug_bind_p (copy
))
409 gimple_debug_bind_reset_value (copy
);
410 else if (gimple_debug_source_bind_p (copy
))
418 FOR_EACH_SSA_USE_OPERAND (use_p
, copy
, op_iter
, SSA_OP_USE
)
420 tree old_name
= USE_FROM_PTR (use_p
);
424 if (TREE_CODE (old_name
) != SSA_NAME
425 || SSA_NAME_IS_DEFAULT_DEF (old_name
))
429 new_expr
= get_rename (rename_map
, old_name
);
432 tree type_old_name
= TREE_TYPE (old_name
);
433 tree type_new_expr
= TREE_TYPE (new_expr
);
435 if (type_old_name
!= type_new_expr
436 || TREE_CODE (new_expr
) != SSA_NAME
)
438 tree var
= create_tmp_var (type_old_name
, "var");
440 if (!useless_type_conversion_p (type_old_name
, type_new_expr
))
441 new_expr
= fold_convert (type_old_name
, new_expr
);
443 new_expr
= force_gimple_operand (new_expr
, &stmts
, true, var
);
444 gsi_insert_seq_before (gsi_tgt
, stmts
, GSI_SAME_STMT
);
447 replace_exp (use_p
, new_expr
);
451 scev
= scalar_evolution_in_region (region
->region
, loop
, old_name
);
453 /* At this point we should know the exact scev for each
454 scalar SSA_NAME used in the scop: all the other scalar
455 SSA_NAMEs should have been translated out of SSA using
456 arrays with one element. */
457 if (chrec_contains_undetermined (scev
))
460 new_expr
= build_zero_cst (TREE_TYPE (old_name
));
463 new_expr
= chrec_apply_map (scev
, iv_map
);
465 /* The apply should produce an expression tree containing
466 the uses of the new induction variables. We should be
467 able to use new_expr instead of the old_name in the newly
468 generated loop nest. */
469 if (chrec_contains_undetermined (new_expr
)
470 || tree_contains_chrecs (new_expr
, NULL
))
473 new_expr
= build_zero_cst (TREE_TYPE (old_name
));
476 /* Replace the old_name with the new_expr. */
477 new_expr
= force_gimple_operand (unshare_expr (new_expr
), &stmts
,
480 gsi_insert_seq_before (gsi_tgt
, stmts
, GSI_SAME_STMT
);
481 replace_exp (use_p
, new_expr
);
483 if (TREE_CODE (new_expr
) == INTEGER_CST
484 && is_gimple_assign (copy
))
486 tree rhs
= gimple_assign_rhs1 (copy
);
488 if (TREE_CODE (rhs
) == ADDR_EXPR
)
489 recompute_tree_invariant_for_addr_expr (rhs
);
492 set_rename (rename_map
, old_name
, new_expr
, region
);
498 /* Duplicates the statements of basic block BB into basic block NEW_BB
499 and compute the new induction variables according to the IV_MAP.
500 GLOOG_ERROR is set when the code generation cannot continue. */
503 graphite_copy_stmts_from_block (basic_block bb
, basic_block new_bb
,
504 rename_map_type
*rename_map
,
505 vec
<tree
> iv_map
, sese_info_p region
,
508 gimple_stmt_iterator gsi
, gsi_tgt
;
509 loop_p loop
= bb
->loop_father
;
511 gsi_tgt
= gsi_start_bb (new_bb
);
512 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
516 gimple
*stmt
= gsi_stmt (gsi
);
520 /* Do not copy labels or conditions. */
521 if (gimple_code (stmt
) == GIMPLE_LABEL
522 || gimple_code (stmt
) == GIMPLE_COND
)
525 /* Do not copy induction variables. */
526 if (is_gimple_assign (stmt
)
527 && (lhs
= gimple_assign_lhs (stmt
))
528 && TREE_CODE (lhs
) == SSA_NAME
529 && is_gimple_reg (lhs
)
530 && scev_analyzable_p (lhs
, region
->region
))
533 /* Do not copy parameters that have been generated in the header of the
535 if (is_gimple_assign (stmt
)
536 && (lhs
= gimple_assign_lhs (stmt
))
537 && TREE_CODE (lhs
) == SSA_NAME
538 && region
->parameter_rename_map
->get(lhs
))
541 /* Create a new copy of STMT and duplicate STMT's virtual
543 copy
= gimple_copy (stmt
);
544 gsi_insert_after (&gsi_tgt
, copy
, GSI_NEW_STMT
);
546 maybe_duplicate_eh_stmt (copy
, stmt
);
547 gimple_duplicate_stmt_histograms (cfun
, copy
, cfun
, stmt
);
549 /* Create new names for all the definitions created by COPY and
550 add replacement mappings for each new name. */
551 FOR_EACH_SSA_DEF_OPERAND (def_p
, copy
, op_iter
, SSA_OP_ALL_DEFS
)
553 tree old_name
= DEF_FROM_PTR (def_p
);
554 tree new_name
= create_new_def_for (old_name
, copy
, def_p
);
555 set_rename (rename_map
, old_name
, new_name
, region
);
558 if (rename_uses (copy
, rename_map
, &gsi_tgt
, region
, loop
, iv_map
,
561 gcc_assert (gsi_stmt (gsi_tgt
) == copy
);
562 fold_stmt_inplace (&gsi_tgt
);
565 /* For each SSA_NAME in the parameter_rename_map rename their usage. */
568 if (!is_gimple_debug (copy
))
569 FOR_EACH_SSA_USE_OPERAND (use_p
, copy
, iter
, SSA_OP_USE
)
571 tree old_name
= USE_FROM_PTR (use_p
);
573 if (TREE_CODE (old_name
) != SSA_NAME
574 || SSA_NAME_IS_DEFAULT_DEF (old_name
))
577 tree
*new_expr
= region
->parameter_rename_map
->get (old_name
);
581 replace_exp (use_p
, *new_expr
);
588 /* Copies BB and includes in the copied BB all the statements that can
589 be reached following the use-def chains from the memory accesses,
590 and returns the next edge following this new block. GLOOG_ERROR is
591 set when the code generation cannot continue. */
594 copy_bb_and_scalar_dependences (basic_block bb
, sese_info_p region
,
595 edge next_e
, vec
<tree
> iv_map
,
598 basic_block new_bb
= split_edge (next_e
);
599 rename_map_type
rename_map (10);
601 next_e
= single_succ_edge (new_bb
);
602 graphite_copy_stmts_from_block (bb
, new_bb
, &rename_map
, iv_map
, region
,
604 remove_phi_nodes (new_bb
);
609 /* Returns the outermost loop in SCOP that contains BB. */
612 outermost_loop_in_sese_1 (sese_l
®ion
, basic_block bb
)
616 nest
= bb
->loop_father
;
617 while (loop_outer (nest
)
618 && loop_in_sese_p (loop_outer (nest
), region
))
619 nest
= loop_outer (nest
);
624 /* Same as outermost_loop_in_sese_1, returns the outermost loop
625 containing BB in REGION, but makes sure that the returned loop
626 belongs to the REGION, and so this returns the first loop in the
627 REGION when the loop containing BB does not belong to REGION. */
630 outermost_loop_in_sese (sese_l
®ion
, basic_block bb
)
632 loop_p nest
= outermost_loop_in_sese_1 (region
, bb
);
634 if (loop_in_sese_p (nest
, region
))
637 /* When the basic block BB does not belong to a loop in the region,
638 return the first loop in the region. */
641 if (loop_in_sese_p (nest
, region
))
650 /* Sets the false region of an IF_REGION to REGION. */
653 if_region_set_false_region (ifsese if_region
, sese_info_p region
)
655 basic_block condition
= if_region_get_condition_block (if_region
);
656 edge false_edge
= get_false_edge_from_guard_bb (condition
);
657 basic_block dummy
= false_edge
->dest
;
658 edge entry_region
= region
->region
.entry
;
659 edge exit_region
= region
->region
.exit
;
660 basic_block before_region
= entry_region
->src
;
661 basic_block last_in_region
= exit_region
->src
;
662 hashval_t hash
= htab_hash_pointer (exit_region
);
664 = current_loops
->exits
->find_slot_with_hash (exit_region
, hash
, NO_INSERT
);
666 entry_region
->flags
= false_edge
->flags
;
667 false_edge
->flags
= exit_region
->flags
;
669 redirect_edge_pred (entry_region
, condition
);
670 redirect_edge_pred (exit_region
, before_region
);
671 redirect_edge_pred (false_edge
, last_in_region
);
672 redirect_edge_succ (false_edge
, single_succ (dummy
));
673 delete_basic_block (dummy
);
675 exit_region
->flags
= EDGE_FALLTHRU
;
676 recompute_all_dominators ();
678 region
->region
.exit
= false_edge
;
680 free (if_region
->false_region
);
681 if_region
->false_region
= region
;
685 struct loop_exit
*loop_exit
= ggc_cleared_alloc
<struct loop_exit
> ();
687 memcpy (loop_exit
, *((struct loop_exit
**) slot
), sizeof (struct loop_exit
));
688 current_loops
->exits
->clear_slot (slot
);
690 hashval_t hash
= htab_hash_pointer (false_edge
);
691 slot
= current_loops
->exits
->find_slot_with_hash (false_edge
, hash
,
693 loop_exit
->e
= false_edge
;
695 false_edge
->src
->loop_father
->exits
->next
= loop_exit
;
699 /* Creates an IFSESE with CONDITION on edge ENTRY. */
702 create_if_region_on_edge (edge entry
, tree condition
)
706 sese_info_p sese_region
= XNEW (struct sese_info_t
);
707 sese_info_p true_region
= XNEW (struct sese_info_t
);
708 sese_info_p false_region
= XNEW (struct sese_info_t
);
709 ifsese if_region
= XNEW (struct ifsese_s
);
710 edge exit
= create_empty_if_region_on_edge (entry
, condition
);
712 if_region
->region
= sese_region
;
713 if_region
->region
->region
.entry
= entry
;
714 if_region
->region
->region
.exit
= exit
;
716 FOR_EACH_EDGE (e
, ei
, entry
->dest
->succs
)
718 if (e
->flags
& EDGE_TRUE_VALUE
)
720 true_region
->region
.entry
= e
;
721 true_region
->region
.exit
= single_succ_edge (e
->dest
);
722 if_region
->true_region
= true_region
;
724 else if (e
->flags
& EDGE_FALSE_VALUE
)
726 false_region
->region
.entry
= e
;
727 false_region
->region
.exit
= single_succ_edge (e
->dest
);
728 if_region
->false_region
= false_region
;
735 /* Moves REGION in a condition expression:
743 move_sese_in_condition (sese_info_p region
)
745 basic_block pred_block
= split_edge (region
->region
.entry
);
748 region
->region
.entry
= single_succ_edge (pred_block
);
749 if_region
= create_if_region_on_edge (single_pred_edge (pred_block
),
751 if_region_set_false_region (if_region
, region
);
756 /* Replaces the condition of the IF_REGION with CONDITION:
764 set_ifsese_condition (ifsese if_region
, tree condition
)
766 sese_info_p region
= if_region
->region
;
767 edge entry
= region
->region
.entry
;
768 basic_block bb
= entry
->dest
;
769 gimple
*last
= last_stmt (bb
);
770 gimple_stmt_iterator gsi
= gsi_last_bb (bb
);
773 gcc_assert (gimple_code (last
) == GIMPLE_COND
);
775 gsi_remove (&gsi
, true);
776 gsi
= gsi_last_bb (bb
);
777 condition
= force_gimple_operand_gsi (&gsi
, condition
, true, NULL
,
778 false, GSI_NEW_STMT
);
779 cond_stmt
= gimple_build_cond_from_tree (condition
, NULL_TREE
, NULL_TREE
);
780 gsi
= gsi_last_bb (bb
);
781 gsi_insert_after (&gsi
, cond_stmt
, GSI_NEW_STMT
);
784 /* Return true when T is defined outside REGION or when no definitions are
785 variant in REGION. When HAS_VDEFS is a valid pointer, sets HAS_VDEFS to true
786 when T depends on memory that may change in REGION. */
789 invariant_in_sese_p_rec (tree t
, sese_l
®ion
, bool *has_vdefs
)
793 if (!defined_in_sese_p (t
, region
))
796 gimple
*stmt
= SSA_NAME_DEF_STMT (t
);
798 if (gimple_code (stmt
) == GIMPLE_PHI
799 || gimple_code (stmt
) == GIMPLE_CALL
)
802 /* VDEF is variant when it is in the region. */
803 if (gimple_vdef (stmt
))
810 /* A VUSE may or may not be variant following the VDEFs. */
811 if (tree vuse
= gimple_vuse (stmt
))
812 return invariant_in_sese_p_rec (vuse
, region
, has_vdefs
);
814 FOR_EACH_SSA_USE_OPERAND (use_p
, stmt
, iter
, SSA_OP_USE
)
816 tree use
= USE_FROM_PTR (use_p
);
818 if (!defined_in_sese_p (use
, region
))
821 if (!invariant_in_sese_p_rec (use
, region
, has_vdefs
))
828 /* Returns the scalar evolution of T in REGION. Every variable that
829 is not defined in the REGION is considered a parameter. */
832 scalar_evolution_in_region (sese_l
®ion
, loop_p loop
, tree t
)
835 struct loop
*def_loop
;
836 basic_block before
= region
.entry
->src
;
838 /* SCOP parameters. */
839 if (TREE_CODE (t
) == SSA_NAME
840 && !defined_in_sese_p (t
, region
))
843 if (TREE_CODE (t
) != SSA_NAME
844 || loop_in_sese_p (loop
, region
))
845 return instantiate_scev (before
, loop
,
846 analyze_scalar_evolution (loop
, t
));
848 def
= SSA_NAME_DEF_STMT (t
);
849 def_loop
= loop_containing_stmt (def
);
851 if (loop_in_sese_p (def_loop
, region
))
853 t
= analyze_scalar_evolution (def_loop
, t
);
854 def_loop
= superloop_at_depth (def_loop
, loop_depth (loop
) + 1);
855 t
= compute_overall_effect_of_inner_loop (def_loop
, t
);
859 bool has_vdefs
= false;
860 if (invariant_in_sese_p_rec (t
, region
, &has_vdefs
))
863 /* T variates in REGION. */
865 return chrec_dont_know
;
867 return instantiate_scev (before
, loop
, t
);