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 | 8e528100d210e225cee417229d94af91355118c0 (patch) | |
tree | fb79d27bfbcb7feb41de5ed4d92fff0c40a04226 /lib | |
parent | e4b1efef8aa51c7ac768f96e77af49622d9e85b9 (diff) | |
download | external_llvm-8e528100d210e225cee417229d94af91355118c0.zip external_llvm-8e528100d210e225cee417229d94af91355118c0.tar.gz external_llvm-8e528100d210e225cee417229d94af91355118c0.tar.bz2 |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAddSub.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 03be8ef..c6d60d6 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/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()); } |