From: Vyacheslav Klochkov Date: Wed, 16 Nov 2016 00:55:50 +0000 (+0000) Subject: Fixed the lost FastMathFlags for CALL operations in SLPVectorizer. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b3dc774a9963a43ea828da9cf31137b7fce7cc7b;p=platform%2Fupstream%2Fllvm.git Fixed the lost FastMathFlags for CALL operations in SLPVectorizer. Reviewer: Michael Zolotukhin. Differential Revision: https://reviews.llvm.org/D26575 llvm-svn: 287064 --- diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 6b27ac6..aac5aae 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -2641,6 +2641,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { ExternalUses.push_back(ExternalUser(ScalarArg, cast(V), 0)); E->VectorizedValue = V; + propagateIRFlags(E->VectorizedValue, E->Scalars); ++NumVectorInstructions; return V; } diff --git a/llvm/test/Transforms/SLPVectorizer/X86/call.ll b/llvm/test/Transforms/SLPVectorizer/X86/call.ll index d6c0ebd..923cbe7 100644 --- a/llvm/test/Transforms/SLPVectorizer/X86/call.ll +++ b/llvm/test/Transforms/SLPVectorizer/X86/call.ll @@ -98,7 +98,7 @@ entry: ; CHECK: sqrt_libm -; CHECK: call <2 x double> @llvm.sqrt.v2f64 +; CHECK: call nnan <2 x double> @llvm.sqrt.v2f64 ; CHECK: ret void define void @sqrt_libm(double* %a, double* %b, double* %c) { entry: diff --git a/llvm/test/Transforms/SLPVectorizer/X86/propagate_ir_flags.ll b/llvm/test/Transforms/SLPVectorizer/X86/propagate_ir_flags.ll index 3f26c81..28217fc 100644 --- a/llvm/test/Transforms/SLPVectorizer/X86/propagate_ir_flags.ll +++ b/llvm/test/Transforms/SLPVectorizer/X86/propagate_ir_flags.ll @@ -398,5 +398,42 @@ define void @fcmp_no_fast(double* %x) #1 { ret void } -attributes #1 = { "target-features"="+avx" } +declare double @llvm.fabs.f64(double) nounwind readnone + +;CHECK-LABEL: @call_fast( +;CHECK: call fast <2 x double> @llvm.fabs.v2f64 +define void @call_fast(double* %x) { + %idx1 = getelementptr inbounds double, double* %x, i64 0 + %idx2 = getelementptr inbounds double, double* %x, i64 1 + + %load1 = load double, double* %idx1, align 8 + %load2 = load double, double* %idx2, align 8 + + %call1 = tail call fast double @llvm.fabs.f64(double %load1) nounwind readnone + %call2 = tail call fast double @llvm.fabs.f64(double %load2) nounwind readnone + + store double %call1, double* %idx1, align 8 + store double %call2, double* %idx2, align 8 + + ret void +} +;CHECK-LABEL: @call_no_fast( +;CHECK: call <2 x double> @llvm.fabs.v2f64 +define void @call_no_fast(double* %x) { + %idx1 = getelementptr inbounds double, double* %x, i64 0 + %idx2 = getelementptr inbounds double, double* %x, i64 1 + + %load1 = load double, double* %idx1, align 8 + %load2 = load double, double* %idx2, align 8 + + %call1 = tail call fast double @llvm.fabs.f64(double %load1) nounwind readnone + %call2 = tail call double @llvm.fabs.f64(double %load2) nounwind readnone + + store double %call1, double* %idx1, align 8 + store double %call2, double* %idx2, align 8 + + ret void +} + +attributes #1 = { "target-features"="+avx" }