Issue |
148603
|
Summary |
Vectorize loops with exit users with EVL tail folding
|
Labels |
vectorizers
|
Assignees |
|
Reporter |
lukel97
|
https://godbolt.org/z/c7daf875K
If a loop has users in the exit block, we currently can't vectorize it with EVL tail folding and instead fall back to a scalar epilogue:
```llvm
define i32 @f(ptr %p, ptr %q, i32 %n) {
entry:
br label %loop
loop:
%iv = phi i32 [0, %entry], [%iv.next, %loop]
%gep = getelementptr i32, ptr %p, i32 %iv
%x = load i32, ptr %gep
%y = add i32 %x, 1
store i32 %y, ptr %gep
%iv.next = add i32 %iv, 1
%done = icmp eq i32 %iv.next, %n
br i1 %done, label %exit, label %loop
exit:
ret i32 %y
}
```
I don't think it's easy to do this with regular data/mask tail folding, but with EVL I think it should be possible to form a VPInstruction::ExtractLastElement which reads from the last active lane.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs