Commit Graph

733 Commits

Author SHA1 Message Date
Chris Lattner
c5e7ea49eb Generalize the code that handles (A&B)|(A&C) to work where B/C are not constants.
Add a new xform to simplify (A&B)|(~A&C).  THis implements InstCombine/or2.ll:test1


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35760 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-08 07:47:01 +00:00
Chris Lattner
4802d90ca8 implement Transforms/InstCombine/malloc2.ll and PR1313
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35700 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-06 18:57:34 +00:00
Dale Johannesen
16ff304e2c Prevent transformConstExprCastCall from generating conversions that assert
elsewhere.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35668 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04 19:16:42 +00:00
Jeff Cohen
86796bec50 Fix 2007-04-04-BadFoldBitcastIntoMalloc.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35665 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04 16:58:57 +00:00
Duncan Sands
0091bf2439 Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35655 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04 06:42:45 +00:00
Chris Lattner
7305084156 Fix a bug I introduced with my patch yesterday which broke Qt (I converted
some constant exprs to apints).

Thanks to Anton for tracking down a small testcase that triggered this!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35633 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 23:29:39 +00:00
Chris Lattner
01deb9d91c reinstate the previous two patches, with a bugfix :)
ldecod now passes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35626 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 17:43:25 +00:00
Evan Cheng
d89f41e9bb Reverting back to 1.723. The last two commits broke JM (and possibily others) on ARM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35620 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 08:11:50 +00:00
Chris Lattner
01d8c107ac Split a whole ton of code out of visitICmpInst into visitICmpInstWithInstAndIntCst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35614 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 04:46:52 +00:00
Chris Lattner
44ad43033e Fix PR1253 and xor2.ll:test[01]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35612 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03 01:47:41 +00:00
Zhou Sheng
4a1822a6d8 1. Make use of APInt operation instead of using ConstantExpr::getXXX.
2. Use cheaper APInt methods.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35594 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 13:45:30 +00:00
Zhou Sheng
4351c649b2 Use uint32_t for bitwidth instead of unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35593 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 08:20:41 +00:00
Chris Lattner
cd1d6d5b03 Wrap long line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35588 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 05:48:58 +00:00
Chris Lattner
acf4e074a9 use more obvious function name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35587 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 05:42:22 +00:00
Chris Lattner
5c6e2db0c4 simplify (x+c)^signbit as (x+c+signbit), pointed out by PR1288. This implements
test/Transforms/InstCombine/xor.ll:test28


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35584 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-02 05:36:22 +00:00
Chris Lattner
55fc8c4c39 simplify this code, make it work for ap ints
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35561 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 20:57:36 +00:00
Zhou Sheng
3a507fda84 Avoid unnecessary APInt construction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35555 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 17:13:37 +00:00
Reid Spencer
e9391fd9b5 For PR1297:
Support overloaded intrinsics bswap, ctpop, cttz, ctlz.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35547 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 07:35:23 +00:00
Chris Lattner
6abbdf90dd Fix InstCombine/2007-03-31-InfiniteLoop.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35536 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-01 05:36:37 +00:00
Zhou Sheng
1c5d163634 Delete dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35525 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-31 02:50:26 +00:00
Zhou Sheng
b9cb95f8e3 Use APInt operators to calculate the carry bits, remove this loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35524 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-31 02:38:39 +00:00
Zhou Sheng
302748dd30 Make sure the use of ConstantInt::getZExtValue() for shift amount safe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35510 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-30 17:20:39 +00:00
Zhou Sheng
0e2d3ac0f8 1. Make sure the use of ConstantInt::getZExtValue() for getting shift
amount is safe.
2. Use new method on ConstantInt instead of (? :) operator.
3. Use new method uge() on ConstantInt to simplify codes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35505 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-30 09:29:48 +00:00
Zhou Sheng
90b9681886 Use APInt operation instead of ConstantExpr::getXX.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35503 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-30 05:45:18 +00:00
Zhou Sheng
290bec5c15 1. Make more use of APInt::getHighBitsSet/getLowBitsSet.
2. Let APInt variable do the binary operation stuff instead of using
   ConstantExpr::getXXX.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35450 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 08:15:12 +00:00
Zhou Sheng
d48653a3ab Clean up some codes in InstCombiner::SimplifyDemandedBits().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35446 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 04:45:55 +00:00
Zhou Sheng
01542f3d80 Clean up codes in InstCombiner::SimplifyDemandedBits():
1. Line out nested call of APInt::zext/trunc.
2. Make more use of APInt::getHighBitsSet/getLowBitsSet.
3. Use APInt[] operator instead of expression like "APIntVal & SignBit".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35444 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 02:26:30 +00:00
Zhou Sheng
97b52c260f 1. Make the APInt variable do the binary operation stuff if possible
instead of using ConstantExpr::getXX.
2. Use constant reference to APInt if possible instead of expensive
   APInt copy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35443 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-29 01:57:21 +00:00
Zhou Sheng
34a4b38cbd Avoid unnecessary APInt construction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35431 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 17:38:21 +00:00
Zhou Sheng
e9e03f6b76 1. Make more use of getLowBitsSet/getHighBitsSet.
2. Use APInt[] instead of "X & SignBit".
3. Clean up some codes.
4. Make the expression like "ShiftAmt = ShiftAmtC->getZExtValue()" safe.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35424 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 15:02:20 +00:00
Zhou Sheng
e82fca09bf 1. Make more use of getLowBitsSet/getHighBitsSet.
2. Make the APInt value do the zext/trunc stuff instead of using
   ConstantExpr::getZExt().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35422 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 09:19:01 +00:00
Zhou Sheng
4acf155af3 Use UnknownBIts[BitWidth-1] instead of UnknownBIts & SignBits.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 05:15:57 +00:00
Zhou Sheng
b32c00603b Remove unused APInt variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35414 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 03:02:21 +00:00
Zhou Sheng
aa305ab5e8 Clean up codes in ComputeMaskedBits():
1. Line out nested use of zext/trunc.
2. Make more use of getHighBitsSet/getLowBitsSet.
3. Use APInt[] != 0 instead of "(APInt & SignBit) != 0".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35408 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 02:19:03 +00:00
Reid Spencer
35c3885ba1 For PR1280:
When converting an add/xor/and triplet into a trunc/sext, only do so if the
intermediate integer type is a bitwidth that the targets can handle.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35400 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-28 01:36:16 +00:00
Evan Cheng
c7baf687ba Unbreaks non-debug builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35383 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-27 16:44:48 +00:00
Reid Spencer
6eb0d99f5f Implement some minor review feedback.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35373 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 23:58:26 +00:00
Reid Spencer
68d27cf84e For PR1271:
Fix another incorrectly converted shift mask.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35371 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 23:45:51 +00:00
Chris Lattner
0e5444bb20 eliminate use of std::set
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35361 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 20:40:50 +00:00
Reid Spencer
a9b8101333 Get better debug output by having modified instructions print both the
original and new instruction. A slight performance hit with ostringstream
but it is only for debug.
Also, clean up an uninitialized variable warning noticed in a release build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35358 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 17:44:01 +00:00
Reid Spencer
d5e30f0a01 Get the number of bits to set in a mask correct for a shl/lshr transform.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35357 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-26 17:18:58 +00:00
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
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