Removes some undefined behaviour in the interpreter VExtr implementation

This commit is contained in:
Ryan Houdek committed 2020-09-26 12:52:26 -07:00
1 parent ddd7b8f406
commit a11aed2f47
1 file changed
+8 -1
@@ -3788,7 +3788,14 @@ void InterpreterCore::ExecuteCode(FEXCore::Core::InternalThreadState *Thread) {
__uint128_t Src2 = *GetSrc<__uint128_t*>(SSAData, Op->Header.Args[1]);
uint64_t Offset = Op->Index * Op->Header.ElementSize * 8;
__uint128_t Dst = (Src1 << (sizeof(__uint128_t) * 8 - Offset)) | (Src2 >> Offset);
__uint128_t Dst{};
if (Offset >= (OpSize * 8)) {
Offset -= OpSize * 8;
Dst = Src1 >> Offset;
}
else {
Dst = (Src1 << (OpSize * 8 - Offset)) | (Src2 >> Offset);
}
memcpy(GDP, &Dst, OpSize);
break;