https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104842
Bug ID: 104842
Summary: mips: signed overflow in LUI_OPERAND
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: xry111 at mengyan1223 dot wang
Target Milestone: ---
Found this building GCC on mips64el-linux-gnuabi64 with bootstrap-ubsan
(testing a patch enabling ubsan for mips64*-linux-gnu*):
../../gcc/gcc/config/mips/predicates.md:382:11: runtime error: signed integer
overflow: 9223372036854775807 + 65536 cannot be represented in type 'long
int'
That line uses LUI_INT (x), which expands to LUI_OPERAND (INTVAL (x)).
LUI_OPERAND is defined as:
#define LUI_OPERAND(VALUE) \
(((VALUE) | 0x7fff0000) == 0x7fff0000 \
|| ((VALUE) | 0x7fff0000) + 0x10000 == 0)
Obviously this will cause a signed overflow when INTVAL (x) is, for example,
the maximum value of HOST_WIDE_INT.