tint/spir-v backend: emit OpSRem instead of OpSMod for remainder

operation

Bug: tint:1802
Change-Id: I690ef658874ba8d0d9cd8efa2a91324db175650b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118100
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Antonio Maiorano 2023-01-31 19:09:05 +00:00 committed by Dawn LUCI CQ
parent 18204a71c3
commit 635c5d0f04
23 changed files with 23 additions and 35 deletions

View File

@ -2129,7 +2129,7 @@ uint32_t Builder::GenerateBinaryExpression(const ast::BinaryExpression* expr) {
} else if (lhs_is_unsigned) {
op = spv::Op::OpUMod;
} else {
op = spv::Op::OpSMod;
op = spv::Op::OpSRem;
}
} else if (expr->IsMultiply()) {
if (lhs_type->is_integer_scalar_or_vector()) {

View File

@ -119,7 +119,7 @@ INSTANTIATE_TEST_SUITE_P(BuilderTest,
testing::Values(BinaryData{ast::BinaryOp::kAdd, "OpIAdd"},
BinaryData{ast::BinaryOp::kAnd, "OpBitwiseAnd"},
BinaryData{ast::BinaryOp::kDivide, "OpSDiv"},
BinaryData{ast::BinaryOp::kModulo, "OpSMod"},
BinaryData{ast::BinaryOp::kModulo, "OpSRem"},
BinaryData{ast::BinaryOp::kMultiply, "OpIMul"},
BinaryData{ast::BinaryOp::kOr, "OpBitwiseOr"},
BinaryData{ast::BinaryOp::kSubtract, "OpISub"},
@ -1458,7 +1458,7 @@ INSTANTIATE_TEST_SUITE_P(BuilderTest,
Param{Type::i32, ast::BinaryOp::kAdd, "OpIAdd"},
Param{Type::i32, ast::BinaryOp::kDivide, "OpSDiv"},
Param{Type::i32, ast::BinaryOp::kModulo, "OpSMod"},
Param{Type::i32, ast::BinaryOp::kModulo, "OpSRem"},
Param{Type::i32, ast::BinaryOp::kMultiply, "OpIMul"},
Param{Type::i32, ast::BinaryOp::kSubtract, "OpISub"},

View File

@ -31,7 +31,7 @@
%15 = OpLogicalAnd %bool %12 %14
%16 = OpLogicalOr %bool %9 %15
%7 = OpSelect %int %16 %int_1 %rhs
%18 = OpSMod %int %lhs %7
%18 = OpSRem %int %lhs %7
OpReturnValue %18
OpFunctionEnd
%f = OpFunction %void None %19

View File

@ -40,7 +40,7 @@
%20 = OpLogicalAnd %v3bool %16 %19
%21 = OpLogicalOr %v3bool %11 %20
%9 = OpSelect %v3int %21 %23 %rhs
%24 = OpSMod %v3int %8 %9
%24 = OpSRem %v3int %8 %9
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %25

View File

@ -40,7 +40,7 @@
%20 = OpLogicalAnd %v3bool %16 %19
%21 = OpLogicalOr %v3bool %11 %20
%9 = OpSelect %v3int %21 %23 %8
%24 = OpSMod %v3int %lhs %9
%24 = OpSRem %v3int %lhs %9
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %25

View File

@ -42,7 +42,7 @@
%19 = OpLogicalAnd %v3bool %15 %18
%20 = OpLogicalOr %v3bool %10 %19
%8 = OpSelect %v3int %20 %22 %rhs
%23 = OpSMod %v3int %lhs %8
%23 = OpSRem %v3int %lhs %8
OpReturnValue %23
OpFunctionEnd
%f = OpFunction %void None %24

View File

@ -30,7 +30,7 @@
%15 = OpLogicalAnd %bool %12 %14
%16 = OpLogicalOr %bool %9 %15
%7 = OpSelect %int %16 %int_1 %rhs
%18 = OpSMod %int %lhs %7
%18 = OpSRem %int %lhs %7
OpReturnValue %18
OpFunctionEnd
%f = OpFunction %void None %19

View File

@ -40,7 +40,7 @@
%20 = OpLogicalAnd %v3bool %16 %19
%21 = OpLogicalOr %v3bool %11 %20
%9 = OpSelect %v3int %21 %23 %rhs
%24 = OpSMod %v3int %8 %9
%24 = OpSRem %v3int %8 %9
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %25

View File

@ -40,7 +40,7 @@
%20 = OpLogicalAnd %v3bool %16 %19
%21 = OpLogicalOr %v3bool %11 %20
%9 = OpSelect %v3int %21 %23 %8
%24 = OpSMod %v3int %lhs %9
%24 = OpSRem %v3int %lhs %9
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %25

View File

@ -41,7 +41,7 @@
%19 = OpLogicalAnd %v3bool %15 %18
%20 = OpLogicalOr %v3bool %10 %19
%8 = OpSelect %v3int %20 %22 %rhs
%23 = OpSMod %v3int %lhs %8
%23 = OpSRem %v3int %lhs %8
OpReturnValue %23
OpFunctionEnd
%f = OpFunction %void None %24

View File

@ -33,7 +33,7 @@
%15 = OpLogicalAnd %bool %12 %14
%16 = OpLogicalOr %bool %9 %15
%7 = OpSelect %int %16 %int_1 %rhs
%18 = OpSMod %int %lhs %7
%18 = OpSRem %int %lhs %7
OpReturnValue %18
OpFunctionEnd
%f = OpFunction %void None %19

View File

@ -44,7 +44,7 @@
%20 = OpLogicalAnd %v3bool %16 %19
%21 = OpLogicalOr %v3bool %11 %20
%9 = OpSelect %v3int %21 %23 %rhs
%24 = OpSMod %v3int %8 %9
%24 = OpSRem %v3int %8 %9
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %25

View File

@ -44,7 +44,7 @@
%20 = OpLogicalAnd %v3bool %16 %19
%21 = OpLogicalOr %v3bool %11 %20
%9 = OpSelect %v3int %21 %23 %8
%24 = OpSMod %v3int %lhs %9
%24 = OpSRem %v3int %lhs %9
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %25

View File

@ -44,7 +44,7 @@
%19 = OpLogicalAnd %v3bool %15 %18
%20 = OpLogicalOr %v3bool %10 %19
%8 = OpSelect %v3int %20 %22 %rhs
%23 = OpSMod %v3int %lhs %8
%23 = OpSRem %v3int %lhs %8
OpReturnValue %23
OpFunctionEnd
%f = OpFunction %void None %24

View File

@ -33,7 +33,7 @@
%15 = OpLogicalAnd %bool %12 %14
%16 = OpLogicalOr %bool %9 %15
%7 = OpSelect %int %16 %int_1 %rhs
%18 = OpSMod %int %lhs %7
%18 = OpSRem %int %lhs %7
OpReturnValue %18
OpFunctionEnd
%f = OpFunction %void None %19

View File

@ -44,7 +44,7 @@
%20 = OpLogicalAnd %v3bool %16 %19
%21 = OpLogicalOr %v3bool %11 %20
%9 = OpSelect %v3int %21 %23 %rhs
%24 = OpSMod %v3int %8 %9
%24 = OpSRem %v3int %8 %9
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %25

View File

@ -44,7 +44,7 @@
%20 = OpLogicalAnd %v3bool %16 %19
%21 = OpLogicalOr %v3bool %11 %20
%9 = OpSelect %v3int %21 %23 %8
%24 = OpSMod %v3int %lhs %9
%24 = OpSRem %v3int %lhs %9
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %25

View File

@ -44,7 +44,7 @@
%19 = OpLogicalAnd %v3bool %15 %18
%20 = OpLogicalOr %v3bool %10 %19
%8 = OpSelect %v3int %20 %22 %rhs
%23 = OpSMod %v3int %lhs %8
%23 = OpSRem %v3int %lhs %8
OpReturnValue %23
OpFunctionEnd
%f = OpFunction %void None %24

View File

@ -61,7 +61,7 @@
%37 = OpLogicalAnd %bool %35 %36
%38 = OpLogicalOr %bool %34 %37
%33 = OpSelect %int %38 %int_1 %rhs_0
%39 = OpSMod %int %lhs_0 %33
%39 = OpSRem %int %lhs_0 %33
OpReturnValue %39
OpFunctionEnd
%foo = OpFunction %void None %40

View File

@ -53,7 +53,7 @@
%23 = OpLogicalAnd %bool %20 %22
%24 = OpLogicalOr %bool %17 %23
%15 = OpSelect %int %24 %int_1 %rhs
%26 = OpSMod %int %lhs %15
%26 = OpSRem %int %lhs %15
OpReturnValue %26
OpFunctionEnd
%foo = OpFunction %void None %6

View File

@ -59,7 +59,7 @@
%28 = OpLogicalAnd %v4bool %24 %27
%29 = OpLogicalOr %v4bool %19 %28
%17 = OpSelect %v4int %29 %31 %16
%32 = OpSMod %v4int %lhs %17
%32 = OpSRem %v4int %lhs %17
OpReturnValue %32
OpFunctionEnd
%foo = OpFunction %void None %7

View File

@ -59,7 +59,7 @@
%27 = OpLogicalAnd %v4bool %23 %26
%28 = OpLogicalOr %v4bool %18 %27
%16 = OpSelect %v4int %28 %30 %rhs
%31 = OpSMod %v4int %lhs %16
%31 = OpSRem %v4int %lhs %16
OpReturnValue %31
OpFunctionEnd
%foo = OpFunction %void None %7

View File

@ -409,29 +409,17 @@ crbug.com/dawn/0000 webgpu:api,validation,buffer,mapping:mapAsync,state,mappingP
crbug.com/dawn/0000 webgpu:api,validation,createBindGroupLayout:multisampled_validation:viewDimension="2d" [ Failure ]
crbug.com/dawn/0000 webgpu:api,validation,createBindGroupLayout:multisampled_validation:viewDimension="_undef_" [ Failure ]
crbug.com/dawn/0000 webgpu:api,validation,encoding,encoder_state:pass_end_twice: [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_r";vectorize="_undef_" [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_r";vectorize="_undef_" [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_r";vectorize=2 [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_r";vectorize=2 [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_r";vectorize=3 [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_r";vectorize=3 [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_r";vectorize=4 [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_r";vectorize=4 [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_rw";vectorize="_undef_" [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_rw";vectorize="_undef_" [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_rw";vectorize=2 [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_rw";vectorize=2 [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_rw";vectorize=3 [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_rw";vectorize=3 [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_rw";vectorize=4 [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="storage_rw";vectorize=4 [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="uniform";vectorize="_undef_" [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="uniform";vectorize="_undef_" [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="uniform";vectorize=2 [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="uniform";vectorize=2 [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="uniform";vectorize=3 [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="uniform";vectorize=3 [ Failure ]
crbug.com/dawn/0000 [ intel-gen-9 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="uniform";vectorize=4 [ Failure ]
crbug.com/dawn/0000 [ nvidia-0x2184 target-cpu-64 ubuntu ] webgpu:shader,execution,expression,binary,i32_arithmetic:remainder:inputSource="uniform";vectorize=4 [ Failure ]
crbug.com/dawn/0000 [ monterey ] webgpu:web_platform,canvas,configure:alpha_mode:* [ Failure ]
crbug.com/dawn/0000 [ monterey ] webgpu:web_platform,canvas,configure:defaults:* [ Failure ]