1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -mattr=+avx2 -S | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; In this test case we start trying to vectorize reduction but end up
8 ; in tryToVectorize() method which then can make several attempts to
9 ; find a pair (roots) for a tree that can be vectorized.
10 ; The order (path) it makes probes for various pairs is predefined by
11 ; the method implementation and it is not guaranteed that the best option
12 ; encountered first (like here).
14 define double @root_selection(double %a, double %b, double %c, double %d) local_unnamed_addr #0 {
15 ; CHECK-LABEL: @root_selection(
16 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x double> poison, double [[B:%.*]], i32 0
17 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x double> [[TMP1]], double [[A:%.*]], i32 1
18 ; CHECK-NEXT: [[TMP3:%.*]] = fdiv fast <2 x double> [[TMP2]], <double 5.000000e+00, double 7.000000e+00>
19 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x double> [[TMP3]], i32 0
20 ; CHECK-NEXT: [[I09:%.*]] = fmul fast double [[TMP4]], undef
21 ; CHECK-NEXT: [[I10:%.*]] = fsub fast double undef, [[I09]]
22 ; CHECK-NEXT: [[TMP5:%.*]] = fmul fast <2 x double> [[TMP3]], <double undef, double 3.000000e+00>
23 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x double> <double poison, double undef>, double [[I10]], i32 0
24 ; CHECK-NEXT: [[TMP7:%.*]] = fmul fast <2 x double> [[TMP6]], [[TMP5]]
25 ; CHECK-NEXT: [[TMP8:%.*]] = fsub fast <2 x double> [[TMP7]], <double 1.100000e+01, double undef>
26 ; CHECK-NEXT: [[TMP9:%.*]] = fmul fast <2 x double> [[TMP8]], <double 1.200000e+01, double 4.000000e+00>
27 ; CHECK-NEXT: [[TMP10:%.*]] = fdiv fast <2 x double> [[TMP9]], <double 1.400000e+00, double 1.400000e+00>
28 ; CHECK-NEXT: [[TMP11:%.*]] = extractelement <2 x double> [[TMP10]], i32 1
29 ; CHECK-NEXT: [[I07:%.*]] = fadd fast double undef, [[TMP11]]
30 ; CHECK-NEXT: [[TMP12:%.*]] = extractelement <2 x double> [[TMP10]], i32 0
31 ; CHECK-NEXT: [[I16:%.*]] = fadd fast double [[I07]], [[TMP12]]
32 ; CHECK-NEXT: [[I17:%.*]] = fadd fast double [[I16]], [[C:%.*]]
33 ; CHECK-NEXT: [[I18:%.*]] = fadd fast double [[I17]], [[D:%.*]]
34 ; CHECK-NEXT: ret double [[I18]]
36 %i01 = fdiv fast double %a, 7.0
37 %i02 = fmul fast double %i01, 3.0
38 %i03 = fmul fast double undef, %i02
39 %i04 = fsub fast double %i03, undef
40 %i05 = fmul fast double %i04, 4.0
41 %i06 = fdiv fast double %i05, 1.4
42 %i07 = fadd fast double undef, %i06
43 %i08 = fdiv fast double %b, 5.0
44 %i09 = fmul fast double %i08, undef
45 %i10 = fsub fast double undef, %i09
46 %i11 = fmul fast double %i08, undef
47 %i12 = fmul fast double %i10, %i11
48 %i13 = fsub fast double %i12, 11.0
49 %i14 = fmul fast double %i13, 12.0
50 %i15 = fdiv fast double %i14, 1.4
51 %i16 = fadd fast double %i07, %i15
52 %i17 = fadd fast double %i16, %c
53 %i18 = fadd fast double %i17, %d
57 attributes #0 = { "unsafe-fp-math"="true" }