Skip to content

Add explicit size int and count types (8, 16, 32, and 64 bits)#540

Merged
pschachte merged 8 commits intomasterfrom
fixedsizeints
Feb 19, 2026
Merged

Add explicit size int and count types (8, 16, 32, and 64 bits)#540
pschachte merged 8 commits intomasterfrom
fixedsizeints

Conversation

@pschachte
Copy link
Owner

Add a test case for all the operations of these types. Fix a few bugs discovered.
Also close #494, removing the +=, -=, etc. operations, since they're now redundant.

BodyBuilder now optimises away equality test for 1
with 1 bit values, taking the compared value as
the result.  This reduces the generated LLVM code,
though I expect the LLVM optimiser would already do
this optimisation.  The benefit is that it reduces
the generated LPVM code, possibly allowing inlining
more often, and maybe benefitting other LPVM optimisations.

This pull also includes an optimisation to remove
llvm and operations applied n-bit values and the
constant 2^n-1.  Unfortunately, this triggers a bug
in BodyBuilder, so I'm leaving it commented out until
I can find and fix the bug.
Copy link
Collaborator

@jimbxb jimbxb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I have the patience to comb through the new int and count variants. This would be a great opportunity for a macro system of sorts, but this isn't a can of worms we should open here.

LGTM

@pschachte pschachte merged commit be3c95a into master Feb 19, 2026
1 check passed
@pschachte
Copy link
Owner Author

Interesting point about macros. In general, I'd rather allow users to write normal Wybe code and have the compiler specialise it for different cases. That's especially true in this case, given how similar the code for the different versions is (the only differences are the representation, the upper and lower bounds, and the specialised C functions called). But I really don't see how to do that in this case. You'd kind of want a type that's parametric in its bitwidth, and we only allow types to be parameterised by other types.

@pschachte pschachte deleted the fixedsizeints branch February 20, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the +=, *=, etc. library operations

2 participants

Comments