Jim Laskey
930ac0606c
Can't combine anymore - we don't have a chain through llvm.dbg intrinsics.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26992 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-23 18:10:42 +00:00
Chris Lattner
035c6a2356
silence a bogus gcc warning
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26953 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-22 17:27:24 +00:00
Chris Lattner
273f202890
Teach cee to propagate through switch statements. This implements
...
Transforms/CorrelatedExprs/switch.ll
Patch contributed by Eric Kidd!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26872 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-19 19:37:24 +00:00
Evan Cheng
21495775e7
- Fixed a bogus if condition.
...
- Added more debugging info.
- Allow reuse of IV of negative stride. e.g. -4 stride == 2 * iv of -2 stride.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26841 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-18 08:03:12 +00:00
Evan Cheng
4496a50deb
Sort StrideOrder so we can process the smallest strides first. This allows
...
for more IV reuses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26837 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-18 00:44:49 +00:00
Evan Cheng
eb8f9e2297
Allow users of iv / stride to be rewritten with expression that is a multiply
...
of a smaller stride even if they have a common loop invariant expression part.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26828 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-17 19:52:23 +00:00
Evan Cheng
d1d6b5cce2
For each loop, keep track of all the IV expressions inserted indexed by
...
stride. For a set of uses of the IV of a stride which is a multiple
of another stride, do not insert a new IV expression. Rather, reuse the
previous IV and rewrite the uses as uses of IV expression multiplied by
the factor.
e.g.
x = 0 ...; x ++
y = 0 ...; y += 4
then use of y can be rewritten as use of 4*x for x86.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26803 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-16 21:53:05 +00:00
Chris Lattner
e9efecbf47
Implement a FIXME, recusively reassociating
...
A*A*B + A*A*C --> A*(A*B+A*C) --> A*(A*(B+C))
This implements Reassociate/mul-factor3.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26757 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-14 16:04:29 +00:00
Chris Lattner
895b392269
extract some code into a method, no functionality change
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26755 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-14 07:11:11 +00:00
Chris Lattner
22a66c41f3
Promote shifts by a constant to multiplies so that we can reassociate
...
(x<<1)+(y<<1) -> (X+Y)<<1. This implements
Transforms/Reassociate/shift-factor.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26753 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-14 06:55:18 +00:00
Evan Cheng
d277f2c669
Added target lowering hooks which LSR consults to make more intelligent
...
transformation decisions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26738 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-13 23:14:23 +00:00
Chris Lattner
25de486263
Fix a miscompilation of 188.ammp with the new CFE. 188.ammp is accessing
...
arrays out of range in a horrible way, but we shouldn't break it anyway.
Details in the comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26606 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-08 01:05:29 +00:00
Chris Lattner
51c26e911a
Teach the alignment handling code to look through constant expr casts and GEPs
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26580 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-07 01:28:57 +00:00
Chris Lattner
95a959dc1a
Teach instcombine to increase the alignment of memset/memcpy/memmove when
...
the pointer is known to come from either a global variable, alloca or
malloc. This allows us to compile this:
P = malloc(28);
memset(P, 0, 28);
into explicit stores on PPC instead of a memset call.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26577 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-06 20:18:44 +00:00
Chris Lattner
220b0cf3e4
Make vector narrowing more effective, implementing
...
Transforms/InstCombine/vec_narrow.ll. This add support for narrowing
extract_element(insertelement) also.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26538 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-05 00:22:33 +00:00
Chris Lattner
e5022fe4cd
Add factoring of multiplications, e.g. turning A*A+A*B into A*(A+B).
...
Testcase here: Transforms/Reassociate/mulfactor.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26524 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-04 09:31:13 +00:00
Chris Lattner
ab51f3fa96
Canonicalize (X+C1)*C2 -> X*C2+C1*C2
...
This implements Transforms/InstCombine/add.ll:test31
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26519 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-04 06:04:02 +00:00
Chris Lattner
21959390c1
Change this to work with renamed intrinsics.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26484 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-03 01:34:17 +00:00
Chris Lattner
db3f873bd8
Generalize the REM folding code to handle another case Nick Lewycky
...
pointed out: realize the AND can provide factors and look through Casts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26469 91177308-0d34-0410-b5e6-96231b3b80d8
2006-03-02 06:50:58 +00:00
Chris Lattner
06e1e25368
Fix a regression in a patch from a couple of days ago. This fixes
...
Transforms/InstCombine/2006-02-28-Crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26427 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-28 19:47:20 +00:00
Chris Lattner
9794392781
Implement rem.ll:test[7-9] and PR712
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26415 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-28 05:49:21 +00:00
Chris Lattner
6c9951b0da
Simplify some code now that the RHS of a rem can't be 0
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26413 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-28 05:40:55 +00:00
Chris Lattner
19ccd5c757
Rearrange some code, fold "rem X, 0", implementing rem.ll:test6
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26411 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-28 05:30:45 +00:00
Chris Lattner
3e88a4d700
Merge two almost-identical pieces of code.
...
Make this code more powerful by using ComputeMaskedBits instead of looking
for an AND operand. This lets us fold this:
int %test23(int %a) {
%tmp.1 = and int %a, 1
%tmp.2 = seteq int %tmp.1, 0
%tmp.3 = cast bool %tmp.2 to int ;; xor tmp1, 1
ret int %tmp.3
}
into: xor (and a, 1), 1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26396 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-27 02:38:23 +00:00
Chris Lattner
26ab9a9218
Fold (A^B) == A -> B == 0
...
and (A-B) == A -> B == 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26394 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-27 01:44:11 +00:00
Chris Lattner
02bd1b3e94
Fold (X|C1)^C2 -> X^(C1|C2) when possible. This implements
...
InstCombine/or.ll:test23.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26385 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-26 19:57:54 +00:00
Chris Lattner
97f37a439c
Fix a problem that Nate noticed that boils down to an over conservative check
...
in the code that does "select C, (X+Y), (X-Y) --> (X+(select C, Y, (-Y)))".
We now compile this loop:
LBB1_1: ; no_exit
add r6, r2, r3
subf r3, r2, r3
cmpwi cr0, r2, 0
addi r7, r5, 4
lwz r2, 0(r5)
addi r4, r4, 1
blt cr0, LBB1_4 ; no_exit
LBB1_3: ; no_exit
mr r3, r6
LBB1_4: ; no_exit
cmpwi cr0, r4, 16
mr r5, r7
bne cr0, LBB1_1 ; no_exit
into this instead:
LBB1_1: ; no_exit
srawi r6, r2, 31
add r2, r2, r6
xor r6, r2, r6
addi r7, r5, 4
lwz r2, 0(r5)
addi r4, r4, 1
add r3, r3, r6
cmpwi cr0, r4, 16
mr r5, r7
bne cr0, LBB1_1 ; no_exit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26356 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-24 18:05:58 +00:00
Chris Lattner
f8bf116f80
Fix Regression/Transforms/LoopUnswitch/2006-02-22-UnswitchCrash.ll, which
...
caused SPASS to fail building last night.
We can't trivially unswitch a loop if the exit block has phi nodes in it,
because we don't know which predecessor to use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26320 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-22 23:55:00 +00:00
Chris Lattner
bd28e3f8ef
Add some comments, simplify some code, and fix a bug that caused rewriting
...
to rewrite with the wrong value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26311 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-22 06:37:14 +00:00
Chris Lattner
a6fc94b71e
improved support for branch folding, still not enabled.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26289 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-18 07:57:38 +00:00
Jeff Cohen
bce4805d6f
Fix bugs identified by VC++.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26287 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-18 03:20:33 +00:00
Chris Lattner
db41024a85
Implement deletion of dead blocks, currently disabled.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26285 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-18 02:42:34 +00:00
Chris Lattner
caf4893536
a previous patch completely disabled trivial unswitching, this fixees it.
...
Thanks to nate for pointing this out :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26280 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-18 01:32:04 +00:00
Chris Lattner
f4412d890d
initial trivial support for folding branches that have now-constant destinations.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26279 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-18 01:27:45 +00:00
Chris Lattner
25cae0fd1c
When unswitching a loop, make sure to update loop info with exit blocks in
...
the right loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26277 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-18 00:55:32 +00:00
Chris Lattner
0017d480cc
Fix loops where the header has an exit, fixing a loop-unswitch crash on crafty
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26258 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-17 06:39:56 +00:00
Chris Lattner
52221f7b16
start of some new simplification code, not thoroughly tested, use at your own
...
risk :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26248 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-17 00:31:07 +00:00
Nate Begeman
368e18d56a
Rework the SelectionDAG-based implementations of SimplifyDemandedBits
...
and ComputeMaskedBits to match the new improved versions in instcombine.
Tested against all of multisource/benchmarks on ppc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26238 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-16 21:11:51 +00:00
Chris Lattner
10cd9bbde7
Change SplitBlock to increment a BasicBlock::iterator, not an Instruction*. Apparently they do different things :)
...
This fixes a testcase that nate reduced from spass.
Also included are a couple minor code changes that don't affect the generated
code at all.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26235 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-16 19:36:22 +00:00
Jeff Cohen
21c107ab0f
Fix VC++ warning.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26228 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-16 04:07:37 +00:00
Chris Lattner
f17c42d409
fix a bug where we unswitched the wrong way
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26225 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-16 01:24:41 +00:00
Chris Lattner
a48654ef23
Implement trivial unswitching for switch stmts. This allows us to trivial
...
unswitch this loop on 2 before sweating to unswitch on 1/3.
void test4(int N, int i, int C, int*P, int*Q) {
int j;
for (j = 0; j < N; ++j) {
switch (C) { // general unswitching.
default: P[i+j] = 0; break;
case 1: Q[i+j] = 0; break;
case 3: P[i+j] = Q[i+j]; break;
case 2: break; // TRIVIAL UNSWITCH on C==2
}
}
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26223 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-15 22:52:05 +00:00
Chris Lattner
4e1323969c
make "trivial" unswitching significantly more general. It can now handle
...
this for example:
for (j = 0; j < N; ++j) { // trivial unswitch
if (C)
P[i+j] = 0;
}
turning it into the obvious code without bothering to duplicate an empty loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26220 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-15 22:03:36 +00:00
Chris Lattner
3fdde110eb
Checking the wrong value. This caused us to emit silly code like
...
Y = seteq bool X, true
instead of just using X :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26215 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-15 19:05:52 +00:00
Chris Lattner
6d9d13d2e4
more refactoring, no functionality change.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26194 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-15 01:44:42 +00:00
Chris Lattner
fed5d9dbd3
pull some code out into a function
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26191 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-15 00:07:43 +00:00
Chris Lattner
3dd4c402de
Use statistics to keep track of what flavors of loops we are unswitching
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26157 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-14 01:01:41 +00:00
Chris Lattner
2082ad9b41
Implement Instcombine/and.ll:test34
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26155 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-13 23:07:23 +00:00
Chris Lattner
f345fe4d9a
If any of the sign extended bits are demanded, the input sign bit is demanded
...
for a sign extension.
This fixes InstCombine/2006-02-13-DemandedMiscompile.ll and Ptrdist/bc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26152 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-13 22:41:07 +00:00
Chris Lattner
c15637bafc
Be careful not to request or look at bits shifted in from outside the size
...
of the input. This fixes the mediabench/gsm/toast failure last night.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26138 91177308-0d34-0410-b5e6-96231b3b80d8
2006-02-13 06:09:08 +00:00