blob: 577f8aa7d39b32ebf89a4aedbbc2b948b102900b [file] [log] [blame]
Evan Chengd36696c2012-10-12 01:15:47 +00001; 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
4; rdar://12481395
Bob Wilson2fef4572011-10-07 16:59:21 +00005
6define void @foo(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp {
7entry:
Evan Chengd36696c2012-10-12 01:15:47 +00008; A8: foo:
9; A8: bl ___divmodsi4
10; A8-NOT: bl ___divmodsi4
11
12; SWIFT: foo:
13; SWIFT: sdiv
14; SWIFT: mls
15; SWIFT-NOT: bl __divmodsi4
Bob Wilson2fef4572011-10-07 16:59:21 +000016 %div = sdiv i32 %x, %y
17 store i32 %div, i32* %P, align 4
18 %rem = srem i32 %x, %y
19 %arrayidx6 = getelementptr inbounds i32* %P, i32 1
20 store i32 %rem, i32* %arrayidx6, align 4
21 ret void
22}
23
24define void @bar(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp {
25entry:
Evan Chengd36696c2012-10-12 01:15:47 +000026; A8: bar:
27; A8: bl ___udivmodsi4
28; A8-NOT: bl ___udivmodsi4
29
30; SWIFT: bar:
31; SWIFT: udiv
32; SWIFT: mls
33; SWIFT-NOT: bl __udivmodsi4
Bob Wilson2fef4572011-10-07 16:59:21 +000034 %div = udiv i32 %x, %y
35 store i32 %div, i32* %P, align 4
36 %rem = urem i32 %x, %y
37 %arrayidx6 = getelementptr inbounds i32* %P, i32 1
38 store i32 %rem, i32* %arrayidx6, align 4
39 ret void
40}
41
42; rdar://9280991
43@flags = external unnamed_addr global i32
44@tabsize = external unnamed_addr global i32
45
46define void @do_indent(i32 %cols) nounwind {
47entry:
Evan Chengd36696c2012-10-12 01:15:47 +000048; A8: do_indent:
49; SWIFT: do_indent:
Bob Wilson2fef4572011-10-07 16:59:21 +000050 %0 = load i32* @flags, align 4
51 %1 = and i32 %0, 67108864
52 %2 = icmp eq i32 %1, 0
53 br i1 %2, label %bb1, label %bb
54
55bb:
Evan Chengd36696c2012-10-12 01:15:47 +000056; A8: bl ___divmodsi4
57; SWIFT: sdiv
58; SWIFT: mls
59; SWIFT-NOT: bl __divmodsi4
Bob Wilson2fef4572011-10-07 16:59:21 +000060 %3 = load i32* @tabsize, align 4
61 %4 = srem i32 %cols, %3
62 %5 = sdiv i32 %cols, %3
Nuno Lopes23e75da2012-05-22 15:25:31 +000063 %6 = tail call i32 @llvm.objectsize.i32(i8* null, i1 false)
Bob Wilson2fef4572011-10-07 16:59:21 +000064 %7 = tail call i8* @__memset_chk(i8* null, i32 9, i32 %5, i32 %6) nounwind
65 br label %bb1
66
67bb1:
68 %line_indent_len.0 = phi i32 [ %4, %bb ], [ 0, %entry ]
69 %8 = getelementptr inbounds i8* null, i32 %line_indent_len.0
70 store i8 0, i8* %8, align 1
71 ret void
72}
73
Nuno Lopes23e75da2012-05-22 15:25:31 +000074declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readnone
Bob Wilson2fef4572011-10-07 16:59:21 +000075declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind
Evan Cheng8ef09682012-06-21 05:56:05 +000076
77; rdar://11714607
78define i32 @howmany(i32 %x, i32 %y) nounwind {
79entry:
Evan Chengd36696c2012-10-12 01:15:47 +000080; A8: howmany:
81; A8: bl ___udivmodsi4
82; A8-NOT: ___udivsi3
83
84; SWIFT: howmany:
85; SWIFT: udiv
86; SWIFT: mls
87; SWIFT-NOT: bl __udivmodsi4
Evan Cheng8ef09682012-06-21 05:56:05 +000088 %rem = urem i32 %x, %y
89 %div = udiv i32 %x, %y
90 %not.cmp = icmp ne i32 %rem, 0
91 %add = zext i1 %not.cmp to i32
92 %cond = add i32 %add, %div
93 ret i32 %cond
94}