-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
| Bugzilla Link | 24743 |
| Version | trunk |
| OS | All |
| CC | @majnemer,@hfinkel |
Extended Description
As mentioned in:
https://llvm.org/bugs/show_bug.cgi?id=23827#c7
SimplifyCFG (eg, FoldBranchToCommonDest()) transforms code based on a static "BonusInstThreshold". This can waste time because this change in the CFG may later be undone in CodeGenPrepare::splitBranchCondition() or SelectionDAGBuilder::visitBr().
Without external information (target hook, profile data, or programmer hint) to justify the transform, SimplifyCFG shouldn't be doing this:
$ cat predictable_branches.ll
define void @x_or_y(i32 %x, i32 %y) #0 {
entry:
%cmp = icmp slt i32 %x, 3
br i1 %cmp, label %if.then, label %lhs.false
lhs.false:
%cmp1 = icmp sgt i32 %y, 10
br i1 %cmp1, label %if.then, label %end
if.then:
%call = call i32 (...) @foo() #2
br label %end
end:
ret void
}
declare i32 @foo(...) #1
$ ./opt -simplifycfg predictable_branches.ll -S
define void @x_or_y(i32 %x, i32 %y) {
entry:
%cmp = icmp slt i32 %x, 3
%cmp1 = icmp sgt i32 %y, 10
%or.cond = or i1 %cmp, %cmp1
br i1 %or.cond, label %if.then, label %end
if.then:
%call = call i32 (...) @foo()
br label %end
end:
ret void
}