-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
| Bugzilla Link | 24670 |
| Version | trunk |
| OS | All |
| CC | @atrick,@hfinkel,@preames |
Extended Description
Currently LLVM does not optimize %c0 to i1 true in the following example:
declare void @use()
define void @f(i32 %len) {
entry:
%e = icmp slt i32 0, %len
br i1 %e, label %loop, label %leave
loop:
%idx = phi i64 [ 0, %entry ], [ %idx.inc, %be ]
%idx.inc = add i64 %idx, 1
%idx.tr = trunc i64 %idx to i32
call void @use()
%c0 = icmp slt i32 %idx.tr, %len
br i1 %c0, label %be, label %leave
be:
%idx.inc.tr = trunc i64 %idx.inc to i32
call void @use()
%c1 = icmp slt i32 %idx.inc.tr, %len
br i1 %c1, label %loop, label %leave
leave:
ret void
}
The interesting bit is that SCEV already has all the smarts required to optimize this check away; and calling simplifyLoopIVs optimizes the check as expected. -indvars does not get this case because it does not look through truncates of induction variables, and thus does not try to eliminate %c0.