[PATCH] [Jump-Threading] Fixed jump threading hang issues (PR15386, PR15851)
Dinesh Dwivedi
dinesh.d at samsung.com
Mon Jun 9 22:53:52 PDT 2014
Each pass iterates over all BBs of the functions and all updated BBs are added to
'UpdatedBB' so if first pass adds 3 BBs and second pass adds 2, there will be
5 BBs in the list and we will still continue with next pass.
Every change in BBs actually adds atleast one new block XXX.thread and till it finds
some new block added or updated, it will do next iteration on all BBs of the function.
and the condition, that will break this is when we are not adding any new block or not
updatind any new BB.
In attached test case, jump threading stuck between 'for.cond1' and 'for.body' block.
Here is sample output for few iterations.
After first iteration:
for.cond1: ; preds = %for.body.thread, %for.body, %land.rhs
%div5 = phi i32 [ 0, %for.body.thread ], [ %div, %for.body ], [ %div, %land.rhs ]
%inc = add nsw i32 %div5, 1
%cmp = icmp slt i32 %inc, 2
br i1 %cmp, label %for.body, label %for.cond1.thread
for.cond1.thread: ; preds = %for.cond1
br label %for.body.thread
for.body.thread: ; preds = %for.cond1.thread
br label %for.cond1
for.body: ; preds = %for.cond1
%i.02 = phi i32 [ %inc, %for.cond1 ]
%div = sdiv i32 %i.02, 2
%i.0.off = add i32 %i.02, 1
%0 = icmp ugt i32 %i.0.off, 2
br i1 %0, label %land.rhs, label %for.cond1
2nd:
for.cond1: ; preds = %for.body.thread, %for.body, %land.rhs
%div5 = phi i32 [ %div, %for.body ], [ %div, %land.rhs ], [ 0, %for.body.thread ]
%inc = add nsw i32 %div5, 1
%cmp = icmp slt i32 %inc, 2
br i1 %cmp, label %for.body, label %for.cond1.thread6
for.cond1.thread6: ; preds = %for.cond1
br label %for.body.thread
for.body.thread: ; preds = %for.cond1.thread6
br label %for.cond1
for.body: ; preds = %for.cond1
%i.02 = phi i32 [ %inc, %for.cond1 ]
%div = sdiv i32 %i.02, 2
%i.0.off = add i32 %i.02, 1
%0 = icmp ugt i32 %i.0.off, 2
br i1 %0, label %land.rhs, label %for.cond1
and 3rd:
for.cond1: ; preds = %for.body.thread, %for.body, %land.rhs
%div5 = phi i32 [ %div, %for.body ], [ %div, %land.rhs ], [ 0, %for.body.thread ]
%inc = add nsw i32 %div5, 1
%cmp = icmp slt i32 %inc, 2
br i1 %cmp, label %for.body, label %for.cond1.thread
for.cond1.thread: ; preds = %for.cond1
br label %for.body.thread
for.body.thread: ; preds = %for.cond1.thread
br label %for.cond1
for.body: ; preds = %for.cond1
%i.02 = phi i32 [ %inc, %for.cond1 ]
%div = sdiv i32 %i.02, 2
%i.0.off = add i32 %i.02, 1
%0 = icmp ugt i32 %i.0.off, 2
br i1 %0, label %land.rhs, label %for.cond1
I will update test cases as you suggested. Actually I am not sure about test as
it hangs with trunk and check-all never completes.
http://reviews.llvm.org/D3991
More information about the llvm-commits
mailing list