1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=thumb-eabi < %s | FileCheck %s
4 define i1 @test_srem_odd(i29 %X) nounwind {
5 ; CHECK-LABEL: test_srem_odd:
7 ; CHECK-NEXT: ldr r1, .LCPI0_0
8 ; CHECK-NEXT: muls r1, r0, r1
9 ; CHECK-NEXT: ldr r0, .LCPI0_1
10 ; CHECK-NEXT: adds r0, r1, r0
11 ; CHECK-NEXT: ldr r1, .LCPI0_2
12 ; CHECK-NEXT: cmp r0, r1
13 ; CHECK-NEXT: blo .LBB0_2
14 ; CHECK-NEXT: @ %bb.1:
15 ; CHECK-NEXT: movs r0, #0
17 ; CHECK-NEXT: .LBB0_2:
18 ; CHECK-NEXT: movs r0, #1
20 ; CHECK-NEXT: .p2align 2
21 ; CHECK-NEXT: @ %bb.3:
22 ; CHECK-NEXT: .LCPI0_0:
23 ; CHECK-NEXT: .long 4208200280 @ 0xfad40a58
24 ; CHECK-NEXT: .LCPI0_1:
25 ; CHECK-NEXT: .long 21691752 @ 0x14afd68
26 ; CHECK-NEXT: .LCPI0_2:
27 ; CHECK-NEXT: .long 43383512 @ 0x295fad8
28 %srem = srem i29 %X, 99
29 %cmp = icmp eq i29 %srem, 0
33 define i1 @test_srem_even(i4 %X) nounwind {
34 ; CHECK-LABEL: test_srem_even:
36 ; CHECK-NEXT: .save {r7, lr}
37 ; CHECK-NEXT: push {r7, lr}
38 ; CHECK-NEXT: lsls r0, r0, #28
39 ; CHECK-NEXT: asrs r0, r0, #28
40 ; CHECK-NEXT: movs r1, #6
41 ; CHECK-NEXT: bl __aeabi_idivmod
42 ; CHECK-NEXT: subs r1, r1, #1
43 ; CHECK-NEXT: rsbs r0, r1, #0
44 ; CHECK-NEXT: adcs r0, r1
45 ; CHECK-NEXT: pop {r7}
46 ; CHECK-NEXT: pop {r1}
49 %cmp = icmp eq i4 %srem, 1
53 define i1 @test_srem_pow2_setne(i6 %X) nounwind {
54 ; CHECK-LABEL: test_srem_pow2_setne:
56 ; CHECK-NEXT: lsls r1, r0, #26
57 ; CHECK-NEXT: asrs r1, r1, #26
58 ; CHECK-NEXT: lsrs r1, r1, #30
59 ; CHECK-NEXT: adds r1, r0, r1
60 ; CHECK-NEXT: movs r2, #60
61 ; CHECK-NEXT: ands r2, r1
62 ; CHECK-NEXT: subs r1, r0, r2
63 ; CHECK-NEXT: movs r0, #63
64 ; CHECK-NEXT: ands r0, r1
65 ; CHECK-NEXT: subs r1, r0, #1
66 ; CHECK-NEXT: sbcs r0, r1
69 %cmp = icmp ne i6 %srem, 0
73 define <3 x i1> @test_srem_vec(<3 x i33> %X) nounwind {
74 ; CHECK-LABEL: test_srem_vec:
76 ; CHECK-NEXT: .save {r4, r5, r6, r7, lr}
77 ; CHECK-NEXT: push {r4, r5, r6, r7, lr}
78 ; CHECK-NEXT: .pad #12
79 ; CHECK-NEXT: sub sp, #12
80 ; CHECK-NEXT: movs r7, r3
81 ; CHECK-NEXT: str r2, [sp, #4] @ 4-byte Spill
82 ; CHECK-NEXT: movs r5, #1
83 ; CHECK-NEXT: ands r1, r5
84 ; CHECK-NEXT: rsbs r1, r1, #0
85 ; CHECK-NEXT: movs r6, #9
86 ; CHECK-NEXT: movs r3, #0
87 ; CHECK-NEXT: str r3, [sp] @ 4-byte Spill
88 ; CHECK-NEXT: movs r2, r6
89 ; CHECK-NEXT: bl __aeabi_ldivmod
90 ; CHECK-NEXT: movs r4, r2
91 ; CHECK-NEXT: movs r0, #3
92 ; CHECK-NEXT: str r0, [sp, #8] @ 4-byte Spill
93 ; CHECK-NEXT: eors r4, r0
94 ; CHECK-NEXT: orrs r4, r3
95 ; CHECK-NEXT: subs r0, r4, #1
96 ; CHECK-NEXT: sbcs r4, r0
97 ; CHECK-NEXT: ands r7, r5
98 ; CHECK-NEXT: rsbs r1, r7, #0
99 ; CHECK-NEXT: ldr r0, [sp, #4] @ 4-byte Reload
100 ; CHECK-NEXT: movs r2, r6
101 ; CHECK-NEXT: ldr r7, [sp] @ 4-byte Reload
102 ; CHECK-NEXT: movs r3, r7
103 ; CHECK-NEXT: bl __aeabi_ldivmod
104 ; CHECK-NEXT: movs r0, r5
105 ; CHECK-NEXT: bics r0, r3
106 ; CHECK-NEXT: movs r1, #2
107 ; CHECK-NEXT: mvns r6, r1
108 ; CHECK-NEXT: eors r6, r2
109 ; CHECK-NEXT: orrs r6, r0
110 ; CHECK-NEXT: subs r0, r6, #1
111 ; CHECK-NEXT: sbcs r6, r0
112 ; CHECK-NEXT: ldr r0, [sp, #36]
113 ; CHECK-NEXT: ands r0, r5
114 ; CHECK-NEXT: rsbs r1, r0, #0
115 ; CHECK-NEXT: movs r0, #8
116 ; CHECK-NEXT: mvns r2, r0
117 ; CHECK-NEXT: mvns r3, r7
118 ; CHECK-NEXT: ldr r0, [sp, #32]
119 ; CHECK-NEXT: bl __aeabi_ldivmod
120 ; CHECK-NEXT: ands r3, r5
121 ; CHECK-NEXT: ldr r0, [sp, #8] @ 4-byte Reload
122 ; CHECK-NEXT: eors r2, r0
123 ; CHECK-NEXT: orrs r2, r3
124 ; CHECK-NEXT: subs r0, r2, #1
125 ; CHECK-NEXT: sbcs r2, r0
126 ; CHECK-NEXT: movs r0, r4
127 ; CHECK-NEXT: movs r1, r6
128 ; CHECK-NEXT: add sp, #12
129 ; CHECK-NEXT: pop {r4, r5, r6, r7}
130 ; CHECK-NEXT: pop {r3}
132 %srem = srem <3 x i33> %X, <i33 9, i33 9, i33 -9>
133 %cmp = icmp ne <3 x i33> %srem, <i33 3, i33 -3, i33 3>