This only handles the basic cases. More work is needed to make better use of op_sel.
The legality check is only done under NDEBUG, so the failure cases are different in a release build. llvm-svn: 366680