1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -slp-vectorizer -instcombine -pass-remarks-output=%t | FileCheck %s
3 ; RUN: cat %t | FileCheck -check-prefix=REMARK %s
4 ; RUN: opt < %s -S -passes='slp-vectorizer,instcombine' -pass-remarks-output=%t | FileCheck %s
5 ; RUN: cat %t | FileCheck -check-prefix=REMARK %s
7 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
8 target triple = "aarch64--linux-gnu"
10 ; REMARK-LABEL: Function: gather_multiple_use
12 ; REMARK-NEXT: - String: 'Vectorized horizontal reduction with cost '
13 ; REMARK-NEXT: - Cost: '-7'
15 define internal i32 @gather_multiple_use(i32 %a, i32 %b, i32 %c, i32 %d) {
16 ; CHECK-LABEL: @gather_multiple_use(
17 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> undef, i32 [[C:%.*]], i32 0
18 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i32> [[TMP1]], i32 [[A:%.*]], i32 1
19 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i32> [[TMP2]], i32 [[B:%.*]], i32 2
20 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x i32> [[TMP3]], i32 [[D:%.*]], i32 3
21 ; CHECK-NEXT: [[TMP5:%.*]] = lshr <4 x i32> [[TMP4]], <i32 15, i32 15, i32 15, i32 15>
22 ; CHECK-NEXT: [[TMP6:%.*]] = and <4 x i32> [[TMP5]], <i32 65537, i32 65537, i32 65537, i32 65537>
23 ; CHECK-NEXT: [[TMP7:%.*]] = mul nuw <4 x i32> [[TMP6]], <i32 65535, i32 65535, i32 65535, i32 65535>
24 ; CHECK-NEXT: [[TMP8:%.*]] = add <4 x i32> [[TMP7]], [[TMP4]]
25 ; CHECK-NEXT: [[TMP9:%.*]] = xor <4 x i32> [[TMP8]], [[TMP7]]
26 ; CHECK-NEXT: [[TMP10:%.*]] = call i32 @llvm.experimental.vector.reduce.add.v4i32(<4 x i32> [[TMP9]])
27 ; CHECK-NEXT: ret i32 [[TMP10]]
29 %tmp00 = lshr i32 %a, 15
30 %tmp01 = and i32 %tmp00, 65537
31 %tmp02 = mul nuw i32 %tmp01, 65535
32 %tmp03 = add i32 %tmp02, %a
33 %tmp04 = xor i32 %tmp03, %tmp02
34 %tmp05 = lshr i32 %c, 15
35 %tmp06 = and i32 %tmp05, 65537
36 %tmp07 = mul nuw i32 %tmp06, 65535
37 %tmp08 = add i32 %tmp07, %c
38 %tmp09 = xor i32 %tmp08, %tmp07
39 %tmp10 = lshr i32 %b, 15
40 %tmp11 = and i32 %tmp10, 65537
41 %tmp12 = mul nuw i32 %tmp11, 65535
42 %tmp13 = add i32 %tmp12, %b
43 %tmp14 = xor i32 %tmp13, %tmp12
44 %tmp15 = lshr i32 %d, 15
45 %tmp16 = and i32 %tmp15, 65537
46 %tmp17 = mul nuw i32 %tmp16, 65535
47 %tmp18 = add i32 %tmp17, %d
48 %tmp19 = xor i32 %tmp18, %tmp17
49 %tmp20 = add i32 %tmp09, %tmp04
50 %tmp21 = add i32 %tmp20, %tmp14
51 %tmp22 = add i32 %tmp21, %tmp19