brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.8 KiB · 9899599 Raw
168 lines · plain
1; RUN: opt < %s -debug-only=loop-vectorize,vplan -passes=loop-vectorize -vectorizer-maximize-bandwidth -mtriple=x86_64-unknown-linux -S 2>&1 | FileCheck %s2; RUN: opt < %s -debug-only=loop-vectorize,vplan -passes=loop-vectorize -vectorizer-maximize-bandwidth -mtriple=x86_64-unknown-linux -mattr=+avx512f -S 2>&1 | FileCheck %s --check-prefix=AVX512F3; REQUIRES: asserts4 5@a = global [1024 x i8] zeroinitializer, align 166@b = global [1024 x i8] zeroinitializer, align 167 8define i32 @foo() {9; This function has a loop of SAD pattern. Here we check when VF = 16 the10; register usage doesn't exceed 16.11;12; CHECK-LABEL: foo13; CHECK:      LV(REG): VF = 814; CHECK-NEXT: LV(REG): Found max usage: 2 item15; CHECK-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 3 registers16; CHECK-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 7 registers17; CHECK-NEXT: LV(REG): Found invariant usage: 1 item18; CHECK:      LV(REG): VF = 1619; CHECK-NEXT: LV(REG): Found max usage: 2 item20; CHECK-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 3 registers21; CHECK-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 13 registers22; CHECK-NEXT: LV(REG): Found invariant usage: 1 item23 24entry:25  br label %for.body26 27for.cond.cleanup:28  %add.lcssa = phi i32 [ %add, %for.body ]29  ret i32 %add.lcssa30 31for.body:32  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]33  %s.015 = phi i32 [ 0, %entry ], [ %add, %for.body ]34  %arrayidx = getelementptr inbounds [1024 x i8], ptr @a, i64 0, i64 %indvars.iv35  %0 = load i8, ptr %arrayidx, align 136  %conv = zext i8 %0 to i3237  %arrayidx2 = getelementptr inbounds [1024 x i8], ptr @b, i64 0, i64 %indvars.iv38  %1 = load i8, ptr %arrayidx2, align 139  %conv3 = zext i8 %1 to i3240  %sub = sub nsw i32 %conv, %conv341  %ispos = icmp sgt i32 %sub, -142  %neg = sub nsw i32 0, %sub43  %2 = select i1 %ispos, i32 %sub, i32 %neg44  %add = add nsw i32 %2, %s.01545  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 146  %exitcond = icmp eq i64 %indvars.iv.next, 102447  br i1 %exitcond, label %for.cond.cleanup, label %for.body48}49 50define i32 @goo() {51; For indvars.iv used in a computating chain only feeding into getelementptr or cmp,52; it will not have vector version and the vector register usage will not exceed the53; available vector register number.54; CHECK-LABEL: goo55; CHECK:      LV(REG): VF = 856; CHECK-NEXT: LV(REG): Found max usage: 2 item57; CHECK-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 3 registers58; CHECK-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 7 registers59; CHECK-NEXT: LV(REG): Found invariant usage: 1 item60; CHECK:      LV(REG): VF = 1661; CHECK-NEXT: LV(REG): Found max usage: 2 item62; CHECK-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 3 registers63; CHECK-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 13 registers64; CHECK-NEXT: LV(REG): Found invariant usage: 1 item65;66; AVX512F-LABEL: goo67; AVX512F:      LV(REG): VF = 868; AVX512F-NEXT: LV(REG): Found max usage: 2 item69; AVX512F-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 3 registers70; AVX512F-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 4 registers71; AVX512F-NEXT: LV(REG): Found invariant usage: 1 item72; AVX512F:      LV(REG): VF = 1673; AVX512F-NEXT: LV(REG): Found max usage: 2 item74; AVX512F-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 3 registers75; AVX512F-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 4 registers76; AVX512F-NEXT: LV(REG): Found invariant usage: 1 item77entry:78  br label %for.body79 80for.cond.cleanup:                                 ; preds = %for.body81  %add.lcssa = phi i32 [ %add, %for.body ]82  ret i32 %add.lcssa83 84for.body:                                         ; preds = %for.body, %entry85  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]86  %s.015 = phi i32 [ 0, %entry ], [ %add, %for.body ]87  %tmp1 = add nsw i64 %indvars.iv, 388  %arrayidx = getelementptr inbounds [1024 x i8], ptr @a, i64 0, i64 %tmp189  %tmp = load i8, ptr %arrayidx, align 190  %conv = zext i8 %tmp to i3291  %tmp2 = add nsw i64 %indvars.iv, 292  %arrayidx2 = getelementptr inbounds [1024 x i8], ptr @b, i64 0, i64 %tmp293  %tmp3 = load i8, ptr %arrayidx2, align 194  %conv3 = zext i8 %tmp3 to i3295  %sub = sub nsw i32 %conv, %conv396  %ispos = icmp sgt i32 %sub, -197  %neg = sub nsw i32 0, %sub98  %tmp4 = select i1 %ispos, i32 %sub, i32 %neg99  %add = add nsw i32 %tmp4, %s.015100  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1101  %exitcond = icmp eq i64 %indvars.iv.next, 1024102  br i1 %exitcond, label %for.cond.cleanup, label %for.body103}104 105define i64 @bar(ptr nocapture %a) {106; CHECK-LABEL: bar107; CHECK:       LV(REG): VF = 2108; CHECK-NEXT: LV(REG): Found max usage: 2 item109; CHECK-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 2 registers110; CHECK-NEXT: LV(REG): RegisterClass: Generic::VectorRC, 3 registers111; CHECK-NEXT: LV(REG): Found invariant usage: 1 item112; CHECK-NEXT: LV(REG): RegisterClass: Generic::ScalarRC, 1 registers113 114 115entry:116  br label %for.body117 118for.cond.cleanup:119  %add2.lcssa = phi i64 [ %add2, %for.body ]120  ret i64 %add2.lcssa121 122for.body:123  %i.012 = phi i64 [ 0, %entry ], [ %inc, %for.body ]124  %s.011 = phi i64 [ 0, %entry ], [ %add2, %for.body ]125  %arrayidx = getelementptr inbounds i64, ptr %a, i64 %i.012126  %0 = load i64, ptr %arrayidx, align 8127  %add = add nsw i64 %0, %i.012128  store i64 %add, ptr %arrayidx, align 8129  %add2 = add nsw i64 %add, %s.011130  %inc = add nuw nsw i64 %i.012, 1131  %exitcond = icmp eq i64 %inc, 1024132  br i1 %exitcond, label %for.cond.cleanup, label %for.body133}134 135@d = external global [0 x i64], align 8136@e = external global [0 x i32], align 4137@c = external global [0 x i32], align 4138 139define void @hoo(i32 %n) {140; For c[i] = e[d[i]] in the loop, e[d[i]] is not consecutive but its index %tmp can141; be gathered into a vector. For VF == 16, the vector version of %tmp will be <16 x i64>142; so the max usage of AVX512 vector register will be 2.143; AVX512F-LABEL: bar144; AVX512F:       LV(REG): VF = 16145; AVX512F-CHECK: LV(REG): Found max usage: 2 item146; AVX512F-CHECK: LV(REG): RegisterClass: Generic::ScalarRC, 2 registers147; AVX512F-CHECK: LV(REG): RegisterClass: Generic::VectorRC, 2 registers148; AVX512F-CHECK: LV(REG): Found invariant usage: 0 item149 150entry:151  br label %for.body152 153for.body:                                         ; preds = %for.body, %entry154  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]155  %arrayidx = getelementptr inbounds [0 x i64], ptr @d, i64 0, i64 %indvars.iv156  %tmp = load i64, ptr %arrayidx, align 8157  %arrayidx1 = getelementptr inbounds [0 x i32], ptr @e, i64 0, i64 %tmp158  %tmp1 = load i32, ptr %arrayidx1, align 4159  %arrayidx3 = getelementptr inbounds [0 x i32], ptr @c, i64 0, i64 %indvars.iv160  store i32 %tmp1, ptr %arrayidx3, align 4161  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1162  %exitcond = icmp eq i64 %indvars.iv.next, 10000163  br i1 %exitcond, label %for.end, label %for.body164 165for.end:                                          ; preds = %for.body166  ret void167}168