1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=thumbv7m-none-eabi -o - | FileCheck %s
4 ; 0xff00ff00 = 4278255360
5 ; 0x00ff00ff = 16711935
6 define i32 @rev16(i32 %a) {
9 ; CHECK-NEXT: rev16 r0, r0
13 %mask_l8 = and i32 %l8, 4278255360
14 %mask_r8 = and i32 %r8, 16711935
15 %tmp = or i32 %mask_l8, %mask_r8
19 define i32 @not_rev16(i32 %a) {
20 ; CHECK-LABEL: not_rev16:
22 ; CHECK-NEXT: mov.w r1, #65280
23 ; CHECK-NEXT: and.w r1, r1, r0, lsr #8
24 ; CHECK-NEXT: and r0, r0, #65280
25 ; CHECK-NEXT: orr.w r0, r1, r0, lsl #8
29 %mask_r8 = and i32 %r8, 4278255360
30 %mask_l8 = and i32 %l8, 16711935
31 %tmp = or i32 %mask_r8, %mask_l8
35 define i32 @extra_maskop_uses2(i32 %a) {
36 ; CHECK-LABEL: extra_maskop_uses2:
38 ; CHECK-NEXT: mov.w r1, #-16711936
39 ; CHECK-NEXT: mov.w r2, #16711935
40 ; CHECK-NEXT: and.w r1, r1, r0, lsl #8
41 ; CHECK-NEXT: and.w r0, r2, r0, lsr #8
42 ; CHECK-NEXT: adds r2, r0, r1
43 ; CHECK-NEXT: muls r0, r1, r0
44 ; CHECK-NEXT: muls r0, r2, r0
48 %mask_l8 = and i32 %l8, 4278255360
49 %mask_r8 = and i32 %r8, 16711935
50 %or = or i32 %mask_r8, %mask_l8
51 %mul = mul i32 %mask_r8, %mask_l8 ; another use of the mask ops
52 %r = mul i32 %mul, %or ; and use that result
57 define i32 @bswap_ror_commuted(i32 %a) {
58 ; CHECK-LABEL: bswap_ror_commuted:
60 ; CHECK-NEXT: rev16 r0, r0
64 %mask_l8 = and i32 %l8, 4278255360
65 %mask_r8 = and i32 %r8, 16711935
66 %tmp = or i32 %mask_r8, %mask_l8
70 define i32 @different_shift_amount(i32 %a) {
71 ; CHECK-LABEL: different_shift_amount:
73 ; CHECK-NEXT: mov.w r1, #16711935
74 ; CHECK-NEXT: movw r2, #65024
75 ; CHECK-NEXT: and.w r1, r1, r0, lsr #8
76 ; CHECK-NEXT: movt r2, #65280
77 ; CHECK-NEXT: and.w r0, r2, r0, lsl #9
78 ; CHECK-NEXT: add r0, r1
82 %mask_l8 = and i32 %l8, 4278255360
83 %mask_r8 = and i32 %r8, 16711935
84 %tmp = or i32 %mask_l8, %mask_r8
88 define i32 @different_constant(i32 %a) {
89 ; CHECK-LABEL: different_constant:
91 ; CHECK-NEXT: mov.w r1, #16711935
92 ; CHECK-NEXT: and.w r0, r1, r0, lsr #8
96 %mask_l8 = and i32 %l8, 42
97 %mask_r8 = and i32 %r8, 16711935
98 %tmp = or i32 %mask_l8, %mask_r8
102 define i32 @different_op(i32 %a) {
103 ; CHECK-LABEL: different_op:
105 ; CHECK-NEXT: mov.w r1, #16711935
106 ; CHECK-NEXT: movw r2, #256
107 ; CHECK-NEXT: and.w r1, r1, r0, lsr #8
108 ; CHECK-NEXT: movt r2, #255
109 ; CHECK-NEXT: add.w r0, r2, r0, lsl #8
110 ; CHECK-NEXT: orrs r0, r1
114 %mask_l8 = sub i32 %l8, 4278255360
115 %mask_r8 = and i32 %r8, 16711935
116 %tmp = or i32 %mask_l8, %mask_r8
120 define i32 @different_vars(i32 %a, i32 %b) {
121 ; CHECK-LABEL: different_vars:
123 ; CHECK-NEXT: mov.w r2, #16711935
124 ; CHECK-NEXT: and.w r1, r2, r1, lsr #8
125 ; CHECK-NEXT: mov.w r2, #-16711936
126 ; CHECK-NEXT: and.w r0, r2, r0, lsl #8
127 ; CHECK-NEXT: add r0, r1
131 %mask_l8 = and i32 %l8, 4278255360
132 %mask_r8 = and i32 %r8, 16711935
133 %tmp = or i32 %mask_l8, %mask_r8
138 ; FIXME: this rev16 pattern is not matching
140 ; 0xff000000 = 4278190080
141 ; 0x00ff0000 = 16711680
144 define i32 @f2(i32 %a) {
147 ; CHECK-NEXT: mov.w r1, #16711680
148 ; CHECK-NEXT: and r2, r0, #16711680
149 ; CHECK-NEXT: and.w r1, r1, r0, lsr #8
150 ; CHECK-NEXT: orr.w r1, r1, r2, lsl #8
151 ; CHECK-NEXT: ubfx r2, r0, #8, #8
152 ; CHECK-NEXT: bfi r2, r0, #8, #8
153 ; CHECK-NEXT: adds r0, r2, r1
157 %masklo_l8 = and i32 %l8, 65280
158 %maskhi_l8 = and i32 %l8, 4278190080
159 %masklo_r8 = and i32 %r8, 255
160 %maskhi_r8 = and i32 %r8, 16711680
161 %tmp1 = or i32 %masklo_l8, %masklo_r8
162 %tmp2 = or i32 %maskhi_l8, %maskhi_r8
163 %tmp = or i32 %tmp1, %tmp2