-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[LoopVectorizer] Propagate underlying instruction to the cloned instances of VPPartialReductionRecipes #123638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NickGuy-Arm
merged 3 commits into
llvm:main
from
NickGuy-Arm:partial-reduce-recipe-fixup
Jan 23, 2025
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
llvm/test/Transforms/LoopVectorize/AArch64/vplan-epilogue-printing.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| ; REQUIRES: asserts | ||
| ; RUN: opt -mattr=+neon,+dotprod -passes=loop-vectorize -debug-only=loop-vectorize -force-vector-interleave=1 -enable-epilogue-vectorization -epilogue-vectorization-force-VF=2 -disable-output %s 2>&1 | FileCheck %s | ||
|
|
||
| target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
| target triple = "aarch64-none-unknown-elf" | ||
|
|
||
| ; Tests for printing VPlans that are enabled under AArch64 | ||
| ; CHECK: VPlan 'Final VPlan for VF={8,16},UF={1}' { | ||
| ; CHECK-NEXT: Live-in ir<16> = VF * UF | ||
| ; CHECK-NEXT: Live-in ir<1024> = vector-trip-count | ||
| ; CHECK-NEXT: Live-in ir<1024> = original trip-count | ||
| ; CHECK-EMPTY: | ||
| ; CHECK-NEXT: ir-bb<entry>: | ||
| ; CHECK-NEXT: Successor(s): ir-bb<scalar.ph>, ir-bb<vector.main.loop.iter.check> | ||
| ; CHECK-EMPTY: | ||
| ; CHECK-NEXT: ir-bb<vector.main.loop.iter.check>: | ||
| ; CHECK-NEXT: Successor(s): ir-bb<scalar.ph>, ir-bb<vector.ph> | ||
| ; CHECK-EMPTY: | ||
| ; CHECK-NEXT: ir-bb<vector.ph>: | ||
| ; CHECK-NEXT: Successor(s): vector loop | ||
| ; CHECK-EMPTY: | ||
| ; CHECK-NEXT: <x1> vector loop: { | ||
| ; CHECK-NEXT: vector.body: | ||
| ; CHECK-NEXT: SCALAR-PHI vp<%0> = phi ir<0>, vp<%index.next> | ||
|
||
| ; CHECK-NEXT: WIDEN-REDUCTION-PHI ir<%accum> = phi ir<0>, ir<%add> (VF scaled by 1/4) | ||
| ; CHECK-NEXT: vp<%1> = SCALAR-STEPS vp<%0>, ir<1> | ||
| ; CHECK-NEXT: CLONE ir<%gep.a> = getelementptr ir<%a>, vp<%1> | ||
| ; CHECK-NEXT: vp<%2> = vector-pointer ir<%gep.a> | ||
| ; CHECK-NEXT: WIDEN ir<%load.a> = load vp<%2> | ||
| ; CHECK-NEXT: WIDEN-CAST ir<%ext.a> = zext ir<%load.a> to i32 | ||
| ; CHECK-NEXT: CLONE ir<%gep.b> = getelementptr ir<%b>, vp<%1> | ||
| ; CHECK-NEXT: vp<%3> = vector-pointer ir<%gep.b> | ||
| ; CHECK-NEXT: WIDEN ir<%load.b> = load vp<%3> | ||
| ; CHECK-NEXT: WIDEN-CAST ir<%ext.b> = zext ir<%load.b> to i32 | ||
| ; CHECK-NEXT: WIDEN ir<%mul> = mul ir<%ext.b>, ir<%ext.a> | ||
| ; CHECK-NEXT: PARTIAL-REDUCE ir<%add> = add ir<%mul>, ir<%accum> | ||
| ; CHECK-NEXT: EMIT vp<%index.next> = add nuw vp<%0>, ir<16> | ||
| ; CHECK-NEXT: EMIT branch-on-count vp<%index.next>, ir<1024> | ||
| ; CHECK-NEXT: No successors | ||
| ; CHECK-NEXT: } | ||
| ; CHECK-NEXT: Successor(s): ir-bb<middle.block> | ||
| ; CHECK-EMPTY: | ||
| ; CHECK-NEXT: ir-bb<middle.block>: | ||
| ; CHECK-NEXT: EMIT vp<%5> = compute-reduction-result ir<%accum>, ir<%add> | ||
| ; CHECK-NEXT: EMIT vp<%6> = extract-from-end vp<%5>, ir<1> | ||
| ; CHECK-NEXT: EMIT vp<%cmp.n> = icmp eq ir<1024>, ir<1024> | ||
| ; CHECK-NEXT: EMIT branch-on-cond vp<%cmp.n> | ||
| ; CHECK-NEXT: Successor(s): ir-bb<exit>, ir-bb<scalar.ph> | ||
| ; CHECK-EMPTY: | ||
| ; CHECK-NEXT: ir-bb<exit>: | ||
| ; CHECK-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<%6> from ir-bb<middle.block>) | ||
| ; CHECK-NEXT: No successors | ||
| ; CHECK-EMPTY: | ||
| ; CHECK-NEXT: ir-bb<scalar.ph>: | ||
| ; CHECK-NEXT: EMIT vp<%vec.epilog.resume.val> = resume-phi ir<1024>, ir<0> | ||
| ; CHECK-NEXT: EMIT vp<%bc.merge.rdx> = resume-phi vp<%5>, ir<0> | ||
| ; CHECK-NEXT: Successor(s): ir-bb<for.body> | ||
| ; CHECK-EMPTY: | ||
| ; CHECK-NEXT: ir-bb<for.body>: | ||
| ; CHECK-NEXT: IR %accum = phi i32 [ 0, %scalar.ph ], [ %add, %for.body ] (extra operand: vp<%bc.merge.rdx> from ir-bb<scalar.ph>) | ||
| ; CHECK-NEXT: IR %gep.a = getelementptr i8, ptr %a, i64 %iv | ||
| ; CHECK-NEXT: IR %load.a = load i8, ptr %gep.a, align 1 | ||
| ; CHECK-NEXT: IR %ext.a = zext i8 %load.a to i32 | ||
| ; CHECK-NEXT: IR %gep.b = getelementptr i8, ptr %b, i64 %iv | ||
| ; CHECK-NEXT: IR %load.b = load i8, ptr %gep.b, align 1 | ||
| ; CHECK-NEXT: IR %ext.b = zext i8 %load.b to i32 | ||
| ; CHECK-NEXT: IR %mul = mul i32 %ext.b, %ext.a | ||
| ; CHECK-NEXT: IR %add = add i32 %mul, %accum | ||
| ; CHECK-NEXT: IR %iv.next = add i64 %iv, 1 | ||
| ; CHECK-NEXT: IR %exitcond.not = icmp eq i64 %iv.next, 1024 | ||
| ; CHECK-NEXT: No successors | ||
| ; CHECK-NEXT: } | ||
| define i32 @print_partial_reduction(ptr %a, ptr %b) { | ||
| entry: | ||
| br label %for.body | ||
|
|
||
| for.body: ; preds = %for.body, %entry | ||
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] | ||
| %accum = phi i32 [ 0, %entry ], [ %add, %for.body ] | ||
| %gep.a = getelementptr i8, ptr %a, i64 %iv | ||
| %load.a = load i8, ptr %gep.a, align 1 | ||
| %ext.a = zext i8 %load.a to i32 | ||
| %gep.b = getelementptr i8, ptr %b, i64 %iv | ||
| %load.b = load i8, ptr %gep.b, align 1 | ||
| %ext.b = zext i8 %load.b to i32 | ||
| %mul = mul i32 %ext.b, %ext.a | ||
| %add = add i32 %mul, %accum | ||
| %iv.next = add i64 %iv, 1 | ||
| %exitcond.not = icmp eq i64 %iv.next, 1024 | ||
| br i1 %exitcond.not, label %exit, label %for.body | ||
|
|
||
| exit: | ||
| ret i32 %add | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test. Do we need a separate test file or could we just enable epilogue vectorization in the existing
llvm/test/Transforms/LoopVectorize/AArch64/vplan-printing.ll?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I was a bit skeptical at first about merging them, but they went together with no issues.