emit_x64_vector: Avoid left shift of negative value in LogicalVShift
Now that we handle the signed variants, we also have to be careful about left shifts with negative values, as this is considered undefined behavior.
This commit is contained in:
parent
9954d28868
commit
5b71b1337b
1 changed files with 2 additions and 1 deletions
|
@ -945,7 +945,8 @@ static constexpr T LogicalVShift(T x, T y) {
|
|||
return x >> T(-shift_amount);
|
||||
}
|
||||
|
||||
return x << T(shift_amount);
|
||||
using unsigned_type = std::make_unsigned_t<T>;
|
||||
return static_cast<T>(static_cast<unsigned_type>(x) << static_cast<unsigned_type>(shift_amount));
|
||||
}
|
||||
|
||||
void EmitX64::EmitVectorLogicalVShiftS8(EmitContext& ctx, IR::Inst* inst) {
|
||||
|
|
Loading…
Reference in a new issue