summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/select.ll
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
* Update Transforms tests to use CHECK-LABEL for easier debugging. No ↵Stephen Lin2013-07-14
| | | | | | | | | | | | | | | | | | | | | | | functionality change. This update was done with the following bash script: find test/Transforms -name "*.ll" | \ while read NAME; do echo "$NAME" if ! grep -q "^; *RUN: *llc" $NAME; then TEMP=`mktemp -t temp` cp $NAME $TEMP sed -n "s/^define [^@]*@\([A-Za-z0-9_]*\)(.*$/\1/p" < $NAME | \ while read FUNC; do sed -i '' "s/;\(.*\)\([A-Za-z0-9_]*\):\( *\)@$FUNC\([( ]*\)\$/;\1\2-LABEL:\3@$FUNC(/g" $TEMP done mv $TEMP $NAME fi done git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186268 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
* Add a test for the foldSelectICmpAndOr fix committed in r180779.David Majnemer2013-05-02
| | | | | | | | This tests a case where C1 and C2 were the same but X and Y were different widths. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180907 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
* 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
* 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
* 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
* 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
* 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
* 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
* Clean up the tests a little, make sure we match an instruction in the rightNick Lewycky2011-01-28
| | | | | | | test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124473 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
* Don't try to pull vector bitcasts that change the number of elements throughNick Lewycky2011-01-21
| | | | | | | | a select. A vector select is pairwise on each element so we'd need a new condition with the right number of elements to select on. Fixes PR8994. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123963 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
* 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
* 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
* Make this test not depend on how the variable is named.Duncan Sands2010-12-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122413 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
* Move PHI tests to phi.ll, out of select.ll.Duncan Sands2010-11-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119153 91177308-0d34-0410-b5e6-96231b3b80d8
* Generalize the reassociation transform in SimplifyCommutative (now renamed toDuncan Sands2010-11-13
| | | | | | | | | | | | | | | | | SimplifyAssociativeOrCommutative) "(A op C1) op C2" -> "A op (C1 op C2)", which previously was only done if C1 and C2 were constants, to occur whenever "C1 op C2" simplifies (a la InstructionSimplify). Since the simplifying operand combination can no longer be assumed to be the right-hand terms, consider all of the possible permutations. When compiling "gcc as one big file", transform 2 (i.e. using right-hand operands) fires about 4000 times but it has to be said that most of the time the simplifying operands are both constants. Transforms 3, 4 and 5 each fired once. Transform 6, which is an existing transform that I didn't change, never fired. With this change, the testcase is now optimized perfectly with one run of instcombine (previously it required instcombine + reassociate + instcombine, and it may just have been luck that this worked). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119002 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach InstructionSimplify how to look through PHI nodes. Since PHIDuncan Sands2010-11-10
| | | | | | | | | | nodes can be used in loops, this could result in infinite looping if there is no recursion limit, so add such a limit. It is also used for the SelectInst case because in theory there could be an infinite loop there too if the basic block is unreachable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118694 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an additional test for icmp of select folding.Duncan Sands2010-11-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118441 91177308-0d34-0410-b5e6-96231b3b80d8
* Add simplification of floating point comparisons with the resultDuncan Sands2010-11-07
| | | | | | | | of a select instruction, the same as already exists for integer comparisons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118379 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a README item: when doing a comparison with the resultDuncan Sands2010-11-07
| | | | | | | | | of a select instruction, see if doing the compare with the true and false values of the select gives the same result. If so, that can be used as the value of the comparison. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118378 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach instcombine to transformBenjamin Kramer2010-07-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | (X >s -1) ? C1 : C2 and (X <s 0) ? C2 : C1 into ((X >>s 31) & (C2 - C1)) + C1, avoiding the conditional. This optimization could be extended to take non-const C1 and C2 but we better stay conservative to avoid code size bloat for now. for int sel(int n) { return n >= 0 ? 60 : 100; } we now generate sarl $31, %edi andl $40, %edi leal 60(%rdi), %eax instead of testl %edi, %edi movl $60, %ecx movl $100, %eax cmovnsl %ecx, %eax git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107866 91177308-0d34-0410-b5e6-96231b3b80d8
* add check lines for min/max tests.Chris Lattner2009-12-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91816 91177308-0d34-0410-b5e6-96231b3b80d8
* really convert this to filecheck.Chris Lattner2009-12-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91815 91177308-0d34-0410-b5e6-96231b3b80d8
* give instcombine some helper functions for matching MIN and MAX, andChris Lattner2009-12-21
| | | | | | | | | | implement some optimizations for MIN(MIN()) and MAX(MAX()) and MIN(MAX()) etc. This substantially improves the code in PR5822 but doesn't kick in much elsewhere. 2 max's were optimized in pairlocalalign and one in smg2000. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91814 91177308-0d34-0410-b5e6-96231b3b80d8
* filecheckizeChris Lattner2009-12-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91813 91177308-0d34-0410-b5e6-96231b3b80d8
* The select instruction is not neccesarily in the same block as theChris Lattner2009-09-28
| | | | | | | | | phi nodes. Make sure to phi translate from the right block. This fixes a llvm-building-llvm failure on GVN-PRE.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82970 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance the previous fix for PR4895 to allow more values than justChris Lattner2009-09-27
| | | | | | | | simple constants for the true/false value of the select. We now do phi translation etc. This really fixes PR4895 :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82917 91177308-0d34-0410-b5e6-96231b3b80d8
* implement PR4895, by making FoldOpIntoPhi handle select conditionsChris Lattner2009-09-27
| | | | | | | | | | | that are phi nodes. Also tighten up FoldOpIntoPhi to treat constantexpr operands to phis just like other variables, avoiding moving constantexpr computations around. Patch by Daniel Dunbar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82913 91177308-0d34-0410-b5e6-96231b3b80d8
* Use opt -S instead of piping bitcode output through llvm-dis.Dan Gohman2009-09-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81257 91177308-0d34-0410-b5e6-96231b3b80d8
* Change these tests to feed the assembly files to opt directly, insteadDan Gohman2009-09-08
| | | | | | | of using llvm-as, now that opt supports this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81226 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove llvm-upgrade and update test cases.Tanya Lattner2008-03-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47793 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement PR1822Chris Lattner2007-11-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44318 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR1319:Reid Spencer2007-04-15
| | | | | | | | Make use of the END. facility on all files > 1K so that we aren't wasting CPU cycles searching for RUN: lines that we'll never find. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36059 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR1319:Reid Spencer2007-04-14
| | | | | | | Upgrade tests to work with new llvm.exp version of llvm_runtest. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36013 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the llvm-upgrade program to upgrade llvm assembly.Reid Spencer2006-12-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32115 91177308-0d34-0410-b5e6-96231b3b80d8
* number test rightChris Lattner2006-09-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30484 91177308-0d34-0410-b5e6-96231b3b80d8
* make this harderChris Lattner2006-09-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30481 91177308-0d34-0410-b5e6-96231b3b80d8
* new testcasesChris Lattner2006-09-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30480 91177308-0d34-0410-b5e6-96231b3b80d8
* new testcaseChris Lattner2006-09-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30229 91177308-0d34-0410-b5e6-96231b3b80d8
* add a new testcaseChris Lattner2005-04-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21469 91177308-0d34-0410-b5e6-96231b3b80d8