diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2006-10-22 22:22:58 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2006-10-22 22:22:58 +0000 |
commit | 6f5c30fcec2ba6cc83375ce0dd7905a70dbb203c (patch) | |
tree | 956cb434303ae3881887316e8ddbb01ec9e2d727 /llvm/lib/Transforms | |
parent | bb3084546a1af66d0b3d292b7abcb9d7f3f91c17 (diff) | |
download | bcm5719-llvm-6f5c30fcec2ba6cc83375ce0dd7905a70dbb203c.tar.gz bcm5719-llvm-6f5c30fcec2ba6cc83375ce0dd7905a70dbb203c.zip |
Fix similar missing optimization opportunity in XOR.
llvm-svn: 31123
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp index 6cda6d257dc..d1fe10668c1 100644 --- a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -349,19 +349,28 @@ namespace { } } break; case Instruction::Xor: { - ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V1); - if (!CI) break; - if (CI->isAllOnesValue()) { - if (BO->getOperand(0) == V1) - add(Opcode, ConstantBool::getFalse(), BO->getOperand(1), false); - if (BO->getOperand(1) == V1) - add(Opcode, ConstantBool::getFalse(), BO->getOperand(0), false); - } - if (CI->isNullValue()) { - if (BO->getOperand(0) == ConstantBool::getTrue()) - add(Opcode, ConstantBool::getTrue(), BO->getOperand(1), false); - if (BO->getOperand(1) == ConstantBool::getTrue()) - add(Opcode, ConstantBool::getTrue(), BO->getOperand(0), false); + if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V1)) { + const Type *Ty = BO->getType(); + if (CI->isAllOnesValue()) { + if (BO->getOperand(0) == V1) + add(Opcode, Constant::getNullValue(Ty), + BO->getOperand(1), false); + if (BO->getOperand(1) == V1) + add(Opcode, Constant::getNullValue(Ty), + BO->getOperand(0), false); + } + if (CI->isNullValue()) { + ConstantIntegral *Op0 = + dyn_cast<ConstantIntegral>(BO->getOperand(0)); + ConstantIntegral *Op1 = + dyn_cast<ConstantIntegral>(BO->getOperand(1)); + if (Op0 && Op0->isAllOnesValue()) + add(Opcode, ConstantIntegral::getAllOnesValue(Ty), + BO->getOperand(1), false); + if (Op1 && Op1->isAllOnesValue()) + add(Opcode, ConstantIntegral::getAllOnesValue(Ty), + BO->getOperand(0), false); + } } } break; default: |