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