1 ; RUN: llc < %s -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -mattr=+neon | FileCheck %s
3 ; This test checks that pmull2 instruction is used for vmull_high_p64 intrinsic.
4 ; There are two extraction operations located in different basic blocks:
6 ; %4 = extractelement <2 x i64> %0, i32 1
7 ; %12 = extractelement <2 x i64> %9, i32 1
11 ; @llvm.aarch64.neon.pmull64(i64 %12, i64 %4) #2
13 ; We test that pattern replacing llvm.aarch64.neon.pmull64 with pmull2
16 ; IR for that test was generated from the following .cpp file:
18 ; #include <arm_neon.h>
24 ; void func (SS *g, unsigned int count, const unsigned char *buf, poly128_t* res )
26 ; const uint64x2_t x = g->x;
27 ; const uint64x2_t h = g->h;
28 ; uint64x2_t ci = g->x;
30 ; for (int i = 0; i < count; i+=2, buf += 16) {
31 ; ci = vreinterpretq_u64_u8(veorq_u8(vreinterpretq_u8_u64(ci),
32 ; vrbitq_u8(vld1q_u8(buf))));
33 ; res[i] = vmull_p64((poly64_t)vget_low_p64(vreinterpretq_p64_u64(ci)),
34 ; (poly64_t)vget_low_p64(vreinterpretq_p64_u64(h)));
35 ; res[i+1] = vmull_high_p64(vreinterpretq_p64_u64(ci),
36 ; vreinterpretq_p64_u64(h));
44 %struct.SS = type { <2 x i64>, <2 x i64> }
46 ; Function Attrs: nofree noinline nounwind
47 define dso_local void @_Z4funcP2SSjPKhPo(%struct.SS* nocapture readonly %g, i32 %count, i8* nocapture readonly %buf, i128* nocapture %res) local_unnamed_addr #0 {
49 %h2 = getelementptr inbounds %struct.SS, %struct.SS* %g, i64 0, i32 1
50 %0 = load <2 x i64>, <2 x i64>* %h2, align 16
51 %cmp34 = icmp eq i32 %count, 0
52 br i1 %cmp34, label %for.cond.cleanup, label %for.body.lr.ph
54 for.body.lr.ph: ; preds = %entry
55 %1 = bitcast %struct.SS* %g to <16 x i8>*
56 %2 = load <16 x i8>, <16 x i8>* %1, align 16
57 %3 = extractelement <2 x i64> %0, i32 0
58 %4 = extractelement <2 x i64> %0, i32 1
59 %5 = zext i32 %count to i64
62 for.cond.cleanup: ; preds = %for.body, %entry
65 for.body: ; preds = %for.body.lr.ph, %for.body
66 %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
67 %buf.addr.036 = phi i8* [ %buf, %for.body.lr.ph ], [ %add.ptr, %for.body ]
68 %6 = phi <16 x i8> [ %2, %for.body.lr.ph ], [ %xor.i, %for.body ]
69 %7 = bitcast i8* %buf.addr.036 to <16 x i8>*
70 %8 = load <16 x i8>, <16 x i8>* %7, align 16
71 %vrbit.i = call <16 x i8> @llvm.aarch64.neon.rbit.v16i8(<16 x i8> %8) #0
72 %xor.i = xor <16 x i8> %vrbit.i, %6
73 %9 = bitcast <16 x i8> %xor.i to <2 x i64>
74 %10 = extractelement <2 x i64> %9, i32 0
75 %vmull_p64.i = call <16 x i8> @llvm.aarch64.neon.pmull64(i64 %10, i64 %3) #0
76 %arrayidx = getelementptr inbounds i128, i128* %res, i64 %indvars.iv
77 %11 = bitcast i128* %arrayidx to <16 x i8>*
78 store <16 x i8> %vmull_p64.i, <16 x i8>* %11, align 16
79 %12 = extractelement <2 x i64> %9, i32 1
80 %vmull_p64.i.i = call <16 x i8> @llvm.aarch64.neon.pmull64(i64 %12, i64 %4) #0
81 %13 = or i64 %indvars.iv, 1
82 %arrayidx16 = getelementptr inbounds i128, i128* %res, i64 %13
83 %14 = bitcast i128* %arrayidx16 to <16 x i8>*
84 store <16 x i8> %vmull_p64.i.i, <16 x i8>* %14, align 16
85 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
86 %add.ptr = getelementptr inbounds i8, i8* %buf.addr.036, i64 16
87 %cmp = icmp ult i64 %indvars.iv.next, %5
88 br i1 %cmp, label %for.body, label %for.cond.cleanup
91 ; Function Attrs: nounwind readnone
92 declare <16 x i8> @llvm.aarch64.neon.rbit.v16i8(<16 x i8>) #0
94 ; Function Attrs: nounwind readnone
95 declare <16 x i8> @llvm.aarch64.neon.pmull64(i64, i64) #0
97 attributes #0 = { nofree noinline nounwind }