This is an archive of the discontinued LLVM Phabricator instance.

[SLP] Compute min/max scalar reduction costs using min/max intrinsics instead of expanded cmp+sel
ClosedPublic

Authored by RKSimon on Apr 13 2023, 4:39 AM.

Details

Summary

By default these will expand back to cmp/sel, but some targets (X86) has optimized costs for scalar integer min/max patterns which are lower than the default expansion (pre-SSE41 is particularly weak for vector min/max support).

Diff Detail

Event Timeline

RKSimon created this revision.Apr 13 2023, 4:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 4:39 AM
RKSimon requested review of this revision.Apr 13 2023, 4:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 4:39 AM
nikic added a comment.Apr 13 2023, 5:05 AM

I was considering updating all the LoopUtils minmax reduction helpers to work with the intrinsics directly (createMinMaxOp in particular), but I'm concerned that we don't guarantee minnum/maxnum handling on all backends. I could still do this for the integer cases at least?

For integers using the intrinsics definitely makes sense. For FP, that depends on whether non-nnan reductions are supported. If these are always nnan then minnum/maxnum should be fine (at least I think we consider those to be the canonical form).

This revision is now accepted and ready to land.Apr 13 2023, 8:50 AM
RKSimon edited the summary of this revision. (Show Details)Apr 13 2023, 8:51 AM