This is an archive of the discontinued LLVM Phabricator instance.

Cache results of WalkChainUsers() in SelectionDAG
AbandonedPublic

Authored by zzheng on Jan 19 2016, 5:59 PM.

Details

Summary

We found the following loop, after unrolled by a large factor, can cause infinite compile-time spent in WalkChainUsers() when -combiner-alias-analysis is enabled. This issue was first report by Chad on: https://llvm.org/bugs/show_bug.cgi?id=21759.

In this patch, we appended the proposed fix in the bug report with a test case. The test case is derived from the loop below with 'opt -loop-unroll -unroll-threshold=700 -unroll-allow-paritial'.

define void @foo(i32* nocapture %a) #0 {
entry:
  br label %for.body

for.body:
  %count = phi i64 [ %dec, %for.body ], [ 3000, %entry ]
  %addr = phi i32* [ %gep, %for.body ], [ %a, %entry ]
  %dec = add nsw i64 %count, -8
  %gep = getelementptr inbounds i32, i32* %addr, i64 8
  %cmp = icmp eq i64 %count, 8
  %cast = bitcast i32* %addr to i8*
  call void @llvm.memset.p0i8.i64(i8* %cast, i8 0, i64 32, i32 4, i1 false)
  br i1 %cmp, label %exit, label %for.body

exit:
  ret void
}

Diff Detail

Repository
rL LLVM

Event Timeline

zzheng updated this revision to Diff 45331.Jan 19 2016, 5:59 PM
zzheng retitled this revision from to Cache results of WalkChainUsers() in SelectionDAG.
zzheng updated this object.
zzheng set the repository for this revision to rL LLVM.
zzheng updated this object.
zzheng added a subscriber: llvm-commits.
sgundapa added inline comments.Jan 19 2016, 7:12 PM
test/CodeGen/Generic/token-compile-time.ll
532

Avoid the static string "3.8.0" as this will make the test a failure some time in future

zzheng updated this revision to Diff 45418.Jan 20 2016, 11:18 AM

Removed irrelevant metadata in test case.

zzheng marked an inline comment as done.Jan 20 2016, 11:19 AM

Addressed Sumanth's comment.

zzheng updated this revision to Diff 45436.Jan 20 2016, 1:07 PM

Removed target info in test case.

mcrosier resigned from this revision.Feb 2 2016, 1:57 PM
mcrosier removed a reviewer: mcrosier.
hfinkel edited edge metadata.Feb 3 2016, 4:13 AM

It looks like this problem has now been solved in trunk (r259315).

zzheng abandoned this revision.Apr 6 2016, 11:17 AM