tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Codegen: direct compare-and-branch for integer comparisons (issue #191)

A switch on tl_int_compare's Order, on tl_int_eq's Bool, or on a
TagIs/Not chain over one — the comparison's result used nowhere else —
becomes a direct compare-and-branch: with both operands proven small
(the range analysis, now consulted at arithmetic uses where a guard's
arm refined them), one C comparison; otherwise a fast path under
tl_likely(a & b & 1) jumping to the arms, the general code — the
extern's call, then the tag dispatch — in the else. Arms are emitted
once under labels both paths jump to, so nested comparisons do not
multiply the C text (time.lse's came out at 8.6 GB without that).

An operand dropped between the comparison and the switch (the
comparison was its last use) has its drop deferred to the slow path,
after the call; on the fast path the guard proves it a small integer,
whose drop is a no-op. Drops and dups of proven-small integers are
skipped outright. tests/run/int_comparisons.lse checks every operator
on small, negative, boundary and big operands on both backends.

olivier · il y a 1 mois · b75564e7781d81381a53843ca6a608cd31ab58cd

Parents e414824

5 fichiers modifiés, 1007 ajouts, 18 suppressions

Mcrates/louise_codegen_c/src/emit/mod.rs+761−3
Mcrates/louise_codegen_c/src/ranges.rs+33−12
Acrates/louise_codegen_c/tests/cmp_paths.rs+143−0
Mcrates/louise_core/src/opt/simplify.rs+2−3