-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integer binary ops design discussion #743
Comments
There's no need to inline the else block, since it's only used for long integers, and we can expect them to be relatively rare. Any performance benefit from inlining isn't worth the extra code size. So this would be a sufficient level of inlining: #define CPY_INT_TAG 1
if (!(left & CPY_INT_TAG)) {
result = left == right;
} else {
result = CPyTagged_IsEq_(left, right);
}
return result This would simplify the IR significantly. Another thing is that we'd need an explicit comparison op after the bitwise and, for example:
The generated IR is still a bit verbose. Maybe we should support integer literals as operands so we could represent the above IR more compactly like this:
This might be worth it, since it looks like the low-level IR will have lots of low-level integer values. (This simplification can happen later.) |
Actually I find that we did register binary comparison ops for short ints(check |
A good entry point would be
|
Integer ops are special enough that we can just implement them in a function called from |
Related: mypyc/mypyc#741 This PR introduces BinaryIntOp to represent all low-level integer binary operations. The block-like logic described in mypyc/mypyc#743 would be handled differently, BinaryIntOp would be the building block of it.
Start with a simple example:
In the current C backend, it will generated C code(fully inlined except the out of memory handling):
So I guess the IR would look like
Instead of generating a single
PrimitiveOp
, we are trying to generate several blocks/branches.BitwiseNot
,BitwiseAnd
,BinaryEq
should all be the binary ops we'd want to add.cc @JukkaL
The text was updated successfully, but these errors were encountered: