tint/transform: Polyfill bit-shift with RHS modulo

Fixed: tint:1453
Fixed: tint:1543
Change-Id: Idb5af752d7a3bb9e181cc47430ad4ddfb707873d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108440
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2022-11-03 19:15:17 +00:00
committed by Dawn LUCI CQ
parent 91e27f25f9
commit 02f04d914d
47 changed files with 345 additions and 157 deletions

View File

@@ -2,6 +2,6 @@
void f() {
const int a = 1;
const uint b = 2u;
const int r = (a << b);
const int r = (a << (b & 31u));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const int a = 1;
const uint b = 2u;
const int r = (a << b);
const int r = (a << (b & 31u));
return;
}

View File

@@ -3,7 +3,7 @@
void f() {
int a = 1;
uint b = 2u;
int r = (a << b);
int r = (a << (b & 31u));
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@@ -4,7 +4,7 @@ using namespace metal;
kernel void f() {
int const a = 1;
uint const b = 2u;
int const r = as_type<int>((as_type<uint>(a) << b));
int const r = as_type<int>((as_type<uint>(a) << (b & 31u)));
return;
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 10
; Bound: 12
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -14,8 +14,10 @@
%int_1 = OpConstant %int 1
%uint = OpTypeInt 32 0
%uint_2 = OpConstant %uint 2
%uint_31 = OpConstant %uint 31
%f = OpFunction %void None %1
%4 = OpLabel
%9 = OpShiftLeftLogical %int %int_1 %uint_2
%10 = OpBitwiseAnd %uint %uint_2 %uint_31
%11 = OpShiftLeftLogical %int %int_1 %10
OpReturn
OpFunctionEnd

View File

@@ -2,6 +2,6 @@
void f() {
const uint a = 1u;
const uint b = 2u;
const uint r = (a << b);
const uint r = (a << (b & 31u));
return;
}

View File

@@ -2,6 +2,6 @@
void f() {
const uint a = 1u;
const uint b = 2u;
const uint r = (a << b);
const uint r = (a << (b & 31u));
return;
}

View File

@@ -3,7 +3,7 @@
void f() {
uint a = 1u;
uint b = 2u;
uint r = (a << b);
uint r = (a << (b & 31u));
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@@ -4,7 +4,7 @@ using namespace metal;
kernel void f() {
uint const a = 1u;
uint const b = 2u;
uint const r = (a << b);
uint const r = (a << (b & 31u));
return;
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 9
; Bound: 11
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -13,8 +13,10 @@
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_31 = OpConstant %uint 31
%f = OpFunction %void None %1
%4 = OpLabel
%8 = OpShiftLeftLogical %uint %uint_1 %uint_2
%9 = OpBitwiseAnd %uint %uint_2 %uint_31
%10 = OpShiftLeftLogical %uint %uint_1 %9
OpReturn
OpFunctionEnd