1; RUN: llc < %s | FileCheck %s 2 3; grep 'Spill' |sed 's%.*\(-[0-9]\+(\%rsp)\).*%\1%g' |sort |uniq -d |awk '{if (/rsp/); exit -1}' 4; Check no spills to the same stack slot after hoisting. 5; CHECK: mov{{.}} %{{.*}}, [[SPOFFSET1:-?[0-9]*]](%rsp) 6; CHECK: mov{{.}} %{{.*}}, [[SPOFFSET2:-?[0-9]*]](%rsp) 7; CHECK: mov{{.}} %{{.*}}, [[SPOFFSET3:-?[0-9]*]](%rsp) 8; CHECK-NOT: mov{{.}} %{{.*}}, [[SPOFFSET1]](%rsp) 9; CHECK-NOT: mov{{.}} %{{.*}}, [[SPOFFSET2]](%rsp) 10; CHECK-NOT: mov{{.}} %{{.*}}, [[SPOFFSET3]](%rsp) 11 12target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 13target triple = "x86_64-unknown-linux-gnu" 14 15@a = external global i32*, align 8 16@b = external global i32, align 4 17@d = external global i32*, align 8 18 19; Function Attrs: norecurse noreturn nounwind uwtable 20define void @fn1(i32 %p1) { 21entry: 22 %tmp = load i32*, i32** @d, align 8 23 %tmp1 = load i32*, i32** @a, align 8 24 %tmp2 = sext i32 %p1 to i64 25 br label %for.cond 26 27for.cond: ; preds = %for.inc14, %entry 28 %indvar = phi i32 [ %indvar.next, %for.inc14 ], [ 0, %entry ] 29 %indvars.iv30.in = phi i32 [ %indvars.iv30, %for.inc14 ], [ %p1, %entry ] 30 %c.0 = phi i32 [ %inc15, %for.inc14 ], [ 1, %entry ] 31 %k.0 = phi i32 [ %k.1.lcssa, %for.inc14 ], [ undef, %entry ] 32 %tmp3 = icmp sgt i32 undef, 0 33 %smax52 = select i1 %tmp3, i32 undef, i32 0 34 %tmp4 = zext i32 %smax52 to i64 35 %tmp5 = icmp sgt i64 undef, %tmp4 36 %smax53 = select i1 %tmp5, i64 undef, i64 %tmp4 37 %tmp6 = add nsw i64 %smax53, 1 38 %tmp7 = sub nsw i64 %tmp6, %tmp4 39 %tmp8 = add nsw i64 %tmp7, -8 40 %tmp9 = sub i32 undef, %indvar 41 %tmp10 = icmp sgt i64 %tmp2, 0 42 %smax40 = select i1 %tmp10, i64 %tmp2, i64 0 43 %scevgep41 = getelementptr i32, i32* %tmp1, i64 %smax40 44 %indvars.iv30 = add i32 %indvars.iv30.in, -1 45 %tmp11 = icmp sgt i32 %indvars.iv30, 0 46 %smax = select i1 %tmp11, i32 %indvars.iv30, i32 0 47 %tmp12 = zext i32 %smax to i64 48 %sub = sub nsw i32 %p1, %c.0 49 %cmp = icmp sgt i32 %sub, 0 50 %sub. = select i1 %cmp, i32 %sub, i32 0 51 %cmp326 = icmp sgt i32 %k.0, %p1 52 br i1 %cmp326, label %for.cond4.preheader, label %for.body.preheader 53 54for.body.preheader: ; preds = %for.cond 55 br label %for.body 56 57for.cond4.preheader: ; preds = %for.body, %for.cond 58 %k.1.lcssa = phi i32 [ %k.0, %for.cond ], [ %add, %for.body ] 59 %cmp528 = icmp sgt i32 %sub., %p1 60 br i1 %cmp528, label %for.inc14, label %for.body6.preheader 61 62for.body6.preheader: ; preds = %for.cond4.preheader 63 br i1 undef, label %for.body6, label %min.iters.checked 64 65min.iters.checked: ; preds = %for.body6.preheader 66 br i1 undef, label %for.body6, label %vector.memcheck 67 68vector.memcheck: ; preds = %min.iters.checked 69 %bound1 = icmp ule i32* undef, %scevgep41 70 %memcheck.conflict = and i1 undef, %bound1 71 br i1 %memcheck.conflict, label %for.body6, label %vector.body.preheader 72 73vector.body.preheader: ; preds = %vector.memcheck 74 %lcmp.mod = icmp eq i64 undef, 0 75 br i1 %lcmp.mod, label %vector.body.preheader.split, label %vector.body.prol 76 77vector.body.prol: ; preds = %vector.body.prol, %vector.body.preheader 78 %prol.iter.cmp = icmp eq i64 undef, 0 79 br i1 %prol.iter.cmp, label %vector.body.preheader.split, label %vector.body.prol 80 81vector.body.preheader.split: ; preds = %vector.body.prol, %vector.body.preheader 82 %tmp13 = icmp ult i64 %tmp8, 24 83 br i1 %tmp13, label %middle.block, label %vector.body 84 85vector.body: ; preds = %vector.body, %vector.body.preheader.split 86 %index = phi i64 [ %index.next.3, %vector.body ], [ 0, %vector.body.preheader.split ] 87 %index.next = add i64 %index, 8 88 %offset.idx.1 = add i64 %tmp12, %index.next 89 %tmp14 = getelementptr inbounds i32, i32* %tmp, i64 %offset.idx.1 90 %tmp15 = bitcast i32* %tmp14 to <4 x i32>* 91 %wide.load.1 = load <4 x i32>, <4 x i32>* %tmp15, align 4 92 %tmp16 = getelementptr inbounds i32, i32* %tmp1, i64 %offset.idx.1 93 %tmp17 = bitcast i32* %tmp16 to <4 x i32>* 94 store <4 x i32> %wide.load.1, <4 x i32>* %tmp17, align 4 95 %index.next.3 = add i64 %index, 32 96 br i1 undef, label %middle.block, label %vector.body 97 98middle.block: ; preds = %vector.body, %vector.body.preheader.split 99 br i1 undef, label %for.inc14, label %for.body6 100 101for.body: ; preds = %for.body, %for.body.preheader 102 %k.127 = phi i32 [ %k.0, %for.body.preheader ], [ %add, %for.body ] 103 %add = add nsw i32 %k.127, 1 104 %tmp18 = load i32, i32* undef, align 4 105 store i32 %tmp18, i32* @b, align 4 106 br i1 undef, label %for.body, label %for.cond4.preheader 107 108for.body6: ; preds = %for.body6, %middle.block, %vector.memcheck, %min.iters.checked, %for.body6.preheader 109 %indvars.iv32 = phi i64 [ undef, %for.body6 ], [ %tmp12, %vector.memcheck ], [ %tmp12, %min.iters.checked ], [ %tmp12, %for.body6.preheader ], [ undef, %middle.block ] 110 %arrayidx8 = getelementptr inbounds i32, i32* %tmp, i64 %indvars.iv32 111 %tmp19 = load i32, i32* %arrayidx8, align 4 112 %arrayidx10 = getelementptr inbounds i32, i32* %tmp1, i64 %indvars.iv32 113 store i32 %tmp19, i32* %arrayidx10, align 4 114 %cmp5 = icmp slt i64 %indvars.iv32, undef 115 br i1 %cmp5, label %for.body6, label %for.inc14 116 117for.inc14: ; preds = %for.body6, %middle.block, %for.cond4.preheader 118 %inc15 = add nuw nsw i32 %c.0, 1 119 %indvar.next = add i32 %indvar, 1 120 br label %for.cond 121} 122