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

failing to move index addition to constant table pointer #58328

Open
mikebenfield opened this issue Oct 12, 2022 · 0 comments
Open

failing to move index addition to constant table pointer #58328

mikebenfield opened this issue Oct 12, 2022 · 0 comments

Comments

@mikebenfield
Copy link

mikebenfield commented Oct 12, 2022

Two LLVM IR functions

Here are two IR functions implementing this pseudocode:

def somefunction(x):
    return switch.table[x - 15]

When somefunction2 is compiled the -15 is moved to the constant table pointer, rather than doing an operation at runtime. Great.

This doesn't happen with somefunction1. Presumably because the compiler wants to maintain the same 8-bit wraparound behavior, so wants to do the arithmetic in 8 bits. But that behavior is irrelevant, as can be determined by either the llvm.assume or the size of the table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants