This is an archive of the discontinued LLVM Phabricator instance.

[LoopVectorize] Add FastMathFlags to the select used for reductions with tail-folding
ClosedPublic

Authored by david-arm on Jun 1 2022, 7:23 AM.

Details

Summary

Based on reviewer comments on https://reviews.llvm.org/D126692 I've
added FastMathFlags to the select instruction used when tail-folding
with reductions. These flags can then be used by InstCombine to
decide upon the most optimal floating point identity value for
fadd/fsub. Doing so unlocks further optimisations, such as folding
selects into masked loads.

Diff Detail

Event Timeline

david-arm created this revision.Jun 1 2022, 7:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 7:23 AM
david-arm requested review of this revision.Jun 1 2022, 7:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 7:23 AM
spatel accepted this revision.Jun 2 2022, 5:34 AM

LGTM - see inline comment for a possible minor improvement.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
3909

Given the variable name, shouldn't this be a 'SelectInst*' rather than a 'Value*'? Then we wouldn't need the cast<> in the new line of code.

This revision is now accepted and ready to land.Jun 2 2022, 5:34 AM
This revision was landed with ongoing or failed builds.Jun 7 2022, 2:21 AM
This revision was automatically updated to reflect the committed changes.