After r311849 Loop Vectorizer generates broken code
| Bugzilla Link | 34743 |
| Resolution | FIXED |
| Resolved on | Dec 16, 2017 05:53 |
| Version | trunk |
| OS | Linux |
| Attachments | Reproducer |
| CC | @hfinkel,@RKSimon,@rengolin |
| Fixed by commit(s) | 314986 |
Extended Description
After r311849 Loop Vectorizer generates a broken code. The reproducer is attached.
to reproduce the issue I ran: $ opt -mcpu=broadwell -loop-vectorize test.ll -S Instruction does not dominate all uses! %59 = sext i32 %scalar.recur to i64 %broadcast.splatinsert = insertelement <4 x i64> undef, i64 %59, i32 0 LLVM ERROR: Broken function found, compilation aborted!
Could you please fix this as soon as possible or disable the functionality causing a regression.
Fixed by rL314986
Thanks Ayal,
Did you submit both to review, with test cases? Can you copy the review link to both bugs?
Cheers, Renato
Sure, https://reviews.llvm.org/D38338 (for this bug) https://reviews.llvm.org/D38339 (for llvm/llvm-project#34059 )
Thanks Ayal,
Did you submit both to review, with test cases? Can you copy the review link to both bugs?
Cheers, Renato
It would be good to have both reported bugs looked at and make sure they're not the same bug before committing the first fix.
Both this and llvm/llvm-project#34059 indeed involve sinking of casts, but each refers to a distinct bug, which can be fixed with an independent patch and testcase, as uploaded for review.
It would be good to have both reported bugs looked at and make sure they're not the same bug before committing the first fix.
Ayal, thank you for the quick fix.
Please, submit a patch with tests to phab.
Created attachment 19204 [details] Tentative fix
A load that participates in an interleaved group is effectively ignored when vectorizing, if it is not the first load of the group. Make sure to move a cast that needs to sink after such an ignored load.
The proposed patch fixes the breakage of the loop vectorizer for the reproducer. Does it also fix the execution of the original problem?
The tentative fix fixes the execution of the original problem. Can you please land this?
Tentative fix A load that participates in an interleaved group is effectively ignored when vectorizing, if it is not the first load of the group. Make sure to move a cast that needs to sink after such an ignored load.
The proposed patch fixes the breakage of the loop vectorizer for the reproducer. Does it also fix the execution of the original problem?
If I understand correctly the problem that Sinking %15 = sext i32 %7 to i64 after %32 = load i32, i32 addrspace(1)* %31, align 4 to vectorize a 1st order recurrence.
%15 sunk and did not go to vectorization plan, later when we try to widen operands of %37 = add i64 %8, %15 we need a vector for %15 but for %15 there is no vector and no scalar. So we create a broadcast and use this %15 for that purpose. However it is not in vectorizable loop. So it causes the issue.
But I do not know what is the right solution for a while.
assigned to @ayalz