From b37279f65ca3bcd34db9cdb3ecab27dcd1bda77b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 1 Apr 2019 19:53:46 -0400 Subject: [PATCH] backend/x64/emit_x64_vector: Prevent undefined behavior within VectorSignedSaturatedShiftLeft Avoids undefined behavior by potentially left-shifting a signed negative value. --- src/backend/x64/emit_x64_vector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/x64/emit_x64_vector.cpp b/src/backend/x64/emit_x64_vector.cpp index a519cd09..03d47af0 100644 --- a/src/backend/x64/emit_x64_vector.cpp +++ b/src/backend/x64/emit_x64_vector.cpp @@ -3838,7 +3838,7 @@ static bool VectorSignedSaturatedShiftLeft(VectorArray& dst, const VectorArra dst[i] = saturate(element); qc_flag = true; } else { - const T shifted = element << shift; + const T shifted = T(U(element) << shift); if ((shifted >> shift) != element) { dst[i] = saturate(element);