From 39b12c059dba3dcaf0315a382cc8f8948e77f90a Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 21 Jan 2011 01:12:09 +0000 Subject: Add a constant folding of casts from zero to zero. Fixes PR9011! While here, I'd like to complain about how vector is not an aggregate type according to llvm::Type::isAggregateType(), but they're listed under aggregate types in the LangRef and zero vectors are stored as ConstantAggregateZero. llvm-svn: 123956 --- llvm/lib/VMCore/ConstantFold.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/VMCore/ConstantFold.cpp') diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp index a21b4a28e47..3fea1910ffe 100644 --- a/llvm/lib/VMCore/ConstantFold.cpp +++ b/llvm/lib/VMCore/ConstantFold.cpp @@ -511,10 +511,14 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, return Constant::getNullValue(DestTy); return UndefValue::get(DestTy); } + // No compile-time operations on this type yet. if (V->getType()->isPPC_FP128Ty() || DestTy->isPPC_FP128Ty()) return 0; + if (V->isNullValue() && !DestTy->isX86_MMXTy()) + return Constant::getNullValue(DestTy); + // If the cast operand is a constant expression, there's a few things we can // do to try to simplify it. if (ConstantExpr *CE = dyn_cast(V)) { -- cgit v1.2.3