]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Fix runtime error in a gcc build with --with-build-config=bootstrap-ubsan
authorGuo Jie <guojie@loongson.cn>
Thu, 23 Nov 2023 03:05:56 +0000 (11:05 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Mon, 27 Nov 2023 02:47:48 +0000 (10:47 +0800)
gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_split_plus_constant):
avoid left shift of negative value -0x8000.

gcc/config/loongarch/loongarch.cc

index c95fc83362e9b7a34b5e3eb28c6c356724b3b520..d3896d72bc2edc5fadfc8b1f4284c275fbe73865 100644 (file)
@@ -4269,7 +4269,7 @@ loongarch_split_plus_constant (rtx *op, machine_mode mode)
   else if (loongarch_addu16i_imm12_operand_p (v, mode))
     a = (v & ~HWIT_UC_0xFFF) + ((v & 0x800) << 1);
   else if (mode == DImode && DUAL_ADDU16I_OPERAND (v))
-    a = (v > 0 ? 0x7fff : -0x8000) << 16;
+    a = (v > 0 ? 0x7fff0000 : ~0x7fffffff);
   else
     gcc_unreachable ();