diff options
author | Duncan Sands <baldrick@free.fr> | 2010-11-23 14:23:47 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-11-23 14:23:47 +0000 |
commit | 5057f381418ddc8c96699c40479ead993cd62e7b (patch) | |
tree | e8737928b5fd38869ede79b36e7987bd51989a9e /lib/Transforms/InstCombine/InstCombine.h | |
parent | 0cc5b1f60e02716cac617959d88d4c412fdb3154 (diff) | |
download | llvm-5057f381418ddc8c96699c40479ead993cd62e7b.tar.gz llvm-5057f381418ddc8c96699c40479ead993cd62e7b.tar.bz2 llvm-5057f381418ddc8c96699c40479ead993cd62e7b.tar.xz |
Exploit distributive laws (eg: And distributes over Or, Mul over Add, etc) in a
fairly systematic way in instcombine. Some of these cases were already dealt
with, in which case I removed the existing code. The case of Add has a bunch of
funky logic which covers some of this plus a few variants (considers shifts to be
a form of multiplication), which I didn't touch. The simplification performed is:
A*B+A*C -> A*(B+C). The improvement is to do this in cases that were not already
handled [such as A*B-A*C -> A*(B-C), which was reported on the mailing list], and
also to do it more often by not checking for "only one use" if "B+C" simplifies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120024 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombine.h')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombine.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombine.h b/lib/Transforms/InstCombine/InstCombine.h index 05846d0f9e..b492777a47 100644 --- a/lib/Transforms/InstCombine/InstCombine.h +++ b/lib/Transforms/InstCombine/InstCombine.h @@ -290,6 +290,12 @@ private: /// operators which are associative or commutative. bool SimplifyAssociativeOrCommutative(BinaryOperator &I); + /// SimplifyDistributed - This tries to simplify binary operations which some + /// other binary operation distributes over (eg "A*B+A*C" -> "A*(B+C)" since + /// addition is distributed over by multiplication). Returns the result of + /// the simplification, or null if no simplification was performed. + Instruction *SimplifyDistributed(BinaryOperator &I); + /// SimplifyDemandedUseBits - Attempts to replace V with a simpler value /// based on the demanded bits. Value *SimplifyDemandedUseBits(Value *V, APInt DemandedMask, |