[NaryReassociate] run NaryReassociate iteratively
authorJingyue Wu <jingyue@google.com>
Fri, 17 Apr 2015 00:25:10 +0000 (00:25 +0000)
committerJingyue Wu <jingyue@google.com>
Fri, 17 Apr 2015 00:25:10 +0000 (00:25 +0000)
commitf182c81444c5545d3205c0a5a7936b5863999aea
treea7b151b09537cb1759b7a292c2f9b5e93ed2e8be
parentf5c3abad67c11888e4ed11d08fa374f2e94fa442
[NaryReassociate] run NaryReassociate iteratively

Summary:
An alternative is to use a worklist approach. However, that approach
would break the traversing order so that we couldn't lookup SeenExprs
efficiently. I don't see a clear winner here, so I picked the easier approach.

Along with two minor improvements:
1. preserves ScalarEvolution by forgetting instructions replaced
2. removes dead code locally avoiding the need of running DCE afterwards

Test Plan: add to slsr-add.ll a test that requires multiple iterations

Reviewers: broune, dberlin, atrick, meheff

Reviewed By: atrick

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D9058

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235151 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/NaryReassociate.cpp
test/Transforms/NaryReassociate/nary-add.ll