1 ; RUN: opt -O3 -S < %s | FileCheck %s
6 ; PR6627 - This whole nasty sequence should be flattened down to a single
8 define void @test2(i8* %arrayidx) nounwind ssp {
10 %xx = bitcast i8* %arrayidx to i32*
11 %x1 = load i32, i32* %xx, align 4
12 %tmp = trunc i32 %x1 to i8
13 %conv = zext i8 %tmp to i32
14 %cmp = icmp eq i32 %conv, 127
15 br i1 %cmp, label %land.lhs.true, label %if.end
17 land.lhs.true: ; preds = %entry
18 %arrayidx4 = getelementptr inbounds i8, i8* %arrayidx, i64 1
19 %tmp5 = load i8, i8* %arrayidx4, align 1
20 %conv6 = zext i8 %tmp5 to i32
21 %cmp7 = icmp eq i32 %conv6, 69
22 br i1 %cmp7, label %land.lhs.true9, label %if.end
24 land.lhs.true9: ; preds = %land.lhs.true
25 %arrayidx12 = getelementptr inbounds i8, i8* %arrayidx, i64 2
26 %tmp13 = load i8, i8* %arrayidx12, align 1
27 %conv14 = zext i8 %tmp13 to i32
28 %cmp15 = icmp eq i32 %conv14, 76
29 br i1 %cmp15, label %land.lhs.true17, label %if.end
31 land.lhs.true17: ; preds = %land.lhs.true9
32 %arrayidx20 = getelementptr inbounds i8, i8* %arrayidx, i64 3
33 %tmp21 = load i8, i8* %arrayidx20, align 1
34 %conv22 = zext i8 %tmp21 to i32
35 %cmp23 = icmp eq i32 %conv22, 70
36 br i1 %cmp23, label %if.then, label %if.end
38 if.then: ; preds = %land.lhs.true17
39 %call25 = call i32 (...) @doo()
45 ; CHECK-LABEL: @test2(
46 ; CHECK: %x1 = load i32, i32* %xx, align 4
47 ; CHECK-NEXT: icmp eq i32 %x1, 1179403647
48 ; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end
51 ; PR6627 - This should all be flattened down to one compare. This is the same
52 ; as test2, except that the initial load is done as an i8 instead of i32, thus
54 define void @test2a(i8* %arrayidx) nounwind ssp {
56 %x1 = load i8, i8* %arrayidx, align 4
57 %conv = zext i8 %x1 to i32
58 %cmp = icmp eq i32 %conv, 127
59 br i1 %cmp, label %land.lhs.true, label %if.end
61 land.lhs.true: ; preds = %entry
62 %arrayidx4 = getelementptr inbounds i8, i8* %arrayidx, i64 1
63 %tmp5 = load i8, i8* %arrayidx4, align 1
64 %conv6 = zext i8 %tmp5 to i32
65 %cmp7 = icmp eq i32 %conv6, 69
66 br i1 %cmp7, label %land.lhs.true9, label %if.end
68 land.lhs.true9: ; preds = %land.lhs.true
69 %arrayidx12 = getelementptr inbounds i8, i8* %arrayidx, i64 2
70 %tmp13 = load i8, i8* %arrayidx12, align 1
71 %conv14 = zext i8 %tmp13 to i32
72 %cmp15 = icmp eq i32 %conv14, 76
73 br i1 %cmp15, label %land.lhs.true17, label %if.end
75 land.lhs.true17: ; preds = %land.lhs.true9
76 %arrayidx20 = getelementptr inbounds i8, i8* %arrayidx, i64 3
77 %tmp21 = load i8, i8* %arrayidx20, align 1
78 %conv22 = zext i8 %tmp21 to i32
79 %cmp23 = icmp eq i32 %conv22, 70
80 br i1 %cmp23, label %if.then, label %if.end
82 if.then: ; preds = %land.lhs.true17
83 %call25 = call i32 (...) @doo()
89 ; CHECK-LABEL: @test2a(
90 ; CHECK: %x1 = load i32, i32* {{.*}}, align 4
91 ; CHECK-NEXT: icmp eq i32 %x1, 1179403647
92 ; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end