1; REQUIRES: asserts 2; RUN: opt < %s -instcombine -licm -loop-unswitch -loop-unswitch-threshold=1000 -disable-output -stats 2>&1| FileCheck %s 3; Check no loop unswitch is done because unswitching of equality expr with 4; undef is unsafe before the freeze patch is committed. 5; CHECK-NOT: Number of branches unswitched 6 7define void @ham(i64 %arg) local_unnamed_addr { 8bb: 9 %tmp = icmp eq i64 %arg, 0 10 br i1 %tmp, label %bb3, label %bb1 11 12bb1: ; preds = %bb 13 %tmp2 = load volatile i64, i64* @global, align 8 14 br label %bb3 15 16bb3: ; preds = %bb1, %bb 17 %tmp4 = phi i64 [ %tmp2, %bb1 ], [ undef, %bb ] 18 %tmp5 = load i64, i64* @global.1, align 8 19 br label %bb6 20 21bb6: ; preds = %bb21, %bb3 22 %tmp7 = phi i64 [ 3, %bb21 ], [ %tmp5, %bb3 ] 23 %tmp8 = phi i64 [ %tmp25, %bb21 ], [ 0, %bb3 ] 24 %tmp9 = icmp eq i64 %tmp7, %arg 25 br i1 %tmp9, label %bb10, label %bb28 26 27bb10: ; preds = %bb6 28 %tmp11 = icmp eq i64 %tmp7, 0 29 br i1 %tmp11, label %bb21, label %bb12 30 31bb12: ; preds = %bb10 32 %tmp13 = load i64, i64* @global.2, align 8 33 %tmp14 = add nsw i64 %tmp13, 1 34 store i64 %tmp14, i64* @global.2, align 8 35 %tmp15 = load i64, i64* @global.3, align 8 36 %tmp16 = icmp eq i64 %tmp15, %tmp4 37 br i1 %tmp16, label %bb17, label %bb21 38 39bb17: ; preds = %bb12 40 %tmp18 = phi i64 [ %tmp15, %bb12 ] 41 %tmp19 = load i64, i64* @global.4, align 8 42 %tmp20 = add nsw i64 %tmp19, %tmp18 43 store i64 %tmp20, i64* @global.5, align 8 44 br label %bb29 45 46bb21: ; preds = %bb12, %bb10 47 %tmp22 = load i64, i64* @global.3, align 8 48 %tmp23 = load volatile i64, i64* @global, align 8 49 %tmp24 = add nsw i64 %tmp23, %tmp22 50 store i64 %tmp24, i64* @global.5, align 8 51 store i64 3, i64* @global.1, align 8 52 %tmp25 = add nsw i64 %tmp8, 1 53 %tmp26 = load i64, i64* @global.6, align 8 54 %tmp27 = icmp slt i64 %tmp25, %tmp26 55 br i1 %tmp27, label %bb6, label %bb28 56 57bb28: ; preds = %bb21, %bb6 58 br label %bb29 59 60bb29: ; preds = %bb28, %bb17 61 ret void 62} 63 64define void @zot(i64 %arg, i64 %arg1) local_unnamed_addr { 65bb: 66 %tmp = icmp eq i64 %arg, 0 67 %tmp2 = select i1 %tmp, i64 %arg1, i64 undef 68 %tmp3 = load i64, i64* @global.1, align 8 69 br label %bb4 70 71bb4: ; preds = %bb19, %bb 72 %tmp5 = phi i64 [ 3, %bb19 ], [ %tmp3, %bb ] 73 %tmp6 = phi i64 [ %tmp23, %bb19 ], [ 0, %bb ] 74 %tmp7 = icmp eq i64 %tmp5, %arg 75 br i1 %tmp7, label %bb8, label %bb26 76 77bb8: ; preds = %bb4 78 %tmp9 = icmp eq i64 %tmp5, 0 79 br i1 %tmp9, label %bb19, label %bb10 80 81bb10: ; preds = %bb8 82 %tmp11 = load i64, i64* @global.2, align 8 83 %tmp12 = add nsw i64 %tmp11, 1 84 store i64 %tmp12, i64* @global.2, align 8 85 %tmp13 = load i64, i64* @global.3, align 8 86 %tmp14 = icmp eq i64 %tmp13, %tmp2 87 br i1 %tmp14, label %bb15, label %bb19 88 89bb15: ; preds = %bb10 90 %tmp16 = phi i64 [ %tmp13, %bb10 ] 91 %tmp17 = load i64, i64* @global.4, align 8 92 %tmp18 = add nsw i64 %tmp17, %tmp16 93 store i64 %tmp18, i64* @global.5, align 8 94 br label %bb27 95 96bb19: ; preds = %bb10, %bb8 97 %tmp20 = load i64, i64* @global.3, align 8 98 %tmp21 = load volatile i64, i64* @global, align 8 99 %tmp22 = add nsw i64 %tmp21, %tmp20 100 store i64 %tmp22, i64* @global.5, align 8 101 store i64 3, i64* @global.1, align 8 102 %tmp23 = add nsw i64 %tmp6, 1 103 %tmp24 = load i64, i64* @global.6, align 8 104 %tmp25 = icmp slt i64 %tmp23, %tmp24 105 br i1 %tmp25, label %bb4, label %bb26 106 107bb26: ; preds = %bb19, %bb4 108 br label %bb27 109 110bb27: ; preds = %bb26, %bb15 111 ret void 112} 113 114@global = common global i64 0, align 8 115@global.1 = common global i64 0, align 8 116@global.2 = common global i64 0, align 8 117@global.3 = common global i64 0, align 8 118@global.4 = common global i64 0, align 8 119@global.5 = common global i64 0, align 8 120@global.6 = common global i64 0, align 8 121 122 123