1 ; RUN: llc < %s -mtriple=armv7-apple-ios | FileCheck %s
4 declare void @llvm.trap()
6 @G1 = external global i32
7 @G2 = external global i32
9 define i32 @f1(i32 %cond1, i32 %x1, i32 %x2, i32 %x3) {
16 %tmp1 = icmp eq i32 %cond1, 0
17 %tmp2 = select i1 %tmp1, i32 %x1, i32 %x2
18 %tmp3 = select i1 %tmp1, i32 %x2, i32 %x3
19 %tmp4 = add i32 %tmp2, %tmp3
23 @foo = external global i32
24 @bar = external global [250 x i8], align 1
26 ; CSE of cmp across BB boundary
28 define void @f2() nounwind ssp {
35 %0 = load i32, i32* @foo, align 4
36 %cmp28 = icmp sgt i32 %0, 0
37 br i1 %cmp28, label %for.body.lr.ph, label %for.cond1.preheader
39 for.body.lr.ph: ; preds = %entry
40 %1 = icmp sgt i32 %0, 1
41 %smax = select i1 %1, i32 %0, i32 1
42 call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([250 x i8], [250 x i8]* @bar, i32 0, i32 0), i8 0, i32 %smax, i1 false)
43 call void @llvm.trap()
46 for.cond1.preheader: ; preds = %entry
50 declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i1) nounwind
53 define i8* @f3(i8* %base, i32* nocapture %offset, i32 %size) nounwind {
59 %0 = load i32, i32* %offset, align 4
60 %cmp = icmp slt i32 %0, %size
61 %s = sub nsw i32 %0, %size
62 %size2 = sub nsw i32 %size, 0
63 br i1 %cmp, label %return, label %if.end
66 ; We are checking cse between %sub here and %s in entry block.
67 %sub = sub nsw i32 %0, %size2
68 %s2 = sub nsw i32 %s, %size
69 %s3 = sub nsw i32 %sub, %s2
70 ; CHECK: sub [[R1:r[0-9]+]], [[R2:r[0-9]+]], r2
71 ; CHECK: sub [[R3:r[0-9]+]], r2, [[R1]]
72 ; CHECK: add [[R4:r[0-9]+]], [[R1]], [[R3]]
75 store i32 %s3, i32* %offset, align 4
76 %add.ptr = getelementptr inbounds i8, i8* %base, i32 %sub
80 %retval.0 = phi i8* [ %add.ptr, %if.end ], [ null, %entry ]