Skip to content

Commit 18e35d8

Browse files
authored
[LoongArch] Don't left shift negative value (#106812)
Fixed another UB from #106332. Detected here https://lab.llvm.org/buildbot/#/builders/169/builds/2662
1 parent 3745a2e commit 18e35d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMatInt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ LoongArchMatInt::InstSeq LoongArchMatInt::generateInstSeq(int64_t Val) {
8282
TmpVal1 = Insts[1].Imm;
8383
if (N == 3)
8484
break;
85-
TmpVal2 = Insts[3].Imm << 52 | TmpVal1;
85+
TmpVal2 = static_cast<uint64_t>(Insts[3].Imm) << 52 | TmpVal1;
8686
}
87-
TmpVal1 |= Insts[0].Imm << 12;
87+
TmpVal1 |= static_cast<uint64_t>(Insts[0].Imm) << 12;
8888
break;
8989
case LoongArch::ORI:
9090
case LoongArch::ADDI_W:

0 commit comments

Comments
 (0)