Index: llvm/test/Transforms/SLPVectorizer/X86/slp-reduc-fma-loss.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/SLPVectorizer/X86/slp-reduc-fma-loss.ll @@ -0,0 +1,46 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -slp-vectorizer -S -mcpu=core-avx2 < %s | FileCheck %s + +; This test checks for a case when a horizontal reduction of floating-point +; adds may look profitable, but is not because it eliminates generation of +; floating-point FMAs that would be more profitable. +; FIXME: We currently generate the horizontal reduction. + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @foo() #0 { +; CHECK-LABEL: @foo( +; CHECK-NEXT: br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[X_544:%.*]] = phi double [ 0.000000e+00, [[TMP0:%.*]] ], [ [[OP_EXTRA:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[X_557:%.*]] = uitofp i16 undef to double +; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x double> poison, double [[X_557]], i32 0 +; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x double> [[TMP1]], <4 x double> poison, <4 x i32> +; CHECK-NEXT: [[TMP2:%.*]] = fmul fast <4 x double> poison, [[SHUFFLE]] +; CHECK-NEXT: [[TMP3:%.*]] = call fast double @llvm.vector.reduce.fadd.v4f64(double -0.000000e+00, <4 x double> [[TMP2]]) +; CHECK-NEXT: [[OP_EXTRA]] = fadd fast double [[TMP3]], [[X_544]] +; CHECK-NEXT: br i1 undef, label [[EXIT:%.*]], label [[LOOP]] +; CHECK: exit: +; CHECK-NEXT: ret void +; + br label %loop + +loop: ; preds = %loop, %0 + %x.544 = phi double [ 0.000000e+00, %0 ], [ %x.616, %loop ] + %x.557 = uitofp i16 undef to double + %x.558 = fmul fast double undef, %x.557 + %x.559 = fadd fast double %x.558, %x.544 + %x.577 = fmul fast double undef, undef + %x.578 = fadd fast double %x.577, %x.559 + %x.596 = fmul fast double undef, undef + %x.597 = fadd fast double %x.596, %x.578 + %x.615 = fmul fast double undef, undef + %x.616 = fadd fast double %x.615, %x.597 + br i1 undef, label %exit, label %loop + +exit: ; preds = %loop + ret void +} + +attributes #0 = { "unsafe-fp-math"="true" }