146 lines · plain
1; RUN: opt -passes=loop-unroll-and-jam -unroll-runtime -unroll-partial-threshold=60 < %s -S | FileCheck %s2; RUN: opt -aa-pipeline=tbaa,basic-aa -passes='loop-unroll-and-jam' -unroll-runtime -unroll-partial-threshold=60 < %s -S | FileCheck %s3 4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"5target triple = "x86_64-unknown-linux-gnu"6 7; CHECK-LABEL: function8; The explicit metadata here should force this to be unroll and jammed 4 times (hence the %.pre60.3)9; CHECK: %.pre = phi i8 [ %.pre60.3, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %.pre.pre, %for.cond1.preheader.us.preheader.new ]10; CHECK: %indvars.iv.3 = phi i64 [ 0, %for.cond1.preheader.us ], [ %indvars.iv.next.3, %for.body4.us ]11define void @function(ptr noalias nocapture %dst, i32 %dst_stride, ptr noalias nocapture readonly %src, i32 %src_stride, i32 %A, i32 %B, i32 %C, i32 %D, i32 %width, i32 %height) {12entry:13 %idxprom = sext i32 %src_stride to i6414 %cmp52 = icmp sgt i32 %height, 015 br i1 %cmp52, label %for.cond1.preheader.lr.ph, label %for.cond.cleanup16 17for.cond1.preheader.lr.ph: ; preds = %entry18 %cmp249 = icmp sgt i32 %width, 019 %idx.ext = sext i32 %dst_stride to i6420 br i1 %cmp249, label %for.cond1.preheader.us.preheader, label %for.cond.cleanup21 22for.cond1.preheader.us.preheader: ; preds = %for.cond1.preheader.lr.ph23 %.pre.pre = load i8, ptr %src, align 124 %wide.trip.count = zext i32 %width to i6425 br label %for.cond1.preheader.us26 27for.cond1.preheader.us: ; preds = %for.cond1.for.cond.cleanup3_crit_edge.us, %for.cond1.preheader.us.preheader28 %.pre = phi i8 [ %.pre60, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %.pre.pre, %for.cond1.preheader.us.preheader ]29 %srcp.056.us.pn = phi ptr [ %srcp.056.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %src, %for.cond1.preheader.us.preheader ]30 %y.055.us = phi i32 [ %inc30.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ 0, %for.cond1.preheader.us.preheader ]31 %dst.addr.054.us = phi ptr [ %add.ptr.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %dst, %for.cond1.preheader.us.preheader ]32 %srcp.056.us = getelementptr inbounds i8, ptr %srcp.056.us.pn, i64 %idxprom33 %.pre60 = load i8, ptr %srcp.056.us, align 134 br label %for.body4.us35 36for.body4.us: ; preds = %for.body4.us, %for.cond1.preheader.us37 %0 = phi i8 [ %.pre60, %for.cond1.preheader.us ], [ %3, %for.body4.us ]38 %1 = phi i8 [ %.pre, %for.cond1.preheader.us ], [ %2, %for.body4.us ]39 %indvars.iv = phi i64 [ 0, %for.cond1.preheader.us ], [ %indvars.iv.next, %for.body4.us ]40 %conv.us = zext i8 %1 to i3241 %mul.us = mul nsw i32 %conv.us, %A42 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 143 %arrayidx8.us = getelementptr inbounds i8, ptr %srcp.056.us.pn, i64 %indvars.iv.next44 %2 = load i8, ptr %arrayidx8.us, align 145 %conv9.us = zext i8 %2 to i3246 %mul10.us = mul nsw i32 %conv9.us, %B47 %conv14.us = zext i8 %0 to i3248 %mul15.us = mul nsw i32 %conv14.us, %C49 %arrayidx19.us = getelementptr inbounds i8, ptr %srcp.056.us, i64 %indvars.iv.next50 %3 = load i8, ptr %arrayidx19.us, align 151 %conv20.us = zext i8 %3 to i3252 %mul21.us = mul nsw i32 %conv20.us, %D53 %add11.us = add i32 %mul.us, 3254 %add16.us = add i32 %add11.us, %mul10.us55 %add22.us = add i32 %add16.us, %mul15.us56 %add23.us = add i32 %add22.us, %mul21.us57 %4 = lshr i32 %add23.us, 658 %conv24.us = trunc i32 %4 to i859 %arrayidx26.us = getelementptr inbounds i8, ptr %dst.addr.054.us, i64 %indvars.iv60 store i8 %conv24.us, ptr %arrayidx26.us, align 161 %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count62 br i1 %exitcond, label %for.cond1.for.cond.cleanup3_crit_edge.us, label %for.body4.us63 64for.cond1.for.cond.cleanup3_crit_edge.us: ; preds = %for.body4.us65 %add.ptr.us = getelementptr inbounds i8, ptr %dst.addr.054.us, i64 %idx.ext66 %inc30.us = add nuw nsw i32 %y.055.us, 167 %exitcond58 = icmp eq i32 %inc30.us, %height68 br i1 %exitcond58, label %for.cond.cleanup, label %for.cond1.preheader.us, !llvm.loop !569 70for.cond.cleanup: ; preds = %for.cond1.for.cond.cleanup3_crit_edge.us, %for.cond1.preheader.lr.ph, %entry71 ret void72}73 74; CHECK-LABEL: function275; The explicit metadata here should force this to be unroll and jammed, but76; the count is left to thresholds. In this case 2 (hence %.pre60.1).77; CHECK: %.pre = phi i8 [ %.pre60.1, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %.pre.pre, %for.cond1.preheader.us.preheader.new ]78; CHECK: %indvars.iv.1 = phi i64 [ 0, %for.cond1.preheader.us ], [ %indvars.iv.next.1, %for.body4.us ]79define void @function2(ptr noalias nocapture %dst, i32 %dst_stride, ptr noalias nocapture readonly %src, i32 %src_stride, i32 %A, i32 %B, i32 %C, i32 %D, i32 %width, i32 %height) {80entry:81 %idxprom = sext i32 %src_stride to i6482 %cmp52 = icmp sgt i32 %height, 083 br i1 %cmp52, label %for.cond1.preheader.lr.ph, label %for.cond.cleanup84 85for.cond1.preheader.lr.ph: ; preds = %entry86 %cmp249 = icmp sgt i32 %width, 087 %idx.ext = sext i32 %dst_stride to i6488 br i1 %cmp249, label %for.cond1.preheader.us.preheader, label %for.cond.cleanup89 90for.cond1.preheader.us.preheader: ; preds = %for.cond1.preheader.lr.ph91 %.pre.pre = load i8, ptr %src, align 192 %wide.trip.count = zext i32 %width to i6493 br label %for.cond1.preheader.us94 95for.cond1.preheader.us: ; preds = %for.cond1.for.cond.cleanup3_crit_edge.us, %for.cond1.preheader.us.preheader96 %.pre = phi i8 [ %.pre60, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %.pre.pre, %for.cond1.preheader.us.preheader ]97 %srcp.056.us.pn = phi ptr [ %srcp.056.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %src, %for.cond1.preheader.us.preheader ]98 %y.055.us = phi i32 [ %inc30.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ 0, %for.cond1.preheader.us.preheader ]99 %dst.addr.054.us = phi ptr [ %add.ptr.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %dst, %for.cond1.preheader.us.preheader ]100 %srcp.056.us = getelementptr inbounds i8, ptr %srcp.056.us.pn, i64 %idxprom101 %.pre60 = load i8, ptr %srcp.056.us, align 1102 br label %for.body4.us103 104for.body4.us: ; preds = %for.body4.us, %for.cond1.preheader.us105 %0 = phi i8 [ %.pre60, %for.cond1.preheader.us ], [ %3, %for.body4.us ]106 %1 = phi i8 [ %.pre, %for.cond1.preheader.us ], [ %2, %for.body4.us ]107 %indvars.iv = phi i64 [ 0, %for.cond1.preheader.us ], [ %indvars.iv.next, %for.body4.us ]108 %conv.us = zext i8 %1 to i32109 %mul.us = mul nsw i32 %conv.us, %A110 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1111 %arrayidx8.us = getelementptr inbounds i8, ptr %srcp.056.us.pn, i64 %indvars.iv.next112 %2 = load i8, ptr %arrayidx8.us, align 1113 %conv9.us = zext i8 %2 to i32114 %mul10.us = mul nsw i32 %conv9.us, %B115 %conv14.us = zext i8 %0 to i32116 %mul15.us = mul nsw i32 %conv14.us, %C117 %arrayidx19.us = getelementptr inbounds i8, ptr %srcp.056.us, i64 %indvars.iv.next118 %3 = load i8, ptr %arrayidx19.us, align 1119 %conv20.us = zext i8 %3 to i32120 %mul21.us = mul nsw i32 %conv20.us, %D121 %add11.us = add i32 %mul.us, 32122 %add16.us = add i32 %add11.us, %mul10.us123 %add22.us = add i32 %add16.us, %mul15.us124 %add23.us = add i32 %add22.us, %mul21.us125 %4 = lshr i32 %add23.us, 6126 %conv24.us = trunc i32 %4 to i8127 %arrayidx26.us = getelementptr inbounds i8, ptr %dst.addr.054.us, i64 %indvars.iv128 store i8 %conv24.us, ptr %arrayidx26.us, align 1129 %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count130 br i1 %exitcond, label %for.cond1.for.cond.cleanup3_crit_edge.us, label %for.body4.us131 132for.cond1.for.cond.cleanup3_crit_edge.us: ; preds = %for.body4.us133 %add.ptr.us = getelementptr inbounds i8, ptr %dst.addr.054.us, i64 %idx.ext134 %inc30.us = add nuw nsw i32 %y.055.us, 1135 %exitcond58 = icmp eq i32 %inc30.us, %height136 br i1 %exitcond58, label %for.cond.cleanup, label %for.cond1.preheader.us, !llvm.loop !7137 138for.cond.cleanup: ; preds = %for.cond1.for.cond.cleanup3_crit_edge.us, %for.cond1.preheader.lr.ph, %entry139 ret void140}141 142!5 = distinct !{!5, !6}143!6 = !{!"llvm.loop.unroll_and_jam.count", i32 4}144!7 = distinct !{!7, !8}145!8 = !{!"llvm.loop.unroll_and_jam.enable"}146