transform/bound_array_accessors: Use new arrayLength overload
Change-Id: I525693c232f1c16ffae5e17f76ae2b9349539469 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54600 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: James Price <jrprice@google.com> Auto-Submit: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
7e22196a35
commit
3184544182
|
@ -70,7 +70,7 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
if (is_arr) {
|
if (is_arr) {
|
||||||
auto* arr = ctx->Clone(expr->array());
|
auto* arr = ctx->Clone(expr->array());
|
||||||
auto* arr_len = b.Call("arrayLength", arr);
|
auto* arr_len = b.Call("arrayLength", ctx->dst->AddressOf(arr));
|
||||||
auto* limit = b.Sub(arr_len, b.Expr(1u));
|
auto* limit = b.Sub(arr_len, b.Expr(1u));
|
||||||
new_idx = b.Call("min", b.Construct<u32>(ctx->Clone(old_idx)), limit);
|
new_idx = b.Call("min", b.Construct<u32>(ctx->Clone(old_idx)), limit);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -557,7 +557,7 @@ struct S {
|
||||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||||
|
|
||||||
fn f() {
|
fn f() {
|
||||||
var d : f32 = s.b[min(u32(25), (arrayLength(s.b) - 1u))];
|
var d : f32 = s.b[min(u32(25), (arrayLength(&(s.b)) - 1u))];
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ struct S {
|
||||||
let c : u32 = 1u;
|
let c : u32 = 1u;
|
||||||
|
|
||||||
fn f() {
|
fn f() {
|
||||||
let b : f32 = s.b[min(u32(c), (arrayLength(s.b) - 1u))];
|
let b : f32 = s.b[min(u32(c), (arrayLength(&(s.b)) - 1u))];
|
||||||
let x : i32 = min(1, 2);
|
let x : i32 = min(1, 2);
|
||||||
let y : u32 = arrayLength(s.b);
|
let y : u32 = arrayLength(s.b);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue