Zhou Sheng
7cf2811ab3
For expression like
...
"APInt::getAllOnesValue(ShiftAmt).zextOrCopy(BitWidth)",
to handle ShiftAmt == BitWidth situation, use zextOrCopy() instead of
zext().
llvm-svn: 35080
2007-03-13 06:40:59 +00:00
Zhou Sheng
14cef9ec74
In APInt version ComputeMaskedBits():
...
1. Ensure VTy, KnownOne and KnownZero have same bitwidth.
2. Make code more efficient.
llvm-svn: 35078
2007-03-13 02:23:10 +00:00
Evan Cheng
1fcdd7e1e5
Use new TargetLowering addressing modes hooks.
...
llvm-svn: 35072
2007-03-12 23:27:37 +00:00
Reid Spencer
d59425085f
Add an APInt version of SimplifyDemandedBits.
...
Patch by Zhou Sheng.
llvm-svn: 35064
2007-03-12 17:25:59 +00:00
Reid Spencer
b18f916bbe
Add an APInt version of ShrinkDemandedConstant.
...
Patch by Zhou Sheng.
llvm-svn: 35063
2007-03-12 17:15:10 +00:00
Zhou Sheng
c8583ff888
Avoid to assert on "(KnownZero & KnownOne) == 0".
...
llvm-svn: 35062
2007-03-12 16:54:56 +00:00
Zhou Sheng
c9c53385b8
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.
llvm-svn: 35060
2007-03-12 05:44:52 +00:00
Nick Lewycky
8a08bcfbe7
Add value ranges. Currently inefficient in both execution time and
...
optimization power.
llvm-svn: 35058
2007-03-10 18:12:48 +00:00
Devang Patel
ca60446cb4
Increment iterator now because IVUseShouldUsePostIncValue may remove
...
User from the list of I users.
llvm-svn: 35051
2007-03-09 21:19:53 +00:00
Zhou Sheng
acc59870f7
Fix a bug in function ComputeMaskedBits().
...
llvm-svn: 35027
2007-03-08 15:15:18 +00:00
Chris Lattner
66843dbef9
This appears correct, enable it so we can see perf changes on testers
...
llvm-svn: 35024
2007-03-08 07:03:55 +00:00
Chris Lattner
049f21257d
Second half of PR1226. This is currently still disabled, until I have a chance to
...
do the correctness/performance analysis testing.
llvm-svn: 35023
2007-03-08 06:36:54 +00:00
Zhou Sheng
37cb2e2d53
Fix a bug in APIntified ComputeMaskedBits().
...
llvm-svn: 35022
2007-03-08 05:42:00 +00:00
Reid Spencer
c3f0724204
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.
llvm-svn: 35019
2007-03-08 01:52:58 +00:00
Reid Spencer
6a924d1a1d
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.
llvm-svn: 35018
2007-03-08 01:46:38 +00:00
Devang Patel
6a56e3c1a0
Now IndVarSimplify is a LoopPass.
...
llvm-svn: 35003
2007-03-07 06:39:01 +00:00
Devang Patel
16107bb71b
Now LICM is a LoopPass.
...
llvm-svn: 35001
2007-03-07 04:41:30 +00:00
Devang Patel
3a24891f80
Now LoopUnroll is a LoopPass.
...
llvm-svn: 34996
2007-03-07 01:38:05 +00:00
Devang Patel
c35610b9f9
Now LoopUnswitch is a LoopPass.
...
llvm-svn: 34992
2007-03-07 00:26:10 +00:00
Devang Patel
0b82378a28
Now LoopStrengthReduce is a LoopPass.
...
llvm-svn: 34984
2007-03-06 21:14:09 +00:00
Reid Spencer
db1c09aef1
Remove an unnecessary if statement and adjust indentation.
...
llvm-svn: 34939
2007-03-05 23:36:13 +00:00
Chris Lattner
b0de2b2a9c
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 &&".
llvm-svn: 34924
2007-03-05 07:52:57 +00:00
Chris Lattner
4dfdbab24b
fix a subtle bug that caused an MSVC warning. Thanks to Jeffc for pointing this out.
...
llvm-svn: 34920
2007-03-05 00:11:19 +00:00
Chris Lattner
4fadd9defa
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
llvm-svn: 34919
2007-03-05 00:02:29 +00:00
Jeff Cohen
98c99a3a02
Unbreak VC++ build.
...
llvm-svn: 34917
2007-03-05 00:00:42 +00:00
Chris Lattner
0036009167
simplify some code
...
llvm-svn: 34914
2007-03-04 23:16:36 +00:00
Chris Lattner
758a83d1b0
minor cleanups
...
llvm-svn: 34904
2007-03-04 04:50:21 +00:00
Chris Lattner
de2b4322ff
Speed up -instcombine by 20% by avoiding a particularly expensive passmgr call.
...
llvm-svn: 34902
2007-03-04 04:27:24 +00:00
Chris Lattner
f2304552f7
switch MarkAliveBlocks over to using SmallPtrSet instead of std::set, speeding
...
up simplifycfg by 20%
llvm-svn: 34901
2007-03-04 04:20:48 +00:00
Chris Lattner
4d48389d2d
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.
llvm-svn: 34898
2007-03-04 03:43:23 +00:00
Chris Lattner
519ed087bb
Implement PR1179/PR1232 and test/Transforms/IndVarsSimplify/loop_evaluate_[234].ll
...
This makes -indvars require and use LCSSA, updating it as appropriate.
llvm-svn: 34896
2007-03-04 01:00:28 +00:00
Chris Lattner
f45fa39069
Make RewriteLoopExitValues far less nested by using continue in the loop
...
llvm-svn: 34891
2007-03-03 22:48:48 +00:00
Chris Lattner
f22da20af4
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.
llvm-svn: 34870
2007-03-03 05:27:34 +00:00
Nick Lewycky
a0a23a645d
Translate bit operations to English.
...
llvm-svn: 34868
2007-03-03 03:14:40 +00:00
Chris Lattner
892090ea95
add a top-level iteration loop to instcombine. This means that it will never
...
finish without combining something it is capable of.
llvm-svn: 34865
2007-03-03 02:04:50 +00:00
Reid Spencer
8c49eb7da5
APIntify this pass.
...
llvm-svn: 34863
2007-03-03 00:48:31 +00:00
Reid Spencer
6f7b9afc1c
Finally get this patch right :)
...
Replace expensive getZExtValue() == 0 calls with isZero() calls.
llvm-svn: 34861
2007-03-02 23:51:25 +00:00
Reid Spencer
438d17b5ad
Dang, I've done that twice now! Undo previous commit.
...
llvm-svn: 34860
2007-03-02 23:37:53 +00:00
Reid Spencer
70fbfc75e8
Use more efficient test for one value in a ConstantInt.
...
llvm-svn: 34859
2007-03-02 23:35:28 +00:00
Reid Spencer
76f02c5848
Guard against huge loop trip counts in an APInt safe way.
...
llvm-svn: 34858
2007-03-02 23:31:34 +00:00
Chris Lattner
e11cd0460a
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.
llvm-svn: 34848
2007-03-02 21:28:56 +00:00
Chris Lattner
fb4d1a6437
minor cleanup
...
llvm-svn: 34846
2007-03-02 19:59:19 +00:00
Reid Spencer
2814c17704
Reverse a premature commital.
...
llvm-svn: 34822
2007-03-02 00:31:39 +00:00
Reid Spencer
1f970769e8
Prefer non-virtual calls to ConstantInt::isZero over virtual calls to
...
Constant::isNullValue() in situations where it is possible.
llvm-svn: 34821
2007-03-02 00:28:52 +00:00
Reid Spencer
e5456dea52
Although probably not necessary, guard against a potential assertion by
...
using isNullValue() instead of getZExtValue() == 0.
llvm-svn: 34815
2007-03-01 21:54:37 +00:00
Reid Spencer
3a7689fe22
Use isUnitValue() instead of getZExtValue() == 1 which will prevent an
...
assert if the ConstantInt's value is large.
llvm-svn: 34814
2007-03-01 21:51:23 +00:00
Reid Spencer
30eac3e0b1
The 64-bit constructor for ConstantInt changes from int64_t to uint64_t.
...
This caused a warning for construction with -1. Avoid the warning by using
-1ULL instead.
llvm-svn: 34796
2007-03-01 19:33:52 +00:00
Reid Spencer
3f3487918c
Remove the "isSigned" parameters from ConstantRange. It turns out they
...
are not needed as the results are the same with or without it.
Patch by Nicholas Lewycky.
llvm-svn: 34782
2007-03-01 07:54:15 +00:00
Reid Spencer
19e5279a38
For PR1205:
...
Adjust to changes in ConstantRange interface.
llvm-svn: 34762
2007-02-28 22:03:51 +00:00
Reid Spencer
965067a054
For PR1205:
...
Remove ConstantInt from ConstantRange interface and adjust its users to
compensate.
llvm-svn: 34758
2007-02-28 19:57:34 +00:00