xref: /llvm-project/llvm/test/Transforms/SLPVectorizer/X86/extractelement-multiple-uses.ll (revision 93a9be0cea0a4c8da820b455fb279ece09a5ca70)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux -mattr=+avx2 -pass-remarks-output=%t | FileCheck %s
3; RUN: FileCheck %s --input-file=%t --check-prefix=YAML
4
5; YAML: --- !Passed
6; YAML: Pass:            slp-vectorizer
7; YAML: Name:            VectorizedList
8; YAML: Function:        multi_uses
9; YAML: Args:
10; YAML:  - String:          'SLP vectorized with cost '
11; YAML:  - Cost:            '-1'
12; YAML:  - String:          ' and with tree size '
13; YAML:  - TreeSize:        '3'
14
15define float @multi_uses(<2 x float> %x, <2 x float> %y) {
16; CHECK-LABEL: @multi_uses(
17; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <2 x float> [[Y:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 1>
18; CHECK-NEXT:    [[TMP2:%.*]] = fmul <2 x float> [[X:%.*]], [[TMP1]]
19; CHECK-NEXT:    [[TMP3:%.*]] = extractelement <2 x float> [[TMP2]], i32 0
20; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x float> [[TMP2]], i32 1
21; CHECK-NEXT:    [[ADD:%.*]] = fadd float [[TMP3]], [[TMP4]]
22; CHECK-NEXT:    ret float [[ADD]]
23;
24  %x0 = extractelement <2 x float> %x, i32 0
25  %x1 = extractelement <2 x float> %x, i32 1
26  %y1 = extractelement <2 x float> %y, i32 1
27  %x0x0 = fmul float %x0, %y1
28  %x1x1 = fmul float %x1, %y1
29  %add = fadd float %x0x0, %x1x1
30  ret float %add
31}
32