[all-commits] [llvm/llvm-project] 1c9bec: [InstCombine] Fold (gep (oneuse(gep Ptr, Idx0)), I...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Thu Jul 22 03:16:36 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1c9bec727ab5c53fa060560dc8d346a911142170
      https://github.com/llvm/llvm-project/commit/1c9bec727ab5c53fa060560dc8d346a911142170
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2021-07-22 (Thu, 22 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/InstCombine/gep-combine-loop-invariant.ll
    M llvm/test/Transforms/InstCombine/gep-custom-dl.ll
    M llvm/test/Transforms/InstCombine/getelementptr.ll
    M llvm/test/Transforms/InstCombine/select-gep.ll
    M llvm/test/Transforms/InstCombine/shift.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/sve-vector-reverse.ll
    M llvm/test/Transforms/LoopVectorize/AArch64/vector-reverse-mask4.ll
    M llvm/test/Transforms/LoopVectorize/ARM/mve-reduction-predselect.ll
    M llvm/test/Transforms/LoopVectorize/ARM/mve-reductions.ll
    M llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll
    M llvm/test/Transforms/LoopVectorize/consecutive-ptr-uniforms.ll
    M llvm/test/Transforms/LoopVectorize/interleaved-accesses.ll

  Log Message:
  -----------
  [InstCombine] Fold (gep (oneuse(gep Ptr, Idx0)), Idx1) -> (gep Ptr, (add Idx0, Idx1)) (PR51069)

As noticed on D106352, after we've folded "(select C, (gep Ptr, Idx), Ptr) -> (gep Ptr, (select C, Idx, 0))" if the inner Ptr was also a (now one use) gep we could then merge the geps, using the sum of the indices instead.

I've limited this to basic 2-op geps - a more general case further down InstCombinerImpl.visitGetElementPtrInst doesn't have the one-use limitation but only creates the add if it can be created via SimplifyAddInst.

https://alive2.llvm.org/ce/z/f8pLfD (Thanks Roman!)

Differential Revision: https://reviews.llvm.org/D106450




More information about the All-commits mailing list