While testing this function: define bool i32() { ret bool true; } I noticed that it is possible for the X86 backend to generate: movb al, eax which doesn't assemble. To make this happen, go to CodeGen/SelectionISel.cpp in the visitRetInst function and make it *not* do an extend (of any kind) for boolean. This will cause the Legalizer to apply an ANY_EXTEND which, presumably, means that not doing an extend is okay. While that change is not correct, the X86 backend shouldn't generate incorrect instructions either.
Looks like legalizer isn't inserting an anyext to i32 so we ended up with a movb with a 32-bit register destination. If you let visitRet insert the anyext node, then it will not generate this illegal instruction.