[PATCH] D124867: [SLP][NFC] Pre-commit test showing horizontal reduction preventing FMA
Bill Schmidt via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 3 11:56:52 PDT 2022
wjschmidt created this revision.
wjschmidt added reviewers: vdmitrie, ABataev, vporpo.
Herald added a project: All.
wjschmidt requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When we generate a horizontal reduction of floating adds fed by a vectorized tree rooted at floating multiplies, we should account for the cost of no longer being able to generate scalar FMAs.
This test was reduced from a case where the vectorizable tree looked barely profitable (cost -1) but produced substantially worse code than allowing the FMAs to be generated. I have a follow-up patch to address this.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124867
Files:
llvm/test/Transforms/SLPVectorizer/X86/slp-reduc-fma-loss.ll
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> <i32 undef, i32 undef, i32 undef, i32 0>
+; 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" }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124867.426796.patch
Type: text/x-patch
Size: 2398 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220503/26186c0d/attachment.bin>
More information about the llvm-commits
mailing list