[PATCH] Fix combine.c compilation warnings.
Roger Sayle
roger@eyesopen.com
Sat Jun 29 12:46:00 GMT 2002
The following patch fixes the numerous "signed vs unsigned comparison"
compilation warnings in combine.c. Most of these are because shift
counts and the return type of num_sign_bit_copies are expressed as
"unsigned int".
The following patch has been tested with a full "make bootstrap" and
"make -k check" on i686-pc-linux-gnu, all languages except Ada and
treelang, with no new regressions. It's also been tested by building
a cross compiler to v850-elf [where unfortunately it doesn't fix
20011223-1.c (high priority PR c/2454) :>]
Ok for mainline?
2002-06-29 Roger Sayle <roger@eyesopen.com>
* combine.c (SUBST_INT): Add cast to avoid compilation warning.
(combine_simplify_rtx): Likewise.
(simplify_if_then_else): Likewise.
(make_extraction): Likewise.
(extended_count): Likewise.
(simplify_shift_const): Likewise.
(simplify_comparison): Likewise.
(force_to_mode): Remove cast to avoid compilation warning.
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.302
diff -c -3 -p -r1.302 combine.c
*** combine.c 28 Jun 2002 21:34:47 -0000 1.302
--- combine.c 29 Jun 2002 16:39:37 -0000
*************** do_SUBST_INT (into, newval)
*** 493,499 ****
buf->next = undobuf.undos, undobuf.undos = buf;
}
! #define SUBST_INT(INTO, NEWVAL) do_SUBST_INT(&(INTO), (NEWVAL))
/* Main entry point for combiner. F is the first insn of the function.
NREGS is the first unused pseudo-reg number.
--- 493,500 ----
buf->next = undobuf.undos, undobuf.undos = buf;
}
! #define SUBST_INT(INTO, NEWVAL) do_SUBST_INT((unsigned int*) &(INTO), \
! (NEWVAL))
/* Main entry point for combiner. F is the first insn of the function.
NREGS is the first unused pseudo-reg number.
*************** combine_simplify_rtx (x, op0_mode, last,
*** 4105,4111 ****
if (TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0))))
&& num_sign_bit_copies (XEXP (x, 0), GET_MODE (XEXP (x, 0)))
! >= GET_MODE_BITSIZE (mode) + 1
&& ! (GET_CODE (XEXP (x, 0)) == LSHIFTRT
&& GET_CODE (XEXP (XEXP (x, 0), 0)) == MULT))
return gen_lowpart_for_combine (mode, XEXP (x, 0));
--- 4106,4112 ----
if (TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0))))
&& num_sign_bit_copies (XEXP (x, 0), GET_MODE (XEXP (x, 0)))
! >= (unsigned int) (GET_MODE_BITSIZE (mode) + 1)
&& ! (GET_CODE (XEXP (x, 0)) == LSHIFTRT
&& GET_CODE (XEXP (XEXP (x, 0), 0)) == MULT))
return gen_lowpart_for_combine (mode, XEXP (x, 0));
*************** simplify_if_then_else (x)
*** 4866,4872 ****
&& subreg_lowpart_p (XEXP (XEXP (t, 0), 0))
&& rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 0)), f)
&& (num_sign_bit_copies (f, GET_MODE (f))
! > (GET_MODE_BITSIZE (mode)
- GET_MODE_BITSIZE (GET_MODE (XEXP (XEXP (t, 0), 0))))))
{
c1 = XEXP (XEXP (t, 0), 1); z = f; op = GET_CODE (XEXP (t, 0));
--- 4867,4874 ----
&& subreg_lowpart_p (XEXP (XEXP (t, 0), 0))
&& rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 0)), f)
&& (num_sign_bit_copies (f, GET_MODE (f))
! > (unsigned int)
! (GET_MODE_BITSIZE (mode)
- GET_MODE_BITSIZE (GET_MODE (XEXP (XEXP (t, 0), 0))))))
{
c1 = XEXP (XEXP (t, 0), 1); z = f; op = GET_CODE (XEXP (t, 0));
*************** simplify_if_then_else (x)
*** 4881,4887 ****
&& subreg_lowpart_p (XEXP (XEXP (t, 0), 1))
&& rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 1)), f)
&& (num_sign_bit_copies (f, GET_MODE (f))
! > (GET_MODE_BITSIZE (mode)
- GET_MODE_BITSIZE (GET_MODE (XEXP (XEXP (t, 0), 1))))))
{
c1 = XEXP (XEXP (t, 0), 0); z = f; op = GET_CODE (XEXP (t, 0));
--- 4883,4890 ----
&& subreg_lowpart_p (XEXP (XEXP (t, 0), 1))
&& rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 1)), f)
&& (num_sign_bit_copies (f, GET_MODE (f))
! > (unsigned int)
! (GET_MODE_BITSIZE (mode)
- GET_MODE_BITSIZE (GET_MODE (XEXP (XEXP (t, 0), 1))))))
{
c1 = XEXP (XEXP (t, 0), 0); z = f; op = GET_CODE (XEXP (t, 0));
*************** make_extraction (mode, inner, pos, pos_r
*** 5971,5977 ****
else if (GET_CODE (inner) == ASHIFT
&& GET_CODE (XEXP (inner, 1)) == CONST_INT
&& pos_rtx == 0 && pos == 0
! && len > INTVAL (XEXP (inner, 1)))
{
/* We're extracting the least significant bits of an rtx
(ashift X (const_int C)), where LEN > C. Extract the
--- 5974,5980 ----
else if (GET_CODE (inner) == ASHIFT
&& GET_CODE (XEXP (inner, 1)) == CONST_INT
&& pos_rtx == 0 && pos == 0
! && len > (unsigned HOST_WIDE_INT) INTVAL (XEXP (inner, 1)))
{
/* We're extracting the least significant bits of an rtx
(ashift X (const_int C)), where LEN > C. Extract the
*************** force_to_mode (x, mode, mask, reg, just_
*** 6814,6820 ****
if (GET_CODE (x) == AND && GET_CODE (XEXP (x, 1)) == CONST_INT
&& ((INTVAL (XEXP (x, 1)) & GET_MODE_MASK (GET_MODE (x)))
! == (HOST_WIDE_INT) mask))
x = XEXP (x, 0);
/* If it remains an AND, try making another AND with the bits
--- 6817,6823 ----
if (GET_CODE (x) == AND && GET_CODE (XEXP (x, 1)) == CONST_INT
&& ((INTVAL (XEXP (x, 1)) & GET_MODE_MASK (GET_MODE (x)))
! == mask))
x = XEXP (x, 0);
/* If it remains an AND, try making another AND with the bits
*************** extended_count (x, mode, unsignedp)
*** 8805,8812 ****
return (unsignedp
? (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
! ? (GET_MODE_BITSIZE (mode) - 1
! - floor_log2 (nonzero_bits (x, mode)))
: 0)
: num_sign_bit_copies (x, mode) - 1);
}
--- 8808,8815 ----
return (unsignedp
? (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
! ? (unsigned int) (GET_MODE_BITSIZE (mode) - 1
! - floor_log2 (nonzero_bits (x, mode)))
: 0)
: num_sign_bit_copies (x, mode) - 1);
}
*************** simplify_shift_const (x, code, result_mo
*** 9036,9042 ****
multiple operations, each of which are defined, we know what the
result is supposed to be. */
! if (count > GET_MODE_BITSIZE (shift_mode) - 1)
{
if (code == ASHIFTRT)
count = GET_MODE_BITSIZE (shift_mode) - 1;
--- 9039,9045 ----
multiple operations, each of which are defined, we know what the
result is supposed to be. */
! if (count > (unsigned int) (GET_MODE_BITSIZE (shift_mode) - 1))
{
if (code == ASHIFTRT)
count = GET_MODE_BITSIZE (shift_mode) - 1;
*************** simplify_shift_const (x, code, result_mo
*** 9152,9160 ****
if (subreg_lowpart_p (varop)
&& (GET_MODE_SIZE (GET_MODE (SUBREG_REG (varop)))
> GET_MODE_SIZE (GET_MODE (varop)))
! && (((GET_MODE_SIZE (GET_MODE (SUBREG_REG (varop)))
! + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
! == mode_words))
{
varop = SUBREG_REG (varop);
if (GET_MODE_SIZE (GET_MODE (varop)) > GET_MODE_SIZE (mode))
--- 9155,9163 ----
if (subreg_lowpart_p (varop)
&& (GET_MODE_SIZE (GET_MODE (SUBREG_REG (varop)))
> GET_MODE_SIZE (GET_MODE (varop)))
! && (unsigned int) ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (varop)))
! + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
! == mode_words)
{
varop = SUBREG_REG (varop);
if (GET_MODE_SIZE (GET_MODE (varop)) > GET_MODE_SIZE (mode))
*************** simplify_shift_const (x, code, result_mo
*** 9195,9201 ****
bit of a wider mode may be different from what would be
interpreted as the sign bit in a narrower mode, so, if
the result is narrower, don't discard the shift. */
! if (code == LSHIFTRT && count == GET_MODE_BITSIZE (result_mode) - 1
&& (GET_MODE_BITSIZE (result_mode)
>= GET_MODE_BITSIZE (GET_MODE (varop))))
{
--- 9198,9205 ----
bit of a wider mode may be different from what would be
interpreted as the sign bit in a narrower mode, so, if
the result is narrower, don't discard the shift. */
! if (code == LSHIFTRT
! && count == (unsigned int) (GET_MODE_BITSIZE (result_mode) - 1)
&& (GET_MODE_BITSIZE (result_mode)
>= GET_MODE_BITSIZE (GET_MODE (varop))))
{
*************** simplify_shift_const (x, code, result_mo
*** 9229,9236 ****
(ashiftrt:M1 (ashift:M1 (and:M1 (subreg:M1 FOO 0 C2) C3) C1).
This simplifies certain SIGN_EXTEND operations. */
if (code == ASHIFT && first_code == ASHIFTRT
! && (GET_MODE_BITSIZE (result_mode)
! - GET_MODE_BITSIZE (GET_MODE (varop))) == count)
{
/* C3 has the low-order C1 bits zero. */
--- 9233,9241 ----
(ashiftrt:M1 (ashift:M1 (and:M1 (subreg:M1 FOO 0 C2) C3) C1).
This simplifies certain SIGN_EXTEND operations. */
if (code == ASHIFT && first_code == ASHIFTRT
! && (unsigned int) (GET_MODE_BITSIZE (result_mode)
! - GET_MODE_BITSIZE (GET_MODE (varop)))
! == count)
{
/* C3 has the low-order C1 bits zero. */
*************** simplify_shift_const (x, code, result_mo
*** 9386,9392 ****
&& XEXP (XEXP (varop, 0), 1) == constm1_rtx
&& (STORE_FLAG_VALUE == 1 || STORE_FLAG_VALUE == -1)
&& (code == LSHIFTRT || code == ASHIFTRT)
! && count == GET_MODE_BITSIZE (GET_MODE (varop)) - 1
&& rtx_equal_p (XEXP (XEXP (varop, 0), 0), XEXP (varop, 1)))
{
count = 0;
--- 9391,9398 ----
&& XEXP (XEXP (varop, 0), 1) == constm1_rtx
&& (STORE_FLAG_VALUE == 1 || STORE_FLAG_VALUE == -1)
&& (code == LSHIFTRT || code == ASHIFTRT)
! && count
! == (unsigned int) (GET_MODE_BITSIZE (GET_MODE (varop)) - 1)
&& rtx_equal_p (XEXP (XEXP (varop, 0), 0), XEXP (varop, 1)))
{
count = 0;
*************** simplify_shift_const (x, code, result_mo
*** 9441,9447 ****
if (code == LSHIFTRT
&& XEXP (varop, 1) == const0_rtx
&& GET_MODE (XEXP (varop, 0)) == result_mode
! && count == GET_MODE_BITSIZE (result_mode) - 1
&& GET_MODE_BITSIZE (result_mode) <= HOST_BITS_PER_WIDE_INT
&& ((STORE_FLAG_VALUE
& ((HOST_WIDE_INT) 1
--- 9447,9453 ----
if (code == LSHIFTRT
&& XEXP (varop, 1) == const0_rtx
&& GET_MODE (XEXP (varop, 0)) == result_mode
! && count == (unsigned int) (GET_MODE_BITSIZE (result_mode) - 1)
&& GET_MODE_BITSIZE (result_mode) <= HOST_BITS_PER_WIDE_INT
&& ((STORE_FLAG_VALUE
& ((HOST_WIDE_INT) 1
*************** simplify_shift_const (x, code, result_mo
*** 9460,9466 ****
case NEG:
/* (lshiftrt (neg A) C) where A is either 0 or 1 and C is one less
than the number of bits in the mode is equivalent to A. */
! if (code == LSHIFTRT && count == GET_MODE_BITSIZE (result_mode) - 1
&& nonzero_bits (XEXP (varop, 0), result_mode) == 1)
{
varop = XEXP (varop, 0);
--- 9466,9473 ----
case NEG:
/* (lshiftrt (neg A) C) where A is either 0 or 1 and C is one less
than the number of bits in the mode is equivalent to A. */
! if (code == LSHIFTRT
! && count == (unsigned int) (GET_MODE_BITSIZE (result_mode) - 1)
&& nonzero_bits (XEXP (varop, 0), result_mode) == 1)
{
varop = XEXP (varop, 0);
*************** simplify_shift_const (x, code, result_mo
*** 9484,9490 ****
/* (lshiftrt (plus A -1) C) where A is either 0 or 1 and C
is one less than the number of bits in the mode is
equivalent to (xor A 1). */
! if (code == LSHIFTRT && count == GET_MODE_BITSIZE (result_mode) - 1
&& XEXP (varop, 1) == constm1_rtx
&& nonzero_bits (XEXP (varop, 0), result_mode) == 1
&& merge_outer_ops (&outer_op, &outer_const, XOR,
--- 9491,9498 ----
/* (lshiftrt (plus A -1) C) where A is either 0 or 1 and C
is one less than the number of bits in the mode is
equivalent to (xor A 1). */
! if (code == LSHIFTRT
! && count == (unsigned int) (GET_MODE_BITSIZE (result_mode) - 1)
&& XEXP (varop, 1) == constm1_rtx
&& nonzero_bits (XEXP (varop, 0), result_mode) == 1
&& merge_outer_ops (&outer_op, &outer_const, XOR,
*************** simplify_shift_const (x, code, result_mo
*** 9549,9558 ****
if ((STORE_FLAG_VALUE == 1 || STORE_FLAG_VALUE == -1)
&& GET_CODE (XEXP (varop, 0)) == ASHIFTRT
! && count == GET_MODE_BITSIZE (GET_MODE (varop)) - 1
&& (code == LSHIFTRT || code == ASHIFTRT)
&& GET_CODE (XEXP (XEXP (varop, 0), 1)) == CONST_INT
! && INTVAL (XEXP (XEXP (varop, 0), 1)) == count
&& rtx_equal_p (XEXP (XEXP (varop, 0), 0), XEXP (varop, 1)))
{
count = 0;
--- 9557,9567 ----
if ((STORE_FLAG_VALUE == 1 || STORE_FLAG_VALUE == -1)
&& GET_CODE (XEXP (varop, 0)) == ASHIFTRT
! && count
! == (unsigned int) (GET_MODE_BITSIZE (GET_MODE (varop)) - 1)
&& (code == LSHIFTRT || code == ASHIFTRT)
&& GET_CODE (XEXP (XEXP (varop, 0), 1)) == CONST_INT
! && (unsigned int) INTVAL (XEXP (XEXP (varop, 0), 1)) == count
&& rtx_equal_p (XEXP (XEXP (varop, 0), 0), XEXP (varop, 1)))
{
count = 0;
*************** simplify_shift_const (x, code, result_mo
*** 9616,9622 ****
if (x && GET_RTX_CLASS (GET_CODE (x)) == '2'
&& GET_CODE (XEXP (x, 1)) == CONST_INT
! && INTVAL (XEXP (x, 1)) == count)
const_rtx = XEXP (x, 1);
else
const_rtx = GEN_INT (count);
--- 9625,9631 ----
if (x && GET_RTX_CLASS (GET_CODE (x)) == '2'
&& GET_CODE (XEXP (x, 1)) == CONST_INT
! && (unsigned int) INTVAL (XEXP (x, 1)) == count)
const_rtx = XEXP (x, 1);
else
const_rtx = GEN_INT (count);
*************** simplify_comparison (code, pop0, pop1)
*** 10528,10534 ****
& ~GET_MODE_MASK (mode))
|| (num_sign_bit_copies (XEXP (SUBREG_REG (op0), 0),
GET_MODE (SUBREG_REG (op0)))
! > (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (op0)))
- GET_MODE_BITSIZE (mode)))))
{
op0 = SUBREG_REG (op0);
--- 10537,10544 ----
& ~GET_MODE_MASK (mode))
|| (num_sign_bit_copies (XEXP (SUBREG_REG (op0), 0),
GET_MODE (SUBREG_REG (op0)))
! > (unsigned int)
! (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (op0)))
- GET_MODE_BITSIZE (mode)))))
{
op0 = SUBREG_REG (op0);
*************** simplify_comparison (code, pop0, pop1)
*** 10612,10618 ****
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);
--- 10622,10629 ----
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
! && (unsigned 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);
*************** simplify_comparison (code, pop0, pop1)
*** 10870,10876 ****
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);
--- 10881,10887 ----
low-order bit. */
if (const_op == 0 && equality_comparison_p
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
! && (unsigned int) INTVAL (XEXP (op0, 1)) == mode_width - 1)
{
op0 = simplify_and_const_int (NULL_RTX, mode, XEXP (op0, 0),
(HOST_WIDE_INT) 1);
*************** simplify_comparison (code, pop0, pop1)
*** 10967,10973 ****
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);
--- 10978,10984 ----
if (const_op == 0
&& (equality_comparison_p || sign_bit_comparison_p)
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
! && (unsigned int) INTVAL (XEXP (op0, 1)) == mode_width - 1)
{
op0 = XEXP (op0, 0);
code = (code == NE || code == GT ? LT : GE);
*************** simplify_comparison (code, pop0, pop1)
*** 11068,11076 ****
if (zero_extended
|| ((num_sign_bit_copies (op0, tmode)
! > GET_MODE_BITSIZE (tmode) - GET_MODE_BITSIZE (mode))
&& (num_sign_bit_copies (op1, tmode)
! > GET_MODE_BITSIZE (tmode) - GET_MODE_BITSIZE (mode))))
{
/* If OP0 is an AND and we don't have an AND in MODE either,
make a new AND in the proper mode. */
--- 11079,11089 ----
if (zero_extended
|| ((num_sign_bit_copies (op0, tmode)
! > (unsigned int)
! (GET_MODE_BITSIZE (tmode) - GET_MODE_BITSIZE (mode)))
&& (num_sign_bit_copies (op1, tmode)
! > (unsigned int)
! (GET_MODE_BITSIZE (tmode) - GET_MODE_BITSIZE (mode)))))
{
/* If OP0 is an AND and we don't have an AND in MODE either,
make a new AND in the proper mode. */
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833
More information about the Gcc-patches
mailing list