diff --git a/src/tint/transform/expand_compound_assignment.cc b/src/tint/transform/expand_compound_assignment.cc index d15d790dab..e5e953cff0 100644 --- a/src/tint/transform/expand_compound_assignment.cc +++ b/src/tint/transform/expand_compound_assignment.cc @@ -174,14 +174,8 @@ void ExpandCompoundAssignment::Run(CloneContext& ctx, const DataMap&, DataMap&) state.Expand(assign, assign->lhs, ctx.Clone(assign->rhs), assign->op); } else if (auto* inc_dec = node->As()) { // For increment/decrement statements, `i++` becomes `i = i + 1`. - // TODO(jrprice): Simplify this when we have untyped literals. - auto* sem_lhs = ctx.src->Sem().Get(inc_dec->lhs); - const ast::IntLiteralExpression* one = - sem_lhs->Type()->UnwrapRef()->is_signed_integer_scalar() - ? ctx.dst->Expr(1_i)->As() - : ctx.dst->Expr(1_u)->As(); auto op = inc_dec->increment ? ast::BinaryOp::kAdd : ast::BinaryOp::kSubtract; - state.Expand(inc_dec, inc_dec->lhs, one, op); + state.Expand(inc_dec, inc_dec->lhs, ctx.dst->Expr(1_a), op); } } state.Finalize(); diff --git a/src/tint/transform/expand_compound_assignment_test.cc b/src/tint/transform/expand_compound_assignment_test.cc index 613a13535a..6b18b40378 100644 --- a/src/tint/transform/expand_compound_assignment_test.cc +++ b/src/tint/transform/expand_compound_assignment_test.cc @@ -473,7 +473,7 @@ fn main() { auto* expect = R"( fn main() { var v : i32; - v = (v + 1i); + v = (v + 1); } )"; @@ -493,7 +493,7 @@ fn main() { auto* expect = R"( fn main() { var v : u32; - v = (v + 1u); + v = (v + 1); } )"; @@ -513,7 +513,7 @@ fn main() { auto* expect = R"( fn main() { var v : i32; - v = (v - 1i); + v = (v - 1); } )"; @@ -533,7 +533,7 @@ fn main() { auto* expect = R"( fn main() { var v : u32; - v = (v - 1u); + v = (v - 1); } )"; @@ -556,7 +556,7 @@ fn main() { var v : i32; let p = &(v); let tint_symbol = &(*(p)); - *(tint_symbol) = (*(tint_symbol) + 1i); + *(tint_symbol) = (*(tint_symbol) + 1); } )"; @@ -584,7 +584,7 @@ struct S { fn main() { var s : S; - s.m = (s.m + 1i); + s.m = (s.m + 1); } )"; @@ -617,7 +617,7 @@ fn idx() -> i32 { fn main() { let tint_symbol = &(a[idx()]); - *(tint_symbol) = (*(tint_symbol) + 1i); + *(tint_symbol) = (*(tint_symbol) + 1); } )"; @@ -651,7 +651,7 @@ fn idx() -> i32 { fn main() { let tint_symbol = &(v); let tint_symbol_1 = idx(); - (*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1i); + (*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1); } )"; @@ -671,7 +671,7 @@ fn main() { auto* expect = R"( fn main() { var v : vec4; - v.y = (v.y + 1i); + v.y = (v.y + 1); } )"; @@ -727,7 +727,7 @@ fn main() { continuing { let tint_symbol = &(a[idx1()]); let tint_symbol_1 = idx2(); - (*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1i); + (*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1); } } }