diff options
author | Paul Redmond <paul.redmond@intel.com> | 2013-01-21 21:57:20 +0000 |
---|---|---|
committer | Paul Redmond <paul.redmond@intel.com> | 2013-01-21 21:57:20 +0000 |
commit | 9d86a4a3b636abc9871108d0ffecb990b824f3dd (patch) | |
tree | 15a1285cc55302d7520f80ca955f316c90d82c51 /llvm/lib/Transforms/InstCombine | |
parent | 830875bbda6b4b3f1e07072904677ce1bc93af3f (diff) | |
download | bcm5719-llvm-9d86a4a3b636abc9871108d0ffecb990b824f3dd.tar.gz bcm5719-llvm-9d86a4a3b636abc9871108d0ffecb990b824f3dd.zip |
Transform (sub 0, (zext bool to A)) to (sext bool to A) and
(sub 0, (sext bool to A)) to (zext bool to A).
Patch by Muhammad Ahmad
Reviewed by Duncan Sands
llvm-svn: 173093
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 03be8ef6fb7..c6d60d6f008 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -1250,6 +1250,16 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (SimplifyDemandedInstructionBits(I)) return &I; + + // Fold (sub 0, (zext bool to B)) --> (sext bool to B) + if (C->isZero() && match(Op1, m_ZExt(m_Value(X)))) + if (X->getType()->isIntegerTy(1)) + return CastInst::CreateSExtOrBitCast(X, Op1->getType()); + + // Fold (sub 0, (sext bool to B)) --> (zext bool to B) + if (C->isZero() && match(Op1, m_SExt(m_Value(X)))) + if (X->getType()->isIntegerTy(1)) + return CastInst::CreateZExtOrBitCast(X, Op1->getType()); } |