[spirv-writer] Emit ShiftRightArithmetic.
This CL updates the SPIR-V writer to emit the arithmetic right shift if the LHS of the expression is a signed scalar or vector. Bug: tint:84 Change-Id: I4ca33a31783e1954515db5f12b2cf1d364aedee4 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28940 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
parent
effd888d2f
commit
45292213bd
src/writer/spirv
|
@ -1428,10 +1428,10 @@ uint32_t Builder::GenerateBinaryExpression(ast::BinaryExpression* expr) {
|
|||
op = spv::Op::OpBitwiseOr;
|
||||
} else if (expr->IsShiftLeft()) {
|
||||
op = spv::Op::OpShiftLeftLogical;
|
||||
} else if (expr->IsShiftRight() && lhs_type->is_signed_scalar_or_vector()) {
|
||||
// A shift right with a signed LHS is an arithmetic shift.
|
||||
op = spv::Op::OpShiftRightArithmetic;
|
||||
} else if (expr->IsShiftRight()) {
|
||||
// TODO(dsinclair): This depends on the type of the LHS if it's a
|
||||
// OpShiftRightLogical or OpShiftRightArithmetic
|
||||
// http://crbug.com/tint/84
|
||||
op = spv::Op::OpShiftRightLogical;
|
||||
} else if (expr->IsSubtract()) {
|
||||
op = lhs_is_float_or_vec ? spv::Op::OpFSub : spv::Op::OpISub;
|
||||
|
|
|
@ -135,7 +135,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
BinaryData{ast::BinaryOp::kOr, "OpBitwiseOr"},
|
||||
BinaryData{ast::BinaryOp::kShiftLeft, "OpShiftLeftLogical"},
|
||||
BinaryData{ast::BinaryOp::kShiftRight,
|
||||
"OpShiftRightLogical"},
|
||||
"OpShiftRightArithmetic"},
|
||||
BinaryData{ast::BinaryOp::kSubtract, "OpISub"},
|
||||
BinaryData{ast::BinaryOp::kXor, "OpBitwiseXor"}));
|
||||
|
||||
|
|
Loading…
Reference in New Issue