1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -passes=slp-vectorizer < %s -mtriple=riscv64-unknown-linux -mattr=+v | FileCheck %s
4 define i32 @sum_of_abs(ptr noalias %a, ptr noalias %b) {
5 ; CHECK-LABEL: define i32 @sum_of_abs
6 ; CHECK-SAME: (ptr noalias [[A:%.*]], ptr noalias [[B:%.*]]) #[[ATTR0:[0-9]+]] {
8 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <8 x ptr> poison, ptr [[A]], i32 0
9 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <8 x ptr> [[TMP0]], <8 x ptr> poison, <8 x i32> zeroinitializer
10 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr i8, <8 x ptr> [[TMP1]], <8 x i64> <i64 0, i64 64, i64 128, i64 192, i64 256, i64 320, i64 384, i64 448>
11 ; CHECK-NEXT: [[TMP3:%.*]] = call <8 x i8> @llvm.masked.gather.v8i8.v8p0(<8 x ptr> [[TMP2]], i32 1, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i8> poison)
12 ; CHECK-NEXT: [[TMP4:%.*]] = call <8 x i8> @llvm.abs.v8i8(<8 x i8> [[TMP3]], i1 false)
13 ; CHECK-NEXT: [[TMP5:%.*]] = sext <8 x i8> [[TMP4]] to <8 x i32>
14 ; CHECK-NEXT: [[TMP6:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP5]])
15 ; CHECK-NEXT: ret i32 [[TMP6]]
18 %0 = load i8, ptr %a, align 1
19 %spec.select.i = tail call i8 @llvm.abs.i8(i8 %0, i1 false)
20 %conv = sext i8 %spec.select.i to i32
21 %arrayidx.1 = getelementptr inbounds i8, ptr %a, i64 64
22 %1 = load i8, ptr %arrayidx.1, align 1
23 %spec.select.i.1 = tail call i8 @llvm.abs.i8(i8 %1, i1 false)
24 %conv.1 = sext i8 %spec.select.i.1 to i32
25 %add.1 = add nsw i32 %conv, %conv.1
26 %arrayidx.2 = getelementptr inbounds i8, ptr %a, i64 128
27 %2 = load i8, ptr %arrayidx.2, align 1
28 %spec.select.i.2 = tail call i8 @llvm.abs.i8(i8 %2, i1 false)
29 %conv.2 = sext i8 %spec.select.i.2 to i32
30 %add.2 = add nsw i32 %add.1, %conv.2
31 %arrayidx.3 = getelementptr inbounds i8, ptr %a, i64 192
32 %3 = load i8, ptr %arrayidx.3, align 1
33 %spec.select.i.3 = tail call i8 @llvm.abs.i8(i8 %3, i1 false)
34 %conv.3 = sext i8 %spec.select.i.3 to i32
35 %add.3 = add nsw i32 %add.2, %conv.3
36 %arrayidx.4 = getelementptr inbounds i8, ptr %a, i64 256
37 %4 = load i8, ptr %arrayidx.4, align 1
38 %spec.select.i.4 = tail call i8 @llvm.abs.i8(i8 %4, i1 false)
39 %conv.4 = sext i8 %spec.select.i.4 to i32
40 %add.4 = add nsw i32 %add.3, %conv.4
41 %arrayidx.5 = getelementptr inbounds i8, ptr %a, i64 320
42 %5 = load i8, ptr %arrayidx.5, align 1
43 %spec.select.i.5 = tail call i8 @llvm.abs.i8(i8 %5, i1 false)
44 %conv.5 = sext i8 %spec.select.i.5 to i32
45 %add.5 = add nsw i32 %add.4, %conv.5
46 %arrayidx.6 = getelementptr inbounds i8, ptr %a, i64 384
47 %6 = load i8, ptr %arrayidx.6, align 1
48 %spec.select.i.6 = tail call i8 @llvm.abs.i8(i8 %6, i1 false)
49 %conv.6 = sext i8 %spec.select.i.6 to i32
50 %add.6 = add nsw i32 %add.5, %conv.6
51 %arrayidx.7 = getelementptr inbounds i8, ptr %a, i64 448
52 %7 = load i8, ptr %arrayidx.7, align 1
53 %spec.select.i.7 = tail call i8 @llvm.abs.i8(i8 %7, i1 false)
54 %conv.7 = sext i8 %spec.select.i.7 to i32
55 %add.7 = add nsw i32 %add.6, %conv.7
59 declare i8 @llvm.abs.i8(i8, i1 immarg)