From: Chris Lattner Date: Tue, 2 Feb 2010 02:26:54 +0000 (+0000) Subject: fix a crash in loop unswitch on a loop invariant vector condition. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=3d606bbc92b5bbed17492b38b4f80728e676179f;p=oota-llvm.git fix a crash in loop unswitch on a loop invariant vector condition. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95055 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 527a7b51e11..e5fba28374b 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -169,6 +169,10 @@ Pass *llvm::createLoopUnswitchPass(bool Os) { /// invariant in the loop, or has an invariant piece, return the invariant. /// Otherwise, return null. static Value *FindLIVLoopCondition(Value *Cond, Loop *L, bool &Changed) { + // We can never unswitch on vector conditions. + if (isa(Cond->getType())) + return 0; + // Constants should be folded, not unswitched on! if (isa(Cond)) return 0; @@ -401,7 +405,7 @@ bool LoopUnswitch::IsTrivialUnswitchCondition(Value *Cond, Constant **Val, /// UnswitchIfProfitable - We have found that we can unswitch currentLoop when /// LoopCond == Val to simplify the loop. If we decide that this is profitable, /// unswitch the loop, reprocess the pieces, then return true. -bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){ +bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val) { initLoopData(); diff --git a/test/Transforms/LoopUnswitch/crash.ll b/test/Transforms/LoopUnswitch/crash.ll index a50bd54e787..fac55a6bb1a 100644 --- a/test/Transforms/LoopUnswitch/crash.ll +++ b/test/Transforms/LoopUnswitch/crash.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -loop-unswitch -disable-output -define void @sort_Eq(i32* %S2) { +define void @test1(i32* %S2) { entry: br i1 false, label %list_Length.exit, label %cond_true.i cond_true.i: ; preds = %entry @@ -30,3 +30,18 @@ return: ; preds = %return.loopexit, %list_Length.exit9 ret void } +define void @test2(i32 %x1, i32 %y1, i32 %z1, i32 %r1) nounwind { +entry: + br label %bb.nph + +bb.nph: ; preds = %entry + %and.i13521 = and <4 x i1> undef, undef ; <<4 x i1>> [#uses=1] + br label %for.body + +for.body: ; preds = %for.body, %bb.nph + %or.i = select <4 x i1> %and.i13521, <4 x i32> undef, <4 x i32> undef ; <<4 x i32>> [#uses=0] + br i1 false, label %for.body, label %for.end + +for.end: ; preds = %for.body, %entry + ret void +}