Skip to main content

counts

Function counts 

Source
pub fn counts(func: &mut Func)
Expand description

Rewrites every bit count into the arithmetic that is one, and leaves the rest alone.

Three instructions and no rules, which is tamnd/rucc#310. popcnt is one instruction on a machine that has it and bsr and bsf are the two searches, and none of the three is a term the model knows about yet, so what runs today is what runs everywhere. The trade is the one spec/10-backend.md section 10.3 describes and expand::bytes above makes for the same reason: slower than the instruction, right on every target, and built only out of rules the verifier has already discharged.

The two searches are rewritten first, into a set bit count and a little arithmetic, and then every set bit count is rewritten. That is one pass rather than two because the second sweep picks up what the first one wrote, and it means there is one place that knows how to count bits rather than three.