tint: Simplify ++/-- handling in transform
Now that we have untyped literals, we can just add `1` rather than
adding either `1u` or `1i`.
Bug: tint:1488
Change-Id: I59512be8fc67b1bf45088478da7c93bed37a69b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94141
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/transform/expand_compound_assignment.cc b/src/tint/transform/expand_compound_assignment.cc
index d15d790..e5e953c 100644
--- a/src/tint/transform/expand_compound_assignment.cc
+++ b/src/tint/transform/expand_compound_assignment.cc
@@ -174,14 +174,8 @@
state.Expand(assign, assign->lhs, ctx.Clone(assign->rhs), assign->op);
} else if (auto* inc_dec = node->As<ast::IncrementDecrementStatement>()) {
// 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<ast::IntLiteralExpression>()
- : ctx.dst->Expr(1_u)->As<ast::IntLiteralExpression>();
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();