1*0a6a1f1dSLionel Sambuc; RUN: llc < %s -o - -mtriple=x86_64-apple-macosx | FileCheck %s 2*0a6a1f1dSLionel Sambuc; Test case for the recoloring of broken hints. 3*0a6a1f1dSLionel Sambuc; This is tricky to have something reasonably small to kick this optimization since 4*0a6a1f1dSLionel Sambuc; it requires that spliting and spilling occur. 5*0a6a1f1dSLionel Sambuc; The bottom line is that this test case is fragile. 6*0a6a1f1dSLionel Sambuc; This was reduced from the make_list function from the llvm-testsuite: 7*0a6a1f1dSLionel Sambuc; SingleSource/Benchmarks/McGill/chomp.c 8*0a6a1f1dSLionel Sambuc 9*0a6a1f1dSLionel Sambuctarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 10*0a6a1f1dSLionel Sambuctarget triple = "x86_64-apple-macosx10.9.0" 11*0a6a1f1dSLionel Sambuc 12*0a6a1f1dSLionel Sambuc%struct._list = type { i32*, %struct._list* } 13*0a6a1f1dSLionel Sambuc 14*0a6a1f1dSLionel Sambuc@ncol = external global i32, align 4 15*0a6a1f1dSLionel Sambuc@nrow = external global i32, align 4 16*0a6a1f1dSLionel Sambuc 17*0a6a1f1dSLionel Sambucdeclare noalias i32* @copy_data() 18*0a6a1f1dSLionel Sambuc 19*0a6a1f1dSLionel Sambucdeclare noalias i8* @malloc(i64) 20*0a6a1f1dSLionel Sambuc 21*0a6a1f1dSLionel Sambucdeclare i32 @get_value() 22*0a6a1f1dSLionel Sambuc 23*0a6a1f1dSLionel Sambucdeclare i32 @in_wanted(i32* nocapture readonly) 24*0a6a1f1dSLionel Sambuc 25*0a6a1f1dSLionel Sambucdeclare noalias i32* @make_data() 26*0a6a1f1dSLionel Sambuc 27*0a6a1f1dSLionel Sambuc; CHECK-LABEL: make_list: 28*0a6a1f1dSLionel Sambuc; Function prologue. 29*0a6a1f1dSLionel Sambuc; CHECK: pushq 30*0a6a1f1dSLionel Sambuc; CHECK: subq ${{[0-9]+}}, %rsp 31*0a6a1f1dSLionel Sambuc; Move the first argument (%data) into a temporary register. 32*0a6a1f1dSLionel Sambuc; It will not survive the call to malloc otherwise. 33*0a6a1f1dSLionel Sambuc; CHECK: movq %rdi, [[ARG1:%r[0-9a-z]+]] 34*0a6a1f1dSLionel Sambuc; CHECK: callq _malloc 35*0a6a1f1dSLionel Sambuc; Compute %data - 1 as used for load in land.rhs.i (via the variable %indvars.iv.next.i). 36*0a6a1f1dSLionel Sambuc; CHECK: addq $-4, [[ARG1]] 37*0a6a1f1dSLionel Sambuc; We use to produce a useless copy here and move %data in another temporary register. 38*0a6a1f1dSLionel Sambuc; CHECK-NOT: movq [[ARG1]] 39*0a6a1f1dSLionel Sambuc; End of the first basic block. 40*0a6a1f1dSLionel Sambuc; CHECK: .align 41*0a6a1f1dSLionel Sambuc; Now check that %data is used in an address computation. 42*0a6a1f1dSLionel Sambuc; CHECK: leaq ([[ARG1]] 43*0a6a1f1dSLionel Sambucdefine %struct._list* @make_list(i32* nocapture readonly %data, i32* nocapture %value, i32* nocapture %all) { 44*0a6a1f1dSLionel Sambucentry: 45*0a6a1f1dSLionel Sambuc %call = tail call i8* @malloc(i64 16) 46*0a6a1f1dSLionel Sambuc %next = getelementptr inbounds i8* %call, i64 8 47*0a6a1f1dSLionel Sambuc %tmp = bitcast i8* %next to %struct._list** 48*0a6a1f1dSLionel Sambuc %tmp2 = bitcast i8* %call to %struct._list* 49*0a6a1f1dSLionel Sambuc %.pre78 = load i32* @ncol, align 4 50*0a6a1f1dSLionel Sambuc br label %for.cond1.preheader 51*0a6a1f1dSLionel Sambuc 52*0a6a1f1dSLionel Sambucfor.cond1.preheader: ; preds = %for.inc32, %entry 53*0a6a1f1dSLionel Sambuc %tmp4 = phi i32 [ %.pre78, %entry ], [ 0, %for.inc32 ] 54*0a6a1f1dSLionel Sambuc %current.077 = phi %struct._list* [ %tmp2, %entry ], [ %current.1.lcssa, %for.inc32 ] 55*0a6a1f1dSLionel Sambuc %cmp270 = icmp eq i32 %tmp4, 0 56*0a6a1f1dSLionel Sambuc br i1 %cmp270, label %for.inc32, label %for.body3 57*0a6a1f1dSLionel Sambuc 58*0a6a1f1dSLionel Sambucfor.body3: ; preds = %if.end31, %for.cond1.preheader 59*0a6a1f1dSLionel Sambuc %current.173 = phi %struct._list* [ %current.2, %if.end31 ], [ %current.077, %for.cond1.preheader ] 60*0a6a1f1dSLionel Sambuc %row.172 = phi i32 [ %row.3, %if.end31 ], [ 0, %for.cond1.preheader ] 61*0a6a1f1dSLionel Sambuc %col.071 = phi i32 [ %inc, %if.end31 ], [ 0, %for.cond1.preheader ] 62*0a6a1f1dSLionel Sambuc %call4 = tail call i32* @make_data() 63*0a6a1f1dSLionel Sambuc %tmp5 = load i32* @ncol, align 4 64*0a6a1f1dSLionel Sambuc %tobool14.i = icmp eq i32 %tmp5, 0 65*0a6a1f1dSLionel Sambuc br i1 %tobool14.i, label %while.cond.i, label %while.body.lr.ph.i 66*0a6a1f1dSLionel Sambuc 67*0a6a1f1dSLionel Sambucwhile.body.lr.ph.i: ; preds = %for.body3 68*0a6a1f1dSLionel Sambuc %tmp6 = sext i32 %tmp5 to i64 69*0a6a1f1dSLionel Sambuc br label %while.body.i 70*0a6a1f1dSLionel Sambuc 71*0a6a1f1dSLionel Sambucwhile.body.i: ; preds = %while.body.i, %while.body.lr.ph.i 72*0a6a1f1dSLionel Sambuc %indvars.iv.i = phi i64 [ %tmp6, %while.body.lr.ph.i ], [ %indvars.iv.next.i, %while.body.i ] 73*0a6a1f1dSLionel Sambuc %indvars.iv.next.i = add nsw i64 %indvars.iv.i, -1 74*0a6a1f1dSLionel Sambuc %tmp9 = trunc i64 %indvars.iv.next.i to i32 75*0a6a1f1dSLionel Sambuc %tobool.i = icmp eq i32 %tmp9, 0 76*0a6a1f1dSLionel Sambuc br i1 %tobool.i, label %while.cond.i, label %while.body.i 77*0a6a1f1dSLionel Sambuc 78*0a6a1f1dSLionel Sambucwhile.cond.i: ; preds = %land.rhs.i, %while.body.i, %for.body3 79*0a6a1f1dSLionel Sambuc %indvars.iv.i64 = phi i64 [ %indvars.iv.next.i65, %land.rhs.i ], [ 0, %for.body3 ], [ %tmp6, %while.body.i ] 80*0a6a1f1dSLionel Sambuc %indvars.iv.next.i65 = add nsw i64 %indvars.iv.i64, -1 81*0a6a1f1dSLionel Sambuc %tmp10 = trunc i64 %indvars.iv.i64 to i32 82*0a6a1f1dSLionel Sambuc %tobool.i66 = icmp eq i32 %tmp10, 0 83*0a6a1f1dSLionel Sambuc br i1 %tobool.i66, label %if.else, label %land.rhs.i 84*0a6a1f1dSLionel Sambuc 85*0a6a1f1dSLionel Sambucland.rhs.i: ; preds = %while.cond.i 86*0a6a1f1dSLionel Sambuc %arrayidx.i67 = getelementptr inbounds i32* %call4, i64 %indvars.iv.next.i65 87*0a6a1f1dSLionel Sambuc %tmp11 = load i32* %arrayidx.i67, align 4 88*0a6a1f1dSLionel Sambuc %arrayidx2.i68 = getelementptr inbounds i32* %data, i64 %indvars.iv.next.i65 89*0a6a1f1dSLionel Sambuc %tmp12 = load i32* %arrayidx2.i68, align 4 90*0a6a1f1dSLionel Sambuc %cmp.i69 = icmp eq i32 %tmp11, %tmp12 91*0a6a1f1dSLionel Sambuc br i1 %cmp.i69, label %while.cond.i, label %equal_data.exit 92*0a6a1f1dSLionel Sambuc 93*0a6a1f1dSLionel Sambucequal_data.exit: ; preds = %land.rhs.i 94*0a6a1f1dSLionel Sambuc %cmp3.i = icmp slt i32 %tmp10, 1 95*0a6a1f1dSLionel Sambuc br i1 %cmp3.i, label %if.else, label %if.then 96*0a6a1f1dSLionel Sambuc 97*0a6a1f1dSLionel Sambucif.then: ; preds = %equal_data.exit 98*0a6a1f1dSLionel Sambuc %next7 = getelementptr inbounds %struct._list* %current.173, i64 0, i32 1 99*0a6a1f1dSLionel Sambuc %tmp14 = load %struct._list** %next7, align 8 100*0a6a1f1dSLionel Sambuc %next12 = getelementptr inbounds %struct._list* %tmp14, i64 0, i32 1 101*0a6a1f1dSLionel Sambuc store %struct._list* null, %struct._list** %next12, align 8 102*0a6a1f1dSLionel Sambuc %tmp15 = load %struct._list** %next7, align 8 103*0a6a1f1dSLionel Sambuc %tmp16 = load i32* %value, align 4 104*0a6a1f1dSLionel Sambuc %cmp14 = icmp eq i32 %tmp16, 1 105*0a6a1f1dSLionel Sambuc %.tmp16 = select i1 %cmp14, i32 0, i32 %tmp16 106*0a6a1f1dSLionel Sambuc %tmp18 = load i32* %all, align 4 107*0a6a1f1dSLionel Sambuc %tmp19 = or i32 %tmp18, %.tmp16 108*0a6a1f1dSLionel Sambuc %tmp20 = icmp eq i32 %tmp19, 0 109*0a6a1f1dSLionel Sambuc br i1 %tmp20, label %if.then19, label %if.end31 110*0a6a1f1dSLionel Sambuc 111*0a6a1f1dSLionel Sambucif.then19: ; preds = %if.then 112*0a6a1f1dSLionel Sambuc %call21 = tail call i32 @in_wanted(i32* %call4) 113*0a6a1f1dSLionel Sambuc br label %if.end31 114*0a6a1f1dSLionel Sambuc 115*0a6a1f1dSLionel Sambucif.else: ; preds = %equal_data.exit, %while.cond.i 116*0a6a1f1dSLionel Sambuc %cmp26 = icmp eq i32 %col.071, 0 117*0a6a1f1dSLionel Sambuc %.row.172 = select i1 %cmp26, i32 0, i32 %row.172 118*0a6a1f1dSLionel Sambuc %sub30 = add nsw i32 %tmp5, -1 119*0a6a1f1dSLionel Sambuc br label %if.end31 120*0a6a1f1dSLionel Sambuc 121*0a6a1f1dSLionel Sambucif.end31: ; preds = %if.else, %if.then19, %if.then 122*0a6a1f1dSLionel Sambuc %col.1 = phi i32 [ %sub30, %if.else ], [ 0, %if.then ], [ 0, %if.then19 ] 123*0a6a1f1dSLionel Sambuc %row.3 = phi i32 [ %.row.172, %if.else ], [ %row.172, %if.then ], [ 0, %if.then19 ] 124*0a6a1f1dSLionel Sambuc %current.2 = phi %struct._list* [ %current.173, %if.else ], [ %tmp15, %if.then ], [ %tmp15, %if.then19 ] 125*0a6a1f1dSLionel Sambuc %inc = add nsw i32 %col.1, 1 126*0a6a1f1dSLionel Sambuc %tmp25 = load i32* @ncol, align 4 127*0a6a1f1dSLionel Sambuc %cmp2 = icmp eq i32 %inc, %tmp25 128*0a6a1f1dSLionel Sambuc br i1 %cmp2, label %for.cond1.for.inc32_crit_edge, label %for.body3 129*0a6a1f1dSLionel Sambuc 130*0a6a1f1dSLionel Sambucfor.cond1.for.inc32_crit_edge: ; preds = %if.end31 131*0a6a1f1dSLionel Sambuc %.pre79 = load i32* @nrow, align 4 132*0a6a1f1dSLionel Sambuc br label %for.inc32 133*0a6a1f1dSLionel Sambuc 134*0a6a1f1dSLionel Sambucfor.inc32: ; preds = %for.cond1.for.inc32_crit_edge, %for.cond1.preheader 135*0a6a1f1dSLionel Sambuc %tmp26 = phi i32 [ %.pre79, %for.cond1.for.inc32_crit_edge ], [ 0, %for.cond1.preheader ] 136*0a6a1f1dSLionel Sambuc %current.1.lcssa = phi %struct._list* [ %current.2, %for.cond1.for.inc32_crit_edge ], [ %current.077, %for.cond1.preheader ] 137*0a6a1f1dSLionel Sambuc %row.1.lcssa = phi i32 [ %row.3, %for.cond1.for.inc32_crit_edge ], [ 0, %for.cond1.preheader ] 138*0a6a1f1dSLionel Sambuc %inc33 = add nsw i32 %row.1.lcssa, 1 139*0a6a1f1dSLionel Sambuc %cmp = icmp eq i32 %inc33, %tmp26 140*0a6a1f1dSLionel Sambuc br i1 %cmp, label %for.end34, label %for.cond1.preheader 141*0a6a1f1dSLionel Sambuc 142*0a6a1f1dSLionel Sambucfor.end34: ; preds = %for.inc32 143*0a6a1f1dSLionel Sambuc %.pre = load %struct._list** %tmp, align 8 144*0a6a1f1dSLionel Sambuc ret %struct._list* %.pre 145*0a6a1f1dSLionel Sambuc} 146