brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · 4281d15 Raw
155 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 computed correctly5# when barrier instructions exist in the loop.6# The original code is as follows.7# 8# ```9# volatile int x = 0;10# void f(int * restrict a, int * restrict b, int * restrict c, int n) {11#   for (int i = 0; i < n; i++) {12#     a[i] *= c[i];13#     b[i] *= c[i];14#     x += i;15#     a[i + 1] *= i;16#     x += i;17#     b[i + 1] *= i;18#   }19# }20# ```21#22# FIXME: Currently the following dependencies are missed.23# Loop carried edges from SU(16)24#   Order25#     SU(6)26#     SU(8)27#     SU(10)28#     SU(11)29# Loop carried edges from SU(17)30#   Order31#     SU(10)32#     SU(11)33# Loop carried edges from SU(19)34#   Order35#     SU(10)36#     SU(11)37 38# CHECK:      ===== Loop Carried Edges Begin =====39# CHECK-NEXT: ===== Loop Carried Edges End =====40 41--- |42  @x = dso_local global i32 0, align 443 44  define dso_local void @f(ptr noalias nocapture noundef %a, ptr noalias nocapture noundef %b, ptr noalias nocapture noundef readonly %c, i32 noundef %n) {45  entry:46    %cmp26 = icmp sgt i32 %n, 047    br i1 %cmp26, label %for.body.preheader, label %for.cond.cleanup48 49  for.body.preheader:50    %.pre = load i32, ptr %a, align 4, !tbaa !551    %.pre28 = load i32, ptr %b, align 4, !tbaa !552    %cgep = getelementptr i8, ptr %b, i32 453    %cgep37 = getelementptr i8, ptr %a, i32 454    br label %for.body55 56  for.cond.cleanup:57    ret void58 59  for.body:60    %lsr.iv35 = phi ptr [ %c, %for.body.preheader ], [ %cgep42, %for.body ]61    %lsr.iv31 = phi ptr [ %cgep37, %for.body.preheader ], [ %cgep41, %for.body ]62    %lsr.iv = phi ptr [ %cgep, %for.body.preheader ], [ %cgep40, %for.body ]63    %0 = phi i32 [ %mul11, %for.body ], [ %.pre28, %for.body.preheader ]64    %1 = phi i32 [ %mul7, %for.body ], [ %.pre, %for.body.preheader ]65    %i.027 = phi i32 [ %add5, %for.body ], [ 0, %for.body.preheader ]66    %2 = load i32, ptr %lsr.iv35, align 4, !tbaa !567    %mul = mul nsw i32 %1, %268    %cgep38 = getelementptr i8, ptr %lsr.iv31, i32 -469    store i32 %mul, ptr %cgep38, align 4, !tbaa !570    %mul4 = mul nsw i32 %0, %271    %cgep39 = getelementptr i8, ptr %lsr.iv, i32 -472    store i32 %mul4, ptr %cgep39, align 4, !tbaa !573    %3 = load volatile i32, ptr @x, align 4, !tbaa !574    %4 = add i32 %i.027, %375    store volatile i32 %4, ptr @x, align 4, !tbaa !576    %add5 = add nuw nsw i32 %i.027, 177    %5 = load i32, ptr %lsr.iv31, align 4, !tbaa !578    %mul7 = mul nsw i32 %5, %i.02779    store i32 %mul7, ptr %lsr.iv31, align 4, !tbaa !580    %6 = load volatile i32, ptr @x, align 4, !tbaa !581    %7 = add i32 %i.027, %682    store volatile i32 %7, ptr @x, align 4, !tbaa !583    %8 = load i32, ptr %lsr.iv, align 4, !tbaa !584    %mul11 = mul nsw i32 %8, %i.02785    store i32 %mul11, ptr %lsr.iv, align 4, !tbaa !586    %exitcond.not = icmp eq i32 %n, %add587    %cgep40 = getelementptr i8, ptr %lsr.iv, i32 488    %cgep41 = getelementptr i8, ptr %lsr.iv31, i32 489    %cgep42 = getelementptr i8, ptr %lsr.iv35, i32 490    br i1 %exitcond.not, label %for.cond.cleanup, label %for.body91  }92 93  !5 = !{!6, !6, i64 0}94  !6 = !{!"int", !7, i64 0}95  !7 = !{!"omnipotent char", !8, i64 0}96  !8 = !{!"Simple C/C++ TBAA"}97 98...99---100name:            f101tracksRegLiveness: true102body:             |103  bb.0.entry:104    successors: %bb.1, %bb.2105    liveins: $r0, $r1, $r2, $r3106  107    %19:intregs = COPY $r3108    %18:intregs = COPY $r2109    %17:intregs = COPY $r1110    %16:intregs = COPY $r0111    %20:predregs = C2_cmpgti %19, 0112    J2_jumpf %20, %bb.2, implicit-def dead $pc113    J2_jump %bb.1, implicit-def dead $pc114  115  bb.1.for.body.preheader:116    %0:intregs, %3:intregs = L2_loadri_pi %16, 4 :: (load (s32) from %ir.a, !tbaa !5)117    %1:intregs, %2:intregs = L2_loadri_pi %17, 4 :: (load (s32) from %ir.b, !tbaa !5)118    %22:intregs = A2_tfrsi 0119    %26:intregs = C4_addipc target-flags(hexagon-pcrel) @x120    %30:intregs = COPY %19121    J2_loop0r %bb.3, %30, implicit-def $lc0, implicit-def $sa0, implicit-def $usr122    J2_jump %bb.3, implicit-def dead $pc123  124  bb.2.for.cond.cleanup:125    PS_jmpret $r31, implicit-def dead $pc126  127  bb.3.for.body:128    successors: %bb.2, %bb.3129  130    %4:intregs = PHI %18, %bb.1, %15, %bb.3131    %5:intregs = PHI %3, %bb.1, %14, %bb.3132    %6:intregs = PHI %2, %bb.1, %13, %bb.3133    %7:intregs = PHI %1, %bb.1, %12, %bb.3134    %8:intregs = PHI %0, %bb.1, %11, %bb.3135    %9:intregs = PHI %22, %bb.1, %10, %bb.3136    %23:intregs, %15:intregs = L2_loadri_pi %4, 4 :: (load (s32) from %ir.lsr.iv35, !tbaa !5)137    %24:intregs = nsw M2_mpyi %8, %23138    S2_storeri_io %5, -4, killed %24 :: (store (s32) into %ir.cgep38, !tbaa !5)139    %25:intregs = nsw M2_mpyi %7, %23140    S2_storeri_io %6, -4, killed %25 :: (store (s32) into %ir.cgep39, !tbaa !5)141    L4_add_memopw_io %26, 0, %9 :: (volatile store (s32) into @x, !tbaa !5), (volatile dereferenceable load (s32) from @x, !tbaa !5)142    %10:intregs = nuw nsw A2_addi %9, 1143    %27:intregs = L2_loadri_io %5, 0 :: (load (s32) from %ir.lsr.iv31, !tbaa !5)144    %11:intregs = nsw M2_mpyi killed %27, %9145    S2_storeri_io %5, 0, %11 :: (store (s32) into %ir.lsr.iv31, !tbaa !5)146    L4_add_memopw_io %26, 0, %9 :: (volatile store (s32) into @x, !tbaa !5), (volatile dereferenceable load (s32) from @x, !tbaa !5)147    %28:intregs = L2_loadri_io %6, 0 :: (load (s32) from %ir.lsr.iv, !tbaa !5)148    %12:intregs = nsw M2_mpyi killed %28, %9149    S2_storeri_io %6, 0, %12 :: (store (s32) into %ir.lsr.iv, !tbaa !5)150    %13:intregs = A2_addi %6, 4151    %14:intregs = A2_addi %5, 4152    ENDLOOP0 %bb.3, implicit-def $pc, implicit-def $lc0, implicit $sa0, implicit $lc0153    J2_jump %bb.2, implicit-def $pc154...155