1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=slp-vectorizer -S -mcpu=corei7 -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-2 < %s | FileCheck %s --check-prefixes=CHECK
3 ; RUN: opt -passes=slp-vectorizer -S -mcpu=bdver2 -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-2 < %s | FileCheck %s --check-prefixes=CHECK
4 ; RUN: opt -passes=slp-vectorizer -S -mcpu=core-avx2 -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-2 < %s | FileCheck %s --check-prefixes=CHECK
6 ; This test checks for a case when a horizontal reduction of floating-point
7 ; adds may look profitable, but is not because it eliminates generation of
8 ; floating-point FMAs that would be more profitable.
10 ; FIXME: We generate a horizontal reduction today.
14 ; CHECK-NEXT: br label [[LOOP:%.*]]
16 ; CHECK-NEXT: [[PHI0:%.*]] = phi double [ 0.000000e+00, [[TMP0:%.*]] ], [ [[OP_RDX:%.*]], [[LOOP]] ]
17 ; CHECK-NEXT: [[CVT0:%.*]] = uitofp i16 0 to double
18 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x double> <double poison, double 0.000000e+00, double 0.000000e+00, double 0.000000e+00>, double [[CVT0]], i32 0
19 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast <4 x double> zeroinitializer, [[TMP1]]
20 ; CHECK-NEXT: [[TMP3:%.*]] = call fast double @llvm.vector.reduce.fadd.v4f64(double -0.000000e+00, <4 x double> [[TMP2]])
21 ; CHECK-NEXT: [[OP_RDX]] = fadd fast double [[TMP3]], [[PHI0]]
22 ; CHECK-NEXT: br i1 true, label [[EXIT:%.*]], label [[LOOP]]
24 ; CHECK-NEXT: ret void
29 %phi0 = phi double [ 0.000000e+00, %0 ], [ %add3, %loop ]
30 %cvt0 = uitofp i16 0 to double
31 %mul0 = fmul fast double 0.000000e+00, %cvt0
32 %add0 = fadd fast double %mul0, %phi0
33 %mul1 = fmul fast double 0.000000e+00, 0.000000e+00
34 %add1 = fadd fast double %mul1, %add0
35 %mul2 = fmul fast double 0.000000e+00, 0.000000e+00
36 %add2 = fadd fast double %mul2, %add1
37 %mul3 = fmul fast double 0.000000e+00, 0.000000e+00
38 %add3 = fadd fast double %mul3, %add2
39 br i1 true, label %exit, label %loop
45 ; This test checks for a case when either a horizontal reduction of
46 ; floating-point adds, or vectorizing a tree of floating-point multiplies,
47 ; may look profitable; but both are not because this eliminates generation
48 ; of floating-point FMAs that would be more profitable.
50 ; FIXME: We generate a horizontal reduction today, and if that's disabled, we
51 ; still vectorize some of the multiplies.
53 define double @hr_or_mul() {
54 ; CHECK-LABEL: @hr_or_mul(
55 ; CHECK-NEXT: [[CVT0:%.*]] = uitofp i16 3 to double
56 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x double> poison, double [[CVT0]], i32 0
57 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x double> [[TMP1]], <4 x double> poison, <4 x i32> zeroinitializer
58 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast <4 x double> <double 7.000000e+00, double -4.300000e+01, double 2.200000e-02, double 9.500000e+00>, [[SHUFFLE]]
59 ; CHECK-NEXT: [[TMP3:%.*]] = call fast double @llvm.vector.reduce.fadd.v4f64(double -0.000000e+00, <4 x double> [[TMP2]])
60 ; CHECK-NEXT: [[OP_RDX:%.*]] = fadd fast double [[TMP3]], [[CVT0]]
61 ; CHECK-NEXT: ret double [[OP_RDX]]
63 %cvt0 = uitofp i16 3 to double
64 %mul0 = fmul fast double 7.000000e+00, %cvt0
65 %add0 = fadd fast double %mul0, %cvt0
66 %mul1 = fmul fast double -4.300000e+01, %cvt0
67 %add1 = fadd fast double %mul1, %add0
68 %mul2 = fmul fast double 2.200000e-02, %cvt0
69 %add2 = fadd fast double %mul2, %add1
70 %mul3 = fmul fast double 9.500000e+00, %cvt0
71 %add3 = fadd fast double %mul3, %add2