1;RUN: opt -passes=gvn -S < %s | FileCheck %s 2 3target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n8:16:32-S64" 4target triple = "thumbv7--linux-gnueabi" 5 6%struct.a = type { i16, i16, [1 x %union.a] } 7%union.a = type { i32 } 8 9@length = external global [0 x i32], align 4 10 11; Function Attrs: nounwind 12define fastcc void @foo(ptr nocapture readonly %x) { 13;CHECK-LABEL: foo 14entry: 15 br label %bb0 16 17bb0: ; preds = %land.lhs.true, %entry 18;CHECK: bb0: 19 %x.tr = phi ptr [ %x, %entry ], [ null, %land.lhs.true ] 20 %0 = load i16, ptr %x.tr, align 4 21; CHECK: load i16, ptr 22 %conv = zext i16 %0 to i32 23 switch i32 %conv, label %if.end.50 [ 24 i32 43, label %cleanup 25 i32 52, label %if.then.5 26 ] 27 28if.then.5: ; preds = %bb0 29 br i1 undef, label %land.lhs.true, label %if.then.26 30 31land.lhs.true: ; preds = %if.then.5 32 br i1 undef, label %cleanup, label %bb0 33 34if.then.26: ; preds = %if.then.5 35 %x.tr.lcssa163 = phi ptr [ %x.tr, %if.then.5 ] 36 br i1 undef, label %cond.end, label %cond.false 37 38cond.false: ; preds = %if.then.26 39; CHECK: cond.false: 40; CHECK: load i16 41 %mode = getelementptr inbounds %struct.a, ptr %x.tr.lcssa163, i32 0, i32 1 42 %bf.load = load i16, ptr %mode, align 2 43 %bf.shl = shl i16 %bf.load, 8 44 br label %cond.end 45 46cond.end: ; preds = %cond.false, %if.then.26 47 br i1 undef, label %if.then.44, label %cleanup 48 49if.then.44: ; preds = %cond.end 50 unreachable 51 52if.end.50: ; preds = %bb0 53;%CHECK: if.end.50: 54 %conv.lcssa = phi i32 [ %conv, %bb0 ] 55 %arrayidx52 = getelementptr inbounds [0 x i32], ptr @length, i32 0, i32 %conv.lcssa 56 %1 = load i32, ptr %arrayidx52, align 4 57 br i1 undef, label %for.body.57, label %cleanup 58 59for.body.57: ; preds = %if.end.50 60 %i.2157 = add nsw i32 %1, -1 61 unreachable 62 63cleanup: ; preds = %if.end.50, %cond.end, %land.lhs.true, %bb0 64 ret void 65} 66 67@yy_c_buf_p = external unnamed_addr global ptr, align 4 68@dfg_text = external global ptr, align 4 69 70define void @dfg_lex() { 71;CHECK-LABEL: dfg_lex 72entry: 73 br label %while.bodythread-pre-split 74 75while.bodythread-pre-split: ; preds = %while.end, %while.end, %entry 76 br i1 undef, label %if.then.14, label %if.end.15 77 78if.then.14: ; preds = %while.end, %while.bodythread-pre-split 79 %v1 = load i32, ptr @dfg_text, align 4 80 %sub.ptr.sub = sub i32 undef, %v1 81 br label %if.end.15 82 83if.end.15: ; preds = %if.then.14, %while.bodythread-pre-split 84 %v2 = load ptr, ptr @yy_c_buf_p, align 4 85 br label %while.cond.16 86 87while.cond.16: ; preds = %while.cond.16, %if.end.15 88 br i1 undef, label %while.cond.16, label %while.end 89 90while.end: ; preds = %while.cond.16 91 %add.ptr = getelementptr inbounds i8, ptr %v2, i32 undef 92 store ptr %add.ptr, ptr @dfg_text, align 4 93 %sub.ptr.rhs.cast25 = ptrtoint ptr %add.ptr to i32 94 %sub.ptr.sub26 = sub i32 0, %sub.ptr.rhs.cast25 95 switch i32 undef, label %sw.default [ 96 i32 65, label %while.bodythread-pre-split 97 i32 3, label %return 98 i32 57, label %while.bodythread-pre-split 99 i32 60, label %if.then.14 100 ] 101 102sw.default: ; preds = %while.end 103 unreachable 104 105return: ; preds = %while.end 106 ret void 107} 108