llvm-project/llvm/lib/Transforms
Nikita Popov 649e125451 [BDCE][DemandedBits] Detect dead uses of undead instructions
This (mostly) fixes https://bugs.llvm.org/show_bug.cgi?id=39771.

BDCE currently detects instructions that don't have any demanded bits
and replaces their uses with zero. However, if an instruction has
multiple uses, then some of the uses may be dead (have no demanded bits)
even though the instruction itself is still live. This patch extends
DemandedBits/BDCE to detect such uses and replace them with zero.
While this will not immediately render any instructions dead, it may
lead to simplifications (in the motivating case, by converting a rotate
into a simple shift), break dependencies, etc.

The implementation tries to strike a balance between analysis power and
complexity/memory usage. Originally I wanted to track demanded bits on
a per-use level, but ultimately we're only really interested in whether
a use is entirely dead or not. I'm using an extra set to track which uses
are dead. However, as initially all uses are dead, I'm not storing uses
those user is also dead. This case is checked separately instead.

The test case has a couple of cases that are not simplified yet. In
particular, we're only looking at uses of instructions right now. I think
it would make sense to also extend this to arguments. Furthermore
DemandedBits doesn't yet know some of the tricks that InstCombine does
for the demanded bits or bitwise or/and/xor in combination with known
bits information.

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

llvm-svn: 349674
2018-12-19 19:56:21 +00:00
..
AggressiveInstCombine [AggressiveInstCombine] convert rotate with guard branch into funnel shift (PR34924) 2018-12-17 21:14:51 +00:00
Coroutines Fix compiler warning about unused variable [NFC] 2018-12-12 06:33:45 +00:00
Hello
IPO [LoopVectorize] Rename pass options. NFC. 2018-12-18 17:46:09 +00:00
InstCombine [InstCombine] Simplify cttz/ctlz + icmp eq/ne into mask check 2018-12-18 19:59:50 +00:00
Instrumentation [asan] Restore ODR-violation detection on vtables 2018-12-18 22:23:30 +00:00
ObjCARC Change the objc ARC optimizer to use the new objc.* intrinsics 2018-12-18 20:32:49 +00:00
Scalar [BDCE][DemandedBits] Detect dead uses of undead instructions 2018-12-19 19:56:21 +00:00
Utils [Util] Refer to [s|z]exts of args when converting dbg.declares (fix PR35400) 2018-12-15 00:03:33 +00:00
Vectorize Test commit 2018-12-19 17:18:40 +00:00
CMakeLists.txt Another try to commit 323321 (aggressive instruction combine). 2018-01-25 12:06:32 +00:00
LLVMBuild.txt Another try to commit 323321 (aggressive instruction combine). 2018-01-25 12:06:32 +00:00