Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / coalesce-1.c
blob96187d858471b54e7ec3de2f969793d875a909e3
1 /* { dg-do compile } */
3 /* { dg-options "-O2 -fdump-rtl-expand-details" } */
5 typedef long unsigned int size_t;
6 union tree_node;
7 typedef union tree_node *tree;
8 union gimple_statement_d;
9 typedef union gimple_statement_d *gimple;
10 typedef const union tree_node *const_tree;
11 typedef const union gimple_statement_d *const_gimple;
12 struct gimple_seq_d;
13 typedef struct gimple_seq_d *gimple_seq;
14 struct edge_def;
15 typedef struct edge_def *edge;
16 struct basic_block_def;
17 typedef struct basic_block_def *basic_block;
18 typedef const struct basic_block_def *const_basic_block;
19 struct tree_exp
21 tree operands[1];
23 typedef struct ssa_use_operand_d
25 tree *use;
26 } ssa_use_operand_t;
27 struct phi_arg_d
29 struct ssa_use_operand_d imm_use;
31 union tree_node
33 struct tree_exp exp;
35 struct function
38 extern struct function *cfun;
39 struct edge_def
41 unsigned int dest_idx;
43 static __inline__ void
44 VEC_edge_must_be_pointer_type (void)
46 (void) ((edge) 1 == (void *) 1);
47 } typedef struct VEC_edge_base
50 unsigned num;
51 unsigned alloc;
52 edge vec[1];
53 } VEC_edge_base;
54 typedef struct VEC_edge_none
56 VEC_edge_base base;
57 } VEC_edge_none;
59 static __inline__ edge
60 VEC_edge_base_index (const VEC_edge_base * vec_, unsigned ix_,
61 const char *file_, unsigned line_, const char *function_)
63 return vec_->vec[ix_];
66 typedef struct VEC_edge_gc
68 VEC_edge_base base;
69 } VEC_edge_gc;
70 struct basic_block_def
72 VEC_edge_gc *succs;
74 static __inline__ edge
75 single_succ_edge (const_basic_block bb)
77 return (VEC_edge_base_index
78 ((((bb)->succs) ? &((bb)->succs)->base : 0), (0),
79 "/home/gcc/virgin-gcc/gcc/basic-block.h", 563, __FUNCTION__));
82 edge find_edge (basic_block, basic_block);
83 typedef tree *def_operand_p;
84 typedef ssa_use_operand_t *use_operand_p;
85 struct gimple_seq_node_d;
86 typedef struct gimple_seq_node_d *gimple_seq_node;
87 struct gimple_seq_node_d
89 gimple stmt;
91 typedef struct
93 gimple_seq_node ptr;
94 gimple_seq seq;
95 basic_block bb;
96 } gimple_stmt_iterator;
97 struct gimple_statement_phi
99 struct phi_arg_d args[1];
101 union gimple_statement_d
103 struct gimple_statement_phi gimple_phi;
105 extern size_t const gimple_ops_offset_[];
106 int gimple_statement_structure (gimple);
107 static __inline__ tree *
108 gimple_ops (gimple gs)
110 size_t off;
111 off = gimple_ops_offset_[gimple_statement_structure (gs)];
112 return (tree *) ((char *) gs + off);
115 static __inline__ tree
116 gimple_op (const_gimple gs, unsigned i)
118 return gimple_ops ((((union
120 const union gimple_statement_d * _q;
121 union gimple_statement_d * _nq;}) (((gs))))._nq))[i];
124 static __inline__ struct phi_arg_d *
125 gimple_phi_arg (gimple gs, unsigned index)
127 return &(gs->gimple_phi.args[index]);
130 static __inline__ tree
131 gimple_switch_label (const_gimple gs, unsigned index)
133 return gimple_op (gs, index + 1);
136 gimple_stmt_iterator gsi_start_phis (basic_block);
137 extern basic_block label_to_block_fn (struct function *, tree);
139 static __inline__ tree
140 get_use_from_ptr (use_operand_p use)
142 return *(use->use);
145 static __inline__ use_operand_p
146 gimple_phi_arg_imm_use_ptr (gimple gs, int i)
148 return &gimple_phi_arg (gs, i)->imm_use;
151 struct switch_conv_info
153 basic_block final_bb;
154 basic_block switch_bb;
155 const char *reason;
156 tree *default_values;
158 static struct switch_conv_info info;
159 void gsi_next (gimple_stmt_iterator *);
160 int gsi_gsi_start_phis (basic_block);
162 static void
163 gather_default_values (tree default_case)
165 gimple_stmt_iterator gsi;
166 basic_block bb =
167 (label_to_block_fn ((cfun + 0), default_case->exp.operands[2]));
168 edge e;
169 int i = 0;
170 if (bb == info.final_bb)
171 e = find_edge (info.switch_bb, bb);
172 else
173 e = single_succ_edge (bb);
174 for (gsi = gsi_start_phis (info.final_bb);
175 gsi_gsi_start_phis (info.final_bb); gsi_next (&gsi))
177 gimple phi = gsi.ptr->stmt;
178 tree val = get_use_from_ptr (gimple_phi_arg_imm_use_ptr
179 ((((phi))), (((e)->dest_idx))));
180 info.default_values[i++] = val;
184 unsigned int gimple_switch_num_labels (gimple);
186 unsigned char
187 process_switch (gimple swtch)
189 unsigned int i, branch_num = gimple_switch_num_labels (swtch);
190 tree index_type;
191 info.reason = "switch has no labels\n";
192 gather_default_values (gimple_switch_label (swtch, 0));
195 /* Verify that out-of-ssa coalescing did its job by verifying there are not
196 any partition copies inserted. */
198 /* { dg-final { scan-rtl-dump-not "partition copy" "expand"} } */