[GuardWidening] Preserve MemorySSA
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 19 Aug 2021 16:42:27 +0000 (18:42 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 19 Aug 2021 18:23:17 +0000 (20:23 +0200)
commit8cf5b69f69bf95413f4009eddd94b2cc0a2d3412
tree9b23223f746aef1e212bf3a0c28aa74116da6bac
parent95ddc8341ae2c27229ad3dcf1d55abebcec15d02
[GuardWidening] Preserve MemorySSA

As reported on https://bugs.llvm.org/show_bug.cgi?id=51020, the
guard widening pass doesn't preserve MemorySSA, so it can no
longer be scheduled in the same loop pass manager as LICM. However,
the loop-schedule.ll test indicates that this is supposed to work.

Fix this by preserving MemorySSA if available, as this seems to be
trivial in this case (we only need to drop the memory access for
the removed guards).

Differential Revision: https://reviews.llvm.org/D108386
llvm/lib/Transforms/Scalar/GuardWidening.cpp
llvm/test/Transforms/GuardWidening/basic-loop.ll
llvm/test/Transforms/GuardWidening/loop-schedule.ll