Fix Transforms/InstCombine/2006-02-07-SextZextCrash.ll
authorChris Lattner <sabre@nondot.org>
Tue, 7 Feb 2006 19:07:40 +0000 (19:07 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 7 Feb 2006 19:07:40 +0000 (19:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26040 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index bcc17f1b98a3eeb614bec4a01578aa7150c71347..6058338531746f2e69c8c23a26344c16e270fd9a 100644 (file)
@@ -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);
       }