diff options
author | Duncan Sands <baldrick@free.fr> | 2012-06-13 09:42:13 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2012-06-13 09:42:13 +0000 |
commit | ee5a094ccf1f04d3fcc92ac4d2fc8a2926cbb232 (patch) | |
tree | e4bba8613607c38aa947509b4cf6f9e501af678a /include/llvm/Constants.h | |
parent | cc95b57d42a4af1cbb0a0e4a4efc2133116dd21c (diff) | |
download | llvm-ee5a094ccf1f04d3fcc92ac4d2fc8a2926cbb232.tar.gz llvm-ee5a094ccf1f04d3fcc92ac4d2fc8a2926cbb232.tar.bz2 llvm-ee5a094ccf1f04d3fcc92ac4d2fc8a2926cbb232.tar.xz |
When linearizing a multiplication, return at once if we see a factor of zero,
since then the entire expression must equal zero (similarly for other operations
with an absorbing element). With this in place a bunch of reassociate code for
handling constants is dead since it is all taken care of when linearizing. No
intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158398 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r-- | include/llvm/Constants.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index a3f5b95dbc..fdd53823aa 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -919,9 +919,15 @@ public: /// getBinOpIdentity - Return the identity for the given binary operation, /// i.e. a constant C such that X op C = X and C op X = X for every X. It - /// is an error to call this for an operation that doesn't have an identity. + /// returns null if the operator doesn't have an identity. static Constant *getBinOpIdentity(unsigned Opcode, Type *Ty); + /// getBinOpAbsorber - Return the absorbing element for the given binary + /// operation, i.e. a constant C such that X op C = C and C op X = C for + /// every X. For example, this returns zero for integer multiplication. + /// It returns null if the operator doesn't have an absorbing element. + static Constant *getBinOpAbsorber(unsigned Opcode, Type *Ty); + /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); |