Update Copyright years for files modified in 2011 and/or 2012.
[gcc.git] / gcc / tree-ssa-ifcombine.c
1 /* Combining of if-expressions on trees.
2 Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
3 Free Software Foundation, Inc.
4 Contributed by Richard Guenther <rguenther@suse.de>
5
6 This file is part of GCC.
7
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)
11 any later version.
12
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.
17
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/>. */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "basic-block.h"
28 #include "tree-pretty-print.h"
29 #include "tree-flow.h"
30 #include "tree-pass.h"
31
32 /* This pass combines COND_EXPRs to simplify control flow. It
33 currently recognizes bit tests and comparisons in chains that
34 represent logical and or logical or of two COND_EXPRs.
35
36 It does so by walking basic blocks in a approximate reverse
37 post-dominator order and trying to match CFG patterns that
38 represent logical and or logical or of two COND_EXPRs.
39 Transformations are done if the COND_EXPR conditions match
40 either
41
42 1. two single bit tests X & (1 << Yn) (for logical and)
43
44 2. two bit tests X & Yn (for logical or)
45
46 3. two comparisons X OPn Y (for logical or)
47
48 To simplify this pass, removing basic blocks and dead code
49 is left to CFG cleanup and DCE. */
50
51
52 /* Recognize a if-then-else CFG pattern starting to match with the
53 COND_BB basic-block containing the COND_EXPR. The recognized
54 then end else blocks are stored to *THEN_BB and *ELSE_BB. If
55 *THEN_BB and/or *ELSE_BB are already set, they are required to
56 match the then and else basic-blocks to make the pattern match.
57 Returns true if the pattern matched, false otherwise. */
58
59 static bool
60 recognize_if_then_else (basic_block cond_bb,
61 basic_block *then_bb, basic_block *else_bb)
62 {
63 edge t, e;
64
65 if (EDGE_COUNT (cond_bb->succs) != 2)
66 return false;
67
68 /* Find the then/else edges. */
69 t = EDGE_SUCC (cond_bb, 0);
70 e = EDGE_SUCC (cond_bb, 1);
71 if (!(t->flags & EDGE_TRUE_VALUE))
72 {
73 edge tmp = t;
74 t = e;
75 e = tmp;
76 }
77 if (!(t->flags & EDGE_TRUE_VALUE)
78 || !(e->flags & EDGE_FALSE_VALUE))
79 return false;
80
81 /* Check if the edge destinations point to the required block. */
82 if (*then_bb
83 && t->dest != *then_bb)
84 return false;
85 if (*else_bb
86 && e->dest != *else_bb)
87 return false;
88
89 if (!*then_bb)
90 *then_bb = t->dest;
91 if (!*else_bb)
92 *else_bb = e->dest;
93
94 return true;
95 }
96
97 /* Verify if the basic block BB does not have side-effects. Return
98 true in this case, else false. */
99
100 static bool
101 bb_no_side_effects_p (basic_block bb)
102 {
103 gimple_stmt_iterator gsi;
104
105 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
106 {
107 gimple stmt = gsi_stmt (gsi);
108
109 if (gimple_has_side_effects (stmt)
110 || gimple_vuse (stmt))
111 return false;
112 }
113
114 return true;
115 }
116
117 /* Verify if all PHI node arguments in DEST for edges from BB1 or
118 BB2 to DEST are the same. This makes the CFG merge point
119 free from side-effects. Return true in this case, else false. */
120
121 static bool
122 same_phi_args_p (basic_block bb1, basic_block bb2, basic_block dest)
123 {
124 edge e1 = find_edge (bb1, dest);
125 edge e2 = find_edge (bb2, dest);
126 gimple_stmt_iterator gsi;
127 gimple phi;
128
129 for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
130 {
131 phi = gsi_stmt (gsi);
132 if (!operand_equal_p (PHI_ARG_DEF_FROM_EDGE (phi, e1),
133 PHI_ARG_DEF_FROM_EDGE (phi, e2), 0))
134 return false;
135 }
136
137 return true;
138 }
139
140 /* Return the best representative SSA name for CANDIDATE which is used
141 in a bit test. */
142
143 static tree
144 get_name_for_bit_test (tree candidate)
145 {
146 /* Skip single-use names in favor of using the name from a
147 non-widening conversion definition. */
148 if (TREE_CODE (candidate) == SSA_NAME
149 && has_single_use (candidate))
150 {
151 gimple def_stmt = SSA_NAME_DEF_STMT (candidate);
152 if (is_gimple_assign (def_stmt)
153 && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
154 {
155 if (TYPE_PRECISION (TREE_TYPE (candidate))
156 <= TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (def_stmt))))
157 return gimple_assign_rhs1 (def_stmt);
158 }
159 }
160
161 return candidate;
162 }
163
164 /* Recognize a single bit test pattern in GIMPLE_COND and its defining
165 statements. Store the name being tested in *NAME and the bit
166 in *BIT. The GIMPLE_COND computes *NAME & (1 << *BIT).
167 Returns true if the pattern matched, false otherwise. */
168
169 static bool
170 recognize_single_bit_test (gimple cond, tree *name, tree *bit, bool inv)
171 {
172 gimple stmt;
173
174 /* Get at the definition of the result of the bit test. */
175 if (gimple_cond_code (cond) != (inv ? EQ_EXPR : NE_EXPR)
176 || TREE_CODE (gimple_cond_lhs (cond)) != SSA_NAME
177 || !integer_zerop (gimple_cond_rhs (cond)))
178 return false;
179 stmt = SSA_NAME_DEF_STMT (gimple_cond_lhs (cond));
180 if (!is_gimple_assign (stmt))
181 return false;
182
183 /* Look at which bit is tested. One form to recognize is
184 D.1985_5 = state_3(D) >> control1_4(D);
185 D.1986_6 = (int) D.1985_5;
186 D.1987_7 = op0 & 1;
187 if (D.1987_7 != 0) */
188 if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR
189 && integer_onep (gimple_assign_rhs2 (stmt))
190 && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME)
191 {
192 tree orig_name = gimple_assign_rhs1 (stmt);
193
194 /* Look through copies and conversions to eventually
195 find the stmt that computes the shift. */
196 stmt = SSA_NAME_DEF_STMT (orig_name);
197
198 while (is_gimple_assign (stmt)
199 && ((CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt))
200 && (TYPE_PRECISION (TREE_TYPE (gimple_assign_lhs (stmt)))
201 <= TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (stmt)))))
202 || gimple_assign_ssa_name_copy_p (stmt)))
203 stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt));
204
205 /* If we found such, decompose it. */
206 if (is_gimple_assign (stmt)
207 && gimple_assign_rhs_code (stmt) == RSHIFT_EXPR)
208 {
209 /* op0 & (1 << op1) */
210 *bit = gimple_assign_rhs2 (stmt);
211 *name = gimple_assign_rhs1 (stmt);
212 }
213 else
214 {
215 /* t & 1 */
216 *bit = integer_zero_node;
217 *name = get_name_for_bit_test (orig_name);
218 }
219
220 return true;
221 }
222
223 /* Another form is
224 D.1987_7 = op0 & (1 << CST)
225 if (D.1987_7 != 0) */
226 if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR
227 && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME
228 && integer_pow2p (gimple_assign_rhs2 (stmt)))
229 {
230 *name = gimple_assign_rhs1 (stmt);
231 *bit = build_int_cst (integer_type_node,
232 tree_log2 (gimple_assign_rhs2 (stmt)));
233 return true;
234 }
235
236 /* Another form is
237 D.1986_6 = 1 << control1_4(D)
238 D.1987_7 = op0 & D.1986_6
239 if (D.1987_7 != 0) */
240 if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR
241 && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME
242 && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME)
243 {
244 gimple tmp;
245
246 /* Both arguments of the BIT_AND_EXPR can be the single-bit
247 specifying expression. */
248 tmp = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt));
249 if (is_gimple_assign (tmp)
250 && gimple_assign_rhs_code (tmp) == LSHIFT_EXPR
251 && integer_onep (gimple_assign_rhs1 (tmp)))
252 {
253 *name = gimple_assign_rhs2 (stmt);
254 *bit = gimple_assign_rhs2 (tmp);
255 return true;
256 }
257
258 tmp = SSA_NAME_DEF_STMT (gimple_assign_rhs2 (stmt));
259 if (is_gimple_assign (tmp)
260 && gimple_assign_rhs_code (tmp) == LSHIFT_EXPR
261 && integer_onep (gimple_assign_rhs1 (tmp)))
262 {
263 *name = gimple_assign_rhs1 (stmt);
264 *bit = gimple_assign_rhs2 (tmp);
265 return true;
266 }
267 }
268
269 return false;
270 }
271
272 /* Recognize a bit test pattern in a GIMPLE_COND and its defining
273 statements. Store the name being tested in *NAME and the bits
274 in *BITS. The COND_EXPR computes *NAME & *BITS.
275 Returns true if the pattern matched, false otherwise. */
276
277 static bool
278 recognize_bits_test (gimple cond, tree *name, tree *bits, bool inv)
279 {
280 gimple stmt;
281
282 /* Get at the definition of the result of the bit test. */
283 if (gimple_cond_code (cond) != (inv ? EQ_EXPR : NE_EXPR)
284 || TREE_CODE (gimple_cond_lhs (cond)) != SSA_NAME
285 || !integer_zerop (gimple_cond_rhs (cond)))
286 return false;
287 stmt = SSA_NAME_DEF_STMT (gimple_cond_lhs (cond));
288 if (!is_gimple_assign (stmt)
289 || gimple_assign_rhs_code (stmt) != BIT_AND_EXPR)
290 return false;
291
292 *name = get_name_for_bit_test (gimple_assign_rhs1 (stmt));
293 *bits = gimple_assign_rhs2 (stmt);
294
295 return true;
296 }
297
298 /* If-convert on a and pattern with a common else block. The inner
299 if is specified by its INNER_COND_BB, the outer by OUTER_COND_BB.
300 inner_inv, outer_inv and result_inv indicate whether the conditions
301 are inverted.
302 Returns true if the edges to the common else basic-block were merged. */
303
304 static bool
305 ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
306 basic_block outer_cond_bb, bool outer_inv, bool result_inv)
307 {
308 gimple_stmt_iterator gsi;
309 gimple inner_cond, outer_cond;
310 tree name1, name2, bit1, bit2, bits1, bits2;
311
312 inner_cond = last_stmt (inner_cond_bb);
313 if (!inner_cond
314 || gimple_code (inner_cond) != GIMPLE_COND)
315 return false;
316
317 outer_cond = last_stmt (outer_cond_bb);
318 if (!outer_cond
319 || gimple_code (outer_cond) != GIMPLE_COND)
320 return false;
321
322 /* See if we test a single bit of the same name in both tests. In
323 that case remove the outer test, merging both else edges,
324 and change the inner one to test for
325 name & (bit1 | bit2) == (bit1 | bit2). */
326 if (recognize_single_bit_test (inner_cond, &name1, &bit1, inner_inv)
327 && recognize_single_bit_test (outer_cond, &name2, &bit2, outer_inv)
328 && name1 == name2)
329 {
330 tree t, t2;
331
332 /* Do it. */
333 gsi = gsi_for_stmt (inner_cond);
334 t = fold_build2 (LSHIFT_EXPR, TREE_TYPE (name1),
335 build_int_cst (TREE_TYPE (name1), 1), bit1);
336 t2 = fold_build2 (LSHIFT_EXPR, TREE_TYPE (name1),
337 build_int_cst (TREE_TYPE (name1), 1), bit2);
338 t = fold_build2 (BIT_IOR_EXPR, TREE_TYPE (name1), t, t2);
339 t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
340 true, GSI_SAME_STMT);
341 t2 = fold_build2 (BIT_AND_EXPR, TREE_TYPE (name1), name1, t);
342 t2 = force_gimple_operand_gsi (&gsi, t2, true, NULL_TREE,
343 true, GSI_SAME_STMT);
344 t = fold_build2 (result_inv ? NE_EXPR : EQ_EXPR,
345 boolean_type_node, t2, t);
346 t = canonicalize_cond_expr_cond (t);
347 if (!t)
348 return false;
349 gimple_cond_set_condition_from_tree (inner_cond, t);
350 update_stmt (inner_cond);
351
352 /* Leave CFG optimization to cfg_cleanup. */
353 gimple_cond_set_condition_from_tree (outer_cond,
354 outer_inv ? boolean_false_node : boolean_true_node);
355 update_stmt (outer_cond);
356
357 if (dump_file)
358 {
359 fprintf (dump_file, "optimizing double bit test to ");
360 print_generic_expr (dump_file, name1, 0);
361 fprintf (dump_file, " & T == T\nwith temporary T = (1 << ");
362 print_generic_expr (dump_file, bit1, 0);
363 fprintf (dump_file, ") | (1 << ");
364 print_generic_expr (dump_file, bit2, 0);
365 fprintf (dump_file, ")\n");
366 }
367
368 return true;
369 }
370
371 /* See if we have two bit tests of the same name in both tests.
372 In that case remove the outer test and change the inner one to
373 test for name & (bits1 | bits2) != 0. */
374 else if (recognize_bits_test (inner_cond, &name1, &bits1, !inner_inv)
375 && recognize_bits_test (outer_cond, &name2, &bits2, !outer_inv))
376 {
377 gimple_stmt_iterator gsi;
378 tree t;
379
380 /* Find the common name which is bit-tested. */
381 if (name1 == name2)
382 ;
383 else if (bits1 == bits2)
384 {
385 t = name2;
386 name2 = bits2;
387 bits2 = t;
388 t = name1;
389 name1 = bits1;
390 bits1 = t;
391 }
392 else if (name1 == bits2)
393 {
394 t = name2;
395 name2 = bits2;
396 bits2 = t;
397 }
398 else if (bits1 == name2)
399 {
400 t = name1;
401 name1 = bits1;
402 bits1 = t;
403 }
404 else
405 return false;
406
407 /* As we strip non-widening conversions in finding a common
408 name that is tested make sure to end up with an integral
409 type for building the bit operations. */
410 if (TYPE_PRECISION (TREE_TYPE (bits1))
411 >= TYPE_PRECISION (TREE_TYPE (bits2)))
412 {
413 bits1 = fold_convert (unsigned_type_for (TREE_TYPE (bits1)), bits1);
414 name1 = fold_convert (TREE_TYPE (bits1), name1);
415 bits2 = fold_convert (unsigned_type_for (TREE_TYPE (bits2)), bits2);
416 bits2 = fold_convert (TREE_TYPE (bits1), bits2);
417 }
418 else
419 {
420 bits2 = fold_convert (unsigned_type_for (TREE_TYPE (bits2)), bits2);
421 name1 = fold_convert (TREE_TYPE (bits2), name1);
422 bits1 = fold_convert (unsigned_type_for (TREE_TYPE (bits1)), bits1);
423 bits1 = fold_convert (TREE_TYPE (bits2), bits1);
424 }
425
426 /* Do it. */
427 gsi = gsi_for_stmt (inner_cond);
428 t = fold_build2 (BIT_IOR_EXPR, TREE_TYPE (name1), bits1, bits2);
429 t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
430 true, GSI_SAME_STMT);
431 t = fold_build2 (BIT_AND_EXPR, TREE_TYPE (name1), name1, t);
432 t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
433 true, GSI_SAME_STMT);
434 t = fold_build2 (result_inv ? NE_EXPR : EQ_EXPR, boolean_type_node, t,
435 build_int_cst (TREE_TYPE (t), 0));
436 t = canonicalize_cond_expr_cond (t);
437 if (!t)
438 return false;
439 gimple_cond_set_condition_from_tree (inner_cond, t);
440 update_stmt (inner_cond);
441
442 /* Leave CFG optimization to cfg_cleanup. */
443 gimple_cond_set_condition_from_tree (outer_cond,
444 outer_inv ? boolean_false_node : boolean_true_node);
445 update_stmt (outer_cond);
446
447 if (dump_file)
448 {
449 fprintf (dump_file, "optimizing bits or bits test to ");
450 print_generic_expr (dump_file, name1, 0);
451 fprintf (dump_file, " & T != 0\nwith temporary T = ");
452 print_generic_expr (dump_file, bits1, 0);
453 fprintf (dump_file, " | ");
454 print_generic_expr (dump_file, bits2, 0);
455 fprintf (dump_file, "\n");
456 }
457
458 return true;
459 }
460
461 /* See if we have two comparisons that we can merge into one. */
462 else if (TREE_CODE_CLASS (gimple_cond_code (inner_cond)) == tcc_comparison
463 && TREE_CODE_CLASS (gimple_cond_code (outer_cond)) == tcc_comparison)
464 {
465 tree t;
466 enum tree_code inner_cond_code = gimple_cond_code (inner_cond);
467 enum tree_code outer_cond_code = gimple_cond_code (outer_cond);
468
469 /* Invert comparisons if necessary (and possible). */
470 if (inner_inv)
471 inner_cond_code = invert_tree_comparison (inner_cond_code,
472 HONOR_NANS (TYPE_MODE (TREE_TYPE (gimple_cond_lhs (inner_cond)))));
473 if (inner_cond_code == ERROR_MARK)
474 return false;
475 if (outer_inv)
476 outer_cond_code = invert_tree_comparison (outer_cond_code,
477 HONOR_NANS (TYPE_MODE (TREE_TYPE (gimple_cond_lhs (outer_cond)))));
478 if (outer_cond_code == ERROR_MARK)
479 return false;
480 /* Don't return false so fast, try maybe_fold_or_comparisons? */
481
482 if (!(t = maybe_fold_and_comparisons (inner_cond_code,
483 gimple_cond_lhs (inner_cond),
484 gimple_cond_rhs (inner_cond),
485 outer_cond_code,
486 gimple_cond_lhs (outer_cond),
487 gimple_cond_rhs (outer_cond))))
488 return false;
489 if (result_inv)
490 t = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (t), t);
491 t = canonicalize_cond_expr_cond (t);
492 if (!t)
493 return false;
494 gimple_cond_set_condition_from_tree (inner_cond, t);
495 update_stmt (inner_cond);
496
497 /* Leave CFG optimization to cfg_cleanup. */
498 gimple_cond_set_condition_from_tree (outer_cond,
499 outer_inv ? boolean_false_node : boolean_true_node);
500 update_stmt (outer_cond);
501
502 if (dump_file)
503 {
504 fprintf (dump_file, "optimizing two comparisons to ");
505 print_generic_expr (dump_file, t, 0);
506 fprintf (dump_file, "\n");
507 }
508
509 return true;
510 }
511
512 return false;
513 }
514
515 /* Recognize a CFG pattern and dispatch to the appropriate
516 if-conversion helper. We start with BB as the innermost
517 worker basic-block. Returns true if a transformation was done. */
518
519 static bool
520 tree_ssa_ifcombine_bb (basic_block inner_cond_bb)
521 {
522 basic_block then_bb = NULL, else_bb = NULL;
523
524 if (!recognize_if_then_else (inner_cond_bb, &then_bb, &else_bb))
525 return false;
526
527 /* Recognize && and || of two conditions with a common
528 then/else block which entry edges we can merge. That is:
529 if (a || b)
530 ;
531 and
532 if (a && b)
533 ;
534 This requires a single predecessor of the inner cond_bb. */
535 if (single_pred_p (inner_cond_bb))
536 {
537 basic_block outer_cond_bb = single_pred (inner_cond_bb);
538
539 /* The && form is characterized by a common else_bb with
540 the two edges leading to it mergable. The latter is
541 guaranteed by matching PHI arguments in the else_bb and
542 the inner cond_bb having no side-effects. */
543 if (recognize_if_then_else (outer_cond_bb, &inner_cond_bb, &else_bb)
544 && same_phi_args_p (outer_cond_bb, inner_cond_bb, else_bb)
545 && bb_no_side_effects_p (inner_cond_bb))
546 {
547 /* We have
548 <outer_cond_bb>
549 if (q) goto inner_cond_bb; else goto else_bb;
550 <inner_cond_bb>
551 if (p) goto ...; else goto else_bb;
552 ...
553 <else_bb>
554 ...
555 */
556 return ifcombine_ifandif (inner_cond_bb, false, outer_cond_bb, false,
557 false);
558 }
559
560 /* And a version where the outer condition is negated. */
561 if (recognize_if_then_else (outer_cond_bb, &else_bb, &inner_cond_bb)
562 && same_phi_args_p (outer_cond_bb, inner_cond_bb, else_bb)
563 && bb_no_side_effects_p (inner_cond_bb))
564 {
565 /* We have
566 <outer_cond_bb>
567 if (q) goto else_bb; else goto inner_cond_bb;
568 <inner_cond_bb>
569 if (p) goto ...; else goto else_bb;
570 ...
571 <else_bb>
572 ...
573 */
574 return ifcombine_ifandif (inner_cond_bb, false, outer_cond_bb, true,
575 false);
576 }
577
578 /* The || form is characterized by a common then_bb with the
579 two edges leading to it mergable. The latter is guaranteed
580 by matching PHI arguments in the then_bb and the inner cond_bb
581 having no side-effects. */
582 if (recognize_if_then_else (outer_cond_bb, &then_bb, &inner_cond_bb)
583 && same_phi_args_p (outer_cond_bb, inner_cond_bb, then_bb)
584 && bb_no_side_effects_p (inner_cond_bb))
585 {
586 /* We have
587 <outer_cond_bb>
588 if (q) goto then_bb; else goto inner_cond_bb;
589 <inner_cond_bb>
590 if (q) goto then_bb; else goto ...;
591 <then_bb>
592 ...
593 */
594 return ifcombine_ifandif (inner_cond_bb, true, outer_cond_bb, true,
595 true);
596 }
597
598 /* And a version where the outer condition is negated. */
599 if (recognize_if_then_else (outer_cond_bb, &inner_cond_bb, &then_bb)
600 && same_phi_args_p (outer_cond_bb, inner_cond_bb, then_bb)
601 && bb_no_side_effects_p (inner_cond_bb))
602 {
603 /* We have
604 <outer_cond_bb>
605 if (q) goto inner_cond_bb; else goto then_bb;
606 <inner_cond_bb>
607 if (q) goto then_bb; else goto ...;
608 <then_bb>
609 ...
610 */
611 return ifcombine_ifandif (inner_cond_bb, true, outer_cond_bb, false,
612 true);
613 }
614 }
615
616 return false;
617 }
618
619 /* Main entry for the tree if-conversion pass. */
620
621 static unsigned int
622 tree_ssa_ifcombine (void)
623 {
624 basic_block *bbs;
625 bool cfg_changed = false;
626 int i;
627
628 bbs = blocks_in_phiopt_order ();
629 calculate_dominance_info (CDI_DOMINATORS);
630
631 for (i = 0; i < n_basic_blocks - NUM_FIXED_BLOCKS; ++i)
632 {
633 basic_block bb = bbs[i];
634 gimple stmt = last_stmt (bb);
635
636 if (stmt
637 && gimple_code (stmt) == GIMPLE_COND)
638 cfg_changed |= tree_ssa_ifcombine_bb (bb);
639 }
640
641 free (bbs);
642
643 return cfg_changed ? TODO_cleanup_cfg : 0;
644 }
645
646 static bool
647 gate_ifcombine (void)
648 {
649 return 1;
650 }
651
652 struct gimple_opt_pass pass_tree_ifcombine =
653 {
654 {
655 GIMPLE_PASS,
656 "ifcombine", /* name */
657 OPTGROUP_NONE, /* optinfo_flags */
658 gate_ifcombine, /* gate */
659 tree_ssa_ifcombine, /* execute */
660 NULL, /* sub */
661 NULL, /* next */
662 0, /* static_pass_number */
663 TV_TREE_IFCOMBINE, /* tv_id */
664 PROP_cfg | PROP_ssa, /* properties_required */
665 0, /* properties_provided */
666 0, /* properties_destroyed */
667 0, /* todo_flags_start */
668 TODO_ggc_collect
669 | TODO_update_ssa
670 | TODO_verify_ssa /* todo_flags_finish */
671 }
672 };