Skip to content

[AArch64] Do not promote scalable constants to global variables #146926

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/lib/Target/AArch64/AArch64PromoteConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ static bool shouldConvertImpl(const Constant *Cst) {
if (Cst->isZeroValue())
return false;

// Globals cannot be or contain scalable vectors.
if (Cst->getType()->isScalableTy())
return false;

if (Stress)
return true;

Expand Down
20 changes: 20 additions & 0 deletions llvm/test/CodeGen/AArch64/no-promote-scalabale-const-to-global.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; RUN: llc -mtriple=aarch64 -mattr=+sve -stop-after=aarch64-promote-const < %s | FileCheck %s

; Test that the constant inside the `phi` is not promoted to a global
; CHECK-NOT: _PromotedConst
define void @f(i1 %c, ptr %p, ptr %q) {
entry:
br i1 %c, label %if.then, label %if.else

if.then:
%u = load [2 x <vscale x 4 x float> ], ptr %p
br label %exit

if.else:
br label %exit

exit:
%v = phi [2 x <vscale x 4 x float> ] [ %u, %if.then], [[<vscale x 4 x float> zeroinitializer, <vscale x 4 x float> poison], %if.else]
store [2 x <vscale x 4 x float>] %v, ptr %q
ret void
}