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

Add support for 'switch' statements #7

Closed
ispc opened this issue Jun 22, 2011 · 1 comment
Closed

Add support for 'switch' statements #7

ispc opened this issue Jun 22, 2011 · 1 comment
Labels

Comments

@ispc
Copy link
Collaborator

ispc commented Jun 22, 2011

It would be good to add support for 'switch'.

For 'uniform' type switch expressions, this should be a very straightforward mapping to the LLVM SwitchInst.

How to efficiently implement it for 'varying' switch expressions is an interesting question. A correct-but-possibly-slow baseline would be to transform it into the equivalent set of if/elses, updating the mask at each block. One could also imagine something more efficient along the lines of:

lanes = current active simd lanes
while (lanes != 0) {
find first lane in lanes that is on
figure out which switch target it wants to jump to
figure out which other active lanes, if any, want to jump to that target
set the mask accordingly
run the code for those lanes
update 'lanes' to turn off the bits for the lanes that just ran
}

@mmp
Copy link
Collaborator

mmp commented Jan 11, 2012

Done in b67446d

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

No branches or pull requests

1 participant