1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
; RUN: llc -mtriple=aarch64 -mattr=+sve < %s -o - | FileCheck --check-prefixes=CHECK,SVE %s
; RUN: llc -mtriple=aarch64 -mattr=+sve2 < %s -o - | FileCheck --check-prefixes=CHECK,SVE2 %s
; Wrong add/shift amount. Should be 32 for shift of 6.
define <vscale x 2 x i64> @neg_urshr_1(<vscale x 2 x i64> %x) {
; CHECK-LABEL: neg_urshr_1:
; CHECK: // %bb.0:
; CHECK-NEXT: add z0.d, z0.d, #16 // =0x10
; CHECK-NEXT: lsr z0.d, z0.d, #6
; CHECK-NEXT: ret
%add = add nuw nsw <vscale x 2 x i64> %x, splat (i64 16)
%sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
ret <vscale x 2 x i64> %sh
}
; Vector Shift.
define <vscale x 2 x i64> @neg_urshr_2(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y) {
; CHECK-LABEL: neg_urshr_2:
; CHECK: // %bb.0:
; CHECK-NEXT: add z0.d, z0.d, #32 // =0x20
; CHECK-NEXT: ptrue p0.d
; CHECK-NEXT: lsr z0.d, p0/m, z0.d, z1.d
; CHECK-NEXT: ret
%add = add nuw nsw <vscale x 2 x i64> %x, splat (i64 32)
%sh = lshr <vscale x 2 x i64> %add, %y
ret <vscale x 2 x i64> %sh
}
; Vector Add.
define <vscale x 2 x i64> @neg_urshr_3(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y) {
; CHECK-LABEL: neg_urshr_3:
; CHECK: // %bb.0:
; CHECK-NEXT: add z0.d, z0.d, z1.d
; CHECK-NEXT: lsr z0.d, z0.d, #6
; CHECK-NEXT: ret
%add = add nuw nsw <vscale x 2 x i64> %x, %y
%sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
ret <vscale x 2 x i64> %sh
}
; Add has two uses.
define <vscale x 2 x i64> @neg_urshr_4(<vscale x 2 x i64> %x, ptr %p) {
; CHECK-LABEL: neg_urshr_4:
; CHECK: // %bb.0:
; CHECK-NEXT: mov z1.d, z0.d
; CHECK-NEXT: ptrue p0.d
; CHECK-NEXT: add z1.d, z1.d, #32 // =0x20
; CHECK-NEXT: lsr z0.d, z1.d, #6
; CHECK-NEXT: st1d { z1.d }, p0, [x0]
; CHECK-NEXT: ret
%add = add nuw nsw <vscale x 2 x i64> %x, splat (i64 32)
%sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
store <vscale x 2 x i64> %add, ptr %p
ret <vscale x 2 x i64> %sh
}
; Add can overflow.
define <vscale x 2 x i64> @neg_urshr_5(<vscale x 2 x i64> %x) {
; CHECK-LABEL: neg_urshr_5:
; CHECK: // %bb.0:
; CHECK-NEXT: add z0.d, z0.d, #32 // =0x20
; CHECK-NEXT: lsr z0.d, z0.d, #6
; CHECK-NEXT: ret
%add = add <vscale x 2 x i64> %x, splat (i64 32)
%sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
ret <vscale x 2 x i64> %sh
}
define <vscale x 16 x i8> @urshr_i8(<vscale x 16 x i8> %x) {
; SVE-LABEL: urshr_i8:
; SVE: // %bb.0:
; SVE-NEXT: add z0.b, z0.b, #32 // =0x20
; SVE-NEXT: lsr z0.b, z0.b, #6
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_i8:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.b
; SVE2-NEXT: urshr z0.b, p0/m, z0.b, #6
; SVE2-NEXT: ret
%add = add nuw nsw <vscale x 16 x i8> %x, splat (i8 32)
%sh = lshr <vscale x 16 x i8> %add, splat (i8 6)
ret <vscale x 16 x i8> %sh
}
define <vscale x 16 x i8> @urshr_8_wide_trunc(<vscale x 16 x i8> %x) {
; SVE-LABEL: urshr_8_wide_trunc:
; SVE: // %bb.0:
; SVE-NEXT: uunpkhi z1.h, z0.b
; SVE-NEXT: uunpklo z0.h, z0.b
; SVE-NEXT: add z0.h, z0.h, #32 // =0x20
; SVE-NEXT: add z1.h, z1.h, #32 // =0x20
; SVE-NEXT: lsr z1.h, z1.h, #6
; SVE-NEXT: lsr z0.h, z0.h, #6
; SVE-NEXT: uzp1 z0.b, z0.b, z1.b
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_8_wide_trunc:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.b
; SVE2-NEXT: urshr z0.b, p0/m, z0.b, #6
; SVE2-NEXT: ret
%ext = zext <vscale x 16 x i8> %x to <vscale x 16 x i16>
%add = add nuw nsw <vscale x 16 x i16> %ext, splat (i16 32)
%sh = lshr <vscale x 16 x i16> %add, splat (i16 6)
%sht = trunc <vscale x 16 x i16> %sh to <vscale x 16 x i8>
ret <vscale x 16 x i8> %sht
}
define <vscale x 16 x i8> @urshr_8_wide_trunc_nomerge(<vscale x 16 x i16> %ext) {
; SVE-LABEL: urshr_8_wide_trunc_nomerge:
; SVE: // %bb.0:
; SVE-NEXT: add z0.h, z0.h, #256 // =0x100
; SVE-NEXT: add z1.h, z1.h, #256 // =0x100
; SVE-NEXT: lsr z1.h, z1.h, #9
; SVE-NEXT: lsr z0.h, z0.h, #9
; SVE-NEXT: uzp1 z0.b, z0.b, z1.b
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_8_wide_trunc_nomerge:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.h
; SVE2-NEXT: urshr z1.h, p0/m, z1.h, #9
; SVE2-NEXT: urshr z0.h, p0/m, z0.h, #9
; SVE2-NEXT: uzp1 z0.b, z0.b, z1.b
; SVE2-NEXT: ret
%add = add nuw nsw <vscale x 16 x i16> %ext, splat (i16 256)
%sh = lshr <vscale x 16 x i16> %add, splat (i16 9)
%sht = trunc <vscale x 16 x i16> %sh to <vscale x 16 x i8>
ret <vscale x 16 x i8> %sht
}
define <vscale x 8 x i16> @urshr_i16(<vscale x 8 x i16> %x) {
; SVE-LABEL: urshr_i16:
; SVE: // %bb.0:
; SVE-NEXT: add z0.h, z0.h, #32 // =0x20
; SVE-NEXT: lsr z0.h, z0.h, #6
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_i16:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.h
; SVE2-NEXT: urshr z0.h, p0/m, z0.h, #6
; SVE2-NEXT: ret
%add = add nuw nsw <vscale x 8 x i16> %x, splat (i16 32)
%sh = lshr <vscale x 8 x i16> %add, splat (i16 6)
ret <vscale x 8 x i16> %sh
}
define <vscale x 8 x i16> @urshr_16_wide_trunc(<vscale x 8 x i16> %x) {
; SVE-LABEL: urshr_16_wide_trunc:
; SVE: // %bb.0:
; SVE-NEXT: uunpkhi z1.s, z0.h
; SVE-NEXT: uunpklo z0.s, z0.h
; SVE-NEXT: add z0.s, z0.s, #32 // =0x20
; SVE-NEXT: add z1.s, z1.s, #32 // =0x20
; SVE-NEXT: lsr z1.s, z1.s, #6
; SVE-NEXT: lsr z0.s, z0.s, #6
; SVE-NEXT: uzp1 z0.h, z0.h, z1.h
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_16_wide_trunc:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.h
; SVE2-NEXT: urshr z0.h, p0/m, z0.h, #6
; SVE2-NEXT: ret
%ext = zext <vscale x 8 x i16> %x to <vscale x 8 x i32>
%add = add nuw nsw <vscale x 8 x i32> %ext, splat (i32 32)
%sh = lshr <vscale x 8 x i32> %add, splat (i32 6)
%sht = trunc <vscale x 8 x i32> %sh to <vscale x 8 x i16>
ret <vscale x 8 x i16> %sht
}
define <vscale x 8 x i16> @urshr_16_wide_trunc_nomerge(<vscale x 8 x i32> %ext) {
; SVE-LABEL: urshr_16_wide_trunc_nomerge:
; SVE: // %bb.0:
; SVE-NEXT: mov z2.s, #0x10000
; SVE-NEXT: add z0.s, z0.s, z2.s
; SVE-NEXT: add z1.s, z1.s, z2.s
; SVE-NEXT: lsr z1.s, z1.s, #17
; SVE-NEXT: lsr z0.s, z0.s, #17
; SVE-NEXT: uzp1 z0.h, z0.h, z1.h
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_16_wide_trunc_nomerge:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.s
; SVE2-NEXT: urshr z1.s, p0/m, z1.s, #17
; SVE2-NEXT: urshr z0.s, p0/m, z0.s, #17
; SVE2-NEXT: uzp1 z0.h, z0.h, z1.h
; SVE2-NEXT: ret
%add = add nuw nsw <vscale x 8 x i32> %ext, splat (i32 65536)
%sh = lshr <vscale x 8 x i32> %add, splat (i32 17)
%sht = trunc <vscale x 8 x i32> %sh to <vscale x 8 x i16>
ret <vscale x 8 x i16> %sht
}
define <vscale x 4 x i32> @urshr_i32(<vscale x 4 x i32> %x) {
; SVE-LABEL: urshr_i32:
; SVE: // %bb.0:
; SVE-NEXT: add z0.s, z0.s, #32 // =0x20
; SVE-NEXT: lsr z0.s, z0.s, #6
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_i32:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.s
; SVE2-NEXT: urshr z0.s, p0/m, z0.s, #6
; SVE2-NEXT: ret
%add = add nuw nsw <vscale x 4 x i32> %x, splat (i32 32)
%sh = lshr <vscale x 4 x i32> %add, splat (i32 6)
ret <vscale x 4 x i32> %sh
}
define <vscale x 4 x i32> @urshr_32_wide_trunc(<vscale x 4 x i32> %x) {
; SVE-LABEL: urshr_32_wide_trunc:
; SVE: // %bb.0:
; SVE-NEXT: uunpkhi z1.d, z0.s
; SVE-NEXT: uunpklo z0.d, z0.s
; SVE-NEXT: add z0.d, z0.d, #32 // =0x20
; SVE-NEXT: add z1.d, z1.d, #32 // =0x20
; SVE-NEXT: lsr z1.d, z1.d, #6
; SVE-NEXT: lsr z0.d, z0.d, #6
; SVE-NEXT: uzp1 z0.s, z0.s, z1.s
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_32_wide_trunc:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.s
; SVE2-NEXT: urshr z0.s, p0/m, z0.s, #6
; SVE2-NEXT: ret
%ext = zext <vscale x 4 x i32> %x to <vscale x 4 x i64>
%add = add nuw nsw <vscale x 4 x i64> %ext, splat (i64 32)
%sh = lshr <vscale x 4 x i64> %add, splat (i64 6)
%sht = trunc <vscale x 4 x i64> %sh to <vscale x 4 x i32>
ret <vscale x 4 x i32> %sht
}
define <vscale x 4 x i32> @urshr_32_wide_trunc_nomerge(<vscale x 4 x i64> %ext) {
; SVE-LABEL: urshr_32_wide_trunc_nomerge:
; SVE: // %bb.0:
; SVE-NEXT: mov z2.d, #0x100000000
; SVE-NEXT: add z0.d, z0.d, z2.d
; SVE-NEXT: add z1.d, z1.d, z2.d
; SVE-NEXT: lsr z1.d, z1.d, #33
; SVE-NEXT: lsr z0.d, z0.d, #33
; SVE-NEXT: uzp1 z0.s, z0.s, z1.s
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_32_wide_trunc_nomerge:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.d
; SVE2-NEXT: urshr z1.d, p0/m, z1.d, #33
; SVE2-NEXT: urshr z0.d, p0/m, z0.d, #33
; SVE2-NEXT: uzp1 z0.s, z0.s, z1.s
; SVE2-NEXT: ret
%add = add nuw nsw <vscale x 4 x i64> %ext, splat (i64 4294967296)
%sh = lshr <vscale x 4 x i64> %add, splat (i64 33)
%sht = trunc <vscale x 4 x i64> %sh to <vscale x 4 x i32>
ret <vscale x 4 x i32> %sht
}
define <vscale x 2 x i64> @urshr_i64(<vscale x 2 x i64> %x) {
; SVE-LABEL: urshr_i64:
; SVE: // %bb.0:
; SVE-NEXT: add z0.d, z0.d, #32 // =0x20
; SVE-NEXT: lsr z0.d, z0.d, #6
; SVE-NEXT: ret
;
; SVE2-LABEL: urshr_i64:
; SVE2: // %bb.0:
; SVE2-NEXT: ptrue p0.d
; SVE2-NEXT: urshr z0.d, p0/m, z0.d, #6
; SVE2-NEXT: ret
%add = add nuw nsw <vscale x 2 x i64> %x, splat (i64 32)
%sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
ret <vscale x 2 x i64> %sh
}
|