1; RUN: llc < %s -march=x86 | FileCheck %s 2; 3; Test RegistersDefinedFromSameValue. We have multiple copies of the same vreg: 4; while.body85.i: 5; vreg1 = copy vreg2 6; vreg2 = add 7; critical edge from land.lhs.true.i -> if.end117.i: 8; vreg27 = vreg2 9; critical edge from land.lhs.true103.i -> if.end117.i: 10; vreg27 = vreg2 11; if.then108.i: 12; vreg27 = vreg1 13; 14; Prior to fixing PR10920 401.bzip miscompile, the coalescer would 15; consider vreg1 and vreg27 to be copies of the same value. It would 16; then remove one of the critical edge copes, which cannot safely be removed. 17; 18; CHECK: # %while.body85.i 19; CHECK-NOT: # % 20; CHECK-NOT: add 21; CHECK: movl %[[POSTR:e[abcdxi]+]], %[[PRER:e[abcdxi]+]] 22; CHECK: addl %{{.*}}, %[[POSTR]] 23; CHECK: # %while.end.i 24; CHECK: movl %[[POSTR]], %[[USER:e[abcdxi]+]] 25; CHECK: # %land.lhs.true.i 26; CHECK: movl %[[POSTR]], %[[USER]] 27; CHECK: # %land.lhs.true103.i 28; CHECK: movl %[[POSTR]], %[[USER]] 29; CHECK: # %if.then108.i 30; [[PRER] live out, so nothing on this path should define it. 31; CHECK-NOT: , %[[PRER]] 32; CHECK: # %if.end117.i 33 34target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" 35 36@.str3 = external unnamed_addr constant [59 x i8], align 1 37 38define void @BZ2_compressBlock() nounwind ssp { 39entry: 40 br i1 undef, label %if.then68, label %if.end85 41 42if.then68: ; preds = %entry 43 br label %for.body.i.i 44 45for.body.i.i: ; preds = %for.inc.i.i, %if.then68 46 br i1 undef, label %for.inc.i.i, label %if.then.i.i 47 48if.then.i.i: ; preds = %for.body.i.i 49 br label %for.inc.i.i 50 51for.inc.i.i: ; preds = %if.then.i.i, %for.body.i.i 52 br i1 undef, label %makeMaps_e.exit.i, label %for.body.i.i 53 54makeMaps_e.exit.i: ; preds = %for.inc.i.i 55 br i1 undef, label %for.cond19.preheader.i, label %for.cond.for.cond19.preheader_crit_edge.i 56 57for.cond.for.cond19.preheader_crit_edge.i: ; preds = %makeMaps_e.exit.i 58 unreachable 59 60for.cond19.preheader.i: ; preds = %makeMaps_e.exit.i 61 br i1 undef, label %for.body25.lr.ph.i, label %for.cond33.preheader.i 62 63for.body25.lr.ph.i: ; preds = %for.cond19.preheader.i 64 br label %for.body25.i 65 66for.cond33.preheader.i: ; preds = %for.body25.i, %for.cond19.preheader.i 67 br i1 undef, label %if.then.i, label %if.end.i 68 69for.body25.i: ; preds = %for.body25.i, %for.body25.lr.ph.i 70 br i1 undef, label %for.body25.i, label %for.cond33.preheader.i 71 72if.then.i: ; preds = %for.cond33.preheader.i 73 br label %if.end.i 74 75if.end.i: ; preds = %if.then.i, %for.cond33.preheader.i 76 br i1 undef, label %for.inc27.us.5.i, label %for.end30.i 77 78for.end30.i: ; preds = %for.inc27.us.5.i, %if.end.i 79 br i1 undef, label %if.end36.i, label %if.then35.i 80 81if.then35.i: ; preds = %for.end30.i 82 unreachable 83 84if.end36.i: ; preds = %for.end30.i 85 %sub83.i = add nsw i32 undef, 1 86 br label %while.body.i188 87 88for.cond182.preheader.i: ; preds = %for.end173.i 89 br i1 undef, label %for.inc220.us.i, label %while.body300.preheader.i 90 91while.body.i188: ; preds = %for.end173.i, %if.end36.i 92 %gs.0526.i = phi i32 [ 0, %if.end36.i ], [ %add177.i, %for.end173.i ] 93 %or.cond514517.i = and i1 false, undef 94 br i1 %or.cond514517.i, label %while.body85.i, label %if.end117.i 95 96while.body85.i: ; preds = %while.body85.i, %while.body.i188 97 %aFreq.0518.i = phi i32 [ %add93.i, %while.body85.i ], [ 0, %while.body.i188 ] 98 %inc87.i = add nsw i32 0, 1 99 %tmp91.i = load i32* undef, align 4, !tbaa !0 100 %add93.i = add nsw i32 %tmp91.i, %aFreq.0518.i 101 %or.cond514.i = and i1 undef, false 102 br i1 %or.cond514.i, label %while.body85.i, label %while.end.i 103 104while.end.i: ; preds = %while.body85.i 105 br i1 undef, label %land.lhs.true.i, label %if.end117.i 106 107land.lhs.true.i: ; preds = %while.end.i 108 br i1 undef, label %land.lhs.true103.i, label %if.end117.i 109 110land.lhs.true103.i: ; preds = %land.lhs.true.i 111 br i1 undef, label %if.then108.i, label %if.end117.i 112 113if.then108.i: ; preds = %land.lhs.true103.i 114 br label %if.end117.i 115 116if.end117.i: ; preds = %if.then108.i, %land.lhs.true103.i, %land.lhs.true.i, %while.end.i, %while.body.i188 117 %aFreq.1.i = phi i32 [ %aFreq.0518.i, %if.then108.i ], [ %add93.i, %land.lhs.true103.i ], [ %add93.i, %land.lhs.true.i ], [ %add93.i, %while.end.i ], [ 0, %while.body.i188 ] 118 %ge.1.i = phi i32 [ 0, %if.then108.i ], [ %inc87.i, %land.lhs.true103.i ], [ %inc87.i, %land.lhs.true.i ], [ %inc87.i, %while.end.i ], [ 0, %while.body.i188 ] 119 br i1 undef, label %if.then122.i, label %for.cond138.preheader.i 120 121if.then122.i: ; preds = %if.end117.i 122 call void (...)* @fprintf(i32 undef, i32 %gs.0526.i, i32 %ge.1.i, i32 %aFreq.1.i, double undef) nounwind 123 br label %for.cond138.preheader.i 124 125for.cond138.preheader.i: ; preds = %if.then122.i, %if.end117.i 126 br i1 undef, label %for.body143.lr.ph.i, label %for.end173.i 127 128for.body143.lr.ph.i: ; preds = %for.cond138.preheader.i 129 br label %for.body143.i 130 131for.body143.i: ; preds = %for.body143.i, %for.body143.lr.ph.i 132 br i1 undef, label %for.end173.i, label %for.body143.i 133 134for.end173.i: ; preds = %for.body143.i, %for.cond138.preheader.i 135 %add177.i = add nsw i32 %ge.1.i, 1 136 %cmp73.i = icmp sgt i32 undef, 0 137 br i1 %cmp73.i, label %while.body.i188, label %for.cond182.preheader.i 138 139for.inc220.us.i: ; preds = %for.cond182.preheader.i 140 unreachable 141 142while.body300.preheader.i: ; preds = %for.cond182.preheader.i 143 br i1 undef, label %for.end335.i, label %while.end2742.i 144 145for.end335.i: ; preds = %for.end2039.i, %while.body300.preheader.i 146 br label %for.body2021.i 147 148for.body2021.i: ; preds = %for.body2021.i, %for.end335.i 149 br i1 undef, label %for.body2021.i, label %for.end2039.i 150 151for.end2039.i: ; preds = %for.body2021.i 152 br label %for.end335.i 153 154while.end2742.i: ; preds = %while.body300.preheader.i 155 br i1 undef, label %if.then2748.i, label %for.body2778.i 156 157if.then2748.i: ; preds = %while.end2742.i 158 unreachable 159 160for.body2778.i: ; preds = %while.end2742.i 161 unreachable 162 163for.inc27.us.5.i: ; preds = %if.end.i 164 br label %for.end30.i 165 166if.end85: ; preds = %entry 167 ret void 168} 169 170declare void @fprintf(...) nounwind 171 172!0 = metadata !{metadata !"int", metadata !1} 173!1 = metadata !{metadata !"omnipotent char", metadata !2} 174!2 = metadata !{metadata !"Simple C/C++ TBAA", null} 175