1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -mtriple=riscv64 -mattr=+v -riscv-v-slp-max-vf=0 -passes=slp-vectorizer -pass-remarks-output=%t < %s | FileCheck %s
3 ; RUN: FileCheck --input-file=%t --check-prefix=YAML %s
5 ; Because all of these addresses are foldable, the scalar cost should be 0 when
6 ; computing the pointers chain cost.
8 ; TODO: These are currently costed as free the indices are all constants, but we
9 ; should check if the constants are actually foldable
10 define void @f(ptr %dest, i64 %i) {
11 ; CHECK-LABEL: define void @f
12 ; CHECK-SAME: (ptr [[DEST:%.*]], i64 [[I:%.*]]) #[[ATTR0:[0-9]+]] {
14 ; CHECK-NEXT: [[P1:%.*]] = getelementptr i32, ptr [[DEST]], i32 0
15 ; CHECK-NEXT: store <4 x i32> splat (i32 1), ptr [[P1]], align 4
16 ; CHECK-NEXT: ret void
19 ; YAML: Pass: slp-vectorizer
20 ; YAML-NEXT: Name: StoresVectorized
21 ; YAML-NEXT: Function: f
23 ; YAML-NEXT: - String: 'Stores SLP vectorized with cost '
24 ; YAML-NEXT: - Cost: '-2'
25 ; YAML-NEXT: - String: ' and with tree size '
26 ; YAML-NEXT: - TreeSize: '2'
27 %p1 = getelementptr i32, ptr %dest, i32 0
29 %p2 = getelementptr i32, ptr %dest, i32 1
31 %p3 = getelementptr i32, ptr %dest, i32 2
33 %p4 = getelementptr i32, ptr %dest, i32 3
38 ; When computing the scalar pointers chain cost here, there is a cost of 1 for
39 ; the base pointer, and the rest can be folded in, so the scalar cost should be
42 ; TODO: These are currently costed as free the indices are all constants, but we
43 ; should check if the constants are actually foldable
44 define void @g(ptr %dest, i64 %i) {
45 ; CHECK-LABEL: define void @g
46 ; CHECK-SAME: (ptr [[DEST:%.*]], i64 [[I:%.*]]) #[[ATTR0]] {
48 ; CHECK-NEXT: [[P1:%.*]] = getelementptr i32, ptr [[DEST]], i32 2048
49 ; CHECK-NEXT: store <4 x i32> splat (i32 1), ptr [[P1]], align 4
50 ; CHECK-NEXT: ret void
53 ; YAML: Pass: slp-vectorizer
54 ; YAML-NEXT: Name: StoresVectorized
55 ; YAML-NEXT: Function: g
57 ; YAML-NEXT: - String: 'Stores SLP vectorized with cost '
58 ; YAML-NEXT: - Cost: '-2'
59 ; YAML-NEXT: - String: ' and with tree size '
60 ; YAML-NEXT: - TreeSize: '2'
61 %p1 = getelementptr i32, ptr %dest, i32 2048
63 %p2 = getelementptr i32, ptr %dest, i32 2049
65 %p3 = getelementptr i32, ptr %dest, i32 2050
67 %p4 = getelementptr i32, ptr %dest, i32 2051
72 ; When computing the scalar pointers chain cost here, there is a cost of
73 ; 1 for the base pointer, and the rest can be folded in, so the scalar cost
75 define void @h(ptr %dest, i32 %i) {
76 ; CHECK-LABEL: define void @h
77 ; CHECK-SAME: (ptr [[DEST:%.*]], i32 [[I:%.*]]) #[[ATTR0]] {
79 ; CHECK-NEXT: [[P1:%.*]] = getelementptr [4 x i32], ptr [[DEST]], i32 [[I]], i32 0
80 ; CHECK-NEXT: store <4 x i32> splat (i32 1), ptr [[P1]], align 4
81 ; CHECK-NEXT: ret void
84 ; YAML: Pass: slp-vectorizer
85 ; YAML-NEXT: Name: StoresVectorized
86 ; YAML-NEXT: Function: h
88 ; YAML-NEXT: - String: 'Stores SLP vectorized with cost '
89 ; YAML-NEXT: - Cost: '-2'
90 ; YAML-NEXT: - String: ' and with tree size '
91 ; YAML-NEXT: - TreeSize: '2'
92 %p1 = getelementptr [4 x i32], ptr %dest, i32 %i, i32 0
94 %p2 = getelementptr [4 x i32], ptr %dest, i32 %i, i32 1
96 %p3 = getelementptr [4 x i32], ptr %dest, i32 %i, i32 2
98 %p4 = getelementptr [4 x i32], ptr %dest, i32 %i, i32 3