Adding the MicroBlaze backend.
[oota-llvm.git] / test / CodeGen / MBlaze / div.ll
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
16     ; DIV:        idivu
17
18     %tmp.2 = sdiv i8 %a, %b
19     ; FUN-NOT:    idiv
20     ; FUN:        brlid
21     ; DIV-NOT:    brlid
22     ; DIV-NOT:    idivu
23     ; DIV:        idiv
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
39     ; DIV:        idivu
40
41     %tmp.2 = sdiv i16 %a, %b
42     ; FUN-NOT:    idiv
43     ; FUN:        brlid
44     ; DIV-NOT:    brlid
45     ; DIV-NOT:    idivu
46     ; DIV:        idiv
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
62     ; DIV:        idivu
63
64     %tmp.2 = sdiv i32 %a, %b
65     ; FUN-NOT:    idiv
66     ; FUN:        brlid
67     ; DIV-NOT:    brlid
68     ; DIV-NOT:    idivu
69     ; DIV:        idiv
70
71     %tmp.3 = add i32 %tmp.1, %tmp.2
72     ret i32 %tmp.3
73     ; FUN:        rtsd
74     ; DIV:        rtsd
75 }