1 ; RUN: llc -mtriple=armv7 %s -o - | FileCheck %s
2 ; RUN: llc -mtriple=thumb-eabi -mcpu=arm1156t2-s -mattr=+thumb2 %s -o - | FileCheck %s --check-prefix=CHECK-T2
4 define i1 @f1(i32 %a, i32 %b) {
6 ; CHECK: subs r0, r0, r1
8 ; CHECK-T2: subs r0, r0, r1
10 ; CHECK-T2: movne r0, #1
11 %tmp = icmp ne i32 %a, %b
15 define i1 @f2(i32 %a, i32 %b) {
17 ; CHECK: sub r0, r0, r1
19 ; CHECK: lsr r0, r0, #5
20 ; CHECK-T2: subs r0, r0, r1
21 ; CHECK-T2: clz r0, r0
22 ; CHECK-T2: lsrs r0, r0, #5
23 %tmp = icmp eq i32 %a, %b
27 define i1 @f6(i32 %a, i32 %b) {
29 ; CHECK: sub r0, r0, r1, lsl #5
31 ; CHECK: lsr r0, r0, #5
32 ; CHECK-T2: sub.w r0, r0, r1, lsl #5
33 ; CHECK-T2: clz r0, r0
34 ; CHECK-T2: lsrs r0, r0, #5
36 %tmp1 = icmp eq i32 %a, %tmp
40 define i1 @f7(i32 %a, i32 %b) {
42 ; CHECK: subs r0, r0, r1, lsr #6
43 ; CHECK: movwne r0, #1
44 ; CHECK-T2: subs.w r0, r0, r1, lsr #6
46 ; CHECK-T2: movne r0, #1
48 %tmp1 = icmp ne i32 %a, %tmp
52 define i1 @f8(i32 %a, i32 %b) {
54 ; CHECK: sub r0, r0, r1, asr #7
56 ; CHECK: lsr r0, r0, #5
57 ; CHECK-T2: sub.w r0, r0, r1, asr #7
58 ; CHECK-T2: clz r0, r0
59 ; CHECK-T2: lsrs r0, r0, #5
61 %tmp1 = icmp eq i32 %a, %tmp
65 define i1 @f9(i32 %a) {
67 ; CHECK: subs r0, r0, r0, ror #8
68 ; CHECK: movwne r0, #1
69 ; CHECK-T2: subs.w r0, r0, r0, ror #8
71 ; CHECK-T2: movne r0, #1
74 %tmp = or i32 %l8, %r8
75 %tmp1 = icmp ne i32 %a, %tmp
79 ; CHECK-LABEL: swap_cmp_shl
81 ; CHECK: cmp r1, r0, lsl #11
82 ; CHECK: movwlt r2, #1
83 ; CHECK-T2: mov{{.*}} r2, #0
84 ; CHECK-T2: cmp.w r1, r0, lsl #11
85 ; CHECK-T2: movlt r2, #1
86 define arm_aapcscc i32 @swap_cmp_shl(i32 %a, i32 %b) {
88 %shift = shl i32 %a, 11
89 %cmp = icmp sgt i32 %shift, %b
90 %conv = zext i1 %cmp to i32
94 ; CHECK-LABEL: swap_cmp_lshr
96 ; CHECK: cmp r1, r0, lsr #11
97 ; CHECK: movwhi r2, #1
98 ; CHECK-T2: mov{{.*}} r2, #0
99 ; CHECK-T2: cmp.w r1, r0, lsr #11
100 ; CHECK-T2: movhi r2, #1
101 define arm_aapcscc i32 @swap_cmp_lshr(i32 %a, i32 %b) {
103 %shift = lshr i32 %a, 11
104 %cmp = icmp ult i32 %shift, %b
105 %conv = zext i1 %cmp to i32
109 ; CHECK-LABEL: swap_cmp_ashr
111 ; CHECK: cmp r1, r0, asr #11
112 ; CHECK: movwle r2, #1
113 ; CHECK-T2: mov{{.*}} r2, #0
114 ; CHECK-T2: cmp.w r1, r0, asr #11
115 ; CHECK-T2: movle r2, #1
116 define arm_aapcscc i32 @swap_cmp_ashr(i32 %a, i32 %b) {
118 %shift = ashr i32 %a, 11
119 %cmp = icmp sge i32 %shift, %b
120 %conv = zext i1 %cmp to i32
124 ; CHECK-LABEL: swap_cmp_rotr
126 ; CHECK: cmp r1, r0, ror #11
127 ; CHECK: movwls r2, #1
128 ; CHECK-T2: mov{{.*}} r2, #0
129 ; CHECK-T2: cmp.w r1, r0, ror #11
130 ; CHECK-T2: movls r2, #1
131 define arm_aapcscc i32 @swap_cmp_rotr(i32 %a, i32 %b) {
133 %lsr = lshr i32 %a, 11
134 %lsl = shl i32 %a, 21
135 %ror = or i32 %lsr, %lsl
136 %cmp = icmp uge i32 %ror, %b
137 %conv = zext i1 %cmp to i32