llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

After r311849 Loop Vectorizer generates broken code

Open serguei-katkov opened this issue 9 years ago • 11 comments

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.

serguei-katkov avatar Sep 27 '17 08:09 serguei-katkov

Fixed by rL314986

RKSimon avatar Dec 16 '17 13:12 RKSimon

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 )

ayalz avatar Oct 01 '17 14:10 ayalz

Thanks Ayal,

Did you submit both to review, with test cases? Can you copy the review link to both bugs?

Cheers, Renato

rengolin avatar Oct 01 '17 13:10 rengolin

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.

ayalz avatar Oct 01 '17 07:10 ayalz

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.

rengolin avatar Sep 28 '17 06:09 rengolin

Ayal, thank you for the quick fix.

serguei-katkov avatar Sep 28 '17 03:09 serguei-katkov

Please, submit a patch with tests to phab.

rengolin avatar Sep 27 '17 19:09 rengolin

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?

llvmbot avatar Sep 27 '17 18:09 llvmbot

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?

ayalz avatar Sep 27 '17 12:09 ayalz

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.

serguei-katkov avatar Sep 27 '17 10:09 serguei-katkov

assigned to @ayalz

serguei-katkov avatar Sep 27 '17 08:09 serguei-katkov