xref: /aosp_15_r20/external/llvm/test/Transforms/PhaseOrdering/PR6627.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -O3 -S < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; XFAIL: *
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workerdeclare i32 @doo(...)
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; PR6627 - This whole nasty sequence should be flattened down to a single
7*9880d681SAndroid Build Coastguard Worker; 32-bit comparison.
8*9880d681SAndroid Build Coastguard Workerdefine void @test2(i8* %arrayidx) nounwind ssp {
9*9880d681SAndroid Build Coastguard Workerentry:
10*9880d681SAndroid Build Coastguard Worker  %xx = bitcast i8* %arrayidx to i32*
11*9880d681SAndroid Build Coastguard Worker  %x1 = load i32, i32* %xx, align 4
12*9880d681SAndroid Build Coastguard Worker  %tmp = trunc i32 %x1 to i8
13*9880d681SAndroid Build Coastguard Worker  %conv = zext i8 %tmp to i32
14*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %conv, 127
15*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %land.lhs.true, label %if.end
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workerland.lhs.true:                                    ; preds = %entry
18*9880d681SAndroid Build Coastguard Worker  %arrayidx4 = getelementptr inbounds i8, i8* %arrayidx, i64 1
19*9880d681SAndroid Build Coastguard Worker  %tmp5 = load i8, i8* %arrayidx4, align 1
20*9880d681SAndroid Build Coastguard Worker  %conv6 = zext i8 %tmp5 to i32
21*9880d681SAndroid Build Coastguard Worker  %cmp7 = icmp eq i32 %conv6, 69
22*9880d681SAndroid Build Coastguard Worker  br i1 %cmp7, label %land.lhs.true9, label %if.end
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerland.lhs.true9:                                   ; preds = %land.lhs.true
25*9880d681SAndroid Build Coastguard Worker  %arrayidx12 = getelementptr inbounds i8, i8* %arrayidx, i64 2
26*9880d681SAndroid Build Coastguard Worker  %tmp13 = load i8, i8* %arrayidx12, align 1
27*9880d681SAndroid Build Coastguard Worker  %conv14 = zext i8 %tmp13 to i32
28*9880d681SAndroid Build Coastguard Worker  %cmp15 = icmp eq i32 %conv14, 76
29*9880d681SAndroid Build Coastguard Worker  br i1 %cmp15, label %land.lhs.true17, label %if.end
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Workerland.lhs.true17:                                  ; preds = %land.lhs.true9
32*9880d681SAndroid Build Coastguard Worker  %arrayidx20 = getelementptr inbounds i8, i8* %arrayidx, i64 3
33*9880d681SAndroid Build Coastguard Worker  %tmp21 = load i8, i8* %arrayidx20, align 1
34*9880d681SAndroid Build Coastguard Worker  %conv22 = zext i8 %tmp21 to i32
35*9880d681SAndroid Build Coastguard Worker  %cmp23 = icmp eq i32 %conv22, 70
36*9880d681SAndroid Build Coastguard Worker  br i1 %cmp23, label %if.then, label %if.end
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %land.lhs.true17
39*9880d681SAndroid Build Coastguard Worker  %call25 = call i32 (...) @doo()
40*9880d681SAndroid Build Coastguard Worker  br label %if.end
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerif.end:
43*9880d681SAndroid Build Coastguard Worker  ret void
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test2(
46*9880d681SAndroid Build Coastguard Worker; CHECK: %x1 = load i32, i32* %xx, align 4
47*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: icmp eq i32 %x1, 1179403647
48*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end
49*9880d681SAndroid Build Coastguard Worker}
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Worker; PR6627 - This should all be flattened down to one compare.  This is the same
52*9880d681SAndroid Build Coastguard Worker; as test2, except that the initial load is done as an i8 instead of i32, thus
53*9880d681SAndroid Build Coastguard Worker; requiring widening.
54*9880d681SAndroid Build Coastguard Workerdefine void @test2a(i8* %arrayidx) nounwind ssp {
55*9880d681SAndroid Build Coastguard Workerentry:
56*9880d681SAndroid Build Coastguard Worker  %x1 = load i8, i8* %arrayidx, align 4
57*9880d681SAndroid Build Coastguard Worker  %conv = zext i8 %x1 to i32
58*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %conv, 127
59*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %land.lhs.true, label %if.end
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Workerland.lhs.true:                                    ; preds = %entry
62*9880d681SAndroid Build Coastguard Worker  %arrayidx4 = getelementptr inbounds i8, i8* %arrayidx, i64 1
63*9880d681SAndroid Build Coastguard Worker  %tmp5 = load i8, i8* %arrayidx4, align 1
64*9880d681SAndroid Build Coastguard Worker  %conv6 = zext i8 %tmp5 to i32
65*9880d681SAndroid Build Coastguard Worker  %cmp7 = icmp eq i32 %conv6, 69
66*9880d681SAndroid Build Coastguard Worker  br i1 %cmp7, label %land.lhs.true9, label %if.end
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Workerland.lhs.true9:                                   ; preds = %land.lhs.true
69*9880d681SAndroid Build Coastguard Worker  %arrayidx12 = getelementptr inbounds i8, i8* %arrayidx, i64 2
70*9880d681SAndroid Build Coastguard Worker  %tmp13 = load i8, i8* %arrayidx12, align 1
71*9880d681SAndroid Build Coastguard Worker  %conv14 = zext i8 %tmp13 to i32
72*9880d681SAndroid Build Coastguard Worker  %cmp15 = icmp eq i32 %conv14, 76
73*9880d681SAndroid Build Coastguard Worker  br i1 %cmp15, label %land.lhs.true17, label %if.end
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Workerland.lhs.true17:                                  ; preds = %land.lhs.true9
76*9880d681SAndroid Build Coastguard Worker  %arrayidx20 = getelementptr inbounds i8, i8* %arrayidx, i64 3
77*9880d681SAndroid Build Coastguard Worker  %tmp21 = load i8, i8* %arrayidx20, align 1
78*9880d681SAndroid Build Coastguard Worker  %conv22 = zext i8 %tmp21 to i32
79*9880d681SAndroid Build Coastguard Worker  %cmp23 = icmp eq i32 %conv22, 70
80*9880d681SAndroid Build Coastguard Worker  br i1 %cmp23, label %if.then, label %if.end
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %land.lhs.true17
83*9880d681SAndroid Build Coastguard Worker  %call25 = call i32 (...) @doo()
84*9880d681SAndroid Build Coastguard Worker  br label %if.end
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard Workerif.end:
87*9880d681SAndroid Build Coastguard Worker  ret void
88*9880d681SAndroid Build Coastguard Worker
89*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test2a(
90*9880d681SAndroid Build Coastguard Worker; CHECK: %x1 = load i32, i32* {{.*}}, align 4
91*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: icmp eq i32 %x1, 1179403647
92*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end
93*9880d681SAndroid Build Coastguard Worker}
94