The goal of this pattern is to eliminate all GEPs that have more than two indices by splitting it into multiple GEPs.
The advantage of this change is that the resulting GEPs only ever index into one aggregate at the time. This enables handling sub-aggregates in other patterns and also creates IR with easier to deduce pointer element types.
As a minor note, getResultPtrElementType for GEPOp was rewritten since it did not properly handle dynamic indices. The way GEPOp is specified, the resulting pointer element type can *always* be deduced from its base type and indices.
IRC we introduced the loop above since using drop_begin on getIndices resulted in strange crashes depending on the machine etc. Maybe copying the indices on the line above actually fixes the problem. Was this the reason for the additional copy?