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