instcombine would propagate shufflevector insts that had wider output vectors onto predecessors, which would sometimes push undef's onto the divisor of a div/rem and result in bad codegen.
I've fixed this by just banning propagating shufflevector back if the result of the shufflevector is wider than the input vectors.
I think this should to into lib/IR/Instructions.cpp, somewhere around the ShuffleVectorInst::isIdentityMask()?
(isWideningMask())