[DAG] Set up infrastructure to avoid smart constructor-based dangling nodes
authorNirav Dave <niravd@google.com>
Fri, 29 Mar 2019 17:26:40 +0000 (17:26 +0000)
committerNirav Dave <niravd@google.com>
Fri, 29 Mar 2019 17:26:40 +0000 (17:26 +0000)
commit610036c506218dbc70464fc2fb7b86dc4d6f906a
tree78df553ae05ec721b3b4a62ce600bb1771f4c739
parent4e00a935587ff90c841edcd41d41e92767f4181a
[DAG] Set up infrastructure to avoid smart constructor-based dangling nodes

Summary:
Various SelectionDAG non-combine operations (e.g. the getNode smart
constructor and legalization) may leave dangling nodes by applying
optimizations without fully pruning unused result values. This results
in nodes that are never added to the worklist and therefore can not be
pruned.

Add a node inserter for the combiner to make sure such nodes have the
chance of being pruned. This allows a number of additional peephole
optimizations.

Reviewers: efriedma, RKSimon, craig.topper, jyknight

Reviewed By: jyknight

Subscribers: msearles, jyknight, sdardis, nemanjai, javed.absar, hiraditya, jrtc27, atanasyan, jsji, llvm-commits

Tags: #llvm

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

llvm-svn: 357279
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp