This is useful because in certain cases it enables you to remove all of the overhead of a switch statement by indexing the label addresses based on the argument to the switch, thus jumping directly to the code you want on a certain input.
When I attempt this with nvcc I get the following output.
Assertion failure at line 123 of …/…/be/opt/opt_lab.cxx:
Compiler Error in file /tmp/tmpxft_00002d90_00000000-7_vm.cpp3.i during Global Optimization – Mainopt Lowering phase:
Unexpected control transfer instruction !
I take it this means computed gotos are unsupported in nvcc. Is this impossible? Will it be added in the future? This sort of thing would be straightforward to implement directly in ptx, but I would prefer to avoid this.
A computed goto sounds like it could end up producing an indirect jump, which is not supported by current hardware. Apparently this will change with Fermi, though…