blob: cf95363e655a2e6ab1e0a9bfd55e2fe05b890213 [file] [log] [blame]
Dmitri Gribenkob137c9e2012-12-30 01:28:40 +00001; RUN: opt -O3 -S < %s | FileCheck %s
Jakob Stoklund Olesen201ba5f2012-04-19 00:20:38 +00002; XFAIL: *
3
4declare i32 @doo(...)
5
6; PR6627 - This whole nasty sequence should be flattened down to a single
7; 32-bit comparison.
8define void @test2(i8* %arrayidx) nounwind ssp {
9entry:
10 %xx = bitcast i8* %arrayidx to i32*
11 %x1 = load 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
16
17land.lhs.true: ; preds = %entry
18 %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1
19 %tmp5 = load 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
23
24land.lhs.true9: ; preds = %land.lhs.true
25 %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2
26 %tmp13 = load 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
30
31land.lhs.true17: ; preds = %land.lhs.true9
32 %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3
33 %tmp21 = load 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
37
38if.then: ; preds = %land.lhs.true17
39 %call25 = call i32 (...)* @doo()
40 br label %if.end
41
42if.end:
43 ret void
44
Stephen Linc1c7a132013-07-14 01:42:54 +000045; CHECK-LABEL: @test2(
Jakob Stoklund Olesen201ba5f2012-04-19 00:20:38 +000046; CHECK: %x1 = load i32* %xx, align 4
47; CHECK-NEXT: icmp eq i32 %x1, 1179403647
48; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end
49}
50
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
53; requiring widening.
54define void @test2a(i8* %arrayidx) nounwind ssp {
55entry:
56 %x1 = load 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
60
61land.lhs.true: ; preds = %entry
62 %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1
63 %tmp5 = load 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
67
68land.lhs.true9: ; preds = %land.lhs.true
69 %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2
70 %tmp13 = load 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
74
75land.lhs.true17: ; preds = %land.lhs.true9
76 %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3
77 %tmp21 = load 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
81
82if.then: ; preds = %land.lhs.true17
83 %call25 = call i32 (...)* @doo()
84 br label %if.end
85
86if.end:
87 ret void
88
Stephen Linc1c7a132013-07-14 01:42:54 +000089; CHECK-LABEL: @test2a(
Jakob Stoklund Olesen201ba5f2012-04-19 00:20:38 +000090; CHECK: %x1 = load i32* {{.*}}, align 4
91; CHECK-NEXT: icmp eq i32 %x1, 1179403647
92; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end
93}