109 lines · plain
1; RUN: opt < %s -passes=loop-vectorize -mtriple aarch64-unknown-linux-gnu -mattr=+sve -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue -S | FileCheck --check-prefixes=CHECK,PREDICATED %s2; RUN: opt < %s -passes=loop-vectorize -mtriple aarch64-unknown-linux-gnu -mattr=+sve -prefer-predicate-over-epilogue=scalar-epilogue -S | FileCheck --check-prefixes=CHECK,SCALAR %s3 4; This file contains the same function but with different trip-count PGO hints5 6; The function is vectorized if there are no trip-count hints7define i32 @foo_no_trip_count(ptr %a, ptr %b, ptr %c, i32 %bound) {8; CHECK-LABEL: @foo_no_trip_count(9; PREDICATED: vector.body10; SCALAR: vector.body11entry:12 br label %for.body13 14for.body: ; preds = %for.body, %entry15 %idx = phi i32 [ 0, %entry ], [ %inc, %for.body ]16 %a.index = getelementptr inbounds [32 x i8], ptr %a, i32 0, i32 %idx17 %0 = load i8, ptr %a.index, align 118 %b.index = getelementptr inbounds [32 x i8], ptr %b, i32 0, i32 %idx19 %1 = load i8, ptr %b.index, align 120 %2 = add i8 %0, %121 %c.index = getelementptr inbounds [32 x i8], ptr %c, i32 0, i32 %idx22 store i8 %2, ptr %c.index, align 123 %inc = add nsw i32 %idx, 124 %exitcond = icmp eq i32 %idx, %bound25 br i1 %exitcond, label %for.end, label %for.body26 27for.end: ; preds = %for.body28 ret i32 029}30 31; If trip-count is equal to 4, the function is not vectorised32define i32 @foo_low_trip_count(ptr %a, ptr %b, ptr %c, i32 %bound) {33; CHECK-LABEL: @foo_low_trip_count(34; PREDICATED-NOT: vector.body35; SCALAR-NOT: vector.body36entry:37 br label %for.body38 39for.body: ; preds = %for.body, %entry40 %idx = phi i32 [ 0, %entry ], [ %inc, %for.body ]41 %a.index = getelementptr inbounds [32 x i8], ptr %a, i32 0, i32 %idx42 %0 = load i8, ptr %a.index, align 143 %b.index = getelementptr inbounds [32 x i8], ptr %b, i32 0, i32 %idx44 %1 = load i8, ptr %b.index, align 145 %2 = add i8 %0, %146 %c.index = getelementptr inbounds [32 x i8], ptr %c, i32 0, i32 %idx47 store i8 %2, ptr %c.index, align 148 %inc = add nsw i32 %idx, 149 %exitcond = icmp eq i32 %idx, %bound50 br i1 %exitcond, label %for.end, label %for.body, !prof !051 52for.end: ; preds = %for.body53 ret i32 054}55 56; If trip-count is equal to 10, the function is vectorised when predicated tail folding is chosen57define i32 @foo_mid_trip_count(ptr %a, ptr %b, ptr %c, i32 %bound) {58; CHECK-LABEL: @foo_mid_trip_count(59; PREDICATED: vector.body60; SCALAR-NOT: vector.body61entry:62 br label %for.body63 64for.body: ; preds = %for.body, %entry65 %idx = phi i32 [ 0, %entry ], [ %inc, %for.body ]66 %a.index = getelementptr inbounds [32 x i8], ptr %a, i32 0, i32 %idx67 %0 = load i8, ptr %a.index, align 168 %b.index = getelementptr inbounds [32 x i8], ptr %b, i32 0, i32 %idx69 %1 = load i8, ptr %b.index, align 170 %2 = add i8 %0, %171 %c.index = getelementptr inbounds [32 x i8], ptr %c, i32 0, i32 %idx72 store i8 %2, ptr %c.index, align 173 %inc = add nsw i32 %idx, 174 %exitcond = icmp eq i32 %idx, %bound75 br i1 %exitcond, label %for.end, label %for.body, !prof !176 77for.end: ; preds = %for.body78 ret i32 079}80 81; If trip-count is equal to 40, the function is always vectorised82define i32 @foo_high_trip_count(ptr %a, ptr %b, ptr %c, i32 %bound) {83; CHECK-LABEL: @foo_high_trip_count(84; PREDICATED: vector.body85; SCALAR: vector.body86entry:87 br label %for.body88 89for.body: ; preds = %for.body, %entry90 %idx = phi i32 [ 0, %entry ], [ %inc, %for.body ]91 %a.index = getelementptr inbounds [32 x i8], ptr %a, i32 0, i32 %idx92 %0 = load i8, ptr %a.index, align 193 %b.index = getelementptr inbounds [32 x i8], ptr %b, i32 0, i32 %idx94 %1 = load i8, ptr %b.index, align 195 %2 = add i8 %0, %196 %c.index = getelementptr inbounds [32 x i8], ptr %c, i32 0, i32 %idx97 store i8 %2, ptr %c.index, align 198 %inc = add nsw i32 %idx, 199 %exitcond = icmp eq i32 %idx, %bound100 br i1 %exitcond, label %for.end, label %for.body, !prof !2101 102for.end: ; preds = %for.body103 ret i32 0104}105 106!0 = !{!"branch_weights", i32 10, i32 30}107!1 = !{!"branch_weights", i32 10, i32 90}108!2 = !{!"branch_weights", i32 10, i32 390}109