This is an archive of the discontinued LLVM Phabricator instance.

[SLP]Fix non-determinism in PHI sorting.
ClosedPublic

Authored by ABataev on Jun 28 2021, 7:30 AM.

Details

Summary

Compare type IDs and DFS numbering for basic block instead of addresses
to fix non-determinism.

Diff Detail

Event Timeline

ABataev created this revision.Jun 28 2021, 7:30 AM
ABataev requested review of this revision.Jun 28 2021, 7:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2021, 7:31 AM
RKSimon added inline comments.Jul 5 2021, 9:19 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
8372

Avoid auto

llvm/test/Transforms/SLPVectorizer/X86/remark_unsupported.ll
5

update this comment? SLP isn't vectorizing x86_fp80 but why are you having to change the test?

ABataev updated this revision to Diff 356694.Jul 6 2021, 5:53 AM

Address comments + fix a bug

ABataev added inline comments.Jul 6 2021, 5:56 AM
llvm/test/Transforms/SLPVectorizer/X86/remark_unsupported.ll
5

Previously root PHI nodes with x86_fp80 type were rejected during graph building, here we started to reject them earlier to avoid some extra work. This leads to the fact that the expected message won't be emitted for this test anymore, so have to rework the test to emit the message again, because we still may see it during graph building, if some instructions return x86_fp80 type

RKSimon accepted this revision.Jul 6 2021, 8:17 AM

LGTM - cheers

This revision is now accepted and ready to land.Jul 6 2021, 8:17 AM
This revision was automatically updated to reflect the committed changes.
skatkov added inline comments.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
8371

Please note that we met triggering this assert. The reduced by bugpoint reproducer looks as follows:

define void @bar() {
bb:
  %tmp = load atomic i8*, i8** undef unordered, align 8
  br label %bb6

bb5:                                              ; No predecessors!
  %tmp4 = load atomic i8*, i8** undef unordered, align 8
  br label %bb6

bb6:                                              ; preds = %bb5, %bb
  %tmp7 = phi i8* [ %tmp, %bb5 ], [ undef, %bb ]
  %tmp8 = phi i8* [ %tmp4, %bb5 ], [ undef, %bb ]
  ret void
}

It looks like we can reach this code with unreachable instruction and it is not guarded in optimization.

Could you please fix it or revert the patch.

ABataev added inline comments.Jul 19 2021, 3:03 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
8371

Will fix it ASAP.

skatkov added inline comments.Jul 19 2021, 3:09 AM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
8371

Thanks in advance.