Add explicit size int and count types (8, 16, 32, and 64 bits)#540
Add explicit size int and count types (8, 16, 32, and 64 bits)#540
Conversation
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.
jimbxb
left a comment
There was a problem hiding this comment.
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
|
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. |
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.