Skip to content

Commit 43a9ec2

Browse files
authored
[AArch64][SME] Instcombine llvm.aarch64.sme.in.streaming.mode() (#147930)
This can fold away in functions with known streaming modes.
1 parent cc65da0 commit 43a9ec2

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,6 +2723,16 @@ static std::optional<Instruction *> instCombineSVEUxt(InstCombiner &IC,
27232723
return std::nullopt;
27242724
}
27252725

2726+
static std::optional<Instruction *>
2727+
instCombineInStreamingMode(InstCombiner &IC, IntrinsicInst &II) {
2728+
SMEAttrs FnSMEAttrs(*II.getFunction());
2729+
bool IsStreaming = FnSMEAttrs.hasStreamingInterfaceOrBody();
2730+
if (IsStreaming || !FnSMEAttrs.hasStreamingCompatibleInterface())
2731+
return IC.replaceInstUsesWith(
2732+
II, ConstantInt::getBool(II.getType(), IsStreaming));
2733+
return std::nullopt;
2734+
}
2735+
27262736
std::optional<Instruction *>
27272737
AArch64TTIImpl::instCombineIntrinsic(InstCombiner &IC,
27282738
IntrinsicInst &II) const {
@@ -2828,6 +2838,8 @@ AArch64TTIImpl::instCombineIntrinsic(InstCombiner &IC,
28282838
return instCombineSVEUxt(IC, II, 16);
28292839
case Intrinsic::aarch64_sve_uxtw:
28302840
return instCombineSVEUxt(IC, II, 32);
2841+
case Intrinsic::aarch64_sme_in_streaming_mode:
2842+
return instCombineInStreamingMode(IC, II);
28312843
}
28322844

28332845
return std::nullopt;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -passes=instcombine -mtriple aarch64 -mattr=+sme -S -o - < %s | FileCheck %s
3+
4+
define i1 @test_in_streaming_mode_streaming_compatible() "aarch64_pstate_sm_compatible" {
5+
; CHECK-LABEL: define i1 @test_in_streaming_mode_streaming_compatible(
6+
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
7+
; CHECK-NEXT: [[SM:%.*]] = tail call i1 @llvm.aarch64.sme.in.streaming.mode()
8+
; CHECK-NEXT: ret i1 [[SM]]
9+
;
10+
%sm = tail call i1 @llvm.aarch64.sme.in.streaming.mode()
11+
ret i1 %sm
12+
}
13+
14+
define i1 @test_in_streaming_mode_streaming() "aarch64_pstate_sm_enabled" {
15+
; CHECK-LABEL: define i1 @test_in_streaming_mode_streaming(
16+
; CHECK-SAME: ) #[[ATTR1:[0-9]+]] {
17+
; CHECK-NEXT: ret i1 true
18+
;
19+
%sm = tail call i1 @llvm.aarch64.sme.in.streaming.mode()
20+
ret i1 %sm
21+
}
22+
23+
define i1 @test_in_streaming_mode_streaming_compatible_streaming_body() "aarch64_pstate_sm_compatible" "aarch64_pstate_sm_body" {
24+
; CHECK-LABEL: define i1 @test_in_streaming_mode_streaming_compatible_streaming_body(
25+
; CHECK-SAME: ) #[[ATTR2:[0-9]+]] {
26+
; CHECK-NEXT: ret i1 true
27+
;
28+
%sm = tail call i1 @llvm.aarch64.sme.in.streaming.mode()
29+
ret i1 %sm
30+
}
31+
32+
define i1 @test_in_streaming_mode_streaming_body() "aarch64_pstate_sm_body" {
33+
; CHECK-LABEL: define i1 @test_in_streaming_mode_streaming_body(
34+
; CHECK-SAME: ) #[[ATTR3:[0-9]+]] {
35+
; CHECK-NEXT: ret i1 true
36+
;
37+
%sm = tail call i1 @llvm.aarch64.sme.in.streaming.mode()
38+
ret i1 %sm
39+
}
40+
41+
define i1 @test_in_streaming_mode_non_streaming() {
42+
; CHECK-LABEL: define i1 @test_in_streaming_mode_non_streaming(
43+
; CHECK-SAME: ) #[[ATTR4:[0-9]+]] {
44+
; CHECK-NEXT: ret i1 false
45+
;
46+
%sm = tail call i1 @llvm.aarch64.sme.in.streaming.mode()
47+
ret i1 %sm
48+
}

0 commit comments

Comments
 (0)