Lines Matching +full:test2 +full:. +full:zeros

1 /* If-conversion support.
4 Free Software Foundation, Inc.
6 This file is part of GCC.
11 any later version.
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
27 #include "rtl.h"
28 #include "regs.h"
29 #include "function.h"
30 #include "flags.h"
31 #include "insn-config.h"
32 #include "recog.h"
33 #include "except.h"
34 #include "hard-reg-set.h"
35 #include "basic-block.h"
36 #include "expr.h"
37 #include "output.h"
38 #include "optabs.h"
39 #include "diagnostic-core.h"
40 #include "tm_p.h"
41 #include "cfgloop.h"
42 #include "target.h"
43 #include "timevar.h"
44 #include "tree-pass.h"
45 #include "df.h"
46 #include "vec.h"
47 #include "pointer-set.h"
48 #include "vecprim.h"
49 #include "dbgcnt.h"
78 execution. */
81 /* # of changes made. */
84 /* Whether conditional execution changes were made. */
87 /* Forward references. */
112 /* Count the number of non-jump active insns in BB. */
134 basic block BB is less than MAX_COST. This function returns
135 false if the cost of any instruction could not be estimated.
138 as those insns are being speculated. MAX_COST is scaled with SCALE
139 plus a small fudge factor. */
150 secondary benefits. So we fudge the scale factor to make speculating in cheap_bb_rtx_cost_p()
151 appear a little more profitable. */ in cheap_bb_rtx_cost_p()
167 register stack. Unfortunately, correctly recognizing and in cheap_bb_rtx_cost_p()
169 now we simply prohibit such speculative execution. */ in cheap_bb_rtx_cost_p()
193 /* Return the first non-jump active insn in the basic block. */
220 /* Return the last non-jump active (non-jump) insn in the basic block. */
246 /* Return the active insn before INSN inside basic block CURR_BB. */
259 /* No other active insn all the way to the start of the basic block. */ in find_active_insn_before()
267 /* Return the active insn after INSN inside basic block CURR_BB. */
280 /* No other active insn all the way to the end of the basic block. */ in find_active_insn_after()
288 /* Return the basic block reached by falling though the basic block BB. */
299 execution format if possible. Return TRUE if all of the non-note
300 insns were processed. */
308 /* probability of branch taken. */int mod_ok) in cond_exec_process_insns()
320 /* dwarf2out can't cope with conditional prologues. */ in cond_exec_process_insns()
329 /* Remove USE insns that get in the way. */ in cond_exec_process_insns()
332 /* ??? Ug. Actually unlinking the thing is problematic, in cond_exec_process_insns()
333 given what we'd have to coordinate with our callers. */ in cond_exec_process_insns()
349 /* Now build the conditional form of the instruction. */ in cond_exec_process_insns()
354 two conditions. */ in cond_exec_process_insns()
369 register, do so here. */ in cond_exec_process_insns()
391 /* Return the condition for a jump. Do not do any special processing. */
405 reverse the condition. */ in cond_exec_get_condition()
421 to conditional execution. Return TRUE if we were successful at
422 converting the block. */
436 int max; /* max # of insns to convert. */ in cond_exec_process_if_block()
451 && elements without an ELSE block. */ in cond_exec_process_if_block()
464 the test. */ in cond_exec_process_if_block()
470 then we can not do conditional execution conversion on this block. */ in cond_exec_process_if_block()
475 and notes at the beginning and end of the block. Then count the total in cond_exec_process_if_block()
476 number of insns and see if it is small enough to convert. */ in cond_exec_process_if_block()
494 and limit the range of insns to be converted if possible. */ in cond_exec_process_if_block()
528 to make sure that they don't clobber the condition. */ in cond_exec_process_if_block()
558 the conditionally executed code. */ in cond_exec_process_if_block()
571 conditional execution register from a comparison, it can do so here. */ in cond_exec_process_if_block()
574 /* See if the conversion failed. */ in cond_exec_process_if_block()
588 /* If we have && or || tests, do them here. These tests are in the adjacent in cond_exec_process_if_block()
589 blocks after the first block containing the test. */ in cond_exec_process_if_block()
613 we can not do conditional execution conversion on this block. */ in cond_exec_process_if_block()
617 /* Find the conditional jump and isolate the test. */ in cond_exec_process_if_block()
640 do so here. */ in cond_exec_process_if_block()
644 /* See if the conversion failed. */ in cond_exec_process_if_block()
656 on then THEN block. */ in cond_exec_process_if_block()
660 to conditional execution. */ in cond_exec_process_if_block()
674 /* If we cannot apply the changes, fail. Do not go through the normal fail in cond_exec_process_if_block()
675 processing, since apply_change_group will call cancel_changes. */ in cond_exec_process_if_block()
679 /* Cancel any machine dependent changes. */ in cond_exec_process_if_block()
686 /* Do any machine dependent final modifications. */ in cond_exec_process_if_block()
690 /* Conversion succeeded. */ in cond_exec_process_if_block()
692 fprintf (dump_file, "%d insn%s converted to conditional execution.\n", in cond_exec_process_if_block()
699 that the remaining one is executed first for both branches. */ in cond_exec_process_if_block()
716 /* Cancel any machine dependent changes. */ in cond_exec_process_if_block()
724 /* Used by noce_process_if_block to communicate with its subroutines.
726 The subroutines know that A and B may be evaluated freely. They
727 know that X is a register. They should insert new instructions
728 before cond_earliest. */
732 /* The basic blocks that make up the IF-THEN-{ELSE-,}JOIN block. */
735 /* The jump that ends TEST_BB. */
738 /* The jump condition. */
741 /* New insns should be inserted before this one. */
744 /* Insns in the THEN and ELSE block. There is always just this
745 one insns in those blocks. The insns are single_set insns.
747 COND_EARLIEST, or NULL_RTX. In the former case, the insn
749 the jump. */
752 /* The SET_SRC of INSN_A and INSN_B. */
755 /* The SET_DEST of INSN_A. */
758 /* True if this if block is not canonical. In the canonical form of
760 from TEST_BB. For the noce transformations, we allow the symmetric
761 form as well. */
764 /* Estimated cost of the particular branch instruction. */
783 /* Helper function for noce_try_store_flag*. */
797 build the store_flag insn directly. */ in noce_emit_store_flag()
841 /* Don't even try if the comparison operands or the mode of X are weird. */ in noce_emit_store_flag()
851 /* Emit instruction to move an rtx, possibly into STRICT_LOW_PART.
852 X is the destination/target and Y is the value to copy. */
868 otherwise construct a suitable SET pattern ourselves. */ in noce_emit_move_insn()
885 BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN. In order to be able to in noce_emit_move_insn()
887 value from the first call. */ in noce_emit_move_insn()
958 /* Return sequence of instructions generated by if conversion. This
960 that are instructions are unshared, recognizable non-jump insns.
961 On failure, this function returns a NULL_RTX. */
975 and that we haven't introduced a new jump instruction. in end_ifcvt_sequence()
977 allows proper placement of required clobbers. */ in end_ifcvt_sequence()
987 "if (a == b) x = a; else x = b" into "x = b". */
1000 or a signed zero. */ in noce_try_move()
1006 either order. */ in noce_try_move()
1014 /* Avoid generating the move if the source is the destination. */ in noce_try_move()
1031 /* Convert "if (test) x = 1; else x = 0".
1033 Only try 0 and STORE_FLAG_VALUE here. Other combinations will be
1035 a go at the conversion. */
1079 /* Convert "if (test) x = a; else x = b", for A and B constant. */
1097 /* Make sure we can represent the difference between the two values. */ in noce_try_store_flag_constants()
1208 similarly for "foo--". */
1224 /* First try to use addcc pattern. */ in noce_try_addcc()
1255 setcc. */ in noce_try_addcc()
1347 /* Helper function for noce_try_cmove and noce_try_cmove_arith. */
1356 /* If earliest == jump, try to build the cmove insn directly. in noce_emit_cmove()
1359 through the normal interface. */ in noce_emit_cmove()
1384 /* Don't even try if the comparison operands are weird. */ in noce_emit_cmove()
1407 the result. in noce_emit_cmove()
1409 If we can't create new pseudos, though, don't bother. */ in noce_emit_cmove()
1434 /* Nope, couldn't do it in that mode either. */ in noce_emit_cmove()
1448 functions involved. Ifdef code, however, should be discouraged in noce_emit_cmove()
1449 because it leads to typos in the code not selected. However, in noce_emit_cmove()
1450 emit_conditional_move won't exist either. */ in noce_emit_cmove()
1455 /* Try only simple constants and registers here. More complex cases
1457 has had a go at it. */
1499 /* Try more complex cases involving conditional_move. */
1515 conditional on their addresses followed by a load. Don't do this in noce_try_cmove_arith()
1516 early because it'll screw alias analysis. Note that we've in noce_try_cmove_arith()
1517 already checked for no side effects. */ in noce_try_cmove_arith()
1518 /* ??? FIXME: Magic number 5. */ in noce_try_cmove_arith()
1525 = targetm.addr_space.address_mode (MEM_ADDR_SPACE (a)); in noce_try_cmove_arith()
1534 not trap or fault. This is also true if we've already loaded in noce_try_cmove_arith()
1535 from the address along the path from ENTRY. */ in noce_try_cmove_arith()
1550 /* Total insn_rtx_cost should be smaller than branch cost. Exit in noce_try_cmove_arith()
1551 if insn_rtx_cost can't be estimated. */ in noce_try_cmove_arith()
1572 /* Possibly rearrange operands to make things come out more natural. */ in noce_try_cmove_arith()
1594 /* If either operand is complex, load it into a register first. in noce_try_cmove_arith()
1595 The best way to do this is to copy the original insn. In this in noce_try_cmove_arith()
1596 way we preserve any clobbers etc that the insn may have had. in noce_try_cmove_arith()
1597 This is of course not possible in the IS_MEM case. */ in noce_try_cmove_arith()
1641 swap insn that sets up A with the one that sets up B. If even in noce_try_cmove_arith()
1642 that doesn't help, punt. */ in noce_try_cmove_arith()
1663 /* If we're handling a memory for above, emit the load now. */ in noce_try_cmove_arith()
1668 /* Copy over flags as appropriate. */ in noce_try_cmove_arith()
1697 choice, but this is not the case for the min/max/abs transforms.
1698 For these we wish to know that it is A or B in the condition. */
1707 /* If target is already mentioned in the known condition, return it. */ in noce_get_alt_condition()
1723 have that constant in it. There are two reasons why it may in noce_get_alt_condition()
1726 1. GCC may have needed to put the constant in a register, because in noce_get_alt_condition()
1727 the target can't compare directly against that constant. For in noce_get_alt_condition()
1729 that puts a constant in that register. in noce_get_alt_condition()
1731 2. GCC may have canonicalized the conditional, for example in noce_get_alt_condition()
1732 replacing "if x < 4" with "if x <= 3". We can undo that (or in noce_get_alt_condition()
1734 if they're off by one in the right direction. */ in noce_get_alt_condition()
1743 /* First, look to see if we put a constant in a register. */ in noce_get_alt_condition()
1772 adjusting the conditional. */ in noce_get_alt_condition()
1815 constants in it. */ in noce_get_alt_condition()
1831 /* We almost certainly searched back to a different place. in noce_get_alt_condition()
1832 Need to re-verify correct lifetimes. */ in noce_get_alt_condition()
1834 /* X may not be mentioned in the range (cond_earliest, jump]. */ in noce_get_alt_condition()
1839 /* A and B may not be modified in the range [cond_earliest, jump). */ in noce_get_alt_condition()
1849 /* Convert "if (a < b) x = a; else x = b;" to "x = min(a, b);", etc. */
1858 /* ??? Reject modes with NaNs or signed zeros since we don't know how in noce_try_minmax()
1859 they will be resolved with an SMIN/SMAX. It wouldn't be too hard in noce_try_minmax()
1860 to get the target to tell us... */ in noce_try_minmax()
1870 the comparison code. */ in noce_try_minmax()
1886 /* Determine what sort of operation this is. Note that the code is for in noce_try_minmax()
1887 a taken branch, so the code->operation mapping appears backwards. */ in noce_try_minmax()
1944 etc. */
1953 /* Reject modes with signed zeros. */ in noce_try_abs()
1957 /* Recognize A and B as constituting an ABS or NABS. The canonical in noce_try_abs()
1959 first operand of a comparison against 0 that evaluates to true. */ in noce_try_abs()
1987 /* Verify the condition is of the form we expect. */ in noce_try_abs()
1998 /* Verify that C is zero. Search one step backward for a in noce_try_abs()
1999 REG_EQUAL note or a simple source if necessary. */ in noce_try_abs()
2022 /* Work around funny ideas get_condition has wrt canonicalization. in noce_try_abs()
2024 therefore imply integer comparisons. */ in noce_try_abs()
2032 /* Determine what sort of operation this is. */ in noce_try_abs()
2058 for integers. Perhaps combine will clean things up. */ in noce_try_abs()
2089 /* Convert "if (m < 0) x = b; else x = 0;" to "x = (m >> C) & b;". */
2121 /* We currently don't handle different modes. */ in noce_try_sign_mask()
2127 original insn sequence or T is cheap. The former happens if B is the in noce_try_sign_mask()
2129 INSN_B which can happen for e.g. conditional stores to memory. For the in noce_try_sign_mask()
2131 after the transformation. */ in noce_try_sign_mask()
2143 "(signed) m >> 31" directly. This benefits targets with specialized in noce_try_sign_mask()
2144 insns to obtain the signmask, but still uses ashr_optab otherwise. */ in noce_try_sign_mask()
2167 transformations. */
2181 /* Check for no else condition. */ in noce_try_bitop()
2185 /* Check for a suitable condition. */ in noce_try_bitop()
2192 /* ??? We could also handle AND here. */ in noce_try_bitop()
2212 /* Check for "if (X & C) x = x op C". */ in noce_try_bitop()
2219 /* if ((x & C) == 0) x |= C; is transformed to x |= C. */ in noce_try_bitop()
2220 /* if ((x & C) != 0) x |= C; is transformed to nothing. */ in noce_try_bitop()
2225 /* if ((x & C) == 0) x ^= C; is transformed to x |= C. */ in noce_try_bitop()
2231 /* if ((x & C) != 0) x ^= C; is transformed to x &= ~C. */ in noce_try_bitop()
2238 /* Check for "if (X & C) x &= ~C". */ in noce_try_bitop()
2245 /* if ((x & C) == 0) x &= ~C; is transformed to nothing. */ in noce_try_bitop()
2246 /* if ((x & C) != 0) x &= ~C; is transformed to x &= ~C. */ in noce_try_bitop()
2268 valid at JUMP, instead of at EARLIEST.
2271 THEN block of the caller, and we have to reverse the condition. */
2285 reverse the condition. */ in noce_get_condition()
2290 i.e. the THEN block isn't the fallthrough block for the TEST block in noce_get_condition()
2291 (see find_if_header). */ in noce_get_condition()
2295 /* If the condition variable is a register and is MODE_INT, accept it. */ in noce_get_condition()
2301 || !targetm.small_register_classes_for_mode_p (BImode))) in noce_get_condition()
2312 work of manipulating MODE_CC values and COMPARE rtx codes. */ in noce_get_condition()
2317 REG_INC notes and making sure no duplicate conditions are emitted. */ in noce_get_condition()
2324 /* Return true if OP is ok for if-then-else processing. */
2333 no address side effects. */ in noce_operand_ok()
2340 /* Return true if a write into MEM may trap or fault. */
2355 /* Call target hook to avoid the effects of -fpic etc.... */ in noce_mem_write_may_trap_or_fault_p()
2356 addr = targetm.delegitimize_address (addr); in noce_mem_write_may_trap_or_fault_p()
2393 /* Return whether we can use store speculation for MEM. TOP_BB is the
2395 doing the speculative store. We look for whether MEM is set
2396 unconditionally later in the function. */
2412 have to stop looking. Even if the MEM is set later in in noce_can_store_speculate_p()
2414 unconditionally before the barrier. */ in noce_can_store_speculate_p()
2432 it without using conditional execution. Return TRUE if we were successful
2433 at converting the block. */
2450 (1) if (...) x = a; else x = b; in noce_process_if_block()
2451 (2) x = b; if (...) x = a; in noce_process_if_block()
2452 (3) if (...) x = a; // as if with an initial x = x. in noce_process_if_block()
2454 The later patterns require jumps to be more expensive. in noce_process_if_block()
2456 ??? For future expansion, look for multiple X in such patterns. */ in noce_process_if_block()
2458 /* Look for one of the potential sets. */ in noce_process_if_block()
2468 /* Look for the other potential set. Make sure we've got equivalent in noce_process_if_block()
2469 destinations. */ in noce_process_if_block()
2470 /* ??? This is overconservative. Storing to two different mems is in noce_process_if_block()
2471 as easy as conditionally computing the address. Storing to a in noce_process_if_block()
2474 stack pointer is available for this. */ in noce_process_if_block()
2489 COND_EARLIEST to JUMP. Make sure the relevant data is still in noce_process_if_block()
2490 intact. */ in noce_process_if_block()
2499 /* Likewise with X. In particular this can happen when in noce_process_if_block()
2501 stream than one might expect. */ in noce_process_if_block()
2509 convert. But even in that case we would need to restore any notes in noce_process_if_block()
2510 (such as REG_INC) at then end. That can be tricky if in noce_process_if_block()
2512 optimization entirely for now if there are side effects. */ in noce_process_if_block()
2519 the lifetime of hard registers on small register class machines. */ in noce_process_if_block()
2523 && targetm.small_register_classes_for_mode_p (GET_MODE (x)))) in noce_process_if_block()
2537 /* Don't operate on sources that may trap or are volatile. */ in noce_process_if_block()
2542 /* Set up the info block for our subroutines. */ in noce_process_if_block()
2549 /* Try optimizations in some approximation of a useful order. */ in noce_process_if_block()
2550 /* ??? Should first look to see if X is live incoming at all. If it in noce_process_if_block()
2551 isn't, we don't need anything but an unconditional set. */ in noce_process_if_block()
2553 /* Look and see if A and B are really the same. Avoid creating silly in noce_process_if_block()
2554 cmove constructs that no one will fix up later. */ in noce_process_if_block()
2557 /* If we have an INSN_B, we don't have to create any new rtl. Just in noce_process_if_block()
2558 move the instruction that we already have. If we don't have an in noce_process_if_block()
2559 INSN_B, that means that A == X, and we've got a noop move. In in noce_process_if_block()
2560 that case don't do anything and let the code below delete INSN_A. */ in noce_process_if_block()
2570 true due to this insn being after a jump. */ in noce_process_if_block()
2576 /* If we have "x = b; if (...) x = a;", and x has side-effects, then in noce_process_if_block()
2577 x must be executed twice. */ in noce_process_if_block()
2587 /* Disallow the "if (...) x = a;" form (implicit "else x = x;") in noce_process_if_block()
2589 i.e. it's a memory other than a static var or a stack slot, in noce_process_if_block()
2590 is misaligned on strict aligned machines or is read-only. If in noce_process_if_block()
2592 avoid the store into it. If there are stores on both the in noce_process_if_block()
2595 false such that the other memory is selected. */ in noce_process_if_block()
2599 /* Avoid store speculation: given "if (...) x = a" where x is a in noce_process_if_block()
2601 somewhere in the function. This avoids cases like in noce_process_if_block()
2605 is held. FIXME: This should ideally be expressed directly in in noce_process_if_block()
2606 RTL somehow. */ in noce_process_if_block()
2624 if (! targetm.have_conditional_execution ()) in noce_process_if_block()
2650 /* If we used a temporary, fix it up now. */ in noce_process_if_block()
2665 /* The original THEN and ELSE blocks may now be removed. The test block in noce_process_if_block()
2666 must now jump to the join block. If the test block and the join block in noce_process_if_block()
2667 can be merged, do so. */ in noce_process_if_block()
2691 /* Check whether a block is suitable for conditional move conversion.
2693 register. For each assignment, store the value in the pointer map
2695 pointer in REGS. COND is the condition we will test. */
2705 /* We can only handle simple jumps at the end of the basic block. in check_cond_move_block()
2706 It is almost impossible to update the CFG otherwise. */ in check_cond_move_block()
2726 && targetm.small_register_classes_for_mode_p (GET_MODE (dest)))) in check_cond_move_block()
2739 modified earlier in the block. */ in check_cond_move_block()
2747 modified earlier in the block. */ in check_cond_move_block()
2752 destination register. */ in check_cond_move_block()
2757 later in the block. */ in check_cond_move_block()
2774 conditional moves. If ELSE_BLOCK is true, THEN_BB was already
2775 processed. The caller has started a sequence for the conversion.
2776 Return true if successful, false if something goes wrong. */
2813 handled this case there. */ in cond_move_convert_if_block()
2839 it using only conditional moves. Return TRUE if we were successful at
2840 converting the block. */
2862 register. */ in cond_move_process_if_block()
2866 /* Make sure the blocks are suitable. */ in cond_move_process_if_block()
2872 /* Make sure the blocks can be used together. If the same register in cond_move_process_if_block()
2874 cases, then both blocks must set it to the same register. We in cond_move_process_if_block()
2876 source register does not change after the assignment. Also count in cond_move_process_if_block()
2877 the number of registers set in only one of the blocks. */ in cond_move_process_if_block()
2897 /* Finish off c for MAX_CONDITIONAL_EXECUTE. */ in cond_move_process_if_block()
2905 /* Make sure it is reasonable to convert this block. What matters in cond_move_process_if_block()
2908 them. */ in cond_move_process_if_block()
2912 /* Try to emit the conditional moves. First do the then block, in cond_move_process_if_block()
2913 then do anything left in the else blocks. */ in cond_move_process_if_block()
2969 IF-THEN-ELSE-JOIN block.
2972 using only transformations that do not require conditional execution.
2974 Return TRUE if we were successful at converting the block. */
2986 /* We only ever should get here before reload. */ in noce_find_if_block()
2989 /* Recognize an IF-THEN-ELSE-JOIN block. */ in noce_find_if_block()
3000 /* Recognize an IF-THEN-JOIN block. */ in noce_find_if_block()
3009 /* Recognize an IF-ELSE-JOIN block. We can have those because the order in noce_find_if_block()
3012 cfgrtl mode). */ in noce_find_if_block()
3017 /* The noce transformations do not apply to IF-ELSE-JOIN blocks. in noce_find_if_block()
3019 and reverse the jump condition. */ in noce_find_if_block()
3026 /* Not a form we can handle. */ in noce_find_if_block()
3029 /* The edges of the THEN and ELSE blocks cannot have complex edges. */ in noce_find_if_block()
3052 jump, then we can not do if-conversion on this block. */ in noce_find_if_block()
3057 /* If this is not a standard conditional jump, we can't parse it. */ in noce_find_if_block()
3062 /* We must be comparing objects whose modes imply the size. */ in noce_find_if_block()
3066 /* Initialize an IF_INFO struct to pass around. */ in noce_find_if_block()
3068 if_info.test_bb = test_bb; in noce_find_if_block()
3069 if_info.then_bb = then_bb; in noce_find_if_block()
3070 if_info.else_bb = else_bb; in noce_find_if_block()
3071 if_info.join_bb = join_bb; in noce_find_if_block()
3072 if_info.cond = cond; in noce_find_if_block()
3073 if_info.cond_earliest = cond_earliest; in noce_find_if_block()
3074 if_info.jump = jump; in noce_find_if_block()
3075 if_info.then_else_reversed = then_else_reversed; in noce_find_if_block()
3076 if_info.branch_cost = BRANCH_COST (optimize_bb_for_speed_p (test_bb), in noce_find_if_block()
3079 /* Do the real work. */ in noce_find_if_block()
3092 /* Merge the blocks and mark for local life update. */
3103 /* All block merging is done into the lower block numbers. */ in merge_if_block()
3108 /* Merge any basic blocks to handle && and || subtests. Each of in merge_if_block()
3109 the blocks are on the fallthru path from the predecessor block. */ in merge_if_block()
3126 /* Merge TEST block into THEN block. Normally the THEN block won't have a in merge_if_block()
3127 label, but it might if there were || tests. That label's count should be in merge_if_block()
3128 zero, and it normally should be removed. */ in merge_if_block()
3136 /* The ELSE block, if it existed, had a label. That label count in merge_if_block()
3138 get their addresses taken. */ in merge_if_block()
3146 to the others, and so we cannot merge them. */ in merge_if_block()
3153 be correct. Verify this. */ in merge_if_block()
3163 blocks taking us to our final destination. */ in merge_if_block()
3172 /* The JOIN block may have had quite a number of other predecessors too. in merge_if_block()
3174 have only one remaining edge from our if-then-else diamond. If there in merge_if_block()
3175 is more than one remaining edge, it must come from elsewhere. There in merge_if_block()
3177 back up (as with a call to a non-return function). */ in merge_if_block()
3182 again on this pass.*/ in merge_if_block()
3188 /* We cannot merge the JOIN. */ in merge_if_block()
3191 be correct. Verify this. */ in merge_if_block()
3195 /* Remove the jump and cruft from the end of the COMBO block. */ in merge_if_block()
3204 in some way. When converting a multi-block condition, put the new code
3205 in the first such block and delete the rest. Return a pointer to this
3206 first block if some transformation was done. Return NULL otherwise. */
3215 /* The kind of block we're looking for has exactly two successors. */ in find_if_header()
3227 /* Neither edge should be abnormal. */ in find_if_header()
3232 /* Nor exit the loop. */ in find_if_header()
3237 /* The THEN edge is canonically the one that falls through. */ in find_if_header()
3247 /* Otherwise this must be a multiway branch of some sort. */ in find_if_header()
3251 ce_info.test_bb = test_bb; in find_if_header()
3252 ce_info.then_bb = then_edge->dest; in find_if_header()
3253 ce_info.else_bb = else_edge->dest; in find_if_header()
3254 ce_info.pass = pass; in find_if_header()
3265 && targetm.have_conditional_execution () in find_if_header()
3275 && (reload_completed || !targetm.have_conditional_execution ())) in find_if_header()
3287 fprintf (dump_file, "Conversion succeeded on pass %d.\n", pass); in find_if_header()
3288 /* Set this so we continue looking. */ in find_if_header()
3290 return ce_info.test_bb; in find_if_header()
3295 block is part of an && test or an || test. Returns either -1 or the number
3296 of non-note, non-jump, non-USE/CLOBBER insns in the block. */
3312 /* If no edges, obviously it doesn't jump or fallthru. */ in block_jumps_and_fallthru_p()
3319 /* Anything complex isn't what we want. */ in block_jumps_and_fallthru_p()
3336 together for conditional execution support. ??? we should support in block_jumps_and_fallthru_p()
3338 for now it makes the code simpler. */ in block_jumps_and_fallthru_p()
3364 block. If so, we'll try to convert the insns to not require the branch.
3365 Return TRUE if we were successful at converting the block. */
3381 and if we have conditional execution. */ in cond_exec_find_if_block()
3382 gcc_assert (reload_completed && targetm.have_conditional_execution ()); in cond_exec_find_if_block()
3386 the then block). */ in cond_exec_find_if_block()
3395 /* Determine if the preceding block is an && or || block. */ in cond_exec_find_if_block()
3416 /* Found at least one && or || block, look for more. */ in cond_exec_find_if_block()
3442 other than any || blocks which jump to the THEN block. */ in cond_exec_find_if_block()
3446 /* The edges of the THEN and ELSE blocks cannot have complex edges. */ in cond_exec_find_if_block()
3459 /* The THEN block of an IF-THEN combo must have zero or one successors. */ in cond_exec_find_if_block()
3468 make a conditional call. Don't do this unless the ELSE block has in cond_exec_find_if_block()
3469 only one incoming edge -- the CFG manipulation is too ugly otherwise. in cond_exec_find_if_block()
3472 code processing. ??? we should fix this in the future. */ in cond_exec_find_if_block()
3497 then we have an IF-THEN combo without an ELSE. */ in cond_exec_find_if_block()
3506 is not complex, then we have an IF-THEN-ELSE combo. */ in cond_exec_find_if_block()
3515 /* Otherwise it is not an IF-THEN or IF-THEN-ELSE combination. */ in cond_exec_find_if_block()
3555 /* Make sure IF, THEN, and ELSE, blocks are adjacent. Actually, we get the in cond_exec_find_if_block()
3557 fallthru edge from IF to THEN. Likewise for the && and || blocks, since in cond_exec_find_if_block()
3559 block. */ in cond_exec_find_if_block()
3560 /* ??? As an enhancement, move the ELSE block. Have to deal with in cond_exec_find_if_block()
3562 exist. Sticky enough I don't want to think about it now. */ in cond_exec_find_if_block()
3574 /* Do the real work. */ in cond_exec_find_if_block()
3582 was no ELSE block. */ in cond_exec_find_if_block()
3598 to a trap, into a conditional trap. */
3609 /* Locate the block with the trap instruction. */ in find_cond_trap()
3611 EH successors. Need to fix merge_if_block for that to work. */ in find_cond_trap()
3625 /* If this is not a standard conditional jump, we can't parse it. */ in find_cond_trap()
3632 we can not do if-conversion on this block. */ in find_cond_trap()
3636 /* We must be comparing objects whose modes imply the size. */ in find_cond_trap()
3640 /* Reverse the comparison code, if necessary. */ in find_cond_trap()
3649 /* Attempt to generate the conditional trap. */ in find_cond_trap()
3656 /* Emit the new insns before cond_earliest. */ in find_cond_trap()
3659 /* Delete the trap block if possible. */ in find_cond_trap()
3671 /* Wire together the blocks again. */ in find_cond_trap()
3697 return it. */
3704 /* We're not the exit block. */ in block_has_only_trap()
3708 /* The block must have no successors. */ in block_has_only_trap()
3712 /* The only instruction in the THEN block must be the trap. */ in block_has_only_trap()
3723 transformable, but not necessarily the other. There need be no
3724 JOIN block.
3726 Return TRUE if we were successful at converting the block.
3757 // multiway branching, e.g. IA-64 BBB bundles. For other targets
3759 // does not sit well with predictors.
3763 if (test2) goto F;
3764 ...
3773 if (test2) goto F;
3778 eliminating. Do it anyway if we can eliminate a branch; this requires
3780 side of the if.
3787 if (test2) goto F;
3788 ...
3791 Again, this is most useful if J postdominates.
3793 (C) CE substitutes for helpful life information.
3795 (D) These heuristics need a lot of work. */
3797 /* Tests for case 1 above. */
3810 and cold sections. in find_if_case_1()
3815 partition boundaries). See the comments at the top of in find_if_case_1()
3816 bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */ in find_if_case_1()
3827 /* THEN has one successor. */ in find_if_case_1()
3831 /* THEN does not fall through, but is not strange either. */ in find_if_case_1()
3835 /* THEN has one predecessor. */ in find_if_case_1()
3839 /* THEN must do something. */ in find_if_case_1()
3855 of speculation is within reason. */ in find_if_case_1()
3868 /* Registers set are dead, or are predicable. */ in find_if_case_1()
3874 jump. Adjust the CFG to match. */ in find_if_case_1()
3877 followed by else_bb, i.e. deleting then_bb allows test_bb to fall in find_if_case_1()
3878 thru to else_bb. */ in find_if_case_1()
3901 block we removed. */ in find_if_case_1()
3907 test bb (you can not fall through across section boundaries). */ in find_if_case_1()
3917 /* Test for case 2 above. */
3929 and cold sections. in find_if_case_2()
3934 partition boundaries). See the comments at the top of in find_if_case_2()
3935 bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */ in find_if_case_2()
3946 /* ELSE has one successor. */ in find_if_case_2()
3952 /* ELSE outgoing edge is not complex. */ in find_if_case_2()
3956 /* ELSE has one predecessor. */ in find_if_case_2()
3960 /* THEN is not EXIT. */ in find_if_case_2()
3975 /* ELSE is predicted or SUCC(ELSE) postdominates THEN. */ in find_if_case_2()
3992 of speculation is within reason. */ in find_if_case_2()
3998 /* Registers set are dead, or are predicable. */ in find_if_case_2()
4003 jump. Adjust the CFG to match. */ in find_if_case_2()
4013 block. Rerun cleanup_cfg? Examine things manually? Wait? */ in find_if_case_2()
4018 /* Used by the code above to perform the actual rtl transformations.
4019 Return TRUE if successful.
4021 TEST_BB is the block containing the conditional branch. MERGE_BB
4022 is the block containing the code to manipulate. DEST_EDGE is an
4024 TEST_BB should be branching to its destination.
4025 REVERSEP is true if the sense of the branch should be reversed. */
4034 /* Number of pending changes. */ in dead_or_predicable()
4040 /* Find the extent of the real code in the merge block. */ in dead_or_predicable()
4050 get an unresolved reference to the jumptable. */ in dead_or_predicable()
4083 to do anything funny with the tests, etc. */ in dead_or_predicable()
4085 if (targetm.have_conditional_execution ()) in dead_or_predicable()
4087 /* In the conditional execution case, we have things easy. We know in dead_or_predicable()
4088 the condition is reversible. We don't have to check life info in dead_or_predicable()
4089 because we're going to conditionally execute the code anyway. in dead_or_predicable()
4091 be predicated. */ in dead_or_predicable()
4124 /* If we allocated new pseudos (e.g. in the conditional move in dead_or_predicable()
4126 array first. */ in dead_or_predicable()
4130 /* Try the NCE path if the CE path did not result in any changes. */ in dead_or_predicable()
4139 that any registers modified are dead at the branch site. */ in dead_or_predicable()
4144 /* Find the extent of the conditional. */ in dead_or_predicable()
4158 /* Collect the set of registers set in MERGE_BB. */ in dead_or_predicable()
4167 the first basic block and merge_bb exits. The idea is to not in dead_or_predicable()
4170 saved in caller-saved regs. A caller-saved reg requires the in dead_or_predicable()
4171 prologue, killing a shrink-wrap opportunity. */ in dead_or_predicable()
4184 params and regs used to return values. */ in dead_or_predicable()
4187 && targetm.calls.function_value_regno_p (i)) in dead_or_predicable()
4200 /* If this insn sets any reg in return_regs.. */ in dead_or_predicable()
4209 /* ..then add all reg uses to the set of regs in dead_or_predicable()
4210 we're interested in. */ in dead_or_predicable()
4228 we don't want to delete_insn called. Also, we want to do our own in dead_or_predicable()
4229 change group management. */ in dead_or_predicable()
4271 /* Move the insns out of MERGE_BB to before the branch. */ in dead_or_predicable()
4280 notes being moved might become invalid. */ in dead_or_predicable()
4298 notes referring to the registers being set might become invalid. */ in dead_or_predicable()
4313 /* Remove the jump and edge if we can. */ in dead_or_predicable()
4318 /* ??? Can't merge blocks here, as then_bb is still in use. in dead_or_predicable()
4319 At minimum, the merge will get done just before bb-reorder. */ in dead_or_predicable()
4333 /* Main entry point for all if-conversion. */
4356 /* Compute postdominators. */ in if_convert()
4361 /* Go through each of the basic blocks looking for things to convert. If we in if_convert()
4363 IF-THEN{-ELSE} blocks within other IF-THEN{-ELSE} blocks. */ in if_convert()
4368 /* Only need to do dce on the first pass. */ in if_convert()
4410 /* If we allocated new pseudos, we must resize the array for sched1. */ in if_convert()
4414 /* Write the final stats. */ in if_convert()
4418 "\n%d possible IF blocks searched.\n", in if_convert()
4421 "%d IF blocks converted.\n", in if_convert()
4424 "%d true changes made.\n\n\n", in if_convert()
4443 /* If-conversion and CFG cleanup. */
4488 to now meet sequence length restrictions. */