comparison gcc/optabs.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
1 /* Expand the basic unary and binary arithmetic operations, for GNU compiler. 1 /* Expand the basic unary and binary arithmetic operations, for GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc. 4 Free Software Foundation, Inc.
5 5
6 This file is part of GCC. 6 This file is part of GCC.
7 7
8 GCC is free software; you can redistribute it and/or modify it under 8 GCC is free software; you can redistribute it and/or modify it under
39 #include "optabs.h" 39 #include "optabs.h"
40 #include "libfuncs.h" 40 #include "libfuncs.h"
41 #include "recog.h" 41 #include "recog.h"
42 #include "reload.h" 42 #include "reload.h"
43 #include "ggc.h" 43 #include "ggc.h"
44 #include "real.h"
45 #include "basic-block.h" 44 #include "basic-block.h"
46 #include "target.h" 45 #include "target.h"
47 46
48 /* Each optab contains info on how this target machine 47 /* Each optab contains info on how this target machine
49 can perform a particular operation 48 can perform a particular operation
1125 subword_label = gen_label_rtx (); 1124 subword_label = gen_label_rtx ();
1126 done_label = gen_label_rtx (); 1125 done_label = gen_label_rtx ();
1127 1126
1128 NO_DEFER_POP; 1127 NO_DEFER_POP;
1129 do_compare_rtx_and_jump (cmp1, cmp2, cmp_code, false, op1_mode, 1128 do_compare_rtx_and_jump (cmp1, cmp2, cmp_code, false, op1_mode,
1130 0, 0, subword_label); 1129 0, 0, subword_label, -1);
1131 OK_DEFER_POP; 1130 OK_DEFER_POP;
1132 1131
1133 if (!expand_superword_shift (binoptab, outof_input, superword_op1, 1132 if (!expand_superword_shift (binoptab, outof_input, superword_op1,
1134 outof_target, into_target, 1133 outof_target, into_target,
1135 unsignedp, methods)) 1134 unsignedp, methods))
1387 1386
1388 static rtx 1387 static rtx
1389 avoid_expensive_constant (enum machine_mode mode, optab binoptab, 1388 avoid_expensive_constant (enum machine_mode mode, optab binoptab,
1390 rtx x, bool unsignedp) 1389 rtx x, bool unsignedp)
1391 { 1390 {
1391 bool speed = optimize_insn_for_speed_p ();
1392
1392 if (mode != VOIDmode 1393 if (mode != VOIDmode
1393 && optimize 1394 && optimize
1394 && CONSTANT_P (x) 1395 && CONSTANT_P (x)
1395 && rtx_cost (x, binoptab->code, optimize_insn_for_speed_p ()) 1396 && rtx_cost (x, binoptab->code, speed) > rtx_cost (x, SET, speed))
1396 > COSTS_N_INSNS (1))
1397 { 1397 {
1398 if (CONST_INT_P (x)) 1398 if (CONST_INT_P (x))
1399 { 1399 {
1400 HOST_WIDE_INT intval = trunc_int_for_mode (INTVAL (x), mode); 1400 HOST_WIDE_INT intval = trunc_int_for_mode (INTVAL (x), mode);
1401 if (intval != INTVAL (x)) 1401 if (intval != INTVAL (x))
2925 rtx op0, rtx target) 2925 rtx op0, rtx target)
2926 { 2926 {
2927 const struct real_format *fmt; 2927 const struct real_format *fmt;
2928 int bitpos, word, nwords, i; 2928 int bitpos, word, nwords, i;
2929 enum machine_mode imode; 2929 enum machine_mode imode;
2930 HOST_WIDE_INT hi, lo; 2930 double_int mask;
2931 rtx temp, insns; 2931 rtx temp, insns;
2932 2932
2933 /* The format has to have a simple sign bit. */ 2933 /* The format has to have a simple sign bit. */
2934 fmt = REAL_MODE_FORMAT (mode); 2934 fmt = REAL_MODE_FORMAT (mode);
2935 if (fmt == NULL) 2935 if (fmt == NULL)
2961 word = bitpos / BITS_PER_WORD; 2961 word = bitpos / BITS_PER_WORD;
2962 bitpos = bitpos % BITS_PER_WORD; 2962 bitpos = bitpos % BITS_PER_WORD;
2963 nwords = (GET_MODE_BITSIZE (mode) + BITS_PER_WORD - 1) / BITS_PER_WORD; 2963 nwords = (GET_MODE_BITSIZE (mode) + BITS_PER_WORD - 1) / BITS_PER_WORD;
2964 } 2964 }
2965 2965
2966 if (bitpos < HOST_BITS_PER_WIDE_INT) 2966 mask = double_int_setbit (double_int_zero, bitpos);
2967 {
2968 hi = 0;
2969 lo = (HOST_WIDE_INT) 1 << bitpos;
2970 }
2971 else
2972 {
2973 hi = (HOST_WIDE_INT) 1 << (bitpos - HOST_BITS_PER_WIDE_INT);
2974 lo = 0;
2975 }
2976 if (code == ABS) 2967 if (code == ABS)
2977 lo = ~lo, hi = ~hi; 2968 mask = double_int_not (mask);
2978 2969
2979 if (target == 0 || target == op0) 2970 if (target == 0 || target == op0)
2980 target = gen_reg_rtx (mode); 2971 target = gen_reg_rtx (mode);
2981 2972
2982 if (nwords > 1) 2973 if (nwords > 1)
2990 2981
2991 if (i == word) 2982 if (i == word)
2992 { 2983 {
2993 temp = expand_binop (imode, code == ABS ? and_optab : xor_optab, 2984 temp = expand_binop (imode, code == ABS ? and_optab : xor_optab,
2994 op0_piece, 2985 op0_piece,
2995 immed_double_const (lo, hi, imode), 2986 immed_double_int_const (mask, imode),
2996 targ_piece, 1, OPTAB_LIB_WIDEN); 2987 targ_piece, 1, OPTAB_LIB_WIDEN);
2997 if (temp != targ_piece) 2988 if (temp != targ_piece)
2998 emit_move_insn (targ_piece, temp); 2989 emit_move_insn (targ_piece, temp);
2999 } 2990 }
3000 else 2991 else
3008 } 2999 }
3009 else 3000 else
3010 { 3001 {
3011 temp = expand_binop (imode, code == ABS ? and_optab : xor_optab, 3002 temp = expand_binop (imode, code == ABS ? and_optab : xor_optab,
3012 gen_lowpart (imode, op0), 3003 gen_lowpart (imode, op0),
3013 immed_double_const (lo, hi, imode), 3004 immed_double_int_const (mask, imode),
3014 gen_lowpart (imode, target), 1, OPTAB_LIB_WIDEN); 3005 gen_lowpart (imode, target), 1, OPTAB_LIB_WIDEN);
3015 target = lowpart_subreg_maybe_copy (mode, temp, imode); 3006 target = lowpart_subreg_maybe_copy (mode, temp, imode);
3016 3007
3017 set_unique_reg_note (get_last_insn (), REG_EQUAL, 3008 set_unique_reg_note (get_last_insn (), REG_EQUAL,
3018 gen_rtx_fmt_e (code, mode, copy_rtx (op0))); 3009 gen_rtx_fmt_e (code, mode, copy_rtx (op0)));
3467 3458
3468 emit_move_insn (target, op0); 3459 emit_move_insn (target, op0);
3469 NO_DEFER_POP; 3460 NO_DEFER_POP;
3470 3461
3471 do_compare_rtx_and_jump (target, CONST0_RTX (mode), GE, 0, mode, 3462 do_compare_rtx_and_jump (target, CONST0_RTX (mode), GE, 0, mode,
3472 NULL_RTX, NULL_RTX, op1); 3463 NULL_RTX, NULL_RTX, op1, -1);
3473 3464
3474 op0 = expand_unop (mode, result_unsignedp ? neg_optab : negv_optab, 3465 op0 = expand_unop (mode, result_unsignedp ? neg_optab : negv_optab,
3475 target, target, 0); 3466 target, target, 0);
3476 if (op0 != target) 3467 if (op0 != target)
3477 emit_move_insn (target, op0); 3468 emit_move_insn (target, op0);
3559 sign = gen_reg_rtx (imode); 3550 sign = gen_reg_rtx (imode);
3560 emit_unop_insn (icode, sign, op1, UNKNOWN); 3551 emit_unop_insn (icode, sign, op1, UNKNOWN);
3561 } 3552 }
3562 else 3553 else
3563 { 3554 {
3564 HOST_WIDE_INT hi, lo; 3555 double_int mask;
3565 3556
3566 if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD) 3557 if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
3567 { 3558 {
3568 imode = int_mode_for_mode (mode); 3559 imode = int_mode_for_mode (mode);
3569 if (imode == BLKmode) 3560 if (imode == BLKmode)
3581 word = bitpos / BITS_PER_WORD; 3572 word = bitpos / BITS_PER_WORD;
3582 bitpos = bitpos % BITS_PER_WORD; 3573 bitpos = bitpos % BITS_PER_WORD;
3583 op1 = operand_subword_force (op1, word, mode); 3574 op1 = operand_subword_force (op1, word, mode);
3584 } 3575 }
3585 3576
3586 if (bitpos < HOST_BITS_PER_WIDE_INT) 3577 mask = double_int_setbit (double_int_zero, bitpos);
3587 { 3578
3588 hi = 0;
3589 lo = (HOST_WIDE_INT) 1 << bitpos;
3590 }
3591 else
3592 {
3593 hi = (HOST_WIDE_INT) 1 << (bitpos - HOST_BITS_PER_WIDE_INT);
3594 lo = 0;
3595 }
3596
3597 sign = gen_reg_rtx (imode);
3598 sign = expand_binop (imode, and_optab, op1, 3579 sign = expand_binop (imode, and_optab, op1,
3599 immed_double_const (lo, hi, imode), 3580 immed_double_int_const (mask, imode),
3600 NULL_RTX, 1, OPTAB_LIB_WIDEN); 3581 NULL_RTX, 1, OPTAB_LIB_WIDEN);
3601 } 3582 }
3602 3583
3603 if (!op0_is_abs) 3584 if (!op0_is_abs)
3604 { 3585 {
3638 static rtx 3619 static rtx
3639 expand_copysign_bit (enum machine_mode mode, rtx op0, rtx op1, rtx target, 3620 expand_copysign_bit (enum machine_mode mode, rtx op0, rtx op1, rtx target,
3640 int bitpos, bool op0_is_abs) 3621 int bitpos, bool op0_is_abs)
3641 { 3622 {
3642 enum machine_mode imode; 3623 enum machine_mode imode;
3643 HOST_WIDE_INT hi, lo; 3624 double_int mask;
3644 int word, nwords, i; 3625 int word, nwords, i;
3645 rtx temp, insns; 3626 rtx temp, insns;
3646 3627
3647 if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD) 3628 if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
3648 { 3629 {
3662 word = bitpos / BITS_PER_WORD; 3643 word = bitpos / BITS_PER_WORD;
3663 bitpos = bitpos % BITS_PER_WORD; 3644 bitpos = bitpos % BITS_PER_WORD;
3664 nwords = (GET_MODE_BITSIZE (mode) + BITS_PER_WORD - 1) / BITS_PER_WORD; 3645 nwords = (GET_MODE_BITSIZE (mode) + BITS_PER_WORD - 1) / BITS_PER_WORD;
3665 } 3646 }
3666 3647
3667 if (bitpos < HOST_BITS_PER_WIDE_INT) 3648 mask = double_int_setbit (double_int_zero, bitpos);
3668 {
3669 hi = 0;
3670 lo = (HOST_WIDE_INT) 1 << bitpos;
3671 }
3672 else
3673 {
3674 hi = (HOST_WIDE_INT) 1 << (bitpos - HOST_BITS_PER_WIDE_INT);
3675 lo = 0;
3676 }
3677 3649
3678 if (target == 0 || target == op0 || target == op1) 3650 if (target == 0 || target == op0 || target == op1)
3679 target = gen_reg_rtx (mode); 3651 target = gen_reg_rtx (mode);
3680 3652
3681 if (nwords > 1) 3653 if (nwords > 1)
3688 rtx op0_piece = operand_subword_force (op0, i, mode); 3660 rtx op0_piece = operand_subword_force (op0, i, mode);
3689 3661
3690 if (i == word) 3662 if (i == word)
3691 { 3663 {
3692 if (!op0_is_abs) 3664 if (!op0_is_abs)
3693 op0_piece = expand_binop (imode, and_optab, op0_piece, 3665 op0_piece
3694 immed_double_const (~lo, ~hi, imode), 3666 = expand_binop (imode, and_optab, op0_piece,
3695 NULL_RTX, 1, OPTAB_LIB_WIDEN); 3667 immed_double_int_const (double_int_not (mask),
3668 imode),
3669 NULL_RTX, 1, OPTAB_LIB_WIDEN);
3696 3670
3697 op1 = expand_binop (imode, and_optab, 3671 op1 = expand_binop (imode, and_optab,
3698 operand_subword_force (op1, i, mode), 3672 operand_subword_force (op1, i, mode),
3699 immed_double_const (lo, hi, imode), 3673 immed_double_int_const (mask, imode),
3700 NULL_RTX, 1, OPTAB_LIB_WIDEN); 3674 NULL_RTX, 1, OPTAB_LIB_WIDEN);
3701 3675
3702 temp = expand_binop (imode, ior_optab, op0_piece, op1, 3676 temp = expand_binop (imode, ior_optab, op0_piece, op1,
3703 targ_piece, 1, OPTAB_LIB_WIDEN); 3677 targ_piece, 1, OPTAB_LIB_WIDEN);
3704 if (temp != targ_piece) 3678 if (temp != targ_piece)
3714 emit_insn (insns); 3688 emit_insn (insns);
3715 } 3689 }
3716 else 3690 else
3717 { 3691 {
3718 op1 = expand_binop (imode, and_optab, gen_lowpart (imode, op1), 3692 op1 = expand_binop (imode, and_optab, gen_lowpart (imode, op1),
3719 immed_double_const (lo, hi, imode), 3693 immed_double_int_const (mask, imode),
3720 NULL_RTX, 1, OPTAB_LIB_WIDEN); 3694 NULL_RTX, 1, OPTAB_LIB_WIDEN);
3721 3695
3722 op0 = gen_lowpart (imode, op0); 3696 op0 = gen_lowpart (imode, op0);
3723 if (!op0_is_abs) 3697 if (!op0_is_abs)
3724 op0 = expand_binop (imode, and_optab, op0, 3698 op0 = expand_binop (imode, and_optab, op0,
3725 immed_double_const (~lo, ~hi, imode), 3699 immed_double_int_const (double_int_not (mask),
3700 imode),
3726 NULL_RTX, 1, OPTAB_LIB_WIDEN); 3701 NULL_RTX, 1, OPTAB_LIB_WIDEN);
3727 3702
3728 temp = expand_binop (imode, ior_optab, op0, op1, 3703 temp = expand_binop (imode, ior_optab, op0, op1,
3729 gen_lowpart (imode, target), 1, OPTAB_LIB_WIDEN); 3704 gen_lowpart (imode, target), 1, OPTAB_LIB_WIDEN);
3730 target = lowpart_subreg_maybe_copy (mode, temp, imode); 3705 target = lowpart_subreg_maybe_copy (mode, temp, imode);
6054 /* Hashtable callbacks for libfunc_decls. */ 6029 /* Hashtable callbacks for libfunc_decls. */
6055 6030
6056 static hashval_t 6031 static hashval_t
6057 libfunc_decl_hash (const void *entry) 6032 libfunc_decl_hash (const void *entry)
6058 { 6033 {
6059 return htab_hash_string (IDENTIFIER_POINTER (DECL_NAME ((const_tree) entry))); 6034 return IDENTIFIER_HASH_VALUE (DECL_NAME ((const_tree) entry));
6060 } 6035 }
6061 6036
6062 static int 6037 static int
6063 libfunc_decl_eq (const void *entry1, const void *entry2) 6038 libfunc_decl_eq (const void *entry1, const void *entry2)
6064 { 6039 {