summaryrefslogtreecommitdiff
path: root/include/llvm/Support/PatternMatch.h
Commit message (Collapse)AuthorAge
* Provide InstCombines for the following 3 cases:Jean-Luc Duprat2013-05-06
| | | | | | | | | | | | | | | A * (1 - (uitofp i1 C)) -> select C, 0, A B * (uitofp i1 C) -> select C, B, 0 select C, 0, A + select C, B, 0 -> select C, B, A These come up in code that has been hand-optimized from a select to a linear blend, on platforms where that may have mattered. We want to undo such changes with the following transform: A*(1 - uitofp i1 C) + B*(uitofp i1 C) -> select C, A, B git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181216 91177308-0d34-0410-b5e6-96231b3b80d8
* PatternMatch: Fix documentation - 'function' not 'attribute'Arnold Schwaighofer2013-05-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181146 91177308-0d34-0410-b5e6-96231b3b80d8
* PatternMatch: Matcher for (un)ordered floating point min/maxArnold Schwaighofer2013-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for matching 'ordered' and 'unordered' floating point min/max constructs. In LLVM we can express min/max functions as a combination of compare and select. We have support for matching such constructs for integers but not for floating point. In floating point math there is no total order because of the presence of 'NaN'. Therefore, we have to be careful to preserve the original fcmp semantics when interpreting floating point compare select combinations as a minimum or maximum function. The resulting 'ordered/unordered' floating point maximum function has to select the same value as the select/fcmp combination it is based on. ordered_max(x,y) = max(x,y) iff x and y are not NaN, y otherwise unordered_max(x,y) = max(x,y) iff x and y are not NaN, x otherwise ordered_min(x,y) = min(x,y) iff x and y are not NaN, y otherwise unordered_min(x,y) = min(x,y) iff x and y are not NaN, x otherwise This matches the behavior of the underlying select(fcmp(olt/ult/.., L, R), L, R) construct. Any code using this predicate has to preserve this semantics. A follow-up patch will use this to implement floating point min/max reductions in the vectorizer. radar://13723044 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181143 91177308-0d34-0410-b5e6-96231b3b80d8
* When code size is the priority (Oz, MinSize attribute), help llvmQuentin Colombet2013-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | turning a code like this: if (foo) free(foo) into that: free(foo) Move a call to free from basic block FB into FB's predecessor, P, when the path from P to FB is taken only if the argument of free is not equal to NULL. Some restrictions apply on P and FB to be sure that this code motion is profitable. Namely: 1. FB must have only one predecessor P. 2. FB must contain only the call to free plus an unconditional branch to S. 3. P's successors are FB and S. Because of 1., we will not increase the code size when moving the call to free from FB to P. Because of 2., FB will be empty after the move. Because of 2. and 3., P's branch instruction becomes useless, so as FB (simplifycfg will do the job). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171762 91177308-0d34-0410-b5e6-96231b3b80d8
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-02
| | | | | | | | | | | | | | | | | | | | | into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8
* Pattern matching code for intrinsics.Michael Ilseman2012-12-13
| | | | | | | | Provides m_Argument that allows matching against a CallSite's specified argument. Provides m_Intrinsic pattern that can be templatized over the intrinsic id and bind/match arguments similarly to other pattern matchers. Implementations provided for 0 to 4 arguments, though it's very simple to extend for more. Also provides example template specialization for bswap (m_BSwap) and example of code cleanup for its use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170091 91177308-0d34-0410-b5e6-96231b3b80d8
* m_CombineOr and m_CombineAnd pattern combinatorsMichael Ilseman2012-12-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170086 91177308-0d34-0410-b5e6-96231b3b80d8
* Pattern matchers for floating point valuesMichael Ilseman2012-12-12
| | | | | | | | | | | | m_ConstantFP - match and bind a float constant m_SpecificConstantFP - match a specific floating point value or vector of floats of that value m_FPOne - match a floating point 1.0 or vector of 1.0s m_NegZero - match -0.0 m_AnyZero - match 0 or -0.0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169939 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove FIXMEs surrounding Constant[Data]Vectors, insteadMichael Ilseman2012-12-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169938 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove trailing whitespaceMichael Ilseman2012-12-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169637 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert commit 149912 (lattner) and add a testcase that shows the problem (whichDuncan Sands2012-02-10
| | | | | | | | | | | is that patterns no longer match for vectors of booleans, because you only get ConstantDataVector when the vector element type is i8, i16, etc, not when it is i1). Original commit message: Remove some dead code and tidy things up now that vectors use ConstantDataVector instead of always using ConstantVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150246 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove some dead code and tidy things up now that vectors use ConstantDataVectorChris Lattner2012-02-06
| | | | | | | | instead of always using ConstantVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149912 91177308-0d34-0410-b5e6-96231b3b80d8
* progress making the world safe to ConstantDataVector. WhileChris Lattner2012-01-26
| | | | | | | | | we're at it, allow PatternMatch's "neg" pattern to match integer vector negations, and enhance ComputeNumSigned bits to handle shl of vectors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149082 91177308-0d34-0410-b5e6-96231b3b80d8
* PatternMatch: Introduce a matcher for instructions with the "exact" bit. Use ↵Benjamin Kramer2012-01-01
| | | | | | it to simplify a few matchers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147403 91177308-0d34-0410-b5e6-96231b3b80d8
* PatternMatch: Simplify code by reusing the Operator class.Benjamin Kramer2012-01-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147402 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement some basic simplifications involving min/max, for exampleDuncan Sands2011-05-03
| | | | | | | | | max(a,b) >= a -> true. According to my super-optimizer, these are by far the most common simplifications (of the -instsimplify kind) that occur in the testsuite and aren't caught by -std-compile-opts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130780 91177308-0d34-0410-b5e6-96231b3b80d8
* add an m_ConstantInt matching predicate that binds to a uint64_t, and add an ↵Chris Lattner2011-04-26
| | | | | | | | | m_OneUse() predicate that matches if the subexpr has a single use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130235 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach PatternMatch that splat vectors could be floating point as well asNick Lewycky2011-02-15
| | | | | | | integer. Fixes PR9228! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125613 91177308-0d34-0410-b5e6-96231b3b80d8
* Rework InstrTypes.h so to reduce the repetition around the NSW/NUW/ExactChris Lattner2011-02-09
| | | | | | | | | | | | | | | | | | | | versions of creation functions. Eventually, the "insertion point" versions of these should just be removed, we do have IRBuilder afterall. Do a massive rewrite of much of pattern match. It is now shorter and less redundant and has several other widgets I will be using in other patches. Among other changes, m_Div is renamed to m_IDiv (since it only matches integer divides) and m_Shift is gone (it used to match all binops!!) and we now have m_LogicalShift for the one client to use. Enhance IRBuilder to have "isExact" arguments to things like CreateUDiv and reduce redundancy within IRbuilder by having these methods chain to each other more instead of duplicating code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125194 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an m_Div pattern for matching either a udiv or an sdiv and use itDuncan Sands2011-02-07
| | | | | | | to simplify the "(X/Y)*Y->X when the division is exact" transform. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125004 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a m_Undef pattern for convenience. This is so that code that usesDuncan Sands2011-02-01
| | | | | | | | pattern matching can also pattern match undef, creating a more uniform style. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124657 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a m_SignBit pattern for convenience.Duncan Sands2011-02-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124656 91177308-0d34-0410-b5e6-96231b3b80d8
* Have m_One also match constant vectors for which every element is 1.Duncan Sands2011-02-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124655 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix m_Not and m_Neg to not match random ConstantInt's. BeforeChris Lattner2011-01-15
| | | | | | | | | | | | | | | these would try hard to match constants by inverting the bits and recursively matching. There are two problems with this: 1) some patterns would match when we didn't want them to (theoretical) 2) this is insanely expensive to do, and most often pointless. This was apparently useful in just 2 instcombine cases, which I added code to handle explicitly. This change speeds up 'opt' time on 176.gcc by 1% and produces bitwise identical code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123518 91177308-0d34-0410-b5e6-96231b3b80d8
* Move some those Xor simplifications which don't require creating newDuncan Sands2010-11-17
| | | | | | | | | instructions out of InstCombine and into InstructionSimplify. While there, introduce an m_AllOnes pattern to simplify matching with integers and vectors with all bits equal to one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119536 91177308-0d34-0410-b5e6-96231b3b80d8
* add m_BitCast for matching a bitcast.Chris Lattner2010-08-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112222 91177308-0d34-0410-b5e6-96231b3b80d8
* change the canonical form of "cond ? -1 : 0" to be Chris Lattner2010-01-24
| | | | | | | | | "sext cond" instead of a select. This simplifies some instcombine code, matches the policy for zext (cond ? 1 : 0 -> zext), and allows us to generate better code for a testcase on ppc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94339 91177308-0d34-0410-b5e6-96231b3b80d8
* teach instcombine to optimize pointer difference idioms involving constantChris Lattner2010-01-01
| | | | | | | expressions. This is a step towards comment #4 in PR3351. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92401 91177308-0d34-0410-b5e6-96231b3b80d8
* add a helper for matching "1".Chris Lattner2009-10-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83760 91177308-0d34-0410-b5e6-96231b3b80d8
* Mark more constants unsigned, as warned about by icc (#68).Duncan Sands2009-09-06
| | | | | | | Patch by Erick Tryzelaar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81116 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a bunch more now-unnecessary Context arguments.Dan Gohman2009-08-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78809 91177308-0d34-0410-b5e6-96231b3b80d8
* Move ConstantExpr to 2.5 API.Owen Anderson2009-07-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77494 91177308-0d34-0410-b5e6-96231b3b80d8
* Move ConstantFP construction back to the 2.5-ish API.Owen Anderson2009-07-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77247 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix obvious typo.Eli Friedman2009-07-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75563 91177308-0d34-0410-b5e6-96231b3b80d8
* Push LLVMContext through the PatternMatch API.Owen Anderson2009-07-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75255 91177308-0d34-0410-b5e6-96231b3b80d8
* Split the Add, Sub, and Mul instruction opcodes into separateDan Gohman2009-06-04
| | | | | | | | | | | | | | | | integer and floating-point opcodes, introducing FAdd, FSub, and FMul. For now, the AsmParser, BitcodeReader, and IRBuilder all preserve backwards compatability, and the Core LLVM APIs preserve backwards compatibility for IR producers. Most front-ends won't need to change immediately. This implements the first step of the plan outlined here: http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72897 91177308-0d34-0410-b5e6-96231b3b80d8
* Removed trailing whitespace.Misha Brukman2009-02-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65196 91177308-0d34-0410-b5e6-96231b3b80d8
* no need to negate the APInt for 0.Chris Lattner2009-01-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61777 91177308-0d34-0410-b5e6-96231b3b80d8
* Change m_ConstantInt and m_SelectCst to take their constant integersChris Lattner2009-01-05
| | | | | | | | as template arguments instead of as instance variables, exposing more optimization opportunities to the compiler earlier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61776 91177308-0d34-0410-b5e6-96231b3b80d8
* make m_ConstantInt(int64_t) safely match ConstantInt's that are larger than i64.Chris Lattner2009-01-05
| | | | | | | This fixes an instcombine crash on PR3235. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61775 91177308-0d34-0410-b5e6-96231b3b80d8
* * Alphabetized system headers per the style guideMisha Brukman2009-01-02
| | | | | | | * Minor spacing and comment cleanups git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61590 91177308-0d34-0410-b5e6-96231b3b80d8
* add a new m_Specific pattern that matches only if we have a specific Value*.Chris Lattner2008-11-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59393 91177308-0d34-0410-b5e6-96231b3b80d8
* add a new template for matching a select between two constants.Chris Lattner2008-11-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59391 91177308-0d34-0410-b5e6-96231b3b80d8
* Canonicalize sext(i1) to i1?-1:0, and update various instcombineDan Gohman2008-10-30
| | | | | | | optimizations accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58457 91177308-0d34-0410-b5e6-96231b3b80d8
* add support for pattern matching 'neg'Chris Lattner2008-05-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50883 91177308-0d34-0410-b5e6-96231b3b80d8
* add match support for casts.Chris Lattner2008-01-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45744 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't attribute in file headers anymore. See llvmdev for theChris Lattner2007-12-29
| | | | | | | | discussion of this change. Boy are my fingers tired. ;-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45411 91177308-0d34-0410-b5e6-96231b3b80d8
* Add m_Zero(). Chris Lattner2007-12-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45255 91177308-0d34-0410-b5e6-96231b3b80d8
* m_not should match vector notChris Lattner2007-06-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37587 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename Value::getValueType to getValueID, to avoid confusion withDan Gohman2007-04-13
| | | | | | | other things named getValueType. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35964 91177308-0d34-0410-b5e6-96231b3b80d8