Chris Lattner
32643d8e05
Constant fold llvm.sqrt
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23487 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-28 01:34:32 +00:00
Chris Lattner
5b3c70263b
add a note about a way to improve this code further, that I won't be getting
...
to right now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23485 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 22:44:59 +00:00
Chris Lattner
9a5582f251
Fix a regression in my previous patch, fixing GlobalOpt/2005-09-27-Crash.ll
...
and PR632.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23484 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 22:28:11 +00:00
Chris Lattner
4531371960
Avoid spilling stack slots... to stack slots.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23478 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 21:33:12 +00:00
Chris Lattner
f4e6c3a69b
Completely rewrite 'correct' eh support. This changes how setjmp insertion
...
is performed so it is only at most once per function that contains an invoke
instead of once per invoke in the function. This patch has the following perks:
1. It fixes PR631, which complains about slowness.
2. If fixes PR240, which complains about non-volatile vars being live across
setjmp/longjmps.
3. It improves (but does not fix) the jmpbuf alignment issue on itanium by not
forcing the jmpbufs to always be 8-bytes off the alignment of the structure.
4. It speeds up 253.perlbmk from 338s to 13.70s (a 25x improvement!), making us
now about 4% faster than GCC.
Further improvements are also possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23477 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 21:18:17 +00:00
Chris Lattner
fe15830f96
Make the pass name simpler
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23476 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 21:10:32 +00:00
Chris Lattner
6d7277b3b4
allow demotion to volatile values, add support for invoke
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23473 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 19:39:00 +00:00
Chris Lattner
a9ec8ab32b
Add support for external calls that we know how to constant fold. This implements
...
ctor-list-opt.ll:CTOR8
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23465 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 05:02:43 +00:00
Chris Lattner
231308c545
Fix a bug where we would evaluate stores into linkonce objects which could be
...
potentially replaced at link-time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23463 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 04:50:03 +00:00
Chris Lattner
cd27142cc8
Implement support for static constructors with calls in them. This is useful
...
because gccas runs globalopt before inlining.
This implements ctor-list-opt.ll:CTOR7
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23462 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 04:45:34 +00:00
Chris Lattner
8a7cc6e71c
Refactor this code a bit, no functionality changes.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23460 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-27 04:27:01 +00:00
Chris Lattner
ff0c1ef9eb
Remove some dead code. ctor evaluation subsumes empty ctor elim
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23453 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 20:38:20 +00:00
Chris Lattner
a22fdb0a37
Add support for alloca, implementing ctor-list-opt.ll:CTOR6
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23452 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 17:07:09 +00:00
Chris Lattner
aae4a1cd3f
Add a debug printout, fix a crash on kc++
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23450 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 07:34:35 +00:00
Chris Lattner
798b4d5bb3
Implement loads/stores through GEP's of globals. This implements
...
ctor-list-opt.ll:CTOR5.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23449 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 06:52:44 +00:00
Chris Lattner
0b142e3920
Replace TraverseGEPInitializer with ConstantFoldLoadThroughGEPConstantExpr
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23447 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 05:34:07 +00:00
Chris Lattner
ebe61201d1
Eliminate GetGEPGlobalInitializer in favor of the more powerful
...
ConstantFoldLoadThroughGEPConstantExpr function in the utils lib.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23446 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 05:28:52 +00:00
Chris Lattner
363f2a26d5
Factor the GetGEPGlobalInitializer out of this pass and into Transforms/Utils
...
as ConstantFoldLoadThroughGEPConstantExpr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23445 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 05:28:06 +00:00
Chris Lattner
c5f52e6da1
Move the ConstantFoldLoadThroughGEPConstantExpr function out of the InstCombine
...
pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23444 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 05:27:10 +00:00
Chris Lattner
562a055ca7
add a comment
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23442 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 05:16:34 +00:00
Chris Lattner
04de1cfb2b
Add support for getelementptr, load, and correctly reject volatile stores.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23441 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 05:15:37 +00:00
Chris Lattner
cdf98bed96
Add support for br/brcond/switch and phi
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23439 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 04:57:38 +00:00
Chris Lattner
79c1101947
Add a simple interpreter to this code, allowing us to statically evaluate
...
global ctors that are simple enough. This implements ctor-list-opt.ll:CTOR2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23437 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 04:44:35 +00:00
Chris Lattner
db973e60ce
factor some code into a InstallGlobalCtors method, add comments. No functionality change.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23435 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 02:31:18 +00:00
Chris Lattner
7d8e58f384
Make the global opt optimizer work on modules with a null terminator, by
...
accepting the null even with a non-65535 init prio
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23434 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 02:19:27 +00:00
Chris Lattner
b1ab458047
Factor this code out into a few methods.
...
Implement the start of global ctor optimization. It is currently smart
enough to remove the global ctor for cases like this:
struct foo {
foo() {}
} x;
... saving a bit of startup time for the program.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23433 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-26 01:43:45 +00:00
Chris Lattner
aebac50e77
Fix some logic I broke that caused a regression on
...
SimplifyLibCalls/2005-05-20-sprintf-crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23430 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-25 07:06:48 +00:00
Chris Lattner
5931c54e85
Move MaskedValueIsZero up.
...
Match a bunch of idioms for sign extensions, implementing InstCombine/signext.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23428 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-24 23:43:33 +00:00
Chris Lattner
5d735bf29b
Simplify this code a bit by relying on recursive simplification. Support
...
sprintf("%s", P)'s that have uses.
s/hasNUses(0)/use_empty()/
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23425 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-24 22:17:06 +00:00
Chris Lattner
b60e0815df
remove some debugging code
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23411 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-23 18:49:09 +00:00
Chris Lattner
263d1e469d
Fold two consequtive branches that share a common destination between them.
...
This implements SimplifyCFG/branch-fold.ll, and is useful on ?:/min/max heavy
code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23410 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-23 18:47:20 +00:00
Chris Lattner
055dc102e9
simplify some logic further
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23408 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-23 07:23:18 +00:00
Chris Lattner
f58c1a578e
pull a bunch of logic out of SimplifyCFG into a helper fn
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23407 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-23 06:39:30 +00:00
Chris Lattner
e9487f0dc8
Start threading across blocks with code in them, so long as the code does
...
not define a value that is used outside of it's block. This catches many
more simplifications, e.g. 854 in 176.gcc, 137 in vpr, etc.
This implements branch-phi-thread.ll:test3.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23397 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-20 01:48:40 +00:00
Chris Lattner
2e42e36698
Implement merging of blocks with the same condition if the block has multiple
...
predecessors. This implements branch-phi-thread.ll::test1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23395 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-20 00:43:16 +00:00
Chris Lattner
9c88d98162
Reject a case we don't handle yet
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23393 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-19 23:57:04 +00:00
Chris Lattner
7e1ff8d2d9
remove debugging code :-/
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23392 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-19 23:50:15 +00:00
Chris Lattner
eaba3a194c
Implement SimplifyCFG/branch-phi-thread.ll, the most trivial case of threading
...
control across branches with determined outcomes. More generality to follow.
This triggers a couple thousand times in specint.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23391 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-19 23:49:37 +00:00
Chris Lattner
7203e158da
Refactor this code a bit and make it more general. This now compiles:
...
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus2 (unsigned int x) { b.j += x; }
To:
_plus2:
lis r2, ha16(L_b$non_lazy_ptr)
lwz r2, lo16(L_b$non_lazy_ptr)(r2)
lwz r4, 0(r2)
slwi r3, r3, 6
add r3, r4, r3
rlwimi r3, r4, 0, 26, 14
stw r3, 0(r2)
blr
instead of:
_plus2:
lis r2, ha16(L_b$non_lazy_ptr)
lwz r2, lo16(L_b$non_lazy_ptr)(r2)
lwz r4, 0(r2)
rlwinm r5, r4, 26, 21, 31
add r3, r5, r3
rlwimi r4, r3, 6, 15, 25
stw r4, 0(r2)
blr
by eliminating an 'and'.
I'm pretty sure this is as small as we can go :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23386 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-18 07:22:02 +00:00
Chris Lattner
150f12af7f
Compile
...
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus2 (unsigned int x) {
b.j += x;
}
to:
plus2:
mov %EAX, DWORD PTR [b]
mov %ECX, %EAX
and %ECX, 131008
mov %EDX, DWORD PTR [%ESP + 4]
shl %EDX, 6
add %EDX, %ECX
and %EDX, 131008
and %EAX, -131009
or %EDX, %EAX
mov DWORD PTR [b], %EDX
ret
instead of:
plus2:
mov %EAX, DWORD PTR [b]
mov %ECX, %EAX
shr %ECX, 6
and %ECX, 2047
add %ECX, DWORD PTR [%ESP + 4]
shl %ECX, 6
and %ECX, 131008
and %EAX, -131009
or %ECX, %EAX
mov DWORD PTR [b], %ECX
ret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23385 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-18 06:30:59 +00:00
Chris Lattner
0b7c0bf249
Generalize this transform, using MaskedValueIsZero, allowing us to compile:
...
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus3 (unsigned int x) { b.k += x; }
To:
plus3:
mov %EAX, DWORD PTR [%ESP + 4]
shl %EAX, 17
add DWORD PTR [b], %EAX
ret
instead of:
plus3:
mov %EAX, DWORD PTR [%ESP + 4]
shl %EAX, 17
mov %ECX, DWORD PTR [b]
add %EAX, %ECX
and %EAX, -131072
and %ECX, 131071
or %ECX, %EAX
mov DWORD PTR [b], %ECX
ret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23384 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-18 06:02:59 +00:00
Chris Lattner
5aa7666ebe
fix typeo
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23383 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-18 05:25:20 +00:00
Chris Lattner
0d947ea943
Remove unintentionally committed code
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23382 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-18 05:12:51 +00:00
Chris Lattner
11021cb988
implement shift.ll:test25. This compiles:
...
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus3 (unsigned int x) {
b.k += x;
}
to:
_plus3:
lis r2, ha16(L_b$non_lazy_ptr)
lwz r2, lo16(L_b$non_lazy_ptr)(r2)
lwz r3, 0(r2)
rlwinm r4, r3, 0, 0, 14
add r4, r4, r3
rlwimi r4, r3, 0, 15, 31
stw r4, 0(r2)
blr
instead of:
_plus3:
lis r2, ha16(L_b$non_lazy_ptr)
lwz r2, lo16(L_b$non_lazy_ptr)(r2)
lwz r4, 0(r2)
srwi r5, r4, 17
add r3, r5, r3
slwi r3, r3, 17
rlwimi r3, r4, 0, 15, 31
stw r3, 0(r2)
blr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23381 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-18 05:12:10 +00:00
Chris Lattner
c8e7756791
Implement add.ll:test29. Codegening:
...
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus1 (unsigned int x) {
b.i += x;
}
as:
_plus1:
lis r2, ha16(L_b$non_lazy_ptr)
lwz r2, lo16(L_b$non_lazy_ptr)(r2)
lwz r4, 0(r2)
add r3, r4, r3
rlwimi r3, r4, 0, 0, 25
stw r3, 0(r2)
blr
instead of:
_plus1:
lis r2, ha16(L_b$non_lazy_ptr)
lwz r2, lo16(L_b$non_lazy_ptr)(r2)
lwz r4, 0(r2)
rlwinm r5, r4, 0, 26, 31
add r3, r5, r3
rlwimi r3, r4, 0, 0, 25
stw r3, 0(r2)
blr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23379 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-18 04:24:45 +00:00
Chris Lattner
3255bd101d
remove debug output
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23377 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-18 03:50:25 +00:00
Chris Lattner
e9bed7d107
Implement or.ll:test21. This teaches instcombine to be able to turn this:
...
struct {
unsigned int bit0:1;
unsigned int ubyte:31;
} sdata;
void foo() {
sdata.ubyte++;
}
into this:
foo:
add DWORD PTR [sdata], 2
ret
instead of this:
foo:
mov %EAX, DWORD PTR [sdata]
mov %ECX, %EAX
add %ECX, 2
and %ECX, -2
and %EAX, 1
or %EAX, %ECX
mov DWORD PTR [sdata], %EAX
ret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23376 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-18 03:42:07 +00:00
Chris Lattner
6e2f843114
Fix the regression last night compiling povray
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23348 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-14 17:32:56 +00:00
Chris Lattner
7835cdde40
Add a simple xform to simplify array accesses with casts in the way.
...
This is useful for 178.galgel where resolution of dope vectors (by the
optimizer) causes the scales to become apparent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23328 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-13 18:36:04 +00:00
Chris Lattner
396b2baf3c
Fix an issue where LSR would miss rewriting a use of an IV expression by a PHI node that is not the original PHI.
...
This fixes up a dot-product loop in galgel, speeding it up from 18.47s to
16.13s.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23327 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-13 02:09:55 +00:00
Chris Lattner
eed48275a1
Add a helper function, allowing us to simplify some code a bit, changing
...
indentation, no functionality change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23325 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-13 00:40:14 +00:00
Chris Lattner
408902b3c4
Implement a simple xform to turn code like this:
...
if () { store A -> P; } else { store B -> P; }
into a PHI node with one store, in the most trival case. This implements
load.ll:test10.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23324 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-12 23:23:25 +00:00
Chris Lattner
9c1f0fd8de
Another load-peephole optimization: do gcse when two loads are next to
...
each other. This implements InstCombine/load.ll:test9
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23322 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-12 22:21:03 +00:00
Chris Lattner
62f254df04
Implement a trivial form of store->load forwarding where the store and the
...
load are exactly consequtive. This is picked up by other passes, but this
triggers thousands of times in fortran programs that use static locals
(and is thus a compile-time speedup).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23320 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-12 22:00:15 +00:00
Chris Lattner
12b50410cd
Fix a regression from last night, which caused this pass to create invalid
...
code for IV uses outside of loops that are not dominated by the latch block.
We should only convert these uses to use the post-inc value if they ARE
dominated by the latch block.
Also use a new LoopInfo method to simplify some code.
This fixes Transforms/LoopStrengthReduce/2005-09-12-UsesOutOutsideOfLoop.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23318 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-12 17:11:27 +00:00
Chris Lattner
c6bae65b49
_test:
...
li r2, 0
LBB_test_1: ; no_exit.2
li r5, 0
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmpwi cr0, r2, 701
blt cr0, LBB_test_1 ; no_exit.2
LBB_test_2: ; loopexit.2.loopexit
addi r2, r2, 1
stw r2, 0(r4)
blr
[zion ~/llvm]$ cat > ~/xx
Uses of IV's outside of the loop should use hte post-incremented version
of the IV, not the preincremented version. This helps many loops (e.g. in sixtrack)
which used to generate code like this (this is the code from the
dont-hoist-simple-loop-constants.ll testcase):
_test:
li r2, 0 **** IV starts at 0
LBB_test_1: ; no_exit.2
or r5, r2, r2 **** Copy for loop exit
li r2, 0
stw r2, 0(r3)
addi r3, r3, 4
addi r2, r5, 1
addi r6, r5, 2 **** IV+2
cmpwi cr0, r6, 701
blt cr0, LBB_test_1 ; no_exit.2
LBB_test_2: ; loopexit.2.loopexit
addi r2, r5, 2 **** IV+2
stw r2, 0(r4)
blr
And now generated code like this:
_test:
li r2, 1 *** IV starts at 1
LBB_test_1: ; no_exit.2
li r5, 0
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmpwi cr0, r2, 701 *** IV.postinc + 0
blt cr0, LBB_test_1
LBB_test_2: ; loopexit.2.loopexit
stw r2, 0(r4) *** IV.postinc + 0
blr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23313 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-12 06:04:47 +00:00
Chris Lattner
7259df3ab8
implement Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll.
...
We used to emit this code for it:
_test:
li r2, 1 ;; Value tying up a register for the whole loop
li r5, 0
LBB_test_1: ; no_exit.2
or r6, r5, r5
li r5, 0
stw r5, 0(r3)
addi r5, r6, 1
addi r3, r3, 4
add r7, r2, r5 ;; should be addi r7, r5, 1
cmpwi cr0, r7, 701
blt cr0, LBB_test_1 ; no_exit.2
LBB_test_2: ; loopexit.2.loopexit
addi r2, r6, 2
stw r2, 0(r4)
blr
now we emit this:
_test:
li r2, 0
LBB_test_1: ; no_exit.2
or r5, r2, r2
li r2, 0
stw r2, 0(r3)
addi r3, r3, 4
addi r2, r5, 1
addi r6, r5, 2 ;; whoa, fold those adds!
cmpwi cr0, r6, 701
blt cr0, LBB_test_1 ; no_exit.2
LBB_test_2: ; loopexit.2.loopexit
addi r2, r5, 2
stw r2, 0(r4)
blr
more improvement coming.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23306 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-10 01:18:45 +00:00
Chris Lattner
7b4ad94282
Fix a problem that Dan Berlin noticed, where reassociation would not succeed
...
in building maximal expressions before simplifying them. In particular, i
cases like this:
X-(A+B+X)
the code would consider A+B+X to be a maximal expression (not understanding
that the single use '-' would be turned into a + later), simplify it (a noop)
then later get simplified again.
Each of these simplify steps is where the cost of reassociation comes from,
so this patch should speed up the already fast pass a bit.
Thanks to Dan for noticing this!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23214 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-02 07:07:58 +00:00
Chris Lattner
2cd85da3ed
Avoid creating garbage instructions, just move the old add instruction
...
to where we need it when converting -(A+B+C) -> -A + -B + -C.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23213 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-02 06:38:04 +00:00
Chris Lattner
368a3aabb2
add some assertions and fix problems where reassociate could access the
...
Ops vector out of range
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23211 91177308-0d34-0410-b5e6-96231b3b80d8
2005-09-02 05:23:22 +00:00
Chris Lattner
ac83b0301e
Fix Regression/Transforms/Reassociate/2005-08-24-Crash.ll
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23019 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-24 17:55:32 +00:00
Chris Lattner
53249865ec
Transform floor((double)FLT) -> (double)floorf(FLT), implementing
...
Regression/Transforms/SimplifyLibCalls/floor.ll. This triggers 19 times in
177.mesa.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23017 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-24 17:22:17 +00:00
Chris Lattner
8385e51e21
Fix Transforms/LoopStrengthReduce/2005-08-17-OutOfLoopVariant.ll, a crash
...
on 177.mesa
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22843 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-17 21:22:41 +00:00
Chris Lattner
aa96ae780a
Use a new helper to split critical edges, making the code simpler.
...
Do not claim to not change the CFG. We do change the cfg to split critical
edges. This isn't causing us a problem now, but could likely do so in the
future.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22824 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-17 06:35:16 +00:00
Chris Lattner
80b32b3aab
Fix a bad case in gzip where we put lots of things in registers across the
...
loop, because a IV-dependent value was used outside of the loop and didn't
have immediate-folding capability
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22798 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-16 00:38:11 +00:00
Chris Lattner
27e5142309
Ooops, don't forget to clear this. The real inner loop is now:
...
.LBB_foo_3: ; no_exit.1
lfd f2, 0(r9)
lfd f3, 8(r9)
fmul f4, f1, f2
fmadd f4, f0, f3, f4
stfd f4, 8(r9)
fmul f3, f1, f3
fmsub f2, f0, f2, f3
stfd f2, 0(r9)
addi r9, r9, 16
addi r8, r8, 1
cmpw cr0, r8, r4
ble .LBB_foo_3 ; no_exit.1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22782 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-13 07:42:01 +00:00
Chris Lattner
934520a747
Recursively scan scev expressions for common subexpressions. This allows us
...
to handle nested loops much better, for example, by being able to tell that
these two expressions:
{( 8 + ( 16 * ( 1 + %Tmp11 + %Tmp12)) + %c_),+,( 16 * %Tmp 12)}<loopentry.1>
{(( 16 * ( 1 + %Tmp11 + %Tmp12)) + %c_),+,( 16 * %Tmp12)}<loopentry.1>
Have the following common part that can be shared:
{(( 16 * ( 1 + %Tmp11 + %Tmp12)) + %c_),+,( 16 * %Tmp12)}<loopentry.1>
This allows us to codegen an important inner loop in 168.wupwise as:
.LBB_foo_4: ; no_exit.1
lfd f2, 16(r9)
fmul f3, f0, f2
fmul f2, f1, f2
fadd f4, f3, f2
stfd f4, 8(r9)
fsub f2, f3, f2
stfd f2, 16(r9)
addi r8, r8, 1
addi r9, r9, 16
cmpw cr0, r8, r4
ble .LBB_foo_4 ; no_exit.1
instead of:
.LBB_foo_3: ; no_exit.1
lfdx f2, r6, r9
add r10, r6, r9
lfd f3, 8(r10)
fmul f4, f1, f2
fmadd f4, f0, f3, f4
stfd f4, 8(r10)
fmul f3, f1, f3
fmsub f2, f0, f2, f3
stfdx f2, r6, r9
addi r9, r9, 16
addi r8, r8, 1
cmpw cr0, r8, r4
ble .LBB_foo_3 ; no_exit.1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22781 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-13 07:27:18 +00:00
Chris Lattner
0ae380a8ac
Teach SplitCriticalEdge to update LoopInfo if it is alive. This fixes
...
a problem in LoopStrengthReduction, where it would split critical edges
then confused itself with outdated loop information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22776 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-13 01:38:43 +00:00
Chris Lattner
8385393dc8
remove dead code. The exit block list is computed on demand, thus does not
...
need to be updated. This code is a relic from when it did.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22775 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-13 01:30:36 +00:00
Chris Lattner
c60fb08f7e
When splitting critical edges, make sure not to leave the new block in the
...
middle of the loop. This turns a critical loop in gzip into this:
.LBB_test_1: ; loopentry
or r27, r28, r28
add r28, r3, r27
lhz r28, 3(r28)
add r26, r4, r27
lhz r26, 3(r26)
cmpw cr0, r28, r26
bne .LBB_test_8 ; loopentry.loopexit_crit_edge
.LBB_test_2: ; shortcirc_next.0
add r28, r3, r27
lhz r28, 5(r28)
add r26, r4, r27
lhz r26, 5(r26)
cmpw cr0, r28, r26
bne .LBB_test_7 ; shortcirc_next.0.loopexit_crit_edge
.LBB_test_3: ; shortcirc_next.1
add r28, r3, r27
lhz r28, 7(r28)
add r26, r4, r27
lhz r26, 7(r26)
cmpw cr0, r28, r26
bne .LBB_test_6 ; shortcirc_next.1.loopexit_crit_edge
.LBB_test_4: ; shortcirc_next.2
add r28, r3, r27
lhz r26, 9(r28)
add r28, r4, r27
lhz r25, 9(r28)
addi r28, r27, 8
cmpw cr7, r26, r25
mfcr r26, 1
rlwinm r26, r26, 31, 31, 31
add r25, r8, r27
cmpw cr7, r25, r7
mfcr r25, 1
rlwinm r25, r25, 29, 31, 31
and. r26, r26, r25
bne .LBB_test_1 ; loopentry
instead of this:
.LBB_test_1: ; loopentry
or r27, r28, r28
add r28, r3, r27
lhz r28, 3(r28)
add r26, r4, r27
lhz r26, 3(r26)
cmpw cr0, r28, r26
beq .LBB_test_3 ; shortcirc_next.0
.LBB_test_2: ; loopentry.loopexit_crit_edge
add r2, r30, r27
add r8, r29, r27
b .LBB_test_9 ; loopexit
.LBB_test_3: ; shortcirc_next.0
add r28, r3, r27
lhz r28, 5(r28)
add r26, r4, r27
lhz r26, 5(r26)
cmpw cr0, r28, r26
beq .LBB_test_5 ; shortcirc_next.1
.LBB_test_4: ; shortcirc_next.0.loopexit_crit_edge
add r2, r11, r27
add r8, r12, r27
b .LBB_test_9 ; loopexit
.LBB_test_5: ; shortcirc_next.1
add r28, r3, r27
lhz r28, 7(r28)
add r26, r4, r27
lhz r26, 7(r26)
cmpw cr0, r28, r26
beq .LBB_test_7 ; shortcirc_next.2
.LBB_test_6: ; shortcirc_next.1.loopexit_crit_edge
add r2, r9, r27
add r8, r10, r27
b .LBB_test_9 ; loopexit
.LBB_test_7: ; shortcirc_next.2
add r28, r3, r27
lhz r26, 9(r28)
add r28, r4, r27
lhz r25, 9(r28)
addi r28, r27, 8
cmpw cr7, r26, r25
mfcr r26, 1
rlwinm r26, r26, 31, 31, 31
add r25, r8, r27
cmpw cr7, r25, r7
mfcr r25, 1
rlwinm r25, r25, 29, 31, 31
and. r26, r26, r25
bne .LBB_test_1 ; loopentry
Next up, improve the code for the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22769 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-12 22:22:17 +00:00
Chris Lattner
e0391beda8
Fix a FIXME: if we are inserting code for a PHI argument, split the critical
...
edge so that the code is not always executed for both operands. This
prevents LSR from inserting code into loops whose exit blocks contain
PHI uses of IV expressions (which are outside of loops). On gzip, for
example, we turn this ugly code:
.LBB_test_1: ; loopentry
add r27, r3, r28
lhz r27, 3(r27)
add r26, r4, r28
lhz r26, 3(r26)
add r25, r30, r28 ;; Only live if exiting the loop
add r24, r29, r28 ;; Only live if exiting the loop
cmpw cr0, r27, r26
bne .LBB_test_5 ; loopexit
into this:
.LBB_test_1: ; loopentry
or r27, r28, r28
add r28, r3, r27
lhz r28, 3(r28)
add r26, r4, r27
lhz r26, 3(r26)
cmpw cr0, r28, r26
beq .LBB_test_3 ; shortcirc_next.0
.LBB_test_2: ; loopentry.loopexit_crit_edge
add r2, r30, r27
add r8, r29, r27
b .LBB_test_9 ; loopexit
.LBB_test_2: ; shortcirc_next.0
...
blt .LBB_test_1
into this:
.LBB_test_1: ; loopentry
or r27, r28, r28
add r28, r3, r27
lhz r28, 3(r28)
add r26, r4, r27
lhz r26, 3(r26)
cmpw cr0, r28, r26
beq .LBB_test_3 ; shortcirc_next.0
.LBB_test_2: ; loopentry.loopexit_crit_edge
add r2, r30, r27
add r8, r29, r27
b .LBB_t_3: ; shortcirc_next.0
.LBB_test_3: ; shortcirc_next.0
...
blt .LBB_test_1
Next step: get the block out of the loop so that the loop is all
fall-throughs again.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22766 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-12 22:06:11 +00:00
Chris Lattner
b01bfd49c3
Change break critical edges to not remove, then insert, PHI node entries.
...
Instead, just update the BB in-place. This is both faster, and it prevents
split-critical-edges from shuffling the PHI argument list unneccesarily.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22765 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-12 21:58:07 +00:00
Chris Lattner
98599ba6c6
remove some trickiness that broke yacr2 and some other programs last night
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22751 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-10 17:15:20 +00:00
Chris Lattner
94f4032448
Make loop-simplify produce better loops by turning PHI nodes like X = phi [X, Y]
...
into just Y. This often occurs when it seperates loops that have collapsed loop
headers. This implements LoopSimplify/phi-node-simplify.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22746 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-10 02:07:32 +00:00
Chris Lattner
cda9ca5a4f
Allow indvar simplify to canonicalize ANY affine IV, not just affine IVs with
...
constant stride. This implements Transforms/IndVarsSimplify/variable-stride-ivs.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22744 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-10 01:12:06 +00:00
Chris Lattner
50fad70279
Teach LSR to strength reduce IVs that have a loop-invariant but non-constant stride.
...
For code like this:
void foo(float *a, float *b, int n, int stride_a, int stride_b) {
int i;
for (i=0; i<n; i++)
a[i*stride_a] = b[i*stride_b];
}
we now emit:
.LBB_foo2_2: ; no_exit
lfs f0, 0(r4)
stfs f0, 0(r3)
addi r7, r7, 1
add r4, r2, r4
add r3, r6, r3
cmpw cr0, r7, r5
blt .LBB_foo2_2 ; no_exit
instead of:
.LBB_foo_2: ; no_exit
mullw r8, r2, r7 ;; multiply!
slwi r8, r8, 2
lfsx f0, r4, r8
mullw r8, r2, r6 ;; multiply!
slwi r8, r8, 2
stfsx f0, r3, r8
addi r2, r2, 1
cmpw cr0, r2, r5
blt .LBB_foo_2 ; no_exit
loops with variable strides occur pretty often. For example, in SPECFP2K
there are 317 variable strides in 177.mesa, 3 in 179.art, 14 in 188.ammp,
56 in 168.wupwise, 36 in 172.mgrid.
Now we can allow indvars to turn functions written like this:
void foo2(float *a, float *b, int n, int stride_a, int stride_b) {
int i, ai = 0, bi = 0;
for (i=0; i<n; i++)
{
a[ai] = b[bi];
ai += stride_a;
bi += stride_b;
}
}
into code like the above for better analysis. With this patch, they generate
identical code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22740 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-10 00:45:21 +00:00
Chris Lattner
c41e34520a
Fix Regression/Transforms/LoopStrengthReduce/phi_node_update_multiple_preds.ll
...
by being more careful about updating PHI nodes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22739 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-10 00:35:32 +00:00
Chris Lattner
87265abffc
Fix some 80 column violations.
...
Once we compute the evolution for a GEP, tell SE about it. This allows users
of the GEP to know it, if the users are not direct. This allows us to compile
this testcase:
void fbSolidFillmmx(int w, unsigned char *d) {
while (w >= 64) {
*(unsigned long long *) (d + 0) = 0;
*(unsigned long long *) (d + 8) = 0;
*(unsigned long long *) (d + 16) = 0;
*(unsigned long long *) (d + 24) = 0;
*(unsigned long long *) (d + 32) = 0;
*(unsigned long long *) (d + 40) = 0;
*(unsigned long long *) (d + 48) = 0;
*(unsigned long long *) (d + 56) = 0;
w -= 64;
d += 64;
}
}
into:
.LBB_fbSolidFillmmx_2: ; no_exit
li r2, 0
stw r2, 0(r4)
stw r2, 4(r4)
stw r2, 8(r4)
stw r2, 12(r4)
stw r2, 16(r4)
stw r2, 20(r4)
stw r2, 24(r4)
stw r2, 28(r4)
stw r2, 32(r4)
stw r2, 36(r4)
stw r2, 40(r4)
stw r2, 44(r4)
stw r2, 48(r4)
stw r2, 52(r4)
stw r2, 56(r4)
stw r2, 60(r4)
addi r4, r4, 64
addi r3, r3, -64
cmpwi cr0, r3, 63
bgt .LBB_fbSolidFillmmx_2 ; no_exit
instead of:
.LBB_fbSolidFillmmx_2: ; no_exit
li r11, 0
stw r11, 0(r4)
stw r11, 4(r4)
stwx r11, r10, r4
add r12, r10, r4
stw r11, 4(r12)
stwx r11, r9, r4
add r12, r9, r4
stw r11, 4(r12)
stwx r11, r8, r4
add r12, r8, r4
stw r11, 4(r12)
stwx r11, r7, r4
add r12, r7, r4
stw r11, 4(r12)
stwx r11, r6, r4
add r12, r6, r4
stw r11, 4(r12)
stwx r11, r5, r4
add r12, r5, r4
stw r11, 4(r12)
stwx r11, r2, r4
add r12, r2, r4
stw r11, 4(r12)
addi r4, r4, 64
addi r3, r3, -64
cmpwi cr0, r3, 63
bgt .LBB_fbSolidFillmmx_2 ; no_exit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22737 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-09 23:39:36 +00:00
Chris Lattner
b965ee5914
SCEVAddExpr::get() of an empty list is invalid.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22724 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-09 01:13:47 +00:00
Chris Lattner
1bbae0cbf2
Implement: LoopStrengthReduce/share_ivs.ll
...
Two changes:
* Only insert one PHI node for each stride. Other values are live in
values. This cannot introduce higher register pressure than the
previous approach, and can take advantage of reg+reg addressing modes.
* Factor common base values out of uses before moving values from the
base to the immediate fields. This improves codegen by starting the
stride-specific PHI node out at a common place for each IV use.
As an example, we used to generate this for a loop in swim:
.LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_2: ; no_exit.7.i
lfd f0, 0(r8)
stfd f0, 0(r3)
lfd f0, 0(r6)
stfd f0, 0(r7)
lfd f0, 0(r2)
stfd f0, 0(r5)
addi r9, r9, 1
addi r2, r2, 8
addi r5, r5, 8
addi r6, r6, 8
addi r7, r7, 8
addi r8, r8, 8
addi r3, r3, 8
cmpw cr0, r9, r4
bgt .LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_1
now we emit:
.LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_2: ; no_exit.7.i
lfdx f0, r8, r2
stfdx f0, r9, r2
lfdx f0, r5, r2
stfdx f0, r7, r2
lfdx f0, r3, r2
stfdx f0, r6, r2
addi r10, r10, 1
addi r2, r2, 8
cmpw cr0, r10, r4
bgt .LBB_main_no_exit_2E_6_2E_i_no_exit_2E_7_2E_i_1
As another more dramatic example, we used to emit this:
.LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_2: ; no_exit.1.i19
lfd f0, 8(r21)
lfd f4, 8(r3)
lfd f5, 8(r27)
lfd f6, 8(r22)
lfd f7, 8(r5)
lfd f8, 8(r6)
lfd f9, 8(r30)
lfd f10, 8(r11)
lfd f11, 8(r12)
fsub f10, f10, f11
fadd f5, f4, f5
fmul f5, f5, f1
fadd f6, f6, f7
fadd f6, f6, f8
fadd f6, f6, f9
fmadd f0, f5, f6, f0
fnmsub f0, f10, f2, f0
stfd f0, 8(r4)
lfd f0, 8(r25)
lfd f5, 8(r26)
lfd f6, 8(r23)
lfd f9, 8(r28)
lfd f10, 8(r10)
lfd f12, 8(r9)
lfd f13, 8(r29)
fsub f11, f13, f11
fadd f4, f4, f5
fmul f4, f4, f1
fadd f5, f6, f9
fadd f5, f5, f10
fadd f5, f5, f12
fnmsub f0, f4, f5, f0
fnmsub f0, f11, f3, f0
stfd f0, 8(r24)
lfd f0, 8(r8)
fsub f4, f7, f8
fsub f5, f12, f10
fnmsub f0, f5, f2, f0
fnmsub f0, f4, f3, f0
stfd f0, 8(r2)
addi r20, r20, 1
addi r2, r2, 8
addi r8, r8, 8
addi r10, r10, 8
addi r12, r12, 8
addi r6, r6, 8
addi r29, r29, 8
addi r28, r28, 8
addi r26, r26, 8
addi r25, r25, 8
addi r24, r24, 8
addi r5, r5, 8
addi r23, r23, 8
addi r22, r22, 8
addi r3, r3, 8
addi r9, r9, 8
addi r11, r11, 8
addi r30, r30, 8
addi r27, r27, 8
addi r21, r21, 8
addi r4, r4, 8
cmpw cr0, r20, r7
bgt .LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_1
we now emit:
.LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_2: ; no_exit.1.i19
lfdx f0, r21, r20
lfdx f4, r3, r20
lfdx f5, r27, r20
lfdx f6, r22, r20
lfdx f7, r5, r20
lfdx f8, r6, r20
lfdx f9, r30, r20
lfdx f10, r11, r20
lfdx f11, r12, r20
fsub f10, f10, f11
fadd f5, f4, f5
fmul f5, f5, f1
fadd f6, f6, f7
fadd f6, f6, f8
fadd f6, f6, f9
fmadd f0, f5, f6, f0
fnmsub f0, f10, f2, f0
stfdx f0, r4, r20
lfdx f0, r25, r20
lfdx f5, r26, r20
lfdx f6, r23, r20
lfdx f9, r28, r20
lfdx f10, r10, r20
lfdx f12, r9, r20
lfdx f13, r29, r20
fsub f11, f13, f11
fadd f4, f4, f5
fmul f4, f4, f1
fadd f5, f6, f9
fadd f5, f5, f10
fadd f5, f5, f12
fnmsub f0, f4, f5, f0
fnmsub f0, f11, f3, f0
stfdx f0, r24, r20
lfdx f0, r8, r20
fsub f4, f7, f8
fsub f5, f12, f10
fnmsub f0, f5, f2, f0
fnmsub f0, f4, f3, f0
stfdx f0, r2, r20
addi r19, r19, 1
addi r20, r20, 8
cmpw cr0, r19, r7
bgt .LBB_main_L_90_no_exit_2E_0_2E_i16_no_exit_2E_1_2E_i19_1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22722 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-09 00:18:09 +00:00
Chris Lattner
a553b0cc01
Suck the base value out of the UsersToProcess vector into the BasedUser
...
class to simplify the code. Fuse two loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22721 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-08 22:56:21 +00:00
Chris Lattner
44b807e3c0
Split MoveLoopVariantsToImediateField out from MoveImmediateValues. The
...
first is a correctness thing, and the later is an optzn thing. This also
is needed to support a future change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22720 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-08 22:32:34 +00:00
Chris Lattner
4bc5f8071a
Use the new 'moveBefore' method to simplify some code. Really, which is
...
easier to understand? :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22706 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-08 19:11:57 +00:00
Chris Lattner
3821e478a5
Not all constants are legal immediates in load/store instructions.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22704 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-08 06:25:50 +00:00
Chris Lattner
5272f3c669
Implement LoopStrengthReduce/share_code_in_preheader.ll by having one
...
rewriter for all code inserted into the preheader, which is never flushed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22702 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-08 05:47:49 +00:00
Chris Lattner
010de25f42
Implement a simple optimization for the termination condition of the loop.
...
The termination condition actually wants to use the post-incremented value
of the loop, not a new indvar with an unusual base.
On PPC, for example, this allows us to compile
LoopStrengthReduce/exit_compare_live_range.ll to:
_foo:
li r2, 0
.LBB_foo_1: ; no_exit
li r5, 0
stw r5, 0(r3)
addi r2, r2, 1
cmpw cr0, r2, r4
bne .LBB_foo_1 ; no_exit
blr
instead of:
_foo:
li r2, 1 ;; IV starts at 1, not 0
.LBB_foo_1: ; no_exit
li r5, 0
stw r5, 0(r3)
addi r5, r2, 1
cmpw cr0, r2, r4
or r2, r5, r5 ;; Reg-reg copy, extra live range
bne .LBB_foo_1 ; no_exit
blr
This implements LoopStrengthReduce/exit_compare_live_range.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22699 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-08 05:28:22 +00:00
Chris Lattner
bbf728edeb
All stats are "Number of ..."
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22694 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-07 20:02:04 +00:00
Chris Lattner
2b83af2d0f
Add some simple folds that occur in bitfield cases. Fix a minor bug in
...
isHighOnes, where it would consider 0 to have high ones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22693 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-07 07:03:10 +00:00
Chris Lattner
4c0e4cdc40
Fix typoCVS: ----------------------------------------------------------------------
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22692 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-07 07:00:52 +00:00
Chris Lattner
ce869ee05b
* Use the new PHINode::hasConstantValue method to simplify some code
...
* Teach this code to move allocas out of the loop when tail call eliminating
a call marked 'tail'. This implements TailCallElim/move_alloca_for_tail_call.ll
* Do not perform this transformation if a call is marked 'tail' and if there
are allocas that we cannot move out of the loop in #2 . Doing so would increase
the stack usage of the function. This implements fixes
PR615 and TailCallElim/dont-tce-tail-marked-call.ll.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22690 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-07 04:27:41 +00:00
Chris Lattner
9a59fbb896
Make sure to clean CastedPointers after casts are potentially deleted.
...
This fixes LSR crashes on 301.apsi, 191.fma3d, and 189.lucas
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22673 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-05 01:30:11 +00:00
Chris Lattner
68ee736694
now that hasConstantValue defaults to only returning values that dominate
...
the PHI node, this ugly code can vanish.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22672 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-05 01:04:30 +00:00
Chris Lattner
5e1b231921
This code can handle non-dominating instructions
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22667 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-05 00:57:45 +00:00
Nate Begeman
a83ba0f5c9
Fix a fixme in CondPropagate.cpp by moving a PhiNode optimization into
...
BasicBlock's removePredecessor routine. This requires shuffling around
the definition and implementation of hasContantValue from Utils.h,cpp into
Instructions.h,cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22664 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-04 23:24:19 +00:00
Chris Lattner
26d91f1646
Modify how immediates are removed from base expressions to deal with the fact
...
that the symbolic evaluator is not always able to use subtraction to remove
expressions. This makes the code faster, and fixes the last crash on 178.galgel.
Finally, add a statistic to see how many phi nodes are inserted.
On 178.galgel, we get the follow stats:
2562 loop-reduce - Number of PHIs inserted
3927 loop-reduce - Number of GEPs strength reduced
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22662 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-04 22:34:05 +00:00
Chris Lattner
2114b273ef
* Refactor some code into a new BasedUser::RewriteInstructionToUseNewBase
...
method.
* Fix a crash on 178.galgel, where we would insert expressions before PHI
nodes instead of into the PHI node predecessor blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22657 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-04 20:03:32 +00:00
Chris Lattner
7a2ca56ef3
Fix a case that caused this to crash on 178.galgel
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22653 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-04 19:26:19 +00:00
Chris Lattner
7db543f887
Teach LSR about loop-variant expressions, such as loops like this:
...
for (i = 0; i < N; ++i)
A[i][foo()] = 0;
here we still want to strength reduce the A[i] part, even though foo() is
l-v.
This also simplifies some of the 'CanReduce' logic.
This implements Transforms/LoopStrengthReduce/ops_after_indvar.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22652 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-04 19:08:16 +00:00
Nate Begeman
f08341457f
Remove some more dead code.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22650 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-04 18:13:56 +00:00
Chris Lattner
3416e5f645
Refactor this code substantially with the following improvements:
...
1. We only analyze instructions once, guaranteed
2. AnalyzeGetElementPtrUsers has been ripped apart and replaced with
something much simpler.
The next step is to handle expressions that are not all indvar+loop-invariant
values (e.g. handling indvar+loopvariant).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22649 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-04 17:40:30 +00:00