summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/shift.ll
Commit message (Collapse)AuthorAge
* InstCombine: Check for zero shift amounts before subtracting one causing ↵Benjamin Kramer2013-08-30
| | | | | | | | | integer overflow. PR17026. Also avoid undefined shifts and shift amounts larger than 64 bits (those are always undef because we can't represent integer types that large). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189672 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
* Commit r185909 was a misapplied patch, fix itDavid Majnemer2013-07-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185910 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r174152. The shift amount may overflow and in that case this ↵Nadav Rotem2013-02-01
| | | | | | transformation is illegal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174156 91177308-0d34-0410-b5e6-96231b3b80d8
* Optimize shift lefts of a constant by a value plus constant into a single shift.Nadav Rotem2013-02-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174152 91177308-0d34-0410-b5e6-96231b3b80d8
* - Fix a problematic way in creating all-the-1 APInt.Shuxin Yang2012-12-12
| | | | | | | - Propagate "exact" bit of [l|a]shr instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169942 91177308-0d34-0410-b5e6-96231b3b80d8
* For rdar://12329730, last piece.Shuxin Yang2012-12-04
| | | | | | | | | | | | | | | | | | | | | | This change attempts to simplify (X^Y) -> X or Y in the user's context if we know that only bits from X or Y are demanded. A minimized case is provided bellow. This change will simplify "t>>16" into "var1 >>16". ============================================================= unsigned foo (unsigned val1, unsigned val2) { unsigned t = val1 ^ 1234; return (t >> 16) | t; // NOTE: t is used more than once. } ============================================================= Note that if the "t" were used only once, the expression would be finally optimized as well. However, with with this change, the optimization will take place earlier. Reviewed by Nadav, Thanks a lot! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169317 91177308-0d34-0410-b5e6-96231b3b80d8
* rdar://12329730 (2nd part, revised)Shuxin Yang2012-12-04
| | | | | | | | The type of shirt-right (logical or arithemetic) should remain unchanged when transforming "X << C1 >> C2" into "X << (C1-C2)" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169209 91177308-0d34-0410-b5e6-96231b3b80d8
* rdar://12329730 (2nd part)Shuxin Yang2012-12-04
| | | | | | | | | | | | This change tries to simmplify E1 = " X >> C1 << C2" into : - E2 = "X << (C2 - C1)" if C2 > C1, or - E2 = "X >> (C1 - C2)" if C1 > C2, or - E2 = X if C1 == C2. Reviewed by Nadav. Thanks! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169182 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r155136 after fixing PR12599.Jakob Stoklund Olesen2012-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original commit message: Defer some shl transforms to DAGCombine. The shl instruction is used to represent multiplication by a constant power of two as well as bitwise left shifts. Some InstCombine transformations would turn an shl instruction into a bit mask operation, making it difficult for later analysis passes to recognize the constsnt multiplication. Disable those shl transformations, deferring them to DAGCombine time. An 'shl X, C' instruction is now treated mostly the same was as 'mul X, C'. These transformations are deferred: (X >>? C) << C --> X & (-1 << C) (When X >> C has multiple uses) (X >>? C1) << C2 --> X << (C2-C1) & (-1 << C2) (When C2 > C1) (X >>? C1) << C2 --> X >>? (C1-C2) & (-1 << C2) (When C1 > C2) The corresponding exact transformations are preserved, just like div-exact + mul: (X >>?,exact C) << C --> X (X >>?,exact C1) << C2 --> X << (C2-C1) (X >>?,exact C1) << C2 --> X >>?,exact (C1-C2) The disabled transformations could also prevent the instruction selector from recognizing rotate patterns in hash functions and cryptographic primitives. I have a test case for that, but it is too fragile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155362 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r155136 "Defer some shl transforms to DAGCombine."Jakob Stoklund Olesen2012-04-20
| | | | | | | | | While the patch was perfect and defect free, it exposed a really nasty bug in X86 SelectionDAG that caused an llc crash when compiling lencod. I'll put the patch back in after fixing the SelectionDAG problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155181 91177308-0d34-0410-b5e6-96231b3b80d8
* Defer some shl transforms to DAGCombine.Jakob Stoklund Olesen2012-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The shl instruction is used to represent multiplication by a constant power of two as well as bitwise left shifts. Some InstCombine transformations would turn an shl instruction into a bit mask operation, making it difficult for later analysis passes to recognize the constsnt multiplication. Disable those shl transformations, deferring them to DAGCombine time. An 'shl X, C' instruction is now treated mostly the same was as 'mul X, C'. These transformations are deferred: (X >>? C) << C --> X & (-1 << C) (When X >> C has multiple uses) (X >>? C1) << C2 --> X << (C2-C1) & (-1 << C2) (When C2 > C1) (X >>? C1) << C2 --> X >>? (C1-C2) & (-1 << C2) (When C1 > C2) The corresponding exact transformations are preserved, just like div-exact + mul: (X >>?,exact C) << C --> X (X >>?,exact C1) << C2 --> X << (C2-C1) (X >>?,exact C1) << C2 --> X >>?,exact (C1-C2) The disabled transformations could also prevent the instruction selector from recognizing rotate patterns in hash functions and cryptographic primitives. I have a test case for that, but it is too fragile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155136 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach instcombine all sorts of great stuff about shifts that have exact, nuw orNick Lewycky2012-01-04
| | | | | | | nsw bits on them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147528 91177308-0d34-0410-b5e6-96231b3b80d8
* Make use of the exact bit when optimizing '(X >>exact 3) << 1' to eliminate theNick Lewycky2011-12-31
| | | | | | | | 'and' that would zero out the trailing bits, and to produce an exact shift ourselves. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147391 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure to correctly clear the exact/nuw/nsw flags off of shifts when they ↵Eli Friedman2011-07-29
| | | | | | are combined together. <rdar://problem/9859829> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136435 91177308-0d34-0410-b5e6-96231b3b80d8
* Transform any logical shift of a power of two into an exact/NUW shift whenChris Lattner2011-05-23
| | | | | | | in a known-non-zero context. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131887 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: turn (C1 << A) << C2) into (C1 << C2) << A)Benjamin Kramer2011-04-29
| | | | | | Fixes PR9809. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130485 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance a bunch of transformations in instcombine to start generatingChris Lattner2011-02-10
| | | | | | | | | | | | | exact/nsw/nuw shifts and have instcombine infer them when it can prove that the relevant properties are true for a given shift without them. Also, a variety of refactoring to use the new patternmatch logic thrown in for good luck. I believe that this takes care of a bunch of related code quality issues attached to PR8862. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125267 91177308-0d34-0410-b5e6-96231b3b80d8
* Move some shift transforms out of instcombine and into InstructionSimplify.Duncan Sands2011-01-14
| | | | | | | | | | | | | While there, I noticed that the transform "undef >>a X -> undef" was wrong. For example if X is 2 then the top two bits must be equal, so the result can not be anything. I fixed this in the constant folder as well. Also, I made the transform for "X << undef" stronger: it now folds to undef always, even though X might be zero. This is in accordance with the LangRef, but I must admit that it is fairly aggressive. Also, I added "i32 X << 32 -> undef" following the LangRef and the constant folder, likewise fairly aggressive. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123417 91177308-0d34-0410-b5e6-96231b3b80d8
* When determining if we can fold (x >> C1) << C2, the bits that we need to ↵Owen Anderson2010-12-23
| | | | | | | | | verify are zero are not the low bits of x, but the bits that WILL be the low bits after the operation completes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122529 91177308-0d34-0410-b5e6-96231b3b80d8
* The srem -> urem transform is not safe for any divisor that's not a power of ↵Benjamin Kramer2010-11-23
| | | | | | | | | | | two. E.g. -5 % 5 is 0 with srem and 1 with urem. Also addresses Frits van Bommel's comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120049 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Reduce "X shift (A srem B)" to "X shift (A urem B)" iff B is ↵Benjamin Kramer2010-11-23
| | | | | | | | | positive. This allows to transform the rem in "1 << ((int)x % 8);" to an and. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120028 91177308-0d34-0410-b5e6-96231b3b80d8
* tidy up test.Chris Lattner2010-08-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112321 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance the shift propagator to handle the case when you have:Chris Lattner2010-08-27
| | | | | | | | | | | | | | | | | | A = shl x, 42 ... B = lshr ..., 38 which can be transformed into: A = shl x, 4 ... iff we can prove that the would-be-shifted-in bits are already zero. This eliminates two shifts in the testcase and allows eliminate of the whole i128 chain in the real example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112314 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement a pretty general logical shift propagationChris Lattner2010-08-27
| | | | | | | | | | | | | framework, which is good at ripping through bitfield operations. This generalize a bunch of the existing xforms that instcombine does, such as (x << c) >> c -> and to handle intermediate logical nodes. This is useful for ripping up the "promote to large integer" code produced by SRoA. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112304 91177308-0d34-0410-b5e6-96231b3b80d8
* merge and filecheckize testChris Lattner2010-08-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112289 91177308-0d34-0410-b5e6-96231b3b80d8
* merge two testsChris Lattner2010-08-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112288 91177308-0d34-0410-b5e6-96231b3b80d8
* merge test into shift.ll, this also eliminates awful grepping on -stats outputChris Lattner2009-10-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83802 91177308-0d34-0410-b5e6-96231b3b80d8
* convert to filecheck.Chris Lattner2009-10-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83801 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
* two changes:Chris Lattner2009-03-24
| | | | | | | | | | | | 1. Make instcombine always canonicalize trunc x to i1 into an icmp(x&1). This exposes the AND to other instcombine xforms and is more of what the code generator expects. 2. Rewrite the remaining trunc pattern match to use 'match', which simplifies it a lot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67635 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove llvm-upgrade and update tests.Tanya Lattner2008-03-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48103 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
* 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
* Make these tests fail if opt crashes.Chris Lattner2006-02-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26127 91177308-0d34-0410-b5e6-96231b3b80d8
* A case that instcombine is not catching.Chris Lattner2006-01-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25127 91177308-0d34-0410-b5e6-96231b3b80d8
* new testcaseChris Lattner2005-09-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23380 91177308-0d34-0410-b5e6-96231b3b80d8
* new testcaseChris Lattner2005-05-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21774 91177308-0d34-0410-b5e6-96231b3b80d8
* new testcaseChris Lattner2005-05-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21714 91177308-0d34-0410-b5e6-96231b3b80d8
* New testcasesChris Lattner2004-09-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16547 91177308-0d34-0410-b5e6-96231b3b80d8
* Testcases for rev 250 of InstructionCombining.cppChris Lattner2004-09-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16522 91177308-0d34-0410-b5e6-96231b3b80d8
* New testcaseChris Lattner2004-05-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13739 91177308-0d34-0410-b5e6-96231b3b80d8
* Testcase to make sure we can apply the shift to the operands of the select,Chris Lattner2004-04-09
| | | | | | | eliminating the shifts git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12801 91177308-0d34-0410-b5e6-96231b3b80d8
* Renamed `as' => `llvm-as', `dis' => `llvm-dis', `link' => `llvm-link'.Misha Brukman2003-09-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8558 91177308-0d34-0410-b5e6-96231b3b80d8
* Update test to represent new cannonicalization rules for multipliesChris Lattner2003-08-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7804 91177308-0d34-0410-b5e6-96231b3b80d8
* Right, instcombine cannot remove ((X >> C) << C) if it's signed.Chris Lattner2003-08-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7790 91177308-0d34-0410-b5e6-96231b3b80d8
* New testcasesChris Lattner2003-08-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7789 91177308-0d34-0410-b5e6-96231b3b80d8
* New testcases for signed shiftsChris Lattner2003-07-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7294 91177308-0d34-0410-b5e6-96231b3b80d8