diff options
author | Dan Gohman <gohman@apple.com> | 2010-06-28 21:30:07 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-06-28 21:30:07 +0000 |
commit | 0dd3549edc91b50fba102a6b0473caf8d4cf6b70 (patch) | |
tree | b560a260051ce541b2ca74278734edd8f0af8dec /lib/VMCore | |
parent | e89c5e57cc5c525d7875032a125e37bd404448c2 (diff) | |
download | external_llvm-0dd3549edc91b50fba102a6b0473caf8d4cf6b70.zip external_llvm-0dd3549edc91b50fba102a6b0473caf8d4cf6b70.tar.gz external_llvm-0dd3549edc91b50fba102a6b0473caf8d4cf6b70.tar.bz2 |
Constant fold x == undef to undef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107074 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index ec62502..3567266 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -1817,8 +1817,15 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, return Constant::getAllOnesValue(ResultTy); // Handle some degenerate cases first - if (isa<UndefValue>(C1) || isa<UndefValue>(C2)) + if (isa<UndefValue>(C1) || isa<UndefValue>(C2)) { + // For EQ and NE, we can always pick a value for the undef to make the + // predicate pass or fail, so we can return undef. + if (ICmpInst::isEquality(ICmpInst::Predicate(pred))) + return UndefValue::get(ResultTy); + // Otherwise, pick the same value as the non-undef operand, and fold + // it to true or false. return ConstantInt::get(ResultTy, CmpInst::isTrueWhenEqual(pred)); + } // No compile-time operations on this type yet. if (C1->getType()->isPPC_FP128Ty()) |