Fixed optimization issues in switch.

This commit adds a new optimization option, PRIORITY_OPTIMIZE, which causes the function to be optimized before its children. This is advantageous for functions whose children being removed via optimization out would cause issues with the compilation process. This causes optimizeDynamic to be called before the children are processed. Additionally, a change has been made to move __autoconcat__ optimization out of the main optimization loop. This makes __autoconcat__ optimization happen independently of the main optimization, which is fairly complex. This means that in the future, optimizations can be turned off, but __autoconcat__ will still be "optimized".

This fixes bug 2985.