diff options
author | Chris Lattner <sabre@nondot.org> | 2010-07-14 05:59:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-07-14 05:59:13 +0000 |
commit | 7e185af9302cfc5e9dffdba65c8a99f9f57b4076 (patch) | |
tree | b224c04ab4d4f9509e950046602a25ce04df3593 /lib/Transforms | |
parent | 44a44ad3bc9aa3ec11f23787500adf552513c3b7 (diff) | |
download | external_llvm-7e185af9302cfc5e9dffdba65c8a99f9f57b4076.zip external_llvm-7e185af9302cfc5e9dffdba65c8a99f9f57b4076.tar.gz external_llvm-7e185af9302cfc5e9dffdba65c8a99f9f57b4076.tar.bz2 |
reapply benjamin's instcombine patch, I don't see anything wrong with it and can't repro any problems with a manual self-host.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108320 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 3f4a857..4542dda 100644 --- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1597,6 +1597,14 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { Instruction *Ret = FoldOrWithConstants(I, Op0, A, V1, D); if (Ret) return Ret; } + + // (A & ~D) | (B & D) -> ((B ^ A) & D) ^ A + if (Op0->hasOneUse() && Op1->hasOneUse() && + match(C, m_Not(m_Specific(D)))) { + Value *Xor = Builder->CreateXor(B, A, "xor"); + Value *And = Builder->CreateAnd(Xor, D, "and"); + return BinaryOperator::CreateXor(And, A); + } } // (X >> Z) | (Y >> Z) -> (X|Y) >> Z for all shifts. |