1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ;RUN: opt -passes=newgvn -S < %s | FileCheck %s
4 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n8:16:32-S64"
5 target triple = "thumbv7--linux-gnueabi"
7 %struct.a = type { i16, i16, [1 x %union.a] }
8 %union.a = type { i32 }
10 @length = external global [0 x i32], align 4
12 ; Function Attrs: nounwind
13 define fastcc void @foo(ptr nocapture readonly %x) {
14 ; CHECK-LABEL: define fastcc void @foo(
15 ; CHECK-SAME: ptr nocapture readonly [[X:%.*]]) {
17 ; CHECK-NEXT: br label [[BB0:%.*]]
19 ; CHECK-NEXT: [[X_TR:%.*]] = phi ptr [ [[X]], [[ENTRY:%.*]] ], [ null, [[LAND_LHS_TRUE:%.*]] ]
20 ; CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr [[X_TR]], align 4
21 ; CHECK-NEXT: [[CONV:%.*]] = zext i16 [[TMP0]] to i32
22 ; CHECK-NEXT: switch i32 [[CONV]], label [[IF_END_50:%.*]] [
23 ; CHECK-NEXT: i32 43, label [[CLEANUP:%.*]]
24 ; CHECK-NEXT: i32 52, label [[IF_THEN_5:%.*]]
27 ; CHECK-NEXT: br i1 undef, label [[LAND_LHS_TRUE]], label [[IF_THEN_26:%.*]]
28 ; CHECK: land.lhs.true:
29 ; CHECK-NEXT: br i1 undef, label [[CLEANUP]], label [[BB0]]
31 ; CHECK-NEXT: br i1 undef, label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
33 ; CHECK-NEXT: [[MODE:%.*]] = getelementptr inbounds [[STRUCT_A:%.*]], ptr [[X_TR]], i32 0, i32 1
34 ; CHECK-NEXT: [[BF_LOAD:%.*]] = load i16, ptr [[MODE]], align 2
35 ; CHECK-NEXT: br label [[COND_END]]
37 ; CHECK-NEXT: br i1 undef, label [[IF_THEN_44:%.*]], label [[CLEANUP]]
39 ; CHECK-NEXT: unreachable
41 ; CHECK-NEXT: [[ARRAYIDX52:%.*]] = getelementptr inbounds [0 x i32], ptr @length, i32 0, i32 [[CONV]]
42 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX52]], align 4
43 ; CHECK-NEXT: br i1 undef, label [[FOR_BODY_57:%.*]], label [[CLEANUP]]
45 ; CHECK-NEXT: unreachable
47 ; CHECK-NEXT: ret void
52 bb0: ; preds = %land.lhs.true, %entry
53 %x.tr = phi ptr [ %x, %entry ], [ null, %land.lhs.true ]
54 %0 = load i16, ptr %x.tr, align 4
55 %conv = zext i16 %0 to i32
56 switch i32 %conv, label %if.end.50 [
57 i32 43, label %cleanup
58 i32 52, label %if.then.5
61 if.then.5: ; preds = %bb0
62 br i1 undef, label %land.lhs.true, label %if.then.26
64 land.lhs.true: ; preds = %if.then.5
65 br i1 undef, label %cleanup, label %bb0
67 if.then.26: ; preds = %if.then.5
68 %x.tr.lcssa163 = phi ptr [ %x.tr, %if.then.5 ]
69 br i1 undef, label %cond.end, label %cond.false
71 cond.false: ; preds = %if.then.26
72 %mode = getelementptr inbounds %struct.a, ptr %x.tr.lcssa163, i32 0, i32 1
73 %bf.load = load i16, ptr %mode, align 2
74 %bf.shl = shl i16 %bf.load, 8
77 cond.end: ; preds = %cond.false, %if.then.26
78 br i1 undef, label %if.then.44, label %cleanup
80 if.then.44: ; preds = %cond.end
83 if.end.50: ; preds = %bb0
84 %conv.lcssa = phi i32 [ %conv, %bb0 ]
85 %arrayidx52 = getelementptr inbounds [0 x i32], ptr @length, i32 0, i32 %conv.lcssa
86 %1 = load i32, ptr %arrayidx52, align 4
87 br i1 undef, label %for.body.57, label %cleanup
89 for.body.57: ; preds = %if.end.50
90 %i.2157 = add nsw i32 %1, -1
93 cleanup: ; preds = %if.end.50, %cond.end, %land.lhs.true, %bb0
97 @yy_c_buf_p = external unnamed_addr global ptr, align 4
98 @dfg_text = external global ptr, align 4
100 define void @dfg_lex() {
101 ; CHECK-LABEL: define void @dfg_lex() {
103 ; CHECK-NEXT: br label [[WHILE_BODYTHREAD_PRE_SPLIT:%.*]]
104 ; CHECK: while.bodythread-pre-split:
105 ; CHECK-NEXT: br i1 undef, label [[IF_THEN_14:%.*]], label [[IF_END_15:%.*]]
107 ; CHECK-NEXT: [[V1:%.*]] = load i32, ptr @dfg_text, align 4
108 ; CHECK-NEXT: br label [[IF_END_15]]
110 ; CHECK-NEXT: [[V2:%.*]] = load ptr, ptr @yy_c_buf_p, align 4
111 ; CHECK-NEXT: br label [[WHILE_COND_16:%.*]]
112 ; CHECK: while.cond.16:
113 ; CHECK-NEXT: br i1 undef, label [[WHILE_COND_16]], label [[WHILE_END:%.*]]
115 ; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[V2]], i32 undef
116 ; CHECK-NEXT: store ptr [[ADD_PTR]], ptr @dfg_text, align 4
117 ; CHECK-NEXT: [[SUB_PTR_RHS_CAST25:%.*]] = ptrtoint ptr [[ADD_PTR]] to i32
118 ; CHECK-NEXT: switch i32 undef, label [[SW_DEFAULT:%.*]] [
119 ; CHECK-NEXT: i32 65, label [[WHILE_BODYTHREAD_PRE_SPLIT]]
120 ; CHECK-NEXT: i32 3, label [[RETURN:%.*]]
121 ; CHECK-NEXT: i32 57, label [[WHILE_BODYTHREAD_PRE_SPLIT]]
122 ; CHECK-NEXT: i32 60, label [[IF_THEN_14]]
125 ; CHECK-NEXT: unreachable
127 ; CHECK-NEXT: ret void
130 br label %while.bodythread-pre-split
132 while.bodythread-pre-split: ; preds = %while.end, %while.end, %entry
133 br i1 undef, label %if.then.14, label %if.end.15
135 if.then.14: ; preds = %while.end, %while.bodythread-pre-split
136 %v1 = load i32, ptr @dfg_text, align 4
137 %sub.ptr.sub = sub i32 undef, %v1
140 if.end.15: ; preds = %if.then.14, %while.bodythread-pre-split
141 %v2 = load ptr, ptr @yy_c_buf_p, align 4
142 br label %while.cond.16
144 while.cond.16: ; preds = %while.cond.16, %if.end.15
145 br i1 undef, label %while.cond.16, label %while.end
147 while.end: ; preds = %while.cond.16
148 %add.ptr = getelementptr inbounds i8, ptr %v2, i32 undef
149 store ptr %add.ptr, ptr @dfg_text, align 4
150 %sub.ptr.rhs.cast25 = ptrtoint ptr %add.ptr to i32
151 %sub.ptr.sub26 = sub i32 0, %sub.ptr.rhs.cast25
152 switch i32 undef, label %sw.default [
153 i32 65, label %while.bodythread-pre-split
155 i32 57, label %while.bodythread-pre-split
156 i32 60, label %if.then.14
159 sw.default: ; preds = %while.end
162 return: ; preds = %while.end