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

llvm-svn: 190871
This commit is contained in:
Arnold Schwaighofer 2013-09-17 17:03:29 +00:00
parent b8d672ef5b
commit 4a3dcaa193
2 changed files with 74 additions and 0 deletions

View File

@ -639,6 +639,18 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth) {
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");

View File

@ -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
}