[llvm] r190871 - SLPVectorizer: Don't vectorize phi nodes that use invoke values
Quentin Colombet
qcolombet at apple.com
Tue Sep 17 10:15:11 PDT 2013
Hi Arnold,
I am curious, what is wrong with splitting critical edges?
Is it related to the potential cost it will incurved or is it just something we do not want to do?
Thanks,
-Quentin
On Sep 17, 2013, at 10:03 AM, Arnold Schwaighofer <aschwaighofer at apple.com> wrote:
> Author: arnolds
> Date: Tue Sep 17 12:03:29 2013
> New Revision: 190871
>
> URL: http://llvm.org/viewvc/llvm-project?rev=190871&view=rev
> Log:
> SLPVectorizer: Don't vectorize phi nodes that use invoke values
>
> We can't insert an insertelement after an invoke. We would have to split a
> critical edge. So when we see a phi node that uses an invoke we just give up.
>
> radar://14990770
>
> Modified:
> llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
> llvm/trunk/test/Transforms/SLPVectorizer/X86/ordering.ll
>
> Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=190871&r1=190870&r2=190871&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
> +++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Tue Sep 17 12:03:29 2013
> @@ -639,6 +639,18 @@ void BoUpSLP::buildTree_rec(ArrayRef<Val
> switch (Opcode) {
> case Instruction::PHI: {
> PHINode *PH = dyn_cast<PHINode>(VL0);
> +
> + // Check for terminator values (e.g. invoke).
> + for (unsigned j = 0; j < VL.size(); ++j)
> + for (unsigned i = 0, e = PH->getNumIncomingValues(); i < e; ++i) {
> + TerminatorInst *Term = dyn_cast<TerminatorInst>(cast<PHINode>(VL[j])->getIncomingValue(i));
> + if (Term) {
> + DEBUG(dbgs() << "SLP: Need to swizzle PHINodes (TerminatorInst use).\n");
> + newTreeEntry(VL, false);
> + return;
> + }
> + }
> +
> newTreeEntry(VL, true);
> DEBUG(dbgs() << "SLP: added a vector of PHINodes.\n");
>
>
> Modified: llvm/trunk/test/Transforms/SLPVectorizer/X86/ordering.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SLPVectorizer/X86/ordering.ll?rev=190871&r1=190870&r2=190871&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/SLPVectorizer/X86/ordering.ll (original)
> +++ llvm/trunk/test/Transforms/SLPVectorizer/X86/ordering.ll Tue Sep 17 12:03:29 2013
> @@ -17,3 +17,65 @@ entry:
> %cmp11 = fcmp olt double %add, 0.000000e+00
> ret void
> }
> +
> +declare i8* @objc_msgSend(i8*, i8*, ...)
> +declare i32 @personality_v0(...)
> +
> +define void @invoketest() {
> +entry:
> + br i1 undef, label %cond.true, label %cond.false
> +
> +cond.true:
> + %call49 = invoke double bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to double (i8*, i8*)*)(i8* undef, i8* undef)
> + to label %cond.true54 unwind label %lpad
> +
> +cond.false:
> + %call51 = invoke double bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to double (i8*, i8*)*)(i8* undef, i8* undef)
> + to label %cond.false57 unwind label %lpad
> +
> +cond.true54:
> + %call56 = invoke double bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to double (i8*, i8*)*)(i8* undef, i8* undef)
> + to label %cond.end60 unwind label %lpad
> +
> +cond.false57:
> + %call59 = invoke double bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to double (i8*, i8*)*)(i8* undef, i8* undef)
> + to label %cond.end60 unwind label %lpad
> +
> +; Make sure we don't vectorize these phis - they have invokes as inputs.
> +
> +; RUN: opt < %s -slp-vectorizer -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7 | FileCheck %s
> +
> +; CHECK-LABEL: invoketest
> +
> +; CHECK-LABEL: cond.end60
> +; CHECK-NEXT-NOT: phi <2 x double>
> +; CHECK: insertelement
> +; CHECK-LABEL: if.then63
> +
> +cond.end60:
> + %cond126 = phi double [ %call49, %cond.true54 ], [ %call51, %cond.false57 ]
> + %cond61 = phi double [ %call56, %cond.true54 ], [ %call59, %cond.false57 ]
> + br i1 undef, label %if.end98, label %if.then63
> +
> +if.then63:
> + %conv69 = fptrunc double undef to float
> + %conv70 = fpext float %conv69 to double
> + %div71 = fdiv double %cond126, %conv70
> + %conv78 = fptrunc double undef to float
> + %conv79 = fpext float %conv78 to double
> + %div80 = fdiv double %cond61, %conv79
> + br label %if.end98
> +
> +lpad:
> + %l = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @personality_v0 to i8*)
> + cleanup
> + resume { i8*, i32 } %l
> +
> +if.end98:
> + %dimensionsResult.sroa.0.0 = phi double [ %div71, %if.then63 ], [ %cond126, %cond.end60 ]
> + %dimensionsResult.sroa.6.0 = phi double [ %div80, %if.then63 ], [ %cond61, %cond.end60 ]
> + br label %if.end99
> +
> +if.end99:
> + ret void
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130917/f33b7865/attachment.html>
More information about the llvm-commits
mailing list