tint: const eval of binary add

Bug: tint:1581
Change-Id: Ie34ee52bdd4a4c5d45a5f6c0d8d923cc690c8b2c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98021
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Antonio Maiorano 2022-08-04 19:48:27 +00:00 committed by Dawn LUCI CQ
parent b8893b4c2f
commit 7e9f571814
85 changed files with 754 additions and 474 deletions

View File

@ -886,11 +886,11 @@ op ! <N: num> (vec<N, bool>) -> vec<N, bool>
////////////////////////////////////////////////////////////////////////////////
// Binary Operators //
////////////////////////////////////////////////////////////////////////////////
op + <T: fiu32_f16>(T, T) -> T
op + <T: fiu32_f16, N: num> (vec<N, T>, vec<N, T>) -> vec<N, T>
op + <T: fiu32_f16, N: num> (vec<N, T>, T) -> vec<N, T>
op + <T: fiu32_f16, N: num> (T, vec<N, T>) -> vec<N, T>
op + <T: f32_f16, N: num, M: num> (mat<N, M, T>, mat<N, M, T>) -> mat<N, M, T>
@const op + <T: fia_fiu32_f16>(T, T) -> T
@const op + <T: fia_fiu32_f16, N: num> (vec<N, T>, vec<N, T>) -> vec<N, T>
@const op + <T: fia_fiu32_f16, N: num> (vec<N, T>, T) -> vec<N, T>
@const op + <T: fia_fiu32_f16, N: num> (T, vec<N, T>) -> vec<N, T>
@const op + <T: fa_f32_f16, N: num, M: num> (mat<N, M, T>, mat<N, M, T>) -> mat<N, M, T>
op - <T: fiu32_f16>(T, T) -> T
op - <T: fiu32_f16, N: num> (vec<N, T>, vec<N, T>) -> vec<N, T>

View File

@ -458,7 +458,7 @@ const Constant* CreateComposite(ProgramBuilder& builder,
}
/// TransformElements constructs a new constant by applying the transformation function 'f' on each
/// of the most deeply nested elements of 'cs'.
/// of the most deeply nested elements of 'cs'. Assumes that all constants are the same type.
template <typename F, typename... CONSTANTS>
const Constant* TransformElements(ProgramBuilder& builder, F&& f, CONSTANTS&&... cs) {
uint32_t n = 0;
@ -470,11 +470,54 @@ const Constant* TransformElements(ProgramBuilder& builder, F&& f, CONSTANTS&&...
utils::Vector<const sem::Constant*, 8> els;
els.Reserve(n);
for (uint32_t i = 0; i < n; i++) {
els.Push(TransformElements(builder, f, cs->Index(i)...));
els.Push(TransformElements(builder, std::forward<F>(f), cs->Index(i)...));
}
return CreateComposite(builder, ty, std::move(els));
}
/// TransformBinaryElements constructs a new constant by applying the transformation function 'f' on
/// each of the most deeply nested elements of both `c0` and `c1`. Unlike TransformElements, this
/// function handles the constants being of different types, e.g. vector-scalar, scalar-vector.
template <typename F>
const Constant* TransformBinaryElements(ProgramBuilder& builder,
F&& f,
const sem::Constant* c0,
const sem::Constant* c1) {
uint32_t n0 = 0, n1 = 0;
sem::Type::ElementOf(c0->Type(), &n0);
sem::Type::ElementOf(c1->Type(), &n1);
uint32_t max_n = std::max(n0, n1);
// If arity of both constants is 1, invoke callback
if (max_n == 1u) {
return f(c0, c1);
}
utils::Vector<const sem::Constant*, 8> els;
els.Reserve(max_n);
for (uint32_t i = 0; i < max_n; i++) {
auto nested_or_self = [&](auto& c, uint32_t num_elems) {
if (num_elems == 1) {
return c;
}
return c->Index(i);
};
els.Push(TransformBinaryElements(builder, std::forward<F>(f), nested_or_self(c0, n0),
nested_or_self(c1, n1)));
}
// Use larger type
auto* ty = n0 > n1 ? c0->Type() : c1->Type();
return CreateComposite(builder, ty, std::move(els));
}
/// CombineSource returns the combined `Source`s of each expression in `exprs`.
Source CombineSource(utils::VectorRef<const sem::Expression*> exprs) {
Source result = exprs[0]->Declaration()->source;
for (size_t i = 1; i < exprs.Length(); ++i) {
result = result.Combine(result, exprs[i]->Declaration()->source);
}
return result;
}
} // namespace
ConstEval::ConstEval(ProgramBuilder& b) : builder(b) {}
@ -722,6 +765,51 @@ ConstEval::ConstantResult ConstEval::OpMinus(const sem::Type*,
return TransformElements(builder, transform, args[0]->ConstantValue());
}
ConstEval::ConstantResult ConstEval::OpPlus(const sem::Type* ty,
utils::VectorRef<const sem::Expression*> args) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
auto create = [&](auto i, auto j) -> const Constant* {
using NumberT = decltype(i);
using T = UnwrapNumber<NumberT>;
auto add_values = [](T lhs, T rhs) {
if constexpr (std::is_integral_v<T> && std::is_signed_v<T>) {
// Ensure no UB for signed overflow
using UT = std::make_unsigned_t<T>;
return static_cast<T>(static_cast<UT>(lhs) + static_cast<UT>(rhs));
} else {
return lhs + rhs;
}
};
NumberT result;
if constexpr (std::is_same_v<NumberT, AInt> || std::is_same_v<NumberT, AFloat>) {
// Check for over/underflow for abstract values
if (auto r = CheckedAdd(i, j)) {
result = r->value;
} else {
AddError("'" + std::to_string(add_values(i.value, j.value)) +
"' cannot be represented as '" +
ty->FriendlyName(builder.Symbols()) + "'",
CombineSource(args));
return nullptr;
}
} else {
result = add_values(i.value, j.value);
}
return CreateElement(builder, c0->Type(), result);
};
return Dispatch_fia_fiu32_f16(create, c0, c1);
};
auto r = TransformBinaryElements(builder, transform, args[0]->ConstantValue(),
args[1]->ConstantValue());
if (builder.Diagnostics().contains_errors()) {
return utils::Failure;
}
return r;
}
ConstEval::ConstantResult ConstEval::atan2(const sem::Type*,
utils::VectorRef<const sem::Expression*> args) {
auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {

View File

@ -177,6 +177,16 @@ class ConstEval {
/// @return the result value, or null if the value cannot be calculated
ConstantResult OpMinus(const sem::Type* ty, utils::VectorRef<const sem::Expression*> args);
////////////////////////////////////////////////////////////////////////////
// Binary Operators
////////////////////////////////////////////////////////////////////////////
/// Plus operator '+'
/// @param ty the expression type
/// @param args the input arguments
/// @return the result value, or null if the value cannot be calculated
ConstantResult OpPlus(const sem::Type* ty, utils::VectorRef<const sem::Expression*> args);
////////////////////////////////////////////////////////////////////////////
// Builtins
////////////////////////////////////////////////////////////////////////////

View File

@ -43,15 +43,26 @@ const auto k3PiOver4 = T(UnwrapNumber<T>(2.356194490192344928846));
template <typename T>
constexpr auto Negate(const Number<T>& v) {
if constexpr (std::is_integral_v<T>) {
if constexpr (std::is_signed_v<T>) {
// For signed integrals, avoid C++ UB by not negating the smallest negative number. In
// WGSL, this operation is well defined to return the same value, see:
// https://gpuweb.github.io/gpuweb/wgsl/#arithmetic-expr.
if constexpr (std::is_integral_v<T> && std::is_signed_v<T>) {
if (v == std::numeric_limits<T>::min()) {
return v;
}
}
return -v;
} else {
// Allow negating unsigned values
using ST = std::make_signed_t<T>;
auto as_signed = Number<ST>{static_cast<ST>(v)};
return Number<T>{static_cast<T>(Negate(as_signed))};
}
} else {
// float case
return -v;
}
}
template <typename T>
@ -65,7 +76,7 @@ auto Abs(const Number<T>& v) {
// Concats any number of std::vectors
template <typename Vec, typename... Vecs>
auto Concat(Vec&& v1, Vecs&&... vs) {
[[nodiscard]] auto Concat(Vec&& v1, Vecs&&... vs) {
auto total_size = v1.size() + (vs.size() + ...);
v1.reserve(total_size);
(std::move(vs.begin(), vs.end(), std::back_inserter(v1)), ...);
@ -3115,6 +3126,140 @@ TEST_F(ResolverConstEvalTest, UnaryNegateLowestAbstract) {
} // namespace unary_op
////////////////////////////////////////////////////////////////////////////////////////////////////
// Binary op
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace binary_op {
template <typename T>
struct Values {
T lhs;
T rhs;
T expect;
bool is_overflow;
};
struct Case {
std::variant<Values<AInt>, Values<AFloat>, Values<u32>, Values<i32>, Values<f32>, Values<f16>>
values;
};
static std::ostream& operator<<(std::ostream& o, const Case& c) {
std::visit([&](auto&& v) { o << v.lhs << " " << v.rhs; }, c.values);
return o;
}
template <typename T>
Case C(T lhs, T rhs, T expect, bool is_overflow = false) {
return Case{Values<T>{lhs, rhs, expect, is_overflow}};
}
using ResolverConstEvalBinaryOpTest = ResolverTestWithParam<std::tuple<ast::BinaryOp, Case>>;
TEST_P(ResolverConstEvalBinaryOpTest, Test) {
Enable(ast::Extension::kF16);
auto op = std::get<0>(GetParam());
auto c = std::get<1>(GetParam());
std::visit(
[&](auto&& values) {
using T = decltype(values.expect);
if constexpr (std::is_same_v<T, AInt> || std::is_same_v<T, AFloat>) {
if (values.is_overflow) {
return;
}
}
auto* expr = create<ast::BinaryExpression>(op, Expr(values.lhs), Expr(values.rhs));
GlobalConst("C", nullptr, expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
auto* sem = Sem().Get(expr);
const sem::Constant* value = sem->ConstantValue();
ASSERT_NE(value, nullptr);
EXPECT_TYPE(value->Type(), sem->Type());
EXPECT_EQ(value->As<T>(), values.expect);
if constexpr (IsInteger<UnwrapNumber<T>>) {
// Check that the constant's integer doesn't contain unexpected data in the MSBs
// that are outside of the bit-width of T.
EXPECT_EQ(value->As<AInt>(), AInt(values.expect));
}
},
c.values);
}
template <typename T>
std::vector<Case> OpAddIntCases() {
static_assert(IsInteger<UnwrapNumber<T>>);
return {
C(T{0}, T{0}, T{0}),
C(T{1}, T{2}, T{3}),
C(T::Lowest(), T{1}, T{T::Lowest() + 1}),
C(T::Highest(), Negate(T{1}), T{T::Highest() - 1}),
C(T::Lowest(), T::Highest(), Negate(T{1})),
C(T::Highest(), T{1}, T::Lowest(), true),
C(T::Lowest(), Negate(T{1}), T::Highest(), true),
};
}
template <typename T>
std::vector<Case> OpAddFloatCases() {
static_assert(IsFloatingPoint<UnwrapNumber<T>>);
return {
C(T{0}, T{0}, T{0}),
C(T{1}, T{2}, T{3}),
C(T::Lowest(), T{1}, T{T::Lowest() + 1}),
C(T::Highest(), Negate(T{1}), T{T::Highest() - 1}),
C(T::Lowest(), T::Highest(), T{0}),
C(T::Highest(), T::Highest(), T::Inf(), true),
C(T::Lowest(), Negate(T::Highest()), -T::Inf(), true),
};
}
INSTANTIATE_TEST_SUITE_P(Add,
ResolverConstEvalBinaryOpTest,
testing::Combine(testing::Values(ast::BinaryOp::kAdd),
testing::ValuesIn(Concat( //
OpAddIntCases<AInt>(),
OpAddIntCases<i32>(),
OpAddIntCases<u32>(),
OpAddFloatCases<AFloat>(),
OpAddFloatCases<f32>(),
OpAddFloatCases<f16>() //
))));
TEST_F(ResolverConstEvalTest, BinaryAbstractAddOverflow_AInt) {
GlobalConst("c", nullptr, Add(Expr(Source{{1, 1}}, AInt::Highest()), 1_a));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"1:1 error: '-9223372036854775808' cannot be represented as 'abstract-int'");
}
TEST_F(ResolverConstEvalTest, BinaryAbstractAddUnderflow_AInt) {
GlobalConst("c", nullptr, Add(Expr(Source{{1, 1}}, AInt::Lowest()), -1_a));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"1:1 error: '9223372036854775807' cannot be represented as 'abstract-int'");
}
TEST_F(ResolverConstEvalTest, BinaryAbstractAddOverflow_AFloat) {
GlobalConst("c", nullptr, Add(Expr(Source{{1, 1}}, AFloat::Highest()), AFloat::Highest()));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "1:1 error: 'inf' cannot be represented as 'abstract-float'");
}
TEST_F(ResolverConstEvalTest, BinaryAbstractAddUnderflow_AFloat) {
GlobalConst("c", nullptr, Add(Expr(Source{{1, 1}}, AFloat::Lowest()), AFloat::Lowest()));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "1:1 error: '-inf' cannot be represented as 'abstract-float'");
}
} // namespace binary_op
////////////////////////////////////////////////////////////////////////////////////////////////////
// Builtin
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace builtin {
template <typename T>

View File

@ -11040,60 +11040,60 @@ constexpr OverloadInfo kOverloads[] = {
/* num parameters */ 2,
/* num template types */ 1,
/* num template numbers */ 0,
/* template types */ &kTemplateTypes[14],
/* template types */ &kTemplateTypes[13],
/* template numbers */ &kTemplateNumbers[10],
/* parameters */ &kParameters[749],
/* return matcher indices */ &kMatcherIndices[1],
/* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::OpPlus,
},
{
/* [243] */
/* num parameters */ 2,
/* num template types */ 1,
/* num template numbers */ 1,
/* template types */ &kTemplateTypes[14],
/* template types */ &kTemplateTypes[13],
/* template numbers */ &kTemplateNumbers[6],
/* parameters */ &kParameters[747],
/* return matcher indices */ &kMatcherIndices[30],
/* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::OpPlus,
},
{
/* [244] */
/* num parameters */ 2,
/* num template types */ 1,
/* num template numbers */ 1,
/* template types */ &kTemplateTypes[14],
/* template types */ &kTemplateTypes[13],
/* template numbers */ &kTemplateNumbers[6],
/* parameters */ &kParameters[745],
/* return matcher indices */ &kMatcherIndices[30],
/* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::OpPlus,
},
{
/* [245] */
/* num parameters */ 2,
/* num template types */ 1,
/* num template numbers */ 1,
/* template types */ &kTemplateTypes[14],
/* template types */ &kTemplateTypes[13],
/* template numbers */ &kTemplateNumbers[6],
/* parameters */ &kParameters[743],
/* return matcher indices */ &kMatcherIndices[30],
/* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::OpPlus,
},
{
/* [246] */
/* num parameters */ 2,
/* num template types */ 1,
/* num template numbers */ 2,
/* template types */ &kTemplateTypes[11],
/* template types */ &kTemplateTypes[12],
/* template numbers */ &kTemplateNumbers[6],
/* parameters */ &kParameters[741],
/* return matcher indices */ &kMatcherIndices[10],
/* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::OpPlus,
},
{
/* [247] */
@ -14578,11 +14578,11 @@ constexpr uint8_t kUnaryOperatorMinus = 2;
constexpr IntrinsicInfo kBinaryOperators[] = {
{
/* [0] */
/* op +<T : fiu32_f16>(T, T) -> T */
/* op +<T : fiu32_f16, N : num>(vec<N, T>, vec<N, T>) -> vec<N, T> */
/* op +<T : fiu32_f16, N : num>(vec<N, T>, T) -> vec<N, T> */
/* op +<T : fiu32_f16, N : num>(T, vec<N, T>) -> vec<N, T> */
/* op +<T : f32_f16, N : num, M : num>(mat<N, M, T>, mat<N, M, T>) -> mat<N, M, T> */
/* op +<T : fia_fiu32_f16>(T, T) -> T */
/* op +<T : fia_fiu32_f16, N : num>(vec<N, T>, vec<N, T>) -> vec<N, T> */
/* op +<T : fia_fiu32_f16, N : num>(vec<N, T>, T) -> vec<N, T> */
/* op +<T : fia_fiu32_f16, N : num>(T, vec<N, T>) -> vec<N, T> */
/* op +<T : fa_f32_f16, N : num, M : num>(mat<N, M, T>, mat<N, M, T>) -> mat<N, M, T> */
/* num overloads */ 5,
/* overloads */ &kOverloads[242],
},

View File

@ -886,20 +886,21 @@ INSTANTIATE_TEST_SUITE_P(AFloat_AInt,
IntrinsicTableAbstractBinaryTest,
testing::Values( // clang-format off
// result | param lhs | param rhs | arg lhs | arg rhs
Case::Create<f32, f32, f32, AFloat, AFloat>(),
Case::Create<f32, f32, f32, AFloat, AInt>(),
Case::Create<f32, f32, f32, AInt, AFloat>(),
Case::Create<i32, i32, i32, AInt, AInt>()
Case::Create<AFloat, AFloat, AFloat, AFloat, AFloat>(),
Case::Create<AFloat, AFloat, AFloat, AFloat, AInt>(),
Case::Create<AFloat, AFloat, AFloat, AInt, AFloat>(),
Case::Create<AInt, AInt, AInt, AInt, AInt>()
)); // clang-format on
INSTANTIATE_TEST_SUITE_P(VecAFloat_VecAInt,
INSTANTIATE_TEST_SUITE_P(
VecAFloat_VecAInt,
IntrinsicTableAbstractBinaryTest,
testing::Values( // clang-format off
// result | param lhs | param rhs | arg lhs | arg rhs
Case::Create<f32V, f32V, f32V, AFloatV, AFloatV>(),
Case::Create<f32V, f32V, f32V, AFloatV, AIntV>(),
Case::Create<f32V, f32V, f32V, AIntV, AFloatV>(),
Case::Create<i32V, i32V, i32V, AIntV, AIntV>()
Case::Create<AFloatV, AFloatV, AFloatV, AFloatV, AFloatV>(),
Case::Create<AFloatV, AFloatV, AFloatV, AFloatV, AIntV>(),
Case::Create<AFloatV, AFloatV, AFloatV, AIntV, AFloatV>(),
Case::Create<AIntV, AIntV, AIntV, AIntV, AIntV>()
)); // clang-format on
INSTANTIATE_TEST_SUITE_P(AFloat_f32,

View File

@ -405,8 +405,11 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
});
SetupFunction(utils::Vector{
Decl(Var("a", nullptr, Expr(2_i))),
Decl(Var("b", nullptr, Expr(4_i))),
Decl(Var("c", nullptr, Expr(3_i))),
Decl(Var("x", nullptr, ast::StorageClass::kNone,
IndexAccessor(MemberAccessor("data", "a"), Sub(Add(2_i, 4_i), 3_i)))),
IndexAccessor(MemberAccessor("data", "a"), Sub(Add("a", "b"), "c")))),
});
GeneratorImpl& gen = SanitizeAndBuild();
@ -426,7 +429,10 @@ layout(binding = 0, std430) buffer Data_1 {
int a[5];
} data;
void tint_symbol() {
int x = data.a[((2 + 4) - 3)];
int a = 2;
int b = 4;
int c = 3;
int x = data.a[((a + b) - c)];
}
void main() {

View File

@ -418,8 +418,11 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
});
SetupFunction(utils::Vector{
Decl(Var("a", nullptr, Expr(2_i))),
Decl(Var("b", nullptr, Expr(4_i))),
Decl(Var("c", nullptr, Expr(3_i))),
Decl(Var("x", nullptr, ast::StorageClass::kNone,
IndexAccessor(MemberAccessor("data", "a"), Sub(Add(2_i, Expr(4_i)), Expr(3_i))))),
IndexAccessor(MemberAccessor("data", "a"), Sub(Add("a", "b"), "c")))),
});
GeneratorImpl& gen = SanitizeAndBuild();
@ -429,7 +432,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
R"(RWByteAddressBuffer data : register(u0, space1);
void main() {
int x = asint(data.Load((4u + (4u * uint(((2 + 4) - 3))))));
int a = 2;
int b = 4;
int c = 3;
int x = asint(data.Load((4u + (4u * uint(((a + b) - c))))));
return;
}
)";

View File

@ -162,10 +162,10 @@ OpReturn
TEST_F(BuilderTest, Const_IndexAccessor_Vector2) {
// let ary : vec3<i32>(1, 2, 3);
// var x = ary[1i + 2i];
// var x = ary[1i + 1i];
auto* ary = Let("ary", nullptr, vec3<i32>(1_i, 2_i, 3_i));
auto* x = Var("x", nullptr, IndexAccessor(ary, Add(1_i, 2_i)));
auto* x = Var("x", nullptr, IndexAccessor(ary, Add(1_i, 1_i)));
WrapInFunction(ary, x);
spirv::Builder& b = SanitizeAndBuild();
@ -180,14 +180,14 @@ TEST_F(BuilderTest, Const_IndexAccessor_Vector2) {
%8 = OpConstant %6 2
%9 = OpConstant %6 3
%10 = OpConstantComposite %5 %7 %8 %9
%14 = OpTypePointer Function %6
%15 = OpConstantNull %6
%13 = OpTypePointer Function %6
%14 = OpConstantNull %6
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%13 = OpVariable %14 Function %15
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%12 = OpVariable %13 Function %14
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(%11 = OpIAdd %6 %7 %8
%12 = OpVectorExtractDynamic %6 %10 %11
OpStore %13 %12
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(%11 = OpCompositeExtract %6 %10 2
OpStore %12 %11
OpReturn
)");
@ -196,10 +196,10 @@ OpReturn
TEST_F(BuilderTest, Runtime_IndexAccessor_Vector2) {
// var ary : vec3<f32>;
// var x = ary[1i + 2i];
// var x = ary[1i + 1i];
auto* ary = Var("ary", ty.vec3<f32>());
auto* x = Var("x", nullptr, IndexAccessor(ary, Add(1_i, 2_i)));
auto* x = Var("x", nullptr, IndexAccessor(ary, Add(1_i, 1_i)));
WrapInFunction(ary, x);
spirv::Builder& b = SanitizeAndBuild();
@ -213,18 +213,16 @@ TEST_F(BuilderTest, Runtime_IndexAccessor_Vector2) {
%6 = OpTypePointer Function %7
%9 = OpConstantNull %7
%10 = OpTypeInt 32 1
%11 = OpConstant %10 1
%12 = OpConstant %10 2
%14 = OpTypePointer Function %8
%18 = OpConstantNull %8
%11 = OpConstant %10 2
%12 = OpTypePointer Function %8
%16 = OpConstantNull %8
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%5 = OpVariable %6 Function %9
%17 = OpVariable %14 Function %18
%15 = OpVariable %12 Function %16
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(%13 = OpIAdd %10 %11 %12
%15 = OpAccessChain %14 %5 %13
%16 = OpLoad %8 %15
OpStore %17 %16
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(%13 = OpAccessChain %12 %5 %11
%14 = OpLoad %8 %13
OpStore %15 %14
OpReturn
)");

View File

@ -1219,30 +1219,48 @@ namespace BinaryArithVectorScalar {
enum class Type { f32, f16, i32, u32 };
static const ast::Expression* MakeVectorExpr(ProgramBuilder* builder, Type type) {
auto name = builder->Symbols().New();
switch (type) {
case Type::f32:
return builder->vec3<f32>(1_f, 1_f, 1_f);
builder->GlobalVar(name, builder->ty.vec3<f32>(), builder->vec3<f32>(1_f, 1_f, 1_f),
ast::StorageClass::kPrivate);
break;
case Type::f16:
return builder->vec3<f16>(1_h, 1_h, 1_h);
builder->GlobalVar(name, builder->ty.vec3<f16>(), builder->vec3<f16>(1_h, 1_h, 1_h),
ast::StorageClass::kPrivate);
break;
case Type::i32:
return builder->vec3<i32>(1_i, 1_i, 1_i);
builder->GlobalVar(name, builder->ty.vec3<i32>(), builder->vec3<i32>(1_i, 1_i, 1_i),
ast::StorageClass::kPrivate);
break;
case Type::u32:
return builder->vec3<u32>(1_u, 1_u, 1_u);
builder->GlobalVar(name, builder->ty.vec3<u32>(), builder->vec3<u32>(1_u, 1_u, 1_u),
ast::StorageClass::kPrivate);
break;
}
return nullptr;
return builder->Expr(name);
}
static const ast::Expression* MakeScalarExpr(ProgramBuilder* builder, Type type) {
auto name = builder->Symbols().New();
switch (type) {
case Type::f32:
return builder->Expr(1_f);
builder->GlobalVar(name, builder->ty.f32(), builder->Expr(1_f),
ast::StorageClass::kPrivate);
break;
case Type::f16:
return builder->Expr(1_h);
builder->GlobalVar(name, builder->ty.f16(), builder->Expr(1_h),
ast::StorageClass::kPrivate);
break;
case Type::i32:
return builder->Expr(1_i);
builder->GlobalVar(name, builder->ty.i32(), builder->Expr(1_i),
ast::StorageClass::kPrivate);
break;
case Type::u32:
return builder->Expr(1_u);
builder->GlobalVar(name, builder->ty.u32(), builder->Expr(1_u),
ast::StorageClass::kPrivate);
break;
}
return nullptr;
return builder->Expr(name);
}
static std::string OpTypeDecl(Type type) {
switch (type) {
@ -1310,26 +1328,33 @@ TEST_P(BinaryArithVectorScalarTest, VectorScalar) {
spirv::Builder& b = Build();
ASSERT_TRUE(b.Build()) << b.error();
EXPECT_EQ(DumpBuilder(b), capability_decl + R"(
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %3 "test_function"
OpExecutionMode %3 LocalSize 1 1 1
OpName %3 "test_function"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = )" + op_type_decl + R"(
%5 = OpTypeVector %6 3
%7 = OpConstant %6 )" + constant_value +
OpEntryPoint GLCompute %11 "test_function"
OpExecutionMode %11 LocalSize 1 1 1
OpName %5 "tint_symbol"
OpName %7 "tint_symbol_1"
OpName %11 "test_function"
%2 = )" + op_type_decl + R"(
%1 = OpTypeVector %2 3
%3 = OpConstant %2 )" + constant_value +
R"(
%8 = OpConstantComposite %5 %7 %7 %7
%11 = OpTypePointer Function %5
%12 = OpConstantNull %5
%3 = OpFunction %2 None %1
%4 = OpLabel
%10 = OpVariable %11 Function %12
%13 = OpCompositeConstruct %5 %7 %7 %7
%9 = )" + param.name + R"( %5 %8 %13
%4 = OpConstantComposite %1 %3 %3 %3
%6 = OpTypePointer Private %1
%5 = OpVariable %6 Private %4
%8 = OpTypePointer Private %2
%7 = OpVariable %8 Private %3
%10 = OpTypeVoid
%9 = OpTypeFunction %10
%17 = OpTypePointer Function %1
%18 = OpConstantNull %1
%11 = OpFunction %10 None %9
%12 = OpLabel
%16 = OpVariable %17 Function %18
%13 = OpLoad %1 %5
%14 = OpLoad %2 %7
%19 = OpCompositeConstruct %1 %14 %14 %14
%15 = )" + param.name + R"( %1 %13 %19
OpReturn
OpFunctionEnd
)");
@ -1355,26 +1380,33 @@ TEST_P(BinaryArithVectorScalarTest, ScalarVector) {
spirv::Builder& b = Build();
ASSERT_TRUE(b.Build()) << b.error();
EXPECT_EQ(DumpBuilder(b), capability_decl + R"(
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %3 "test_function"
OpExecutionMode %3 LocalSize 1 1 1
OpName %3 "test_function"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%5 = )" + op_type_decl + R"(
%6 = OpConstant %5 )" + constant_value +
OpEntryPoint GLCompute %11 "test_function"
OpExecutionMode %11 LocalSize 1 1 1
OpName %3 "tint_symbol"
OpName %7 "tint_symbol_1"
OpName %11 "test_function"
%1 = )" + op_type_decl + R"(
%2 = OpConstant %1 )" + constant_value +
R"(
%7 = OpTypeVector %5 3
%8 = OpConstantComposite %7 %6 %6 %6
%11 = OpTypePointer Function %7
%12 = OpConstantNull %7
%3 = OpFunction %2 None %1
%4 = OpLabel
%10 = OpVariable %11 Function %12
%13 = OpCompositeConstruct %7 %6 %6 %6
%9 = )" + param.name + R"( %7 %13 %8
%4 = OpTypePointer Private %1
%3 = OpVariable %4 Private %2
%5 = OpTypeVector %1 3
%6 = OpConstantComposite %5 %2 %2 %2
%8 = OpTypePointer Private %5
%7 = OpVariable %8 Private %6
%10 = OpTypeVoid
%9 = OpTypeFunction %10
%17 = OpTypePointer Function %5
%18 = OpConstantNull %5
%11 = OpFunction %10 None %9
%12 = OpLabel
%16 = OpVariable %17 Function %18
%13 = OpLoad %1 %3
%14 = OpLoad %5 %7
%19 = OpCompositeConstruct %5 %13 %13 %13
%15 = )" + param.name + R"( %5 %19 %14
OpReturn
OpFunctionEnd
)");
@ -1428,22 +1460,29 @@ TEST_P(BinaryArithVectorScalarMultiplyTest, VectorScalar) {
spirv::Builder& b = Build();
ASSERT_TRUE(b.Build()) << b.error();
EXPECT_EQ(DumpBuilder(b), capability_decl + R"(
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %3 "test_function"
OpExecutionMode %3 LocalSize 1 1 1
OpName %3 "test_function"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = )" + op_type_decl + R"(
%5 = OpTypeVector %6 3
%7 = OpConstant %6 )" + constant_value +
OpEntryPoint GLCompute %11 "test_function"
OpExecutionMode %11 LocalSize 1 1 1
OpName %5 "tint_symbol"
OpName %7 "tint_symbol_1"
OpName %11 "test_function"
%2 = )" + op_type_decl + R"(
%1 = OpTypeVector %2 3
%3 = OpConstant %2 )" + constant_value +
R"(
%8 = OpConstantComposite %5 %7 %7 %7
%3 = OpFunction %2 None %1
%4 = OpLabel
%9 = OpVectorTimesScalar %5 %8 %7
%4 = OpConstantComposite %1 %3 %3 %3
%6 = OpTypePointer Private %1
%5 = OpVariable %6 Private %4
%8 = OpTypePointer Private %2
%7 = OpVariable %8 Private %3
%10 = OpTypeVoid
%9 = OpTypeFunction %10
%11 = OpFunction %10 None %9
%12 = OpLabel
%13 = OpLoad %1 %5
%14 = OpLoad %2 %7
%15 = OpVectorTimesScalar %1 %13 %14
OpReturn
OpFunctionEnd
)");
@ -1469,22 +1508,29 @@ TEST_P(BinaryArithVectorScalarMultiplyTest, ScalarVector) {
spirv::Builder& b = Build();
ASSERT_TRUE(b.Build()) << b.error();
EXPECT_EQ(DumpBuilder(b), capability_decl + R"(
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %3 "test_function"
OpExecutionMode %3 LocalSize 1 1 1
OpName %3 "test_function"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%5 = )" + op_type_decl + R"(
%6 = OpConstant %5 )" + constant_value +
OpEntryPoint GLCompute %11 "test_function"
OpExecutionMode %11 LocalSize 1 1 1
OpName %3 "tint_symbol"
OpName %7 "tint_symbol_1"
OpName %11 "test_function"
%1 = )" + op_type_decl + R"(
%2 = OpConstant %1 )" + constant_value +
R"(
%7 = OpTypeVector %5 3
%8 = OpConstantComposite %7 %6 %6 %6
%3 = OpFunction %2 None %1
%4 = OpLabel
%9 = OpVectorTimesScalar %7 %8 %6
%4 = OpTypePointer Private %1
%3 = OpVariable %4 Private %2
%5 = OpTypeVector %1 3
%6 = OpConstantComposite %5 %2 %2 %2
%8 = OpTypePointer Private %5
%7 = OpVariable %8 Private %6
%10 = OpTypeVoid
%9 = OpTypeFunction %10
%11 = OpFunction %10 None %9
%12 = OpLabel
%13 = OpLoad %1 %3
%14 = OpLoad %5 %7
%15 = OpVectorTimesScalar %5 %14 %13
OpReturn
OpFunctionEnd
)");
@ -1502,22 +1548,31 @@ namespace BinaryArithMatrixMatrix {
enum class Type { f32, f16 };
static const ast::Expression* MakeMat3x4Expr(ProgramBuilder* builder, Type type) {
auto name = builder->Symbols().New();
switch (type) {
case Type::f32:
return builder->mat3x4<f32>();
builder->GlobalVar(name, builder->ty.mat3x4<f32>(), builder->mat3x4<f32>(),
ast::StorageClass::kPrivate);
break;
case Type::f16:
return builder->mat3x4<f16>();
builder->GlobalVar(name, builder->ty.mat3x4<f16>(), builder->mat3x4<f16>(),
ast::StorageClass::kPrivate);
break;
}
return nullptr;
return builder->Expr(name);
}
static const ast::Expression* MakeMat4x3Expr(ProgramBuilder* builder, Type type) {
auto name = builder->Symbols().New();
switch (type) {
case Type::f32:
return builder->mat4x3<f32>();
builder->GlobalVar(name, builder->ty.mat4x3<f32>(), builder->mat4x3<f32>(),
ast::StorageClass::kPrivate);
break;
case Type::f16:
return builder->mat4x3<f16>();
builder->GlobalVar(name, builder->ty.mat4x3<f16>(), builder->mat4x3<f16>(),
ast::StorageClass::kPrivate);
}
return nullptr;
return builder->Expr(name);
}
static std::string OpTypeDecl(Type type) {
switch (type) {
@ -1567,30 +1622,36 @@ TEST_P(BinaryArithMatrixMatrix, AddOrSubtract) {
spirv::Builder& b = Build();
ASSERT_TRUE(b.Build()) << b.error();
EXPECT_EQ(DumpBuilder(b), capability_decl + R"(
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %3 "test_function"
OpExecutionMode %3 LocalSize 1 1 1
OpName %3 "test_function"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = )" + op_type_decl + R"(
%6 = OpTypeVector %7 4
%5 = OpTypeMatrix %6 3
%8 = OpConstantNull %5
%3 = OpFunction %2 None %1
%4 = OpLabel
%10 = OpCompositeExtract %6 %8 0
%11 = OpCompositeExtract %6 %8 0
%12 = )" + param.name + R"( %6 %10 %11
%13 = OpCompositeExtract %6 %8 1
%14 = OpCompositeExtract %6 %8 1
%15 = )" + param.name + R"( %6 %13 %14
%16 = OpCompositeExtract %6 %8 2
%17 = OpCompositeExtract %6 %8 2
%18 = )" + param.name + R"( %6 %16 %17
%19 = OpCompositeConstruct %5 %12 %15 %18
OpEntryPoint GLCompute %10 "test_function"
OpExecutionMode %10 LocalSize 1 1 1
OpName %5 "tint_symbol"
OpName %7 "tint_symbol_1"
OpName %10 "test_function"
%3 = )" + op_type_decl + R"(
%2 = OpTypeVector %3 4
%1 = OpTypeMatrix %2 3
%4 = OpConstantNull %1
%6 = OpTypePointer Private %1
%5 = OpVariable %6 Private %4
%7 = OpVariable %6 Private %4
%9 = OpTypeVoid
%8 = OpTypeFunction %9
%10 = OpFunction %9 None %8
%11 = OpLabel
%12 = OpLoad %1 %5
%13 = OpLoad %1 %7
%15 = OpCompositeExtract %2 %12 0
%16 = OpCompositeExtract %2 %13 0
%17 = )" + param.name + R"( %2 %15 %16
%18 = OpCompositeExtract %2 %12 1
%19 = OpCompositeExtract %2 %13 1
%20 = )" + param.name + R"( %2 %18 %19
%21 = OpCompositeExtract %2 %12 2
%22 = OpCompositeExtract %2 %13 2
%23 = )" + param.name + R"( %2 %21 %22
%24 = OpCompositeConstruct %1 %17 %20 %23
OpReturn
OpFunctionEnd
)");
@ -1624,25 +1685,32 @@ TEST_P(BinaryArithMatrixMatrixMultiply, Multiply) {
spirv::Builder& b = Build();
ASSERT_TRUE(b.Build()) << b.error();
EXPECT_EQ(DumpBuilder(b), capability_decl + R"(
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %3 "test_function"
OpExecutionMode %3 LocalSize 1 1 1
OpName %3 "test_function"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = )" + op_type_decl + R"(
%6 = OpTypeVector %7 4
%5 = OpTypeMatrix %6 3
%8 = OpConstantNull %5
%10 = OpTypeVector %7 3
%9 = OpTypeMatrix %10 4
%11 = OpConstantNull %9
%13 = OpTypeMatrix %6 4
%3 = OpFunction %2 None %1
%4 = OpLabel
%12 = OpMatrixTimesMatrix %13 %8 %11
OpEntryPoint GLCompute %14 "test_function"
OpExecutionMode %14 LocalSize 1 1 1
OpName %5 "tint_symbol"
OpName %10 "tint_symbol_1"
OpName %14 "test_function"
%3 = )" + op_type_decl + R"(
%2 = OpTypeVector %3 4
%1 = OpTypeMatrix %2 3
%4 = OpConstantNull %1
%6 = OpTypePointer Private %1
%5 = OpVariable %6 Private %4
%8 = OpTypeVector %3 3
%7 = OpTypeMatrix %8 4
%9 = OpConstantNull %7
%11 = OpTypePointer Private %7
%10 = OpVariable %11 Private %9
%13 = OpTypeVoid
%12 = OpTypeFunction %13
%19 = OpTypeMatrix %2 4
%14 = OpFunction %13 None %12
%15 = OpLabel
%16 = OpLoad %1 %5
%17 = OpLoad %7 %10
%18 = OpMatrixTimesMatrix %19 %16 %17
OpReturn
OpFunctionEnd
)");

View File

@ -73,32 +73,34 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
}
TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) {
auto* init = vec2<f32>(1_f, Add(3_f, 3_f));
auto* a = Let("a", nullptr, Expr(3_f));
auto* init = vec2<f32>(1_f, Add(Expr("a"), 3_f));
auto* v = Var("var", ty.vec2<f32>(), ast::StorageClass::kNone, init);
WrapInFunction(v);
WrapInFunction(a, v);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_TRUE(b.GenerateFunctionVariable(a)) << b.error();
EXPECT_TRUE(b.GenerateFunctionVariable(v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %7 "var"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 2
%3 = OpConstant %2 1
%4 = OpConstant %2 3
%8 = OpTypePointer Function %1
%9 = OpConstantNull %1
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeFloat 32
%2 = OpConstant %1 3
%3 = OpTypeVector %1 2
%4 = OpConstant %1 1
%8 = OpTypePointer Function %3
%9 = OpConstantNull %3
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()),
R"(%7 = OpVariable %8 Function %9
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(%5 = OpFAdd %2 %4 %4
%6 = OpCompositeConstruct %1 %3 %5
R"(%5 = OpFAdd %1 %2 %2
%6 = OpCompositeConstruct %3 %4 %5
OpStore %7 %6
)");
}

View File

@ -1,5 +1,5 @@
[numthreads(1, 1, 1)]
void f() {
const float16_t r = (float16_t(1.0h) + float16_t(2.0h));
const float16_t r = float16_t(3.0h);
return;
}

View File

@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void f() {
float16_t r = (1.0hf + 2.0hf);
float16_t r = 3.0hf;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -1,5 +1,5 @@
[numthreads(1, 1, 1)]
void f() {
const float r = (1.0f + 2.0f);
const float r = 3.0f;
return;
}

View File

@ -1,5 +1,5 @@
[numthreads(1, 1, 1)]
void f() {
const float r = (1.0f + 2.0f);
const float r = 3.0f;
return;
}

View File

@ -1,7 +1,7 @@
#version 310 es
void f() {
float r = (1.0f + 2.0f);
float r = 3.0f;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -1,5 +1,5 @@
[numthreads(1, 1, 1)]
void f() {
const int r = (1 + 2);
const int r = 3;
return;
}

View File

@ -1,5 +1,5 @@
[numthreads(1, 1, 1)]
void f() {
const int r = (1 + 2);
const int r = 3;
return;
}

View File

@ -1,7 +1,7 @@
#version 310 es
void f() {
int r = (1 + 2);
int r = 3;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -1,5 +1,5 @@
[numthreads(1, 1, 1)]
void f() {
const uint r = (1u + 2u);
const uint r = 3u;
return;
}

View File

@ -1,5 +1,5 @@
[numthreads(1, 1, 1)]
void f() {
const uint r = (1u + 2u);
const uint r = 3u;
return;
}

View File

@ -1,7 +1,7 @@
#version 310 es
void f() {
uint r = (1u + 2u);
uint r = 3u;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -6,6 +6,6 @@ void unused_entry_point() {
int add_int_min_explicit() {
int a = -2147483648;
int b = (a + 1);
int c = (-2147483648 + 1);
int c = -2147483647;
return c;
}

View File

@ -6,6 +6,6 @@ void unused_entry_point() {
int add_int_min_explicit() {
int a = -2147483648;
int b = (a + 1);
int c = (-2147483648 + 1);
int c = -2147483647;
return c;
}

View File

@ -7,7 +7,7 @@ void unused_entry_point() {
int add_int_min_explicit() {
int a = -2147483648;
int b = (a + 1);
int c = (-2147483648 + 1);
int c = -2147483647;
return c;
}

View File

@ -4,7 +4,7 @@ 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)));
int c = -2147483647;
return c;
}

View File

@ -20,6 +20,7 @@
%_ptr_Function_int = OpTypePointer Function %int
%12 = OpConstantNull %int
%int_1 = OpConstant %int 1
%int_n2147483647 = OpConstant %int -2147483647
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
@ -33,8 +34,7 @@
%13 = OpLoad %int %a
%15 = OpIAdd %int %13 %int_1
OpStore %b %15
%17 = OpIAdd %int %int_n2147483648 %int_1
OpStore %c %17
OpStore %c %int_n2147483647
%19 = OpLoad %int %c
OpReturnValue %19
OpFunctionEnd

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
vector<float16_t, 2> v2 = vector<float16_t, 2>(((float16_t(1.0h) + float16_t(2.0h))).xx);
vector<float16_t, 3> v3 = vector<float16_t, 3>(((float16_t(1.0h) + float16_t(2.0h))).xxx);
vector<float16_t, 4> v4 = vector<float16_t, 4>(((float16_t(1.0h) + float16_t(2.0h))).xxxx);
vector<float16_t, 2> v2 = (float16_t(3.0h)).xx;
vector<float16_t, 3> v3 = (float16_t(3.0h)).xxx;
vector<float16_t, 4> v4 = (float16_t(3.0h)).xxxx;
}

View File

@ -6,8 +6,8 @@ void unused_entry_point() {
return;
}
void f() {
f16vec2 v2 = f16vec2((1.0hf + 2.0hf));
f16vec3 v3 = f16vec3((1.0hf + 2.0hf));
f16vec4 v4 = f16vec4((1.0hf + 2.0hf));
f16vec2 v2 = f16vec2(3.0hf);
f16vec3 v3 = f16vec3(3.0hf);
f16vec4 v4 = f16vec4(3.0hf);
}

View File

@ -2,8 +2,8 @@
using namespace metal;
void f() {
half2 v2 = half2((1.0h + 2.0h));
half3 v3 = half3((1.0h + 2.0h));
half4 v4 = half4((1.0h + 2.0h));
half2 v2 = half2(3.0h);
half3 v3 = half3(3.0h);
half4 v4 = half4(3.0h);
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 28
; Bound: 24
; Schema: 0
OpCapability Shader
OpCapability Float16
@ -20,33 +20,29 @@
%1 = OpTypeFunction %void
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%half_0x1p_0 = OpConstant %half 0x1p+0
%half_0x1p_1 = OpConstant %half 0x1p+1
%half_0x1_8p_1 = OpConstant %half 0x1.8p+1
%10 = OpConstantComposite %v2half %half_0x1_8p_1 %half_0x1_8p_1
%_ptr_Function_v2half = OpTypePointer Function %v2half
%15 = OpConstantNull %v2half
%13 = OpConstantNull %v2half
%v3half = OpTypeVector %half 3
%15 = OpConstantComposite %v3half %half_0x1_8p_1 %half_0x1_8p_1 %half_0x1_8p_1
%_ptr_Function_v3half = OpTypePointer Function %v3half
%21 = OpConstantNull %v3half
%18 = OpConstantNull %v3half
%v4half = OpTypeVector %half 4
%20 = OpConstantComposite %v4half %half_0x1_8p_1 %half_0x1_8p_1 %half_0x1_8p_1 %half_0x1_8p_1
%_ptr_Function_v4half = OpTypePointer Function %v4half
%27 = OpConstantNull %v4half
%23 = OpConstantNull %v4half
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%v2 = OpVariable %_ptr_Function_v2half Function %15
%v3 = OpVariable %_ptr_Function_v3half Function %21
%v4 = OpVariable %_ptr_Function_v4half Function %27
%11 = OpFAdd %half %half_0x1p_0 %half_0x1p_1
%12 = OpCompositeConstruct %v2half %11 %11
OpStore %v2 %12
%17 = OpFAdd %half %half_0x1p_0 %half_0x1p_1
%18 = OpCompositeConstruct %v3half %17 %17 %17
OpStore %v3 %18
%23 = OpFAdd %half %half_0x1p_0 %half_0x1p_1
%24 = OpCompositeConstruct %v4half %23 %23 %23 %23
OpStore %v4 %24
%v2 = OpVariable %_ptr_Function_v2half Function %13
%v3 = OpVariable %_ptr_Function_v3half Function %18
%v4 = OpVariable %_ptr_Function_v4half Function %23
OpStore %v2 %10
OpStore %v3 %15
OpStore %v4 %20
OpReturn
OpFunctionEnd

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
float2 v2 = float2(((1.0f + 2.0f)).xx);
float3 v3 = float3(((1.0f + 2.0f)).xxx);
float4 v4 = float4(((1.0f + 2.0f)).xxxx);
float2 v2 = (3.0f).xx;
float3 v3 = (3.0f).xxx;
float4 v4 = (3.0f).xxxx;
}

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
float2 v2 = float2(((1.0f + 2.0f)).xx);
float3 v3 = float3(((1.0f + 2.0f)).xxx);
float4 v4 = float4(((1.0f + 2.0f)).xxxx);
float2 v2 = (3.0f).xx;
float3 v3 = (3.0f).xxx;
float4 v4 = (3.0f).xxxx;
}

View File

@ -5,8 +5,8 @@ void unused_entry_point() {
return;
}
void f() {
vec2 v2 = vec2((1.0f + 2.0f));
vec3 v3 = vec3((1.0f + 2.0f));
vec4 v4 = vec4((1.0f + 2.0f));
vec2 v2 = vec2(3.0f);
vec3 v3 = vec3(3.0f);
vec4 v4 = vec4(3.0f);
}

View File

@ -2,8 +2,8 @@
using namespace metal;
void f() {
float2 v2 = float2((1.0f + 2.0f));
float3 v3 = float3((1.0f + 2.0f));
float4 v4 = float4((1.0f + 2.0f));
float2 v2 = float2(3.0f);
float3 v3 = float3(3.0f);
float4 v4 = float4(3.0f);
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 28
; Bound: 24
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,33 +16,29 @@
%1 = OpTypeFunction %void
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%float_3 = OpConstant %float 3
%10 = OpConstantComposite %v2float %float_3 %float_3
%_ptr_Function_v2float = OpTypePointer Function %v2float
%15 = OpConstantNull %v2float
%13 = OpConstantNull %v2float
%v3float = OpTypeVector %float 3
%15 = OpConstantComposite %v3float %float_3 %float_3 %float_3
%_ptr_Function_v3float = OpTypePointer Function %v3float
%21 = OpConstantNull %v3float
%18 = OpConstantNull %v3float
%v4float = OpTypeVector %float 4
%20 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3
%_ptr_Function_v4float = OpTypePointer Function %v4float
%27 = OpConstantNull %v4float
%23 = OpConstantNull %v4float
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%v2 = OpVariable %_ptr_Function_v2float Function %15
%v3 = OpVariable %_ptr_Function_v3float Function %21
%v4 = OpVariable %_ptr_Function_v4float Function %27
%11 = OpFAdd %float %float_1 %float_2
%12 = OpCompositeConstruct %v2float %11 %11
OpStore %v2 %12
%17 = OpFAdd %float %float_1 %float_2
%18 = OpCompositeConstruct %v3float %17 %17 %17
OpStore %v3 %18
%23 = OpFAdd %float %float_1 %float_2
%24 = OpCompositeConstruct %v4float %23 %23 %23 %23
OpStore %v4 %24
%v2 = OpVariable %_ptr_Function_v2float Function %13
%v3 = OpVariable %_ptr_Function_v3float Function %18
%v4 = OpVariable %_ptr_Function_v4float Function %23
OpStore %v2 %10
OpStore %v3 %15
OpStore %v4 %20
OpReturn
OpFunctionEnd

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
int2 v2 = int2(((1 + 2)).xx);
int3 v3 = int3(((1 + 2)).xxx);
int4 v4 = int4(((1 + 2)).xxxx);
int2 v2 = (3).xx;
int3 v3 = (3).xxx;
int4 v4 = (3).xxxx;
}

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
int2 v2 = int2(((1 + 2)).xx);
int3 v3 = int3(((1 + 2)).xxx);
int4 v4 = int4(((1 + 2)).xxxx);
int2 v2 = (3).xx;
int3 v3 = (3).xxx;
int4 v4 = (3).xxxx;
}

View File

@ -5,8 +5,8 @@ void unused_entry_point() {
return;
}
void f() {
ivec2 v2 = ivec2((1 + 2));
ivec3 v3 = ivec3((1 + 2));
ivec4 v4 = ivec4((1 + 2));
ivec2 v2 = ivec2(3);
ivec3 v3 = ivec3(3);
ivec4 v4 = ivec4(3);
}

View File

@ -2,8 +2,8 @@
using namespace metal;
void f() {
int2 v2 = int2(as_type<int>((as_type<uint>(1) + as_type<uint>(2))));
int3 v3 = int3(as_type<int>((as_type<uint>(1) + as_type<uint>(2))));
int4 v4 = int4(as_type<int>((as_type<uint>(1) + as_type<uint>(2))));
int2 v2 = int2(3);
int3 v3 = int3(3);
int4 v4 = int4(3);
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 28
; Bound: 24
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,33 +16,29 @@
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%v2int = OpTypeVector %int 2
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%int_3 = OpConstant %int 3
%10 = OpConstantComposite %v2int %int_3 %int_3
%_ptr_Function_v2int = OpTypePointer Function %v2int
%15 = OpConstantNull %v2int
%13 = OpConstantNull %v2int
%v3int = OpTypeVector %int 3
%15 = OpConstantComposite %v3int %int_3 %int_3 %int_3
%_ptr_Function_v3int = OpTypePointer Function %v3int
%21 = OpConstantNull %v3int
%18 = OpConstantNull %v3int
%v4int = OpTypeVector %int 4
%20 = OpConstantComposite %v4int %int_3 %int_3 %int_3 %int_3
%_ptr_Function_v4int = OpTypePointer Function %v4int
%27 = OpConstantNull %v4int
%23 = OpConstantNull %v4int
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%v2 = OpVariable %_ptr_Function_v2int Function %15
%v3 = OpVariable %_ptr_Function_v3int Function %21
%v4 = OpVariable %_ptr_Function_v4int Function %27
%11 = OpIAdd %int %int_1 %int_2
%12 = OpCompositeConstruct %v2int %11 %11
OpStore %v2 %12
%17 = OpIAdd %int %int_1 %int_2
%18 = OpCompositeConstruct %v3int %17 %17 %17
OpStore %v3 %18
%23 = OpIAdd %int %int_1 %int_2
%24 = OpCompositeConstruct %v4int %23 %23 %23 %23
OpStore %v4 %24
%v2 = OpVariable %_ptr_Function_v2int Function %13
%v3 = OpVariable %_ptr_Function_v3int Function %18
%v4 = OpVariable %_ptr_Function_v4int Function %23
OpStore %v2 %10
OpStore %v3 %15
OpStore %v4 %20
OpReturn
OpFunctionEnd

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
uint2 v2 = uint2(((1u + 2u)).xx);
uint3 v3 = uint3(((1u + 2u)).xxx);
uint4 v4 = uint4(((1u + 2u)).xxxx);
uint2 v2 = (3u).xx;
uint3 v3 = (3u).xxx;
uint4 v4 = (3u).xxxx;
}

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
uint2 v2 = uint2(((1u + 2u)).xx);
uint3 v3 = uint3(((1u + 2u)).xxx);
uint4 v4 = uint4(((1u + 2u)).xxxx);
uint2 v2 = (3u).xx;
uint3 v3 = (3u).xxx;
uint4 v4 = (3u).xxxx;
}

View File

@ -5,8 +5,8 @@ void unused_entry_point() {
return;
}
void f() {
uvec2 v2 = uvec2((1u + 2u));
uvec3 v3 = uvec3((1u + 2u));
uvec4 v4 = uvec4((1u + 2u));
uvec2 v2 = uvec2(3u);
uvec3 v3 = uvec3(3u);
uvec4 v4 = uvec4(3u);
}

View File

@ -2,8 +2,8 @@
using namespace metal;
void f() {
uint2 v2 = uint2((1u + 2u));
uint3 v3 = uint3((1u + 2u));
uint4 v4 = uint4((1u + 2u));
uint2 v2 = uint2(3u);
uint3 v3 = uint3(3u);
uint4 v4 = uint4(3u);
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 28
; Bound: 24
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,33 +16,29 @@
%1 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%v2uint = OpTypeVector %uint 2
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
%10 = OpConstantComposite %v2uint %uint_3 %uint_3
%_ptr_Function_v2uint = OpTypePointer Function %v2uint
%15 = OpConstantNull %v2uint
%13 = OpConstantNull %v2uint
%v3uint = OpTypeVector %uint 3
%15 = OpConstantComposite %v3uint %uint_3 %uint_3 %uint_3
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
%21 = OpConstantNull %v3uint
%18 = OpConstantNull %v3uint
%v4uint = OpTypeVector %uint 4
%20 = OpConstantComposite %v4uint %uint_3 %uint_3 %uint_3 %uint_3
%_ptr_Function_v4uint = OpTypePointer Function %v4uint
%27 = OpConstantNull %v4uint
%23 = OpConstantNull %v4uint
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%v2 = OpVariable %_ptr_Function_v2uint Function %15
%v3 = OpVariable %_ptr_Function_v3uint Function %21
%v4 = OpVariable %_ptr_Function_v4uint Function %27
%11 = OpIAdd %uint %uint_1 %uint_2
%12 = OpCompositeConstruct %v2uint %11 %11
OpStore %v2 %12
%17 = OpIAdd %uint %uint_1 %uint_2
%18 = OpCompositeConstruct %v3uint %17 %17 %17
OpStore %v3 %18
%23 = OpIAdd %uint %uint_1 %uint_2
%24 = OpCompositeConstruct %v4uint %23 %23 %23 %23
OpStore %v4 %24
%v2 = OpVariable %_ptr_Function_v2uint Function %13
%v3 = OpVariable %_ptr_Function_v3uint Function %18
%v4 = OpVariable %_ptr_Function_v4uint Function %23
OpStore %v2 %10
OpStore %v3 %15
OpStore %v4 %20
OpReturn
OpFunctionEnd

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
float16_t v = (float16_t(1.0h) + float16_t(2.0h));
float16_t v = float16_t(3.0h);
vector<float16_t, 2> v2 = vector<float16_t, 2>((v).xx);
vector<float16_t, 3> v3 = vector<float16_t, 3>((v).xxx);
vector<float16_t, 4> v4 = vector<float16_t, 4>((v).xxxx);

View File

@ -6,7 +6,7 @@ void unused_entry_point() {
return;
}
void f() {
float16_t v = (1.0hf + 2.0hf);
float16_t v = 3.0hf;
f16vec2 v2 = f16vec2(v);
f16vec3 v3 = f16vec3(v);
f16vec4 v4 = f16vec4(v);

View File

@ -2,7 +2,7 @@
using namespace metal;
void f() {
half v = (1.0h + 2.0h);
half v = 3.0h;
half2 v2 = half2(v);
half3 v3 = half3(v);
half4 v4 = half4(v);

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 32
; Bound: 30
; Schema: 0
OpCapability Shader
OpCapability Float16
@ -20,39 +20,37 @@
%void = OpTypeVoid
%1 = OpTypeFunction %void
%half = OpTypeFloat 16
%half_0x1p_0 = OpConstant %half 0x1p+0
%half_0x1p_1 = OpConstant %half 0x1p+1
%half_0x1_8p_1 = OpConstant %half 0x1.8p+1
%_ptr_Function_half = OpTypePointer Function %half
%13 = OpConstantNull %half
%11 = OpConstantNull %half
%v2half = OpTypeVector %half 2
%_ptr_Function_v2half = OpTypePointer Function %v2half
%19 = OpConstantNull %v2half
%17 = OpConstantNull %v2half
%v3half = OpTypeVector %half 3
%_ptr_Function_v3half = OpTypePointer Function %v3half
%25 = OpConstantNull %v3half
%23 = OpConstantNull %v3half
%v4half = OpTypeVector %half 4
%_ptr_Function_v4half = OpTypePointer Function %v4half
%31 = OpConstantNull %v4half
%29 = OpConstantNull %v4half
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%v = OpVariable %_ptr_Function_half Function %13
%v2 = OpVariable %_ptr_Function_v2half Function %19
%v3 = OpVariable %_ptr_Function_v3half Function %25
%v4 = OpVariable %_ptr_Function_v4half Function %31
%10 = OpFAdd %half %half_0x1p_0 %half_0x1p_1
OpStore %v %10
%15 = OpLoad %half %v
%16 = OpCompositeConstruct %v2half %15 %15
OpStore %v2 %16
%21 = OpLoad %half %v
%22 = OpCompositeConstruct %v3half %21 %21 %21
OpStore %v3 %22
%27 = OpLoad %half %v
%28 = OpCompositeConstruct %v4half %27 %27 %27 %27
OpStore %v4 %28
%v = OpVariable %_ptr_Function_half Function %11
%v2 = OpVariable %_ptr_Function_v2half Function %17
%v3 = OpVariable %_ptr_Function_v3half Function %23
%v4 = OpVariable %_ptr_Function_v4half Function %29
OpStore %v %half_0x1_8p_1
%13 = OpLoad %half %v
%14 = OpCompositeConstruct %v2half %13 %13
OpStore %v2 %14
%19 = OpLoad %half %v
%20 = OpCompositeConstruct %v3half %19 %19 %19
OpStore %v3 %20
%25 = OpLoad %half %v
%26 = OpCompositeConstruct %v4half %25 %25 %25 %25
OpStore %v4 %26
OpReturn
OpFunctionEnd

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
float v = (1.0f + 2.0f);
float v = 3.0f;
float2 v2 = float2((v).xx);
float3 v3 = float3((v).xxx);
float4 v4 = float4((v).xxxx);

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
float v = (1.0f + 2.0f);
float v = 3.0f;
float2 v2 = float2((v).xx);
float3 v3 = float3((v).xxx);
float4 v4 = float4((v).xxxx);

View File

@ -5,7 +5,7 @@ void unused_entry_point() {
return;
}
void f() {
float v = (1.0f + 2.0f);
float v = 3.0f;
vec2 v2 = vec2(v);
vec3 v3 = vec3(v);
vec4 v4 = vec4(v);

View File

@ -2,7 +2,7 @@
using namespace metal;
void f() {
float v = (1.0f + 2.0f);
float v = 3.0f;
float2 v2 = float2(v);
float3 v3 = float3(v);
float4 v4 = float4(v);

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 32
; Bound: 30
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,39 +16,37 @@
%void = OpTypeVoid
%1 = OpTypeFunction %void
%float = OpTypeFloat 32
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%float_3 = OpConstant %float 3
%_ptr_Function_float = OpTypePointer Function %float
%13 = OpConstantNull %float
%11 = OpConstantNull %float
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%19 = OpConstantNull %v2float
%17 = OpConstantNull %v2float
%v3float = OpTypeVector %float 3
%_ptr_Function_v3float = OpTypePointer Function %v3float
%25 = OpConstantNull %v3float
%23 = OpConstantNull %v3float
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%31 = OpConstantNull %v4float
%29 = OpConstantNull %v4float
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%v = OpVariable %_ptr_Function_float Function %13
%v2 = OpVariable %_ptr_Function_v2float Function %19
%v3 = OpVariable %_ptr_Function_v3float Function %25
%v4 = OpVariable %_ptr_Function_v4float Function %31
%10 = OpFAdd %float %float_1 %float_2
OpStore %v %10
%15 = OpLoad %float %v
%16 = OpCompositeConstruct %v2float %15 %15
OpStore %v2 %16
%21 = OpLoad %float %v
%22 = OpCompositeConstruct %v3float %21 %21 %21
OpStore %v3 %22
%27 = OpLoad %float %v
%28 = OpCompositeConstruct %v4float %27 %27 %27 %27
OpStore %v4 %28
%v = OpVariable %_ptr_Function_float Function %11
%v2 = OpVariable %_ptr_Function_v2float Function %17
%v3 = OpVariable %_ptr_Function_v3float Function %23
%v4 = OpVariable %_ptr_Function_v4float Function %29
OpStore %v %float_3
%13 = OpLoad %float %v
%14 = OpCompositeConstruct %v2float %13 %13
OpStore %v2 %14
%19 = OpLoad %float %v
%20 = OpCompositeConstruct %v3float %19 %19 %19
OpStore %v3 %20
%25 = OpLoad %float %v
%26 = OpCompositeConstruct %v4float %25 %25 %25 %25
OpStore %v4 %26
OpReturn
OpFunctionEnd

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
int v = (1 + 2);
int v = 3;
int2 v2 = int2((v).xx);
int3 v3 = int3((v).xxx);
int4 v4 = int4((v).xxxx);

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
int v = (1 + 2);
int v = 3;
int2 v2 = int2((v).xx);
int3 v3 = int3((v).xxx);
int4 v4 = int4((v).xxxx);

View File

@ -5,7 +5,7 @@ void unused_entry_point() {
return;
}
void f() {
int v = (1 + 2);
int v = 3;
ivec2 v2 = ivec2(v);
ivec3 v3 = ivec3(v);
ivec4 v4 = ivec4(v);

View File

@ -2,7 +2,7 @@
using namespace metal;
void f() {
int v = as_type<int>((as_type<uint>(1) + as_type<uint>(2)));
int v = 3;
int2 v2 = int2(v);
int3 v3 = int3(v);
int4 v4 = int4(v);

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 32
; Bound: 30
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,39 +16,37 @@
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%int_3 = OpConstant %int 3
%_ptr_Function_int = OpTypePointer Function %int
%13 = OpConstantNull %int
%11 = OpConstantNull %int
%v2int = OpTypeVector %int 2
%_ptr_Function_v2int = OpTypePointer Function %v2int
%19 = OpConstantNull %v2int
%17 = OpConstantNull %v2int
%v3int = OpTypeVector %int 3
%_ptr_Function_v3int = OpTypePointer Function %v3int
%25 = OpConstantNull %v3int
%23 = OpConstantNull %v3int
%v4int = OpTypeVector %int 4
%_ptr_Function_v4int = OpTypePointer Function %v4int
%31 = OpConstantNull %v4int
%29 = OpConstantNull %v4int
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%v = OpVariable %_ptr_Function_int Function %13
%v2 = OpVariable %_ptr_Function_v2int Function %19
%v3 = OpVariable %_ptr_Function_v3int Function %25
%v4 = OpVariable %_ptr_Function_v4int Function %31
%10 = OpIAdd %int %int_1 %int_2
OpStore %v %10
%15 = OpLoad %int %v
%16 = OpCompositeConstruct %v2int %15 %15
OpStore %v2 %16
%21 = OpLoad %int %v
%22 = OpCompositeConstruct %v3int %21 %21 %21
OpStore %v3 %22
%27 = OpLoad %int %v
%28 = OpCompositeConstruct %v4int %27 %27 %27 %27
OpStore %v4 %28
%v = OpVariable %_ptr_Function_int Function %11
%v2 = OpVariable %_ptr_Function_v2int Function %17
%v3 = OpVariable %_ptr_Function_v3int Function %23
%v4 = OpVariable %_ptr_Function_v4int Function %29
OpStore %v %int_3
%13 = OpLoad %int %v
%14 = OpCompositeConstruct %v2int %13 %13
OpStore %v2 %14
%19 = OpLoad %int %v
%20 = OpCompositeConstruct %v3int %19 %19 %19
OpStore %v3 %20
%25 = OpLoad %int %v
%26 = OpCompositeConstruct %v4int %25 %25 %25 %25
OpStore %v4 %26
OpReturn
OpFunctionEnd

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
uint v = (1u + 2u);
uint v = 3u;
uint2 v2 = uint2((v).xx);
uint3 v3 = uint3((v).xxx);
uint4 v4 = uint4((v).xxxx);

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void f() {
uint v = (1u + 2u);
uint v = 3u;
uint2 v2 = uint2((v).xx);
uint3 v3 = uint3((v).xxx);
uint4 v4 = uint4((v).xxxx);

View File

@ -5,7 +5,7 @@ void unused_entry_point() {
return;
}
void f() {
uint v = (1u + 2u);
uint v = 3u;
uvec2 v2 = uvec2(v);
uvec3 v3 = uvec3(v);
uvec4 v4 = uvec4(v);

View File

@ -2,7 +2,7 @@
using namespace metal;
void f() {
uint v = (1u + 2u);
uint v = 3u;
uint2 v2 = uint2(v);
uint3 v3 = uint3(v);
uint4 v4 = uint4(v);

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 32
; Bound: 30
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,39 +16,37 @@
%void = OpTypeVoid
%1 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
%_ptr_Function_uint = OpTypePointer Function %uint
%13 = OpConstantNull %uint
%11 = OpConstantNull %uint
%v2uint = OpTypeVector %uint 2
%_ptr_Function_v2uint = OpTypePointer Function %v2uint
%19 = OpConstantNull %v2uint
%17 = OpConstantNull %v2uint
%v3uint = OpTypeVector %uint 3
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
%25 = OpConstantNull %v3uint
%23 = OpConstantNull %v3uint
%v4uint = OpTypeVector %uint 4
%_ptr_Function_v4uint = OpTypePointer Function %v4uint
%31 = OpConstantNull %v4uint
%29 = OpConstantNull %v4uint
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%v = OpVariable %_ptr_Function_uint Function %13
%v2 = OpVariable %_ptr_Function_v2uint Function %19
%v3 = OpVariable %_ptr_Function_v3uint Function %25
%v4 = OpVariable %_ptr_Function_v4uint Function %31
%10 = OpIAdd %uint %uint_1 %uint_2
OpStore %v %10
%15 = OpLoad %uint %v
%16 = OpCompositeConstruct %v2uint %15 %15
OpStore %v2 %16
%21 = OpLoad %uint %v
%22 = OpCompositeConstruct %v3uint %21 %21 %21
OpStore %v3 %22
%27 = OpLoad %uint %v
%28 = OpCompositeConstruct %v4uint %27 %27 %27 %27
OpStore %v4 %28
%v = OpVariable %_ptr_Function_uint Function %11
%v2 = OpVariable %_ptr_Function_v2uint Function %17
%v3 = OpVariable %_ptr_Function_v3uint Function %23
%v4 = OpVariable %_ptr_Function_v4uint Function %29
OpStore %v %uint_3
%13 = OpLoad %uint %v
%14 = OpCompositeConstruct %v2uint %13 %13
OpStore %v2 %14
%19 = OpLoad %uint %v
%20 = OpCompositeConstruct %v3uint %19 %19 %19
OpStore %v3 %20
%25 = OpLoad %uint %v
%26 = OpCompositeConstruct %v4uint %25 %25 %25 %25
OpStore %v4 %26
OpReturn
OpFunctionEnd

View File

@ -2,7 +2,7 @@ static int I = 0;
void main_1() {
I = 123;
I = ((100 + 20) + 3);
I = 123;
return;
}

View File

@ -2,7 +2,7 @@ static int I = 0;
void main_1() {
I = 123;
I = ((100 + 20) + 3);
I = 123;
return;
}

View File

@ -3,7 +3,7 @@
int I = 0;
void main_1() {
I = 123;
I = ((100 + 20) + 3);
I = 123;
return;
}

View File

@ -4,7 +4,7 @@ using namespace metal;
void main_1() {
thread int tint_symbol_1 = 0;
tint_symbol_1 = 123;
tint_symbol_1 = as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(100) + as_type<uint>(20)))) + as_type<uint>(3)));
tint_symbol_1 = 123;
return;
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 18
; Bound: 13
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -17,19 +17,14 @@
%void = OpTypeVoid
%5 = OpTypeFunction %void
%int_123 = OpConstant %int 123
%int_100 = OpConstant %int 100
%int_20 = OpConstant %int 20
%int_3 = OpConstant %int 3
%main_1 = OpFunction %void None %5
%8 = OpLabel
OpStore %I %int_123
%12 = OpIAdd %int %int_100 %int_20
%14 = OpIAdd %int %12 %int_3
OpStore %I %14
OpStore %I %int_123
OpReturn
OpFunctionEnd
%main = OpFunction %void None %5
%16 = OpLabel
%17 = OpFunctionCall %void %main_1
%11 = OpLabel
%12 = OpFunctionCall %void %main_1
OpReturn
OpFunctionEnd

View File

@ -3,6 +3,6 @@ static int I = 0;
[numthreads(1, 1, 1)]
void main() {
I = 123;
I = ((100 + 20) + 3);
I = 123;
return;
}

View File

@ -3,6 +3,6 @@ static int I = 0;
[numthreads(1, 1, 1)]
void main() {
I = 123;
I = ((100 + 20) + 3);
I = 123;
return;
}

View File

@ -3,7 +3,7 @@
int I = 0;
void tint_symbol() {
I = 123;
I = ((100 + 20) + 3);
I = 123;
}
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 tint_symbol() {
thread int tint_symbol_1 = 0;
tint_symbol_1 = 123;
tint_symbol_1 = as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(100) + as_type<uint>(20)))) + as_type<uint>(3)));
tint_symbol_1 = 123;
return;
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 15
; Bound: 10
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,14 +16,9 @@
%void = OpTypeVoid
%5 = OpTypeFunction %void
%int_123 = OpConstant %int 123
%int_100 = OpConstant %int 100
%int_20 = OpConstant %int 20
%int_3 = OpConstant %int 3
%main = OpFunction %void None %5
%8 = OpLabel
OpStore %I %int_123
%12 = OpIAdd %int %int_100 %int_20
%14 = OpIAdd %int %12 %int_3
OpStore %I %14
OpStore %I %int_123
OpReturn
OpFunctionEnd

View File

@ -2,7 +2,7 @@ void main_1() {
int i = 0;
i = 123;
i = 123;
i = ((100 + 20) + 3);
i = 123;
return;
}

View File

@ -2,7 +2,7 @@ void main_1() {
int i = 0;
i = 123;
i = 123;
i = ((100 + 20) + 3);
i = 123;
return;
}

View File

@ -4,7 +4,7 @@ void main_1() {
int i = 0;
i = 123;
i = 123;
i = ((100 + 20) + 3);
i = 123;
return;
}

View File

@ -5,7 +5,7 @@ void main_1() {
int i = 0;
i = 123;
i = 123;
i = as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(100) + as_type<uint>(20)))) + as_type<uint>(3)));
i = 123;
return;
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 18
; Bound: 13
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,22 +16,17 @@
%6 = OpConstantNull %int
%_ptr_Function_int = OpTypePointer Function %int
%int_123 = OpConstant %int 123
%int_100 = OpConstant %int 100
%int_20 = OpConstant %int 20
%int_3 = OpConstant %int 3
%main_1 = OpFunction %void None %1
%4 = OpLabel
%i = OpVariable %_ptr_Function_int Function %6
OpStore %i %6
OpStore %i %int_123
OpStore %i %int_123
%12 = OpIAdd %int %int_100 %int_20
%14 = OpIAdd %int %12 %int_3
OpStore %i %14
OpStore %i %int_123
OpReturn
OpFunctionEnd
%main = OpFunction %void None %1
%16 = OpLabel
%17 = OpFunctionCall %void %main_1
%11 = OpLabel
%12 = OpFunctionCall %void %main_1
OpReturn
OpFunctionEnd

View File

@ -2,6 +2,6 @@
void main() {
int i = 123;
i = 123;
i = ((100 + 20) + 3);
i = 123;
return;
}

View File

@ -2,6 +2,6 @@
void main() {
int i = 123;
i = 123;
i = ((100 + 20) + 3);
i = 123;
return;
}

View File

@ -3,7 +3,7 @@
void tint_symbol() {
int i = 123;
i = 123;
i = ((100 + 20) + 3);
i = 123;
}
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 tint_symbol() {
int i = 123;
i = 123;
i = as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(100) + as_type<uint>(20)))) + as_type<uint>(3)));
i = 123;
return;
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 15
; Bound: 10
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -15,16 +15,11 @@
%int_123 = OpConstant %int 123
%_ptr_Function_int = OpTypePointer Function %int
%9 = OpConstantNull %int
%int_100 = OpConstant %int 100
%int_20 = OpConstant %int 20
%int_3 = OpConstant %int 3
%main = OpFunction %void None %1
%4 = OpLabel
%i = OpVariable %_ptr_Function_int Function %9
OpStore %i %int_123
OpStore %i %int_123
%12 = OpIAdd %int %int_100 %int_20
%14 = OpIAdd %int %12 %int_3
OpStore %i %14
OpStore %i %int_123
OpReturn
OpFunctionEnd