mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-13 14:35:54 +00:00
zext(undef) = 0 and sext(undef) = 0, not undef.
This hopefully fixes a miscompilation of TargetData.cpp when self hosting. llvm-svn: 40125
This commit is contained in:
parent
9663eb4a5b
commit
c157b172c1
@ -140,8 +140,13 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
|
||||
const Type *DestTy) {
|
||||
const Type *SrcTy = V->getType();
|
||||
|
||||
if (isa<UndefValue>(V))
|
||||
if (isa<UndefValue>(V)) {
|
||||
// zext(undef) = 0, because the top bits will be zero.
|
||||
// sext(undef) = 0, because the top bits will all be the same.
|
||||
if (opc == Instruction::ZExt || opc == Instruction::SExt)
|
||||
return Constant::getNullValue(DestTy);
|
||||
return UndefValue::get(DestTy);
|
||||
}
|
||||
|
||||
// If the cast operand is a constant expression, there's a few things we can
|
||||
// do to try to simplify it.
|
||||
|
Loading…
Reference in New Issue
Block a user