This is an archive of the discontinued LLVM Phabricator instance.

[VPlan] Consider scalar VF in masked VPReductionRecipe
Needs ReviewPublic

Authored by iamlouk on Aug 8 2023, 12:46 AM.

Details

Summary

When a VPReductionRecipe has a condition, its execute method first
creates a select where the values for the disabled lanes are replaced
by the identity values for that reduction kind. This patch fixes
a crash in that logic when the VF is scalar, so that there is no
need to create a vector of identity values.

Diff Detail

Event Timeline

iamlouk created this revision.Aug 8 2023, 12:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2023, 12:46 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
iamlouk requested review of this revision.Aug 8 2023, 12:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2023, 12:46 AM
iamlouk retitled this revision from Consider scalar VF in masked VPReductionRecipe to [VPlan] Consider scalar VF in masked VPReductionRecipe.Aug 8 2023, 12:49 AM
iamlouk added reviewers: fhahn, Ayal, ABataev.
iamlouk updated this revision to Diff 548115.Aug 8 2023, 2:11 AM

Fix clang-format issue.

ABataev added inline comments.Aug 8 2023, 6:45 AM
llvm/test/Transforms/LoopVectorize/AArch64/scalar_interleave_masked_reduce.ll
16

You can drop the attributes for %c parameter

39

You can drop this attribute

iamlouk updated this revision to Diff 548216.Aug 8 2023, 7:29 AM

Remove unnecessary attributes in test.

iamlouk marked 2 inline comments as done.
ABataev added inline comments.Aug 8 2023, 10:07 AM
llvm/test/Transforms/LoopVectorize/AArch64/scalar_interleave_masked_reduce.ll
5–6

I also suggest to remove these lines and add -mtriple=aarch64-linux-gnu as an opt parameter

35–36

Also, do you need this or phi can be removed and make function just return void?

fhahn added inline comments.Aug 8 2023, 10:08 AM
llvm/test/Transforms/LoopVectorize/AArch64/scalar_interleave_masked_reduce.ll
19

it's probably worth to check the full IR; the code modifies IR generation so we should check the generated IR

iamlouk updated this revision to Diff 548508.Aug 9 2023, 1:05 AM

Address code review comments: use mtriple and check full IR

iamlouk marked 3 inline comments as done.Aug 9 2023, 1:18 AM
iamlouk added inline comments.
llvm/test/Transforms/LoopVectorize/AArch64/scalar_interleave_masked_reduce.ll
35–36

I simplified the test a tiny bit more by removing the LCSSA phi, I used a return to make the value live-out. If there is another (preferred) way, I'd be happy to change this!

iamlouk marked an inline comment as done.Aug 16 2023, 11:44 PM

Please let me know if there is anything else I can improve.