mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 09:45:00 +00:00
ConstantFold: Clean up X * undef code
No functional change intended. llvm-svn: 223970
This commit is contained in:
parent
cde1ba6638
commit
fb504668cb
@ -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<ConstantInt>(C1)) && CI->getValue()[0]) ||
|
||||
((CI = dyn_cast<ConstantInt>(C2)) && CI->getValue()[0]) ||
|
||||
(isa<UndefValue>(C1) && isa<UndefValue>(C2)))
|
||||
return UndefValue::get(C1->getType());
|
||||
// undef * undef -> undef
|
||||
if (isa<UndefValue>(C1) && isa<UndefValue>(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());
|
||||
|
Loading…
Reference in New Issue
Block a user