1; RUN: opt -loop-load-elim -mtriple=aarch64 -mattr=+sve -S -debug < %s 2>&1 | FileCheck %s
2; REQUIRES: asserts
3
4; Regression tests verifying "assumption that TypeSize is not scalable" and
5; "Invalid size request on a scalable vector." are not produced by
6; -load-loop-elim (this would cause the test to fail because opt would exit with
7; a non-zero exit status).
8
9; No output checked for this one, but causes a fatal error if the regression is present.
10
11define void @regression_test_get_gep_induction_operand_typesize_warning(i64 %n, <vscale x 4 x i32>* %a) {
12entry:
13  br label %loop.body
14
15loop.body:
16  %0 = phi i64 [ 0, %entry ], [ %1, %loop.body ]
17  %idx = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* %a, i64 %0
18  store <vscale x 4 x i32> zeroinitializer, <vscale x 4 x i32>* %idx
19  %1 = add i64 %0, 1
20  %2 = icmp eq i64 %1, %n
21  br i1 %2, label %loop.end, label %loop.body
22
23loop.end:
24  ret void
25}
26
27; CHECK-LABEL: LAA: Found a loop in regression_test_loop_access_scalable_typesize
28; CHECK: LAA: Bad stride - Scalable object:
29define void @regression_test_loop_access_scalable_typesize(<vscale x 16 x i8>* %input_ptr) {
30entry:
31  br label %vector.body
32vector.body:
33  %ind_ptr = phi <vscale x 16 x i8>* [ %next_ptr, %vector.body ], [ %input_ptr, %entry ]
34  %ind = phi i64 [ %next, %vector.body ], [ 0, %entry ]
35  %ld = load <vscale x 16 x i8>, <vscale x 16 x i8>* %ind_ptr, align 16
36  store <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8>* %ind_ptr, align 16
37  %next_ptr = getelementptr inbounds <vscale x 16 x i8>, <vscale x 16 x i8>* %ind_ptr, i64 1
38  %next = add i64 %ind, 1
39  %cond = icmp ult i64 %next, 1024
40  br i1 %cond, label %end, label %vector.body
41end:
42  ret void
43}
44
45; CHECK-LABEL: LAA: Found a loop in regression_test_loop_access_scalable_typesize_nonscalable_object
46; CHECK: LAA: Bad stride - Scalable object:
47define void @regression_test_loop_access_scalable_typesize_nonscalable_object(i8* %input_ptr) {
48entry:
49  br label %vector.body
50vector.body:
51  %ind_ptr = phi i8* [ %next_ptr, %vector.body ], [ %input_ptr, %entry ]
52  %ind = phi i64 [ %next, %vector.body ], [ 0, %entry ]
53  %scalable_ptr = bitcast i8* %ind_ptr to <vscale x 16 x i8>*
54  %ld = load <vscale x 16 x i8>, <vscale x 16 x i8>* %scalable_ptr, align 16
55  store <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8>* %scalable_ptr, align 16
56  %next_ptr = getelementptr inbounds i8, i8* %ind_ptr, i64 1
57  %next = add i64 %ind, 1
58  %cond = icmp ult i64 %next, 1024
59  br i1 %cond, label %end, label %vector.body
60end:
61  ret void
62}
63