OSDN Git Service

* combine.c (try_combine): Use any_condjump_p, any_uncondjump_p
[pf3gnuchains/gcc-fork.git] / gcc / ifcvt.c
1 /* If-conversion support.
2    Copyright (C) 2000 Free Software Foundation, Inc.
3
4    This file is part of GNU CC.
5
6    GNU CC 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)
9    any later version.
10
11    GNU CC 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.
15
16    You should have received a copy of the GNU General Public License
17    along with GNU CC; see the file COPYING.  If not, write to
18    the Free Software Foundation, 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20
21 #include "config.h"
22 #include "system.h"
23
24 #include "rtl.h"
25 #include "regs.h"
26 #include "function.h"
27 #include "flags.h"
28 #include "insn-config.h"
29 #include "recog.h"
30 #include "hard-reg-set.h"
31 #include "basic-block.h"
32 #include "expr.h"
33 #include "output.h"
34 #include "tm_p.h"
35
36
37 #ifndef HAVE_conditional_execution
38 #define HAVE_conditional_execution 0
39 #endif
40 #ifndef HAVE_conditional_move
41 #define HAVE_conditional_move 0
42 #endif
43 #ifndef HAVE_incscc
44 #define HAVE_incscc 0
45 #endif
46 #ifndef HAVE_decscc
47 #define HAVE_decscc 0
48 #endif
49
50 #ifndef MAX_CONDITIONAL_EXECUTE
51 #define MAX_CONDITIONAL_EXECUTE   (BRANCH_COST + 1)
52 #endif
53
54 #define EDGE_COMPLEX    (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH)
55
56 #define NULL_EDGE       ((struct edge_def *)NULL)
57 #define NULL_BLOCK      ((struct basic_block_def *)NULL)
58
59 /* # of IF-THEN or IF-THEN-ELSE blocks we looked at  */
60 static int num_possible_if_blocks;
61
62 /* # of IF-THEN or IF-THEN-ELSE blocks were converted to conditional
63    execution.  */
64 static int num_updated_if_blocks;
65
66 /* # of basic blocks that were removed.  */
67 static int num_removed_blocks;
68
69 /* The post-dominator relation on the original block numbers.  */
70 static sbitmap *post_dominators;
71
72 /* Forward references.  */
73 static int count_bb_insns               PARAMS ((basic_block));
74 static rtx first_active_insn            PARAMS ((basic_block));
75 static int last_active_insn_p           PARAMS ((basic_block, rtx));
76
77 static int cond_exec_process_insns      PARAMS ((rtx, rtx, rtx, rtx, int));
78 static rtx cond_exec_get_condition      PARAMS ((rtx));
79 static int cond_exec_process_if_block   PARAMS ((basic_block, basic_block,
80                                                  basic_block, basic_block));
81
82 static rtx noce_get_condition           PARAMS ((rtx, rtx *));
83 static int noce_process_if_block        PARAMS ((basic_block, basic_block,
84                                                  basic_block, basic_block));
85
86 static int process_if_block             PARAMS ((basic_block, basic_block,
87                                                  basic_block, basic_block));
88 static void merge_if_block              PARAMS ((basic_block, basic_block,
89                                                  basic_block, basic_block));
90
91 static int find_if_header               PARAMS ((basic_block));
92 static int find_if_block                PARAMS ((basic_block, edge, edge));
93 static int find_if_case_1               PARAMS ((basic_block, edge, edge));
94 static int find_if_case_2               PARAMS ((basic_block, edge, edge));
95 static int find_memory                  PARAMS ((rtx *, void *));
96 static int dead_or_predicable           PARAMS ((basic_block, basic_block,
97                                                  basic_block, rtx, int));
98 \f
99 /* Abuse the basic_block AUX field to store the original block index,
100    as well as a flag indicating that the block should be rescaned for
101    life analysis.  */
102
103 #define SET_ORIG_INDEX(BB,I)    ((BB)->aux = (void *)((size_t)(I) << 1))
104 #define ORIG_INDEX(BB)          ((size_t)(BB)->aux >> 1)
105 #define SET_UPDATE_LIFE(BB)     ((BB)->aux = (void *)((size_t)(BB)->aux | 1))
106 #define UPDATE_LIFE(BB)         ((size_t)(BB)->aux & 1)
107
108 \f
109 /* Count the number of non-jump active insns in BB.  */
110
111 static int
112 count_bb_insns (bb)
113      basic_block bb;
114 {
115   int count = 0;
116   rtx insn = bb->head;
117
118   while (1)
119     {
120       if (GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == INSN)
121         count++;
122
123       if (insn == bb->end)
124         break;
125       insn = NEXT_INSN (insn);
126     }
127
128   return count;
129 }
130
131 /* Return the first non-jump active insn in the basic block.  */
132
133 static rtx
134 first_active_insn (bb)
135      basic_block bb;
136 {
137   rtx insn = bb->head;
138
139   if (GET_CODE (insn) == CODE_LABEL)
140     {
141       if (insn == bb->end)
142         return NULL_RTX;
143       insn = NEXT_INSN (insn);
144     }
145
146   while (GET_CODE (insn) == NOTE)
147     {
148       if (insn == bb->end)
149         return NULL_RTX;
150       insn = NEXT_INSN (insn);
151     }
152
153   if (GET_CODE (insn) == JUMP_INSN)
154     return NULL_RTX;
155
156   return insn;
157 }
158
159 /* Return true if INSN is the last active non-jump insn in BB.  */
160
161 static int
162 last_active_insn_p (bb, insn)
163      basic_block bb;
164      rtx insn;
165 {
166   do
167     {
168       if (insn == bb->end)
169         return TRUE;
170       insn = NEXT_INSN (insn);
171     }
172   while (GET_CODE (insn) == NOTE);
173
174   return GET_CODE (insn) == JUMP_INSN;
175 }
176 \f
177 /* Go through a bunch of insns, converting them to conditional
178    execution format if possible.  Return TRUE if all of the non-note
179    insns were processed.  */
180
181 static int
182 cond_exec_process_insns (start, end, test, prob_val, mod_ok)
183      rtx start;                 /* first insn to look at */
184      rtx end;                   /* last insn to look at */
185      rtx test;                  /* conditional execution test */
186      rtx prob_val;              /* probability of branch taken.  */
187      int mod_ok;                /* true if modifications ok last insn.  */
188 {
189   int must_be_last = FALSE;
190   rtx insn;
191
192   for (insn = start; ; insn = NEXT_INSN (insn))
193     {
194       if (GET_CODE (insn) == NOTE)
195         goto insn_done;
196
197       if (GET_CODE (insn) != INSN && GET_CODE (insn) != CALL_INSN)
198         abort ();
199
200       /* Remove USE and CLOBBER insns that get in the way.  */
201       if (reload_completed
202           && (GET_CODE (PATTERN (insn)) == USE
203               || GET_CODE (PATTERN (insn)) == CLOBBER))
204         {
205           /* ??? Ug.  Actually unlinking the thing is problematic, 
206              given what we'd have to coordinate with our callers.  */
207           PUT_CODE (insn, NOTE);
208           NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
209           NOTE_SOURCE_FILE (insn) = 0;
210           goto insn_done;
211         }
212
213       /* Last insn wasn't last?  */
214       if (must_be_last)
215         return FALSE;
216
217       if (modified_in_p (test, insn))
218         {
219           if (!mod_ok)
220             return FALSE;
221           must_be_last = TRUE;
222         }
223
224       /* Now build the conditional form of the instruction.  */
225       validate_change (insn, &PATTERN (insn),
226                        gen_rtx_COND_EXEC (VOIDmode, copy_rtx (test),
227                                           PATTERN (insn)), 1);
228
229       if (GET_CODE (insn) == CALL_INSN && prob_val)
230         validate_change (insn, &REG_NOTES (insn),
231                          alloc_EXPR_LIST (REG_BR_PROB, prob_val,
232                                           REG_NOTES (insn)), 1);
233
234     insn_done:
235       if (insn == end)
236         break;
237     }
238
239   return TRUE;
240 }
241
242 /* Return the condition for a jump.  Do not do any special processing.  */
243
244 static rtx
245 cond_exec_get_condition (jump)
246      rtx jump;
247 {
248   rtx test_if, cond;
249
250   if (any_condjump_p (jump))
251     test_if = pc_set (jump);
252   else
253     return NULL_RTX;
254   cond = XEXP (test_if, 0);
255
256   /* If this branches to JUMP_LABEL when the condition is false,
257      reverse the condition.  */
258   if (GET_CODE (XEXP (test_if, 2)) == LABEL_REF
259       && XEXP (XEXP (test_if, 2), 0) == JUMP_LABEL (jump))
260     cond = gen_rtx_fmt_ee (reverse_condition (GET_CODE (cond)),
261                            GET_MODE (cond), XEXP (cond, 0),
262                            XEXP (cond, 1));
263
264   return cond;
265 }
266
267 /* Given a simple IF-THEN or IF-THEN-ELSE block, attempt to convert it
268    to conditional execution.  Return TRUE if we were successful at
269    converting the the block.  */
270
271 static int
272 cond_exec_process_if_block (test_bb, then_bb, else_bb, join_bb)
273      basic_block test_bb;       /* Basic block test is in */
274      basic_block then_bb;       /* Basic block for THEN block */
275      basic_block else_bb;       /* Basic block for ELSE block */
276      basic_block join_bb;       /* Basic block the join label is in */
277 {
278   rtx test_expr;                /* expression in IF_THEN_ELSE that is tested */
279   rtx then_start;               /* first insn in THEN block */
280   rtx then_end;                 /* last insn + 1 in THEN block */
281   rtx else_start;               /* first insn in ELSE block or NULL */
282   rtx else_end;                 /* last insn + 1 in ELSE block */
283   int max;                      /* max # of insns to convert. */
284   int then_mod_ok;              /* whether conditional mods are ok in THEN */
285   rtx true_expr;                /* test for else block insns */
286   rtx false_expr;               /* test for then block insns */
287   rtx true_prob_val;            /* probability of else block */
288   rtx false_prob_val;           /* probability of then block */
289   int n_insns;
290
291   /* Find the conditional jump to the ELSE or JOIN part, and isolate
292      the test.  */
293   test_expr = cond_exec_get_condition (test_bb->end);
294   if (! test_expr)
295     return FALSE;
296
297   /* Collect the bounds of where we're to search.  */
298
299   then_start = then_bb->head;
300   then_end = then_bb->end;
301
302   /* Skip a label heading THEN block.  */
303   if (GET_CODE (then_start) == CODE_LABEL)
304     then_start = NEXT_INSN (then_start);
305
306   /* Skip a (use (const_int 0)) or branch as the final insn.  */
307   if (GET_CODE (then_end) == INSN
308       && GET_CODE (PATTERN (then_end)) == USE
309       && GET_CODE (XEXP (PATTERN (then_end), 0)) == CONST_INT)
310     then_end = PREV_INSN (then_end);
311   else if (GET_CODE (then_end) == JUMP_INSN)
312     then_end = PREV_INSN (then_end);
313
314   if (else_bb)
315     {
316       /* Skip the ELSE block's label.  */
317       else_start = NEXT_INSN (else_bb->head);
318       else_end = else_bb->end;
319
320       /* Skip a (use (const_int 0)) or branch as the final insn.  */
321       if (GET_CODE (else_end) == INSN
322           && GET_CODE (PATTERN (else_end)) == USE
323           && GET_CODE (XEXP (PATTERN (else_end), 0)) == CONST_INT)
324         else_end = PREV_INSN (else_end);
325       else if (GET_CODE (else_end) == JUMP_INSN)
326         else_end = PREV_INSN (else_end);
327     }
328
329   /* How many instructions should we convert in total?  */
330   n_insns = 0;
331   if (else_bb)
332     {
333       max = 2 * MAX_CONDITIONAL_EXECUTE;
334       n_insns = count_bb_insns (else_bb);
335     }
336   else
337     max = MAX_CONDITIONAL_EXECUTE;
338   n_insns += count_bb_insns (then_bb);
339   if (n_insns > max)
340     return FALSE;
341
342   /* Map test_expr/test_jump into the appropriate MD tests to use on
343      the conditionally executed code.  */
344   
345   true_expr = test_expr;
346   false_expr = gen_rtx_fmt_ee (reverse_condition (GET_CODE (true_expr)),
347                                GET_MODE (true_expr), XEXP (true_expr, 0),
348                                XEXP (true_expr, 1));
349
350   true_prob_val = find_reg_note (test_bb->end, REG_BR_PROB, NULL_RTX);
351   if (true_prob_val)
352     {
353       true_prob_val = XEXP (true_prob_val, 0);
354       false_prob_val = GEN_INT (REG_BR_PROB_BASE - INTVAL (true_prob_val));
355     }
356   else
357     false_prob_val = NULL_RTX;
358
359   /* For IF-THEN-ELSE blocks, we don't allow modifications of the test
360      on then THEN block.  */
361   then_mod_ok = (else_bb == NULL_BLOCK);
362
363   /* Go through the THEN and ELSE blocks converting the insns if possible
364      to conditional execution.  */
365
366   if (then_end
367       && ! cond_exec_process_insns (then_start, then_end,
368                                     false_expr, false_prob_val, then_mod_ok))
369     goto fail;
370
371   if (else_bb
372       && ! cond_exec_process_insns (else_start, else_end,
373                                     true_expr, true_prob_val, TRUE))
374     goto fail;
375
376   if (! apply_change_group ())
377     return FALSE;
378
379   /* Conversion succeeded.  */
380   if (rtl_dump_file)
381     fprintf (rtl_dump_file, "%d insn%s converted to conditional execution.\n",
382              n_insns, (n_insns == 1) ? " was" : "s were");
383
384   /* Merge the blocks!  */
385   merge_if_block (test_bb, then_bb, else_bb, join_bb);
386   return TRUE;
387
388  fail:
389   cancel_changes (0);
390   return FALSE;
391 }
392 \f
393 /* Used by noce_process_if_block to communicate with its subroutines. 
394
395    The subroutines know that A and B may be evaluated freely.  They
396    know that X is a register.  They should insert new instructions 
397    before cond_earliest.  */
398
399 struct noce_if_info
400 {
401   rtx insn_a, insn_b;
402   rtx x, a, b;
403   rtx jump, cond, cond_earliest;
404 };
405
406 static rtx noce_emit_store_flag         PARAMS ((struct noce_if_info *,
407                                                  rtx, int, int));
408 static int noce_try_store_flag          PARAMS ((struct noce_if_info *));
409 static int noce_try_store_flag_inc      PARAMS ((struct noce_if_info *));
410 static int noce_try_store_flag_constants PARAMS ((struct noce_if_info *));
411 static int noce_try_store_flag_mask     PARAMS ((struct noce_if_info *));
412 static rtx noce_emit_cmove              PARAMS ((struct noce_if_info *,
413                                                  rtx, enum rtx_code, rtx,
414                                                  rtx, rtx, rtx));
415 static int noce_try_cmove               PARAMS ((struct noce_if_info *));
416 static int noce_try_cmove_arith         PARAMS ((struct noce_if_info *));
417
418 /* Helper function for noce_try_store_flag*.  */
419
420 static rtx
421 noce_emit_store_flag (if_info, x, reversep, normalize)
422      struct noce_if_info *if_info;
423      rtx x;
424      int reversep, normalize;
425 {
426   rtx cond = if_info->cond;
427   int cond_complex;
428   enum rtx_code code;
429
430   cond_complex = (! general_operand (XEXP (cond, 0), VOIDmode)
431                   || ! general_operand (XEXP (cond, 1), VOIDmode));
432
433   /* If earliest == jump, or when the condition is complex, try to
434      build the store_flag insn directly.  */
435
436   if (cond_complex)
437     cond = XEXP (SET_SRC (PATTERN (if_info->jump)), 0);
438
439   if ((if_info->cond_earliest == if_info->jump || cond_complex)
440       && (normalize == 0 || STORE_FLAG_VALUE == normalize))
441     {
442       rtx tmp;
443
444       code = GET_CODE (cond);
445       if (reversep)
446         code = reverse_condition (code);
447
448       tmp = gen_rtx_fmt_ee (code, GET_MODE (x), XEXP (cond, 0),
449                             XEXP (cond, 1));
450       tmp = gen_rtx_SET (VOIDmode, x, tmp);
451
452       start_sequence ();
453       tmp = emit_insn (tmp);
454
455       if (recog_memoized (tmp) >= 0)
456         {
457           tmp = get_insns ();
458           end_sequence ();
459           emit_insns (tmp);
460
461           if_info->cond_earliest = if_info->jump;
462
463           return x;
464         }
465
466       end_sequence ();
467     }
468
469   /* Don't even try if the comparison operands are weird.  */
470   if (cond_complex)
471     return NULL_RTX;
472
473   code = GET_CODE (cond);
474   if (reversep)
475     code = reverse_condition (code);
476
477   return emit_store_flag (x, code, XEXP (cond, 0),
478                           XEXP (cond, 1), VOIDmode,
479                           (code == LTU || code == LEU
480                            || code == GEU || code == GTU), normalize);
481 }
482
483 /* Convert "if (test) x = 1; else x = 0".
484
485    Only try 0 and STORE_FLAG_VALUE here.  Other combinations will be
486    tried in noce_try_store_flag_constants after noce_try_cmove has had
487    a go at the conversion.  */
488
489 static int
490 noce_try_store_flag (if_info)
491      struct noce_if_info *if_info;
492 {
493   int reversep;
494   rtx target, seq;
495
496   if (GET_CODE (if_info->b) == CONST_INT
497       && INTVAL (if_info->b) == STORE_FLAG_VALUE
498       && if_info->a == const0_rtx)
499     reversep = 0;
500   else if (if_info->b == const0_rtx
501            && GET_CODE (if_info->a) == CONST_INT
502            && INTVAL (if_info->a) == STORE_FLAG_VALUE
503            && can_reverse_comparison_p (if_info->cond, if_info->jump))
504     reversep = 1;
505   else
506     return FALSE;
507
508   start_sequence ();
509
510   target = noce_emit_store_flag (if_info, if_info->x, reversep, 0);
511   if (target)
512     {
513       if (target != if_info->x)
514         emit_move_insn (if_info->x, target);
515
516       seq = get_insns ();
517       end_sequence ();
518       emit_insns_before (seq, if_info->cond_earliest);
519
520       return TRUE;
521     }
522   else
523     {
524       end_sequence ();
525       return FALSE;
526     }
527 }
528
529 /* Convert "if (test) x = a; else x = b", for A and B constant.  */
530
531 static int
532 noce_try_store_flag_constants (if_info)
533      struct noce_if_info *if_info;
534 {
535   rtx target, seq;
536   int reversep;
537   HOST_WIDE_INT itrue, ifalse, diff, tmp;
538   int normalize, can_reverse;
539
540   if (! no_new_pseudos
541       && GET_CODE (if_info->a) == CONST_INT
542       && GET_CODE (if_info->b) == CONST_INT)
543     {
544       ifalse = INTVAL (if_info->a);
545       itrue = INTVAL (if_info->b);
546       diff = itrue - ifalse;
547
548       can_reverse = can_reverse_comparison_p (if_info->cond, if_info->jump);
549
550       reversep = 0;
551       if (diff == STORE_FLAG_VALUE || diff == -STORE_FLAG_VALUE)
552         normalize = 0;
553       else if (ifalse == 0 && exact_log2 (itrue) >= 0
554                && (STORE_FLAG_VALUE == 1
555                    || BRANCH_COST >= 2))
556         normalize = 1;
557       else if (itrue == 0 && exact_log2 (ifalse) >= 0 && can_reverse
558                && (STORE_FLAG_VALUE == 1 || BRANCH_COST >= 2))
559         normalize = 1, reversep = 1;
560       else if (itrue == -1
561                && (STORE_FLAG_VALUE == -1
562                    || BRANCH_COST >= 2))
563         normalize = -1;
564       else if (ifalse == -1 && can_reverse
565                && (STORE_FLAG_VALUE == -1 || BRANCH_COST >= 2))
566         normalize = -1, reversep = 1;
567       else if ((BRANCH_COST >= 2 && STORE_FLAG_VALUE == -1)
568                || BRANCH_COST >= 3)
569         normalize = -1;
570       else
571         return FALSE;
572
573       if (reversep)
574         {
575           tmp = itrue; itrue = ifalse; ifalse = tmp;
576           diff = -diff;
577         }
578
579       start_sequence ();
580       target = noce_emit_store_flag (if_info, if_info->x, reversep, normalize);
581       if (! target)
582         {
583           end_sequence ();
584           return FALSE;
585         }
586
587       /* if (test) x = 3; else x = 4;
588          =>   x = 3 + (test == 0);  */
589       if (diff == STORE_FLAG_VALUE || diff == -STORE_FLAG_VALUE)
590         {
591           target = expand_binop (GET_MODE (if_info->x),
592                                  (diff == STORE_FLAG_VALUE
593                                   ? add_optab : sub_optab),
594                                  GEN_INT (ifalse), target, if_info->x, 0,
595                                  OPTAB_WIDEN);
596         }
597
598       /* if (test) x = 8; else x = 0;
599          =>   x = (test != 0) << 3;  */
600       else if (ifalse == 0 && (tmp = exact_log2 (itrue)) >= 0)
601         {
602           target = expand_binop (GET_MODE (if_info->x), ashl_optab,
603                                  target, GEN_INT (tmp), if_info->x, 0,
604                                  OPTAB_WIDEN);
605         }
606
607       /* if (test) x = -1; else x = b;
608          =>   x = -(test != 0) | b;  */
609       else if (itrue == -1)
610         {
611           target = expand_binop (GET_MODE (if_info->x), ior_optab,
612                                  target, GEN_INT (ifalse), if_info->x, 0,
613                                  OPTAB_WIDEN);
614         }
615
616       /* if (test) x = a; else x = b;
617          =>   x = (-(test != 0) & (b - a)) + a;  */
618       else
619         {
620           target = expand_binop (GET_MODE (if_info->x), and_optab,
621                                  target, GEN_INT (diff), if_info->x, 0,
622                                  OPTAB_WIDEN);
623           if (target)
624             target = expand_binop (GET_MODE (if_info->x), add_optab,
625                                    target, GEN_INT (ifalse), if_info->x, 0,
626                                    OPTAB_WIDEN);
627         }
628
629       if (! target)
630         {
631           end_sequence ();
632           return FALSE;
633         }
634
635       if (target != if_info->x)
636         emit_move_insn (if_info->x, target);
637
638       seq = get_insns ();
639       end_sequence ();
640       emit_insns_before (seq, if_info->cond_earliest);
641
642       return TRUE;
643     }
644
645   return FALSE;
646 }
647
648 /* Convert "if (test) foo++" into "foo += (test != 0)", and 
649    similarly for "foo--".  */
650
651 static int
652 noce_try_store_flag_inc (if_info)
653      struct noce_if_info *if_info;
654 {
655   rtx target, seq;
656   int subtract, normalize;
657
658   if (! no_new_pseudos
659       && (BRANCH_COST >= 2
660           || HAVE_incscc
661           || HAVE_decscc)
662       /* Should be no `else' case to worry about.  */
663       && if_info->b == if_info->x
664       && GET_CODE (if_info->a) == PLUS
665       && (XEXP (if_info->a, 1) == const1_rtx
666           || XEXP (if_info->a, 1) == constm1_rtx)
667       && rtx_equal_p (XEXP (if_info->a, 0), if_info->x)
668       && can_reverse_comparison_p (if_info->cond, if_info->jump))
669     {
670       if (STORE_FLAG_VALUE == INTVAL (XEXP (if_info->a, 1)))
671         subtract = 0, normalize = 0;
672       else if (-STORE_FLAG_VALUE == INTVAL (XEXP (if_info->a, 1)))
673         subtract = 1, normalize = 0;
674       else
675         subtract = 0, normalize = INTVAL (XEXP (if_info->a, 1));
676       
677       start_sequence ();
678
679       target = noce_emit_store_flag (if_info,
680                                      gen_reg_rtx (GET_MODE (if_info->x)),
681                                      1, normalize);
682
683       if (target)
684         target = expand_binop (GET_MODE (if_info->x),
685                                subtract ? sub_optab : add_optab,
686                                if_info->x, target, if_info->x, 0, OPTAB_WIDEN);
687       if (target)
688         {
689           if (target != if_info->x)
690             emit_move_insn (if_info->x, target);
691
692           seq = get_insns ();
693           end_sequence ();
694           emit_insns_before (seq, if_info->cond_earliest);
695
696           return TRUE;
697         }
698
699       end_sequence ();
700     }
701
702   return FALSE;
703 }
704
705 /* Convert "if (test) x = 0;" to "x &= -(test == 0);"  */
706
707 static int
708 noce_try_store_flag_mask (if_info)
709      struct noce_if_info *if_info;
710 {
711   rtx target, seq;
712   int reversep;
713
714   reversep = 0;
715   if (! no_new_pseudos
716       && (BRANCH_COST >= 2
717           || STORE_FLAG_VALUE == -1)
718       && ((if_info->a == const0_rtx
719            && rtx_equal_p (if_info->b, if_info->x))
720           || ((reversep = can_reverse_comparison_p (if_info->cond,
721                                                     if_info->jump))
722               && if_info->b == const0_rtx
723               && rtx_equal_p (if_info->a, if_info->x))))
724     {
725       start_sequence ();
726       target = noce_emit_store_flag (if_info,
727                                      gen_reg_rtx (GET_MODE (if_info->x)),
728                                      reversep, -1);
729       if (target)
730         target = expand_binop (GET_MODE (if_info->x), and_optab,
731                                if_info->x, target, if_info->x, 0,
732                                OPTAB_WIDEN);
733
734       if (target)
735         {
736           if (target != if_info->x)
737             emit_move_insn (if_info->x, target);
738
739           seq = get_insns ();
740           end_sequence ();
741           emit_insns_before (seq, if_info->cond_earliest);
742
743           return TRUE;
744         }
745
746       end_sequence ();
747     }
748
749   return FALSE;
750 }
751
752 /* Helper function for noce_try_cmove and noce_try_cmove_arith.  */
753
754 static rtx
755 noce_emit_cmove (if_info, x, code, cmp_a, cmp_b, vfalse, vtrue)
756      struct noce_if_info *if_info;
757      rtx x, cmp_a, cmp_b, vfalse, vtrue;
758      enum rtx_code code;
759 {
760   /* If earliest == jump, try to build the cmove insn directly.
761      This is helpful when combine has created some complex condition
762      (like for alpha's cmovlbs) that we can't hope to regenerate
763      through the normal interface.  */
764
765   if (if_info->cond_earliest == if_info->jump)
766     {
767       rtx tmp;
768
769       tmp = gen_rtx_fmt_ee (code, GET_MODE (if_info->cond), cmp_a, cmp_b);
770       tmp = gen_rtx_IF_THEN_ELSE (GET_MODE (x), tmp, vtrue, vfalse);
771       tmp = gen_rtx_SET (VOIDmode, x, tmp);
772
773       start_sequence ();
774       tmp = emit_insn (tmp);
775
776       if (recog_memoized (tmp) >= 0)
777         {
778           tmp = get_insns ();
779           end_sequence ();
780           emit_insns (tmp);
781
782           return x;
783         }
784
785       end_sequence ();
786     }
787
788   /* Don't even try if the comparison operands are weird.  */
789   if (! general_operand (cmp_a, GET_MODE (cmp_a))
790       || ! general_operand (cmp_b, GET_MODE (cmp_b)))
791     return NULL_RTX;
792
793 #if HAVE_conditional_move
794   return emit_conditional_move (x, code, cmp_a, cmp_b, VOIDmode,
795                                 vtrue, vfalse, GET_MODE (x),
796                                 (code == LTU || code == GEU
797                                  || code == LEU || code == GTU));
798 #else
799   /* We'll never get here, as noce_process_if_block doesn't call the
800      functions involved.  Ifdef code, however, should be discouraged
801      because it leads to typos in the code not selected.  However, 
802      emit_conditional_move won't exist either.  */
803   return NULL_RTX;
804 #endif
805 }
806
807 /* Try only simple constants and registers here.  More complex cases
808    are handled in noce_try_cmove_arith after noce_try_store_flag_arith
809    has had a go at it.  */
810
811 static int
812 noce_try_cmove (if_info)
813      struct noce_if_info *if_info;
814 {
815   enum rtx_code code;
816   rtx target, seq;
817
818   if ((CONSTANT_P (if_info->a) || register_operand (if_info->a, VOIDmode))
819       && (CONSTANT_P (if_info->b) || register_operand (if_info->b, VOIDmode)))
820     {
821       start_sequence ();
822
823       code = GET_CODE (if_info->cond);
824       target = noce_emit_cmove (if_info, if_info->x, code,
825                                 XEXP (if_info->cond, 0),
826                                 XEXP (if_info->cond, 1),
827                                 if_info->a, if_info->b);
828
829       if (target)
830         {
831           if (target != if_info->x)
832             emit_move_insn (if_info->x, target);
833
834           seq = get_insns ();
835           end_sequence ();
836           emit_insns_before (seq, if_info->cond_earliest);
837           return TRUE;
838         }
839       else
840         {
841           end_sequence ();
842           return FALSE;
843         }
844     }
845
846   return FALSE;
847 }
848
849 /* Try more complex cases involving conditional_move.  */
850
851 static int
852 noce_try_cmove_arith (if_info)
853      struct noce_if_info *if_info;
854 {
855   rtx a = if_info->a;
856   rtx b = if_info->b;
857   rtx x = if_info->x;
858   rtx insn_a, insn_b;
859   rtx tmp, target;
860   int is_mem = 0;
861   enum rtx_code code;
862
863   /* A conditional move from two memory sources is equivalent to a
864      conditional on their addresses followed by a load.  Don't do this
865      early because it'll screw alias analysis.  Note that we've
866      already checked for no side effects.  */
867   if (! no_new_pseudos && cse_not_expected
868       && GET_CODE (a) == MEM && GET_CODE (b) == MEM
869       && BRANCH_COST >= 5)
870     {
871       a = XEXP (a, 0);
872       b = XEXP (b, 0);
873       x = gen_reg_rtx (Pmode);
874       is_mem = 1;
875     }
876
877   /* ??? We could handle this if we knew that a load from A or B could
878      not fault.  This is also true if we've already loaded
879      from the address along the path from ENTRY.  */
880   else if (may_trap_p (a) || may_trap_p (b))
881     return FALSE;
882
883   /* if (test) x = a + b; else x = c - d;
884      => y = a + b;
885         x = c - d;
886         if (test)
887           x = y;
888   */
889   
890   code = GET_CODE (if_info->cond);
891   insn_a = if_info->insn_a;
892   insn_b = if_info->insn_b;
893
894   /* Possibly rearrange operands to make things come out more natural.  */
895   if (can_reverse_comparison_p (if_info->cond, if_info->jump))
896     {
897       int reversep = 0;
898       if (rtx_equal_p (b, x))
899         reversep = 1;
900       else if (general_operand (b, GET_MODE (b)))
901         reversep = 1;
902
903       if (reversep)
904         {
905           code = reverse_condition (code);
906           tmp = a, a = b, b = tmp;
907           tmp = insn_a, insn_a = insn_b, insn_b = tmp;
908         }
909     }
910
911   start_sequence ();
912
913   /* If either operand is complex, load it into a register first.
914      The best way to do this is to copy the original insn.  In this
915      way we preserve any clobbers etc that the insn may have had.  
916      This is of course not possible in the IS_MEM case.  */
917   if (! general_operand (a, GET_MODE (a)))
918     {
919       rtx set;
920
921       if (no_new_pseudos)
922         goto end_seq_and_fail;
923
924       if (is_mem)
925         {
926           tmp = gen_reg_rtx (GET_MODE (a));
927           tmp = emit_insn (gen_rtx_SET (VOIDmode, tmp, a));
928         }
929       else if (! insn_a)
930         goto end_seq_and_fail;
931       else
932         {
933           a = gen_reg_rtx (GET_MODE (a));
934           tmp = copy_rtx (insn_a);
935           set = single_set (tmp);
936           SET_DEST (set) = a;
937           tmp = emit_insn (PATTERN (tmp));
938         }
939       if (recog_memoized (tmp) < 0)
940         goto end_seq_and_fail;
941     }
942   if (! general_operand (b, GET_MODE (b)))
943     {
944       rtx set;
945
946       if (no_new_pseudos)
947         goto end_seq_and_fail;
948
949       if (is_mem)
950         {
951           tmp = gen_reg_rtx (GET_MODE (b));
952           tmp = emit_insn (gen_rtx_SET (VOIDmode, tmp, b));
953         }
954       else if (! insn_b)
955         goto end_seq_and_fail;
956       else
957         {
958           b = gen_reg_rtx (GET_MODE (b));
959           tmp = copy_rtx (insn_b);
960           set = single_set (tmp);
961           SET_DEST (set) = b;
962           tmp = emit_insn (PATTERN (tmp));
963         }
964       if (recog_memoized (tmp) < 0)
965         goto end_seq_and_fail;
966     }
967
968   target = noce_emit_cmove (if_info, x, code, XEXP (if_info->cond, 0),
969                             XEXP (if_info->cond, 1), a, b);
970
971   if (! target)
972     goto end_seq_and_fail;
973
974   /* If we're handling a memory for above, emit the load now.  */
975   if (is_mem)
976     {
977       tmp = gen_rtx_MEM (GET_MODE (if_info->x), target);
978
979       /* Copy over flags as appropriate.  */
980       if (MEM_VOLATILE_P (if_info->a) || MEM_VOLATILE_P (if_info->b))
981         MEM_VOLATILE_P (tmp) = 1;
982       if (MEM_IN_STRUCT_P (if_info->a) && MEM_IN_STRUCT_P (if_info->b))
983         MEM_IN_STRUCT_P (tmp) = 1;
984       if (MEM_SCALAR_P (if_info->a) && MEM_SCALAR_P (if_info->b))
985         MEM_SCALAR_P (tmp) = 1;
986       if (MEM_ALIAS_SET (if_info->a) == MEM_ALIAS_SET (if_info->b))
987         MEM_ALIAS_SET (tmp) = MEM_ALIAS_SET (if_info->a);
988
989       emit_move_insn (if_info->x, tmp);
990     }
991   else if (target != x)
992     emit_move_insn (x, target);
993
994   tmp = get_insns ();
995   end_sequence ();
996   emit_insns_before (tmp, if_info->cond_earliest);
997   return TRUE;
998
999  end_seq_and_fail:
1000   end_sequence ();
1001   return FALSE;
1002 }
1003
1004 /* Look for the condition for the jump first.  We'd prefer to avoid
1005    get_condition if we can -- it tries to look back for the contents
1006    of an original compare.  On targets that use normal integers for
1007    comparisons, e.g. alpha, this is wasteful.  */
1008
1009 static rtx
1010 noce_get_condition (jump, earliest)
1011      rtx jump;
1012      rtx *earliest;
1013 {
1014   rtx cond;
1015   rtx set;
1016
1017   /* If the condition variable is a register and is MODE_INT, accept it.
1018      Otherwise, fall back on get_condition.  */
1019
1020   if (! any_condjump_p (jump))
1021     return NULL_RTX;
1022
1023   set = pc_set (jump);
1024
1025   cond = XEXP (SET_SRC (set), 0);
1026   if (GET_CODE (XEXP (cond, 0)) == REG
1027       && GET_MODE_CLASS (GET_MODE (XEXP (cond, 0))) == MODE_INT)
1028     {
1029       *earliest = jump;
1030
1031       /* If this branches to JUMP_LABEL when the condition is false,
1032          reverse the condition.  */
1033       if (GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF
1034           && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump))
1035         cond = gen_rtx_fmt_ee (reverse_condition (GET_CODE (cond)),
1036                                GET_MODE (cond), XEXP (cond, 0),
1037                                XEXP (cond, 1));
1038     }
1039   else
1040     cond = get_condition (jump, earliest);
1041
1042   return cond;
1043 }
1044
1045 /* Given a simple IF-THEN or IF-THEN-ELSE block, attempt to convert it
1046    without using conditional execution.  Return TRUE if we were
1047    successful at converting the the block.  */
1048
1049 static int
1050 noce_process_if_block (test_bb, then_bb, else_bb, join_bb)
1051      basic_block test_bb;       /* Basic block test is in */
1052      basic_block then_bb;       /* Basic block for THEN block */
1053      basic_block else_bb;       /* Basic block for ELSE block */
1054      basic_block join_bb;       /* Basic block the join label is in */
1055 {
1056   /* We're looking for patterns of the form
1057
1058      (1) if (...) x = a; else x = b;
1059      (2) x = b; if (...) x = a;
1060      (3) if (...) x = a;   // as if with an initial x = x.
1061
1062      The later patterns require jumps to be more expensive.
1063
1064      ??? For future expansion, look for multiple X in such patterns.  */
1065
1066   struct noce_if_info if_info;
1067   rtx insn_a, insn_b;
1068   rtx set_a, set_b;
1069   rtx orig_x, x, a, b;
1070   rtx jump, cond, insn;
1071
1072   /* If this is not a standard conditional jump, we can't parse it.  */
1073   jump = test_bb->end;
1074   cond = noce_get_condition (jump, &if_info.cond_earliest);
1075   if (! cond)
1076     return FALSE;
1077
1078   /* We must be comparing objects whose modes imply the size.  */
1079   if (GET_MODE (XEXP (cond, 0)) == BLKmode)
1080     return FALSE;
1081
1082   /* Look for one of the potential sets.  */
1083   insn_a = first_active_insn (then_bb);
1084   if (! insn_a
1085       || ! last_active_insn_p (then_bb, insn_a)
1086       || (set_a = single_set (insn_a)) == NULL_RTX)
1087     return FALSE;
1088
1089   x = SET_DEST (set_a);
1090   a = SET_SRC (set_a);
1091
1092   /* Look for the other potential set.  Make sure we've got equivalent
1093      destinations.  */
1094   /* ??? This is overconservative.  Storing to two different mems is
1095      as easy as conditionally computing the address.  Storing to a
1096      single mem merely requires a scratch memory to use as one of the
1097      destination addresses; often the memory immediately below the
1098      stack pointer is available for this.  */
1099   set_b = NULL_RTX;
1100   if (else_bb)
1101     {
1102       insn_b = first_active_insn (else_bb);
1103       if (! insn_b
1104           || ! last_active_insn_p (else_bb, insn_b)
1105           || (set_b = single_set (insn_b)) == NULL_RTX
1106           || ! rtx_equal_p (x, SET_DEST (set_b)))
1107         return FALSE;
1108     }
1109   else
1110     {
1111       insn_b = prev_nonnote_insn (if_info.cond_earliest);
1112       if (! insn_b
1113           || GET_CODE (insn_b) != INSN
1114           || (set_b = single_set (insn_b)) == NULL_RTX
1115           || ! rtx_equal_p (x, SET_DEST (set_b))
1116           || reg_mentioned_p (x, cond)
1117           || reg_mentioned_p (x, a)
1118           || reg_mentioned_p (x, SET_SRC (set_b)))
1119         insn_b = set_b = NULL_RTX;
1120     }
1121   b = (set_b ? SET_SRC (set_b) : x);
1122
1123   /* X may not be mentioned in the range (cond_earliest, jump].  */
1124   for (insn = jump; insn != if_info.cond_earliest; insn = PREV_INSN (insn))
1125     if (INSN_P (insn) && reg_mentioned_p (x, insn))
1126       return FALSE;
1127
1128   /* A and B may not be modified in the range [cond_earliest, jump).  */
1129   for (insn = if_info.cond_earliest; insn != jump; insn = NEXT_INSN (insn))
1130     if (INSN_P (insn)
1131         && (modified_in_p (a, insn) || modified_in_p (b, insn)))
1132       return FALSE;
1133
1134   /* Only operate on register destinations, and even then avoid extending
1135      the lifetime of hard registers on small register class machines.  */
1136   orig_x = x;
1137   if (GET_CODE (x) != REG
1138       || (SMALL_REGISTER_CLASSES
1139           && REGNO (x) < FIRST_PSEUDO_REGISTER))
1140     {
1141       if (no_new_pseudos)
1142         return FALSE;
1143       x = gen_reg_rtx (GET_MODE (x));
1144     }
1145
1146   /* Don't operate on sources that may trap or are volatile.  */
1147   if (side_effects_p (a) || side_effects_p (b)
1148       || (GET_CODE (a) != MEM && may_trap_p (a))
1149       || (GET_CODE (b) != MEM && may_trap_p (b)))
1150     return FALSE;
1151
1152   /* Set up the info block for our subroutines.  */
1153   if_info.cond = cond;
1154   if_info.jump = jump;
1155   if_info.insn_a = insn_a;
1156   if_info.insn_b = insn_b;
1157   if_info.x = x;
1158   if_info.a = a;
1159   if_info.b = b;
1160
1161   /* Try optimizations in some approximation of a useful order.  */
1162   /* ??? Should first look to see if X is live incoming at all.  If it
1163      isn't, we don't need anything but an unconditional set.  */
1164
1165   /* Look and see if A and B are really the same.  Avoid creating silly
1166      cmove constructs that no one will fix up later.  */
1167   if (rtx_equal_p (a, b))
1168     {
1169       /* If we have an INSN_B, we don't have to create any new rtl.  Just
1170          move the instruction that we already have.  If we don't have an
1171          INSN_B, that means that A == X, and we've got a noop move.  In
1172          that case don't do anything and let the code below delete INSN_A.  */
1173       if (insn_b && else_bb)
1174         {
1175           if (else_bb && insn_b == else_bb->end)
1176             else_bb->end = PREV_INSN (insn_b);
1177           reorder_insns (insn_b, insn_b, PREV_INSN (if_info.cond_earliest));
1178           insn_b = NULL_RTX;
1179         }
1180       x = orig_x;
1181       goto success;
1182     }
1183
1184   if (noce_try_store_flag (&if_info))
1185     goto success;
1186   if (HAVE_conditional_move
1187       && noce_try_cmove (&if_info))
1188     goto success;
1189   if (! HAVE_conditional_execution)
1190     {
1191       if (noce_try_store_flag_constants (&if_info))
1192         goto success;
1193       if (noce_try_store_flag_inc (&if_info))
1194         goto success;
1195       if (noce_try_store_flag_mask (&if_info))
1196         goto success;
1197       if (HAVE_conditional_move
1198           && noce_try_cmove_arith (&if_info))
1199         goto success;
1200     }
1201
1202   return FALSE;
1203
1204  success:
1205   /* The original sets may now be killed.  */
1206   if (insn_a == then_bb->end)
1207     then_bb->end = PREV_INSN (insn_a);
1208   flow_delete_insn (insn_a);
1209
1210   /* Several special cases here: First, we may have reused insn_b above,
1211      in which case insn_b is now NULL.  Second, we want to delete insn_b
1212      if it came from the ELSE block, because follows the now correct
1213      write that appears in the TEST block.  However, if we got insn_b from
1214      the TEST block, it may in fact be loading data needed for the comparison.
1215      We'll let life_analysis remove the insn if it's really dead.  */
1216   if (insn_b && else_bb)
1217     {
1218       if (insn_b == else_bb->end)
1219         else_bb->end = PREV_INSN (insn_b);
1220       flow_delete_insn (insn_b);
1221     }
1222
1223   /* The new insns will have been inserted before cond_earliest.  We should
1224      be able to remove the jump with impunity, but the condition itself may
1225      have been modified by gcse to be shared across basic blocks.  */
1226   test_bb->end = PREV_INSN (jump);
1227   flow_delete_insn (jump);
1228
1229   /* If we used a temporary, fix it up now.  */
1230   if (orig_x != x)
1231     {
1232       start_sequence ();
1233       emit_move_insn (orig_x, x);
1234       insn_b = gen_sequence ();
1235       end_sequence ();
1236
1237       test_bb->end = emit_insn_after (insn_b, test_bb->end);
1238     }
1239
1240   /* Merge the blocks!  */
1241   merge_if_block (test_bb, then_bb, else_bb, join_bb);
1242
1243   return TRUE;
1244 }
1245 \f
1246 /* Attempt to convert an IF-THEN or IF-THEN-ELSE block into
1247    straight line code.  Return true if successful.  */
1248
1249 static int
1250 process_if_block (test_bb, then_bb, else_bb, join_bb)
1251      basic_block test_bb;       /* Basic block test is in */
1252      basic_block then_bb;       /* Basic block for THEN block */
1253      basic_block else_bb;       /* Basic block for ELSE block */
1254      basic_block join_bb;       /* Basic block the join label is in */
1255 {
1256   if (! reload_completed
1257       && noce_process_if_block (test_bb, then_bb, else_bb, join_bb))
1258     return TRUE;
1259
1260   if (HAVE_conditional_execution
1261       && reload_completed
1262       && cond_exec_process_if_block (test_bb, then_bb, else_bb, join_bb))
1263     return TRUE;
1264
1265   return FALSE;
1266 }
1267
1268 /* Merge the blocks and mark for local life update.  */
1269
1270 static void
1271 merge_if_block (test_bb, then_bb, else_bb, join_bb)
1272      basic_block test_bb;       /* Basic block test is in */
1273      basic_block then_bb;       /* Basic block for THEN block */
1274      basic_block else_bb;       /* Basic block for ELSE block */
1275      basic_block join_bb;       /* Basic block the join label is in */
1276 {
1277   basic_block combo_bb;
1278
1279   /* All block merging is done into the lower block numbers.  */
1280
1281   combo_bb = test_bb;
1282
1283   /* First merge TEST block into THEN block.  This is a no-brainer since
1284      the THEN block did not have a code label to begin with.  */
1285
1286   if (combo_bb->global_live_at_end)
1287     COPY_REG_SET (combo_bb->global_live_at_end, then_bb->global_live_at_end);
1288   merge_blocks_nomove (combo_bb, then_bb);
1289   num_removed_blocks++;
1290
1291   /* The ELSE block, if it existed, had a label.  That label count
1292      will almost always be zero, but odd things can happen when labels
1293      get their addresses taken.  */
1294   if (else_bb)
1295     {
1296       merge_blocks_nomove (combo_bb, else_bb);
1297       num_removed_blocks++;
1298     }
1299
1300   /* If there was no join block reported, that means it was not adjacent
1301      to the others, and so we cannot merge them.  */
1302
1303   if (! join_bb)
1304     {
1305       /* The outgoing edge for the current COMBO block should already
1306          be correct.  Verify this.  */
1307       if (combo_bb->succ == NULL_EDGE)
1308         abort ();
1309
1310       /* There should sill be a branch at the end of the THEN or ELSE
1311          blocks taking us to our final destination.  */
1312       if (! simplejump_p (combo_bb->end)
1313           && ! returnjump_p (combo_bb->end))
1314         abort ();
1315     }
1316
1317   /* The JOIN block may have had quite a number of other predecessors too.
1318      Since we've already merged the TEST, THEN and ELSE blocks, we should
1319      have only one remaining edge from our if-then-else diamond.  If there
1320      is more than one remaining edge, it must come from elsewhere.  */
1321   else if (join_bb->pred->pred_next == NULL)
1322     {
1323       /* We can merge the JOIN.  */
1324       if (combo_bb->global_live_at_end)
1325         COPY_REG_SET (combo_bb->global_live_at_end,
1326                       join_bb->global_live_at_end);
1327       merge_blocks_nomove (combo_bb, join_bb);
1328       num_removed_blocks++;
1329     }
1330   else
1331     {
1332       /* We cannot merge the JOIN.  */
1333
1334       /* The outgoing edge for the current COMBO block should already
1335          be correct.  Verify this.  */
1336       if (combo_bb->succ->succ_next != NULL_EDGE
1337           || combo_bb->succ->dest != join_bb)
1338         abort ();
1339
1340       /* Remove the jump and cruft from the end of the COMBO block.  */
1341       tidy_fallthru_edge (combo_bb->succ, combo_bb, join_bb);
1342     }
1343
1344   /* Make sure we update life info properly.  */
1345   SET_UPDATE_LIFE (combo_bb);
1346
1347   num_updated_if_blocks++;
1348 }
1349 \f
1350 /* Find a block ending in a simple IF condition.  Return TRUE if
1351    we were able to transform it in some way.  */
1352
1353 static int
1354 find_if_header (test_bb)
1355      basic_block test_bb;
1356 {
1357   edge then_edge;
1358   edge else_edge;
1359
1360   /* The kind of block we're looking for has exactly two successors.  */
1361   if ((then_edge = test_bb->succ) == NULL_EDGE
1362       || (else_edge = then_edge->succ_next) == NULL_EDGE
1363       || else_edge->succ_next != NULL_EDGE)
1364     return FALSE;
1365
1366   /* Neither edge should be abnormal.  */
1367   if ((then_edge->flags & EDGE_COMPLEX)
1368       || (else_edge->flags & EDGE_COMPLEX))
1369     return FALSE;
1370
1371   /* The THEN edge is canonically the one that falls through.  */
1372   if (then_edge->flags & EDGE_FALLTHRU)
1373     ;
1374   else if (else_edge->flags & EDGE_FALLTHRU)
1375     {
1376       edge e = else_edge;
1377       else_edge = then_edge;
1378       then_edge = e;
1379     }
1380   else
1381     /* Otherwise this must be a multiway branch of some sort.  */
1382     return FALSE;
1383
1384   if (find_if_block (test_bb, then_edge, else_edge))
1385     goto success;
1386   if (post_dominators
1387       && (! HAVE_conditional_execution || reload_completed))
1388     {
1389       if (find_if_case_1 (test_bb, then_edge, else_edge))
1390         goto success;
1391       if (find_if_case_2 (test_bb, then_edge, else_edge))
1392         goto success;
1393     }
1394
1395   return FALSE;
1396
1397  success:
1398   if (rtl_dump_file)
1399     fprintf (rtl_dump_file, "Conversion succeeded.\n");
1400   return TRUE;
1401 }
1402
1403 /* Determine if a given basic block heads a simple IF-THEN or IF-THEN-ELSE
1404    block.  If so, we'll try to convert the insns to not require the branch.
1405    Return TRUE if we were successful at converting the the block.  */
1406
1407 static int
1408 find_if_block (test_bb, then_edge, else_edge)
1409       basic_block test_bb;
1410       edge then_edge, else_edge;
1411 {
1412   basic_block then_bb = then_edge->dest;
1413   basic_block else_bb = else_edge->dest;
1414   basic_block join_bb = NULL_BLOCK;
1415   edge then_succ = then_bb->succ;
1416   edge else_succ = else_bb->succ;
1417   int next_index;
1418
1419   /* The THEN block of an IF-THEN combo must have exactly one predecessor.  */
1420   if (then_bb->pred->pred_next != NULL_EDGE)
1421     return FALSE;
1422
1423   /* The THEN block of an IF-THEN combo must have exactly one successor.  */
1424   if (then_succ == NULL_EDGE
1425       || then_succ->succ_next != NULL_EDGE
1426       || (then_succ->flags & EDGE_COMPLEX))
1427     return FALSE;
1428
1429   /* If the THEN block's successor is the other edge out of the TEST block,
1430      then we have an IF-THEN combo without an ELSE.  */
1431   if (then_succ->dest == else_bb)
1432     {
1433       join_bb = else_bb;
1434       else_bb = NULL_BLOCK;
1435     }
1436
1437   /* If the THEN and ELSE block meet in a subsequent block, and the ELSE
1438      has exactly one predecessor and one successor, and the outgoing edge
1439      is not complex, then we have an IF-THEN-ELSE combo.  */
1440   else if (else_succ != NULL_EDGE
1441            && then_succ->dest == else_succ->dest
1442            && else_bb->pred->pred_next == NULL_EDGE
1443            && else_succ->succ_next == NULL_EDGE
1444            && ! (else_succ->flags & EDGE_COMPLEX))
1445     join_bb = else_succ->dest;
1446
1447   /* Otherwise it is not an IF-THEN or IF-THEN-ELSE combination.  */
1448   else
1449     return FALSE;          
1450
1451   num_possible_if_blocks++;
1452
1453   if (rtl_dump_file)
1454     {
1455       if (else_bb)
1456         fprintf (rtl_dump_file,
1457                  "\nIF-THEN-ELSE block found, start %d, then %d, else %d, join %d\n",
1458                  test_bb->index, then_bb->index, else_bb->index,
1459                  join_bb->index);
1460       else
1461         fprintf (rtl_dump_file,
1462                  "\nIF-THEN block found, start %d, then %d, join %d\n",
1463                  test_bb->index, then_bb->index, join_bb->index);
1464     }
1465
1466   /* Make sure IF, THEN, and ELSE, blocks are adjacent.  Actually, we
1467      get the first condition for free, since we've already asserted that
1468      there's a fallthru edge from IF to THEN.  */
1469   /* ??? As an enhancement, move the ELSE block.  Have to deal with EH and
1470      BLOCK notes, if by no other means than aborting the merge if they
1471      exist.  Sticky enough I don't want to think about it now.  */
1472   next_index = then_bb->index;
1473   if (else_bb && ++next_index != else_bb->index)
1474     return FALSE;
1475   if (++next_index != join_bb->index)
1476     {
1477       if (else_bb)
1478         join_bb = NULL;
1479       else
1480         return FALSE;
1481     }
1482
1483   /* Do the real work.  */
1484   return process_if_block (test_bb, then_bb, else_bb, join_bb);
1485 }
1486
1487 /* Look for IF-THEN-ELSE cases in which one of THEN or ELSE is
1488    transformable, but not necessarily the other.  There need be no
1489    JOIN block.
1490
1491    Return TRUE if we were successful at converting the the block.
1492
1493    Cases we'd like to look at:
1494
1495    (1)
1496         if (test) goto over; // x not live
1497         x = a;
1498         goto label;
1499         over:
1500
1501    becomes
1502
1503         x = a;
1504         if (! test) goto label;
1505
1506    (2)
1507         if (test) goto E; // x not live
1508         x = big();
1509         goto L;
1510         E:
1511         x = b;
1512         goto M;
1513
1514    becomes
1515
1516         x = b;
1517         if (test) goto M;
1518         x = big();
1519         goto L;
1520
1521    (3) // This one's really only interesting for targets that can do
1522        // multiway branching, e.g. IA-64 BBB bundles.  For other targets
1523        // it results in multiple branches on a cache line, which often
1524        // does not sit well with predictors.
1525
1526         if (test1) goto E; // predicted not taken
1527         x = a;
1528         if (test2) goto F;
1529         ...
1530         E:
1531         x = b;
1532         J:
1533
1534    becomes
1535
1536         x = a;
1537         if (test1) goto E;
1538         if (test2) goto F;
1539
1540    Notes:
1541
1542    (A) Don't do (2) if the branch is predicted against the block we're
1543    eliminating.  Do it anyway if we can eliminate a branch; this requires
1544    that the sole successor of the eliminated block postdominate the other
1545    side of the if.
1546
1547    (B) With CE, on (3) we can steal from both sides of the if, creating
1548
1549         if (test1) x = a;
1550         if (!test1) x = b;
1551         if (test1) goto J;
1552         if (test2) goto F;
1553         ...
1554         J:
1555
1556    Again, this is most useful if J postdominates.
1557
1558    (C) CE substitutes for helpful life information.
1559
1560    (D) These heuristics need a lot of work.  */
1561
1562 /* Tests for case 1 above.  */
1563
1564 static int
1565 find_if_case_1 (test_bb, then_edge, else_edge)
1566       basic_block test_bb;
1567       edge then_edge, else_edge;
1568 {
1569   basic_block then_bb = then_edge->dest;
1570   basic_block else_bb = else_edge->dest;
1571   edge then_succ = then_bb->succ;
1572   rtx new_lab;
1573
1574   /* THEN has one successor.  */
1575   if (!then_succ || then_succ->succ_next != NULL)
1576     return FALSE;
1577
1578   /* THEN does not fall through, but is not strange either.  */
1579   if (then_succ->flags & (EDGE_COMPLEX | EDGE_FALLTHRU))
1580     return FALSE;
1581
1582   /* THEN has one predecessor.  */
1583   if (then_bb->pred->pred_next != NULL)
1584     return FALSE;
1585
1586   /* ELSE follows THEN.  (??? could be moved)  */
1587   if (else_bb->index != then_bb->index + 1)
1588     return FALSE;
1589
1590   num_possible_if_blocks++;
1591   if (rtl_dump_file)
1592     fprintf (rtl_dump_file,
1593              "\nIF-CASE-1 found, start %d, then %d\n",
1594              test_bb->index, then_bb->index);
1595
1596   /* THEN is small.  */
1597   if (count_bb_insns (then_bb) > BRANCH_COST)
1598     return FALSE;
1599
1600   /* Find the label for THEN's destination.  */
1601   if (then_succ->dest == EXIT_BLOCK_PTR)
1602     new_lab = NULL_RTX;
1603   else
1604     {
1605       new_lab = JUMP_LABEL (then_bb->end);
1606       if (! new_lab)
1607         abort ();
1608     }
1609
1610   /* Registers set are dead, or are predicable.  */
1611   if (! dead_or_predicable (test_bb, then_bb, else_bb, new_lab, 1))
1612     return FALSE;
1613
1614   /* Conversion went ok, including moving the insns and fixing up the
1615      jump.  Adjust the CFG to match.  */
1616
1617   SET_UPDATE_LIFE (test_bb);
1618   bitmap_operation (test_bb->global_live_at_end,
1619                     else_bb->global_live_at_start,
1620                     then_bb->global_live_at_end, BITMAP_IOR);
1621   
1622   make_edge (NULL, test_bb, then_succ->dest, 0);
1623   flow_delete_block (then_bb);
1624   tidy_fallthru_edge (else_edge, test_bb, else_bb);
1625
1626   num_removed_blocks++;
1627   num_updated_if_blocks++;
1628
1629   return TRUE;
1630 }
1631
1632 /* Test for case 2 above.  */
1633
1634 static int
1635 find_if_case_2 (test_bb, then_edge, else_edge)
1636       basic_block test_bb;
1637       edge then_edge, else_edge;
1638 {
1639   basic_block then_bb = then_edge->dest;
1640   basic_block else_bb = else_edge->dest;
1641   edge else_succ = else_bb->succ;
1642   rtx new_lab, note;
1643
1644   /* ELSE has one successor.  */
1645   if (!else_succ || else_succ->succ_next != NULL)
1646     return FALSE;
1647
1648   /* ELSE outgoing edge is not complex.  */
1649   if (else_succ->flags & EDGE_COMPLEX)
1650     return FALSE;
1651
1652   /* ELSE has one predecessor.  */
1653   if (else_bb->pred->pred_next != NULL)
1654     return FALSE;
1655
1656   /* THEN is not EXIT.  */
1657   if (then_bb->index < 0)
1658     return FALSE;
1659
1660   /* ELSE is predicted or SUCC(ELSE) postdominates THEN.  */
1661   note = find_reg_note (test_bb->end, REG_BR_PROB, NULL_RTX);
1662   if (note && INTVAL (XEXP (note, 0)) >= REG_BR_PROB_BASE / 2)
1663     ;
1664   else if (else_succ->dest->index < 0
1665            || TEST_BIT (post_dominators[ORIG_INDEX (then_bb)], 
1666                         ORIG_INDEX (else_succ->dest)))
1667     ;
1668   else
1669     return FALSE;
1670
1671   num_possible_if_blocks++;
1672   if (rtl_dump_file)
1673     fprintf (rtl_dump_file,
1674              "\nIF-CASE-2 found, start %d, else %d\n",
1675              test_bb->index, else_bb->index);
1676
1677   /* ELSE is small.  */
1678   if (count_bb_insns (then_bb) > BRANCH_COST)
1679     return FALSE;
1680
1681   /* Find the label for ELSE's destination.  */
1682   if (else_succ->dest == EXIT_BLOCK_PTR)
1683     new_lab = NULL_RTX;
1684   else
1685     {
1686       if (else_succ->flags & EDGE_FALLTHRU)
1687         {
1688           new_lab = else_succ->dest->head;
1689           if (GET_CODE (new_lab) != CODE_LABEL)
1690             abort ();
1691         }
1692       else
1693         {
1694           new_lab = JUMP_LABEL (else_bb->end);
1695           if (! new_lab)
1696             abort ();
1697         }
1698     }
1699
1700   /* Registers set are dead, or are predicable.  */
1701   if (! dead_or_predicable (test_bb, else_bb, then_bb, new_lab, 0))
1702     return FALSE;
1703
1704   /* Conversion went ok, including moving the insns and fixing up the
1705      jump.  Adjust the CFG to match.  */
1706
1707   SET_UPDATE_LIFE (test_bb);
1708   bitmap_operation (test_bb->global_live_at_end,
1709                     then_bb->global_live_at_start,
1710                     else_bb->global_live_at_end, BITMAP_IOR);
1711   
1712   remove_edge (else_edge);
1713   make_edge (NULL, test_bb, else_succ->dest, 0);
1714   flow_delete_block (else_bb);
1715
1716   num_removed_blocks++;
1717   num_updated_if_blocks++;
1718
1719   /* ??? We may now fallthru from one of THEN's successors into a join
1720      block.  Rerun cleanup_cfg?  Examine things manually?  Wait?  */
1721
1722   return TRUE;
1723 }
1724
1725 /* A subroutine of dead_or_predicable called through for_each_rtx.
1726    Return 1 if a memory is found.  */
1727
1728 static int
1729 find_memory (px, data)
1730      rtx *px;
1731      void *data ATTRIBUTE_UNUSED;
1732 {
1733   return GET_CODE (*px) == MEM;
1734 }
1735
1736 /* Used by the code above to perform the actual rtl transformations.
1737    Return TRUE if successful.
1738
1739    TEST_BB is the block containing the conditional branch.  MERGE_BB
1740    is the block containing the code to manipulate.  NEW_DEST is the
1741    label TEST_BB should be branching to after the conversion.
1742    REVERSEP is true if the sense of the branch should be reversed.  */
1743
1744 static int
1745 dead_or_predicable (test_bb, merge_bb, other_bb, new_dest, reversep)
1746      basic_block test_bb, merge_bb, other_bb;
1747      rtx new_dest;
1748      int reversep;
1749 {
1750   rtx head, end, jump, earliest, old_dest;
1751
1752   jump = test_bb->end;
1753
1754   /* Find the extent of the real code in the merge block.  */
1755   head = merge_bb->head;
1756   end = merge_bb->end;
1757
1758   if (GET_CODE (head) == CODE_LABEL)
1759     head = NEXT_INSN (head);
1760   if (GET_CODE (head) == NOTE)
1761     {
1762       if (head == end)
1763         {
1764           head = end = NULL_RTX;
1765           goto no_body;
1766         }
1767       head = NEXT_INSN (head);
1768     }
1769
1770   if (GET_CODE (end) == JUMP_INSN)
1771     {
1772       if (head == end)
1773         {
1774           head = end = NULL_RTX;
1775           goto no_body;
1776         }
1777       end = PREV_INSN (end);
1778     }
1779
1780   if (HAVE_conditional_execution)
1781     {
1782       /* In the conditional execution case, we have things easy.  We know
1783          the condition is reversable.  We don't have to check life info,
1784          becase we're going to conditionally execute the code anyway.
1785          All that's left is making sure the insns involved can actually
1786          be predicated.  */
1787
1788       rtx cond, prob_val;
1789
1790       cond = cond_exec_get_condition (jump);
1791
1792       prob_val = find_reg_note (jump, REG_BR_PROB, NULL_RTX);
1793       if (prob_val)
1794         prob_val = XEXP (prob_val, 0);
1795
1796       if (reversep)
1797         {
1798           cond = gen_rtx_fmt_ee (reverse_condition (GET_CODE (cond)),
1799                                  GET_MODE (cond), XEXP (cond, 0),
1800                                  XEXP (cond, 1));
1801           if (prob_val)
1802             prob_val = GEN_INT (REG_BR_PROB_BASE - INTVAL (prob_val));
1803         }
1804
1805       if (! cond_exec_process_insns (head, end, cond, prob_val, 0))
1806         goto cancel;
1807
1808       earliest = jump;
1809     }
1810   else
1811     {
1812       /* In the non-conditional execution case, we have to verify that there
1813          are no trapping operations, no calls, no references to memory, and
1814          that any registers modified are dead at the branch site.  */
1815
1816       rtx insn, cond, prev;
1817       regset_head merge_set_head, tmp_head, test_live_head, test_set_head;
1818       regset merge_set, tmp, test_live, test_set;
1819       struct propagate_block_info *pbi;
1820       int i, fail = 0;
1821
1822       /* Check for no calls or trapping operations.  */
1823       for (insn = head; ; insn = NEXT_INSN (insn))
1824         {
1825           if (GET_CODE (insn) == CALL_INSN)
1826             return FALSE;
1827           if (INSN_P (insn))
1828             {
1829               if (may_trap_p (PATTERN (insn)))
1830                 return FALSE;
1831
1832               /* ??? Even non-trapping memories such as stack frame
1833                  references must be avoided.  For stores, we collect
1834                  no lifetime info; for reads, we'd have to assert
1835                  true_dependance false against every store in the
1836                  TEST range.  */
1837               if (for_each_rtx (&PATTERN (insn), find_memory, NULL))
1838                 return FALSE;
1839             }
1840           if (insn == end)
1841             break;
1842         }
1843
1844       if (! any_condjump_p (jump))
1845         return FALSE;
1846
1847       /* Find the extent of the conditional.  */
1848       cond = noce_get_condition (jump, &earliest);
1849       if (! cond)
1850         return FALSE;
1851
1852       /* Collect:
1853            MERGE_SET = set of registers set in MERGE_BB
1854            TEST_LIVE = set of registers live at EARLIEST
1855            TEST_SET  = set of registers set between EARLIEST and the
1856                        end of the block.  */
1857
1858       tmp = INITIALIZE_REG_SET (tmp_head);
1859       merge_set = INITIALIZE_REG_SET (merge_set_head);
1860       test_live = INITIALIZE_REG_SET (test_live_head);
1861       test_set = INITIALIZE_REG_SET (test_set_head);
1862
1863       /* ??? bb->local_set is only valid during calculate_global_regs_live,
1864          so we must recompute usage for MERGE_BB.  Not so bad, I suppose, 
1865          since we've already asserted that MERGE_BB is small.  */
1866       propagate_block (merge_bb, tmp, merge_set, 0);
1867
1868       /* For small register class machines, don't lengthen lifetimes of
1869          hard registers before reload.  */
1870       if (SMALL_REGISTER_CLASSES && ! reload_completed)
1871         {
1872           EXECUTE_IF_SET_IN_BITMAP
1873             (merge_set, 0, i,
1874              {
1875                if (i < FIRST_PSEUDO_REGISTER
1876                    && ! fixed_regs[i]
1877                    && ! global_regs[i])
1878                 fail = 1;
1879              });
1880         }
1881
1882       /* For TEST, we're interested in a range of insns, not a whole block.
1883          Moreover, we're interested in the insns live from OTHER_BB.  */
1884
1885       COPY_REG_SET (test_live, other_bb->global_live_at_start);
1886       pbi = init_propagate_block_info (test_bb, test_live, test_set, 0);
1887
1888       for (insn = jump; ; insn = prev)
1889         {
1890           prev = propagate_one_insn (pbi, insn);
1891           if (insn == earliest)
1892             break;
1893         }
1894
1895       free_propagate_block_info (pbi);
1896
1897       /* We can perform the transformation if
1898            MERGE_SET & (TEST_SET | TEST_LIVE)
1899          and
1900            TEST_SET & merge_bb->global_live_at_start
1901          are empty.  */
1902
1903       bitmap_operation (tmp, test_set, test_live, BITMAP_IOR);
1904       bitmap_operation (tmp, tmp, merge_set, BITMAP_AND);
1905       EXECUTE_IF_SET_IN_BITMAP(tmp, 0, i, fail = 1);
1906
1907       bitmap_operation (tmp, test_set, merge_bb->global_live_at_start,
1908                         BITMAP_AND);
1909       EXECUTE_IF_SET_IN_BITMAP(tmp, 0, i, fail = 1);
1910
1911       FREE_REG_SET (tmp);
1912       FREE_REG_SET (merge_set);
1913       FREE_REG_SET (test_live);
1914       FREE_REG_SET (test_set);
1915
1916       if (fail)
1917         return FALSE;
1918     }
1919
1920  no_body:
1921   /* We don't want to use normal invert_jump or redirect_jump because
1922      we don't want to delete_insn called.  Also, we want to do our own
1923      change group management.  */
1924
1925   old_dest = JUMP_LABEL (jump);
1926   if (reversep
1927       ? ! invert_jump_1 (jump, new_dest)
1928       : ! redirect_jump_1 (jump, new_dest))
1929     goto cancel;
1930
1931   if (! apply_change_group ())
1932     return FALSE;
1933
1934   if (old_dest)
1935     LABEL_NUSES (old_dest) -= 1;
1936   if (new_dest)
1937     LABEL_NUSES (new_dest) += 1;
1938   JUMP_LABEL (jump) = new_dest;
1939
1940   if (reversep)
1941     {
1942       rtx note = find_reg_note (jump, REG_BR_PROB, NULL_RTX);
1943       if (note)
1944         XEXP (note, 0) = GEN_INT (REG_BR_PROB_BASE - INTVAL (XEXP (note, 0)));
1945     }
1946
1947   /* Move the insns out of MERGE_BB to before the branch.  */
1948   if (head != NULL)
1949     {
1950       if (end == merge_bb->end)
1951         merge_bb->end = PREV_INSN (head);
1952
1953       head = squeeze_notes (head, end);
1954       if (GET_CODE (end) == NOTE
1955           && (NOTE_LINE_NUMBER (end) == NOTE_INSN_BLOCK_END
1956               || NOTE_LINE_NUMBER (end) == NOTE_INSN_BLOCK_BEG
1957               || NOTE_LINE_NUMBER (end) == NOTE_INSN_LOOP_BEG
1958               || NOTE_LINE_NUMBER (end) == NOTE_INSN_LOOP_END
1959               || NOTE_LINE_NUMBER (end) == NOTE_INSN_LOOP_CONT
1960               || NOTE_LINE_NUMBER (end) == NOTE_INSN_LOOP_VTOP))
1961         {
1962           if (head == end)
1963             return TRUE;
1964           end = PREV_INSN (end);
1965         }
1966
1967       reorder_insns (head, end, PREV_INSN (earliest));
1968     }
1969   return TRUE;
1970
1971  cancel:
1972   cancel_changes (0);
1973   return FALSE;
1974 }
1975 \f
1976 /* Main entry point for all if-conversion.  */
1977
1978 void
1979 if_convert (life_data_ok)
1980      int life_data_ok;
1981 {
1982   int block_num;
1983
1984   num_possible_if_blocks = 0;
1985   num_updated_if_blocks = 0;
1986   num_removed_blocks = 0;
1987
1988   /* Free up basic_block_for_insn so that we don't have to keep it 
1989      up to date, either here or in merge_blocks_nomove.  */
1990   free_basic_block_vars (1);
1991
1992   /* Compute postdominators if we think we'll use them.  */
1993   post_dominators = NULL;
1994   if (HAVE_conditional_execution || life_data_ok)
1995     {
1996       post_dominators = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
1997       compute_flow_dominators (NULL, post_dominators);
1998     }
1999
2000   /* Record initial block numbers.  */
2001   for (block_num = 0; block_num < n_basic_blocks; block_num++)
2002     SET_ORIG_INDEX (BASIC_BLOCK (block_num), block_num);
2003
2004   /* Go through each of the basic blocks looking for things to convert.  */
2005   for (block_num = 0; block_num < n_basic_blocks; )
2006     {
2007       basic_block bb = BASIC_BLOCK (block_num);
2008       if (find_if_header (bb))
2009         block_num = bb->index;
2010       else 
2011         block_num++;
2012     }
2013
2014   if (post_dominators)
2015     sbitmap_vector_free (post_dominators);
2016
2017   if (rtl_dump_file)
2018     fflush (rtl_dump_file);
2019
2020   /* Rebuild basic_block_for_insn for update_life_info and for gcse.  */
2021   compute_bb_for_insn (get_max_uid ());
2022
2023   /* Rebuild life info for basic blocks that require it.  */
2024   if (num_removed_blocks && life_data_ok)
2025     {
2026       sbitmap update_life_blocks = sbitmap_alloc (n_basic_blocks);
2027       sbitmap_zero (update_life_blocks);
2028
2029       /* If we allocated new pseudos, we must resize the array for sched1.  */
2030       if (max_regno < max_reg_num ())
2031         {
2032           max_regno = max_reg_num ();
2033           allocate_reg_info (max_regno, FALSE, FALSE);
2034         }
2035
2036       for (block_num = 0; block_num < n_basic_blocks; block_num++)
2037         if (UPDATE_LIFE (BASIC_BLOCK (block_num)))
2038           SET_BIT (update_life_blocks, block_num);
2039
2040       count_or_remove_death_notes (update_life_blocks, 1);
2041       /* ??? See about adding a mode that verifies that the initial
2042         set of blocks don't let registers come live.  */
2043       update_life_info (update_life_blocks, UPDATE_LIFE_GLOBAL,
2044                         PROP_DEATH_NOTES | PROP_SCAN_DEAD_CODE
2045                         | PROP_KILL_DEAD_CODE);
2046
2047       sbitmap_free (update_life_blocks);
2048     }
2049
2050   /* Write the final stats.  */
2051   if (rtl_dump_file && num_possible_if_blocks > 0)
2052     {
2053       fprintf (rtl_dump_file,
2054                "\n%d possible IF blocks searched.\n",
2055                num_possible_if_blocks);
2056       fprintf (rtl_dump_file,
2057                "%d IF blocks converted.\n",
2058                num_updated_if_blocks);
2059       fprintf (rtl_dump_file,
2060                "%d basic blocks deleted.\n\n\n",
2061                num_removed_blocks);
2062     }
2063
2064 #ifdef ENABLE_CHECKING
2065   verify_flow_info ();
2066 #endif
2067 }