Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 1 | ; Ensure that multiplication is lowered to function calls when the multiplier |
| 2 | ; unit is not available in the hardware and that function calls are not used |
| 3 | ; when the multiplier unit is available in the hardware. |
| 4 | ; |
| 5 | ; RUN: llc < %s -march=mblaze | FileCheck -check-prefix=FUN %s |
| 6 | ; RUN: llc < %s -march=mblaze -mattr=+div | FileCheck -check-prefix=DIV %s |
| 7 | |
| 8 | define i8 @test_i8(i8 %a, i8 %b) { |
| 9 | ; FUN: test_i8: |
| 10 | ; DIV: test_i8: |
| 11 | |
| 12 | %tmp.1 = udiv i8 %a, %b |
| 13 | ; FUN-NOT: idiv |
| 14 | ; FUN: brlid |
| 15 | ; DIV-NOT: brlid |
Dan Gohman | 8c2d270 | 2011-10-24 17:45:02 +0000 | [diff] [blame] | 16 | ; DIV: idiv |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 17 | |
| 18 | %tmp.2 = sdiv i8 %a, %b |
| 19 | ; FUN-NOT: idiv |
| 20 | ; FUN: brlid |
| 21 | ; DIV-NOT: brlid |
Dan Gohman | 8c2d270 | 2011-10-24 17:45:02 +0000 | [diff] [blame] | 22 | ; DIV-NOT: idiv |
| 23 | ; DIV: idivu |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 24 | |
| 25 | %tmp.3 = add i8 %tmp.1, %tmp.2 |
| 26 | ret i8 %tmp.3 |
| 27 | ; FUN: rtsd |
| 28 | ; DIV: rtsd |
| 29 | } |
| 30 | |
| 31 | define i16 @test_i16(i16 %a, i16 %b) { |
| 32 | ; FUN: test_i16: |
| 33 | ; DIV: test_i16: |
| 34 | |
| 35 | %tmp.1 = udiv i16 %a, %b |
| 36 | ; FUN-NOT: idiv |
| 37 | ; FUN: brlid |
| 38 | ; DIV-NOT: brlid |
Dan Gohman | 8c2d270 | 2011-10-24 17:45:02 +0000 | [diff] [blame] | 39 | ; DIV: idiv |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 40 | |
| 41 | %tmp.2 = sdiv i16 %a, %b |
| 42 | ; FUN-NOT: idiv |
| 43 | ; FUN: brlid |
| 44 | ; DIV-NOT: brlid |
Dan Gohman | 8c2d270 | 2011-10-24 17:45:02 +0000 | [diff] [blame] | 45 | ; DIV-NOT: idiv |
| 46 | ; DIV: idivu |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 47 | |
| 48 | %tmp.3 = add i16 %tmp.1, %tmp.2 |
| 49 | ret i16 %tmp.3 |
| 50 | ; FUN: rtsd |
| 51 | ; DIV: rtsd |
| 52 | } |
| 53 | |
| 54 | define i32 @test_i32(i32 %a, i32 %b) { |
| 55 | ; FUN: test_i32: |
| 56 | ; DIV: test_i32: |
| 57 | |
| 58 | %tmp.1 = udiv i32 %a, %b |
| 59 | ; FUN-NOT: idiv |
| 60 | ; FUN: brlid |
| 61 | ; DIV-NOT: brlid |
Dan Gohman | 8c2d270 | 2011-10-24 17:45:02 +0000 | [diff] [blame] | 62 | ; DIV: idiv |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 63 | |
| 64 | %tmp.2 = sdiv i32 %a, %b |
| 65 | ; FUN-NOT: idiv |
| 66 | ; FUN: brlid |
| 67 | ; DIV-NOT: brlid |
Dan Gohman | 8c2d270 | 2011-10-24 17:45:02 +0000 | [diff] [blame] | 68 | ; DIV-NOT: idiv |
| 69 | ; DIV: idivu |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 70 | |
| 71 | %tmp.3 = add i32 %tmp.1, %tmp.2 |
| 72 | ret i32 %tmp.3 |
| 73 | ; FUN: rtsd |
| 74 | ; DIV: rtsd |
| 75 | } |