Mercurial > hg > CbC > CbC_gcc
comparison gcc/combine.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Optimize by combining instructions for GNU compiler. | 1 /* Optimize by combining instructions for GNU compiler. |
2 Copyright (C) 1987-2018 Free Software Foundation, Inc. | 2 Copyright (C) 1987-2020 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GCC. | 4 This file is part of GCC. |
5 | 5 |
6 GCC is free software; you can redistribute it and/or modify it under | 6 GCC is free software; you can redistribute it and/or modify it under |
7 the terms of the GNU General Public License as published by the Free | 7 the terms of the GNU General Public License as published by the Free |
98 /* Include expr.h after insn-config.h so we get HAVE_conditional_move. */ | 98 /* Include expr.h after insn-config.h so we get HAVE_conditional_move. */ |
99 #include "explow.h" | 99 #include "explow.h" |
100 #include "insn-attr.h" | 100 #include "insn-attr.h" |
101 #include "rtlhooks-def.h" | 101 #include "rtlhooks-def.h" |
102 #include "expr.h" | 102 #include "expr.h" |
103 #include "params.h" | |
104 #include "tree-pass.h" | 103 #include "tree-pass.h" |
105 #include "valtrack.h" | 104 #include "valtrack.h" |
106 #include "rtl-iter.h" | 105 #include "rtl-iter.h" |
107 #include "print-rtl.h" | 106 #include "print-rtl.h" |
107 #include "function-abi.h" | |
108 | 108 |
109 /* Number of attempts to combine instructions in this function. */ | 109 /* Number of attempts to combine instructions in this function. */ |
110 | 110 |
111 static int combine_attempts; | 111 static int combine_attempts; |
112 | 112 |
528 targetm.canonicalize_comparison (&code_int, op0, op1, op0_preserve_value); | 528 targetm.canonicalize_comparison (&code_int, op0, op1, op0_preserve_value); |
529 *code = (enum rtx_code)code_int; | 529 *code = (enum rtx_code)code_int; |
530 } | 530 } |
531 | 531 |
532 /* Try to split PATTERN found in INSN. This returns NULL_RTX if | 532 /* Try to split PATTERN found in INSN. This returns NULL_RTX if |
533 PATTERN can not be split. Otherwise, it returns an insn sequence. | 533 PATTERN cannot be split. Otherwise, it returns an insn sequence. |
534 This is a wrapper around split_insns which ensures that the | 534 This is a wrapper around split_insns which ensures that the |
535 reg_stat vector is made larger if the splitter creates a new | 535 reg_stat vector is made larger if the splitter creates a new |
536 register. */ | 536 register. */ |
537 | 537 |
538 static rtx_insn * | 538 static rtx_insn * |
569 case CONST: | 569 case CONST: |
570 case LABEL_REF: | 570 case LABEL_REF: |
571 case SYMBOL_REF: | 571 case SYMBOL_REF: |
572 CASE_CONST_ANY: | 572 CASE_CONST_ANY: |
573 case CLOBBER: | 573 case CLOBBER: |
574 case CLOBBER_HIGH: | |
575 return 0; | 574 return 0; |
576 | 575 |
577 case SET: | 576 case SET: |
578 /* If the destination is anything other than CC0, PC, a REG or a SUBREG | 577 /* If the destination is anything other than CC0, PC, a REG or a SUBREG |
579 of a REG that occupies all of the REG, the insn uses DEST if | 578 of a REG that occupies all of the REG, the insn uses DEST if |
981 | 980 |
982 return true; | 981 return true; |
983 } | 982 } |
984 | 983 |
985 | 984 |
986 /* Delete any insns that copy a register to itself. */ | 985 /* Delete any insns that copy a register to itself. |
987 | 986 Return true if the CFG was changed. */ |
988 static void | 987 |
988 static bool | |
989 delete_noop_moves (void) | 989 delete_noop_moves (void) |
990 { | 990 { |
991 rtx_insn *insn, *next; | 991 rtx_insn *insn, *next; |
992 basic_block bb; | 992 basic_block bb; |
993 | 993 |
994 bool edges_deleted = false; | |
995 | |
994 FOR_EACH_BB_FN (bb, cfun) | 996 FOR_EACH_BB_FN (bb, cfun) |
995 { | 997 { |
996 for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); insn = next) | 998 for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); insn = next) |
997 { | 999 { |
998 next = NEXT_INSN (insn); | 1000 next = NEXT_INSN (insn); |
999 if (INSN_P (insn) && noop_move_p (insn)) | 1001 if (INSN_P (insn) && noop_move_p (insn)) |
1000 { | 1002 { |
1001 if (dump_file) | 1003 if (dump_file) |
1002 fprintf (dump_file, "deleting noop move %d\n", INSN_UID (insn)); | 1004 fprintf (dump_file, "deleting noop move %d\n", INSN_UID (insn)); |
1003 | 1005 |
1004 delete_insn_and_edges (insn); | 1006 edges_deleted |= delete_insn_and_edges (insn); |
1005 } | 1007 } |
1006 } | 1008 } |
1007 } | 1009 } |
1010 | |
1011 return edges_deleted; | |
1008 } | 1012 } |
1009 | 1013 |
1010 | 1014 |
1011 /* Return false if we do not want to (or cannot) combine DEF. */ | 1015 /* Return false if we do not want to (or cannot) combine DEF. */ |
1012 static bool | 1016 static bool |
1141 } | 1145 } |
1142 | 1146 |
1143 /* Main entry point for combiner. F is the first insn of the function. | 1147 /* Main entry point for combiner. F is the first insn of the function. |
1144 NREGS is the first unused pseudo-reg number. | 1148 NREGS is the first unused pseudo-reg number. |
1145 | 1149 |
1146 Return nonzero if the combiner has turned an indirect jump | 1150 Return nonzero if the CFG was changed (e.g. if the combiner has |
1147 instruction into a direct jump. */ | 1151 turned an indirect jump instruction into a direct jump). */ |
1148 static int | 1152 static int |
1149 combine_instructions (rtx_insn *f, unsigned int nregs) | 1153 combine_instructions (rtx_insn *f, unsigned int nregs) |
1150 { | 1154 { |
1151 rtx_insn *insn, *next; | 1155 rtx_insn *insn, *next; |
1152 rtx_insn *prev; | 1156 rtx_insn *prev; |
1217 rtx links; | 1221 rtx links; |
1218 | 1222 |
1219 subst_low_luid = DF_INSN_LUID (insn); | 1223 subst_low_luid = DF_INSN_LUID (insn); |
1220 subst_insn = insn; | 1224 subst_insn = insn; |
1221 | 1225 |
1222 note_stores (PATTERN (insn), set_nonzero_bits_and_sign_copies, | 1226 note_stores (insn, set_nonzero_bits_and_sign_copies, insn); |
1223 insn); | |
1224 record_dead_and_set_regs (insn); | 1227 record_dead_and_set_regs (insn); |
1225 | 1228 |
1226 if (AUTO_INC_DEC) | 1229 if (AUTO_INC_DEC) |
1227 for (links = REG_NOTES (insn); links; links = XEXP (links, 1)) | 1230 for (links = REG_NOTES (insn); links; links = XEXP (links, 1)) |
1228 if (REG_NOTE_KIND (links) == REG_INC) | 1231 if (REG_NOTE_KIND (links) == REG_INC) |
1229 set_nonzero_bits_and_sign_copies (XEXP (links, 0), NULL_RTX, | 1232 set_nonzero_bits_and_sign_copies (XEXP (links, 0), NULL_RTX, |
1230 insn); | 1233 insn); |
1231 | 1234 |
1232 /* Record the current insn_cost of this instruction. */ | 1235 /* Record the current insn_cost of this instruction. */ |
1233 if (NONJUMP_INSN_P (insn)) | 1236 INSN_COST (insn) = insn_cost (insn, optimize_this_for_speed_p); |
1234 INSN_COST (insn) = insn_cost (insn, optimize_this_for_speed_p); | |
1235 if (dump_file) | 1237 if (dump_file) |
1236 { | 1238 { |
1237 fprintf (dump_file, "insn_cost %d for ", INSN_COST (insn)); | 1239 fprintf (dump_file, "insn_cost %d for ", INSN_COST (insn)); |
1238 dump_insn_slim (dump_file, insn); | 1240 dump_insn_slim (dump_file, insn); |
1239 } | 1241 } |
1245 /* Now scan all the insns in forward order. */ | 1247 /* Now scan all the insns in forward order. */ |
1246 label_tick = label_tick_ebb_start = 1; | 1248 label_tick = label_tick_ebb_start = 1; |
1247 init_reg_last (); | 1249 init_reg_last (); |
1248 setup_incoming_promotions (first); | 1250 setup_incoming_promotions (first); |
1249 last_bb = ENTRY_BLOCK_PTR_FOR_FN (cfun); | 1251 last_bb = ENTRY_BLOCK_PTR_FOR_FN (cfun); |
1250 int max_combine = PARAM_VALUE (PARAM_MAX_COMBINE_INSNS); | 1252 int max_combine = param_max_combine_insns; |
1251 | 1253 |
1252 FOR_EACH_BB_FN (this_basic_block, cfun) | 1254 FOR_EACH_BB_FN (this_basic_block, cfun) |
1253 { | 1255 { |
1254 rtx_insn *last_combined_insn = NULL; | 1256 rtx_insn *last_combined_insn = NULL; |
1255 | 1257 |
1527 } | 1529 } |
1528 | 1530 |
1529 default_rtl_profile (); | 1531 default_rtl_profile (); |
1530 clear_bb_flags (); | 1532 clear_bb_flags (); |
1531 new_direct_jump_p |= purge_all_dead_edges (); | 1533 new_direct_jump_p |= purge_all_dead_edges (); |
1532 delete_noop_moves (); | 1534 new_direct_jump_p |= delete_noop_moves (); |
1533 | 1535 |
1534 /* Clean up. */ | 1536 /* Clean up. */ |
1535 obstack_free (&insn_link_obstack, NULL); | 1537 obstack_free (&insn_link_obstack, NULL); |
1536 free (uid_log_links); | 1538 free (uid_log_links); |
1537 free (uid_insn_cost); | 1539 free (uid_insn_cost); |
1594 | 1596 |
1595 /* Determine, if possible, whether all call sites of the current | 1597 /* Determine, if possible, whether all call sites of the current |
1596 function lie within the current compilation unit. (This does | 1598 function lie within the current compilation unit. (This does |
1597 take into account the exporting of a function via taking its | 1599 take into account the exporting of a function via taking its |
1598 address, and so forth.) */ | 1600 address, and so forth.) */ |
1599 strictly_local = cgraph_node::local_info (current_function_decl)->local; | 1601 strictly_local |
1602 = cgraph_node::local_info_node (current_function_decl)->local; | |
1600 | 1603 |
1601 /* The mode and signedness of the argument before any promotions happen | 1604 /* The mode and signedness of the argument before any promotions happen |
1602 (equal to the mode of the pseudo holding it at that stage). */ | 1605 (equal to the mode of the pseudo holding it at that stage). */ |
1603 mode1 = TYPE_MODE (TREE_TYPE (arg)); | 1606 mode1 = TYPE_MODE (TREE_TYPE (arg)); |
1604 uns1 = TYPE_UNSIGNED (TREE_TYPE (arg)); | 1607 uns1 = TYPE_UNSIGNED (TREE_TYPE (arg)); |
1696 } | 1699 } |
1697 | 1700 |
1698 /* Don't call nonzero_bits if it cannot change anything. */ | 1701 /* Don't call nonzero_bits if it cannot change anything. */ |
1699 if (rsp->nonzero_bits != HOST_WIDE_INT_M1U) | 1702 if (rsp->nonzero_bits != HOST_WIDE_INT_M1U) |
1700 { | 1703 { |
1701 bits = nonzero_bits (src, nonzero_bits_mode); | 1704 machine_mode mode = GET_MODE (x); |
1705 if (GET_MODE_CLASS (mode) == MODE_INT | |
1706 && HWI_COMPUTABLE_MODE_P (mode)) | |
1707 mode = nonzero_bits_mode; | |
1708 bits = nonzero_bits (src, mode); | |
1702 if (reg_equal && bits) | 1709 if (reg_equal && bits) |
1703 bits &= nonzero_bits (reg_equal, nonzero_bits_mode); | 1710 bits &= nonzero_bits (reg_equal, mode); |
1704 rsp->nonzero_bits |= bits; | 1711 rsp->nonzero_bits |= bits; |
1705 } | 1712 } |
1706 | 1713 |
1707 /* Don't call num_sign_bit_copies if it cannot change anything. */ | 1714 /* Don't call num_sign_bit_copies if it cannot change anything. */ |
1708 if (rsp->sign_bit_copies != 1) | 1715 if (rsp->sign_bit_copies != 1) |
1751 { | 1758 { |
1752 rsp->nonzero_bits = GET_MODE_MASK (mode); | 1759 rsp->nonzero_bits = GET_MODE_MASK (mode); |
1753 rsp->sign_bit_copies = 1; | 1760 rsp->sign_bit_copies = 1; |
1754 return; | 1761 return; |
1755 } | 1762 } |
1756 | |
1757 /* Should not happen as we only using pseduo registers. */ | |
1758 gcc_assert (GET_CODE (set) != CLOBBER_HIGH); | |
1759 | 1763 |
1760 /* If this register is being initialized using itself, and the | 1764 /* If this register is being initialized using itself, and the |
1761 register is uninitialized in this basic block, and there are | 1765 register is uninitialized in this basic block, and there are |
1762 no LOG_LINKS which set the register, then part of the | 1766 no LOG_LINKS which set the register, then part of the |
1763 register is uninitialized. In that case we can't assume | 1767 register is uninitialized. In that case we can't assume |
1913 } | 1917 } |
1914 break; | 1918 break; |
1915 | 1919 |
1916 /* We can ignore CLOBBERs. */ | 1920 /* We can ignore CLOBBERs. */ |
1917 case CLOBBER: | 1921 case CLOBBER: |
1918 case CLOBBER_HIGH: | |
1919 break; | 1922 break; |
1920 | 1923 |
1921 case SET: | 1924 case SET: |
1922 /* Ignore SETs whose result isn't used but not those that | 1925 /* Ignore SETs whose result isn't used but not those that |
1923 have side-effects. */ | 1926 have side-effects. */ |
2105 volatile insn might affect machine state. */ | 2108 volatile insn might affect machine state. */ |
2106 | 2109 |
2107 is_volatile_p = volatile_refs_p (PATTERN (insn)) | 2110 is_volatile_p = volatile_refs_p (PATTERN (insn)) |
2108 ? volatile_refs_p | 2111 ? volatile_refs_p |
2109 : volatile_insn_p; | 2112 : volatile_insn_p; |
2110 | 2113 |
2111 for (p = NEXT_INSN (insn); p != i3; p = NEXT_INSN (p)) | 2114 for (p = NEXT_INSN (insn); p != i3; p = NEXT_INSN (p)) |
2112 if (INSN_P (p) && p != succ && p != succ2 && is_volatile_p (PATTERN (p))) | 2115 if (INSN_P (p) && p != succ && p != succ2 && is_volatile_p (PATTERN (p))) |
2113 return 0; | 2116 return 0; |
2114 | 2117 |
2115 /* If INSN contains an autoincrement or autodecrement, make sure that | 2118 /* If INSN contains an autoincrement or autodecrement, make sure that |
2116 register is not used between there and I3, and not already used in | 2119 register is not used between there and I3, and not already used in |
2117 I3 either. Neither must it be used in PRED or SUCC, if they exist. | 2120 I3 either. Neither must it be used in PRED or SUCC, if they exist. |
2118 Also insist that I3 not be a jump; if it were one | 2121 Also insist that I3 not be a jump if using LRA; if it were one |
2119 and the incremented register were spilled, we would lose. */ | 2122 and the incremented register were spilled, we would lose. |
2123 Reload handles this correctly. */ | |
2120 | 2124 |
2121 if (AUTO_INC_DEC) | 2125 if (AUTO_INC_DEC) |
2122 for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) | 2126 for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) |
2123 if (REG_NOTE_KIND (link) == REG_INC | 2127 if (REG_NOTE_KIND (link) == REG_INC |
2124 && (JUMP_P (i3) | 2128 && ((JUMP_P (i3) && targetm.lra_p ()) |
2125 || reg_used_between_p (XEXP (link, 0), insn, i3) | 2129 || reg_used_between_p (XEXP (link, 0), insn, i3) |
2126 || (pred != NULL_RTX | 2130 || (pred != NULL_RTX |
2127 && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (pred))) | 2131 && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (pred))) |
2128 || (pred2 != NULL_RTX | 2132 || (pred2 != NULL_RTX |
2129 && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (pred2))) | 2133 && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (pred2))) |
2347 src = SUBREG_REG (src); | 2351 src = SUBREG_REG (src); |
2348 if (GET_CODE (dest) == SUBREG) | 2352 if (GET_CODE (dest) == SUBREG) |
2349 dest = SUBREG_REG (dest); | 2353 dest = SUBREG_REG (dest); |
2350 if (REG_P (src) && REG_P (dest) | 2354 if (REG_P (src) && REG_P (dest) |
2351 && ((HARD_REGISTER_P (src) | 2355 && ((HARD_REGISTER_P (src) |
2352 && ! TEST_HARD_REG_BIT (fixed_reg_set, REGNO (src))) | 2356 && ! TEST_HARD_REG_BIT (fixed_reg_set, REGNO (src)) |
2357 #ifdef LEAF_REGISTERS | |
2358 && ! LEAF_REGISTERS [REGNO (src)]) | |
2359 #else | |
2360 ) | |
2361 #endif | |
2353 || (HARD_REGISTER_P (dest) | 2362 || (HARD_REGISTER_P (dest) |
2354 && ! TEST_HARD_REG_BIT (fixed_reg_set, REGNO (dest)) | 2363 && ! TEST_HARD_REG_BIT (fixed_reg_set, REGNO (dest)) |
2355 && targetm.class_likely_spilled_p (REGNO_REG_CLASS (REGNO (dest)))))) | 2364 && targetm.class_likely_spilled_p (REGNO_REG_CLASS (REGNO (dest)))))) |
2356 return 1; | 2365 return 1; |
2357 | 2366 |
2423 info.regno = regno; | 2432 info.regno = regno; |
2424 info.nregs = nregs; | 2433 info.nregs = nregs; |
2425 info.mask = mask; | 2434 info.mask = mask; |
2426 for (p = PREV_INSN (use); info.mask && p != insn; p = PREV_INSN (p)) | 2435 for (p = PREV_INSN (use); info.mask && p != insn; p = PREV_INSN (p)) |
2427 if (INSN_P (p)) | 2436 if (INSN_P (p)) |
2428 note_stores (PATTERN (p), likely_spilled_retval_1, &info); | 2437 note_stores (p, likely_spilled_retval_1, &info); |
2429 mask = info.mask; | 2438 mask = info.mask; |
2430 | 2439 |
2431 /* Check if any of the (probably) live return value registers is | 2440 /* Check if any of the (probably) live return value registers is |
2432 likely spilled. */ | 2441 likely spilled. */ |
2433 nregs --; | 2442 nregs --; |
2579 { | 2588 { |
2580 case CLOBBER: | 2589 case CLOBBER: |
2581 if (XEXP (XVECEXP (pat, 0, i), 0) == const0_rtx) | 2590 if (XEXP (XVECEXP (pat, 0, i), 0) == const0_rtx) |
2582 return false; | 2591 return false; |
2583 break; | 2592 break; |
2584 case CLOBBER_HIGH: | |
2585 break; | |
2586 default: | 2593 default: |
2587 return false; | 2594 return false; |
2588 } | 2595 } |
2589 return true; | 2596 return true; |
2590 } | 2597 } |
2623 { | 2630 { |
2624 if (INSN_P (x)) | 2631 if (INSN_P (x)) |
2625 x = PATTERN (x); | 2632 x = PATTERN (x); |
2626 | 2633 |
2627 return (GET_CODE (x) == SET && general_operand (SET_SRC (x), VOIDmode)); | 2634 return (GET_CODE (x) == SET && general_operand (SET_SRC (x), VOIDmode)); |
2635 } | |
2636 | |
2637 /* Callback function to count autoincs. */ | |
2638 | |
2639 static int | |
2640 count_auto_inc (rtx, rtx, rtx, rtx, rtx, void *arg) | |
2641 { | |
2642 (*((int *) arg))++; | |
2643 | |
2644 return 0; | |
2628 } | 2645 } |
2629 | 2646 |
2630 /* Try to combine the insns I0, I1 and I2 into I3. | 2647 /* Try to combine the insns I0, I1 and I2 into I3. |
2631 Here I0, I1 and I2 appear earlier than I3. | 2648 Here I0, I1 and I2 appear earlier than I3. |
2632 I0 and I1 can be zero; then we combine just I2 into I3, or I1 and I2 into | 2649 I0 and I1 can be zero; then we combine just I2 into I3, or I1 and I2 into |
2690 int have_mult = 0; | 2707 int have_mult = 0; |
2691 int swap_i2i3 = 0; | 2708 int swap_i2i3 = 0; |
2692 int split_i2i3 = 0; | 2709 int split_i2i3 = 0; |
2693 int changed_i3_dest = 0; | 2710 int changed_i3_dest = 0; |
2694 bool i2_was_move = false, i3_was_move = false; | 2711 bool i2_was_move = false, i3_was_move = false; |
2712 int n_auto_inc = 0; | |
2695 | 2713 |
2696 int maxreg; | 2714 int maxreg; |
2697 rtx_insn *temp_insn; | 2715 rtx_insn *temp_insn; |
2698 rtx temp_expr; | 2716 rtx temp_expr; |
2699 struct insn_link *link; | 2717 struct insn_link *link; |
2870 that usually (see can_combine_p), so do not here either. */ | 2888 that usually (see can_combine_p), so do not here either. */ |
2871 bool ok = true; | 2889 bool ok = true; |
2872 for (i = 0; ok && i < XVECLEN (p2, 0); i++) | 2890 for (i = 0; ok && i < XVECLEN (p2, 0); i++) |
2873 { | 2891 { |
2874 if ((GET_CODE (XVECEXP (p2, 0, i)) == SET | 2892 if ((GET_CODE (XVECEXP (p2, 0, i)) == SET |
2875 || GET_CODE (XVECEXP (p2, 0, i)) == CLOBBER | 2893 || GET_CODE (XVECEXP (p2, 0, i)) == CLOBBER) |
2876 || GET_CODE (XVECEXP (p2, 0, i)) == CLOBBER_HIGH) | |
2877 && reg_overlap_mentioned_p (SET_DEST (PATTERN (i3)), | 2894 && reg_overlap_mentioned_p (SET_DEST (PATTERN (i3)), |
2878 SET_DEST (XVECEXP (p2, 0, i)))) | 2895 SET_DEST (XVECEXP (p2, 0, i)))) |
2879 ok = false; | 2896 ok = false; |
2880 else if (GET_CODE (XVECEXP (p2, 0, i)) == SET | 2897 else if (GET_CODE (XVECEXP (p2, 0, i)) == SET |
2881 && GET_CODE (SET_SRC (XVECEXP (p2, 0, i))) == ASM_OPERANDS) | 2898 && GET_CODE (SET_SRC (XVECEXP (p2, 0, i))) == ASM_OPERANDS) |
3062 } | 3079 } |
3063 | 3080 |
3064 /* Verify that I2 and maybe I1 and I0 can be combined into I3. */ | 3081 /* Verify that I2 and maybe I1 and I0 can be combined into I3. */ |
3065 if (!can_combine_p (i2, i3, i0, i1, NULL, NULL, &i2dest, &i2src)) | 3082 if (!can_combine_p (i2, i3, i0, i1, NULL, NULL, &i2dest, &i2src)) |
3066 { | 3083 { |
3067 if (dump_file) | 3084 if (dump_file && (dump_flags & TDF_DETAILS)) |
3068 fprintf (dump_file, "Can't combine i2 into i3\n"); | 3085 fprintf (dump_file, "Can't combine i2 into i3\n"); |
3069 undo_all (); | 3086 undo_all (); |
3070 return 0; | 3087 return 0; |
3071 } | 3088 } |
3072 if (i1 && !can_combine_p (i1, i3, i0, NULL, i2, NULL, &i1dest, &i1src)) | 3089 if (i1 && !can_combine_p (i1, i3, i0, NULL, i2, NULL, &i1dest, &i1src)) |
3073 { | 3090 { |
3074 if (dump_file) | 3091 if (dump_file && (dump_flags & TDF_DETAILS)) |
3075 fprintf (dump_file, "Can't combine i1 into i3\n"); | 3092 fprintf (dump_file, "Can't combine i1 into i3\n"); |
3076 undo_all (); | 3093 undo_all (); |
3077 return 0; | 3094 return 0; |
3078 } | 3095 } |
3079 if (i0 && !can_combine_p (i0, i3, NULL, NULL, i1, i2, &i0dest, &i0src)) | 3096 if (i0 && !can_combine_p (i0, i3, NULL, NULL, i1, i2, &i0dest, &i0src)) |
3080 { | 3097 { |
3081 if (dump_file) | 3098 if (dump_file && (dump_flags & TDF_DETAILS)) |
3082 fprintf (dump_file, "Can't combine i0 into i3\n"); | 3099 fprintf (dump_file, "Can't combine i0 into i3\n"); |
3083 undo_all (); | 3100 undo_all (); |
3084 return 0; | 3101 return 0; |
3085 } | 3102 } |
3086 | 3103 |
3193 || (i0 && added_sets_0 && targetm.cannot_copy_insn_p (i0)))) | 3210 || (i0 && added_sets_0 && targetm.cannot_copy_insn_p (i0)))) |
3194 { | 3211 { |
3195 undo_all (); | 3212 undo_all (); |
3196 return 0; | 3213 return 0; |
3197 } | 3214 } |
3215 | |
3216 /* Count how many auto_inc expressions there were in the original insns; | |
3217 we need to have the same number in the resulting patterns. */ | |
3218 | |
3219 if (i0) | |
3220 for_each_inc_dec (PATTERN (i0), count_auto_inc, &n_auto_inc); | |
3221 if (i1) | |
3222 for_each_inc_dec (PATTERN (i1), count_auto_inc, &n_auto_inc); | |
3223 for_each_inc_dec (PATTERN (i2), count_auto_inc, &n_auto_inc); | |
3224 for_each_inc_dec (PATTERN (i3), count_auto_inc, &n_auto_inc); | |
3198 | 3225 |
3199 /* If the set in I2 needs to be kept around, we must make a copy of | 3226 /* If the set in I2 needs to be kept around, we must make a copy of |
3200 PATTERN (I2), so that when we substitute I1SRC for I1DEST in | 3227 PATTERN (I2), so that when we substitute I1SRC for I1DEST in |
3201 PATTERN (I2), we are only substituting for the original I1DEST, not into | 3228 PATTERN (I2), we are only substituting for the original I1DEST, not into |
3202 an already-substituted copy. This also prevents making self-referential | 3229 an already-substituted copy. This also prevents making self-referential |
3395 /* If we already got a failure, don't try to do more. Otherwise, try to | 3422 /* If we already got a failure, don't try to do more. Otherwise, try to |
3396 substitute I1 if we have it. */ | 3423 substitute I1 if we have it. */ |
3397 | 3424 |
3398 if (i1 && GET_CODE (newpat) != CLOBBER) | 3425 if (i1 && GET_CODE (newpat) != CLOBBER) |
3399 { | 3426 { |
3400 /* Check that an autoincrement side-effect on I1 has not been lost. | 3427 /* Before we can do this substitution, we must redo the test done |
3401 This happens if I1DEST is mentioned in I2 and dies there, and | 3428 above (see detailed comments there) that ensures I1DEST isn't |
3402 has disappeared from the new pattern. */ | 3429 mentioned in any SETs in NEWPAT that are field assignments. */ |
3403 if ((FIND_REG_INC_NOTE (i1, NULL_RTX) != 0 | 3430 if (!combinable_i3pat (NULL, &newpat, i1dest, NULL_RTX, NULL_RTX, |
3404 && i1_feeds_i2_n | 3431 0, 0, 0)) |
3405 && dead_or_set_p (i2, i1dest) | |
3406 && !reg_overlap_mentioned_p (i1dest, newpat)) | |
3407 /* Before we can do this substitution, we must redo the test done | |
3408 above (see detailed comments there) that ensures I1DEST isn't | |
3409 mentioned in any SETs in NEWPAT that are field assignments. */ | |
3410 || !combinable_i3pat (NULL, &newpat, i1dest, NULL_RTX, NULL_RTX, | |
3411 0, 0, 0)) | |
3412 { | 3432 { |
3413 undo_all (); | 3433 undo_all (); |
3414 return 0; | 3434 return 0; |
3415 } | 3435 } |
3416 | 3436 |
3436 | 3456 |
3437 /* Likewise for I0 if we have it. */ | 3457 /* Likewise for I0 if we have it. */ |
3438 | 3458 |
3439 if (i0 && GET_CODE (newpat) != CLOBBER) | 3459 if (i0 && GET_CODE (newpat) != CLOBBER) |
3440 { | 3460 { |
3441 if ((FIND_REG_INC_NOTE (i0, NULL_RTX) != 0 | 3461 if (!combinable_i3pat (NULL, &newpat, i0dest, NULL_RTX, NULL_RTX, |
3442 && ((i0_feeds_i2_n && dead_or_set_p (i2, i0dest)) | 3462 0, 0, 0)) |
3443 || (i0_feeds_i1_n && dead_or_set_p (i1, i0dest))) | |
3444 && !reg_overlap_mentioned_p (i0dest, newpat)) | |
3445 || !combinable_i3pat (NULL, &newpat, i0dest, NULL_RTX, NULL_RTX, | |
3446 0, 0, 0)) | |
3447 { | 3463 { |
3448 undo_all (); | 3464 undo_all (); |
3449 return 0; | 3465 return 0; |
3450 } | 3466 } |
3451 | 3467 |
3460 | 3476 |
3461 n_occurrences = 0; | 3477 n_occurrences = 0; |
3462 subst_low_luid = DF_INSN_LUID (i0); | 3478 subst_low_luid = DF_INSN_LUID (i0); |
3463 newpat = subst (newpat, i0dest, i0src, 0, 0, 0); | 3479 newpat = subst (newpat, i0dest, i0src, 0, 0, 0); |
3464 substed_i0 = 1; | 3480 substed_i0 = 1; |
3481 } | |
3482 | |
3483 if (n_auto_inc) | |
3484 { | |
3485 int new_n_auto_inc = 0; | |
3486 for_each_inc_dec (newpat, count_auto_inc, &new_n_auto_inc); | |
3487 | |
3488 if (n_auto_inc != new_n_auto_inc) | |
3489 { | |
3490 if (dump_file && (dump_flags & TDF_DETAILS)) | |
3491 fprintf (dump_file, "Number of auto_inc expressions changed\n"); | |
3492 undo_all (); | |
3493 return 0; | |
3494 } | |
3465 } | 3495 } |
3466 | 3496 |
3467 /* Fail if an autoincrement side-effect has been duplicated. Be careful | 3497 /* Fail if an autoincrement side-effect has been duplicated. Be careful |
3468 to count all the ways that I2SRC and I1SRC can be used. */ | 3498 to count all the ways that I2SRC and I1SRC can be used. */ |
3469 if ((FIND_REG_INC_NOTE (i2, NULL_RTX) != 0 | 3499 if ((FIND_REG_INC_NOTE (i2, NULL_RTX) != 0 |
4701 | 4731 |
4702 /* Update reg_stat[].nonzero_bits et al for any changes that may have | 4732 /* Update reg_stat[].nonzero_bits et al for any changes that may have |
4703 been made to this insn. The order is important, because newi2pat | 4733 been made to this insn. The order is important, because newi2pat |
4704 can affect nonzero_bits of newpat. */ | 4734 can affect nonzero_bits of newpat. */ |
4705 if (newi2pat) | 4735 if (newi2pat) |
4706 note_stores (newi2pat, set_nonzero_bits_and_sign_copies, NULL); | 4736 note_pattern_stores (newi2pat, set_nonzero_bits_and_sign_copies, NULL); |
4707 note_stores (newpat, set_nonzero_bits_and_sign_copies, NULL); | 4737 note_pattern_stores (newpat, set_nonzero_bits_and_sign_copies, NULL); |
4708 } | 4738 } |
4709 | 4739 |
4710 if (undobuf.other_insn != NULL_RTX) | 4740 if (undobuf.other_insn != NULL_RTX) |
4711 { | 4741 { |
4712 if (dump_file) | 4742 if (dump_file) |
4943 XEXP (x, 0))); | 4973 XEXP (x, 0))); |
4944 return &XEXP (XEXP (x, 0), 0); | 4974 return &XEXP (XEXP (x, 0), 0); |
4945 } | 4975 } |
4946 | 4976 |
4947 /* If we have a PLUS whose second operand is a constant and the | 4977 /* If we have a PLUS whose second operand is a constant and the |
4948 address is not valid, perhaps will can split it up using | 4978 address is not valid, perhaps we can split it up using |
4949 the machine-specific way to split large constants. We use | 4979 the machine-specific way to split large constants. We use |
4950 the first pseudo-reg (one of the virtual regs) as a placeholder; | 4980 the first pseudo-reg (one of the virtual regs) as a placeholder; |
4951 it will not remain in the result. */ | 4981 it will not remain in the result. */ |
4952 if (GET_CODE (XEXP (x, 0)) == PLUS | 4982 if (GET_CODE (XEXP (x, 0)) == PLUS |
4953 && CONST_INT_P (XEXP (XEXP (x, 0), 1)) | 4983 && CONST_INT_P (XEXP (XEXP (x, 0), 1)) |
4958 rtx_insn *seq = combine_split_insns (gen_rtx_SET (reg, XEXP (x, 0)), | 4988 rtx_insn *seq = combine_split_insns (gen_rtx_SET (reg, XEXP (x, 0)), |
4959 subst_insn); | 4989 subst_insn); |
4960 | 4990 |
4961 /* This should have produced two insns, each of which sets our | 4991 /* This should have produced two insns, each of which sets our |
4962 placeholder. If the source of the second is a valid address, | 4992 placeholder. If the source of the second is a valid address, |
4963 we can make put both sources together and make a split point | 4993 we can put both sources together and make a split point |
4964 in the middle. */ | 4994 in the middle. */ |
4965 | 4995 |
4966 if (seq | 4996 if (seq |
4967 && NEXT_INSN (seq) != NULL_RTX | 4997 && NEXT_INSN (seq) != NULL_RTX |
4968 && NEXT_INSN (NEXT_INSN (seq)) == NULL_RTX | 4998 && NEXT_INSN (NEXT_INSN (seq)) == NULL_RTX |
4999 SUBST (XEXP (x, 0), src2); | 5029 SUBST (XEXP (x, 0), src2); |
5000 return split; | 5030 return split; |
5001 } | 5031 } |
5002 } | 5032 } |
5003 | 5033 |
5034 /* If that didn't work and we have a nested plus, like: | |
5035 ((REG1 * CONST1) + REG2) + CONST2 and (REG1 + REG2) + CONST2 | |
5036 is valid address, try to split (REG1 * CONST1). */ | |
5037 if (GET_CODE (XEXP (XEXP (x, 0), 0)) == PLUS | |
5038 && !OBJECT_P (XEXP (XEXP (XEXP (x, 0), 0), 0)) | |
5039 && OBJECT_P (XEXP (XEXP (XEXP (x, 0), 0), 1)) | |
5040 && ! (GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == SUBREG | |
5041 && OBJECT_P (SUBREG_REG (XEXP (XEXP (XEXP (x, 0), | |
5042 0), 0))))) | |
5043 { | |
5044 rtx tem = XEXP (XEXP (XEXP (x, 0), 0), 0); | |
5045 XEXP (XEXP (XEXP (x, 0), 0), 0) = reg; | |
5046 if (memory_address_addr_space_p (GET_MODE (x), XEXP (x, 0), | |
5047 MEM_ADDR_SPACE (x))) | |
5048 { | |
5049 XEXP (XEXP (XEXP (x, 0), 0), 0) = tem; | |
5050 return &XEXP (XEXP (XEXP (x, 0), 0), 0); | |
5051 } | |
5052 XEXP (XEXP (XEXP (x, 0), 0), 0) = tem; | |
5053 } | |
5054 else if (GET_CODE (XEXP (XEXP (x, 0), 0)) == PLUS | |
5055 && OBJECT_P (XEXP (XEXP (XEXP (x, 0), 0), 0)) | |
5056 && !OBJECT_P (XEXP (XEXP (XEXP (x, 0), 0), 1)) | |
5057 && ! (GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 1)) == SUBREG | |
5058 && OBJECT_P (SUBREG_REG (XEXP (XEXP (XEXP (x, 0), | |
5059 0), 1))))) | |
5060 { | |
5061 rtx tem = XEXP (XEXP (XEXP (x, 0), 0), 1); | |
5062 XEXP (XEXP (XEXP (x, 0), 0), 1) = reg; | |
5063 if (memory_address_addr_space_p (GET_MODE (x), XEXP (x, 0), | |
5064 MEM_ADDR_SPACE (x))) | |
5065 { | |
5066 XEXP (XEXP (XEXP (x, 0), 0), 1) = tem; | |
5067 return &XEXP (XEXP (XEXP (x, 0), 0), 1); | |
5068 } | |
5069 XEXP (XEXP (XEXP (x, 0), 0), 1) = tem; | |
5070 } | |
5071 | |
5004 /* If that didn't work, perhaps the first operand is complex and | 5072 /* If that didn't work, perhaps the first operand is complex and |
5005 needs to be computed separately, so make a split point there. | 5073 needs to be computed separately, so make a split point there. |
5006 This will occur on machines that just support REG + CONST | 5074 This will occur on machines that just support REG + CONST |
5007 and have a constant moved through some previous computation. */ | 5075 and have a constant moved through some previous computation. */ |
5008 | 5076 if (!OBJECT_P (XEXP (XEXP (x, 0), 0)) |
5009 else if (!OBJECT_P (XEXP (XEXP (x, 0), 0)) | 5077 && ! (GET_CODE (XEXP (XEXP (x, 0), 0)) == SUBREG |
5010 && ! (GET_CODE (XEXP (XEXP (x, 0), 0)) == SUBREG | 5078 && OBJECT_P (SUBREG_REG (XEXP (XEXP (x, 0), 0))))) |
5011 && OBJECT_P (SUBREG_REG (XEXP (XEXP (x, 0), 0))))) | |
5012 return &XEXP (XEXP (x, 0), 0); | 5079 return &XEXP (XEXP (x, 0), 0); |
5013 } | 5080 } |
5014 | 5081 |
5015 /* If we have a PLUS whose first operand is complex, try computing it | 5082 /* If we have a PLUS whose first operand is complex, try computing it |
5016 separately by making a split there. */ | 5083 separately by making a split there. */ |
5611 if (! x) | 5678 if (! x) |
5612 x = gen_rtx_CLOBBER (mode, const0_rtx); | 5679 x = gen_rtx_CLOBBER (mode, const0_rtx); |
5613 } | 5680 } |
5614 else if (CONST_SCALAR_INT_P (new_rtx) | 5681 else if (CONST_SCALAR_INT_P (new_rtx) |
5615 && (GET_CODE (x) == ZERO_EXTEND | 5682 && (GET_CODE (x) == ZERO_EXTEND |
5683 || GET_CODE (x) == SIGN_EXTEND | |
5616 || GET_CODE (x) == FLOAT | 5684 || GET_CODE (x) == FLOAT |
5617 || GET_CODE (x) == UNSIGNED_FLOAT)) | 5685 || GET_CODE (x) == UNSIGNED_FLOAT)) |
5618 { | 5686 { |
5619 x = simplify_unary_operation (GET_CODE (x), GET_MODE (x), | 5687 x = simplify_unary_operation (GET_CODE (x), GET_MODE (x), |
5620 new_rtx, | 5688 new_rtx, |
5832 x = simplify_gen_unary (NEG, mode, | 5900 x = simplify_gen_unary (NEG, mode, |
5833 simplify_gen_relational (reversed, | 5901 simplify_gen_relational (reversed, |
5834 mode, VOIDmode, | 5902 mode, VOIDmode, |
5835 cond, cop1), | 5903 cond, cop1), |
5836 mode); | 5904 mode); |
5837 else | |
5838 return gen_rtx_IF_THEN_ELSE (mode, | |
5839 simplify_gen_relational (cond_code, | |
5840 mode, | |
5841 VOIDmode, | |
5842 cond, | |
5843 cop1), | |
5844 true_rtx, false_rtx); | |
5845 | 5905 |
5846 code = GET_CODE (x); | 5906 code = GET_CODE (x); |
5847 op0_mode = VOIDmode; | 5907 op0_mode = VOIDmode; |
5848 } | 5908 } |
5849 } | 5909 } |
5939 && (GET_MODE_PRECISION (int_mode) | 5999 && (GET_MODE_PRECISION (int_mode) |
5940 < GET_MODE_PRECISION (int_op0_mode)) | 6000 < GET_MODE_PRECISION (int_op0_mode)) |
5941 && known_eq (subreg_lowpart_offset (int_mode, int_op0_mode), | 6001 && known_eq (subreg_lowpart_offset (int_mode, int_op0_mode), |
5942 SUBREG_BYTE (x)) | 6002 SUBREG_BYTE (x)) |
5943 && HWI_COMPUTABLE_MODE_P (int_op0_mode) | 6003 && HWI_COMPUTABLE_MODE_P (int_op0_mode) |
5944 && (nonzero_bits (SUBREG_REG (x), int_op0_mode) | 6004 && ((nonzero_bits (SUBREG_REG (x), int_op0_mode) |
5945 & GET_MODE_MASK (int_mode)) == 0) | 6005 & GET_MODE_MASK (int_mode)) == 0) |
6006 && !side_effects_p (SUBREG_REG (x))) | |
5946 return CONST0_RTX (int_mode); | 6007 return CONST0_RTX (int_mode); |
5947 } | 6008 } |
5948 | 6009 |
5949 /* Don't change the mode of the MEM if that would change the meaning | 6010 /* Don't change the mode of the MEM if that would change the meaning |
5950 of the address. */ | 6011 of the address. */ |
6522 || (GET_CODE (true_rtx) == SUBREG && OBJECT_P (SUBREG_REG (true_rtx)) | 6583 || (GET_CODE (true_rtx) == SUBREG && OBJECT_P (SUBREG_REG (true_rtx)) |
6523 && !OBJECT_P (false_rtx)) | 6584 && !OBJECT_P (false_rtx)) |
6524 || reg_mentioned_p (true_rtx, false_rtx) | 6585 || reg_mentioned_p (true_rtx, false_rtx) |
6525 || rtx_equal_p (false_rtx, XEXP (cond, 0)))) | 6586 || rtx_equal_p (false_rtx, XEXP (cond, 0)))) |
6526 { | 6587 { |
6527 true_code = reversed_comparison_code (cond, NULL); | |
6528 SUBST (XEXP (x, 0), reversed_comparison (cond, GET_MODE (cond))); | 6588 SUBST (XEXP (x, 0), reversed_comparison (cond, GET_MODE (cond))); |
6529 SUBST (XEXP (x, 1), false_rtx); | 6589 SUBST (XEXP (x, 1), false_rtx); |
6530 SUBST (XEXP (x, 2), true_rtx); | 6590 SUBST (XEXP (x, 2), true_rtx); |
6531 | 6591 |
6532 std::swap (true_rtx, false_rtx); | 6592 std::swap (true_rtx, false_rtx); |
7633 % (STRICT_ALIGNMENT ? GET_MODE_ALIGNMENT (tmode) | 7693 % (STRICT_ALIGNMENT ? GET_MODE_ALIGNMENT (tmode) |
7634 : BITS_PER_UNIT)) == 0 | 7694 : BITS_PER_UNIT)) == 0 |
7635 /* We can't do this if we are widening INNER_MODE (it | 7695 /* We can't do this if we are widening INNER_MODE (it |
7636 may not be aligned, for one thing). */ | 7696 may not be aligned, for one thing). */ |
7637 && !paradoxical_subreg_p (tmode, inner_mode) | 7697 && !paradoxical_subreg_p (tmode, inner_mode) |
7698 && known_le (pos + len, GET_MODE_PRECISION (is_mode)) | |
7638 && (inner_mode == tmode | 7699 && (inner_mode == tmode |
7639 || (! mode_dependent_address_p (XEXP (inner, 0), | 7700 || (! mode_dependent_address_p (XEXP (inner, 0), |
7640 MEM_ADDR_SPACE (inner)) | 7701 MEM_ADDR_SPACE (inner)) |
7641 && ! MEM_VOLATILE_P (inner)))))) | 7702 && ! MEM_VOLATILE_P (inner)))))) |
7642 { | 7703 { |
7759 and their respective operands. | 7820 and their respective operands. |
7760 | 7821 |
7761 For memory, assume that the desired extraction_mode and pos_mode | 7822 For memory, assume that the desired extraction_mode and pos_mode |
7762 are the same as for a register operation, since at present we don't | 7823 are the same as for a register operation, since at present we don't |
7763 have named patterns for aligned memory structures. */ | 7824 have named patterns for aligned memory structures. */ |
7764 struct extraction_insn insn; | 7825 class extraction_insn insn; |
7765 unsigned int inner_size; | 7826 unsigned int inner_size; |
7766 if (GET_MODE_BITSIZE (inner_mode).is_constant (&inner_size) | 7827 if (GET_MODE_BITSIZE (inner_mode).is_constant (&inner_size) |
7767 && get_best_reg_extraction_insn (&insn, pattern, inner_size, mode)) | 7828 && get_best_reg_extraction_insn (&insn, pattern, inner_size, mode)) |
7768 { | 7829 { |
7769 wanted_inner_reg_mode = insn.struct_mode.require (); | 7830 wanted_inner_reg_mode = insn.struct_mode.require (); |
7774 /* Never narrow an object, since that might not be safe. */ | 7835 /* Never narrow an object, since that might not be safe. */ |
7775 | 7836 |
7776 if (mode != VOIDmode | 7837 if (mode != VOIDmode |
7777 && partial_subreg_p (extraction_mode, mode)) | 7838 && partial_subreg_p (extraction_mode, mode)) |
7778 extraction_mode = mode; | 7839 extraction_mode = mode; |
7840 | |
7841 /* Punt if len is too large for extraction_mode. */ | |
7842 if (maybe_gt (len, GET_MODE_PRECISION (extraction_mode))) | |
7843 return NULL_RTX; | |
7779 | 7844 |
7780 if (!MEM_P (inner)) | 7845 if (!MEM_P (inner)) |
7781 wanted_inner_mode = wanted_inner_reg_mode; | 7846 wanted_inner_mode = wanted_inner_reg_mode; |
7782 else | 7847 else |
7783 { | 7848 { |
8863 | 8928 |
8864 case MINUS: | 8929 case MINUS: |
8865 /* If X is (minus C Y) where C's least set bit is larger than any bit | 8930 /* If X is (minus C Y) where C's least set bit is larger than any bit |
8866 in the mask, then we may replace with (neg Y). */ | 8931 in the mask, then we may replace with (neg Y). */ |
8867 if (poly_int_rtx_p (XEXP (x, 0), &const_op0) | 8932 if (poly_int_rtx_p (XEXP (x, 0), &const_op0) |
8868 && (unsigned HOST_WIDE_INT) known_alignment (const_op0) > mask) | 8933 && known_alignment (poly_uint64 (const_op0)) > mask) |
8869 { | 8934 { |
8870 x = simplify_gen_unary (NEG, xmode, XEXP (x, 1), xmode); | 8935 x = simplify_gen_unary (NEG, xmode, XEXP (x, 1), xmode); |
8871 return force_to_mode (x, mode, mask, next_select); | 8936 return force_to_mode (x, mode, mask, next_select); |
8872 } | 8937 } |
8873 | 8938 |
10185 return x; | 10250 return x; |
10186 } | 10251 } |
10187 | 10252 |
10188 /* Given a REG X of mode XMODE, compute which bits in X can be nonzero. | 10253 /* Given a REG X of mode XMODE, compute which bits in X can be nonzero. |
10189 We don't care about bits outside of those defined in MODE. | 10254 We don't care about bits outside of those defined in MODE. |
10255 We DO care about all the bits in MODE, even if XMODE is smaller than MODE. | |
10190 | 10256 |
10191 For most X this is simply GET_MODE_MASK (GET_MODE (MODE)), but if X is | 10257 For most X this is simply GET_MODE_MASK (GET_MODE (MODE)), but if X is |
10192 a shift, AND, or zero_extract, we can do better. */ | 10258 a shift, AND, or zero_extract, we can do better. */ |
10193 | 10259 |
10194 static rtx | 10260 static rtx |
11744 return adjust_address_nv (x, omode, offset); | 11810 return adjust_address_nv (x, omode, offset); |
11745 } | 11811 } |
11746 | 11812 |
11747 /* If X is a comparison operator, rewrite it in a new mode. This | 11813 /* If X is a comparison operator, rewrite it in a new mode. This |
11748 probably won't match, but may allow further simplifications. */ | 11814 probably won't match, but may allow further simplifications. */ |
11749 else if (COMPARISON_P (x)) | 11815 else if (COMPARISON_P (x) |
11816 && SCALAR_INT_MODE_P (imode) | |
11817 && SCALAR_INT_MODE_P (omode)) | |
11750 return gen_rtx_fmt_ee (GET_CODE (x), omode, XEXP (x, 0), XEXP (x, 1)); | 11818 return gen_rtx_fmt_ee (GET_CODE (x), omode, XEXP (x, 0), XEXP (x, 1)); |
11751 | 11819 |
11752 /* If we couldn't simplify X any other way, just enclose it in a | 11820 /* If we couldn't simplify X any other way, just enclose it in a |
11753 SUBREG. Normally, this SUBREG won't match, but some patterns may | 11821 SUBREG. Normally, this SUBREG won't match, but some patterns may |
11754 include an explicit SUBREG or we may simplify it further in combine. */ | 11822 include an explicit SUBREG or we may simplify it further in combine. */ |
12340 /* If we are doing a < 0 or >= 0 comparison, it means we are testing | 12408 /* If we are doing a < 0 or >= 0 comparison, it means we are testing |
12341 a particular bit. Convert it to an AND of a constant of that | 12409 a particular bit. Convert it to an AND of a constant of that |
12342 bit. This will be converted into a ZERO_EXTRACT. */ | 12410 bit. This will be converted into a ZERO_EXTRACT. */ |
12343 if (const_op == 0 && sign_bit_comparison_p | 12411 if (const_op == 0 && sign_bit_comparison_p |
12344 && CONST_INT_P (XEXP (op0, 1)) | 12412 && CONST_INT_P (XEXP (op0, 1)) |
12345 && mode_width <= HOST_BITS_PER_WIDE_INT) | 12413 && mode_width <= HOST_BITS_PER_WIDE_INT |
12414 && UINTVAL (XEXP (op0, 1)) < mode_width) | |
12346 { | 12415 { |
12347 op0 = simplify_and_const_int (NULL_RTX, mode, XEXP (op0, 0), | 12416 op0 = simplify_and_const_int (NULL_RTX, mode, XEXP (op0, 0), |
12348 (HOST_WIDE_INT_1U | 12417 (HOST_WIDE_INT_1U |
12349 << (mode_width - 1 | 12418 << (mode_width - 1 |
12350 - INTVAL (XEXP (op0, 1))))); | 12419 - INTVAL (XEXP (op0, 1))))); |
13213 tem = XEXP (tem, 0); | 13282 tem = XEXP (tem, 0); |
13214 else if (count_occurrences (value, reg, 1) >= 2) | 13283 else if (count_occurrences (value, reg, 1) >= 2) |
13215 { | 13284 { |
13216 /* If there are two or more occurrences of REG in VALUE, | 13285 /* If there are two or more occurrences of REG in VALUE, |
13217 prevent the value from growing too much. */ | 13286 prevent the value from growing too much. */ |
13218 if (count_rtxs (tem) > MAX_LAST_VALUE_RTL) | 13287 if (count_rtxs (tem) > param_max_last_value_rtl) |
13219 tem = gen_rtx_CLOBBER (GET_MODE (tem), const0_rtx); | 13288 tem = gen_rtx_CLOBBER (GET_MODE (tem), const0_rtx); |
13220 } | 13289 } |
13221 | 13290 |
13222 value = replace_rtx (copy_rtx (value), reg, tem); | 13291 value = replace_rtx (copy_rtx (value), reg, tem); |
13223 } | 13292 } |
13329 && known_le (GET_MODE_PRECISION (GET_MODE (dest)), | 13398 && known_le (GET_MODE_PRECISION (GET_MODE (dest)), |
13330 BITS_PER_WORD) | 13399 BITS_PER_WORD) |
13331 && subreg_lowpart_p (SET_DEST (setter))) | 13400 && subreg_lowpart_p (SET_DEST (setter))) |
13332 record_value_for_reg (dest, record_dead_insn, | 13401 record_value_for_reg (dest, record_dead_insn, |
13333 WORD_REGISTER_OPERATIONS | 13402 WORD_REGISTER_OPERATIONS |
13403 && word_register_operation_p (SET_SRC (setter)) | |
13334 && paradoxical_subreg_p (SET_DEST (setter)) | 13404 && paradoxical_subreg_p (SET_DEST (setter)) |
13335 ? SET_SRC (setter) | 13405 ? SET_SRC (setter) |
13336 : gen_lowpart (GET_MODE (dest), | 13406 : gen_lowpart (GET_MODE (dest), |
13337 SET_SRC (setter))); | 13407 SET_SRC (setter))); |
13338 else if (GET_CODE (setter) == CLOBBER_HIGH) | |
13339 { | |
13340 reg_stat_type *rsp = ®_stat[REGNO (dest)]; | |
13341 if (rsp->last_set_value | |
13342 && reg_is_clobbered_by_clobber_high | |
13343 (REGNO (dest), GET_MODE (rsp->last_set_value), | |
13344 XEXP (setter, 0))) | |
13345 record_value_for_reg (dest, NULL, NULL_RTX); | |
13346 } | |
13347 else | 13408 else |
13348 record_value_for_reg (dest, record_dead_insn, NULL_RTX); | 13409 record_value_for_reg (dest, record_dead_insn, NULL_RTX); |
13349 } | 13410 } |
13350 else if (MEM_P (dest) | 13411 else if (MEM_P (dest) |
13351 /* Ignore pushes, they clobber nothing. */ | 13412 /* Ignore pushes, they clobber nothing. */ |
13389 record_value_for_reg (XEXP (link, 0), insn, NULL_RTX); | 13450 record_value_for_reg (XEXP (link, 0), insn, NULL_RTX); |
13390 } | 13451 } |
13391 | 13452 |
13392 if (CALL_P (insn)) | 13453 if (CALL_P (insn)) |
13393 { | 13454 { |
13455 HARD_REG_SET callee_clobbers | |
13456 = insn_callee_abi (insn).full_and_partial_reg_clobbers (); | |
13394 hard_reg_set_iterator hrsi; | 13457 hard_reg_set_iterator hrsi; |
13395 EXECUTE_IF_SET_IN_HARD_REG_SET (regs_invalidated_by_call, 0, i, hrsi) | 13458 EXECUTE_IF_SET_IN_HARD_REG_SET (callee_clobbers, 0, i, hrsi) |
13396 { | 13459 { |
13397 reg_stat_type *rsp; | 13460 reg_stat_type *rsp; |
13398 | 13461 |
13462 /* ??? We could try to preserve some information from the last | |
13463 set of register I if the call doesn't actually clobber | |
13464 (reg:last_set_mode I), which might be true for ABIs with | |
13465 partial clobbers. However, it would be difficult to | |
13466 update last_set_nonzero_bits and last_sign_bit_copies | |
13467 to account for the part of I that actually was clobbered. | |
13468 It wouldn't help much anyway, since we rarely see this | |
13469 situation before RA. */ | |
13399 rsp = ®_stat[i]; | 13470 rsp = ®_stat[i]; |
13400 rsp->last_set_invalid = 1; | 13471 rsp->last_set_invalid = 1; |
13401 rsp->last_set = insn; | 13472 rsp->last_set = insn; |
13402 rsp->last_set_value = 0; | 13473 rsp->last_set_value = 0; |
13403 rsp->last_set_mode = VOIDmode; | 13474 rsp->last_set_mode = VOIDmode; |
13411 | 13482 |
13412 /* We can't combine into a call pattern. Remember, though, that | 13483 /* We can't combine into a call pattern. Remember, though, that |
13413 the return value register is set at this LUID. We could | 13484 the return value register is set at this LUID. We could |
13414 still replace a register with the return value from the | 13485 still replace a register with the return value from the |
13415 wrong subroutine call! */ | 13486 wrong subroutine call! */ |
13416 note_stores (PATTERN (insn), record_dead_and_set_regs_1, NULL_RTX); | 13487 note_stores (insn, record_dead_and_set_regs_1, NULL_RTX); |
13417 } | 13488 } |
13418 else | 13489 else |
13419 note_stores (PATTERN (insn), record_dead_and_set_regs_1, insn); | 13490 note_stores (insn, record_dead_and_set_regs_1, insn); |
13420 } | 13491 } |
13421 | 13492 |
13422 /* If a SUBREG has the promoted bit set, it is in fact a property of the | 13493 /* If a SUBREG has the promoted bit set, it is in fact a property of the |
13423 register present in the SUBREG, so for each such SUBREG go back and | 13494 register present in the SUBREG, so for each such SUBREG go back and |
13424 adjust nonzero and sign bit information of the registers that are | 13495 adjust nonzero and sign bit information of the registers that are |
13777 unsigned int regno, endregno; | 13848 unsigned int regno, endregno; |
13778 | 13849 |
13779 if (!REG_P (dest)) | 13850 if (!REG_P (dest)) |
13780 return; | 13851 return; |
13781 | 13852 |
13782 if (GET_CODE (x) == CLOBBER_HIGH | |
13783 && !reg_is_clobbered_by_clobber_high (reg_dead_reg, XEXP (x, 0))) | |
13784 return; | |
13785 | |
13786 regno = REGNO (dest); | 13853 regno = REGNO (dest); |
13787 endregno = END_REGNO (dest); | 13854 endregno = END_REGNO (dest); |
13788 if (reg_dead_endregno > regno && reg_dead_regno < endregno) | 13855 if (reg_dead_endregno > regno && reg_dead_regno < endregno) |
13789 reg_dead_flag = (GET_CODE (x) == CLOBBER) ? 1 : -1; | 13856 reg_dead_flag = (GET_CODE (x) == CLOBBER) ? 1 : -1; |
13790 } | 13857 } |
13828 if (INSN_P (insn)) | 13895 if (INSN_P (insn)) |
13829 { | 13896 { |
13830 if (find_regno_note (insn, REG_UNUSED, reg_dead_regno)) | 13897 if (find_regno_note (insn, REG_UNUSED, reg_dead_regno)) |
13831 return 1; | 13898 return 1; |
13832 | 13899 |
13833 note_stores (PATTERN (insn), reg_dead_at_p_1, NULL); | 13900 note_stores (insn, reg_dead_at_p_1, NULL); |
13834 if (reg_dead_flag) | 13901 if (reg_dead_flag) |
13835 return reg_dead_flag == 1 ? 1 : 0; | 13902 return reg_dead_flag == 1 ? 1 : 0; |
13836 | 13903 |
13837 if (find_regno_note (insn, REG_DEAD, reg_dead_regno)) | 13904 if (find_regno_note (insn, REG_DEAD, reg_dead_regno)) |
13838 return 1; | 13905 return 1; |
14954 continue; | 15021 continue; |
14955 | 15022 |
14956 rtx set = single_set (insn); | 15023 rtx set = single_set (insn); |
14957 if (!set) | 15024 if (!set) |
14958 continue; | 15025 continue; |
15026 | |
15027 rtx dest = SET_DEST (set); | |
15028 if (!(REG_P (dest) && !HARD_REGISTER_P (dest))) | |
15029 continue; | |
15030 | |
14959 rtx src = SET_SRC (set); | 15031 rtx src = SET_SRC (set); |
14960 rtx dest = SET_DEST (set); | |
14961 if (GET_CODE (src) == SUBREG) | |
14962 src = SUBREG_REG (src); | |
14963 if (!(REG_P (src) && HARD_REGISTER_P (src))) | 15032 if (!(REG_P (src) && HARD_REGISTER_P (src))) |
14964 continue; | 15033 continue; |
14965 if (TEST_HARD_REG_BIT (fixed_reg_set, REGNO (src))) | 15034 if (TEST_HARD_REG_BIT (fixed_reg_set, REGNO (src))) |
14966 continue; | 15035 continue; |
14967 | 15036 |
14968 rtx new_reg = gen_reg_rtx (GET_MODE (dest)); | 15037 rtx new_reg = gen_reg_rtx (GET_MODE (dest)); |
14969 rtx_insn *insn1 = gen_move_insn (new_reg, src); | 15038 rtx_insn *new_insn = gen_move_insn (new_reg, src); |
14970 rtx_insn *insn2 = gen_move_insn (dest, new_reg); | 15039 SET_SRC (set) = new_reg; |
14971 emit_insn_after (insn1, insn); | 15040 emit_insn_before (new_insn, insn); |
14972 emit_insn_after (insn2, insn1); | 15041 df_insn_rescan (insn); |
14973 delete_insn (insn); | |
14974 | |
14975 insn = insn2; | |
14976 } | 15042 } |
14977 } | 15043 } |
14978 } | 15044 } |
14979 | 15045 |
14980 /* Try combining insns through substitution. */ | 15046 /* Try combining insns through substitution. */ |