tint: Fix Resolver erroneously materializing matrices of abstract numeric type

ShouldMaterializeArgument must check that the deepest element is not
abstract numeric to support matrices.

This CL also enables the "no materialize" tests for binary ops, as
constant evaluation of binary addition was recently landed, and that's
what the test uses. The fix in this CL is also necessary for this test
to pass the matrix addition case (it would fail because it erroneously
materialized).

Bug: tint:1581
Change-Id: Id55341c05604c1ac560127826fc415eb38792503
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98682
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano 2022-08-10 14:32:19 +00:00 committed by Dawn LUCI CQ
parent f350578c99
commit a8e9a6ef2b
2 changed files with 5 additions and 4 deletions

View File

@ -464,9 +464,10 @@ constexpr Method kSwitchMethods[] = {
/// Methods that do not materialize /// Methods that do not materialize
constexpr Method kNoMaterializeMethods[] = { constexpr Method kNoMaterializeMethods[] = {
Method::kPhonyAssign, Method::kPhonyAssign, //
// TODO(crbug.com/tint/1504): Enable once we have abstract overloads of builtins / binary Method::kBinaryOp,
// ops: Method::kBuiltinArg, Method::kBinaryOp, // TODO(crbug.com/tint/1504): Enable once "min" supports const evaluation
// Method::kBuiltinArg,
}; };
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
MaterializeScalar, MaterializeScalar,

View File

@ -1452,7 +1452,7 @@ bool Resolver::MaterializeArguments(utils::Vector<const sem::Expression*, N>& ar
} }
bool Resolver::ShouldMaterializeArgument(const sem::Type* parameter_ty) const { bool Resolver::ShouldMaterializeArgument(const sem::Type* parameter_ty) const {
const auto* param_el_ty = sem::Type::ElementOf(parameter_ty); const auto* param_el_ty = sem::Type::DeepestElementOf(parameter_ty);
return param_el_ty && !param_el_ty->Is<sem::AbstractNumeric>(); return param_el_ty && !param_el_ty->Is<sem::AbstractNumeric>();
} }