mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
Restore "MSL writer: make signed int overflow defined behaviour"
This reverts commit e33b0baa08.
Added tests/expressions/literals/intmin.wgsl test.
Bug: tint:124
Change-Id: I3d46f939ff20fa377ddb5fcb52f9afe728b8e430
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60441
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
9bdf2dcc6b
commit
d388bc9b36
7
test/expressions/literals/intmin.wgsl
Normal file
7
test/expressions/literals/intmin.wgsl
Normal file
@@ -0,0 +1,7 @@
|
||||
fn add_int_min_explicit() -> i32 {
|
||||
var a = -2147483648;
|
||||
var b = a + 1;
|
||||
|
||||
var c = -2147483648 + 1;
|
||||
return c;
|
||||
}
|
||||
11
test/expressions/literals/intmin.wgsl.expected.hlsl
Normal file
11
test/expressions/literals/intmin.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,11 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
int add_int_min_explicit() {
|
||||
int a = -2147483648;
|
||||
int b = (a + 1);
|
||||
int c = (-2147483648 + 1);
|
||||
return c;
|
||||
}
|
||||
10
test/expressions/literals/intmin.wgsl.expected.msl
Normal file
10
test/expressions/literals/intmin.wgsl.expected.msl
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int add_int_min_explicit() {
|
||||
int a = (-2147483647 - 1);
|
||||
int b = as_type<int>((as_type<uint>(a) + as_type<uint>(1)));
|
||||
int c = as_type<int>((as_type<uint>((-2147483647 - 1)) + as_type<uint>(1)));
|
||||
return c;
|
||||
}
|
||||
|
||||
40
test/expressions/literals/intmin.wgsl.expected.spvasm
Normal file
40
test/expressions/literals/intmin.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,40 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 20
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %add_int_min_explicit "add_int_min_explicit"
|
||||
OpName %a "a"
|
||||
OpName %b "b"
|
||||
OpName %c "c"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%5 = OpTypeFunction %int
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%_ptr_Function_int = OpTypePointer Function %int
|
||||
%12 = OpConstantNull %int
|
||||
%int_1 = OpConstant %int 1
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%add_int_min_explicit = OpFunction %int None %5
|
||||
%8 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_int Function %12
|
||||
%b = OpVariable %_ptr_Function_int Function %12
|
||||
%c = OpVariable %_ptr_Function_int Function %12
|
||||
OpStore %a %int_n2147483648
|
||||
%13 = OpLoad %int %a
|
||||
%15 = OpIAdd %int %13 %int_1
|
||||
OpStore %b %15
|
||||
%17 = OpIAdd %int %int_n2147483648 %int_1
|
||||
OpStore %c %17
|
||||
%19 = OpLoad %int %c
|
||||
OpReturnValue %19
|
||||
OpFunctionEnd
|
||||
6
test/expressions/literals/intmin.wgsl.expected.wgsl
Normal file
6
test/expressions/literals/intmin.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,6 @@
|
||||
fn add_int_min_explicit() -> i32 {
|
||||
var a = -2147483648;
|
||||
var b = (a + 1);
|
||||
var c = (-2147483648 + 1);
|
||||
return c;
|
||||
}
|
||||
Reference in New Issue
Block a user