Teach the constant folder how to do select instructions

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12321 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-03-12 05:53:32 +00:00
parent cfdd148972
commit e97148628f

View File

@ -582,6 +582,17 @@ Constant *llvm::ConstantFoldCastInstruction(const Constant *V,
}
}
Constant *llvm::ConstantFoldSelectInstruction(const Constant *Cond,
const Constant *V1,
const Constant *V2) {
if (Cond == ConstantBool::True)
return const_cast<Constant*>(V1);
else if (Cond == ConstantBool::False)
return const_cast<Constant*>(V2);
return 0;
}
/// IdxCompare - Compare the two constants as though they were getelementptr
/// indices. This allows coersion of the types to be the same thing.
///