llvm-project/llvm/lib/Transforms/InstCombine
Nikita Popov 4ef272ec9c [InstCombine] DCE instructions earlier
When InstCombine initially populates the worklist, it already
performs constant folding and DCE. However, as the instructions
are initially visited in program order, this DCE can pick up only
the last instruction of a dead chain, the rest would only get
picked up in the main InstCombine run.

To avoid this, we instead perform the DCE in separate pass over the
collected instructions in reverse order, which will allow us to
pick up full dead instruction chains. We already need to do this
reverse iteration anyway to populate the worklist, so this
shouldn't add extra cost.

This by itself only fixes a small part of the problem though:
The same basic issue also applies during the main InstCombine loop.
We generally always want DCE to occur as early as possible,
because it will allow one-use folds to happen. Address this by also
performing DCE while adding deferred instructions to the main worklist.

This drops the number of tests that perform more than 2 InstCombine
iterations from ~80 to ~40. There's some spurious test changes due
to operand order / icmp toggling.

Differential Revision: https://reviews.llvm.org/D75008
2020-02-27 18:45:59 +01:00
..
CMakeLists.txt [cmake] Explicitly mark libraries defined in lib/ as "Component Libraries" 2019-11-21 10:48:08 -08:00
InstCombineAddSub.cpp Remove BinaryOperator::CreateFNeg 2020-02-27 09:06:03 -08:00
InstCombineAndOrXor.cpp [InstCombin] Avoid nested Create calls, to guarantee order. 2020-02-18 09:44:11 +01:00
InstCombineAtomicRMW.cpp [InstCombine] Use replaceOperand() in more places 2020-02-11 17:38:23 +01:00
InstCombineCalls.cpp Remove BinaryOperator::CreateFNeg 2020-02-27 09:06:03 -08:00
InstCombineCasts.cpp Remove BinaryOperator::CreateFNeg 2020-02-27 09:06:03 -08:00
InstCombineCompares.cpp [InstCombine] Fix confusing variable name. 2020-02-27 11:27:49 +00:00
InstCombineInternal.h [InstCombine] DCE instructions earlier 2020-02-27 18:45:59 +01:00
InstCombineLoadStoreAlloca.cpp [InstCombine] Fix infinite loop in min/max load/store bitcast combine (PR44835) 2020-02-08 16:55:22 +01:00
InstCombineMulDivRem.cpp Remove BinaryOperator::CreateFNeg 2020-02-27 09:06:03 -08:00
InstCombinePHI.cpp [InstCombine] Don't use getFirstNonPHI in FoldIntegerTypedPHI 2019-11-14 17:52:01 -08:00
InstCombineSelect.cpp Remove BinaryOperator::CreateFNeg 2020-02-27 09:06:03 -08:00
InstCombineShifts.cpp [InstCombine] reassociateShiftAmtsOfTwoSameDirectionShifts(): fix miscompile (PR44802) 2020-02-25 18:23:51 +03:00
InstCombineSimplifyDemanded.cpp [InstCombine] Improve simplify demanded bits worklist management 2020-02-21 18:51:41 +01:00
InstCombineTables.td InstCombine/AMDGPU: Add dimension-aware image intrinsics to SimplifyDemanded 2018-06-21 13:37:31 +00:00
InstCombineVectorOps.cpp [InstCombine] Use replaceOperand() in more places 2020-02-11 17:38:23 +01:00
InstructionCombining.cpp [InstCombine] DCE instructions earlier 2020-02-27 18:45:59 +01:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00