As noted in PR24766:
https://llvm.org/bugs/show_bug.cgi?id=24766#c2
...we're not doing a great job of optimizing/shrinking switch conditions in InstCombine. If we do better, we could remove bogus case statements.
Step 1 to solving this is to remove a hack that was added for the benefit of x86 codegen. It prevented shrinking the switch condition even to smaller legal types.
FWIW, I don't see any perf difference on test-suite on x86 with this change, and I'm not sure how the supposed extra zext x86 instructions would hurt anyway.
I think it would be better to refactor InstCombiner::ShouldChangeType to have a version that directly takes the bit widths. ShouldChangeType just calls getPrimitiveSizeInBits on the provided types anyway, and that prevents the need to speculatively call Type::getIntNTy.