-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LV] Avoid scalable vectorization for loops containing alloca
This patch returns an Invalid cost from getInstructionCost() for alloca instructions if the VF is scalable, as otherwise loops which contain these instructions will crash when attempting to scalarize the alloca. Reviewed By: sdesmalen Differential Revision: https://reviews.llvm.org/D105824
- Loading branch information
1 parent
99eb96f
commit 49d7313
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
31 changes: 31 additions & 0 deletions
31
llvm/test/Transforms/LoopVectorize/AArch64/scalable-alloca.ll
This file contains 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,31 @@ | ||
; RUN: opt -S -loop-vectorize -mattr=+sve -mtriple aarch64-unknown-linux-gnu -force-vector-width=2 -scalable-vectorization=preferred -pass-remarks-analysis=loop-vectorize -pass-remarks-missed=loop-vectorize < %s 2>%t | FileCheck %s | ||
; RUN: FileCheck %s --check-prefix=CHECK-REMARKS < %t | ||
|
||
; CHECK-REMARKS: UserVF ignored because of invalid costs. | ||
; CHECK-REMARKS: Instruction with invalid costs prevented vectorization at VF=(vscale x 1, vscale x 2): alloca | ||
; CHECK-REMARKS: Instruction with invalid costs prevented vectorization at VF=(vscale x 1): store | ||
define void @alloca(i32** %vla, i64 %N) { | ||
; CHECK-LABEL: @alloca( | ||
; CHECK-NOT: <vscale x | ||
|
||
entry: | ||
br label %for.body | ||
|
||
for.body: | ||
%iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ] | ||
%alloca = alloca i32, align 16 | ||
%arrayidx = getelementptr inbounds i32*, i32** %vla, i64 %iv | ||
store i32* %alloca, i32** %arrayidx, align 8 | ||
%iv.next = add nuw nsw i64 %iv, 1 | ||
%exitcond.not = icmp eq i64 %iv.next, %N | ||
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !0 | ||
|
||
for.end: | ||
call void @foo(i32** nonnull %vla) | ||
ret void | ||
} | ||
|
||
declare void @foo(i32**) | ||
|
||
!0 = !{!0, !1} | ||
!1 = !{!"llvm.loop.vectorize.scalable.enable", i1 true} |