summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* For PR1271:Reid Spencer2007-03-261-1/+1
| | | | | | | | Fix SingleSource/Regression/C/2003-05-21-UnionBitFields.c by changing a getHighBitsSet call to getLowBitsSet call that was incorrectly converted from the original lshr constant expression. llvm-svn: 35348
* For PR1271:Reid Spencer2007-03-251-12/+11
| | | | | | | | | | Remove a use of getLowBitsSet that caused the mask used for replacement of shl/lshr pairs with an AND instruction to be computed incorrectly. Its not clear exactly why this is the case. This solves the disappearing shifts problem, but it doesn't fix Regression/C/2003-05-21-UnionBitFields. It seems there is more going on. llvm-svn: 35342
* implement Transforms/InstCombine/cast2.ll:test3 and PR1263Chris Lattner2007-03-251-1/+21
| | | | llvm-svn: 35341
* Some cleanup from review:Reid Spencer2007-03-251-16/+18
| | | | | | | | | * Don't assume shift amounts are <= 64 bits * Avoid creating an extra APInt in SubOne and AddOne by using -- and ++ * Add another use of getLowBitsSet * Convert a series of if statements to a switch llvm-svn: 35339
* Refactor several ConstantExpr::getXXX calls with ConstantInt argumentsReid Spencer2007-03-251-27/+40
| | | | | | | | using the facilities of APInt. While this duplicates a tiny fraction of the constant folding code, it also makes the code easier to read and avoids large ConstantExpr overhead for simple, known computations. llvm-svn: 35335
* 1. Avoid unnecessary APInt construction if possible.Zhou Sheng2007-03-251-7/+5
| | | | | | | 2. Use isStrictlyPositive() instead of isPositive() in two places where they need APInt value > 0 not only >=0. llvm-svn: 35333
* Make more uses of getHighBitsSet and get rid of some pointless & of anReid Spencer2007-03-251-12/+12
| | | | | | APInt with its type mask. llvm-svn: 35325
* More APIntification:Reid Spencer2007-03-251-24/+24
| | | | | | | | | | | | | | | * Convert the last use of a uint64_t that should have been an APInt. * Change ComputeMaskedBits to have a const reference argument for the Mask so that recursions don't cause unneeded temporaries. This causes temps to be needed in other places (where the mask has to change) but this change optimizes for the recursion which is more frequent. * Remove two instances of &ing a Mask with getAllOnesValue. Its not needed any more because APInt is accurate in its bit computations. * Start using the getLowBitsSet and getHighBits set methods on APInt instead of shifting. This makes it more clear in the code what is going on. llvm-svn: 35321
* fix a regression on vector or instructions.Chris Lattner2007-03-241-9/+9
| | | | llvm-svn: 35314
* Make some codes more efficient.Zhou Sheng2007-03-241-15/+17
| | | | llvm-svn: 35297
* For PR1205:Reid Spencer2007-03-241-12/+11
| | | | | | | Convert some calls to ConstantInt::getZExtValue() into getValue() and use APInt facilities in the subsequent computations. llvm-svn: 35294
* For PR1205:Reid Spencer2007-03-231-762/+37
| | | | | | | | | | | | * APIntify visitAdd and visitSelectInst * Remove unused uint64_t versions of utility functions that have been replaced with APInt versions. This completes most of the changes for APIntification of InstCombine. This passes llvm-test and llvm/test/Transforms/InstCombine/APInt. Patch by Zhou Sheng. llvm-svn: 35287
* For PR1205:Reid Spencer2007-03-231-25/+22
| | | | | | | | APIntify visitDiv, visitMul and visitRem. Patch by Zhou Sheng. llvm-svn: 35283
* switch AddReachableCodeToWorklist from being recursive to being iterative.Chris Lattner2007-03-231-46/+54
| | | | llvm-svn: 35282
* For PR1205:Reid Spencer2007-03-231-37/+39
| | | | | | | | | APIntify several utility functions supporting logical operators and shift operators. Patch by Zhou Sheng. llvm-svn: 35281
* Make the "KnownZero ^ TypeMask" computation just once.Zhou Sheng2007-03-231-3/+4
| | | | llvm-svn: 35276
* Simplify the code.Zhou Sheng2007-03-231-1/+1
| | | | llvm-svn: 35275
* For PR1205:Reid Spencer2007-03-221-21/+25
| | | | | | | | APInt support for logical operators in visitAnd, visitOr, and visitXor. Patch by Zhou Sheng. llvm-svn: 35273
* For PR1205:Reid Spencer2007-03-221-16/+17
| | | | | | | | | | * APIntify commonIntCastTransforms * APIntify visitTrunc * APIntify visitZExt Patch by Zhou Sheng. llvm-svn: 35271
* For PR1205:Reid Spencer2007-03-221-63/+63
| | | | | | | | * Re-enable the APInt version of MaskedValueIsZero. * APIntify the Comput{Un}SignedMinMaxValuesFromKnownBits functions * APIntify visitICmpInst. llvm-svn: 35270
* Change uses of Function::front to Function::getEntryBlock for readability.Dan Gohman2007-03-221-1/+2
| | | | llvm-svn: 35265
* For PR1248:Reid Spencer2007-03-211-18/+26
| | | | | | | | | | | | * Fix some indentation and comments in InsertRangeTest * Add an "IsSigned" parameter to AddWithOverflow and make it handle signed additions. Also, APIntify this function so it works with any bitwidth. * For the icmp pred ([us]div %X, C1), C2 transforms, exit early if the div instruction's RHS is zero. * Finally, for icmp pred (sdiv %X, C1), -C2, fix an off-by-one error. The HiBound needs to be incremented in order to get the range test correct. llvm-svn: 35247
* Simplify isHighOnes().Zhou Sheng2007-03-201-9/+1
| | | | llvm-svn: 35211
* Make isOneBitSet faster by using APInt::isPowerOf2. Thanks Chris.Reid Spencer2007-03-201-1/+1
| | | | llvm-svn: 35194
* APIntify the isHighOnes utility function.Reid Spencer2007-03-191-5/+6
| | | | llvm-svn: 35190
* Implement isMaxValueMinusOne in terms of APInt instead of uint64_t.Reid Spencer2007-03-191-5/+4
| | | | | | Patch by Sheng Zhou. llvm-svn: 35188
* Implement isMinValuePlusOne using facilities of APInt instead of uint64_tReid Spencer2007-03-191-5/+4
| | | | | | Patch by Zhou Sheng. llvm-svn: 35187
* Implement isOneBitSet in terms of APInt::countPopulation.Reid Spencer2007-03-191-2/+1
| | | | llvm-svn: 35186
* 1. Use APInt::getSignBit to reduce clutter (patch by Sheng Zhou)Reid Spencer2007-03-191-8/+4
| | | | | | 2. Replace uses of the "isPositive" utility function with APInt::isPositive llvm-svn: 35185
* Remove a redundant clause in an if statement.Reid Spencer2007-03-191-1/+0
| | | | | | Patch by Sheng Zhou. llvm-svn: 35184
* Implement InstCombine/and-xor-merge.ll:test[12].Chris Lattner2007-03-181-54/+96
| | | | | | Rearrange some code to simplify it now that shifts are binops llvm-svn: 35145
* ShiftAmt might equal to zero. Handle this situation.Zhou Sheng2007-03-141-7/+9
| | | | llvm-svn: 35094
* Enable KnownZero/One.clear().Zhou Sheng2007-03-141-2/+2
| | | | llvm-svn: 35093
* ifdef out some dead code.Chris Lattner2007-03-131-2/+8
| | | | | | Fix PR1244 and Transforms/InstCombine/2007-03-13-CompareMerge.ll llvm-svn: 35082
* For expression likeZhou Sheng2007-03-131-3/+3
| | | | | | | | "APInt::getAllOnesValue(ShiftAmt).zextOrCopy(BitWidth)", to handle ShiftAmt == BitWidth situation, use zextOrCopy() instead of zext(). llvm-svn: 35080
* In APInt version ComputeMaskedBits():Zhou Sheng2007-03-131-15/+28
| | | | | | | 1. Ensure VTy, KnownOne and KnownZero have same bitwidth. 2. Make code more efficient. llvm-svn: 35078
* Add an APInt version of SimplifyDemandedBits.Reid Spencer2007-03-121-1/+524
| | | | | | Patch by Zhou Sheng. llvm-svn: 35064
* Add an APInt version of ShrinkDemandedConstant.Reid Spencer2007-03-121-0/+24
| | | | | | Patch by Zhou Sheng. llvm-svn: 35063
* Avoid to assert on "(KnownZero & KnownOne) == 0".Zhou Sheng2007-03-121-1/+1
| | | | llvm-svn: 35062
* In function ComputeMaskedBits():Zhou Sheng2007-03-121-6/+6
| | | | | | | | 1. Replace getSignedMinValue() with getSignBit() for better code readability. 2. Replace APIntOps::shl() with operator<<= for convenience. 3. Make APInt construction more effective. llvm-svn: 35060
* Fix a bug in function ComputeMaskedBits().Zhou Sheng2007-03-081-2/+2
| | | | llvm-svn: 35027
* Fix a bug in APIntified ComputeMaskedBits().Zhou Sheng2007-03-081-8/+4
| | | | llvm-svn: 35022
* For PR1205:Reid Spencer2007-03-081-0/+10
| | | | | | | | | | Provide an APIntified version of MaskedValueIsZero. This will (temporarily) cause a "defined but not used" message from the compiler. It will be used in the next patch in this series. Patch by Sheng Zhou. llvm-svn: 35019
* For PR1205:Reid Spencer2007-03-081-1/+206
| | | | | | | | Add a new ComputeMaskedBits function that is APIntified. We'll slowly convert things over to use this version. When its all done, we'll remove the existing version. llvm-svn: 35018
* Remove an unnecessary if statement and adjust indentation.Reid Spencer2007-03-051-23/+21
| | | | llvm-svn: 34939
* fix a subtle bug that caused an MSVC warning. Thanks to Jeffc for pointing ↵Chris Lattner2007-03-051-2/+3
| | | | | | this out. llvm-svn: 34920
* Add some simplifications for demanded bits, this allows instcombine to turn:Chris Lattner2007-03-051-0/+31
| | | | | | | | | | | | | | | | | | | | | define i64 @test(i64 %A, i32 %B) { %tmp12 = zext i32 %B to i64 ; <i64> [#uses=1] %tmp3 = shl i64 %tmp12, 32 ; <i64> [#uses=1] %tmp5 = add i64 %tmp3, %A ; <i64> [#uses=1] %tmp6 = and i64 %tmp5, 123 ; <i64> [#uses=1] ret i64 %tmp6 } into: define i64 @test(i64 %A, i32 %B) { %tmp6 = and i64 %A, 123 ; <i64> [#uses=1] ret i64 %tmp6 } This implements Transforms/InstCombine/add2.ll:test1 llvm-svn: 34919
* Unbreak VC++ build.Jeff Cohen2007-03-051-0/+1
| | | | llvm-svn: 34917
* simplify some codeChris Lattner2007-03-041-18/+17
| | | | llvm-svn: 34914
* Speed up -instcombine by 20% by avoiding a particularly expensive passmgr call.Chris Lattner2007-03-041-1/+4
| | | | llvm-svn: 34902
OpenPOWER on IntegriCloud