This patch extends the patterns recognised by InstCombine to also optimise gep (gep p, a), (b-a) into gep p, b.
Some minor refactoring was done in order to make the various optimisation/shortcut cases share the same code structure.
The missing optimisation was found investigating why LLVM did not optimise away pointer computations in Rust slices: https://github.com/rust-lang/rust/pull/37921
You can fold the SimplifyAddInst inside the if, no?