GEP's across basic blocks were not getting splitted due to EnableGEPOpt which was turned off by default. Hence, EarlyCSE missed the opportunity to eliminate common part of GEP's. This can be achieved by simply turning GEP pass on.
- This patch moves SeparateConstOffsetFromGEPPass() just before LSR().
- It enables EnableGEPOpt by default.
Resolves - https://github.com/llvm/llvm-project/issues/50528
Added an unit test.
Let me know best course of action on lowerToSingleIndexGEPs().
I have temporarily removed it because I was running SPEC benchmarks for AArch64 and GEP's are being splitted using lowerToSingleIndexGEPs() when called using clang.
But when called using opt, lowerToArithmetics() gets called. I want to have lowerToArithmetics() as default.
Also, this pass was no longer used.