-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LV] Check all users of partial reductions in chain have same scale. #162822
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
Open
fhahn
wants to merge
1
commit into
llvm:main
Choose a base branch
from
fhahn:lv-scaled-fix-crash
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
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
112 changes: 112 additions & 0 deletions
112
llvm/test/Transforms/LoopVectorize/AArch64/partial-reduce-incomplete-chains.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,112 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals none --filter-out-after "^scalar.ph:" --version 4 | ||
; RUN: opt --mattr=+neon,+dotprod -passes=loop-vectorize -force-vector-interleave=1 -enable-epilogue-vectorization=false -S < %s | FileCheck %s --check-prefixes=CHECK-NEON | ||
|
||
target triple = "arm64-apple-macosx" | ||
|
||
define i32 @red_extended_add_incomplete_chain(ptr %start, ptr %end, i32 %offset) { | ||
; CHECK-NEON-LABEL: define i32 @red_extended_add_incomplete_chain( | ||
; CHECK-NEON-SAME: ptr [[START:%.*]], ptr [[END:%.*]], i32 [[OFFSET:%.*]]) #[[ATTR1:[0-9]+]] { | ||
; CHECK-NEON-NEXT: entry: | ||
; CHECK-NEON-NEXT: [[START2:%.*]] = ptrtoint ptr [[START]] to i64 | ||
; CHECK-NEON-NEXT: [[END1:%.*]] = ptrtoint ptr [[END]] to i64 | ||
; CHECK-NEON-NEXT: [[TMP0:%.*]] = add i64 [[END1]], 1 | ||
; CHECK-NEON-NEXT: [[TMP1:%.*]] = sub i64 [[TMP0]], [[START2]] | ||
; CHECK-NEON-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP1]], 16 | ||
; CHECK-NEON-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] | ||
; CHECK-NEON: vector.ph: | ||
; CHECK-NEON-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP1]], 16 | ||
; CHECK-NEON-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP1]], [[N_MOD_VF]] | ||
; CHECK-NEON-NEXT: [[TMP2:%.*]] = getelementptr i8, ptr [[START]], i64 [[N_VEC]] | ||
; CHECK-NEON-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <16 x i32> poison, i32 [[OFFSET]], i64 0 | ||
; CHECK-NEON-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <16 x i32> [[BROADCAST_SPLATINSERT]], <16 x i32> poison, <16 x i32> zeroinitializer | ||
; CHECK-NEON-NEXT: br label [[VECTOR_BODY:%.*]] | ||
; CHECK-NEON: vector.body: | ||
; CHECK-NEON-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] | ||
; CHECK-NEON-NEXT: [[VEC_PHI:%.*]] = phi <16 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP4:%.*]], [[VECTOR_BODY]] ] | ||
; CHECK-NEON-NEXT: [[NEXT_GEP:%.*]] = getelementptr i8, ptr [[START]], i64 [[INDEX]] | ||
; CHECK-NEON-NEXT: [[WIDE_LOAD:%.*]] = load <16 x i8>, ptr [[NEXT_GEP]], align 1 | ||
; CHECK-NEON-NEXT: [[TMP3:%.*]] = zext <16 x i8> [[WIDE_LOAD]] to <16 x i32> | ||
; CHECK-NEON-NEXT: [[PARTIAL_REDUCE:%.*]] = add <16 x i32> [[VEC_PHI]], [[TMP3]] | ||
; CHECK-NEON-NEXT: [[TMP4]] = add <16 x i32> [[PARTIAL_REDUCE]], [[BROADCAST_SPLAT]] | ||
; CHECK-NEON-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16 | ||
; CHECK-NEON-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]] | ||
; CHECK-NEON-NEXT: br i1 [[TMP5]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP22:![0-9]+]] | ||
; CHECK-NEON: middle.block: | ||
; CHECK-NEON-NEXT: [[TMP6:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[TMP4]]) | ||
; CHECK-NEON-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP1]], [[N_VEC]] | ||
; CHECK-NEON-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]] | ||
; CHECK-NEON: scalar.ph: | ||
; | ||
entry: | ||
br label %loop | ||
|
||
loop: | ||
%ptr.iv = phi ptr [ %start, %entry ], [ %gep.iv.next, %loop ] | ||
%red = phi i32 [ 0, %entry ], [ %red.next, %loop ] | ||
%l = load i8, ptr %ptr.iv, align 1 | ||
%l.ext = zext i8 %l to i32 | ||
%add = add i32 %red, %l.ext | ||
%red.next = add i32 %add, %offset | ||
%gep.iv.next = getelementptr i8, ptr %ptr.iv, i64 1 | ||
%ec = icmp eq ptr %ptr.iv, %end | ||
br i1 %ec, label %exit, label %loop | ||
|
||
exit: | ||
ret i32 %red.next | ||
} | ||
|
||
|
||
define i16 @test_incomplete_chain_without_mul(ptr noalias %dst, ptr %A, ptr %B) #0 { | ||
; CHECK-NEON-LABEL: define i16 @test_incomplete_chain_without_mul( | ||
; CHECK-NEON-SAME: ptr noalias [[DST:%.*]], ptr [[A:%.*]], ptr [[B:%.*]]) #[[ATTR0:[0-9]+]] { | ||
; CHECK-NEON-NEXT: entry: | ||
; CHECK-NEON-NEXT: br label [[VECTOR_MEMCHECK:%.*]] | ||
; CHECK-NEON: vector.ph: | ||
; CHECK-NEON-NEXT: br label [[VECTOR_BODY:%.*]] | ||
; CHECK-NEON: vector.body: | ||
; CHECK-NEON-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_MEMCHECK]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] | ||
; CHECK-NEON-NEXT: [[VEC_PHI:%.*]] = phi <16 x i16> [ zeroinitializer, [[VECTOR_MEMCHECK]] ], [ [[TMP7:%.*]], [[VECTOR_BODY]] ] | ||
; CHECK-NEON-NEXT: [[TMP0:%.*]] = load i8, ptr [[A]], align 1 | ||
; CHECK-NEON-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <16 x i8> poison, i8 [[TMP0]], i64 0 | ||
; CHECK-NEON-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <16 x i8> [[BROADCAST_SPLATINSERT]], <16 x i8> poison, <16 x i32> zeroinitializer | ||
; CHECK-NEON-NEXT: [[TMP1:%.*]] = zext <16 x i8> [[BROADCAST_SPLAT]] to <16 x i16> | ||
; CHECK-NEON-NEXT: [[TMP2:%.*]] = extractelement <16 x i16> [[TMP1]], i32 15 | ||
; CHECK-NEON-NEXT: store i16 [[TMP2]], ptr [[DST]], align 2 | ||
; CHECK-NEON-NEXT: [[TMP3:%.*]] = load i8, ptr [[B]], align 1 | ||
; CHECK-NEON-NEXT: [[BROADCAST_SPLATINSERT6:%.*]] = insertelement <16 x i8> poison, i8 [[TMP3]], i64 0 | ||
; CHECK-NEON-NEXT: [[BROADCAST_SPLAT7:%.*]] = shufflevector <16 x i8> [[BROADCAST_SPLATINSERT6]], <16 x i8> poison, <16 x i32> zeroinitializer | ||
; CHECK-NEON-NEXT: [[TMP4:%.*]] = zext <16 x i8> [[BROADCAST_SPLAT7]] to <16 x i16> | ||
; CHECK-NEON-NEXT: [[TMP5:%.*]] = add <16 x i16> [[VEC_PHI]], [[TMP4]] | ||
; CHECK-NEON-NEXT: [[TMP6:%.*]] = add <16 x i16> [[TMP5]], [[TMP1]] | ||
; CHECK-NEON-NEXT: [[TMP7]] = add <16 x i16> [[TMP6]], [[TMP4]] | ||
; CHECK-NEON-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16 | ||
; CHECK-NEON-NEXT: [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 | ||
; CHECK-NEON-NEXT: br i1 [[TMP8]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] | ||
; CHECK-NEON: middle.block: | ||
; CHECK-NEON-NEXT: [[TMP9:%.*]] = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> [[TMP7]]) | ||
; CHECK-NEON-NEXT: br label [[SCALAR_PH:%.*]] | ||
; CHECK-NEON: scalar.ph: | ||
; | ||
entry: | ||
br label %loop | ||
|
||
loop: | ||
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ] | ||
%red = phi i16 [ 0, %entry ], [ %red.next, %loop ] | ||
%l.a = load i8, ptr %A, align 1 | ||
%a.ext = zext i8 %l.a to i16 | ||
store i16 %a.ext, ptr %dst, align 2 | ||
%l.b = load i8, ptr %B, align 1 | ||
%b.ext = zext i8 %l.b to i16 | ||
%add = add i16 %red, %b.ext | ||
%add.1 = add i16 %add, %a.ext | ||
%red.next = add i16 %add.1, %b.ext | ||
%iv.next = add i64 %iv, 1 | ||
%ec = icmp ult i64 %iv, 1024 | ||
br i1 %ec, label %loop, label %exit | ||
|
||
exit: | ||
ret i16 %red.next | ||
} | ||
|
||
attributes #0 = { "target-cpu"="grace" } |
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.