This is intended to be the same functionality as D31037 (EarlyCSE) but implemented as an independent pass, so there's no stretching of scope and feature creep for an existing pass. I also proposed a weaker version of this for SimplifyCFG in D30910. And I initially had almost this same functionality as another lump of CGP in the motivating example of PR31028 ( https://bugs.llvm.org/show_bug.cgi?id=31028 ). It's been a long road. :)
The advantage of positioning this ahead of SimplifyCFG / InstCombine in the pass pipeline is that we'll reduce the positive test cases to a single block:
%rem = urem i8 %a, %b %div = udiv i8 %a, %b %cmp = icmp eq i8 %div, 42 %sel = select i1 %cmp, i8 %rem, i8 3 ret i8 %sel
...and that can lead to better codegen even for targets that don't have a joint divrem instruction. D30910 has an AArch64 example of that.