summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineSelect.cpp
Commit message (Collapse)AuthorAge
* InstCombine: Only foldSelectICmpAndOr for integer typesJustin Bogner2013-09-27
| | | | | | | | | | Currently foldSelectICmpAndOr asserts if the "or" involves a vector containing several of the same power of two. We can easily avoid this by only performing the fold on integer types, like foldSelectICmpAnd does. Fixes <rdar://problem/15012516> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191552 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Also turn selects fed by an and into arithmetic when the types ↵Benjamin Kramer2013-06-29
| | | | | | | | | don't match. Inserting a zext or trunc is sufficient. This pattern is somewhat common in LLVM's pointer mangling code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185270 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r164763 because it introduces new shuffles.Nadav Rotem2013-05-06
| | | | | | | | Thanks Nick Lewycky for pointing this out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181177 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in foldSelectICmpAndOr.David Majnemer2013-04-30
| | | | | | | | Differences in bitwidth between X and Y could exist even if C1 and C2 have the same Log2 representation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180779 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix "Combine bit test + conditional or into simple math"David Majnemer2013-04-30
| | | | | | | | | | This fixes the optimization introduced in r179748 and reverted in r179750. While the optimization was sound, it did not properly respect differences in bit-width. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180777 91177308-0d34-0410-b5e6-96231b3b80d8
* Keep coding stanard. Don't use "else if" after "return".Jakub Staszak2013-04-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179826 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Combine bit test + conditional or into simple math"David Majnemer2013-04-18
| | | | | | | It is causing stage2 builds to fail, let's get them running again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179750 91177308-0d34-0410-b5e6-96231b3b80d8
* Combine bit test + conditional or into simple mathDavid Majnemer2013-04-18
| | | | | | | | | | | | | | | | | Simplify: (select (icmp eq (and X, C1), 0), Y, (or Y, C2)) Into: (or (shl (and X, C1), C3), y) Where: C3 = Log(C2) - Log(C1) If: C1 and C2 are both powers of two git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179748 91177308-0d34-0410-b5e6-96231b3b80d8
* Tidy up a bit. No functional change.Jim Grosbach2013-04-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178915 91177308-0d34-0410-b5e6-96231b3b80d8
* Check if Type is a vector before calling function Type::getVectorNumElements.Akira Hatanaka2013-03-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178208 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-03
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Fix an edge case where constant icmps could sneak into ↵Benjamin Kramer2012-10-20
| | | | | | | | ConstantFoldInstOperands and crash. Have to refactor the ConstantFolder interface one day to define bugs like this away. Fixes PR14131. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166374 91177308-0d34-0410-b5e6-96231b3b80d8
* Move TargetData to DataLayout.Micah Villmow2012-10-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165402 91177308-0d34-0410-b5e6-96231b3b80d8
* Surprisingly, we missed a trivial case here. Fix that!Nick Lewycky2012-09-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164814 91177308-0d34-0410-b5e6-96231b3b80d8
* Prefer shuffles to selects. Backends love shuffles!Nick Lewycky2012-09-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164763 91177308-0d34-0410-b5e6-96231b3b80d8
* fix infinite loop in instcombine in the presence of a (malformed) ↵Nuno Lopes2012-07-27
| | | | | | | | self-referencing select inst. This can happen as long as the instruction is not reachable. Instcombine does generate these unreachable malformed selects when doing RAUW git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160874 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify demanded bits of select sources where the condition is a constant ↵Pete Cooper2012-07-26
| | | | | | vector git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160835 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in FoldSelectOpOp. Bitcast ops may change the number of vector ↵Nadav Rotem2012-06-07
| | | | | | elements, which may disagree with the select condition type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158166 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Fix infinite loop when encountering switch on trivial icmp.Benjamin Kramer2012-05-28
| | | | | | | | | | | | The test case feeds the following into InstCombine's visitSelect: %tobool8 = icmp ne i32 0, 0 %phitmp = select i1 %tobool8, i32 3, i32 0 Then instcombine replaces the right side of the switch with 0, doesn't notice that nothing changes and tries again indefinitely. This fixes PR12897. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157587 91177308-0d34-0410-b5e6-96231b3b80d8
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148578 91177308-0d34-0410-b5e6-96231b3b80d8
* Added InstCombine for "select cond, ~cond, x" type patternsPete Cooper2011-12-15
| | | | | | These can be reduced to "~cond & x" or "~cond | x" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146624 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a few more places where TargetData/TargetLibraryInfo is not being passed.Chad Rosier2011-12-02
| | | | | | Add FIXMEs to places that are non-trivial to fix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145661 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new icmp+select optz'n. Also shows off the load(cst) folding added inNick Lewycky2011-10-02
| | | | | | | r140966. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140969 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance a couple places where we were doing constant folding of instructions,Nick Lewycky2011-10-02
| | | | | | | but not load instructions. Noticed by inspection. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140966 91177308-0d34-0410-b5e6-96231b3b80d8
* Clean up includes of llvm/Analysis/ConstantFolding.h so it's included where ↵Eli Friedman2011-07-20
| | | | | | it's used and not included where it isn't. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135628 91177308-0d34-0410-b5e6-96231b3b80d8
* Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.Jay Foad2011-07-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135477 91177308-0d34-0410-b5e6-96231b3b80d8
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
* PR10180: Fix a instcombine crash with FP vectors.Eli Friedman2011-06-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133756 91177308-0d34-0410-b5e6-96231b3b80d8
* ConstantFoldInstOperands doesn't like compares, hand it off to instsimplify ↵Benjamin Kramer2011-05-28
| | | | | | | | instead. Fixes PR10040. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132254 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Make switch folding with equality compares more aggressive by ↵Benjamin Kramer2011-05-27
| | | | | | | | trying instsimplify on the arm where we know the compared value. Stuff like "x == y ? y : x&y" now folds into "x&y". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132185 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch more inst insertion in instcombine to IRBuilder.Eli Friedman2011-05-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131547 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch more inst insertion in instcombine to IRBuilder.Eli Friedman2011-05-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131544 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch inst insertion in instcombine transform to IRBuilder.Eli Friedman2011-05-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131542 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove tabs I accidentally added.Nick Lewycky2011-03-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128413 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach the transformation that moves binary operators around selects to preserveNick Lewycky2011-03-27
| | | | | | | the subclass optional data. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128388 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a small missed optimization: turn X == C ? X : Y into X == C ? C : Y. ThisNick Lewycky2011-03-27
| | | | | | | | | | | removes one use of X which helps it pass the many hasOneUse() checks. In my analysis, this turns up very often where X = A >>exact B and that can't be simplified unless X has one use (except by increasing the lifetime of A which is generally a performance loss). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128373 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Fix a thinko where transform an icmp under the assumption that ↵Benjamin Kramer2011-03-11
| | | | | | | | it's a zero comparison when it's not. Fixes PR9454. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127464 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold select + select where both selects are on the same condition.Nick Lewycky2011-01-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124469 91177308-0d34-0410-b5e6-96231b3b80d8
* Instcombine: Fix pattern where the sext did not dominate the icmp using itTobias Grosser2011-01-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123121 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in r123034 (trying to sext/zext non-integers) and clean up a little.Frits van Bommel2011-01-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123061 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Match min/max hidden by sext/zextTobias Grosser2011-01-07
| | | | | | | | | | | | | | | X = sext x; x >s c ? X : C+1 --> X = sext x; X <s C+1 ? C+1 : X X = sext x; x <s c ? X : C-1 --> X = sext x; X >s C-1 ? C-1 : X X = zext x; x >u c ? X : C+1 --> X = zext x; X <u C+1 ? C+1 : X X = zext x; x <u c ? X : C-1 --> X = zext x; X >u C-1 ? C-1 : X X = sext x; x >u c ? X : C+1 --> X = sext x; X <u C+1 ? C+1 : X X = sext x; x <u c ? X : C-1 --> X = sext x; X >u C-1 ? C-1 : X Instead of calculating this with mixed types promote all to the larger type. This enables scalar evolution to analyze this expression. PR8866 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123034 91177308-0d34-0410-b5e6-96231b3b80d8
* Some whitespace fixesTobias Grosser2011-01-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123033 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: creating selects from -1 and 0 is fine, they combine into a ↵Benjamin Kramer2010-12-22
| | | | | | sext from i1. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122453 91177308-0d34-0410-b5e6-96231b3b80d8
* Generalize the and-icmp-select instcombine further by allowing selects of ↵Benjamin Kramer2010-12-11
| | | | | | | | | | | | the form (x & 2^n) ? 2^m+C : C we can offset both arms by C to get the "(x & 2^n) ? 2^m : 0" form, optimize the select to a shift and apply the offset afterwards. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121609 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor the (x & 2^n) ? 2^m : 0 instcombine into its own method and generalize itBenjamin Kramer2010-12-11
| | | | | | | to catch cases where n != m with a shift. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121608 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach InstCombine not to use Add and Neg on FP. PR 8490.Dale Johannesen2010-10-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117510 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the rest of my instcombine changes. Back to the drawing board on ↵Owen Anderson2010-07-16
| | | | | | this one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108530 91177308-0d34-0410-b5e6-96231b3b80d8
* Speculatively revert r108429 to fix the clang self-host.Owen Anderson2010-07-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108436 91177308-0d34-0410-b5e6-96231b3b80d8
* Per Chris' suggestion, get rid of the select canonicalization and just addOwen Anderson2010-07-15
| | | | | | | | | the corresponding or-icmp-and pattern. This has the added benefit of doing the matching earlier, and thus being less susceptible to being confused by earlier transforms. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108429 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r108378, with bugfixes, testcase, and improved comment formatting.Owen Anderson2010-07-15
| | | | | | | This now passes LIT, nighty test, and llvm-gcc bootstrap on my machine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108422 91177308-0d34-0410-b5e6-96231b3b80d8