1 ; RUN: llc < %s | FileCheck %s
3 target triple = "aarch64"
6 define void @dont_rematerialize_cntd(i32 %N) #0 {
7 ; CHECK-LABEL: dont_rematerialize_cntd:
14 %cmp2 = icmp sgt i32 %N, 0
15 br i1 %cmp2, label %for.body, label %for.cond.cleanup
17 for.body: ; preds = %entry, %for.body
18 %index.03 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
19 call void asm sideeffect "", "~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27}"() nounwind
20 %.tr = call i32 @llvm.vscale.i32()
21 %conv = shl nuw nsw i32 %.tr, 4
22 call void @foo(i32 %conv)
23 %inc = add nuw nsw i32 %index.03, 1
24 %exitcond.not = icmp eq i32 %inc, %N
25 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
27 for.cond.cleanup: ; preds = %for.body, %entry
31 ; This test doesn't strictly make sense, because it passes a scalable predicate
32 ; to a function, which makes little sense if the VL is not the same in/out of
33 ; streaming-SVE mode. If the VL is known to be the same, then we could just as
34 ; well rematerialize the `ptrue` inside the call sequence. However, the purpose
35 ; of this test is more to ensure that the logic works, which may also trigger
36 ; when the value is not being passed as argument (e.g. when it is hoisted from
37 ; a loop and placed inside the call sequence).
39 ; FIXME: This test also exposes another bug, where the 'mul vl' addressing mode
40 ; is used before/after the smstop. This will be fixed in a future patch.
41 define void @dont_rematerialize_ptrue(i32 %N) #0 {
42 ; CHECK-LABEL: dont_rematerialize_ptrue:
43 ; CHECK: ptrue [[PTRUE:p[0-9]+]].b
44 ; CHECK: str [[PTRUE]], [[[SPILL_ADDR:.*]]]
46 ; CHECK: ldr p0, [[[SPILL_ADDR]]]
51 %cmp2 = icmp sgt i32 %N, 0
52 br i1 %cmp2, label %for.body, label %for.cond.cleanup
54 for.body: ; preds = %entry, %for.body
55 %index.03 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
56 call void asm sideeffect "", "~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27}"() nounwind
57 %ptrue.ins = insertelement <vscale x 16 x i1> poison, i1 1, i32 0
58 %ptrue = shufflevector <vscale x 16 x i1> %ptrue.ins, <vscale x 16 x i1> poison, <vscale x 16 x i32> zeroinitializer
59 call void @bar(<vscale x 16 x i1> %ptrue)
60 %inc = add nuw nsw i32 %index.03, 1
61 %exitcond.not = icmp eq i32 %inc, %N
62 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
64 for.cond.cleanup: ; preds = %for.body, %entry
67 declare void @foo(i32)
68 declare void @bar(<vscale x 16 x i1>)
69 declare i32 @llvm.vscale.i32()
71 attributes #0 = { "aarch64_pstate_sm_enabled" "frame-pointer"="non-leaf" "target-features"="+sme,+sve" }