Evan Cheng | d36696c | 2012-10-12 01:15:47 +0000 | [diff] [blame] | 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 | |
| 4 | ; rdar://12481395 |
Bob Wilson | 2fef457 | 2011-10-07 16:59:21 +0000 | [diff] [blame] | 5 | |
| 6 | define void @foo(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp { |
| 7 | entry: |
Evan Cheng | d36696c | 2012-10-12 01:15:47 +0000 | [diff] [blame] | 8 | ; 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 Wilson | 2fef457 | 2011-10-07 16:59:21 +0000 | [diff] [blame] | 16 | %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 | |
| 24 | define void @bar(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp { |
| 25 | entry: |
Evan Cheng | d36696c | 2012-10-12 01:15:47 +0000 | [diff] [blame] | 26 | ; 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 Wilson | 2fef457 | 2011-10-07 16:59:21 +0000 | [diff] [blame] | 34 | %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 | |
| 46 | define void @do_indent(i32 %cols) nounwind { |
| 47 | entry: |
Evan Cheng | d36696c | 2012-10-12 01:15:47 +0000 | [diff] [blame] | 48 | ; A8: do_indent: |
| 49 | ; SWIFT: do_indent: |
Bob Wilson | 2fef457 | 2011-10-07 16:59:21 +0000 | [diff] [blame] | 50 | %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 | |
| 55 | bb: |
Evan Cheng | d36696c | 2012-10-12 01:15:47 +0000 | [diff] [blame] | 56 | ; A8: bl ___divmodsi4 |
| 57 | ; SWIFT: sdiv |
| 58 | ; SWIFT: mls |
| 59 | ; SWIFT-NOT: bl __divmodsi4 |
Bob Wilson | 2fef457 | 2011-10-07 16:59:21 +0000 | [diff] [blame] | 60 | %3 = load i32* @tabsize, align 4 |
| 61 | %4 = srem i32 %cols, %3 |
| 62 | %5 = sdiv i32 %cols, %3 |
Nuno Lopes | 23e75da | 2012-05-22 15:25:31 +0000 | [diff] [blame] | 63 | %6 = tail call i32 @llvm.objectsize.i32(i8* null, i1 false) |
Bob Wilson | 2fef457 | 2011-10-07 16:59:21 +0000 | [diff] [blame] | 64 | %7 = tail call i8* @__memset_chk(i8* null, i32 9, i32 %5, i32 %6) nounwind |
| 65 | br label %bb1 |
| 66 | |
| 67 | bb1: |
| 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 Lopes | 23e75da | 2012-05-22 15:25:31 +0000 | [diff] [blame] | 74 | declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readnone |
Bob Wilson | 2fef457 | 2011-10-07 16:59:21 +0000 | [diff] [blame] | 75 | declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind |
Evan Cheng | 8ef0968 | 2012-06-21 05:56:05 +0000 | [diff] [blame] | 76 | |
| 77 | ; rdar://11714607 |
| 78 | define i32 @howmany(i32 %x, i32 %y) nounwind { |
| 79 | entry: |
Evan Cheng | d36696c | 2012-10-12 01:15:47 +0000 | [diff] [blame] | 80 | ; 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 Cheng | 8ef0968 | 2012-06-21 05:56:05 +0000 | [diff] [blame] | 88 | %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 | } |