File: buildvector-float-and-extract-lane1.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (40 lines) | stat: -rw-r--r-- 1,711 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
; RUN: opt -passes=slp-vectorizer -mtriple=-x86_64-grtev4-linux-gnu -S -mcpu=corei7-avx -pass-remarks-output=%t < %s | FileCheck %s
; RUN: FileCheck --input-file=%t --check-prefix=YAML %s

; Building a vector of a float (lane 0) and an extract from lane 1 (lane 1)
; should have a cost of +1 because we need an extra instruction to combine
; both into a single vector.
; So this code should not be vectorized.

; YAML: --- !Missed
; YAML: Pass:            slp-vectorizer
; YAML: Name:            NotBeneficial
; YAML: Function:        test
; YAML: Args:
; YAML:   - String:          'List vectorization was possible but not beneficial with cost '
; YAML:   - Cost:            '0'
; YAML:   - String:          ' >= '
; YAML:   - Treshold:        '0'
; YAML: ...
define void @test(<4 x float> %vec, float %a, float %b, ptr %ptr) {
; CHECK-LABEL: define void @test
; CHECK-SAME: (<4 x float> [[VEC:%.*]], float [[A:%.*]], float [[B:%.*]], ptr [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT:    [[FADD:%.*]] = fadd float [[A]], [[B]]
; CHECK-NEXT:    [[EXTR1:%.*]] = extractelement <4 x float> [[VEC]], i64 1
; CHECK-NEXT:    [[FSUB0:%.*]] = fsub float [[FADD]], [[FADD]]
; CHECK-NEXT:    [[FSUB1:%.*]] = fsub float [[EXTR1]], [[EXTR1]]
; CHECK-NEXT:    [[ROOT:%.*]] = fadd float [[FSUB0]], [[FSUB1]]
; CHECK-NEXT:    store float [[ROOT]], ptr [[PTR]], align 4
; CHECK-NEXT:    ret void
;
  %fadd = fadd float %a, %b
  %extr1 = extractelement <4 x float> %vec, i64 1

  %fsub0 = fsub float %fadd, %fadd
  %fsub1 = fsub float %extr1, %extr1

  %root = fadd float %fsub0, %fsub1
  store float %root, ptr %ptr
  ret void
}