diff --git a/llvm/test/Transforms/SLPVectorizer/X86/vectorize-pair-path.ll b/llvm/test/Transforms/SLPVectorizer/X86/vectorize-pair-path.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/SLPVectorizer/X86/vectorize-pair-path.ll @@ -0,0 +1,66 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -slp-vectorizer -mattr=+avx2 -S | FileCheck %s + +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" + +; In this test case we start trying to vectorize reduction but end up +; in tryToVectorize() method which then can make several attempts to +; find a pair (roots) for a tree that can be vectorized. +; The order (path) it makes probes for various pairs is predefined by +; the method implementation and it is not guaranteed that the best option +; encountered first (like here). + +define double @root_selection(double %a, double %b, double %c, double %d) local_unnamed_addr #0 { +; CHECK-LABEL: @root_selection( +; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x double> poison, double [[A:%.*]], i32 0 +; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x double> [[TMP1]], double [[B:%.*]], i32 1 +; CHECK-NEXT: [[TMP3:%.*]] = fdiv fast <2 x double> [[TMP2]], +; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x double> [[TMP3]], i32 1 +; CHECK-NEXT: [[I11:%.*]] = fmul fast double [[TMP4]], undef +; CHECK-NEXT: [[TMP5:%.*]] = fmul fast <2 x double> [[TMP3]], +; CHECK-NEXT: [[TMP6:%.*]] = fmul fast <2 x double> undef, [[TMP5]] +; CHECK-NEXT: [[TMP7:%.*]] = fsub fast <2 x double> undef, [[TMP5]] +; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <2 x double> [[TMP6]], <2 x double> [[TMP7]], <2 x i32> +; CHECK-NEXT: [[TMP9:%.*]] = insertelement <2 x double> , double [[I11]], i32 1 +; CHECK-NEXT: [[TMP10:%.*]] = fsub fast <2 x double> [[TMP8]], [[TMP9]] +; CHECK-NEXT: [[TMP11:%.*]] = fmul fast <2 x double> [[TMP8]], [[TMP9]] +; CHECK-NEXT: [[TMP12:%.*]] = shufflevector <2 x double> [[TMP10]], <2 x double> [[TMP11]], <2 x i32> +; CHECK-NEXT: [[TMP13:%.*]] = fmul fast <2 x double> [[TMP12]], +; CHECK-NEXT: [[TMP14:%.*]] = fsub fast <2 x double> [[TMP12]], +; CHECK-NEXT: [[TMP15:%.*]] = shufflevector <2 x double> [[TMP13]], <2 x double> [[TMP14]], <2 x i32> +; CHECK-NEXT: [[TMP16:%.*]] = fdiv fast <2 x double> [[TMP15]], +; CHECK-NEXT: [[TMP17:%.*]] = fmul fast <2 x double> [[TMP15]], +; CHECK-NEXT: [[TMP18:%.*]] = shufflevector <2 x double> [[TMP16]], <2 x double> [[TMP17]], <2 x i32> +; CHECK-NEXT: [[TMP19:%.*]] = fadd fast <2 x double> [[TMP18]], +; CHECK-NEXT: [[TMP20:%.*]] = fdiv fast <2 x double> [[TMP18]], +; CHECK-NEXT: [[TMP21:%.*]] = shufflevector <2 x double> [[TMP19]], <2 x double> [[TMP20]], <2 x i32> +; CHECK-NEXT: [[TMP22:%.*]] = extractelement <2 x double> [[TMP21]], i32 0 +; CHECK-NEXT: [[TMP23:%.*]] = extractelement <2 x double> [[TMP21]], i32 1 +; CHECK-NEXT: [[I16:%.*]] = fadd fast double [[TMP22]], [[TMP23]] +; CHECK-NEXT: [[I17:%.*]] = fadd fast double [[I16]], [[C:%.*]] +; CHECK-NEXT: [[I18:%.*]] = fadd fast double [[I17]], [[D:%.*]] +; CHECK-NEXT: ret double [[I18]] +; + %i01 = fdiv fast double %a, 7.0 + %i02 = fmul fast double %i01, 3.0 + %i03 = fmul fast double undef, %i02 + %i04 = fsub fast double %i03, undef + %i05 = fmul fast double %i04, 4.0 + %i06 = fdiv fast double %i05, 1.4 + %i07 = fadd fast double undef, %i06 + %i08 = fdiv fast double %b, 5.0 + %i09 = fmul fast double %i08, undef + %i10 = fsub fast double undef, %i09 + %i11 = fmul fast double %i08, undef + %i12 = fmul fast double %i10, %i11 + %i13 = fsub fast double %i12, 11.0 + %i14 = fmul fast double %i13, 12.0 + %i15 = fdiv fast double %i14, 1.4 + %i16 = fadd fast double %i07, %i15 + %i17 = fadd fast double %i16, %c + %i18 = fadd fast double %i17, %d + ret double %i18 +} + +attributes #0 = { "unsafe-fp-math"="true" }