From: David Majnemer Date: Wed, 10 Dec 2014 21:58:17 +0000 (+0000) Subject: ConstantFold: Clean up X * undef code X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3e04c3e2537911b35d978d584212e1efd6881e82;p=oota-llvm.git ConstantFold: Clean up X * undef code No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223970 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/ConstantFold.cpp b/lib/IR/ConstantFold.cpp index a05c594ac8e..31e962af0b7 100644 --- a/lib/IR/ConstantFold.cpp +++ b/lib/IR/ConstantFold.cpp @@ -915,12 +915,14 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, return C1; return Constant::getNullValue(C1->getType()); // undef & X -> 0 case Instruction::Mul: { - ConstantInt *CI; - // X * undef -> undef if X is odd or undef - if (((CI = dyn_cast(C1)) && CI->getValue()[0]) || - ((CI = dyn_cast(C2)) && CI->getValue()[0]) || - (isa(C1) && isa(C2))) - return UndefValue::get(C1->getType()); + // undef * undef -> undef + if (isa(C1) && isa(C2)) + return C1; + const APInt *CV; + // X * undef -> undef if X is odd + if (match(C1, m_APInt(CV)) || match(C2, m_APInt(CV))) + if ((*CV)[0]) + return UndefValue::get(C1->getType()); // X * undef -> 0 otherwise return Constant::getNullValue(C1->getType());