brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 3c2e0c4 Raw
110 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 correctly added when two5# arrays may point to the same memory location.6#7# ```8# void f(int *a, int *b, int n) {9#   for (int i = 0; i < n; i++) {10#     a[i] += b[i];11#     b[i] += a[i];12#   }13# }14# ```15#16# Here is what each instruction does.17# SU(2): Load b[i]18# SU(3): Load a[i]19# SU(5): Store a[i]20# SU(6): Load b[i]21# SU(8): Store b[i]22#23# Note that if there is already a dependency between two instructions, we don't24# add loop-carried on between them since non-loop-carried one imposes stronger25# constraint than loop-carried one.26 27# CHECK:      ===== Loop Carried Edges Begin =====28# CHECK-NEXT:   Loop carried edges from SU(5)29# CHECK-NEXT:     Order30# CHECK-NEXT:       SU(2)31# CHECK-NEXT:   Loop carried edges from SU(6)32# CHECK-NEXT:     Order33# CHECK-NEXT:       SU(5)34# CHECK-NEXT:   Loop carried edges from SU(8)35# CHECK-NEXT:     Order36# CHECK-NEXT:       SU(3)37# CHECK-NEXT:       SU(5)38# CHECK-NEXT: ===== Loop Carried Edges End =====39 40--- |41  define dso_local void @f(ptr nocapture noundef %a, ptr nocapture noundef %b, i32 noundef %n) local_unnamed_addr {42  entry:43    %cmp12 = icmp sgt i32 %n, 044    br i1 %cmp12, label %for.body, label %for.cond.cleanup45 46  for.cond.cleanup:47    ret void48 49  for.body:50    %lsr.iv15 = phi ptr [ %cgep17, %for.body ], [ %b, %entry ]51    %lsr.iv14 = phi ptr [ %cgep, %for.body ], [ %a, %entry ]52    %lsr.iv = phi i32 [ %lsr.iv.next, %for.body ], [ %n, %entry ]53    %0 = load i32, ptr %lsr.iv15, align 4, !tbaa !554    %1 = load i32, ptr %lsr.iv14, align 4, !tbaa !555    %add = add nsw i32 %1, %056    store i32 %add, ptr %lsr.iv14, align 4, !tbaa !557    %2 = load i32, ptr %lsr.iv15, align 4, !tbaa !558    %add4 = add nsw i32 %2, %add59    store i32 %add4, ptr %lsr.iv15, align 4, !tbaa !560    %lsr.iv.next = add i32 %lsr.iv, -161    %exitcond.not = icmp eq i32 %lsr.iv.next, 062    %cgep = getelementptr i8, ptr %lsr.iv14, i32 463    %cgep17 = getelementptr i8, ptr %lsr.iv15, i32 464    br i1 %exitcond.not, label %for.cond.cleanup, label %for.body65  }66 67  !5 = !{!6, !6, i64 0}68  !6 = !{!"int", !7, i64 0}69  !7 = !{!"omnipotent char", !8, i64 0}70  !8 = !{!"Simple C/C++ TBAA"}71 72...73---74name:            f75tracksRegLiveness: true76body:             |77  bb.0.entry:78    successors: %bb.3, %bb.179    liveins: $r0, $r1, $r280  81    %8:intregs = COPY $r282    %7:intregs = COPY $r183    %6:intregs = COPY $r084    %9:predregs = C2_cmpgti %8, 085    J2_jumpf %9, %bb.1, implicit-def $pc86  87  bb.3:88    %16:intregs = COPY %889    J2_loop0r %bb.2, %16, implicit-def $lc0, implicit-def $sa0, implicit-def $usr90    J2_jump %bb.2, implicit-def $pc91  92  bb.1.for.cond.cleanup:93    PS_jmpret $r31, implicit-def dead $pc94  95  bb.2.for.body:96    successors: %bb.1, %bb.297  98    %0:intregs = PHI %7, %bb.3, %5, %bb.299    %1:intregs = PHI %6, %bb.3, %4, %bb.2100    %10:intregs = L2_loadri_io %0, 0 :: (load (s32) from %ir.lsr.iv15, !tbaa !5)101    %11:intregs = L2_loadri_io %1, 0 :: (load (s32) from %ir.lsr.iv14, !tbaa !5)102    %12:intregs = nsw A2_add killed %11, killed %10103    %4:intregs = S2_storeri_pi %1, 4, %12 :: (store (s32) into %ir.lsr.iv14, !tbaa !5)104    %13:intregs = L2_loadri_io %0, 0 :: (load (s32) from %ir.lsr.iv15, !tbaa !5)105    %14:intregs = nsw A2_add killed %13, %12106    %5:intregs = S2_storeri_pi %0, 4, killed %14 :: (store (s32) into %ir.lsr.iv15, !tbaa !5)107    ENDLOOP0 %bb.2, implicit-def $pc, implicit-def $lc0, implicit $sa0, implicit $lc0108    J2_jump %bb.1, implicit-def $pc109...110