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