[Simplify] Remove unused instructions and accesses.
commit6c1dcb4649ad8c5df81985baab490cf615c62ed6
authorMichael Kruse <llvm@meinersbur.de>
Thu, 20 Jul 2017 16:21:55 +0000 (20 16:21 +0000)
committerMichael Kruse <llvm@meinersbur.de>
Thu, 20 Jul 2017 16:21:55 +0000 (20 16:21 +0000)
tree5e186c9aa299e74d43cb21f380139638c0970d9a
parent8c48cc4c5a0f88d54e40710b21cdb9bf6e5977eb
[Simplify] Remove unused instructions and accesses.

Use a mark-and-sweep algorithm to find and remove unused instructions
and MemoryAccesses. This is useful in particular to remove scalar
writes that are never used anywhere. A scalar write in a loop induces
a write-after-write dependency that stops the loop iterations to be
rescheduled. Such writes can be a result of previous transformations
such as DeLICM and operand tree forwarding.

It adds a new class VirtualInstruction that represents an instruction in
a particular statement. At the moment an instruction can only belong to
the statement that represents a BasicBlock. In the future, instructions
can be in one of multiple statements representing a BasicBlock
(Nandini's work), in different statements than its BasicBlock would
indicate, and even multiple statements at once (by forwarding operand
trees). It also integrates nicely with the VirtualUse class.

ScopStmt::contains(Instruction*) currently uses the instruction's parent
BasicBlock to check whether it contains the instruction. It will need to
check the actual statement list when one of the aforementioned features
become possible.

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

git-svn-id: https://llvm.org/svn/llvm-project/polly/trunk@308626 91177308-0d34-0410-b5e6-96231b3b80d8
include/polly/ScopInfo.h
include/polly/Support/VirtualInstruction.h
lib/Analysis/ScopInfo.cpp
lib/Support/VirtualInstruction.cpp
lib/Transform/Simplify.cpp
test/Simplify/dead_access_load.ll [new file with mode: 0644]
test/Simplify/dead_access_phi.ll [new file with mode: 0644]
test/Simplify/dead_access_value.ll [new file with mode: 0644]
test/Simplify/dead_instruction.ll [new file with mode: 0644]