Fix a bug in InstCombine where it attempted to cast a Value* to an Instruction*

when it was actually a Constant*.

There are quite a few other casts to Instruction that might have the same problem,
but this is the only one I have a test case for.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191668 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Joey Gouly
2013-09-30 14:18:35 +00:00
parent 6206a132a7
commit 6ef4dd8cb6
2 changed files with 25 additions and 2 deletions

View File

@ -519,10 +519,10 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
if (Opnd0->hasOneUse()) {
// -X * Y => -(X*Y) (Promote negation as high as possible)
Value *T = Builder->CreateFMul(N0, Opnd1);
cast<Instruction>(T)->setDebugLoc(I.getDebugLoc());
Instruction *Neg = BinaryOperator::CreateFNeg(T);
if (I.getFastMathFlags().any()) {
cast<Instruction>(T)->copyFastMathFlags(&I);
if (Instruction *TI = dyn_cast<Instruction>(T))
TI->copyFastMathFlags(&I);
Neg->copyFastMathFlags(&I);
}
return Neg;