From d89d888cc5a4d5aad9cb810953eed2b919d0beac Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 7 Feb 2006 19:07:40 +0000 Subject: [PATCH] Fix Transforms/InstCombine/2006-02-07-SextZextCrash.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26040 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index bcc17f1b98a..60583385317 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -563,10 +563,12 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t Mask, // extend instead of a sign extend. if ((Mask & ((1ULL << SrcBits)-1)) == 0) { // Convert to unsigned first. - Value *NewVal; + Instruction *NewVal; NewVal = new CastInst(I->getOperand(0), SrcTy->getUnsignedVersion(), - I->getOperand(0)->getName(), I); - NewVal = new CastInst(I->getOperand(0), I->getType(), I->getName()); + I->getOperand(0)->getName()); + InsertNewInstBefore(NewVal, *I); + NewVal = new CastInst(NewVal, I->getType(), I->getName()); + InsertNewInstBefore(NewVal, *I); return UpdateValueUsesWith(I, NewVal); }