comparison gcc/cse.c @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents 77e2b8dfacca
children f6334be47118
comparison
equal deleted inserted replaced
56:3c8a44c06a95 63:b7f97abdc517
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see 19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */ 20 <http://www.gnu.org/licenses/>. */
21 21
22 #include "config.h" 22 #include "config.h"
23 /* stdio.h must precede rtl.h for FFS. */
24 #include "system.h" 23 #include "system.h"
25 #include "coretypes.h" 24 #include "coretypes.h"
26 #include "tm.h" 25 #include "tm.h"
27 #include "rtl.h" 26 #include "rtl.h"
28 #include "tm_p.h" 27 #include "tm_p.h"
29 #include "hard-reg-set.h" 28 #include "hard-reg-set.h"
30 #include "regs.h" 29 #include "regs.h"
31 #include "basic-block.h" 30 #include "basic-block.h"
32 #include "flags.h" 31 #include "flags.h"
33 #include "real.h"
34 #include "insn-config.h" 32 #include "insn-config.h"
35 #include "recog.h" 33 #include "recog.h"
36 #include "function.h" 34 #include "function.h"
37 #include "expr.h" 35 #include "expr.h"
38 #include "toplev.h" 36 #include "toplev.h"
684 682
685 if (! CHEAP_REGNO (regno)) 683 if (! CHEAP_REGNO (regno))
686 { 684 {
687 if (regno < FIRST_PSEUDO_REGISTER) 685 if (regno < FIRST_PSEUDO_REGISTER)
688 { 686 {
689 if (SMALL_REGISTER_CLASSES) 687 if (targetm.small_register_classes_for_mode_p (GET_MODE (x)))
690 return 1; 688 return 1;
691 *cost_p += 2; 689 *cost_p += 2;
692 } 690 }
693 else 691 else
694 *cost_p += 1; 692 *cost_p += 1;
2302 record = false; 2300 record = false;
2303 else if (fixed_regs[regno]) 2301 else if (fixed_regs[regno])
2304 record = true; 2302 record = true;
2305 else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_CC) 2303 else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_CC)
2306 record = true; 2304 record = true;
2307 else if (SMALL_REGISTER_CLASSES) 2305 else if (targetm.small_register_classes_for_mode_p (GET_MODE (x)))
2308 record = false; 2306 record = false;
2309 else if (CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (regno))) 2307 else if (CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (regno)))
2310 record = false; 2308 record = false;
2311 else 2309 else
2312 record = true; 2310 record = true;
4434 4432
4435 Nothing in this loop changes the hash table or the register chains. */ 4433 Nothing in this loop changes the hash table or the register chains. */
4436 4434
4437 for (i = 0; i < n_sets; i++) 4435 for (i = 0; i < n_sets; i++)
4438 { 4436 {
4437 bool repeat = false;
4439 rtx src, dest; 4438 rtx src, dest;
4440 rtx src_folded; 4439 rtx src_folded;
4441 struct table_elt *elt = 0, *p; 4440 struct table_elt *elt = 0, *p;
4442 enum machine_mode mode; 4441 enum machine_mode mode;
4443 rtx src_eqv_here; 4442 rtx src_eqv_here;
5027 if (!MEM_P (src) || !MEM_P (dest) 5026 if (!MEM_P (src) || !MEM_P (dest)
5028 || !nonoverlapping_memrefs_p (src, dest)) 5027 || !nonoverlapping_memrefs_p (src, dest))
5029 break; 5028 break;
5030 } 5029 }
5031 5030
5031 /* Try to optimize
5032 (set (reg:M N) (const_int A))
5033 (set (reg:M2 O) (const_int B))
5034 (set (zero_extract:M2 (reg:M N) (const_int C) (const_int D))
5035 (reg:M2 O)). */
5036 if (GET_CODE (SET_DEST (sets[i].rtl)) == ZERO_EXTRACT
5037 && CONST_INT_P (trial)
5038 && CONST_INT_P (XEXP (SET_DEST (sets[i].rtl), 1))
5039 && CONST_INT_P (XEXP (SET_DEST (sets[i].rtl), 2))
5040 && REG_P (XEXP (SET_DEST (sets[i].rtl), 0))
5041 && (GET_MODE_BITSIZE (GET_MODE (SET_DEST (sets[i].rtl)))
5042 >= INTVAL (XEXP (SET_DEST (sets[i].rtl), 1)))
5043 && ((unsigned) INTVAL (XEXP (SET_DEST (sets[i].rtl), 1))
5044 + (unsigned) INTVAL (XEXP (SET_DEST (sets[i].rtl), 2))
5045 <= HOST_BITS_PER_WIDE_INT))
5046 {
5047 rtx dest_reg = XEXP (SET_DEST (sets[i].rtl), 0);
5048 rtx width = XEXP (SET_DEST (sets[i].rtl), 1);
5049 rtx pos = XEXP (SET_DEST (sets[i].rtl), 2);
5050 unsigned int dest_hash = HASH (dest_reg, GET_MODE (dest_reg));
5051 struct table_elt *dest_elt
5052 = lookup (dest_reg, dest_hash, GET_MODE (dest_reg));
5053 rtx dest_cst = NULL;
5054
5055 if (dest_elt)
5056 for (p = dest_elt->first_same_value; p; p = p->next_same_value)
5057 if (p->is_const && CONST_INT_P (p->exp))
5058 {
5059 dest_cst = p->exp;
5060 break;
5061 }
5062 if (dest_cst)
5063 {
5064 HOST_WIDE_INT val = INTVAL (dest_cst);
5065 HOST_WIDE_INT mask;
5066 unsigned int shift;
5067 if (BITS_BIG_ENDIAN)
5068 shift = GET_MODE_BITSIZE (GET_MODE (dest_reg))
5069 - INTVAL (pos) - INTVAL (width);
5070 else
5071 shift = INTVAL (pos);
5072 if (INTVAL (width) == HOST_BITS_PER_WIDE_INT)
5073 mask = ~(HOST_WIDE_INT) 0;
5074 else
5075 mask = ((HOST_WIDE_INT) 1 << INTVAL (width)) - 1;
5076 val &= ~(mask << shift);
5077 val |= (INTVAL (trial) & mask) << shift;
5078 val = trunc_int_for_mode (val, GET_MODE (dest_reg));
5079 validate_unshare_change (insn, &SET_DEST (sets[i].rtl),
5080 dest_reg, 1);
5081 validate_unshare_change (insn, &SET_SRC (sets[i].rtl),
5082 GEN_INT (val), 1);
5083 if (apply_change_group ())
5084 {
5085 rtx note = find_reg_note (insn, REG_EQUAL, NULL_RTX);
5086 if (note)
5087 {
5088 remove_note (insn, note);
5089 df_notes_rescan (insn);
5090 }
5091 src_eqv = NULL_RTX;
5092 src_eqv_elt = NULL;
5093 src_eqv_volatile = 0;
5094 src_eqv_in_memory = 0;
5095 src_eqv_hash = 0;
5096 repeat = true;
5097 break;
5098 }
5099 }
5100 }
5101
5032 /* We don't normally have an insn matching (set (pc) (pc)), so 5102 /* We don't normally have an insn matching (set (pc) (pc)), so
5033 check for this separately here. We will delete such an 5103 check for this separately here. We will delete such an
5034 insn below. 5104 insn below.
5035 5105
5036 For other cases such as a table jump or conditional jump 5106 For other cases such as a table jump or conditional jump
5100 src_folded_force_flag = 1; 5170 src_folded_force_flag = 1;
5101 src_folded = trial; 5171 src_folded = trial;
5102 src_folded_cost = constant_pool_entries_cost; 5172 src_folded_cost = constant_pool_entries_cost;
5103 src_folded_regcost = constant_pool_entries_regcost; 5173 src_folded_regcost = constant_pool_entries_regcost;
5104 } 5174 }
5175 }
5176
5177 /* If we changed the insn too much, handle this set from scratch. */
5178 if (repeat)
5179 {
5180 i--;
5181 continue;
5105 } 5182 }
5106 5183
5107 src = SET_SRC (sets[i].rtl); 5184 src = SET_SRC (sets[i].rtl);
5108 5185
5109 /* In general, it is good to have a SET with SET_SRC == SET_DEST. 5186 /* In general, it is good to have a SET with SET_SRC == SET_DEST.