From: Devang Patel Date: Mon, 2 Jun 2008 22:52:56 +0000 (+0000) Subject: Update dom tree. Fix PR 2372. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2f170997b5349bf7e9ef4cb5cb38af5f7df0c54b;p=oota-llvm.git Update dom tree. Fix PR 2372. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51887 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 767ea1d30ee..e0fb4c614d9 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -569,7 +569,6 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val, // Insert the new branch. BranchInst::Create(TrueDest, FalseDest, BranchVal, InsertPt); - } @@ -607,6 +606,10 @@ void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond, // insert the new conditional branch. EmitPreheaderBranchOnCondition(Cond, Val, NewExit, NewPH, OrigPH->getTerminator()); + if (DT) { + DT->changeImmediateDominator(NewExit, OrigPH); + DT->changeImmediateDominator(NewPH, OrigPH); + } LPM->deleteSimpleAnalysisValue(OrigPH->getTerminator(), L); OrigPH->getTerminator()->eraseFromParent(); diff --git a/test/Transforms/LoopUnswitch/2008-06-02-DomInfo.ll b/test/Transforms/LoopUnswitch/2008-06-02-DomInfo.ll new file mode 100644 index 00000000000..dcf41c34a48 --- /dev/null +++ b/test/Transforms/LoopUnswitch/2008-06-02-DomInfo.ll @@ -0,0 +1,26 @@ +; RUN: llvm-as < %s | opt -loop-unswitch -instcombine -gvn -disable-output +; PR2372 +target triple = "i386-pc-linux-gnu" + +define i32 @func_3(i16 signext %p_5, i16 signext %p_6) nounwind { +entry: + %tmp3 = icmp eq i16 %p_5, 0 ; [#uses=1] + %tmp1314 = sext i16 %p_6 to i32 ; [#uses=1] + %tmp28 = icmp ugt i32 %tmp1314, 3 ; [#uses=1] + %bothcond = or i1 %tmp28, false ; [#uses=1] + br label %bb +bb: ; preds = %bb54, %entry + br i1 %tmp3, label %bb54, label %bb5 +bb5: ; preds = %bb + br i1 %bothcond, label %bb54, label %bb31 +bb31: ; preds = %bb5 + br label %bb54 +bb54: ; preds = %bb31, %bb5, %bb + br i1 false, label %bb64, label %bb +bb64: ; preds = %bb54 + %tmp6566 = sext i16 %p_6 to i32 ; [#uses=1] + %tmp68 = tail call i32 (...)* @func_18( i32 1, i32 %tmp6566, i32 1 ) nounwind ; [#uses=0] + ret i32 undef +} + +declare i32 @func_18(...)