File: sve-gather-scatter-dag-combine.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (73 lines) | stat: -rw-r--r-- 3,929 bytes parent folder | download | duplicates (7)
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
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s

; Verify that DAG combine rules for LD1 + sext/zext don't apply when the
; result of LD1 has multiple uses

define <vscale x 2 x i64> @no_dag_combine_zext_sext(<vscale x 2 x i1> %pg,
                                                    <vscale x 2 x i64> %base,
                                                    <vscale x 2 x i8>* %res_out,
                                                    <vscale x 2 x i1> %pred) {
; CHECK-LABEL: no_dag_combine_zext_sext
; CHECK:  	ld1b	{ z0.d }, p0/z, [z0.d, #16]
; CHECK-NEXT:	st1b	{ z0.d }, p1, [x0]
; CHECK-NEXT:	and	z0.d, z0.d, #0xff
; CHECK-NEXT: ret
  %load = call <vscale x 2 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> %pg,
                                                                                           <vscale x 2 x i64> %base,
                                                                                           i64 16)
  %res1 = zext <vscale x 2 x i8> %load to <vscale x 2 x i64>
  %res2 = sext <vscale x 2 x i8> %load to <vscale x 2 x i64>
  call void @llvm.masked.store.nxv2i8(<vscale x 2 x i8> %load,
                                      <vscale x 2 x i8> *%res_out,
                                      i32 8,
                                      <vscale x 2 x i1> %pred)

  ret <vscale x 2 x i64> %res1
}

define <vscale x 2 x i64> @no_dag_combine_sext(<vscale x 2 x i1> %pg,
                                               <vscale x 2 x i64> %base,
                                               <vscale x 2 x i8>* %res_out,
                                               <vscale x 2 x i1> %pred) {
; CHECK-LABEL: no_dag_combine_sext
; CHECK:  	ld1b	{ z1.d }, p0/z, [z0.d, #16]
; CHECK-NEXT:	ptrue	p0.d
; CHECK-NEXT: movprfx z0, z1
; CHECK-NEXT:	sxtb	z0.d, p0/m, z1.d
; CHECK-NEXT:	st1b	{ z1.d }, p1, [x0]
; CHECK-NEXT:	ret
  %load = call <vscale x 2 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> %pg,
                                                                                           <vscale x 2 x i64> %base,
                                                                                           i64 16)
  %res = sext <vscale x 2 x i8> %load to <vscale x 2 x i64>
  call void @llvm.masked.store.nxv2i8(<vscale x 2 x i8> %load,
                                      <vscale x 2 x i8> *%res_out,
                                      i32 8,
                                      <vscale x 2 x i1> %pred)

  ret <vscale x 2 x i64> %res
}

define <vscale x 2 x i64> @no_dag_combine_zext(<vscale x 2 x i1> %pg,
                                               <vscale x 2 x i64> %base,
                                               <vscale x 2 x i8>* %res_out,
                                               <vscale x 2 x i1> %pred) {
; CHECK-LABEL: no_dag_combine_zext
; CHECK:  	ld1b	{ z0.d }, p0/z, [z0.d, #16]
; CHECK-NEXT:	st1b	{ z0.d }, p1, [x0]
; CHECK-NEXT:	and	z0.d, z0.d, #0xff
; CHECK-NEXT:	ret
  %load = call <vscale x 2 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> %pg,
                                                                                           <vscale x 2 x i64> %base,
                                                                                           i64 16)
  %res = zext <vscale x 2 x i8> %load to <vscale x 2 x i64>
  call void @llvm.masked.store.nxv2i8(<vscale x 2 x i8> %load,
                                      <vscale x 2 x i8> *%res_out,
                                      i32 8,
                                      <vscale x 2 x i1> %pred)

  ret <vscale x 2 x i64> %res
}

declare <vscale x 2 x i8> @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>, i64)
declare void @llvm.masked.store.nxv2i8(<vscale x 2 x i8>, <vscale x 2 x i8>*, i32, <vscale x 2 x i1>)