[DAGCombiner] After performing the division by constant optimization for a DIV or...
authorCraig Topper <craig.topper@intel.com>
Wed, 2 Jan 2019 18:19:07 +0000 (18:19 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 2 Jan 2019 18:19:07 +0000 (18:19 +0000)
commit8dd7bd2cd7575e125307b2d392d45ecfbe0ac1f4
tree448b7290be13d2f8caa70cbd2e7b9bd57576bf84
parentda997b4aaf39862dbc530dc0be85b1212f569b8f
[DAGCombiner] After performing the division by constant optimization for a DIV or REM node, replace the users of the corresponding REM or DIV node if it exists.

Currently we expand the two nodes separately. This gives DAG combiner an opportunity to optimize the expanded sequence taking into account only one set of users. When we expand the other node we'll create the expansion again, but might not be able to optimize it the same way. So the nodes won't CSE and we'll have two similarish sequences in the same basic block. By expanding both nodes at the same time we'll avoid prematurely optimizing the expansion until both the division and remainder have been replaced.

Improves the test case from PR38217. There may be additional opportunities after this.

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

llvm-svn: 350239
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/divide-by-constant.ll
llvm/test/CodeGen/X86/pr38217.ll