1 /* SSA operands management for trees.
2 Copyright (C) 2003, 2004 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
23 #include "coretypes.h"
28 #include "diagnostic.h"
30 #include "tree-flow.h"
31 #include "tree-inline.h"
32 #include "tree-pass.h"
36 #include "langhooks.h"
38 /* This file contains the code required to manage the operands cache of the
39 SSA optimizer. For every stmt, we maintain an operand cache in the stmt
40 annotation. This cache contains operands that will be of interest to
41 optimizers and other passes wishing to manipulate the IL.
43 The operand type are broken up into REAL and VIRTUAL operands. The real
44 operands are represented as pointers into the stmt's operand tree. Thus
45 any manipulation of the real operands will be reflected in the actual tree.
46 Virtual operands are represented solely in the cache, although the base
47 variable for the SSA_NAME may, or may not occur in the stmt's tree.
48 Manipulation of the virtual operands will not be reflected in the stmt tree.
50 The routines in this file are concerned with creating this operand cache
53 get_stmt_operands() in the primary entry point.
55 The operand tree is the parsed by the various get_* routines which look
56 through the stmt tree for the occurrence of operands which may be of
57 interest, and calls are made to the append_* routines whenever one is
58 found. There are 5 of these routines, each representing one of the
59 5 types of operands. Defs, Uses, Virtual Uses, Virtual May Defs, and
62 The append_* routines check for duplication, and simply keep a list of
63 unique objects for each operand type in the build_* extendable vectors.
65 Once the stmt tree is completely parsed, the finalize_ssa_operands()
66 routine is called, which proceeds to perform the finalization routine
67 on each of the 5 operand vectors which have been built up.
69 If the stmt had a previous operand cache, the finalization routines
70 attempt to match up the new operands with the old ones. If its a perfect
71 match, the old vector is simply reused. If it isn't a perfect match, then
72 a new vector is created and the new operands are placed there. For
73 virtual operands, if the previous cache had SSA_NAME version of a
74 variable, and that same variable occurs in the same operands cache, then
75 the new cache vector will also get the same SSA_NAME.
77 i.e., if a stmt had a VUSE of 'a_5', and 'a' occurs in the new operand
78 vector for VUSE, then the new vector will also be modified such that
79 it contains 'a_5' rather than 'a'.
84 /* Flags to describe operand properties in get_stmt_operands and helpers. */
86 /* By default, operands are loaded. */
89 /* Operand is the target of an assignment expression or a
90 call-clobbered variable */
91 #define opf_is_def (1 << 0)
93 /* Operand is the target of an assignment expression. */
94 #define opf_kill_def (1 << 1)
96 /* No virtual operands should be created in the expression. This is used
97 when traversing ADDR_EXPR nodes which have different semantics than
98 other expressions. Inside an ADDR_EXPR node, the only operands that we
99 need to consider are indices into arrays. For instance, &a.b[i] should
100 generate a USE of 'i' but it should not generate a VUSE for 'a' nor a
102 #define opf_no_vops (1 << 2)
104 /* Array for building all the def operands. */
105 static GTY (()) varray_type build_defs
;
107 /* Array for building all the use operands. */
108 static GTY (()) varray_type build_uses
;
110 /* Array for building all the v_may_def operands. */
111 static GTY (()) varray_type build_v_may_defs
;
113 /* Array for building all the vuse operands. */
114 static GTY (()) varray_type build_vuses
;
116 /* Array for building all the v_must_def operands. */
117 static GTY (()) varray_type build_v_must_defs
;
120 #ifdef ENABLE_CHECKING
121 /* Used to make sure operand construction is working on the proper stmt. */
122 tree check_build_stmt
;
125 def_operand_p NULL_DEF_OPERAND_P
= { NULL
};
126 use_operand_p NULL_USE_OPERAND_P
= { NULL
};
128 static void note_addressable (tree
, stmt_ann_t
);
129 static void get_expr_operands (tree
, tree
*, int);
130 static void get_asm_expr_operands (tree
);
131 static void get_indirect_ref_operands (tree
, tree
, int);
132 static void get_call_expr_operands (tree
, tree
);
133 static inline void append_def (tree
*);
134 static inline void append_use (tree
*);
135 static void append_v_may_def (tree
);
136 static void append_v_must_def (tree
);
137 static void add_call_clobber_ops (tree
);
138 static void add_call_read_ops (tree
);
139 static void add_stmt_operand (tree
*, tree
, int);
141 /* Return a vector of contiguous memory for NUM def operands. */
143 static inline def_optype
144 allocate_def_optype (unsigned num
)
148 size
= sizeof (struct def_optype_d
) + sizeof (tree
*) * (num
- 1);
149 def_ops
= ggc_alloc (size
);
150 def_ops
->num_defs
= num
;
155 /* Return a vector of contiguous memory for NUM use operands. */
157 static inline use_optype
158 allocate_use_optype (unsigned num
)
162 size
= sizeof (struct use_optype_d
) + sizeof (tree
*) * (num
- 1);
163 use_ops
= ggc_alloc (size
);
164 use_ops
->num_uses
= num
;
169 /* Return a vector of contiguous memory for NUM v_may_def operands. */
171 static inline v_may_def_optype
172 allocate_v_may_def_optype (unsigned num
)
174 v_may_def_optype v_may_def_ops
;
176 size
= sizeof (struct v_may_def_optype_d
)
177 + sizeof (v_def_use_operand_type_t
) * (num
- 1);
178 v_may_def_ops
= ggc_alloc (size
);
179 v_may_def_ops
->num_v_may_defs
= num
;
180 return v_may_def_ops
;
184 /* Return a vector of contiguous memory for NUM v_use operands. */
186 static inline vuse_optype
187 allocate_vuse_optype (unsigned num
)
189 vuse_optype vuse_ops
;
191 size
= sizeof (struct vuse_optype_d
) + sizeof (tree
) * (num
- 1);
192 vuse_ops
= ggc_alloc (size
);
193 vuse_ops
->num_vuses
= num
;
198 /* Return a vector of contiguous memory for NUM v_must_def operands. */
200 static inline v_must_def_optype
201 allocate_v_must_def_optype (unsigned num
)
203 v_must_def_optype v_must_def_ops
;
205 size
= sizeof (struct v_must_def_optype_d
) + sizeof (v_def_use_operand_type_t
) * (num
- 1);
206 v_must_def_ops
= ggc_alloc (size
);
207 v_must_def_ops
->num_v_must_defs
= num
;
208 return v_must_def_ops
;
212 /* Free memory for USES. */
215 free_uses (use_optype
*uses
)
225 /* Free memory for DEFS. */
228 free_defs (def_optype
*defs
)
238 /* Free memory for VUSES. */
241 free_vuses (vuse_optype
*vuses
)
251 /* Free memory for V_MAY_DEFS. */
254 free_v_may_defs (v_may_def_optype
*v_may_defs
)
258 ggc_free (*v_may_defs
);
264 /* Free memory for V_MUST_DEFS. */
267 free_v_must_defs (v_must_def_optype
*v_must_defs
)
271 ggc_free (*v_must_defs
);
277 /* Initialize the operand cache routines. */
280 init_ssa_operands (void)
282 VARRAY_TREE_PTR_INIT (build_defs
, 5, "build defs");
283 VARRAY_TREE_PTR_INIT (build_uses
, 10, "build uses");
284 VARRAY_TREE_INIT (build_v_may_defs
, 10, "build v_may_defs");
285 VARRAY_TREE_INIT (build_vuses
, 10, "build vuses");
286 VARRAY_TREE_INIT (build_v_must_defs
, 10, "build v_must_defs");
290 /* Dispose of anything required by the operand routines. */
293 fini_ssa_operands (void)
295 ggc_free (build_defs
);
296 ggc_free (build_uses
);
297 ggc_free (build_v_may_defs
);
298 ggc_free (build_vuses
);
299 ggc_free (build_v_must_defs
);
302 build_v_may_defs
= NULL
;
304 build_v_must_defs
= NULL
;
308 /* All the finalize_ssa_* routines do the work required to turn the build_
309 VARRAY into an operand_vector of the appropriate type. The original vector,
310 if any, is passed in for comparison and virtual SSA_NAME reuse. If the
311 old vector is reused, the pointer passed in is set to NULL so that
312 the memory is not freed when the old operands are freed. */
314 /* Return a new def operand vector for STMT, comparing to OLD_OPS_P. */
317 finalize_ssa_defs (def_optype
*old_ops_p
, tree stmt ATTRIBUTE_UNUSED
)
320 def_optype def_ops
, old_ops
;
323 num
= VARRAY_ACTIVE_SIZE (build_defs
);
327 /* There should only be a single real definition per assignment. */
328 gcc_assert (TREE_CODE (stmt
) != MODIFY_EXPR
|| num
<= 1);
330 old_ops
= *old_ops_p
;
332 /* Compare old vector and new array. */
334 if (old_ops
&& old_ops
->num_defs
== num
)
337 for (x
= 0; x
< num
; x
++)
338 if (old_ops
->defs
[x
].def
!= VARRAY_TREE_PTR (build_defs
, x
))
352 def_ops
= allocate_def_optype (num
);
353 for (x
= 0; x
< num
; x
++)
354 def_ops
->defs
[x
].def
= VARRAY_TREE_PTR (build_defs
, x
);
357 VARRAY_POP_ALL (build_defs
);
363 /* Return a new use operand vector for STMT, comparing to OLD_OPS_P. */
366 finalize_ssa_uses (use_optype
*old_ops_p
, tree stmt ATTRIBUTE_UNUSED
)
369 use_optype use_ops
, old_ops
;
372 num
= VARRAY_ACTIVE_SIZE (build_uses
);
376 #ifdef ENABLE_CHECKING
379 /* If the pointer to the operand is the statement itself, something is
380 wrong. It means that we are pointing to a local variable (the
381 initial call to get_stmt_operands does not pass a pointer to a
383 for (x
= 0; x
< num
; x
++)
384 gcc_assert (*(VARRAY_TREE_PTR (build_uses
, x
)) != stmt
);
387 old_ops
= *old_ops_p
;
389 /* Check if the old vector and the new array are the same. */
391 if (old_ops
&& old_ops
->num_uses
== num
)
394 for (x
= 0; x
< num
; x
++)
395 if (old_ops
->uses
[x
].use
!= VARRAY_TREE_PTR (build_uses
, x
))
409 use_ops
= allocate_use_optype (num
);
410 for (x
= 0; x
< num
; x
++)
411 use_ops
->uses
[x
].use
= VARRAY_TREE_PTR (build_uses
, x
);
413 VARRAY_POP_ALL (build_uses
);
419 /* Return a new v_may_def operand vector for STMT, comparing to OLD_OPS_P. */
421 static v_may_def_optype
422 finalize_ssa_v_may_defs (v_may_def_optype
*old_ops_p
)
424 unsigned num
, x
, i
, old_num
;
425 v_may_def_optype v_may_def_ops
, old_ops
;
429 num
= VARRAY_ACTIVE_SIZE (build_v_may_defs
);
433 old_ops
= *old_ops_p
;
435 /* Check if the old vector and the new array are the same. */
437 if (old_ops
&& old_ops
->num_v_may_defs
== num
)
441 for (x
= 0; x
< num
; x
++)
443 var
= old_ops
->v_may_defs
[x
].def
;
444 if (TREE_CODE (var
) == SSA_NAME
)
445 var
= SSA_NAME_VAR (var
);
446 if (var
!= VARRAY_TREE (build_v_may_defs
, x
))
454 old_num
= (old_ops
? old_ops
->num_v_may_defs
: 0);
458 v_may_def_ops
= old_ops
;
463 v_may_def_ops
= allocate_v_may_def_optype (num
);
464 for (x
= 0; x
< num
; x
++)
466 var
= VARRAY_TREE (build_v_may_defs
, x
);
467 /* Look for VAR in the old operands vector. */
468 for (i
= 0; i
< old_num
; i
++)
470 result
= old_ops
->v_may_defs
[i
].def
;
471 if (TREE_CODE (result
) == SSA_NAME
)
472 result
= SSA_NAME_VAR (result
);
475 v_may_def_ops
->v_may_defs
[x
] = old_ops
->v_may_defs
[i
];
481 v_may_def_ops
->v_may_defs
[x
].def
= var
;
482 v_may_def_ops
->v_may_defs
[x
].use
= var
;
487 /* Empty the V_MAY_DEF build vector after VUSES have been processed. */
489 return v_may_def_ops
;
493 /* Return a new vuse operand vector, comparing to OLD_OPS_P. */
496 finalize_ssa_vuses (vuse_optype
*old_ops_p
)
498 unsigned num
, x
, i
, num_v_may_defs
, old_num
;
499 vuse_optype vuse_ops
, old_ops
;
502 num
= VARRAY_ACTIVE_SIZE (build_vuses
);
505 VARRAY_POP_ALL (build_v_may_defs
);
509 /* Remove superfluous VUSE operands. If the statement already has a
510 V_MAY_DEF operation for a variable 'a', then a VUSE for 'a' is not
511 needed because V_MAY_DEFs imply a VUSE of the variable. For instance,
512 suppose that variable 'a' is aliased:
515 # a_3 = V_MAY_DEF <a_2>
518 The VUSE <a_2> is superfluous because it is implied by the V_MAY_DEF
521 num_v_may_defs
= VARRAY_ACTIVE_SIZE (build_v_may_defs
);
523 if (num_v_may_defs
> 0)
527 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (build_vuses
); i
++)
529 vuse
= VARRAY_TREE (build_vuses
, i
);
530 for (j
= 0; j
< num_v_may_defs
; j
++)
532 if (vuse
== VARRAY_TREE (build_v_may_defs
, j
))
536 /* If we found a useless VUSE operand, remove it from the
537 operand array by replacing it with the last active element
538 in the operand array (unless the useless VUSE was the
539 last operand, in which case we simply remove it. */
540 if (j
!= num_v_may_defs
)
542 if (i
!= VARRAY_ACTIVE_SIZE (build_vuses
) - 1)
544 VARRAY_TREE (build_vuses
, i
)
545 = VARRAY_TREE (build_vuses
,
546 VARRAY_ACTIVE_SIZE (build_vuses
) - 1);
548 VARRAY_POP (build_vuses
);
550 /* We want to rescan the element at this index, unless
551 this was the last element, in which case the loop
558 num
= VARRAY_ACTIVE_SIZE (build_vuses
);
559 /* We could have reduced the size to zero now, however. */
562 VARRAY_POP_ALL (build_v_may_defs
);
566 old_ops
= *old_ops_p
;
568 /* Determine whether vuses is the same as the old vector. */
570 if (old_ops
&& old_ops
->num_vuses
== num
)
574 for (x
= 0; x
< num
; x
++)
577 v
= old_ops
->vuses
[x
];
578 if (TREE_CODE (v
) == SSA_NAME
)
579 v
= SSA_NAME_VAR (v
);
580 if (v
!= VARRAY_TREE (build_vuses
, x
))
588 old_num
= (old_ops
? old_ops
->num_vuses
: 0);
597 vuse_ops
= allocate_vuse_optype (num
);
598 for (x
= 0; x
< num
; x
++)
600 tree result
, var
= VARRAY_TREE (build_vuses
, x
);
601 /* Look for VAR in the old vector, and use that SSA_NAME. */
602 for (i
= 0; i
< old_num
; i
++)
604 result
= old_ops
->vuses
[i
];
605 if (TREE_CODE (result
) == SSA_NAME
)
606 result
= SSA_NAME_VAR (result
);
609 vuse_ops
->vuses
[x
] = old_ops
->vuses
[i
];
614 vuse_ops
->vuses
[x
] = var
;
618 /* The v_may_def build vector wasn't freed because we needed it here.
619 Free it now with the vuses build vector. */
620 VARRAY_POP_ALL (build_vuses
);
621 VARRAY_POP_ALL (build_v_may_defs
);
626 /* Return a new v_must_def operand vector for STMT, comparing to OLD_OPS_P. */
628 static v_must_def_optype
629 finalize_ssa_v_must_defs (v_must_def_optype
*old_ops_p
,
630 tree stmt ATTRIBUTE_UNUSED
)
632 unsigned num
, x
, i
, old_num
= 0;
633 v_must_def_optype v_must_def_ops
, old_ops
;
636 num
= VARRAY_ACTIVE_SIZE (build_v_must_defs
);
640 /* There should only be a single V_MUST_DEF per assignment. */
641 gcc_assert (TREE_CODE (stmt
) != MODIFY_EXPR
|| num
<= 1);
643 old_ops
= *old_ops_p
;
645 /* Check if the old vector and the new array are the same. */
647 if (old_ops
&& old_ops
->num_v_must_defs
== num
)
651 for (x
= 0; x
< num
; x
++)
653 tree var
= old_ops
->v_must_defs
[x
].def
;
654 if (TREE_CODE (var
) == SSA_NAME
)
655 var
= SSA_NAME_VAR (var
);
656 if (var
!= VARRAY_TREE (build_v_must_defs
, x
))
664 old_num
= (old_ops
? old_ops
->num_v_must_defs
: 0);
668 v_must_def_ops
= old_ops
;
673 v_must_def_ops
= allocate_v_must_def_optype (num
);
674 for (x
= 0; x
< num
; x
++)
676 tree result
, var
= VARRAY_TREE (build_v_must_defs
, x
);
677 /* Look for VAR in the original vector. */
678 for (i
= 0; i
< old_num
; i
++)
680 result
= old_ops
->v_must_defs
[i
].def
;
681 if (TREE_CODE (result
) == SSA_NAME
)
682 result
= SSA_NAME_VAR (result
);
685 v_must_def_ops
->v_must_defs
[x
].def
= old_ops
->v_must_defs
[i
].def
;
686 v_must_def_ops
->v_must_defs
[x
].use
= old_ops
->v_must_defs
[i
].use
;
692 v_must_def_ops
->v_must_defs
[x
].def
= var
;
693 v_must_def_ops
->v_must_defs
[x
].use
= var
;
697 VARRAY_POP_ALL (build_v_must_defs
);
699 return v_must_def_ops
;
703 /* Finalize all the build vectors, fill the new ones into INFO. */
706 finalize_ssa_stmt_operands (tree stmt
, stmt_operands_p old_ops
,
707 stmt_operands_p new_ops
)
709 new_ops
->def_ops
= finalize_ssa_defs (&(old_ops
->def_ops
), stmt
);
710 new_ops
->use_ops
= finalize_ssa_uses (&(old_ops
->use_ops
), stmt
);
711 new_ops
->v_must_def_ops
712 = finalize_ssa_v_must_defs (&(old_ops
->v_must_def_ops
), stmt
);
713 new_ops
->v_may_def_ops
= finalize_ssa_v_may_defs (&(old_ops
->v_may_def_ops
));
714 new_ops
->vuse_ops
= finalize_ssa_vuses (&(old_ops
->vuse_ops
));
718 /* Start the process of building up operands vectors in INFO. */
721 start_ssa_stmt_operands (void)
723 gcc_assert (VARRAY_ACTIVE_SIZE (build_defs
) == 0);
724 gcc_assert (VARRAY_ACTIVE_SIZE (build_uses
) == 0);
725 gcc_assert (VARRAY_ACTIVE_SIZE (build_vuses
) == 0);
726 gcc_assert (VARRAY_ACTIVE_SIZE (build_v_may_defs
) == 0);
727 gcc_assert (VARRAY_ACTIVE_SIZE (build_v_must_defs
) == 0);
731 /* Add DEF_P to the list of pointers to operands. */
734 append_def (tree
*def_p
)
736 VARRAY_PUSH_TREE_PTR (build_defs
, def_p
);
740 /* Add USE_P to the list of pointers to operands. */
743 append_use (tree
*use_p
)
745 VARRAY_PUSH_TREE_PTR (build_uses
, use_p
);
749 /* Add a new virtual may def for variable VAR to the build array. */
752 append_v_may_def (tree var
)
756 /* Don't allow duplicate entries. */
757 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (build_v_may_defs
); i
++)
758 if (var
== VARRAY_TREE (build_v_may_defs
, i
))
761 VARRAY_PUSH_TREE (build_v_may_defs
, var
);
765 /* Add VAR to the list of virtual uses. */
768 append_vuse (tree var
)
772 /* Don't allow duplicate entries. */
773 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (build_vuses
); i
++)
774 if (var
== VARRAY_TREE (build_vuses
, i
))
777 VARRAY_PUSH_TREE (build_vuses
, var
);
781 /* Add VAR to the list of virtual must definitions for INFO. */
784 append_v_must_def (tree var
)
788 /* Don't allow duplicate entries. */
789 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (build_v_must_defs
); i
++)
790 if (var
== VARRAY_TREE (build_v_must_defs
, i
))
793 VARRAY_PUSH_TREE (build_v_must_defs
, var
);
796 /* Create an operands cache for STMT, returning it in NEW_OPS. OLD_OPS are the
797 original operands, and if ANN is non-null, appropriate stmt flags are set
798 in the stmt's annotation. Note that some fields in old_ops may
799 change to NULL, although none of the memory they originally pointed to
800 will be destroyed. It is appropriate to call free_stmt_operands() on
801 the value returned in old_ops.
803 The rationale for this: Certain optimizations wish to examine the difference
804 between new_ops and old_ops after processing. If a set of operands don't
805 change, new_ops will simply assume the pointer in old_ops, and the old_ops
806 pointer will be set to NULL, indicating no memory needs to be cleared.
807 Usage might appear something like:
809 old_ops_copy = old_ops = stmt_ann(stmt)->operands;
810 build_ssa_operands (stmt, NULL, &old_ops, &new_ops);
811 <* compare old_ops_copy and new_ops *>
812 free_ssa_operands (old_ops); */
815 build_ssa_operands (tree stmt
, stmt_ann_t ann
, stmt_operands_p old_ops
,
816 stmt_operands_p new_ops
)
819 tree_ann_t saved_ann
= stmt
->common
.ann
;
821 /* Replace stmt's annotation with the one passed in for the duration
822 of the operand building process. This allows "fake" stmts to be built
823 and not be included in other data structures which can be built here. */
824 stmt
->common
.ann
= (tree_ann_t
) ann
;
826 /* Initially assume that the statement has no volatile operands, nor
827 makes aliased loads or stores. */
830 ann
->has_volatile_ops
= false;
831 ann
->makes_aliased_stores
= false;
832 ann
->makes_aliased_loads
= false;
835 start_ssa_stmt_operands ();
837 code
= TREE_CODE (stmt
);
841 get_expr_operands (stmt
, &TREE_OPERAND (stmt
, 1), opf_none
);
842 if (TREE_CODE (TREE_OPERAND (stmt
, 0)) == ARRAY_REF
843 || TREE_CODE (TREE_OPERAND (stmt
, 0)) == ARRAY_RANGE_REF
844 || TREE_CODE (TREE_OPERAND (stmt
, 0)) == COMPONENT_REF
845 || TREE_CODE (TREE_OPERAND (stmt
, 0)) == REALPART_EXPR
846 || TREE_CODE (TREE_OPERAND (stmt
, 0)) == IMAGPART_EXPR
847 /* Use a V_MAY_DEF if the RHS might throw, as the LHS won't be
848 modified in that case. FIXME we should represent somehow
849 that it is killed on the fallthrough path. */
850 || tree_could_throw_p (TREE_OPERAND (stmt
, 1)))
851 get_expr_operands (stmt
, &TREE_OPERAND (stmt
, 0), opf_is_def
);
853 get_expr_operands (stmt
, &TREE_OPERAND (stmt
, 0),
854 opf_is_def
| opf_kill_def
);
858 get_expr_operands (stmt
, &COND_EXPR_COND (stmt
), opf_none
);
862 get_expr_operands (stmt
, &SWITCH_COND (stmt
), opf_none
);
866 get_asm_expr_operands (stmt
);
870 get_expr_operands (stmt
, &TREE_OPERAND (stmt
, 0), opf_none
);
874 get_expr_operands (stmt
, &GOTO_DESTINATION (stmt
), opf_none
);
878 get_expr_operands (stmt
, &LABEL_EXPR_LABEL (stmt
), opf_none
);
881 /* These nodes contain no variable references. */
883 case CASE_LABEL_EXPR
:
885 case TRY_FINALLY_EXPR
:
892 /* Notice that if get_expr_operands tries to use &STMT as the operand
893 pointer (which may only happen for USE operands), we will abort in
894 append_use. This default will handle statements like empty
895 statements, or CALL_EXPRs that may appear on the RHS of a statement
896 or as statements themselves. */
897 get_expr_operands (stmt
, &stmt
, opf_none
);
901 finalize_ssa_stmt_operands (stmt
, old_ops
, new_ops
);
902 stmt
->common
.ann
= saved_ann
;
906 /* Free any operands vectors in OPS. */
909 free_ssa_operands (stmt_operands_p ops
)
912 free_defs (&(ops
->def_ops
));
914 free_uses (&(ops
->use_ops
));
916 free_vuses (&(ops
->vuse_ops
));
917 if (ops
->v_may_def_ops
)
918 free_v_may_defs (&(ops
->v_may_def_ops
));
919 if (ops
->v_must_def_ops
)
920 free_v_must_defs (&(ops
->v_must_def_ops
));
924 /* Get the operands of statement STMT. Note that repeated calls to
925 get_stmt_operands for the same statement will do nothing until the
926 statement is marked modified by a call to modify_stmt(). */
929 get_stmt_operands (tree stmt
)
932 stmt_operands_t old_operands
;
934 /* The optimizers cannot handle statements that are nothing but a
935 _DECL. This indicates a bug in the gimplifier. */
936 gcc_assert (!SSA_VAR_P (stmt
));
938 /* Ignore error statements. */
939 if (TREE_CODE (stmt
) == ERROR_MARK
)
942 ann
= get_stmt_ann (stmt
);
944 /* If the statement has not been modified, the operands are still valid. */
948 timevar_push (TV_TREE_OPS
);
950 old_operands
= ann
->operands
;
951 memset (&(ann
->operands
), 0, sizeof (stmt_operands_t
));
953 build_ssa_operands (stmt
, ann
, &old_operands
, &(ann
->operands
));
954 free_ssa_operands (&old_operands
);
956 /* Clear the modified bit for STMT. Subsequent calls to
957 get_stmt_operands for this statement will do nothing until the
958 statement is marked modified by a call to modify_stmt(). */
961 timevar_pop (TV_TREE_OPS
);
965 /* Recursively scan the expression pointed by EXPR_P in statement referred to
966 by INFO. FLAGS is one of the OPF_* constants modifying how to interpret the
970 get_expr_operands (tree stmt
, tree
*expr_p
, int flags
)
973 enum tree_code_class
class;
976 if (expr
== NULL
|| expr
== error_mark_node
)
979 code
= TREE_CODE (expr
);
980 class = TREE_CODE_CLASS (code
);
985 /* We could have the address of a component, array member,
986 etc which has interesting variable references. */
987 /* Taking the address of a variable does not represent a
988 reference to it, but the fact that the stmt takes its address will be
989 of interest to some passes (e.g. alias resolution). */
990 add_stmt_operand (expr_p
, stmt
, 0);
992 /* If the address is invariant, there may be no interesting variable
993 references inside. */
994 if (is_gimple_min_invariant (expr
))
997 /* There should be no VUSEs created, since the referenced objects are
998 not really accessed. The only operands that we should find here
999 are ARRAY_REF indices which will always be real operands (GIMPLE
1000 does not allow non-registers as array indices). */
1001 flags
|= opf_no_vops
;
1003 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), flags
);
1011 /* If we found a variable, add it to DEFS or USES depending
1012 on the operand flags. */
1013 add_stmt_operand (expr_p
, stmt
, flags
);
1016 case MISALIGNED_INDIRECT_REF
:
1017 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 1), flags
);
1020 case ALIGN_INDIRECT_REF
:
1022 get_indirect_ref_operands (stmt
, expr
, flags
);
1026 case ARRAY_RANGE_REF
:
1027 /* Treat array references as references to the virtual variable
1028 representing the array. The virtual variable for an ARRAY_REF
1029 is the VAR_DECL for the array. */
1031 /* Add the virtual variable for the ARRAY_REF to VDEFS or VUSES
1032 according to the value of IS_DEF. Recurse if the LHS of the
1033 ARRAY_REF node is not a regular variable. */
1034 if (SSA_VAR_P (TREE_OPERAND (expr
, 0)))
1035 add_stmt_operand (expr_p
, stmt
, flags
);
1037 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), flags
);
1039 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 1), opf_none
);
1040 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 2), opf_none
);
1041 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 3), opf_none
);
1047 /* Similarly to arrays, references to compound variables (complex
1048 types and structures/unions) are globbed.
1050 FIXME: This means that
1056 will not be constant propagated because the two partial
1057 definitions to 'a' will kill each other. Note that SRA may be
1058 able to fix this problem if 'a' can be scalarized. */
1060 /* If the LHS of the compound reference is not a regular variable,
1061 recurse to keep looking for more operands in the subexpression. */
1062 if (SSA_VAR_P (TREE_OPERAND (expr
, 0)))
1063 add_stmt_operand (expr_p
, stmt
, flags
);
1065 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), flags
);
1067 if (code
== COMPONENT_REF
)
1068 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 2), opf_none
);
1071 case WITH_SIZE_EXPR
:
1072 /* WITH_SIZE_EXPR is a pass-through reference to its first argument,
1073 and an rvalue reference to its second argument. */
1074 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 1), opf_none
);
1075 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), flags
);
1079 get_call_expr_operands (stmt
, expr
);
1084 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), opf_none
);
1085 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 1), opf_none
);
1086 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 2), opf_none
);
1094 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 1), opf_none
);
1096 op
= TREE_OPERAND (expr
, 0);
1097 if (TREE_CODE (op
) == WITH_SIZE_EXPR
)
1098 op
= TREE_OPERAND (expr
, 0);
1099 if (TREE_CODE (op
) == ARRAY_REF
1100 || TREE_CODE (op
) == ARRAY_RANGE_REF
1101 || TREE_CODE (op
) == COMPONENT_REF
1102 || TREE_CODE (op
) == REALPART_EXPR
1103 || TREE_CODE (op
) == IMAGPART_EXPR
)
1104 subflags
= opf_is_def
;
1106 subflags
= opf_is_def
| opf_kill_def
;
1108 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), subflags
);
1114 /* General aggregate CONSTRUCTORs have been decomposed, but they
1115 are still in use as the COMPLEX_EXPR equivalent for vectors. */
1118 for (t
= TREE_OPERAND (expr
, 0); t
; t
= TREE_CHAIN (t
))
1119 get_expr_operands (stmt
, &TREE_VALUE (t
), opf_none
);
1124 case TRUTH_NOT_EXPR
:
1126 case VIEW_CONVERT_EXPR
:
1128 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), flags
);
1131 case TRUTH_AND_EXPR
:
1133 case TRUTH_XOR_EXPR
:
1138 tree op0
= TREE_OPERAND (expr
, 0);
1139 tree op1
= TREE_OPERAND (expr
, 1);
1141 /* If it would be profitable to swap the operands, then do so to
1142 canonicalize the statement, enabling better optimization.
1144 By placing canonicalization of such expressions here we
1145 transparently keep statements in canonical form, even
1146 when the statement is modified. */
1147 if (tree_swap_operands_p (op0
, op1
, false))
1149 /* For relationals we need to swap the operands
1150 and change the code. */
1156 TREE_SET_CODE (expr
, swap_tree_comparison (code
));
1157 TREE_OPERAND (expr
, 0) = op1
;
1158 TREE_OPERAND (expr
, 1) = op0
;
1161 /* For a commutative operator we can just swap the operands. */
1162 else if (commutative_tree_code (code
))
1164 TREE_OPERAND (expr
, 0) = op1
;
1165 TREE_OPERAND (expr
, 1) = op0
;
1169 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), flags
);
1170 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 1), flags
);
1174 case REALIGN_LOAD_EXPR
:
1176 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), flags
);
1177 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 1), flags
);
1178 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 2), flags
);
1187 /* Expressions that make no memory references. */
1191 if (class == tcc_unary
)
1193 if (class == tcc_binary
|| class == tcc_comparison
)
1195 if (class == tcc_constant
|| class == tcc_type
)
1199 /* If we get here, something has gone wrong. */
1200 #ifdef ENABLE_CHECKING
1201 fprintf (stderr
, "unhandled expression in get_expr_operands():\n");
1203 fputs ("\n", stderr
);
1204 internal_error ("internal error");
1210 /* Scan operands in the ASM_EXPR stmt referred to in INFO. */
1213 get_asm_expr_operands (tree stmt
)
1215 stmt_ann_t s_ann
= stmt_ann (stmt
);
1216 int noutputs
= list_length (ASM_OUTPUTS (stmt
));
1217 const char **oconstraints
1218 = (const char **) alloca ((noutputs
) * sizeof (const char *));
1221 const char *constraint
;
1222 bool allows_mem
, allows_reg
, is_inout
;
1224 for (i
=0, link
= ASM_OUTPUTS (stmt
); link
; ++i
, link
= TREE_CHAIN (link
))
1226 oconstraints
[i
] = constraint
1227 = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link
)));
1228 parse_output_constraint (&constraint
, i
, 0, 0,
1229 &allows_mem
, &allows_reg
, &is_inout
);
1231 /* This should have been split in gimplify_asm_expr. */
1232 gcc_assert (!allows_reg
|| !is_inout
);
1234 /* Memory operands are addressable. Note that STMT needs the
1235 address of this operand. */
1236 if (!allows_reg
&& allows_mem
)
1238 tree t
= get_base_address (TREE_VALUE (link
));
1239 if (t
&& DECL_P (t
))
1240 note_addressable (t
, s_ann
);
1243 get_expr_operands (stmt
, &TREE_VALUE (link
), opf_is_def
);
1246 for (link
= ASM_INPUTS (stmt
); link
; link
= TREE_CHAIN (link
))
1249 = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link
)));
1250 parse_input_constraint (&constraint
, 0, 0, noutputs
, 0,
1251 oconstraints
, &allows_mem
, &allows_reg
);
1253 /* Memory operands are addressable. Note that STMT needs the
1254 address of this operand. */
1255 if (!allows_reg
&& allows_mem
)
1257 tree t
= get_base_address (TREE_VALUE (link
));
1258 if (t
&& DECL_P (t
))
1259 note_addressable (t
, s_ann
);
1262 get_expr_operands (stmt
, &TREE_VALUE (link
), 0);
1266 /* Clobber memory for asm ("" : : : "memory"); */
1267 for (link
= ASM_CLOBBERS (stmt
); link
; link
= TREE_CHAIN (link
))
1268 if (strcmp (TREE_STRING_POINTER (TREE_VALUE (link
)), "memory") == 0)
1273 /* Clobber all call-clobbered variables (or .GLOBAL_VAR if we
1274 decided to group them). */
1276 add_stmt_operand (&global_var
, stmt
, opf_is_def
);
1278 EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars
, 0, i
, bi
)
1280 tree var
= referenced_var (i
);
1281 add_stmt_operand (&var
, stmt
, opf_is_def
);
1284 /* Now clobber all addressables. */
1285 EXECUTE_IF_SET_IN_BITMAP (addressable_vars
, 0, i
, bi
)
1287 tree var
= referenced_var (i
);
1288 add_stmt_operand (&var
, stmt
, opf_is_def
);
1295 /* A subroutine of get_expr_operands to handle INDIRECT_REF,
1296 ALIGN_INDIRECT_REF and MISALIGNED_INDIRECT_REF. */
1299 get_indirect_ref_operands (tree stmt
, tree expr
, int flags
)
1301 tree
*pptr
= &TREE_OPERAND (expr
, 0);
1303 stmt_ann_t ann
= stmt_ann (stmt
);
1305 /* Stores into INDIRECT_REF operands are never killing definitions. */
1306 flags
&= ~opf_kill_def
;
1308 if (REF_ORIGINAL (expr
))
1310 enum tree_code ocode
= TREE_CODE (REF_ORIGINAL (expr
));
1312 /* If we originally accessed part of a structure, we do it still. */
1313 if (ocode
== ARRAY_REF
1314 || ocode
== COMPONENT_REF
1315 || ocode
== REALPART_EXPR
1316 || ocode
== IMAGPART_EXPR
)
1317 flags
&= ~opf_kill_def
;
1320 if (SSA_VAR_P (ptr
))
1322 struct ptr_info_def
*pi
= NULL
;
1324 /* If PTR has flow-sensitive points-to information, use it. */
1325 if (TREE_CODE (ptr
) == SSA_NAME
1326 && (pi
= SSA_NAME_PTR_INFO (ptr
)) != NULL
1327 && pi
->name_mem_tag
)
1329 /* PTR has its own memory tag. Use it. */
1330 add_stmt_operand (&pi
->name_mem_tag
, stmt
, flags
);
1334 /* If PTR is not an SSA_NAME or it doesn't have a name
1335 tag, use its type memory tag. */
1338 /* If we are emitting debugging dumps, display a warning if
1339 PTR is an SSA_NAME with no flow-sensitive alias
1340 information. That means that we may need to compute
1343 && TREE_CODE (ptr
) == SSA_NAME
1347 "NOTE: no flow-sensitive alias info for ");
1348 print_generic_expr (dump_file
, ptr
, dump_flags
);
1349 fprintf (dump_file
, " in ");
1350 print_generic_stmt (dump_file
, stmt
, dump_flags
);
1353 if (TREE_CODE (ptr
) == SSA_NAME
)
1354 ptr
= SSA_NAME_VAR (ptr
);
1355 ann
= var_ann (ptr
);
1356 if (ann
->type_mem_tag
)
1357 add_stmt_operand (&ann
->type_mem_tag
, stmt
, flags
);
1361 /* If a constant is used as a pointer, we can't generate a real
1362 operand for it but we mark the statement volatile to prevent
1363 optimizations from messing things up. */
1364 else if (TREE_CODE (ptr
) == INTEGER_CST
)
1367 ann
->has_volatile_ops
= true;
1371 /* Everything else *should* have been folded elsewhere, but users
1372 are smarter than we in finding ways to write invalid code. We
1373 cannot just abort here. If we were absolutely certain that we
1374 do handle all valid cases, then we could just do nothing here.
1375 That seems optimistic, so attempt to do something logical... */
1376 else if ((TREE_CODE (ptr
) == PLUS_EXPR
|| TREE_CODE (ptr
) == MINUS_EXPR
)
1377 && TREE_CODE (TREE_OPERAND (ptr
, 0)) == ADDR_EXPR
1378 && TREE_CODE (TREE_OPERAND (ptr
, 1)) == INTEGER_CST
)
1380 /* Make sure we know the object is addressable. */
1381 pptr
= &TREE_OPERAND (ptr
, 0);
1382 add_stmt_operand (pptr
, stmt
, 0);
1384 /* Mark the object itself with a VUSE. */
1385 pptr
= &TREE_OPERAND (*pptr
, 0);
1386 get_expr_operands (stmt
, pptr
, flags
);
1390 /* Ok, this isn't even is_gimple_min_invariant. Something's broke. */
1394 /* Add a USE operand for the base pointer. */
1395 get_expr_operands (stmt
, pptr
, opf_none
);
1398 /* A subroutine of get_expr_operands to handle CALL_EXPR. */
1401 get_call_expr_operands (tree stmt
, tree expr
)
1404 int call_flags
= call_expr_flags (expr
);
1406 /* Find uses in the called function. */
1407 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 0), opf_none
);
1409 for (op
= TREE_OPERAND (expr
, 1); op
; op
= TREE_CHAIN (op
))
1410 get_expr_operands (stmt
, &TREE_VALUE (op
), opf_none
);
1412 get_expr_operands (stmt
, &TREE_OPERAND (expr
, 2), opf_none
);
1414 if (!bitmap_empty_p (call_clobbered_vars
))
1416 /* A 'pure' or a 'const' functions never call clobber anything.
1417 A 'noreturn' function might, but since we don't return anyway
1418 there is no point in recording that. */
1419 if (TREE_SIDE_EFFECTS (expr
)
1420 && !(call_flags
& (ECF_PURE
| ECF_CONST
| ECF_NORETURN
)))
1421 add_call_clobber_ops (stmt
);
1422 else if (!(call_flags
& ECF_CONST
))
1423 add_call_read_ops (stmt
);
1428 /* Add *VAR_P to the appropriate operand array for INFO. FLAGS is as in
1429 get_expr_operands. If *VAR_P is a GIMPLE register, it will be added to
1430 the statement's real operands, otherwise it is added to virtual
1434 add_stmt_operand (tree
*var_p
, tree stmt
, int flags
)
1438 stmt_ann_t s_ann
= stmt_ann (stmt
);
1444 /* If the operand is an ADDR_EXPR, add its operand to the list of
1445 variables that have had their address taken in this statement. */
1446 if (TREE_CODE (var
) == ADDR_EXPR
)
1448 note_addressable (TREE_OPERAND (var
, 0), s_ann
);
1452 /* If the original variable is not a scalar, it will be added to the list
1453 of virtual operands. In that case, use its base symbol as the virtual
1454 variable representing it. */
1455 is_real_op
= is_gimple_reg (var
);
1456 if (!is_real_op
&& !DECL_P (var
))
1457 var
= get_virtual_var (var
);
1459 /* If VAR is not a variable that we care to optimize, do nothing. */
1460 if (var
== NULL_TREE
|| !SSA_VAR_P (var
))
1463 sym
= (TREE_CODE (var
) == SSA_NAME
? SSA_NAME_VAR (var
) : var
);
1464 v_ann
= var_ann (sym
);
1466 /* Don't expose volatile variables to the optimizers. */
1467 if (TREE_THIS_VOLATILE (sym
))
1470 s_ann
->has_volatile_ops
= true;
1476 /* The variable is a GIMPLE register. Add it to real operands. */
1477 if (flags
& opf_is_def
)
1484 varray_type aliases
;
1486 /* The variable is not a GIMPLE register. Add it (or its aliases) to
1487 virtual operands, unless the caller has specifically requested
1488 not to add virtual operands (used when adding operands inside an
1489 ADDR_EXPR expression). */
1490 if (flags
& opf_no_vops
)
1493 aliases
= v_ann
->may_aliases
;
1495 if (aliases
== NULL
)
1497 /* The variable is not aliased or it is an alias tag. */
1498 if (flags
& opf_is_def
)
1500 if (flags
& opf_kill_def
)
1502 /* Only regular variables may get a V_MUST_DEF
1504 gcc_assert (v_ann
->mem_tag_kind
== NOT_A_TAG
);
1505 /* V_MUST_DEF for non-aliased, non-GIMPLE register
1506 variable definitions. */
1507 append_v_must_def (var
);
1511 /* Add a V_MAY_DEF for call-clobbered variables and
1513 append_v_may_def (var
);
1519 if (s_ann
&& v_ann
->is_alias_tag
)
1520 s_ann
->makes_aliased_loads
= 1;
1527 /* The variable is aliased. Add its aliases to the virtual
1529 gcc_assert (VARRAY_ACTIVE_SIZE (aliases
) != 0);
1531 if (flags
& opf_is_def
)
1533 /* If the variable is also an alias tag, add a virtual
1534 operand for it, otherwise we will miss representing
1535 references to the members of the variable's alias set.
1536 This fixes the bug in gcc.c-torture/execute/20020503-1.c. */
1537 if (v_ann
->is_alias_tag
)
1538 append_v_may_def (var
);
1540 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (aliases
); i
++)
1541 append_v_may_def (VARRAY_TREE (aliases
, i
));
1544 s_ann
->makes_aliased_stores
= 1;
1548 /* Similarly, append a virtual uses for VAR itself, when
1549 it is an alias tag. */
1550 if (v_ann
->is_alias_tag
)
1553 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (aliases
); i
++)
1554 append_vuse (VARRAY_TREE (aliases
, i
));
1557 s_ann
->makes_aliased_loads
= 1;
1564 /* Record that VAR had its address taken in the statement with annotations
1568 note_addressable (tree var
, stmt_ann_t s_ann
)
1573 var
= get_base_address (var
);
1574 if (var
&& SSA_VAR_P (var
))
1576 if (s_ann
->addresses_taken
== NULL
)
1577 s_ann
->addresses_taken
= BITMAP_GGC_ALLOC ();
1578 bitmap_set_bit (s_ann
->addresses_taken
, var_ann (var
)->uid
);
1583 /* Add clobbering definitions for .GLOBAL_VAR or for each of the call
1584 clobbered variables in the function. */
1587 add_call_clobber_ops (tree stmt
)
1589 /* Functions that are not const, pure or never return may clobber
1590 call-clobbered variables. */
1591 if (stmt_ann (stmt
))
1592 stmt_ann (stmt
)->makes_clobbering_call
= true;
1594 /* If we had created .GLOBAL_VAR earlier, use it. Otherwise, add
1595 a V_MAY_DEF operand for every call clobbered variable. See
1596 compute_may_aliases for the heuristic used to decide whether
1597 to create .GLOBAL_VAR or not. */
1599 add_stmt_operand (&global_var
, stmt
, opf_is_def
);
1605 EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars
, 0, i
, bi
)
1607 tree var
= referenced_var (i
);
1608 if (TREE_READONLY (var
)
1609 && (TREE_STATIC (var
) || DECL_EXTERNAL (var
)))
1610 add_stmt_operand (&var
, stmt
, opf_none
);
1612 add_stmt_operand (&var
, stmt
, opf_is_def
);
1618 /* Add VUSE operands for .GLOBAL_VAR or all call clobbered variables in the
1622 add_call_read_ops (tree stmt
)
1626 /* Otherwise, if the function is not pure, it may reference memory. Add
1627 a VUSE for .GLOBAL_VAR if it has been created. Otherwise, add a VUSE
1628 for each call-clobbered variable. See add_referenced_var for the
1629 heuristic used to decide whether to create .GLOBAL_VAR. */
1631 add_stmt_operand (&global_var
, stmt
, opf_none
);
1636 EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars
, 0, i
, bi
)
1638 tree var
= referenced_var (i
);
1639 add_stmt_operand (&var
, stmt
, opf_none
);
1644 /* Copies virtual operands from SRC to DST. */
1647 copy_virtual_operands (tree dst
, tree src
)
1650 vuse_optype vuses
= STMT_VUSE_OPS (src
);
1651 v_may_def_optype v_may_defs
= STMT_V_MAY_DEF_OPS (src
);
1652 v_must_def_optype v_must_defs
= STMT_V_MUST_DEF_OPS (src
);
1653 vuse_optype
*vuses_new
= &stmt_ann (dst
)->operands
.vuse_ops
;
1654 v_may_def_optype
*v_may_defs_new
= &stmt_ann (dst
)->operands
.v_may_def_ops
;
1655 v_must_def_optype
*v_must_defs_new
= &stmt_ann (dst
)->operands
.v_must_def_ops
;
1659 *vuses_new
= allocate_vuse_optype (NUM_VUSES (vuses
));
1660 for (i
= 0; i
< NUM_VUSES (vuses
); i
++)
1661 SET_VUSE_OP (*vuses_new
, i
, VUSE_OP (vuses
, i
));
1666 *v_may_defs_new
= allocate_v_may_def_optype (NUM_V_MAY_DEFS (v_may_defs
));
1667 for (i
= 0; i
< NUM_V_MAY_DEFS (v_may_defs
); i
++)
1669 SET_V_MAY_DEF_OP (*v_may_defs_new
, i
, V_MAY_DEF_OP (v_may_defs
, i
));
1670 SET_V_MAY_DEF_RESULT (*v_may_defs_new
, i
,
1671 V_MAY_DEF_RESULT (v_may_defs
, i
));
1677 *v_must_defs_new
= allocate_v_must_def_optype (NUM_V_MUST_DEFS (v_must_defs
));
1678 for (i
= 0; i
< NUM_V_MUST_DEFS (v_must_defs
); i
++)
1680 SET_V_MUST_DEF_RESULT (*v_must_defs_new
, i
, V_MUST_DEF_RESULT (v_must_defs
, i
));
1681 SET_V_MUST_DEF_KILL (*v_must_defs_new
, i
, V_MUST_DEF_KILL (v_must_defs
, i
));
1687 /* Specifically for use in DOM's expression analysis. Given a store, we
1688 create an artificial stmt which looks like a load from the store, this can
1689 be used to eliminate redundant loads. OLD_OPS are the operands from the
1690 store stmt, and NEW_STMT is the new load which represents a load of the
1694 create_ssa_artficial_load_stmt (stmt_operands_p old_ops
, tree new_stmt
)
1698 stmt_operands_t tmp
;
1701 memset (&tmp
, 0, sizeof (stmt_operands_t
));
1702 ann
= get_stmt_ann (new_stmt
);
1704 /* Free operands just in case is was an existing stmt. */
1705 free_ssa_operands (&(ann
->operands
));
1707 build_ssa_operands (new_stmt
, NULL
, &tmp
, &(ann
->operands
));
1708 free_vuses (&(ann
->operands
.vuse_ops
));
1709 free_v_may_defs (&(ann
->operands
.v_may_def_ops
));
1710 free_v_must_defs (&(ann
->operands
.v_must_def_ops
));
1712 /* For each VDEF on the original statement, we want to create a
1713 VUSE of the V_MAY_DEF result or V_MUST_DEF op on the new
1715 for (j
= 0; j
< NUM_V_MAY_DEFS (old_ops
->v_may_def_ops
); j
++)
1717 op
= V_MAY_DEF_RESULT (old_ops
->v_may_def_ops
, j
);
1721 for (j
= 0; j
< NUM_V_MUST_DEFS (old_ops
->v_must_def_ops
); j
++)
1723 op
= V_MUST_DEF_RESULT (old_ops
->v_must_def_ops
, j
);
1727 /* Now set the vuses for this new stmt. */
1728 ann
->operands
.vuse_ops
= finalize_ssa_vuses (&(tmp
.vuse_ops
));
1731 #include "gt-tree-ssa-operands.h"