xref: /minix3/external/bsd/llvm/dist/llvm/test/CodeGen/ARM/divmod.ll (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc; RUN: llc < %s -mtriple=arm-apple-ios5.0 -mcpu=cortex-a8 | FileCheck %s -check-prefix=A8
2*f4a2713aSLionel Sambuc; RUN: llc < %s -mtriple=arm-apple-ios5.0 -mcpu=swift     | FileCheck %s -check-prefix=SWIFT
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuc; rdar://12481395
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambucdefine void @foo(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp {
7*f4a2713aSLionel Sambucentry:
8*f4a2713aSLionel Sambuc; A8-LABEL: foo:
9*f4a2713aSLionel Sambuc; A8: bl ___divmodsi4
10*f4a2713aSLionel Sambuc; A8-NOT: bl ___divmodsi4
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc; SWIFT-LABEL: foo:
13*f4a2713aSLionel Sambuc; SWIFT: sdiv
14*f4a2713aSLionel Sambuc; SWIFT: mls
15*f4a2713aSLionel Sambuc; SWIFT-NOT: bl __divmodsi4
16*f4a2713aSLionel Sambuc  %div = sdiv i32 %x, %y
17*f4a2713aSLionel Sambuc  store i32 %div, i32* %P, align 4
18*f4a2713aSLionel Sambuc  %rem = srem i32 %x, %y
19*f4a2713aSLionel Sambuc  %arrayidx6 = getelementptr inbounds i32* %P, i32 1
20*f4a2713aSLionel Sambuc  store i32 %rem, i32* %arrayidx6, align 4
21*f4a2713aSLionel Sambuc  ret void
22*f4a2713aSLionel Sambuc}
23*f4a2713aSLionel Sambuc
24*f4a2713aSLionel Sambucdefine void @bar(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp {
25*f4a2713aSLionel Sambucentry:
26*f4a2713aSLionel Sambuc; A8-LABEL: bar:
27*f4a2713aSLionel Sambuc; A8: bl ___udivmodsi4
28*f4a2713aSLionel Sambuc; A8-NOT: bl ___udivmodsi4
29*f4a2713aSLionel Sambuc
30*f4a2713aSLionel Sambuc; SWIFT-LABEL: bar:
31*f4a2713aSLionel Sambuc; SWIFT: udiv
32*f4a2713aSLionel Sambuc; SWIFT: mls
33*f4a2713aSLionel Sambuc; SWIFT-NOT: bl __udivmodsi4
34*f4a2713aSLionel Sambuc  %div = udiv i32 %x, %y
35*f4a2713aSLionel Sambuc  store i32 %div, i32* %P, align 4
36*f4a2713aSLionel Sambuc  %rem = urem i32 %x, %y
37*f4a2713aSLionel Sambuc  %arrayidx6 = getelementptr inbounds i32* %P, i32 1
38*f4a2713aSLionel Sambuc  store i32 %rem, i32* %arrayidx6, align 4
39*f4a2713aSLionel Sambuc  ret void
40*f4a2713aSLionel Sambuc}
41*f4a2713aSLionel Sambuc
42*f4a2713aSLionel Sambuc; rdar://9280991
43*f4a2713aSLionel Sambuc@flags = external unnamed_addr global i32
44*f4a2713aSLionel Sambuc@tabsize = external unnamed_addr global i32
45*f4a2713aSLionel Sambuc
46*f4a2713aSLionel Sambucdefine void @do_indent(i32 %cols) nounwind {
47*f4a2713aSLionel Sambucentry:
48*f4a2713aSLionel Sambuc; A8-LABEL: do_indent:
49*f4a2713aSLionel Sambuc; SWIFT-LABEL: do_indent:
50*f4a2713aSLionel Sambuc  %0 = load i32* @flags, align 4
51*f4a2713aSLionel Sambuc  %1 = and i32 %0, 67108864
52*f4a2713aSLionel Sambuc  %2 = icmp eq i32 %1, 0
53*f4a2713aSLionel Sambuc  br i1 %2, label %bb1, label %bb
54*f4a2713aSLionel Sambuc
55*f4a2713aSLionel Sambucbb:
56*f4a2713aSLionel Sambuc; A8: bl ___divmodsi4
57*f4a2713aSLionel Sambuc; SWIFT: sdiv
58*f4a2713aSLionel Sambuc; SWIFT: mls
59*f4a2713aSLionel Sambuc; SWIFT-NOT: bl __divmodsi4
60*f4a2713aSLionel Sambuc  %3 = load i32* @tabsize, align 4
61*f4a2713aSLionel Sambuc  %4 = srem i32 %cols, %3
62*f4a2713aSLionel Sambuc  %5 = sdiv i32 %cols, %3
63*f4a2713aSLionel Sambuc  %6 = tail call i32 @llvm.objectsize.i32.p0i8(i8* null, i1 false)
64*f4a2713aSLionel Sambuc  %7 = tail call i8* @__memset_chk(i8* null, i32 9, i32 %5, i32 %6) nounwind
65*f4a2713aSLionel Sambuc  br label %bb1
66*f4a2713aSLionel Sambuc
67*f4a2713aSLionel Sambucbb1:
68*f4a2713aSLionel Sambuc  %line_indent_len.0 = phi i32 [ %4, %bb ], [ 0, %entry ]
69*f4a2713aSLionel Sambuc  %8 = getelementptr inbounds i8* null, i32 %line_indent_len.0
70*f4a2713aSLionel Sambuc  store i8 0, i8* %8, align 1
71*f4a2713aSLionel Sambuc  ret void
72*f4a2713aSLionel Sambuc}
73*f4a2713aSLionel Sambuc
74*f4a2713aSLionel Sambucdeclare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readnone
75*f4a2713aSLionel Sambucdeclare i8* @__memset_chk(i8*, i32, i32, i32) nounwind
76*f4a2713aSLionel Sambuc
77*f4a2713aSLionel Sambuc; rdar://11714607
78*f4a2713aSLionel Sambucdefine i32 @howmany(i32 %x, i32 %y) nounwind {
79*f4a2713aSLionel Sambucentry:
80*f4a2713aSLionel Sambuc; A8-LABEL: howmany:
81*f4a2713aSLionel Sambuc; A8: bl ___udivmodsi4
82*f4a2713aSLionel Sambuc; A8-NOT: ___udivsi3
83*f4a2713aSLionel Sambuc
84*f4a2713aSLionel Sambuc; SWIFT-LABEL: howmany:
85*f4a2713aSLionel Sambuc; SWIFT: udiv
86*f4a2713aSLionel Sambuc; SWIFT: mls
87*f4a2713aSLionel Sambuc; SWIFT-NOT: bl __udivmodsi4
88*f4a2713aSLionel Sambuc  %rem = urem i32 %x, %y
89*f4a2713aSLionel Sambuc  %div = udiv i32 %x, %y
90*f4a2713aSLionel Sambuc  %not.cmp = icmp ne i32 %rem, 0
91*f4a2713aSLionel Sambuc  %add = zext i1 %not.cmp to i32
92*f4a2713aSLionel Sambuc  %cond = add i32 %add, %div
93*f4a2713aSLionel Sambuc  ret i32 %cond
94*f4a2713aSLionel Sambuc}
95