This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Avoid signed/unsigned warnigs
- To: gcc-patches at gcc dot gnu dot org
- Subject: Avoid signed/unsigned warnigs
- From: Jan van Male <jan dot vanmale at fenk dot wau dot nl>
- Date: Tue, 10 Jul 2001 18:14:43 +0200
- Reply-To: jan dot vanmale at fenk dot wau dot nl
Hi all,
This patch is very similar to my recent patch to alias.c:
http://gcc.gnu.org/ml/gcc-patches/2001-07/msg00266.html
It fixes the following warnings during stage3 of the bootstrap:
../../gcc/gcc/combine.c: In function `find_split_point':
../../gcc/gcc/combine.c:2981: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c: In function `combine_simplify_rtx':
../../gcc/gcc/combine.c:3938: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c: In function `simplify_logical':
../../gcc/gcc/combine.c:5328: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:5424: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c: In function `expand_field_assignment':
../../gcc/gcc/combine.c:5681: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:5692: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c: In function `force_to_mode':
../../gcc/gcc/combine.c:6848: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:6893: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:6905: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:6961: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:7022: warning: signed and unsigned type in conditional expression
../../gcc/gcc/combine.c:7044: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:7093: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c: In function `simplify_shift_const':
../../gcc/gcc/combine.c:9079: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:9419: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:9440: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c: In function `simplify_comparison':
../../gcc/gcc/combine.c:9868: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:10475: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:10732: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:10808: warning: comparison between signed and unsigned
../../gcc/gcc/combine.c:10821: warning: comparison between signed and unsigned
../../gcc/gcc/cse.c: In function `fold_rtx':
../../gcc/gcc/cse.c:3505: warning: comparison between signed and unsigned
../../gcc/gcc/cse.c:3507: warning: comparison between signed and unsigned
../../gcc/gcc/cse.c:3640: warning: comparison between signed and unsigned
../../gcc/gcc/cse.c:3651: warning: comparison between signed and unsigned
../../gcc/gcc/cse.c:4258: warning: comparison between signed and unsigned
../../gcc/gcc/expmed.c: In function `expand_shift':
../../gcc/gcc/expmed.c:2007: warning: comparison between signed and unsigned
../../gcc/gcc/fold-const.c: In function `optimize_bit_field_compare':
../../gcc/gcc/fold-const.c:2935: warning: comparison between signed and unsigned
These warnings were also introduced by this (huge) patch:
http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00872.html
The relevant change is
* machmode.h (mode_size, mode_unit_size): Now unsigned.
which changed `mode_size' from `int' to `unsigned'. This patch eliminates
the warnings by adding an explicit cast to `int' of GET_MODE_SIZE and
GET_MODE_BITSIZE.
GET_MODE_SIZE is defined in machmode.h as:
#define GET_MODE_SIZE(MODE) (mode_size[(int) (MODE)])
The maximum value of mode_size is 64 according to machmode.def so a cast to
int is safe.
This change
http://gcc.gnu.org/ml/gcc-patches/2000-09/msg00771.html
changed the definition of GET_MODE_BITSIZE from
#define GET_MODE_BITSIZE(MODE) (BITS_PER_UNIT * mode_size[(int) (MODE)])
to
#define GET_MODE_BITSIZE(MODE) (mode_bitsize[(int) (MODE)])
However, mode_bitsize[(int) (MODE)] exactly equals
BITS_PER_UNIT * mode_size[(int) (MODE)] as can be seen in machmode.def.
The largest value for BITS_PER_UNIT is 32 (defined in c4x.h) the product
therefore never exceeds 2048. A cast to int should be safe since an int is
at least 16 bit.
The cast of `mode_width' in combine.c is also safe since `mode_width' is
equal to GET_MODE_BITSIZE.
The patch passes a full bootstrap and tests without regressions on
i686-pc-linux-gnu, please apply it when ok, since I don't have cvs write
priviledges.
jan
Changelog:
2001-07-09 Jan van Male <jan.vanmale@fenk.wau.nl>
* expmed.c (expand_shift): Cast GET_MODE_BITSIZE to int to avoid
warnings.
* fold-const.c (optimize_bit_field_compare): Likewise.
* combine.c (find_split_point, case SET): Likewise.
(combine_simplify_rtx, case NEG): Likewise.
(simplify_logical, case IOR, XOR): Likewise.
(expand_field_assignment): Likewise.
(force_to_mode, case XOR, ASHIFT, LSHIFTRT, ASHIFTRT): Likewise.
(simplify_shift_const, case ROTATE, TRUNCATE) Likewise.
(simplify_shift_const): Likewise.
(simplify_comparison): Likewise
(simplify_comparison, case MINUS, ASHIFT, LSHIFTRT) Cast mode_width
to int to avoid warnings.
* cse.c (fold_rtx): Cast both GET_MODE_SIZE and GET_MODE_BITSIZE to
int to avoid warnings.
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.213
diff -c -3 -p -r1.213 combine.c
*** combine.c 2001/07/10 10:38:05 1.213
--- combine.c 2001/07/10 16:07:12
*************** find_split_point (loc, insn)
*** 2978,2984 ****
&& GET_CODE (SET_SRC (x)) == CONST_INT
&& ((INTVAL (XEXP (SET_DEST (x), 1))
+ INTVAL (XEXP (SET_DEST (x), 2)))
! <= GET_MODE_BITSIZE (GET_MODE (XEXP (SET_DEST (x), 0))))
&& ! side_effects_p (XEXP (SET_DEST (x), 0)))
{
HOST_WIDE_INT pos = INTVAL (XEXP (SET_DEST (x), 2));
--- 2978,2984 ----
&& GET_CODE (SET_SRC (x)) == CONST_INT
&& ((INTVAL (XEXP (SET_DEST (x), 1))
+ INTVAL (XEXP (SET_DEST (x), 2)))
! <= (int) GET_MODE_BITSIZE (GET_MODE (XEXP (SET_DEST (x), 0))))
&& ! side_effects_p (XEXP (SET_DEST (x), 0)))
{
HOST_WIDE_INT pos = INTVAL (XEXP (SET_DEST (x), 2));
*************** combine_simplify_rtx (x, op0_mode, last,
*** 3935,3941 ****
if (GET_CODE (temp) == ASHIFTRT
&& GET_CODE (XEXP (temp, 1)) == CONST_INT
! && INTVAL (XEXP (temp, 1)) == GET_MODE_BITSIZE (mode) - 1)
return simplify_shift_const (temp, LSHIFTRT, mode, XEXP (temp, 0),
INTVAL (XEXP (temp, 1)));
--- 3935,3941 ----
if (GET_CODE (temp) == ASHIFTRT
&& GET_CODE (XEXP (temp, 1)) == CONST_INT
! && INTVAL (XEXP (temp, 1)) == (int) GET_MODE_BITSIZE (mode) - 1)
return simplify_shift_const (temp, LSHIFTRT, mode, XEXP (temp, 0),
INTVAL (XEXP (temp, 1)));
*************** simplify_logical (x, last)
*** 5325,5331 ****
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
&& GET_CODE (XEXP (op1, 1)) == CONST_INT
&& (INTVAL (XEXP (op0, 1)) + INTVAL (XEXP (op1, 1))
! == GET_MODE_BITSIZE (mode)))
return gen_rtx_ROTATE (mode, XEXP (op0, 0),
(GET_CODE (op0) == ASHIFT
? XEXP (op0, 1) : XEXP (op1, 1)));
--- 5325,5331 ----
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
&& GET_CODE (XEXP (op1, 1)) == CONST_INT
&& (INTVAL (XEXP (op0, 1)) + INTVAL (XEXP (op1, 1))
! == (int) GET_MODE_BITSIZE (mode)))
return gen_rtx_ROTATE (mode, XEXP (op0, 0),
(GET_CODE (op0) == ASHIFT
? XEXP (op0, 1) : XEXP (op1, 1)));
*************** simplify_logical (x, last)
*** 5421,5427 ****
&& op1 == const1_rtx
&& GET_CODE (op0) == LSHIFTRT
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
! && INTVAL (XEXP (op0, 1)) == GET_MODE_BITSIZE (mode) - 1)
return gen_rtx_GE (mode, XEXP (op0, 0), const0_rtx);
/* (xor (comparison foo bar) (const_int sign-bit))
--- 5421,5427 ----
&& op1 == const1_rtx
&& GET_CODE (op0) == LSHIFTRT
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
! && INTVAL (XEXP (op0, 1)) == (int) GET_MODE_BITSIZE (mode) - 1)
return gen_rtx_GE (mode, XEXP (op0, 0), const0_rtx);
/* (xor (comparison foo bar) (const_int sign-bit))
*************** expand_field_assignment (x)
*** 5678,5684 ****
/* If the position is constant and spans the width of INNER,
surround INNER with a USE to indicate this. */
if (GET_CODE (pos) == CONST_INT
! && INTVAL (pos) + len > GET_MODE_BITSIZE (GET_MODE (inner)))
inner = gen_rtx_USE (GET_MODE (SET_DEST (x)), inner);
if (BITS_BIG_ENDIAN)
--- 5678,5685 ----
/* If the position is constant and spans the width of INNER,
surround INNER with a USE to indicate this. */
if (GET_CODE (pos) == CONST_INT
! && INTVAL (pos) + len
! > (int) GET_MODE_BITSIZE (GET_MODE (inner)))
inner = gen_rtx_USE (GET_MODE (SET_DEST (x)), inner);
if (BITS_BIG_ENDIAN)
*************** expand_field_assignment (x)
*** 5689,5695 ****
else if (GET_CODE (pos) == MINUS
&& GET_CODE (XEXP (pos, 1)) == CONST_INT
&& (INTVAL (XEXP (pos, 1))
! == GET_MODE_BITSIZE (GET_MODE (inner)) - len))
/* If position is ADJUST - X, new position is X. */
pos = XEXP (pos, 0);
else
--- 5690,5696 ----
else if (GET_CODE (pos) == MINUS
&& GET_CODE (XEXP (pos, 1)) == CONST_INT
&& (INTVAL (XEXP (pos, 1))
! == (int) GET_MODE_BITSIZE (GET_MODE (inner)) - len))
/* If position is ADJUST - X, new position is X. */
pos = XEXP (pos, 0);
else
*************** force_to_mode (x, mode, mask, reg, just_
*** 6845,6851 ****
&& GET_CODE (XEXP (x, 1)) == CONST_INT
&& ((INTVAL (XEXP (XEXP (x, 0), 1))
+ floor_log2 (INTVAL (XEXP (x, 1))))
! < GET_MODE_BITSIZE (GET_MODE (x)))
&& (INTVAL (XEXP (x, 1))
& ~nonzero_bits (XEXP (x, 0), GET_MODE (x))) == 0)
{
--- 6846,6852 ----
&& GET_CODE (XEXP (x, 1)) == CONST_INT
&& ((INTVAL (XEXP (XEXP (x, 0), 1))
+ floor_log2 (INTVAL (XEXP (x, 1))))
! < (int) GET_MODE_BITSIZE (GET_MODE (x)))
&& (INTVAL (XEXP (x, 1))
& ~nonzero_bits (XEXP (x, 0), GET_MODE (x))) == 0)
{
*************** force_to_mode (x, mode, mask, reg, just_
*** 6890,6896 ****
if (! (GET_CODE (XEXP (x, 1)) == CONST_INT
&& INTVAL (XEXP (x, 1)) >= 0
! && INTVAL (XEXP (x, 1)) < GET_MODE_BITSIZE (mode))
&& ! (GET_MODE (XEXP (x, 1)) != VOIDmode
&& (nonzero_bits (XEXP (x, 1), GET_MODE (XEXP (x, 1)))
< (unsigned HOST_WIDE_INT) GET_MODE_BITSIZE (mode))))
--- 6891,6897 ----
if (! (GET_CODE (XEXP (x, 1)) == CONST_INT
&& INTVAL (XEXP (x, 1)) >= 0
! && INTVAL (XEXP (x, 1)) < (int) GET_MODE_BITSIZE (mode))
&& ! (GET_MODE (XEXP (x, 1)) != VOIDmode
&& (nonzero_bits (XEXP (x, 1), GET_MODE (XEXP (x, 1)))
< (unsigned HOST_WIDE_INT) GET_MODE_BITSIZE (mode))))
*************** force_to_mode (x, mode, mask, reg, just_
*** 6901,6907 ****
conservative form of the mask. */
if (GET_CODE (XEXP (x, 1)) == CONST_INT
&& INTVAL (XEXP (x, 1)) >= 0
! && INTVAL (XEXP (x, 1)) < GET_MODE_BITSIZE (op_mode)
&& GET_MODE_BITSIZE (op_mode) <= HOST_BITS_PER_WIDE_INT)
mask >>= INTVAL (XEXP (x, 1));
else
--- 6902,6908 ----
conservative form of the mask. */
if (GET_CODE (XEXP (x, 1)) == CONST_INT
&& INTVAL (XEXP (x, 1)) >= 0
! && INTVAL (XEXP (x, 1)) < (int) GET_MODE_BITSIZE (op_mode)
&& GET_MODE_BITSIZE (op_mode) <= HOST_BITS_PER_WIDE_INT)
mask >>= INTVAL (XEXP (x, 1));
else
*************** force_to_mode (x, mode, mask, reg, just_
*** 6958,6964 ****
/* Number of bits left after the shift must be more than the mask
needs. */
&& ((INTVAL (XEXP (x, 1)) + exact_log2 (mask + 1))
! <= GET_MODE_BITSIZE (GET_MODE (x)))
/* Must be more sign bit copies than the mask needs. */
&& ((int) num_sign_bit_copies (XEXP (x, 0), GET_MODE (XEXP (x, 0)))
>= exact_log2 (mask + 1)))
--- 6959,6965 ----
/* Number of bits left after the shift must be more than the mask
needs. */
&& ((INTVAL (XEXP (x, 1)) + exact_log2 (mask + 1))
! <= (int) GET_MODE_BITSIZE (GET_MODE (x)))
/* Must be more sign bit copies than the mask needs. */
&& ((int) num_sign_bit_copies (XEXP (x, 0), GET_MODE (XEXP (x, 0)))
>= exact_log2 (mask + 1)))
*************** force_to_mode (x, mode, mask, reg, just_
*** 7019,7025 ****
x = simplify_shift_const
(x, LSHIFTRT, GET_MODE (x), XEXP (x, 0),
i < 0 ? INTVAL (XEXP (x, 1))
! : GET_MODE_BITSIZE (GET_MODE (x)) - 1 - i);
if (GET_CODE (x) != ASHIFTRT)
return force_to_mode (x, mode, mask, reg, next_select);
--- 7020,7026 ----
x = simplify_shift_const
(x, LSHIFTRT, GET_MODE (x), XEXP (x, 0),
i < 0 ? INTVAL (XEXP (x, 1))
! : (int) GET_MODE_BITSIZE (GET_MODE (x)) - 1 - i);
if (GET_CODE (x) != ASHIFTRT)
return force_to_mode (x, mode, mask, reg, next_select);
*************** force_to_mode (x, mode, mask, reg, just_
*** 7041,7047 ****
&& GET_CODE (XEXP (x, 1)) == CONST_INT
&& INTVAL (XEXP (x, 1)) >= 0
&& (INTVAL (XEXP (x, 1))
! <= GET_MODE_BITSIZE (GET_MODE (x)) - (floor_log2 (mask) + 1))
&& GET_CODE (XEXP (x, 0)) == ASHIFT
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
&& INTVAL (XEXP (XEXP (x, 0), 1)) == INTVAL (XEXP (x, 1)))
--- 7042,7049 ----
&& GET_CODE (XEXP (x, 1)) == CONST_INT
&& INTVAL (XEXP (x, 1)) >= 0
&& (INTVAL (XEXP (x, 1))
! <= (int) GET_MODE_BITSIZE (GET_MODE (x))
! - (floor_log2 (mask) + 1))
&& GET_CODE (XEXP (x, 0)) == ASHIFT
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
&& INTVAL (XEXP (XEXP (x, 0), 1)) == INTVAL (XEXP (x, 1)))
*************** force_to_mode (x, mode, mask, reg, just_
*** 7090,7096 ****
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
&& INTVAL (XEXP (XEXP (x, 0), 1)) >= 0
&& (INTVAL (XEXP (XEXP (x, 0), 1)) + floor_log2 (mask)
! < GET_MODE_BITSIZE (GET_MODE (x)))
&& INTVAL (XEXP (XEXP (x, 0), 1)) < HOST_BITS_PER_WIDE_INT)
{
temp = GEN_INT (mask << INTVAL (XEXP (XEXP (x, 0), 1)));
--- 7092,7098 ----
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
&& INTVAL (XEXP (XEXP (x, 0), 1)) >= 0
&& (INTVAL (XEXP (XEXP (x, 0), 1)) + floor_log2 (mask)
! < (int) GET_MODE_BITSIZE (GET_MODE (x)))
&& INTVAL (XEXP (XEXP (x, 0), 1)) < HOST_BITS_PER_WIDE_INT)
{
temp = GEN_INT (mask << INTVAL (XEXP (XEXP (x, 0), 1)));
*************** simplify_shift_const (x, code, result_mo
*** 9076,9082 ****
AND of a new shift with a mask. We compute the result below. */
if (GET_CODE (XEXP (varop, 1)) == CONST_INT
&& INTVAL (XEXP (varop, 1)) >= 0
! && INTVAL (XEXP (varop, 1)) < GET_MODE_BITSIZE (GET_MODE (varop))
&& GET_MODE_BITSIZE (result_mode) <= HOST_BITS_PER_WIDE_INT
&& GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
{
--- 9078,9085 ----
AND of a new shift with a mask. We compute the result below. */
if (GET_CODE (XEXP (varop, 1)) == CONST_INT
&& INTVAL (XEXP (varop, 1)) >= 0
! && INTVAL (XEXP (varop, 1))
! < (int) GET_MODE_BITSIZE (GET_MODE (varop))
&& GET_MODE_BITSIZE (result_mode) <= HOST_BITS_PER_WIDE_INT
&& GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
{
*************** simplify_shift_const (x, code, result_mo
*** 9437,9444 ****
&& GET_CODE (XEXP (varop, 0)) == LSHIFTRT
&& GET_CODE (XEXP (XEXP (varop, 0), 1)) == CONST_INT
&& (INTVAL (XEXP (XEXP (varop, 0), 1))
! >= (GET_MODE_BITSIZE (GET_MODE (XEXP (varop, 0)))
! - GET_MODE_BITSIZE (GET_MODE (varop)))))
{
rtx varop_inner = XEXP (varop, 0);
--- 9440,9447 ----
&& GET_CODE (XEXP (varop, 0)) == LSHIFTRT
&& GET_CODE (XEXP (XEXP (varop, 0), 1)) == CONST_INT
&& (INTVAL (XEXP (XEXP (varop, 0), 1))
! >= (int) (GET_MODE_BITSIZE (GET_MODE (XEXP (varop, 0)))
! - GET_MODE_BITSIZE (GET_MODE (varop)))))
{
rtx varop_inner = XEXP (varop, 0);
*************** simplify_comparison (code, pop0, pop1)
*** 9864,9872 ****
&& INTVAL (XEXP (op0, 1)) == INTVAL (XEXP (XEXP (op0, 0), 1))
&& INTVAL (XEXP (op0, 1)) == INTVAL (XEXP (XEXP (op1, 0), 1))
&& (INTVAL (XEXP (op0, 1))
! == (GET_MODE_BITSIZE (GET_MODE (op0))
! - (GET_MODE_BITSIZE
! (GET_MODE (SUBREG_REG (XEXP (XEXP (op0, 0), 0))))))))
{
op0 = SUBREG_REG (XEXP (XEXP (op0, 0), 0));
op1 = SUBREG_REG (XEXP (XEXP (op1, 0), 0));
--- 9867,9875 ----
&& INTVAL (XEXP (op0, 1)) == INTVAL (XEXP (XEXP (op0, 0), 1))
&& INTVAL (XEXP (op0, 1)) == INTVAL (XEXP (XEXP (op1, 0), 1))
&& (INTVAL (XEXP (op0, 1))
! == (int) (GET_MODE_BITSIZE (GET_MODE (op0))
! - (GET_MODE_BITSIZE
! (GET_MODE (SUBREG_REG (XEXP (XEXP (op0, 0), 0))))))))
{
op0 = SUBREG_REG (XEXP (XEXP (op0, 0), 0));
op1 = SUBREG_REG (XEXP (XEXP (op1, 0), 0));
*************** simplify_comparison (code, pop0, pop1)
*** 10472,10478 ****
of bits in X minus 1, is one iff X > 0. */
if (sign_bit_comparison_p && GET_CODE (XEXP (op0, 0)) == ASHIFTRT
&& GET_CODE (XEXP (XEXP (op0, 0), 1)) == CONST_INT
! && INTVAL (XEXP (XEXP (op0, 0), 1)) == mode_width - 1
&& rtx_equal_p (XEXP (XEXP (op0, 0), 0), XEXP (op0, 1)))
{
op0 = XEXP (op0, 1);
--- 10475,10481 ----
of bits in X minus 1, is one iff X > 0. */
if (sign_bit_comparison_p && GET_CODE (XEXP (op0, 0)) == ASHIFTRT
&& GET_CODE (XEXP (XEXP (op0, 0), 1)) == CONST_INT
! && INTVAL (XEXP (XEXP (op0, 0), 1)) == (int) mode_width - 1
&& rtx_equal_p (XEXP (XEXP (op0, 0), 0), XEXP (op0, 1)))
{
op0 = XEXP (op0, 1);
*************** simplify_comparison (code, pop0, pop1)
*** 10730,10736 ****
low-order bit. */
if (const_op == 0 && equality_comparison_p
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
! && INTVAL (XEXP (op0, 1)) == mode_width - 1)
{
op0 = simplify_and_const_int (NULL_RTX, mode, XEXP (op0, 0),
(HOST_WIDE_INT) 1);
--- 10733,10739 ----
low-order bit. */
if (const_op == 0 && equality_comparison_p
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
! && INTVAL (XEXP (op0, 1)) == (int) mode_width - 1)
{
op0 = simplify_and_const_int (NULL_RTX, mode, XEXP (op0, 0),
(HOST_WIDE_INT) 1);
*************** simplify_comparison (code, pop0, pop1)
*** 10806,10812 ****
& (((HOST_WIDE_INT) 1 << INTVAL (XEXP (op0, 1))) - 1)) == 0
&& (const_op == 0
|| (floor_log2 (const_op) + INTVAL (XEXP (op0, 1))
! < mode_width)))
{
const_op <<= INTVAL (XEXP (op0, 1));
op1 = GEN_INT (const_op);
--- 10809,10815 ----
& (((HOST_WIDE_INT) 1 << INTVAL (XEXP (op0, 1))) - 1)) == 0
&& (const_op == 0
|| (floor_log2 (const_op) + INTVAL (XEXP (op0, 1))
! < (int) mode_width)))
{
const_op <<= INTVAL (XEXP (op0, 1));
op1 = GEN_INT (const_op);
*************** simplify_comparison (code, pop0, pop1)
*** 10819,10825 ****
if (const_op == 0
&& (equality_comparison_p || sign_bit_comparison_p)
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
! && INTVAL (XEXP (op0, 1)) == mode_width - 1)
{
op0 = XEXP (op0, 0);
code = (code == NE || code == GT ? LT : GE);
--- 10822,10828 ----
if (const_op == 0
&& (equality_comparison_p || sign_bit_comparison_p)
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
! && INTVAL (XEXP (op0, 1)) == (int) mode_width - 1)
{
op0 = XEXP (op0, 0);
code = (code == NE || code == GT ? LT : GE);
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.189
diff -c -3 -p -r1.189 cse.c
*** cse.c 2001/07/09 11:20:50 1.189
--- cse.c 2001/07/10 16:07:14
*************** fold_rtx (x, insn)
*** 3498,3506 ****
if (op0 && op1
&& GET_CODE (elt->exp) == ASHIFT
&& GET_CODE (op1) == CONST_INT
! && INTVAL (op1) >= GET_MODE_BITSIZE (mode))
{
! if (INTVAL (op1) < GET_MODE_BITSIZE (GET_MODE (elt->exp)))
/* If the count fits in the inner mode's width,
but exceeds the outer mode's width,
--- 3498,3507 ----
if (op0 && op1
&& GET_CODE (elt->exp) == ASHIFT
&& GET_CODE (op1) == CONST_INT
! && INTVAL (op1) >= (int) GET_MODE_BITSIZE (mode))
{
! if (INTVAL (op1)
! < (int) GET_MODE_BITSIZE (GET_MODE (elt->exp)))
/* If the count fits in the inner mode's width,
but exceeds the outer mode's width,
*************** fold_rtx (x, insn)
*** 3632,3638 ****
rtx table = PATTERN (table_insn);
if (offset >= 0
! && (offset / GET_MODE_SIZE (GET_MODE (table))
< XVECLEN (table, 0)))
return XVECEXP (table, 0,
offset / GET_MODE_SIZE (GET_MODE (table)));
--- 3633,3639 ----
rtx table = PATTERN (table_insn);
if (offset >= 0
! && (offset / (int) GET_MODE_SIZE (GET_MODE (table))
< XVECLEN (table, 0)))
return XVECEXP (table, 0,
offset / GET_MODE_SIZE (GET_MODE (table)));
*************** fold_rtx (x, insn)
*** 3643,3649 ****
rtx table = PATTERN (table_insn);
if (offset >= 0
! && (offset / GET_MODE_SIZE (GET_MODE (table))
< XVECLEN (table, 1)))
{
offset /= GET_MODE_SIZE (GET_MODE (table));
--- 3644,3650 ----
rtx table = PATTERN (table_insn);
if (offset >= 0
! && (offset / (int) GET_MODE_SIZE (GET_MODE (table))
< XVECLEN (table, 1)))
{
offset /= GET_MODE_SIZE (GET_MODE (table));
*************** fold_rtx (x, insn)
*** 4251,4257 ****
of shifts. */
if (is_shift && GET_CODE (new_const) == CONST_INT
! && INTVAL (new_const) >= GET_MODE_BITSIZE (mode))
{
/* As an exception, we can turn an ASHIFTRT of this
form into a shift of the number of bits - 1. */
--- 4252,4258 ----
of shifts. */
if (is_shift && GET_CODE (new_const) == CONST_INT
! && INTVAL (new_const) >= (int) GET_MODE_BITSIZE (mode))
{
/* As an exception, we can turn an ASHIFTRT of this
form into a shift of the number of bits - 1. */
Index: expmed.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expmed.c,v
retrieving revision 1.82
diff -c -3 -p -r1.82 expmed.c
*** expmed.c 2001/07/09 15:25:34 1.82
--- expmed.c 2001/07/10 16:07:15
*************** expand_shift (code, mode, shifted, amoun
*** 1999,2005 ****
that is in range, try a rotate in the opposite direction. */
if (temp == 0 && GET_CODE (op1) == CONST_INT
! && INTVAL (op1) > 0 && INTVAL (op1) < GET_MODE_BITSIZE (mode))
temp = expand_binop (mode,
left ? rotr_optab : rotl_optab,
shifted,
--- 1999,2006 ----
that is in range, try a rotate in the opposite direction. */
if (temp == 0 && GET_CODE (op1) == CONST_INT
! && INTVAL (op1) > 0
! && INTVAL (op1) < (int) GET_MODE_BITSIZE (mode))
temp = expand_binop (mode,
left ? rotr_optab : rotl_optab,
shifted,
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.159
diff -c -3 -p -r1.159 fold-const.c
*** fold-const.c 2001/07/06 18:39:56 1.159
--- fold-const.c 2001/07/10 16:07:17
*************** optimize_bit_field_compare (code, compar
*** 2932,2939 ****
then will no longer be able to replace it. */
linner = get_inner_reference (lhs, &lbitsize, &lbitpos, &offset, &lmode,
&lunsignedp, &lvolatilep, &alignment);
! if (linner == lhs || lbitsize == GET_MODE_BITSIZE (lmode) || lbitsize < 0
! || offset != 0 || TREE_CODE (linner) == PLACEHOLDER_EXPR)
return 0;
if (!const_p)
--- 2932,2942 ----
then will no longer be able to replace it. */
linner = get_inner_reference (lhs, &lbitsize, &lbitpos, &offset, &lmode,
&lunsignedp, &lvolatilep, &alignment);
! if (linner == lhs
! || lbitsize == (int) GET_MODE_BITSIZE (lmode)
! || lbitsize < 0
! || offset != 0
! || TREE_CODE (linner) == PLACEHOLDER_EXPR)
return 0;
if (!const_p)