[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)

Sam Tebbs via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 10:07:01 PST 2024


SamTebbs33 wrote:

OK, I've pushed up the change to mark partial reductions as additional simplifications. I'll keep the changes to the test though as it was not intended to produce a partial reduction and it would be good to decouple them.
________________________________
From: Florian Hahn ***@***.***>
Sent: 16 December 2024 17:11
To: llvm/llvm-project ***@***.***>
Cc: Samuel Tebbs ***@***.***>; Mention ***@***.***>
Subject: Re: [llvm/llvm-project] [LoopVectorizer] Add support for partial reductions (PR #92418)


There are a number of users of clang with assertions enabled and if there are cases where the patch will trigger an assertion this should be fixed before landing. Please also see my earlier comments re removing forcing costs from the tests, as they will hide the issue.On 16 Dec 2024, at 17:01, Sam Tebbs ***@***.***> wrote:
Thank you for the approval by the way! I rebased on top of main and noticed that a commit merged the day before added a test (Transforms/LoopVectorize/AArch64/fully-unrolled-cost.ll) that tripped the BestFactor.Width == LegacyVF.Width assertion (only in debug mode, of course), since the partial reduction that it results in is costed very differently to the add instruction that the legacy model costs. I spoke to the author of the commit and we agreed to change the test so that it doesn't produce a partial reduction and stops the assertion being tripped. Since this assertion only exists in debug mode and doesn't have an impact on release mode functionality I think this is OK as a solution. A follow-up could be to mark a partial reduction as an "additional simplification" in planContainsAdditionalSimplifications since it's very unlikely the legacy cost model and vplan-based cost model will ever agree on the costs of such differing instructions (the partial reduction in the VPlan and the underlying add that the legacy model sees).

________________________________

From: Florian Hahn ***@***.***>

Sent: 16 December 2024 16:40

To: llvm/llvm-project ***@***.***>

Cc: Samuel Tebbs ***@***.***>; Mention ***@***.***>

Subject: Re: [llvm/llvm-project] [LoopVectorizer] Add support for partial reductions (PR #92418)





@fhahn commented on this pull request.



________________________________



In llvm/test/Transforms/LoopVectorize/AArch64/fully-unrolled-cost.ll<https://github.com/llvm/llvm-project/pull/92418#discussion_r1887153929>:



> @@ -31,8 +31,8 @@ for.body: ; preds = %entry, %for.body

%arrayidx2 = getelementptr inbounds i8, ptr %b, i64 %i.iv

%1 = load i8, ptr %arrayidx2, align 1

%conv3 = zext i8 %1 to i64

- %mul = mul nuw nsw i64 %conv3, %conv

- %add = add i64 %mul, %sum

+ %div = udiv i64 %conv3, %conv





why are those changes needed?



—

Reply to this email directly, view it on GitHub<https://github.com/llvm/llvm-project/pull/92418#pullrequestreview-2506731978>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAOXB6TFQCDK4VU4RZWR2DD2F37BNAVCNFSM6AAAAABH2QN3M6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKMBWG4ZTCOJXHA>.

You are receiving this because you were mentioned.Message ID: ***@***.***>



IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.



—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>

—
Reply to this email directly, view it on GitHub<https://github.com/llvm/llvm-project/pull/92418#issuecomment-2546185333>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAOXB6TEPBKPNIEZKBOFSNL2F4CTHAVCNFSM6AAAAABH2QN3M6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBWGE4DKMZTGM>.
You are receiving this because you were mentioned.Message ID: ***@***.***>

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


https://github.com/llvm/llvm-project/pull/92418


More information about the llvm-commits mailing list