1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
4 define i16 @fold_srem_1_i16(i16 %x) {
5 ; CHECK-LABEL: fold_srem_1_i16:
7 ; CHECK-NEXT: mov w0, wzr
13 define i32 @fold_srem_1_i32(i32 %x) {
14 ; CHECK-LABEL: fold_srem_1_i32:
16 ; CHECK-NEXT: mov w0, wzr
22 define i64 @fold_srem_1_i64(i64 %x) {
23 ; CHECK-LABEL: fold_srem_1_i64:
25 ; CHECK-NEXT: mov x0, xzr
31 define i16 @fold_srem_2_i16(i16 %x) {
32 ; CHECK-LABEL: fold_srem_2_i16:
34 ; CHECK-NEXT: and w8, w0, #0x8000
35 ; CHECK-NEXT: add w8, w0, w8, lsr #15
36 ; CHECK-NEXT: and w8, w8, #0xfffffffe
37 ; CHECK-NEXT: sub w0, w0, w8
43 define i32 @fold_srem_2_i64(i32 %x) {
44 ; CHECK-LABEL: fold_srem_2_i64:
46 ; CHECK-NEXT: and w8, w0, #0x1
47 ; CHECK-NEXT: cmp w0, #0
48 ; CHECK-NEXT: cneg w0, w8, lt
54 define i64 @fold_srem_2_i32(i64 %x) {
55 ; CHECK-LABEL: fold_srem_2_i32:
57 ; CHECK-NEXT: and x8, x0, #0x1
58 ; CHECK-NEXT: cmp x0, #0
59 ; CHECK-NEXT: cneg x0, x8, lt
65 define i16 @fold_srem_pow2_i16(i16 %x) {
66 ; CHECK-LABEL: fold_srem_pow2_i16:
68 ; CHECK-NEXT: sxth w8, w0
69 ; CHECK-NEXT: ubfx w8, w8, #25, #6
70 ; CHECK-NEXT: add w8, w0, w8
71 ; CHECK-NEXT: and w8, w8, #0xffffffc0
72 ; CHECK-NEXT: sub w0, w0, w8
78 define i32 @fold_srem_pow2_i32(i32 %x) {
79 ; CHECK-LABEL: fold_srem_pow2_i32:
81 ; CHECK-NEXT: negs w8, w0
82 ; CHECK-NEXT: and w9, w0, #0x3f
83 ; CHECK-NEXT: and w8, w8, #0x3f
84 ; CHECK-NEXT: csneg w0, w9, w8, mi
90 define i64 @fold_srem_pow2_i64(i64 %x) {
91 ; CHECK-LABEL: fold_srem_pow2_i64:
93 ; CHECK-NEXT: negs x8, x0
94 ; CHECK-NEXT: and x9, x0, #0x3f
95 ; CHECK-NEXT: and x8, x8, #0x3f
96 ; CHECK-NEXT: csneg x0, x9, x8, mi
102 define i16 @fold_srem_smax_i16(i16 %x) {
103 ; CHECK-LABEL: fold_srem_smax_i16:
105 ; CHECK-NEXT: sxth w8, w0
106 ; CHECK-NEXT: ubfx w8, w8, #16, #15
107 ; CHECK-NEXT: add w8, w0, w8
108 ; CHECK-NEXT: and w8, w8, #0xffff8000
109 ; CHECK-NEXT: add w0, w0, w8
111 %1 = srem i16 %x, 32768
115 define i32 @fold_srem_smax_i32(i32 %x) {
116 ; CHECK-LABEL: fold_srem_smax_i32:
118 ; CHECK-NEXT: negs w8, w0
119 ; CHECK-NEXT: and w9, w0, #0x7fffffff
120 ; CHECK-NEXT: and w8, w8, #0x7fffffff
121 ; CHECK-NEXT: csneg w0, w9, w8, mi
123 %1 = srem i32 %x, 2147483648
127 define i64 @fold_srem_smax_i64(i64 %x) {
128 ; CHECK-LABEL: fold_srem_smax_i64:
130 ; CHECK-NEXT: negs x8, x0
131 ; CHECK-NEXT: and x9, x0, #0x7fffffffffffffff
132 ; CHECK-NEXT: and x8, x8, #0x7fffffffffffffff
133 ; CHECK-NEXT: csneg x0, x9, x8, mi
135 %1 = srem i64 %x, -9223372036854775808