104 lines · plain
1# RUN: llc -mtriple=hexagon -run-pass pipeliner -debug-only=pipeliner %s -o /dev/null 2>&1 -pipeliner-experimental-cg=true | FileCheck %s2# REQUIRES: asserts3 4# Test that loop-carried memory dependencies are added correctly.5# The original code is as follows.6#7# ```8# void f(int *a, int n) {9# for (int i = 1; i < n; i++) {10# a[i] += a[i];11# a[i-1] += i;12# }13# }14# ```15# 16# Loop-carried dependencies exist from load/store for a[i] to store for a[i-1], but not vice versa.17 18# CHECK: ===== Loop Carried Edges Begin =====19# CHECK-NEXT: Loop carried edges from SU(3)20# CHECK-NEXT: Order21# CHECK-NEXT: SU(7)22# CHECK-NEXT: Loop carried edges from SU(5)23# CHECK-NEXT: Order24# CHECK-NEXT: SU(7)25# CHECK-NEXT: ===== Loop Carried Edges End =====26 27--- |28 define dso_local void @f(ptr nocapture noundef %a, i32 noundef %n) local_unnamed_addr {29 entry:30 %cmp11 = icmp sgt i32 %n, 131 br i1 %cmp11, label %for.body.preheader, label %for.cond.cleanup32 33 for.body.preheader:34 %load_initial = load i32, ptr %a, align 435 %cgep = getelementptr i8, ptr %a, i32 436 br label %for.body37 38 for.cond.cleanup:39 ret void40 41 for.body:42 %lsr.iv = phi ptr [ %cgep, %for.body.preheader ], [ %cgep16, %for.body ]43 %store_forwarded = phi i32 [ %load_initial, %for.body.preheader ], [ %add, %for.body ]44 %i.012 = phi i32 [ 1, %for.body.preheader ], [ %inc, %for.body ]45 %0 = load i32, ptr %lsr.iv, align 4, !tbaa !546 %add = shl nsw i32 %0, 147 store i32 %add, ptr %lsr.iv, align 4, !tbaa !548 %1 = add i32 %store_forwarded, %i.01249 %cgep15 = getelementptr i8, ptr %lsr.iv, i32 -450 store i32 %1, ptr %cgep15, align 4, !tbaa !551 %inc = add nuw nsw i32 %i.012, 152 %exitcond.not = icmp eq i32 %n, %inc53 %cgep16 = getelementptr i8, ptr %lsr.iv, i32 454 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body55 }56 57 !5 = !{!6, !6, i64 0}58 !6 = !{!"int", !7, i64 0}59 !7 = !{!"omnipotent char", !8, i64 0}60 !8 = !{!"Simple C/C++ TBAA"}61 62...63---64name: f65tracksRegLiveness: true66body: |67 bb.0.entry:68 successors: %bb.1, %bb.269 liveins: $r0, $r170 71 %9:intregs = COPY $r172 %8:intregs = COPY $r073 %10:predregs = C2_cmpgti %9, 174 J2_jumpf %10, %bb.2, implicit-def dead $pc75 J2_jump %bb.1, implicit-def dead $pc76 77 bb.1.for.body.preheader:78 %0:intregs, %1:intregs = L2_loadri_pi %8, 4 :: (load (s32) from %ir.a)79 %12:intregs = A2_tfrsi 180 %16:intregs = A2_addi %9, -181 %17:intregs = COPY %1682 J2_loop0r %bb.3, %17, implicit-def $lc0, implicit-def $sa0, implicit-def $usr83 J2_jump %bb.3, implicit-def dead $pc84 85 bb.2.for.cond.cleanup:86 PS_jmpret $r31, implicit-def dead $pc87 88 bb.3.for.body (machine-block-address-taken):89 successors: %bb.2(0x04000000), %bb.3(0x7c000000)90 91 %2:intregs = PHI %1, %bb.1, %7, %bb.392 %3:intregs = PHI %0, %bb.1, %5, %bb.393 %4:intregs = PHI %12, %bb.1, %6, %bb.394 %13:intregs = L2_loadri_io %2, 0 :: (load (s32) from %ir.lsr.iv, !tbaa !5)95 %5:intregs = nsw S2_asl_i_r killed %13, 196 S2_storeri_io %2, 0, %5 :: (store (s32) into %ir.lsr.iv, !tbaa !5)97 %14:intregs = A2_add %3, %498 S2_storeri_io %2, -4, killed %14 :: (store (s32) into %ir.cgep15, !tbaa !5)99 %6:intregs = nuw nsw A2_addi %4, 1100 %7:intregs = A2_addi %2, 4101 ENDLOOP0 %bb.3, implicit-def $pc, implicit-def $lc0, implicit $sa0, implicit $lc0102 J2_jump %bb.2, implicit-def $pc103...104