1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK
4 define <2 x i32> @and_extract_zext_idx0(<4 x i16> %vec) nounwind {
5 ; CHECK-LABEL: and_extract_zext_idx0:
7 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
8 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
10 %zext = zext <4 x i16> %vec to <4 x i32>
11 %extract = call <2 x i32> @llvm.vector.extract.v2i32.v4i32(<4 x i32> %zext, i64 0)
12 %and = and <2 x i32> %extract, <i32 65535, i32 65535>
16 define <4 x i16> @and_extract_sext_idx0(<8 x i8> %vec) nounwind {
17 ; CHECK-LABEL: and_extract_sext_idx0:
19 ; CHECK-NEXT: ushll v0.8h, v0.8b, #0
20 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
22 %sext = sext <8 x i8> %vec to <8 x i16>
23 %extract = call <4 x i16> @llvm.vector.extract.v4i16.v8i16(<8 x i16> %sext, i64 0)
24 %and = and <4 x i16> %extract, <i16 255, i16 255, i16 255, i16 255>
28 define <2 x i32> @and_extract_zext_idx2(<4 x i16> %vec) nounwind {
29 ; CHECK-LABEL: and_extract_zext_idx2:
31 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
32 ; CHECK-NEXT: ext v0.16b, v0.16b, v0.16b, #8
33 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
35 %zext = zext <4 x i16> %vec to <4 x i32>
36 %extract = call <2 x i32> @llvm.vector.extract.v2i32.v4i32(<4 x i32> %zext, i64 2)
37 %and = and <2 x i32> %extract, <i32 65535, i32 65535>
41 define <4 x i16> @and_extract_sext_idx4(<8 x i8> %vec) nounwind {
42 ; CHECK-LABEL: and_extract_sext_idx4:
44 ; CHECK-NEXT: ushll v0.8h, v0.8b, #0
45 ; CHECK-NEXT: ext v0.16b, v0.16b, v0.16b, #8
46 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
48 %sext = sext <8 x i8> %vec to <8 x i16>
49 %extract = call <4 x i16> @llvm.vector.extract.v4i16.v8i16(<8 x i16> %sext, i64 4)
50 %and = and <4 x i16> %extract, <i16 255, i16 255, i16 255, i16 255>
54 define <2 x i32> @sext_extract_zext_idx0(<4 x i16> %vec) nounwind {
55 ; CHECK-LABEL: sext_extract_zext_idx0:
57 ; CHECK-NEXT: sshll v0.4s, v0.4h, #0
58 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
60 %zext = zext <4 x i16> %vec to <4 x i32>
61 %extract = call <2 x i32> @llvm.vector.extract.v2i32.v4i32(<4 x i32> %zext, i64 0)
62 %sext_inreg_step0 = shl <2 x i32> %extract, <i32 16, i32 16>
63 %sext_inreg = ashr <2 x i32> %sext_inreg_step0, <i32 16, i32 16>
64 ret <2 x i32> %sext_inreg
67 ; Negative test, combine should not fire if sign extension is for a different width.
68 define <2 x i32> @sext_extract_zext_idx0_negtest(<4 x i16> %vec) nounwind {
69 ; CHECK-LABEL: sext_extract_zext_idx0_negtest:
71 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
72 ; CHECK-NEXT: shl v0.2s, v0.2s, #17
73 ; CHECK-NEXT: sshr v0.2s, v0.2s, #17
75 %zext = zext <4 x i16> %vec to <4 x i32>
76 %extract = call <2 x i32> @llvm.vector.extract.v2i32.v4i32(<4 x i32> %zext, i64 0)
77 %sext_inreg_step0 = shl <2 x i32> %extract, <i32 17, i32 17>
78 %sext_inreg = ashr <2 x i32> %sext_inreg_step0, <i32 17, i32 17>
79 ret <2 x i32> %sext_inreg
82 define <4 x i16> @sext_extract_sext_idx0(<8 x i8> %vec) nounwind {
83 ; CHECK-LABEL: sext_extract_sext_idx0:
85 ; CHECK-NEXT: sshll v0.8h, v0.8b, #0
86 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
88 %sext = sext <8 x i8> %vec to <8 x i16>
89 %extract = call <4 x i16> @llvm.vector.extract.v4i16.v8i16(<8 x i16> %sext, i64 0)
90 %sext_inreg_step0 = shl <4 x i16> %extract, <i16 8, i16 8, i16 8, i16 8>
91 %sext_inreg = ashr <4 x i16> %sext_inreg_step0, <i16 8, i16 8, i16 8, i16 8>
92 ret <4 x i16> %sext_inreg
95 define <2 x i32> @sext_extract_zext_idx2(<4 x i16> %vec) nounwind {
96 ; CHECK-LABEL: sext_extract_zext_idx2:
98 ; CHECK-NEXT: sshll v0.4s, v0.4h, #0
99 ; CHECK-NEXT: ext v0.16b, v0.16b, v0.16b, #8
100 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
102 %zext = zext <4 x i16> %vec to <4 x i32>
103 %extract = call <2 x i32> @llvm.vector.extract.v2i32.v4i32(<4 x i32> %zext, i64 2)
104 %sext_inreg_step0 = shl <2 x i32> %extract, <i32 16, i32 16>
105 %sext_inreg = ashr <2 x i32> %sext_inreg_step0, <i32 16, i32 16>
106 ret <2 x i32> %sext_inreg
109 define <4 x i16> @sext_extract_sext_idx4(<8 x i8> %vec) nounwind {
110 ; CHECK-LABEL: sext_extract_sext_idx4:
112 ; CHECK-NEXT: sshll v0.8h, v0.8b, #0
113 ; CHECK-NEXT: ext v0.16b, v0.16b, v0.16b, #8
114 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
116 %sext = sext <8 x i8> %vec to <8 x i16>
117 %extract = call <4 x i16> @llvm.vector.extract.v4i16.v8i16(<8 x i16> %sext, i64 4)
118 %sext_inreg_step0 = shl <4 x i16> %extract, <i16 8, i16 8, i16 8, i16 8>
119 %sext_inreg = ashr <4 x i16> %sext_inreg_step0, <i16 8, i16 8, i16 8, i16 8>
120 ret <4 x i16> %sext_inreg
123 declare <2 x i32> @llvm.vector.extract.v2i32.v4i32(<4 x i32>, i64)
124 declare <4 x i16> @llvm.vector.extract.v4i16.v8i16(<8 x i16>, i64)