Closed as not planned
Description
LLVM commit: 41c6c75
Reproduce with:
opt -passes=loop-reroll bbi-77532.ll -S -o -
In the input the loop is executed 23 rounds
%i.021 = phi i16 [ 4, %entry ], [ %add45, %while.body ]
[...]
%add45 = add nsw i16 %i.021, 4
%sub = sub nsw i16 97, %add45
%cmp = icmp sge i16 %sub, 4
br i1 %cmp, label %while.body, label %while.end
and as seen above each round %add45
is incremented by 4:
%add45 = add nsw i16 %i.021, 4
After the loop %add45
is returned from the function:
%i.0.lcssa = phi i16 [ %add45, %while.body ]
ret i16 %i.0.lcssa
After loop-reroll, the loop executes 92 rounds
%indvar = phi i16 [ %indvar.next, %while.body ], [ 0, %entry ]
[...]
%indvar.next = add i16 %indvar, 1
%exitcond = icmp eq i16 %indvar, 91
br i1 %exitcond, label %while.end, label %while.body
but %add45
is still incremented by 4 each round
%add45 = add nsw i16 %i.021, 4
and it's still returned after the loop
%i.0.lcssa = phi i16 [ %add45, %while.body ]
ret i16 %i.0.lcssa
So the return value from the function is changed by the loop-reroll pass.
bbi-77532.ll.gz