|
| 1 | +; RUN: opt < %s -mattr=+sve -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -prefer-predicate-over-epilogue=predicate-dont-vectorize -S | FileCheck %s |
| 2 | +; RUN: opt < %s -mattr=+sve -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -prefer-predicate-over-epilogue=predicate-dont-vectorize -pass-remarks-analysis=loop-vectorize -disable-output -S 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 3 | + |
| 4 | +target triple = "aarch64-unknown-linux-gnu" |
| 5 | + |
| 6 | +; Tests basic vectorization of scalable homogeneous struct literal returns. |
| 7 | + |
| 8 | +; TODO: Support vectorization in this case. |
| 9 | +; CHECK-REMARKS: remark: {{.*}} loop not vectorized: Auto-vectorization of calls that return struct types is not yet supported |
| 10 | +define void @struct_return_f32_widen(ptr noalias %in, ptr noalias writeonly %out_a, ptr noalias writeonly %out_b) { |
| 11 | +; CHECK-LABEL: define void @struct_return_f32_widen |
| 12 | +; CHECK-NOT: vector.body: |
| 13 | +entry: |
| 14 | + br label %for.body |
| 15 | + |
| 16 | +for.body: |
| 17 | + %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] |
| 18 | + %arrayidx = getelementptr inbounds float, ptr %in, i64 %iv |
| 19 | + %in_val = load float, ptr %arrayidx, align 4 |
| 20 | + %call = tail call { float, float } @foo(float %in_val) #0 |
| 21 | + %extract_a = extractvalue { float, float } %call, 0 |
| 22 | + %extract_b = extractvalue { float, float } %call, 1 |
| 23 | + %arrayidx2 = getelementptr inbounds float, ptr %out_a, i64 %iv |
| 24 | + store float %extract_a, ptr %arrayidx2, align 4 |
| 25 | + %arrayidx4 = getelementptr inbounds float, ptr %out_b, i64 %iv |
| 26 | + store float %extract_b, ptr %arrayidx4, align 4 |
| 27 | + %iv.next = add nuw nsw i64 %iv, 1 |
| 28 | + %exitcond.not = icmp eq i64 %iv.next, 1024 |
| 29 | + br i1 %exitcond.not, label %exit, label %for.body |
| 30 | + |
| 31 | +exit: |
| 32 | + ret void |
| 33 | +} |
| 34 | + |
| 35 | +; TODO: Support vectorization in this case. |
| 36 | +; CHECK-REMARKS: remark: {{.*}} loop not vectorized: Auto-vectorization of calls that return struct types is not yet supported |
| 37 | +define void @struct_return_f64_widen(ptr noalias %in, ptr noalias writeonly %out_a, ptr noalias writeonly %out_b) { |
| 38 | +; CHECK-LABEL: define void @struct_return_f64_widen |
| 39 | +; CHECK-NOT: vector.body: |
| 40 | +entry: |
| 41 | + br label %for.body |
| 42 | + |
| 43 | +for.body: |
| 44 | + %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] |
| 45 | + %arrayidx = getelementptr inbounds double, ptr %in, i64 %iv |
| 46 | + %in_val = load double, ptr %arrayidx, align 8 |
| 47 | + %call = tail call { double, double } @bar(double %in_val) #1 |
| 48 | + %extract_a = extractvalue { double, double } %call, 0 |
| 49 | + %extract_b = extractvalue { double, double } %call, 1 |
| 50 | + %arrayidx2 = getelementptr inbounds double, ptr %out_a, i64 %iv |
| 51 | + store double %extract_a, ptr %arrayidx2, align 8 |
| 52 | + %arrayidx4 = getelementptr inbounds double, ptr %out_b, i64 %iv |
| 53 | + store double %extract_b, ptr %arrayidx4, align 8 |
| 54 | + %iv.next = add nuw nsw i64 %iv, 1 |
| 55 | + %exitcond.not = icmp eq i64 %iv.next, 1024 |
| 56 | + br i1 %exitcond.not, label %exit, label %for.body |
| 57 | + |
| 58 | +exit: |
| 59 | + ret void |
| 60 | +} |
| 61 | + |
| 62 | +; TODO: Support vectorization in this case. |
| 63 | +; CHECK-REMARKS: remark: {{.*}} loop not vectorized: Auto-vectorization of calls that return struct types is not yet supported |
| 64 | +define void @struct_return_f32_widen_rt_checks(ptr %in, ptr writeonly %out_a, ptr writeonly %out_b) { |
| 65 | +; CHECK-LABEL: define void @struct_return_f32_widen_rt_checks |
| 66 | +; CHECK-NOT: vector.body: |
| 67 | +entry: |
| 68 | + br label %for.body |
| 69 | + |
| 70 | +for.body: |
| 71 | + %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] |
| 72 | + %arrayidx = getelementptr inbounds float, ptr %in, i64 %iv |
| 73 | + %in_val = load float, ptr %arrayidx, align 4 |
| 74 | + %call = tail call { float, float } @foo(float %in_val) #0 |
| 75 | + %extract_a = extractvalue { float, float } %call, 0 |
| 76 | + %extract_b = extractvalue { float, float } %call, 1 |
| 77 | + %arrayidx2 = getelementptr inbounds float, ptr %out_a, i64 %iv |
| 78 | + store float %extract_a, ptr %arrayidx2, align 4 |
| 79 | + %arrayidx4 = getelementptr inbounds float, ptr %out_b, i64 %iv |
| 80 | + store float %extract_b, ptr %arrayidx4, align 4 |
| 81 | + %iv.next = add nuw nsw i64 %iv, 1 |
| 82 | + %exitcond.not = icmp eq i64 %iv.next, 1024 |
| 83 | + br i1 %exitcond.not, label %exit, label %for.body |
| 84 | + |
| 85 | +exit: |
| 86 | + ret void |
| 87 | +} |
| 88 | + |
| 89 | +declare { float, float } @foo(float) |
| 90 | +declare { double, double } @bar(double) |
| 91 | + |
| 92 | +declare { <vscale x 4 x float>, <vscale x 4 x float> } @scalable_vec_masked_foo(<vscale x 4 x float>, <vscale x 4 x i1>) |
| 93 | +declare { <vscale x 2 x double>, <vscale x 2 x double> } @scalable_vec_masked_bar(<vscale x 2 x double>, <vscale x 2 x i1>) |
| 94 | + |
| 95 | + |
| 96 | +attributes #0 = { nounwind "vector-function-abi-variant"="_ZGVsMxv_foo(scalable_vec_masked_foo)" } |
| 97 | +attributes #1 = { nounwind "vector-function-abi-variant"="_ZGVsMxv_bar(scalable_vec_masked_bar)" } |
0 commit comments