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.
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:2ab70a4a5c2d5a9ffb923f13b1c3b938c60dd0f0 commit r12-7555-g2ab70a4a5c2d5a9ffb923f13b1c3b938c60dd0f0 Author: Xi Ruoyao <xry111@mengyan1223.wang> Date: Wed Mar 9 01:08:58 2022 +0800 mips: avoid signed overflow in LUI_OPERAND [PR104842] gcc/ PR target/104842 * config/mips/mips.h (LUI_OPERAND): Cast the input to an unsigned value before adding an offset.
Fixed for trunk.