108 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 * restrict a, int * restrict b, int n) {9# for (int i = 0; i < n; i++) {10# a[i] += i;11# b[i] += a[i+1];12# }13# }14# ```15# 16# Loop-carried dependencies exist from load for a[i+1] to store for a[i].17 18# CHECK: ===== Loop Carried Edges Begin =====19# CHECK-NEXT: Loop carried edges from SU(7)20# CHECK-NEXT: Order21# CHECK-NEXT: SU(5)22# CHECK-NEXT: ===== Loop Carried Edges End =====23 24--- |25 define dso_local void @f(ptr noalias nocapture noundef %a, ptr noalias nocapture noundef %b, i32 noundef %n) local_unnamed_addr {26 entry:27 %cmp11 = icmp sgt i32 %n, 028 br i1 %cmp11, label %for.body.preheader, label %for.cond.cleanup29 30 for.body.preheader:31 %.pre = load i32, ptr %a, align 4, !tbaa !532 %cgep = getelementptr i8, ptr %a, i32 433 br label %for.body34 35 for.cond.cleanup:36 ret void37 38 for.body:39 %lsr.iv15 = phi ptr [ %cgep, %for.body.preheader ], [ %cgep20, %for.body ]40 %lsr.iv13 = phi i32 [ %n, %for.body.preheader ], [ %lsr.iv.next, %for.body ]41 %lsr.iv = phi ptr [ %b, %for.body.preheader ], [ %cgep19, %for.body ]42 %0 = phi i32 [ %2, %for.body ], [ %.pre, %for.body.preheader ]43 %i.012 = phi i32 [ %add1, %for.body ], [ 0, %for.body.preheader ]44 %1 = add i32 %0, %i.01245 %cgep18 = getelementptr i8, ptr %lsr.iv15, i32 -446 store i32 %1, ptr %cgep18, align 4, !tbaa !547 %add1 = add nuw nsw i32 %i.012, 148 %2 = load i32, ptr %lsr.iv15, align 4, !tbaa !549 %3 = load i32, ptr %lsr.iv, align 4, !tbaa !550 %add4 = add nsw i32 %3, %251 store i32 %add4, ptr %lsr.iv, align 4, !tbaa !552 %lsr.iv.next = add i32 %lsr.iv13, -153 %exitcond.not = icmp eq i32 %lsr.iv.next, 054 %cgep19 = getelementptr i8, ptr %lsr.iv, i32 455 %cgep20 = getelementptr i8, ptr %lsr.iv15, i32 456 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body57 }58 59 !5 = !{!6, !6, i64 0}60 !6 = !{!"int", !7, i64 0}61 !7 = !{!"omnipotent char", !8, i64 0}62 !8 = !{!"Simple C/C++ TBAA"}63 64...65---66name: f67tracksRegLiveness: true68body: |69 bb.0.entry:70 successors: %bb.1, %bb.271 liveins: $r0, $r1, $r272 73 %14:intregs = COPY $r274 %13:intregs = COPY $r175 %12:intregs = COPY $r076 %15:predregs = C2_cmpgti %14, 077 J2_jumpf %15, %bb.2, implicit-def dead $pc78 J2_jump %bb.1, implicit-def dead $pc79 80 bb.1.for.body.preheader:81 %0:intregs, %1:intregs = L2_loadri_pi %12, 4 :: (load (s32) from %ir.a, !tbaa !5)82 %17:intregs = A2_tfrsi 083 %22:intregs = COPY %1484 J2_loop0r %bb.3, %22, implicit-def $lc0, implicit-def $sa0, implicit-def $usr85 J2_jump %bb.3, implicit-def dead $pc86 87 bb.2.for.cond.cleanup:88 PS_jmpret $r31, implicit-def dead $pc89 90 bb.3.for.body:91 successors: %bb.2, %bb.392 93 %2:intregs = PHI %1, %bb.1, %11, %bb.394 %4:intregs = PHI %13, %bb.1, %10, %bb.395 %5:intregs = PHI %0, %bb.1, %8, %bb.396 %6:intregs = PHI %17, %bb.1, %7, %bb.397 %18:intregs = A2_add %5, %698 S2_storeri_io %2, -4, killed %18 :: (store (s32) into %ir.cgep18, !tbaa !5)99 %7:intregs = nuw nsw A2_addi %6, 1100 %8:intregs = L2_loadri_io %2, 0 :: (load (s32) from %ir.lsr.iv15, !tbaa !5)101 %19:intregs = L2_loadri_io %4, 0 :: (load (s32) from %ir.lsr.iv, !tbaa !5)102 %20:intregs = nsw A2_add killed %19, %8103 %10:intregs = S2_storeri_pi %4, 4, killed %20 :: (store (s32) into %ir.lsr.iv, !tbaa !5)104 %11:intregs = A2_addi %2, 4105 ENDLOOP0 %bb.3, implicit-def $pc, implicit-def $lc0, implicit $sa0, implicit $lc0106 J2_jump %bb.2, implicit-def $pc107...108