Message ID | 8ad1739a9149328c19c704463359bcb8bc0a3597.camel@mengyan1223.wang |
---|---|
State | New |
Headers | show |
Series | mips: avoid signed overflow in LUI_OPERAND [PR104842] | expand |
Xi Ruoyao <xry111@mengyan1223.wang> writes: > I think this one obvious. Ok for trunk? OK, thanks. Richard > > gcc/ > > PR target/104842 > * config/mips/mips.h (LUI_OPERAND): Cast the input to an unsigned > value before adding an offset. > --- > gcc/config/mips/mips.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h > index bf5c1d5a709..0029864fdcd 100644 > --- a/gcc/config/mips/mips.h > +++ b/gcc/config/mips/mips.h > @@ -2309,7 +2309,7 @@ enum reg_class > > #define LUI_OPERAND(VALUE) \ > (((VALUE) | 0x7fff0000) == 0x7fff0000 \ > - || ((VALUE) | 0x7fff0000) + 0x10000 == 0) > + || ((unsigned HOST_WIDE_INT) (VALUE) | 0x7fff0000) + 0x10000 == 0) > > /* Return a value X with the low 16 bits clear, and such that > VALUE - X is a signed 16-bit value. */
On Tue, 2022-03-08 at 18:20 +0000, Richard Sandiford wrote: > Xi Ruoyao <xry111@mengyan1223.wang> writes: > > I think this one obvious. Ok for trunk? > OK, thanks. Committed r12-7555. /* snip */ > > #define LUI_OPERAND(VALUE) \ > > (((VALUE) | 0x7fff0000) == 0x7fff0000 \ > > - || ((VALUE) | 0x7fff0000) + 0x10000 == 0) > > + || ((unsigned HOST_WIDE_INT) (VALUE) | 0x7fff0000) + 0x10000 == 0)
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index bf5c1d5a709..0029864fdcd 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -2309,7 +2309,7 @@ enum reg_class #define LUI_OPERAND(VALUE) \ (((VALUE) | 0x7fff0000) == 0x7fff0000 \ - || ((VALUE) | 0x7fff0000) + 0x10000 == 0) + || ((unsigned HOST_WIDE_INT) (VALUE) | 0x7fff0000) + 0x10000 == 0) /* Return a value X with the low 16 bits clear, and such that VALUE - X is a signed 16-bit value. */