Commit Graph

2918 Commits

Author SHA1 Message Date
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
Jeff Cohen
c4558fde76 Unbreak VC++ build. Do not use identifiers starting with _ as they are reserved and
can collide with system defined names.  Windows defines _BB, for example.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35066 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-12 17:56:27 +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
Reid Spencer
6b79e2d202 Add an APInt version of ShrinkDemandedConstant.
Patch by Zhou Sheng.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35063 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-12 17:15:10 +00:00
Zhou Sheng
edd089c86a Avoid to assert on "(KnownZero & KnownOne) == 0".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35062 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-12 16:54:56 +00:00
Zhou Sheng
430f626937 In function ComputeMaskedBits():
1. Replace getSignedMinValue() with getSignBit() for better code readability.
  2. Replace APIntOps::shl() with operator<<= for convenience.
  3. Make APInt construction more effective.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35060 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-12 05:44:52 +00:00
Nick Lewycky
e677a0b099 Add value ranges. Currently inefficient in both execution time and
optimization power.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35058 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-10 18:12:48 +00:00
Anton Korobeynikov
e2ff29c17c Use range tests in LowerSwitch, where possible
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35057 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-10 16:46:28 +00:00
Devang Patel
f7543fe35a Remove dead comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35053 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-09 23:41:03 +00:00
Devang Patel
a5b7dc5ef8 Avoid recursion. Use iterative algorithm for RenamePass().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35052 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-09 23:39:14 +00:00
Devang Patel
4fe26582c0 Increment iterator now because IVUseShouldUsePostIncValue may remove
User from the list of I users.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35051 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-09 21:19:53 +00:00
Zhou Sheng
a47f60bfaf Fix a bug in function ComputeMaskedBits().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35027 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-08 15:15:18 +00:00
Chris Lattner
97f9df1cd1 This appears correct, enable it so we can see perf changes on testers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35024 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-08 07:03:55 +00:00
Chris Lattner
c14d3cac4b Second half of PR1226. This is currently still disabled, until I have a chance to
do the correctness/performance analysis testing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35023 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-08 06:36:54 +00:00
Zhou Sheng
9a28daa864 Fix a bug in APIntified ComputeMaskedBits().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35022 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-08 05:42:00 +00:00
Reid Spencer
e7816b5c9e For PR1205:
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35019 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-08 01:52:58 +00:00
Reid Spencer
3e7594f187 For PR1205:
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35018 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-08 01:46:38 +00:00
Devang Patel
5ee9997906 Now IndVarSimplify is a LoopPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35003 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-07 06:39:01 +00:00
Devang Patel
54959d6cf6 Now LICM is a LoopPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35001 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-07 04:41:30 +00:00
Devang Patel
3f1a1e0366 Now LoopUnroll is a LoopPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34996 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-07 01:38:05 +00:00
Devang Patel
1bc89361c2 Now LoopUnswitch is a LoopPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34992 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-07 00:26:10 +00:00
Devang Patel
0f54dcbf07 Now LoopStrengthReduce is a LoopPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34984 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-06 21:14:09 +00:00
Reid Spencer
baf1e4b914 Remove an unnecessary if statement and adjust indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34939 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-05 23:36:13 +00:00
Chris Lattner
372dda8881 This is the first major step of implementing PR1226. We now successfully
scalarrepl things down to elements, but mem2reg can't promote elements that
are memset/memcpy'd.  Until then, the code is disabled "0 &&".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34924 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-05 07:52:57 +00:00
Chris Lattner
3c69849696 fix a subtle bug that caused an MSVC warning. Thanks to Jeffc for pointing this out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34920 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-05 00:11:19 +00:00
Chris Lattner
783ccdb5c4 Add some simplifications for demanded bits, this allows instcombine to turn:
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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34919 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-05 00:02:29 +00:00
Jeff Cohen
ca5183d445 Unbreak VC++ build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34917 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-05 00:00:42 +00:00
Chris Lattner
d5fa214729 simplify some code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34914 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-04 23:16:36 +00:00
Chris Lattner
57939df2eb minor cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34904 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-04 04:50:21 +00:00
Chris Lattner
f964f321eb Speed up -instcombine by 20% by avoiding a particularly expensive passmgr call.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34902 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-04 04:27:24 +00:00
Chris Lattner
55091782c1 switch MarkAliveBlocks over to using SmallPtrSet instead of std::set, speeding
up simplifycfg by 20%


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34901 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-04 04:20:48 +00:00
Chris Lattner
9f3d738866 make better use of LCSSA information in RewriteLoopExitValues. Before, we
would scan the entire loop body, then scan all users of instructions in the
loop, looking for users outside the loop.  Now, since we know that the
loop is in LCSSA form, we know that any users outside the loop will be LCSSA
phi nodes.  Just scan them.

This speeds up indvars significantly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34898 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-04 03:43:23 +00:00
Chris Lattner
9caed5440d Implement PR1179/PR1232 and test/Transforms/IndVarsSimplify/loop_evaluate_[234].ll
This makes -indvars require and use LCSSA, updating it as appropriate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34896 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-04 01:00:28 +00:00
Chris Lattner
c9838f25d5 Make RewriteLoopExitValues far less nested by using continue in the loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34891 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-03 22:48:48 +00:00
Chris Lattner
c739cd6d07 my recent change caused a failure in a bswap testcase, because it changed
the order that instcombine processed instructions in the testcase.  The end
result is that instcombine finished with:

define i16 @test1(i16 %a) {
        %tmp = zext i16 %a to i32               ; <i32> [#uses=2]
        %tmp21 = lshr i32 %tmp, 8               ; <i32> [#uses=1]
        %tmp5 = shl i32 %tmp, 8         ; <i32> [#uses=1]
        %tmp.upgrd.32 = or i32 %tmp21, %tmp5            ; <i32> [#uses=1]
        %tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16           ; <i16> [#uses=1]
        ret i16 %tmp.upgrd.3
}

which can't get matched as a bswap.

This patch makes instcombine more sophisticated about removing truncating
casts, allowing it to turn this into:

define i16 @test2(i16 %a) {
        %tmp211 = lshr i16 %a, 8
        %tmp52 = shl i16 %a, 8
        %tmp.upgrd.323 = or i16 %tmp211, %tmp52
        ret i16 %tmp.upgrd.323
}

which then matches as bswap.  This fixes bswap.ll and implements
InstCombine/cast2.ll:test[12].  This also implements cast elimination of
add/sub.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34870 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-03 05:27:34 +00:00
Nick Lewycky
b6431da7be Translate bit operations to English.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34868 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-03 03:14:40 +00:00
Chris Lattner
ec9c35826d add a top-level iteration loop to instcombine. This means that it will never
finish without combining something it is capable of.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34865 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-03 02:04:50 +00:00
Reid Spencer
af3e9468dc APIntify this pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34863 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-03 00:48:31 +00:00
Reid Spencer
bee0f663d8 Finally get this patch right :)
Replace expensive getZExtValue() == 0 calls with isZero() calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34861 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 23:51:25 +00:00
Reid Spencer
502db93a8a Dang, I've done that twice now! Undo previous commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34860 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 23:37:53 +00:00
Reid Spencer
a5dae0cac0 Use more efficient test for one value in a ConstantInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34859 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 23:35:28 +00:00
Reid Spencer
4e69f48a0a Guard against huge loop trip counts in an APInt safe way.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34858 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 23:31:34 +00:00
Reid Spencer
e8391e039e Make sure debug code is not evaluated in non-debug case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34856 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 23:15:21 +00:00
Reid Spencer
f1bed4c720 1. Sort switch cases using APInt safe comparison.
2. Make sure debug output of APInt values is safe for all bit widths.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34855 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 23:05:28 +00:00
Reid Spencer
4cf735b47e Use APInt safe isOne() method on ConstantInt instead of getZExtValue()==1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34854 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 23:03:17 +00:00
Reid Spencer
e1c99d4c69 Make sorting of ConstantInt be APInt clean through use of ult function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34853 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 23:01:14 +00:00
Chris Lattner
dbab386e23 Fix a significant algorithm problem with the instcombine worklist. removing
a value from the worklist required scanning the entire worklist to remove all
entries.  We now use a combination map+vector to prevent duplicates from
happening and prevent the scan.  This speeds up instcombine on a large file
from the llvm-gcc bootstrap from 189.7s to 4.84s in a debug build and from
5.04s to 1.37s in a release build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34848 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-02 21:28:56 +00:00