[CGP] Ensure sinking multiple instructions does not invalidate dominance checks
commit3110f6b18ee13c1a73bb86497381a1fddf7795e4
authorDavid Green <david.green@arm.com>
Thu, 12 Sep 2019 16:00:07 +0000 (12 16:00 +0000)
committerDavid Green <david.green@arm.com>
Thu, 12 Sep 2019 16:00:07 +0000 (12 16:00 +0000)
tree80de36a0ef8adda101b8fd9c1aaa5e6a0e33081d
parentfff5baa19a1f5353d8e02d18943bb05cf9316ad8
[CGP] Ensure sinking multiple instructions does not invalidate dominance checks

In MVE, as of rL371218, we are attempting to sink chains of instructions such as:
  %l1 = insertelement <8 x i8> undef, i8 %l0, i32 0
  %broadcast.splat26 = shufflevector <8 x i8> %l1, <8 x i8> undef, <8 x i32> zeroinitializer
In certain situations though, we can end up breaking the dominance relations of
instructions. This happens when we sink the instruction into a loop, but cannot
remove the originals. The Use is updated, which might in fact be a Use from the
second instruction to the first.

This attempts to fix that by reversing the order of instruction that are sunk,
and ensuring that we update the uses on new instructions if they have already
been sunk, not the old ones.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371743 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CodeGenPrepare.cpp
test/Transforms/CodeGenPrepare/ARM/sink-add-mul-shufflevector.ll
test/Transforms/CodeGenPrepare/ARM/sinkchain.ll [new file with mode: 0644]