Commit Graph

1530 Commits

Author SHA1 Message Date
Reid Spencer
1be1284fe6 For PR1271:
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35348 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 05:25:00 +00:00
Dale Johannesen
da91f49751 Look through bitcast when finding IVs. (Chris' patch really.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35347 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 03:01:27 +00:00
Reid Spencer
55702aaa52 For PR1271:
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35342 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-25 21:11:44 +00:00
Chris Lattner
db9654e284 implement Transforms/InstCombine/cast2.ll:test3 and PR1263
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35341 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-25 20:43:09 +00:00
Reid Spencer
2149a9dfec Some cleanup from review:
* 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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35339 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-25 19:55:33 +00:00
Reid Spencer
7177c3a60a Refactor several ConstantExpr::getXXX calls with ConstantInt arguments
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35335 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-25 05:33:51 +00:00
Zhou Sheng
0fc5095d0e 1. Avoid unnecessary APInt construction if possible.
2. Use isStrictlyPositive() instead of isPositive() in two places where
   they need APInt value > 0 not only >=0.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35333 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-25 05:01:29 +00:00
Reid Spencer
2f5491791b Make more uses of getHighBitsSet and get rid of some pointless & of an
APInt with its type mask.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35325 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-25 04:26:16 +00:00
Reid Spencer
2b81207b4b More APIntification:
* 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35321 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-25 02:03:12 +00:00
Chris Lattner
42593e69e2 fix a regression on vector or instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35314 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-24 23:56:43 +00:00
Zhou Sheng
00f436c5bc Make some codes more efficient.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35297 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-24 15:34:37 +00:00
Reid Spencer
f244252740 For PR1205:
Convert some calls to ConstantInt::getZExtValue() into getValue() and
use APInt facilities in the subsequent computations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35294 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-24 00:42:08 +00:00
Reid Spencer
2ec619a29a For PR1205:
* 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35287 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-23 21:24:59 +00:00
Reid Spencer
bca0e38baa For PR1205:
APIntify visitDiv, visitMul and visitRem.

Patch by Zhou Sheng.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35283 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-23 20:05:17 +00:00
Chris Lattner
2c7718a539 switch AddReachableCodeToWorklist from being recursive to being iterative.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35282 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-23 19:17:18 +00:00
Reid Spencer
b35ae0371a For PR1205:
APIntify several utility functions supporting logical operators and shift
operators.

Patch by Zhou Sheng.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35281 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-23 18:46:34 +00:00
Zhou Sheng
f62cc9f9e5 Make the "KnownZero ^ TypeMask" computation just once.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35276 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-23 03:13:21 +00:00
Zhou Sheng
9c636fe6f2 Simplify the code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35275 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-23 02:39:25 +00:00
Reid Spencer
a03d45fa88 For PR1205:
APInt support for logical operators in visitAnd, visitOr, and visitXor.

Patch by Zhou Sheng.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35273 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-22 22:19:58 +00:00
Reid Spencer
ad6676e81b For PR1205:
* APIntify commonIntCastTransforms
* APIntify visitTrunc
* APIntify visitZExt

Patch by Zhou Sheng.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35271 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-22 20:56:53 +00:00
Reid Spencer
0460fb3ea5 For PR1205:
* Re-enable the APInt version of MaskedValueIsZero.
* APIntify the Comput{Un}SignedMinMaxValuesFromKnownBits functions
* APIntify visitICmpInst.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35270 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-22 20:36:03 +00:00
Dan Gohman
ecb7a77885 Change uses of Function::front to Function::getEntryBlock for readability.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35265 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-22 16:38:57 +00:00
Nick Lewycky
27e4da93b6 Fix broken optimization disabled by a logic bug.
Analyze GEPs. If the indices are all zero, transfer whether the pointer is
known to be not null through the GEP.

Add a few more cases for xor and shift instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35257 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-22 02:02:51 +00:00
Reid Spencer
e4e4003032 For PR1248:
* 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35247 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-21 23:19:50 +00:00
Dale Johannesen
8e59e163db do not share old induction variables when this would result in invalid
instructions (that would have to be split later)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35227 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-20 21:54:54 +00:00
Jeff Cohen
c01a53007a Fix some VC++ warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35224 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-20 20:43:18 +00:00
Zhou Sheng
2cde46cb66 Simplify isHighOnes().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35211 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-20 12:49:06 +00:00
Dale Johannesen
dc42f48ea9 use types of loads and stores, not address, in CheckForIVReuse
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35197 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-20 00:47:50 +00:00
Reid Spencer
5f6a89562d Make isOneBitSet faster by using APInt::isPowerOf2. Thanks Chris.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35194 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-20 00:16:52 +00:00
Reid Spencer
05227d88af APIntify the isHighOnes utility function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35190 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 21:29:50 +00:00
Reid Spencer
3a2a9fbf99 Implement isMaxValueMinusOne in terms of APInt instead of uint64_t.
Patch by Sheng Zhou.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35188 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 21:10:28 +00:00
Reid Spencer
727992c30a Implement isMinValuePlusOne using facilities of APInt instead of uint64_t
Patch by Zhou Sheng.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35187 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 21:08:07 +00:00
Reid Spencer
44e33e674a Implement isOneBitSet in terms of APInt::countPopulation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35186 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 21:04:43 +00:00
Reid Spencer
5a1e3e1a7d 1. Use APInt::getSignBit to reduce clutter (patch by Sheng Zhou)
2. Replace uses of the "isPositive" utility function with APInt::isPositive


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35185 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 20:58:18 +00:00
Reid Spencer
8439bc8d69 Remove a redundant clause in an if statement.
Patch by Sheng Zhou.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35184 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 20:47:50 +00:00
Chris Lattner
a9d1a843fc fix ScalarRepl/2007-03-19-CanonicalizeMemcpy.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35169 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 18:25:57 +00:00
Chris Lattner
8bf9911932 implement the next chunk of SROA with memset/memcpy's of aggregates. This
implements Transforms/ScalarRepl/memset-aggregate-byte-leader.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35150 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-19 00:16:43 +00:00
Nick Lewycky
3f64b1ab1d Clean up this code and fix subtract miscompile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35146 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-18 22:58:46 +00:00
Chris Lattner
318bf7963a Implement InstCombine/and-xor-merge.ll:test[12].
Rearrange some code to simplify it now that shifts are binops


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35145 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-18 22:51:34 +00:00
Nick Lewycky
1eda0f60d7 Propagate ValueRanges across equality.
Add some more micro-optimizations: x * 0 = 0, a - x = a --> x = 0.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35138 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-18 01:09:32 +00:00
Anton Korobeynikov
1cc6452181 Silence warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35137 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-17 14:48:06 +00:00
Nick Lewycky
4c70875774 Add more comments and update to new asm syntax.
Add new micro-optimizations.

Add icmp predicate snuggling. Given %x ULT 4, "icmp ugt %x, 2" becomes
"icmp eq %x, 3". This doesn't apply in any non-trivial cases yet due to missing
support for NE values in ValueRanges.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35119 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-16 02:37:39 +00:00
Zhou Sheng
adc149549d ShiftAmt might equal to zero. Handle this situation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35094 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-14 09:07:33 +00:00
Zhou Sheng
9670445cd4 Enable KnownZero/One.clear().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35093 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-14 03:21:24 +00:00
Evan Cheng
1d95816db5 Correct type info for isLegalAddressImmediate() check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35086 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-13 20:34:37 +00:00
Chris Lattner
bc1dbfce62 ifdef out some dead code.
Fix PR1244 and Transforms/InstCombine/2007-03-13-CompareMerge.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35082 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-13 14:27:42 +00:00
Zhou Sheng
b277b16593 For expression like
"APInt::getAllOnesValue(ShiftAmt).zextOrCopy(BitWidth)",
to handle ShiftAmt == BitWidth situation, use zextOrCopy() instead of
zext().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35080 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-13 06:40:59 +00:00
Zhou Sheng
771dbf7677 In APInt version ComputeMaskedBits():
1. Ensure VTy, KnownOne and KnownZero have same bitwidth.
  2. Make code more efficient.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35078 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-13 02:23:10 +00:00
Evan Cheng
5eef2d21a0 Use new TargetLowering addressing modes hooks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35072 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-12 23:27:37 +00:00
Reid Spencer
8cb6834ccf Add an APInt version of SimplifyDemandedBits.
Patch by Zhou Sheng.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35064 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-12 17:25:59 +00:00