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
e08c1bdae1
commit
f90a476546
@ -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…
x
Reference in New Issue
Block a user