This is an archive of the discontinued LLVM Phabricator instance.

[SLP][NFC] Remove comparator argument of `tryToVectorizeSequence()`
Needs ReviewPublic

Authored by vporpo on Apr 14 2023, 2:15 PM.

Details

Summary

As far as I can tell there is no good reason why we are defining the comparator
before calling tryToVectorizeSequence() but running sort() inside
tryToVectorizeSequence().
So this patch simplifies the code by moving the call to sort() closer to its
comparator.

Diff Detail

Event Timeline

vporpo created this revision.Apr 14 2023, 2:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2023, 2:15 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
vporpo requested review of this revision.Apr 14 2023, 2:15 PM
ABataev added inline comments.Apr 14 2023, 2:29 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
14144

Would be good to add the assert that the array is properly sorted, but I don't know how to do it without comparator here.

ABataev added inline comments.Apr 14 2023, 2:32 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
14144

The general idea behind passing it as an argument was ensure that the incomming array is properly sorted, so we operate on potentially vectorizable lists instead of trying incompatible ones. So, it just allows do not forget about comparator for the new operations (e.g. math intrinsics calls).

vporpo added inline comments.Apr 14 2023, 2:41 PM
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
14144

Makes sense. I think we can use a common comparator function, let me see if it works.