blob: aeb2bc4d1a21bb7e3b956eb3647620e914a8f569 [file] [log] [blame]
Chris Lattner734d7c22011-04-26 20:45:33 +00001; RUN: opt -O3 -S %s | FileCheck %s
2
3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
4target triple = "x86_64-apple-macosx10.6.7"
5
6declare i8* @malloc(i64)
7declare void @free(i8*)
8
9
10; PR2338
11define void @test1() nounwind ssp {
12 %retval = alloca i32, align 4
13 %i = alloca i8*, align 8
14 %call = call i8* @malloc(i64 1)
15 store i8* %call, i8** %i, align 8
16 %tmp = load i8** %i, align 8
17 store i8 1, i8* %tmp
18 %tmp1 = load i8** %i, align 8
19 call void @free(i8* %tmp1)
20 ret void
21
22; CHECK: @test1
23; CHECK-NEXT: ret void
24}
25
26
27; PR6627 - This whole nasty sequence should be flattened down to a single
28; 32-bit comparison.
29define void @test2(i8* %arrayidx) nounwind ssp {
30entry:
31 %xx = bitcast i8* %arrayidx to i32*
32 %x1 = load i32* %xx, align 4
33 %tmp = trunc i32 %x1 to i8
34 %conv = zext i8 %tmp to i32
35 %cmp = icmp eq i32 %conv, 127
36 br i1 %cmp, label %land.lhs.true, label %if.end
37
38land.lhs.true: ; preds = %entry
39 %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1
40 %tmp5 = load i8* %arrayidx4, align 1
41 %conv6 = zext i8 %tmp5 to i32
42 %cmp7 = icmp eq i32 %conv6, 69
43 br i1 %cmp7, label %land.lhs.true9, label %if.end
44
45land.lhs.true9: ; preds = %land.lhs.true
46 %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2
47 %tmp13 = load i8* %arrayidx12, align 1
48 %conv14 = zext i8 %tmp13 to i32
49 %cmp15 = icmp eq i32 %conv14, 76
50 br i1 %cmp15, label %land.lhs.true17, label %if.end
51
52land.lhs.true17: ; preds = %land.lhs.true9
53 %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3
54 %tmp21 = load i8* %arrayidx20, align 1
55 %conv22 = zext i8 %tmp21 to i32
56 %cmp23 = icmp eq i32 %conv22, 70
57 br i1 %cmp23, label %if.then, label %if.end
58
59if.then: ; preds = %land.lhs.true17
60 %call25 = call i32 (...)* @doo()
61 br label %if.end
62
63if.end: ; preds = %if.then, %land.lhs.true17, %land.lhs.true9, %land.lhs.true, %entry
64 ret void
65
66; CHECK: @test2
67; CHECK: %x1 = load i32* %xx, align 4
68; CHECK-NEXT: icmp eq i32 %x1, 1179403647
69; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end
70}
71
72declare i32 @doo(...)
73