Skip to content

Commit 8e6e7ee

Browse files
committed
[AArch64] Dont inline streaming Fn if caller has no SVE
Without this change, the following test would fail to compile with `-march=armv8-a+sme`: void func1(const svuint32_t *in, svuint32_t *out) { [&]() __arm_streaming { *out = *in; }(); }
1 parent 482acab commit 8e6e7ee

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,22 @@ bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
280280
if (CallAttrs.callee().isNewZA() || CallAttrs.callee().isNewZT0())
281281
return false;
282282

283+
const TargetMachine &TM = getTLI()->getTargetMachine();
284+
const FeatureBitset &CallerBits =
285+
TM.getSubtargetImpl(*Caller)->getFeatureBits();
286+
287+
// Cannot inline a streaming function into a non-streaming function,
288+
// if the caller has no SVE.
289+
if (CallAttrs.requiresSMChange() && !CallerBits.test(AArch64::FeatureSVE))
290+
return false;
291+
283292
if (CallAttrs.requiresLazySave() || CallAttrs.requiresSMChange() ||
284293
CallAttrs.requiresPreservingZT0() ||
285294
CallAttrs.requiresPreservingAllZAState()) {
286295
if (hasPossibleIncompatibleOps(Callee))
287296
return false;
288297
}
289298

290-
const TargetMachine &TM = getTLI()->getTargetMachine();
291-
const FeatureBitset &CallerBits =
292-
TM.getSubtargetImpl(*Caller)->getFeatureBits();
293299
const FeatureBitset &CalleeBits =
294300
TM.getSubtargetImpl(*Callee)->getFeatureBits();
295301
// Adjust the feature bitsets by inverting some of the bits. This is needed

llvm/test/Transforms/Inline/AArch64/sme-pstatesm-attrs.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ define void @nosve_streaming_function(ptr %ptr) "target-features"="+sme" "aarch6
691691
define void @nosve_non_streaming_caller_streaming_callee_dont_inline(ptr %ptr) "target-features"="+sme" {
692692
; CHECK-LABEL: define void @nosve_non_streaming_caller_streaming_callee_dont_inline
693693
; CHECK-SAME: (ptr [[PTR:%.*]]) #[[ATTR1]] {
694-
; CHECK-NEXT: store <vscale x 4 x i32> zeroinitializer, ptr [[PTR]], align 16
694+
; CHECK-NEXT: call void @nosve_streaming_function(ptr [[PTR]])
695695
; CHECK-NEXT: ret void
696696
;
697697
call void @nosve_streaming_function(ptr %ptr)

0 commit comments

Comments
 (0)