Skip to content

Commit 8aba95d

Browse files
committed
[RISCV] Avoid signed integer overflow UB in RISCVMatInt::generateInstSeq
Found by UBSan. llvm-svn: 366398
1 parent ad73a43 commit 8aba95d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Target/RISCV/Utils/RISCVMatInt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void generateInstSeq(int64_t Val, bool IsRV64, InstSeq &Res) {
6464
// performed when the recursion returns.
6565

6666
int64_t Lo12 = SignExtend64<12>(Val);
67-
int64_t Hi52 = (Val + 0x800) >> 12;
67+
int64_t Hi52 = ((uint64_t)Val + 0x800ull) >> 12;
6868
int ShiftAmount = 12 + findFirstSet((uint64_t)Hi52);
6969
Hi52 = SignExtend64(Hi52 >> (ShiftAmount - 12), 64 - ShiftAmount);
7070

0 commit comments

Comments
 (0)