175 lines · plain
1; RUN: llc -verify-machineinstrs -ppc-reduce-cr-logicals \2; RUN: -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s3 4; Test case is reduced from the snappy benchmark.5; Verify MachineLICM will always hoist trivially rematerializable instructions even when register pressure is high.6 7%"class.snappy::SnappyDecompressor" = type <{ ptr, ptr, ptr, i32, i8, [5 x i8], [6 x i8] }>8%"class.snappy::Source" = type { ptr }9%"struct.snappy::iovec" = type { ptr, i64 }10%"class.snappy::SnappyIOVecWriter" = type { ptr, i64, i64, i64, i64, i64 }11 12@_ZN6snappy8internalL10char_tableE = internal unnamed_addr constant [5 x i16] [i16 1, i16 2052, i16 4097, i16 8193, i16 2], align 213@_ZN6snappy8internalL8wordmaskE = internal unnamed_addr constant [5 x i32] [i32 0, i32 255, i32 65535, i32 16777215, i32 -1], align 414 15; Function Attrs: argmemonly nounwind16declare void @llvm.memmove.p0.p0.i64(ptr nocapture, ptr nocapture readonly, i64, i1) #217; Function Attrs: argmemonly nounwind18declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #219 20define linkonce_odr void @ZN6snappyDecompressor_(ptr %this, ptr %writer) {21; CHECK-LABEL: ZN6snappyDecompressor_:22; CHECK: # %bb.0: # %entry23; CHECK: addis 4, 2, .L_MergedGlobals@toc@ha24; CHECK: addi 26, 4, .L_MergedGlobals@toc@l25; CHECK: .LBB0_2: # %for.cond26; CHECK-NOT: addis {{[0-9]+}}, 2, .L_MergedGlobals@toc@ha27; CHECK: bctrl28entry:29 %ip_limit_ = getelementptr inbounds %"class.snappy::SnappyDecompressor", ptr %this, i64 0, i32 230 %curr_iov_index_.i = getelementptr inbounds %"class.snappy::SnappyIOVecWriter", ptr %writer, i64 0, i32 231 %curr_iov_written_.i = getelementptr inbounds %"class.snappy::SnappyIOVecWriter", ptr %writer, i64 0, i32 332 br label %for.cond33 34for.cond: ; preds = %if.end82, %if.then56, %if.end49, %entry35 %ip.0 = phi ptr [ null, %entry ], [ %add.ptr50, %if.end49 ], [ null, %if.then56 ], [ undef, %if.end82 ]36 %incdec.ptr = getelementptr inbounds i8, ptr %ip.0, i64 137 %0 = load i8, ptr %ip.0, align 138 %conv = zext i8 %0 to i3239 br i1 undef, label %if.then7, label %if.else40 41if.then7: ; preds = %for.cond42 %1 = lshr i32 %conv, 243 %add = add nuw nsw i32 %1, 144 %conv9 = zext i32 %add to i6445 %2 = load i64, ptr %ip_limit_, align 846 %sub.ptr.sub13 = sub i64 %2, 047 %3 = load i64, ptr undef, align 848 %4 = load i64, ptr null, align 849 %sub.i = sub i64 %3, %450 %cmp.i = icmp ult i32 %add, 1751 %cmp2.i = icmp ugt i64 %sub.ptr.sub13, 2052 %or.cond.i = and i1 %cmp.i, %cmp2.i53 %cmp4.i = icmp ugt i64 %sub.i, 1554 %or.cond13.i = and i1 %or.cond.i, %cmp4.i55 br i1 %or.cond13.i, label %land.lhs.true5.i, label %if.end1756 57land.lhs.true5.i: ; preds = %if.then758 %5 = load ptr, ptr undef, align 859 %6 = load i64, ptr %curr_iov_index_.i, align 860 %7 = load i64, ptr %curr_iov_written_.i, align 861 %sub6.i = sub i64 0, %762 %cmp7.i = icmp ugt i64 %sub6.i, 1563 br i1 %cmp7.i, label %cleanup102, label %if.end1764 65if.end17: ; preds = %land.lhs.true5.i, %if.then766 %sub = add nsw i64 %conv9, -6067 %8 = load i32, ptr undef, align 468 %arrayidx = getelementptr inbounds [5 x i32], ptr @_ZN6snappy8internalL8wordmaskE, i64 0, i64 %sub69 %9 = load i32, ptr %arrayidx, align 470 %and21 = and i32 %9, %871 %add22 = add i32 %and21, 172 %conv23 = zext i32 %add22 to i6473 %add.ptr24 = getelementptr inbounds i8, ptr %incdec.ptr, i64 %sub74 br label %if.end2575 76if.end25: ; preds = %if.end1777 %sub.ptr.rhs.cast28 = ptrtoint ptr %add.ptr24 to i6478 %cmp30233 = icmp ugt i64 %conv23, 079 br i1 %cmp30233, label %while.body.preheader, label %while.end80 81while.body.preheader: ; preds = %if.end2582 %add.i158256 = add i64 %4, 083 %cmp.i160257 = icmp ugt i64 %add.i158256, %384 br i1 %cmp.i160257, label %cleanup105, label %while.cond.preheader.i85 86while.cond.preheader.i: ; preds = %while.body.preheader87 %call39 = call ptr undef(ptr undef, ptr nonnull undef)88 unreachable89 90while.end: ; preds = %if.end2591 br label %while.cond.preheader.i17692 93while.cond.preheader.i176: ; preds = %while.end94 br i1 undef, label %if.end49, label %while.body.lr.ph.i18295 96while.body.lr.ph.i182: ; preds = %while.cond.preheader.i17697 %.pre.i181 = load i64, ptr %curr_iov_written_.i, align 898 %10 = load ptr, ptr undef, align 899 %11 = load i64, ptr %curr_iov_index_.i, align 8100 %iov_len.i185 = getelementptr inbounds %"struct.snappy::iovec", ptr %10, i64 %11, i32 1101 %12 = load i64, ptr %iov_len.i185, align 8102 br label %cond.end.i190103 104cond.end.i190: ; preds = %while.body.lr.ph.i182105 br i1 undef, label %if.end18.i207, label %if.then10.i193106 107if.then10.i193: ; preds = %cond.end.i190108 %add12.i191 = add i64 %11, 1109 %iov_len22.phi.trans.insert.i194 = getelementptr inbounds %"struct.snappy::iovec", ptr %10, i64 %add12.i191, i32 1110 %.pre48.i195 = load i64, ptr %iov_len22.phi.trans.insert.i194, align 8111 br label %if.end18.i207112 113if.end18.i207: ; preds = %if.then10.i193, %cond.end.i190114 %13 = phi i64 [ %.pre.i181, %cond.end.i190 ], [ 0, %if.then10.i193 ]115 %14 = phi i64 [ %12, %cond.end.i190 ], [ %.pre48.i195, %if.then10.i193 ]116 %15 = phi i64 [ %11, %cond.end.i190 ], [ %add12.i191, %if.then10.i193 ]117 %sub.i197 = sub i64 %14, %13118 %cmp.i.i198 = icmp ult i64 %sub.i197, %conv23119 %.sroa.speculated.i199 = select i1 %cmp.i.i198, i64 %sub.i197, i64 %conv23120 %iov_base.i.i200 = getelementptr inbounds %"struct.snappy::iovec", ptr %10, i64 %15, i32 0121 %16 = load ptr, ptr %iov_base.i.i200, align 8122 %add.ptr.i.i201 = getelementptr inbounds i8, ptr %16, i64 %13123 call void @llvm.memcpy.p0.p0.i64(ptr %add.ptr.i.i201, ptr %add.ptr24, i64 %.sroa.speculated.i199, i1 false) #12124 %add30.i203 = add i64 0, %.sroa.speculated.i199125 store i64 %add30.i203, ptr null, align 8126 %.pre245 = load i64, ptr %ip_limit_, align 8127 br label %if.end49128 129if.end49: ; preds = %if.end18.i207, %while.cond.preheader.i176130 %17 = phi i64 [ %.pre245, %if.end18.i207 ], [ %2, %while.cond.preheader.i176 ]131 %add.ptr50 = getelementptr inbounds i8, ptr %add.ptr24, i64 %conv23132 %sub.ptr.sub54 = sub i64 %17, 0133 %cmp55 = icmp slt i64 %sub.ptr.sub54, 5134 br i1 %cmp55, label %if.then56, label %for.cond135 136if.then56: ; preds = %if.end49137 br label %for.cond138 139if.else: ; preds = %for.cond140 %idxprom = zext i8 %0 to i64141 %arrayidx68 = getelementptr inbounds [5 x i16], ptr @_ZN6snappy8internalL10char_tableE, i64 0, i64 %idxprom142 %18 = load i16, ptr %arrayidx68, align 2143 %conv69 = zext i16 %18 to i64144 %19 = load i32, ptr undef, align 4145 %shr71 = lshr i64 %conv69, 11146 %arrayidx72 = getelementptr inbounds [5 x i32], ptr @_ZN6snappy8internalL8wordmaskE, i64 0, i64 %shr71147 %20 = load i32, ptr %arrayidx72, align 4148 %and73 = and i32 %20, %19149 %conv74 = zext i32 %and73 to i64150 %add79 = add nuw nsw i64 0, %conv74151 %call80 = call zeroext i1 @_ZN6snappy17SnappyIOVecWriterAppendFromSelfEmm(ptr %writer, i64 %add79, i64 undef)152 br i1 %call80, label %if.end82, label %cleanup105153 154if.end82: ; preds = %if.else155 br label %for.cond156 157cleanup102: ; preds = %land.lhs.true5.i158 %iov_base.i.i = getelementptr inbounds %"struct.snappy::iovec", ptr %5, i64 %6, i32 0159 %21 = load ptr, ptr %iov_base.i.i, align 8160 %add.ptr.i.i = getelementptr inbounds i8, ptr %21, i64 %7161 call void @llvm.memmove.p0.p0.i64(ptr %add.ptr.i.i, ptr %incdec.ptr, i64 16, i1 false) #12162 %22 = load <2 x i64>, ptr %curr_iov_written_.i, align 8163 %23 = insertelement <2 x i64> undef, i64 %conv9, i32 0164 %24 = shufflevector <2 x i64> %23, <2 x i64> undef, <2 x i32> zeroinitializer165 %25 = add <2 x i64> %22, %24166 store <2 x i64> %25, ptr undef, align 8167 unreachable168 169cleanup105: ; preds = %if.else, %while.body.preheader170 ret void171}172 173; Function Attrs: inlinehint174declare zeroext i1 @_ZN6snappy17SnappyIOVecWriterAppendFromSelfEmm(ptr, i64, i64) local_unnamed_addr #10 align 2175