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 4 5; Because all of these addresses are foldable, the scalar cost should be 0 when 6; computing the pointers chain cost. 7; 8; TODO: These are currently costed as free the indices are all constants, but we 9; should check if the constants are actually foldable 10define void @f(ptr %dest, i64 %i) { 11; CHECK-LABEL: define void @f 12; CHECK-SAME: (ptr [[DEST:%.*]], i64 [[I:%.*]]) #[[ATTR0:[0-9]+]] { 13; CHECK-NEXT: entry: 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 17; 18entry: 19; YAML: Pass: slp-vectorizer 20; YAML-NEXT: Name: StoresVectorized 21; YAML-NEXT: Function: f 22; YAML-NEXT: Args: 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 28 store i32 1, ptr %p1 29 %p2 = getelementptr i32, ptr %dest, i32 1 30 store i32 1, ptr %p2 31 %p3 = getelementptr i32, ptr %dest, i32 2 32 store i32 1, ptr %p3 33 %p4 = getelementptr i32, ptr %dest, i32 3 34 store i32 1, ptr %p4 35 ret void 36} 37 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 40; 1. 41; 42; TODO: These are currently costed as free the indices are all constants, but we 43; should check if the constants are actually foldable 44define void @g(ptr %dest, i64 %i) { 45; CHECK-LABEL: define void @g 46; CHECK-SAME: (ptr [[DEST:%.*]], i64 [[I:%.*]]) #[[ATTR0]] { 47; CHECK-NEXT: entry: 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 51; 52entry: 53; YAML: Pass: slp-vectorizer 54; YAML-NEXT: Name: StoresVectorized 55; YAML-NEXT: Function: g 56; YAML-NEXT: Args: 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 62 store i32 1, ptr %p1 63 %p2 = getelementptr i32, ptr %dest, i32 2049 64 store i32 1, ptr %p2 65 %p3 = getelementptr i32, ptr %dest, i32 2050 66 store i32 1, ptr %p3 67 %p4 = getelementptr i32, ptr %dest, i32 2051 68 store i32 1, ptr %p4 69 ret void 70} 71 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 74; should be 1. 75define void @h(ptr %dest, i32 %i) { 76; CHECK-LABEL: define void @h 77; CHECK-SAME: (ptr [[DEST:%.*]], i32 [[I:%.*]]) #[[ATTR0]] { 78; CHECK-NEXT: entry: 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 82; 83entry: 84; YAML: Pass: slp-vectorizer 85; YAML-NEXT: Name: StoresVectorized 86; YAML-NEXT: Function: h 87; YAML-NEXT: Args: 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 93 store i32 1, ptr %p1 94 %p2 = getelementptr [4 x i32], ptr %dest, i32 %i, i32 1 95 store i32 1, ptr %p2 96 %p3 = getelementptr [4 x i32], ptr %dest, i32 %i, i32 2 97 store i32 1, ptr %p3 98 %p4 = getelementptr [4 x i32], ptr %dest, i32 %i, i32 3 99 store i32 1, ptr %p4 100 ret void 101} 102