1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -O3 -mtriple=aarch64 -mattr=+sme -S < %s | FileCheck %s
4 ; Test PHI nodes are allowed with opaque scalable types.
5 define target("aarch64.svcount") @test_alloca_store_reload(target("aarch64.svcount") %val0, target("aarch64.svcount") %val1, ptr %iptr, ptr %pptr, i64 %N) nounwind {
6 ; CHECK-LABEL: @test_alloca_store_reload(
8 ; CHECK-NEXT: store i64 0, ptr [[IPTR:%.*]], align 8
9 ; CHECK-NEXT: store target("aarch64.svcount") [[VAL0:%.*]], ptr [[PPTR:%.*]], align 2
10 ; CHECK-NEXT: [[I1_PEEL:%.*]] = icmp eq i64 [[N:%.*]], 0
11 ; CHECK-NEXT: br i1 [[I1_PEEL]], label [[LOOP_EXIT:%.*]], label [[LOOP_BODY:%.*]]
13 ; CHECK-NEXT: [[IND:%.*]] = phi i64 [ [[IND_NEXT:%.*]], [[LOOP_BODY]] ], [ 1, [[ENTRY:%.*]] ]
14 ; CHECK-NEXT: [[IPTR_GEP:%.*]] = getelementptr i64, ptr [[IPTR]], i64 [[IND]]
15 ; CHECK-NEXT: store i64 [[IND]], ptr [[IPTR_GEP]], align 8
16 ; CHECK-NEXT: store target("aarch64.svcount") [[VAL1:%.*]], ptr [[PPTR]], align 2
17 ; CHECK-NEXT: [[IND_NEXT]] = add i64 [[IND]], 1
18 ; CHECK-NEXT: [[I1:%.*]] = icmp eq i64 [[IND]], [[N]]
19 ; CHECK-NEXT: br i1 [[I1]], label [[LOOP_EXIT]], label [[LOOP_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
21 ; CHECK-NEXT: [[PHI_LCSSA:%.*]] = phi target("aarch64.svcount") [ [[VAL0]], [[ENTRY]] ], [ [[VAL1]], [[LOOP_BODY]] ]
22 ; CHECK-NEXT: ret target("aarch64.svcount") [[PHI_LCSSA]]
28 %ind = phi i64 [0, %entry], [%ind.next, %loop.body]
29 %phi = phi target("aarch64.svcount") [%val0, %entry], [%val1, %loop.body]
30 %iptr.gep = getelementptr i64, ptr %iptr, i64 %ind
31 store i64 %ind, ptr %iptr.gep
32 store target("aarch64.svcount") %phi, ptr %pptr
33 %ind.next = add i64 %ind, 1
34 %i1 = icmp eq i64 %ind, %N
35 br i1 %i1, label %loop.exit, label %loop.body
38 ret target("aarch64.svcount") %phi