[tint][ir] Fix unittests that used invalid binary-ops
Change-Id: Ida1176328988490b9adeb25e18d3aec89287997d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/168221
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/core/ir/transform/binary_polyfill_test.cc b/src/tint/lang/core/ir/transform/binary_polyfill_test.cc
index 2d0ae9f..b582411 100644
--- a/src/tint/lang/core/ir/transform/binary_polyfill_test.cc
+++ b/src/tint/lang/core/ir/transform/binary_polyfill_test.cc
@@ -63,9 +63,9 @@
};
TEST_F(IR_BinaryPolyfillTest, ShiftLeft_NoPolyfill) {
- Build(BinaryOp::kShiftLeft, ty.i32(), ty.i32(), ty.i32());
+ Build(BinaryOp::kShiftLeft, ty.i32(), ty.i32(), ty.u32());
auto* src = R"(
-%foo = func(%lhs:i32, %rhs:i32):i32 -> %b1 {
+%foo = func(%lhs:i32, %rhs:u32):i32 -> %b1 {
%b1 = block {
%result:i32 = shl %lhs, %rhs
ret %result
@@ -83,9 +83,9 @@
}
TEST_F(IR_BinaryPolyfillTest, ShiftRight_NoPolyfill) {
- Build(BinaryOp::kShiftRight, ty.i32(), ty.i32(), ty.i32());
+ Build(BinaryOp::kShiftRight, ty.i32(), ty.i32(), ty.u32());
auto* src = R"(
-%foo = func(%lhs:i32, %rhs:i32):i32 -> %b1 {
+%foo = func(%lhs:i32, %rhs:u32):i32 -> %b1 {
%b1 = block {
%result:i32 = shr %lhs, %rhs
ret %result
@@ -103,9 +103,9 @@
}
TEST_F(IR_BinaryPolyfillTest, ShiftLeft_I32) {
- Build(BinaryOp::kShiftLeft, ty.i32(), ty.i32(), ty.i32());
+ Build(BinaryOp::kShiftLeft, ty.i32(), ty.i32(), ty.u32());
auto* src = R"(
-%foo = func(%lhs:i32, %rhs:i32):i32 -> %b1 {
+%foo = func(%lhs:i32, %rhs:u32):i32 -> %b1 {
%b1 = block {
%result:i32 = shl %lhs, %rhs
ret %result
@@ -113,9 +113,9 @@
}
)";
auto* expect = R"(
-%foo = func(%lhs:i32, %rhs:i32):i32 -> %b1 {
+%foo = func(%lhs:i32, %rhs:u32):i32 -> %b1 {
%b1 = block {
- %4:i32 = and %rhs, 31u
+ %4:u32 = and %rhs, 31u
%result:i32 = shl %lhs, %4
ret %result
}
@@ -159,9 +159,9 @@
}
TEST_F(IR_BinaryPolyfillTest, ShiftLeft_Vec2I32) {
- Build(BinaryOp::kShiftLeft, ty.vec2<i32>(), ty.vec2<i32>(), ty.vec2<i32>());
+ Build(BinaryOp::kShiftLeft, ty.vec2<i32>(), ty.vec2<i32>(), ty.vec2<u32>());
auto* src = R"(
-%foo = func(%lhs:vec2<i32>, %rhs:vec2<i32>):vec2<i32> -> %b1 {
+%foo = func(%lhs:vec2<i32>, %rhs:vec2<u32>):vec2<i32> -> %b1 {
%b1 = block {
%result:vec2<i32> = shl %lhs, %rhs
ret %result
@@ -169,9 +169,9 @@
}
)";
auto* expect = R"(
-%foo = func(%lhs:vec2<i32>, %rhs:vec2<i32>):vec2<i32> -> %b1 {
+%foo = func(%lhs:vec2<i32>, %rhs:vec2<u32>):vec2<i32> -> %b1 {
%b1 = block {
- %4:vec2<i32> = and %rhs, vec2<u32>(31u)
+ %4:vec2<u32> = and %rhs, vec2<u32>(31u)
%result:vec2<i32> = shl %lhs, %4
ret %result
}
@@ -215,9 +215,9 @@
}
TEST_F(IR_BinaryPolyfillTest, ShiftRight_I32) {
- Build(BinaryOp::kShiftRight, ty.i32(), ty.i32(), ty.i32());
+ Build(BinaryOp::kShiftRight, ty.i32(), ty.i32(), ty.u32());
auto* src = R"(
-%foo = func(%lhs:i32, %rhs:i32):i32 -> %b1 {
+%foo = func(%lhs:i32, %rhs:u32):i32 -> %b1 {
%b1 = block {
%result:i32 = shr %lhs, %rhs
ret %result
@@ -225,9 +225,9 @@
}
)";
auto* expect = R"(
-%foo = func(%lhs:i32, %rhs:i32):i32 -> %b1 {
+%foo = func(%lhs:i32, %rhs:u32):i32 -> %b1 {
%b1 = block {
- %4:i32 = and %rhs, 31u
+ %4:u32 = and %rhs, 31u
%result:i32 = shr %lhs, %4
ret %result
}
@@ -271,9 +271,9 @@
}
TEST_F(IR_BinaryPolyfillTest, ShiftRight_Vec2I32) {
- Build(BinaryOp::kShiftRight, ty.vec2<i32>(), ty.vec2<i32>(), ty.vec2<i32>());
+ Build(BinaryOp::kShiftRight, ty.vec2<i32>(), ty.vec2<i32>(), ty.vec2<u32>());
auto* src = R"(
-%foo = func(%lhs:vec2<i32>, %rhs:vec2<i32>):vec2<i32> -> %b1 {
+%foo = func(%lhs:vec2<i32>, %rhs:vec2<u32>):vec2<i32> -> %b1 {
%b1 = block {
%result:vec2<i32> = shr %lhs, %rhs
ret %result
@@ -281,9 +281,9 @@
}
)";
auto* expect = R"(
-%foo = func(%lhs:vec2<i32>, %rhs:vec2<i32>):vec2<i32> -> %b1 {
+%foo = func(%lhs:vec2<i32>, %rhs:vec2<u32>):vec2<i32> -> %b1 {
%b1 = block {
- %4:vec2<i32> = and %rhs, vec2<u32>(31u)
+ %4:vec2<u32> = and %rhs, vec2<u32>(31u)
%result:vec2<i32> = shr %lhs, %4
ret %result
}
diff --git a/src/tint/lang/wgsl/writer/raise/rename_conflicts_test.cc b/src/tint/lang/wgsl/writer/raise/rename_conflicts_test.cc
index 3adb76c..6facee7 100644
--- a/src/tint/lang/wgsl/writer/raise/rename_conflicts_test.cc
+++ b/src/tint/lang/wgsl/writer/raise/rename_conflicts_test.cc
@@ -202,7 +202,7 @@
b.Append(fn->Block(), [&] {
auto* load_outer = b.Load(outer);
- auto* inner = b.Var(ty.ptr<function, f32>());
+ auto* inner = b.Var(ty.ptr<function, i32>());
b.ir.SetName(inner, "v");
auto* load_inner = b.Load(inner);
@@ -218,8 +218,8 @@
%f = func():i32 -> %b2 {
%b2 = block {
%3:i32 = load %v
- %v_1:ptr<function, f32, read_write> = var # %v_1: 'v'
- %5:f32 = load %v_1
+ %v_1:ptr<function, i32, read_write> = var # %v_1: 'v'
+ %5:i32 = load %v_1
%6:i32 = add %3, %5
ret %6
}
@@ -241,7 +241,7 @@
auto* fn = b.Function("f", ty.i32());
b.Append(fn->Block(), [&] {
- auto* inner = b.Var(ty.ptr<function, f32>());
+ auto* inner = b.Var(ty.ptr<function, i32>());
b.ir.SetName(inner, "v");
auto* load_outer = b.Load(outer);
@@ -257,9 +257,9 @@
%f = func():i32 -> %b2 {
%b2 = block {
- %v_1:ptr<function, f32, read_write> = var # %v_1: 'v'
+ %v_1:ptr<function, i32, read_write> = var # %v_1: 'v'
%4:i32 = load %v
- %5:f32 = load %v_1
+ %5:i32 = load %v_1
%6:i32 = add %4, %5
ret %6
}
@@ -274,9 +274,9 @@
%f = func():i32 -> %b2 {
%b2 = block {
- %v_1:ptr<function, f32, read_write> = var
+ %v_1:ptr<function, i32, read_write> = var
%4:i32 = load %v
- %5:f32 = load %v_1
+ %5:i32 = load %v_1
%6:i32 = add %4, %5
ret %6
}
@@ -291,14 +291,14 @@
TEST_F(IRToProgramRenameConflictsTest, NoModify_FnVar_ShadowedBy_IfVar) {
auto* fn = b.Function("f", ty.i32());
b.Append(fn->Block(), [&] {
- auto* outer = b.Var(ty.ptr<function, f32>());
+ auto* outer = b.Var(ty.ptr<function, i32>());
b.ir.SetName(outer, "v");
auto* if_ = b.If(true);
b.Append(if_->True(), [&] {
auto* load_outer = b.Load(outer);
- auto* inner = b.Var(ty.ptr<function, f32>());
+ auto* inner = b.Var(ty.ptr<function, i32>());
b.ir.SetName(inner, "v");
auto* load_inner = b.Load(inner);
@@ -311,12 +311,12 @@
auto* src = R"(
%f = func():i32 -> %b1 {
%b1 = block {
- %v:ptr<function, f32, read_write> = var
+ %v:ptr<function, i32, read_write> = var
if true [t: %b2] { # if_1
%b2 = block { # true
- %3:f32 = load %v
- %v_1:ptr<function, f32, read_write> = var # %v_1: 'v'
- %5:f32 = load %v_1
+ %3:i32 = load %v
+ %v_1:ptr<function, i32, read_write> = var # %v_1: 'v'
+ %5:i32 = load %v_1
%6:i32 = add %3, %5
ret %6
}
@@ -337,12 +337,12 @@
TEST_F(IRToProgramRenameConflictsTest, Conflict_FnVar_ShadowedBy_IfVar) {
auto* fn = b.Function("f", ty.i32());
b.Append(fn->Block(), [&] {
- auto* outer = b.Var(ty.ptr<function, f32>());
+ auto* outer = b.Var(ty.ptr<function, i32>());
b.ir.SetName(outer, "v");
auto* if_ = b.If(true);
b.Append(if_->True(), [&] {
- auto* inner = b.Var(ty.ptr<function, f32>());
+ auto* inner = b.Var(ty.ptr<function, i32>());
b.ir.SetName(inner, "v");
auto* load_outer = b.Load(outer);
@@ -356,12 +356,12 @@
auto* src = R"(
%f = func():i32 -> %b1 {
%b1 = block {
- %v:ptr<function, f32, read_write> = var
+ %v:ptr<function, i32, read_write> = var
if true [t: %b2] { # if_1
%b2 = block { # true
- %v_1:ptr<function, f32, read_write> = var # %v_1: 'v'
- %4:f32 = load %v
- %5:f32 = load %v_1
+ %v_1:ptr<function, i32, read_write> = var # %v_1: 'v'
+ %4:i32 = load %v
+ %5:i32 = load %v_1
%6:i32 = add %4, %5
ret %6
}
@@ -375,12 +375,12 @@
auto* expect = R"(
%f = func():i32 -> %b1 {
%b1 = block {
- %v:ptr<function, f32, read_write> = var
+ %v:ptr<function, i32, read_write> = var
if true [t: %b2] { # if_1
%b2 = block { # true
- %v_1:ptr<function, f32, read_write> = var
- %4:f32 = load %v
- %5:f32 = load %v_1
+ %v_1:ptr<function, i32, read_write> = var
+ %4:i32 = load %v
+ %5:i32 = load %v_1
%6:i32 = add %4, %5
ret %6
}
@@ -400,14 +400,14 @@
b.Append(fn->Block(), [&] {
auto* loop = b.Loop();
b.Append(loop->Initializer(), [&] {
- auto* outer = b.Var(ty.ptr<function, f32>());
+ auto* outer = b.Var(ty.ptr<function, i32>());
b.ir.SetName(outer, "v");
b.NextIteration(loop);
b.Append(loop->Body(), [&] {
auto* load_outer = b.Load(outer);
- auto* inner = b.Var(ty.ptr<function, f32>());
+ auto* inner = b.Var(ty.ptr<function, i32>());
b.ir.SetName(inner, "v");
auto* load_inner = b.Load(inner);
@@ -423,13 +423,13 @@
%b1 = block {
loop [i: %b2, b: %b3] { # loop_1
%b2 = block { # initializer
- %v:ptr<function, f32, read_write> = var
+ %v:ptr<function, i32, read_write> = var
next_iteration %b3
}
%b3 = block { # body
- %3:f32 = load %v
- %v_1:ptr<function, f32, read_write> = var # %v_1: 'v'
- %5:f32 = load %v_1
+ %3:i32 = load %v
+ %v_1:ptr<function, i32, read_write> = var # %v_1: 'v'
+ %5:i32 = load %v_1
%6:i32 = add %3, %5
ret %6
}
@@ -452,12 +452,12 @@
b.Append(fn->Block(), [&] {
auto* loop = b.Loop();
b.Append(loop->Initializer(), [&] {
- auto* outer = b.Var(ty.ptr<function, f32>());
+ auto* outer = b.Var(ty.ptr<function, i32>());
b.ir.SetName(outer, "v");
b.NextIteration(loop);
b.Append(loop->Body(), [&] {
- auto* inner = b.Var(ty.ptr<function, f32>());
+ auto* inner = b.Var(ty.ptr<function, i32>());
b.ir.SetName(inner, "v");
auto* load_outer = b.Load(outer);
@@ -474,13 +474,13 @@
%b1 = block {
loop [i: %b2, b: %b3] { # loop_1
%b2 = block { # initializer
- %v:ptr<function, f32, read_write> = var
+ %v:ptr<function, i32, read_write> = var
next_iteration %b3
}
%b3 = block { # body
- %v_1:ptr<function, f32, read_write> = var # %v_1: 'v'
- %4:f32 = load %v
- %5:f32 = load %v_1
+ %v_1:ptr<function, i32, read_write> = var # %v_1: 'v'
+ %4:i32 = load %v
+ %5:i32 = load %v_1
%6:i32 = add %4, %5
ret %6
}
@@ -496,13 +496,13 @@
%b1 = block {
loop [i: %b2, b: %b3] { # loop_1
%b2 = block { # initializer
- %v:ptr<function, f32, read_write> = var
+ %v:ptr<function, i32, read_write> = var
next_iteration %b3
}
%b3 = block { # body
- %v_1:ptr<function, f32, read_write> = var
- %4:f32 = load %v
- %5:f32 = load %v_1
+ %v_1:ptr<function, i32, read_write> = var
+ %4:i32 = load %v
+ %5:i32 = load %v_1
%6:i32 = add %4, %5
ret %6
}
@@ -523,14 +523,14 @@
auto* loop = b.Loop();
b.Append(loop->Initializer(), [&] { b.NextIteration(loop); });
b.Append(loop->Body(), [&] {
- auto* outer = b.Var(ty.ptr<function, f32>());
+ auto* outer = b.Var(ty.ptr<function, i32>());
b.ir.SetName(outer, "v");
b.Continue(loop);
b.Append(loop->Continuing(), [&] {
auto* load_outer = b.Load(outer);
- auto* inner = b.Var(ty.ptr<function, f32>());
+ auto* inner = b.Var(ty.ptr<function, i32>());
b.ir.SetName(inner, "v");
auto* load_inner = b.Load(inner);
@@ -549,13 +549,13 @@
next_iteration %b3
}
%b3 = block { # body
- %v:ptr<function, f32, read_write> = var
+ %v:ptr<function, i32, read_write> = var
continue %b4
}
%b4 = block { # continuing
- %3:f32 = load %v
- %v_1:ptr<function, f32, read_write> = var # %v_1: 'v'
- %5:f32 = load %v_1
+ %3:i32 = load %v
+ %v_1:ptr<function, i32, read_write> = var # %v_1: 'v'
+ %5:i32 = load %v_1
%6:i32 = add %3, %5
ret %6
}
@@ -579,12 +579,12 @@
auto* loop = b.Loop();
b.Append(loop->Initializer(), [&] { b.NextIteration(loop); });
b.Append(loop->Body(), [&] {
- auto* outer = b.Var(ty.ptr<function, f32>());
+ auto* outer = b.Var(ty.ptr<function, i32>());
b.ir.SetName(outer, "v");
b.Continue(loop);
b.Append(loop->Continuing(), [&] {
- auto* inner = b.Var(ty.ptr<function, f32>());
+ auto* inner = b.Var(ty.ptr<function, i32>());
b.ir.SetName(inner, "v");
auto* load_outer = b.Load(outer);
@@ -604,13 +604,13 @@
next_iteration %b3
}
%b3 = block { # body
- %v:ptr<function, f32, read_write> = var
+ %v:ptr<function, i32, read_write> = var
continue %b4
}
%b4 = block { # continuing
- %v_1:ptr<function, f32, read_write> = var # %v_1: 'v'
- %4:f32 = load %v
- %5:f32 = load %v_1
+ %v_1:ptr<function, i32, read_write> = var # %v_1: 'v'
+ %4:i32 = load %v
+ %5:i32 = load %v_1
%6:i32 = add %4, %5
ret %6
}
@@ -629,13 +629,13 @@
next_iteration %b3
}
%b3 = block { # body
- %v:ptr<function, f32, read_write> = var
+ %v:ptr<function, i32, read_write> = var
continue %b4
}
%b4 = block { # continuing
- %v_1:ptr<function, f32, read_write> = var
- %4:f32 = load %v
- %5:f32 = load %v_1
+ %v_1:ptr<function, i32, read_write> = var
+ %4:i32 = load %v
+ %5:i32 = load %v_1
%6:i32 = add %4, %5
ret %6
}