aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-03-25 20:08:07 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-03-25 20:08:07 +0000
commit26471c48b3d49bdbcfcc05cb9a575b5fa123fbbf (patch)
treecf75442b4cf9f93ed3b27eef5bd8a601353c94b9 /lib/VMCore/ConstantFold.cpp
parentd34af7875b682d519038295b04ab4e15f237ccdf (diff)
downloadexternal_llvm-26471c48b3d49bdbcfcc05cb9a575b5fa123fbbf.zip
external_llvm-26471c48b3d49bdbcfcc05cb9a575b5fa123fbbf.tar.gz
external_llvm-26471c48b3d49bdbcfcc05cb9a575b5fa123fbbf.tar.bz2
Handle a special case xor undef, undef -> 0. Technically this should be transformed to undef. But this is such a common idiom (misuse) we are going to handle it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48792 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 762a24a..7b21817 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -474,9 +474,14 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
// Handle UndefValue up front
if (isa<UndefValue>(C1) || isa<UndefValue>(C2)) {
switch (Opcode) {
+ case Instruction::Xor:
+ if (isa<UndefValue>(C1) && isa<UndefValue>(C2))
+ // Handle undef ^ undef -> 0 special case. This is a common
+ // idiom (misuse).
+ return Constant::getNullValue(C1->getType());
+ // Fallthrough
case Instruction::Add:
case Instruction::Sub:
- case Instruction::Xor:
return UndefValue::get(C1->getType());
case Instruction::Mul:
case Instruction::And: