[RISCV] Avoid signed integer overflow UB in RISCVMatInt::generateInstSeq

Found by UBSan.

llvm-svn: 366398
This commit is contained in:
Alex Bradbury 2019-07-18 04:02:58 +00:00
parent ad73a436dc
commit 8aba95d64c
1 changed files with 1 additions and 1 deletions

View File

@ -64,7 +64,7 @@ void generateInstSeq(int64_t Val, bool IsRV64, InstSeq &Res) {
// performed when the recursion returns.
int64_t Lo12 = SignExtend64<12>(Val);
int64_t Hi52 = (Val + 0x800) >> 12;
int64_t Hi52 = ((uint64_t)Val + 0x800ull) >> 12;
int ShiftAmount = 12 + findFirstSet((uint64_t)Hi52);
Hi52 = SignExtend64(Hi52 >> (ShiftAmount - 12), 64 - ShiftAmount);