Skip to content
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

Rewrite builder.CreateAnd and builder.CreateOr when translating to LLVM #1269

Open
skrynski opened this issue Mar 6, 2024 · 0 comments
Open
Labels
backend needs working on the llvm backend (/compiler/native) enhancement

Comments

@skrynski
Copy link
Collaborator

skrynski commented Mar 6, 2024

CreateAnd and CreateOr are used in such a way that both arguments are fully computed before the test is performed, reducing opportunity for short-circuiting.

Ex.


builder.CreateOr(
                builder.CreateICmpEQ(v, c(0)),   
                builder.CreateOr(builder.CreateICmpEQ(v, c(1)),
                                 builder.CreateICmpEQ(v, c(NA_LOGICAL))))

The way we write the code, both arguments to CreateOr will already emit code even before the method is invoked. Then the actual OR operation is emitted.
I suggest we rewrite both operators similarly to what we do for createSelect2, this is, we take functions for the arguments.
Going a step further, we could also take a vectors of functions instead of a fixed two args (see isVector())

@skrynski skrynski added enhancement backend needs working on the llvm backend (/compiler/native) labels Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend needs working on the llvm backend (/compiler/native) enhancement
Projects
None yet
Development

No branches or pull requests

1 participant