• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=armv7-apple-ios | FileCheck %s
2;rdar://8003725
3
4@G1 = external global i32
5@G2 = external global i32
6
7define i32 @f1(i32 %cond1, i32 %x1, i32 %x2, i32 %x3) {
8entry:
9; CHECK-LABEL: f1:
10; CHECK: cmp
11; CHECK: moveq
12; CHECK-NOT: cmp
13; CHECK: mov{{eq|ne}}
14    %tmp1 = icmp eq i32 %cond1, 0
15    %tmp2 = select i1 %tmp1, i32 %x1, i32 %x2
16    %tmp3 = select i1 %tmp1, i32 %x2, i32 %x3
17    %tmp4 = add i32 %tmp2, %tmp3
18    ret i32 %tmp4
19}
20
21@foo = external global i32
22@bar = external global [250 x i8], align 1
23
24; CSE of cmp across BB boundary
25; rdar://10660865
26define void @f2() nounwind ssp {
27entry:
28; CHECK-LABEL: f2:
29; CHECK: cmp
30; CHECK: bxlt
31; CHECK-NOT: cmp
32; CHECK: movle
33  %0 = load i32, i32* @foo, align 4
34  %cmp28 = icmp sgt i32 %0, 0
35  br i1 %cmp28, label %for.body.lr.ph, label %for.cond1.preheader
36
37for.body.lr.ph:                                   ; preds = %entry
38  %1 = icmp sgt i32 %0, 1
39  %smax = select i1 %1, i32 %0, i32 1
40  call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([250 x i8], [250 x i8]* @bar, i32 0, i32 0), i8 0, i32 %smax, i32 1, i1 false)
41  unreachable
42
43for.cond1.preheader:                              ; preds = %entry
44  ret void
45}
46
47declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind
48
49; rdar://12462006
50define i8* @f3(i8* %base, i32* nocapture %offset, i32 %size) nounwind {
51entry:
52; CHECK-LABEL: f3:
53; CHECK-NOT: sub
54; CHECK: cmp
55; CHECK: blt
56%0 = load i32, i32* %offset, align 4
57%cmp = icmp slt i32 %0, %size
58%s = sub nsw i32 %0, %size
59%size2 = sub nsw i32 %size, 0
60br i1 %cmp, label %return, label %if.end
61
62if.end:
63; We are checking cse between %sub here and %s in entry block.
64%sub = sub nsw i32 %0, %size2
65%s2 = sub nsw i32 %s, %size
66%s3 = sub nsw i32 %sub, %s2
67; CHECK: sub [[R1:r[0-9]+]], [[R2:r[0-9]+]], r2
68; CHECK: sub [[R3:r[0-9]+]], [[R1]], r2
69; CHECK: sub [[R4:r[0-9]+]], [[R1]], [[R3]]
70; CHECK-NOT: sub
71; CHECK: str
72store i32 %s3, i32* %offset, align 4
73%add.ptr = getelementptr inbounds i8, i8* %base, i32 %sub
74br label %return
75
76return:
77%retval.0 = phi i8* [ %add.ptr, %if.end ], [ null, %entry ]
78ret i8* %retval.0
79}
80