Dan Gohman
8b6ebb1112
Minor code simplifications. Don't attempt LSR on theoretical
...
targets with pointers larger than 64 bits, due to the code not
yet being APInt clean.
llvm-svn: 69296
2009-04-16 16:49:48 +00:00
Dan Gohman
e2ead2c328
LSR is no longer a GEP optimizer. It is now an IV expression
...
optimizer, which just happen to frequently involve optimizing GEPs.
llvm-svn: 69295
2009-04-16 16:46:01 +00:00
Dan Gohman
a8be04b2db
Use ConstantExpr::getIntToPtr instead of SCEVExpander::InsertCastOfTo,
...
since the operand is always a constant.
llvm-svn: 69291
2009-04-16 15:48:38 +00:00
Dan Gohman
71bccd3e0e
Use a SCEV expression cast instead of immediately inserting a
...
new instruction with SCEVExpander::InsertCastOfTo.
llvm-svn: 69290
2009-04-16 15:47:35 +00:00
Dan Gohman
0a40ad93a9
Expand GEPs in ScalarEvolution expressions. SCEV expressions can now
...
have pointer types, though in contrast to C pointer types, SCEV
addition is never implicitly scaled. This not only eliminates the
need for special code like IndVars' EliminatePointerRecurrence
and LSR's own GEP expansion code, it also does a better job because
it lets the normal optimizations handle pointer expressions just
like integer expressions.
Also, since LLVM IR GEPs can't directly index into multi-dimensional
VLAs, moving the GEP analysis out of client code and into the SCEV
framework makes it easier for clients to handle multi-dimensional
VLAs the same way as other arrays.
Some existing regression tests show improved optimization.
test/CodeGen/ARM/2007-03-13-InstrSched.ll in particular improved to
the point where if-conversion started kicking in; I turned it off
for this test to preserve the intent of the test.
llvm-svn: 69258
2009-04-16 03:18:22 +00:00
Dale Johannesen
a71daa83c6
Eliminate zext over (iv | const) or (signed iv),
...
and sext over (iv | const), if a longer iv is
available. Allow expressions to have more than
one zext/sext parent. All from OpenSSL.
llvm-svn: 69241
2009-04-15 23:31:51 +00:00
Dale Johannesen
82230b5b17
Eliminate zext over (iv & const) or ((iv+const)&const)
...
if a longer iv is available. These subscript forms are
not common; they're a bottleneck in OpenSSL.
llvm-svn: 69215
2009-04-15 20:41:02 +00:00
Dale Johannesen
7ffb7d5728
Enhance induction variable code to remove the
...
sext around sext(shorter IV + constant), using a
longer IV instead, when it can figure out the
add can't overflow. This comes up a lot in
subscripting; mainly affects 64 bit.
llvm-svn: 69123
2009-04-15 01:10:12 +00:00
Evan Cheng
ffb83a155e
Avoid making the transformation enabled by my last patch if the new destinations have phi nodes.
...
llvm-svn: 69121
2009-04-15 00:43:54 +00:00
Devang Patel
046bf624b9
While inlining, clone llvm.dbg.func.start intrinsic and adjust
...
llvm.dbg.region.end instrinsic. This nested llvm.dbg.func.start/llvm.dbg.region.end pair now enables DW_TAG_inlined_subroutine support in code generator.
llvm-svn: 69118
2009-04-15 00:17:06 +00:00
Evan Cheng
5ebf2acd84
Optimize conditional branch on i1 phis with non-constant inputs.
...
This turns:
eq:
%3 = icmp eq i32 %1, %2
br label %join
ne:
%4 = icmp ne i32 %1, %2
br label %join
join:
%5 = phi i1 [%3, %eq], [%4, %ne]
br i1 %5, label %yes, label %no
=>
eq:
%3 = icmp eq i32 %1, %2
br i1 %3, label %yes, label %no
ne:
%4 = icmp ne i32 %1, %2
br i1 %4, label %yes, label %no
llvm-svn: 69102
2009-04-14 23:40:03 +00:00
Owen Anderson
a1902318e3
LoopIndexSplit needs to inform the loop pass manager of the instructions it is
...
deleting, not just the basic block.
llvm-svn: 69011
2009-04-14 01:04:19 +00:00
Chris Lattner
836e77d161
eliminate unneeded parens.
...
llvm-svn: 68939
2009-04-13 05:38:23 +00:00
Chris Lattner
6cd82fb430
"There was a typo in my previous patch which leads to miscompilation of
...
strncat :(
strncat(foo, "bar", 99)
would be optimized to
memcpy(foo+strlen(foo), "bar", 100, 1)
instead of
memcpy(foo+strlen(foo), "bar", 4, 1)"
Patch by Benjamin Kramer!
llvm-svn: 68905
2009-04-12 18:22:33 +00:00
Chris Lattner
91b6af24ac
add some optimizations for strncpy/strncat and factor some
...
code. Patch by Benjamin Kramer!
llvm-svn: 68885
2009-04-12 05:06:39 +00:00
Chris Lattner
eb510d6b3d
Instcombine should not promote whole computation trees to "strange"
...
integer types, unless they are already strange. This prevents it from
turning the code produced by SROA into crazy libcalls and stuff that
the code generator can't handle. In the attached example, the result
was an i96 multiply that caused the x86 backend to assert.
Note that if TargetData had an idea of what the legal types are for
a target that this could be used to stop instcombine from introducing
i64 muls, as Scott wanted.
llvm-svn: 68598
2009-04-08 05:41:03 +00:00
Chris Lattner
321741af5f
fix rdar://6762290, a crash compiling cxx filt with clang.
...
llvm-svn: 68500
2009-04-07 05:03:34 +00:00
Chris Lattner
47d6e7b93e
remove empty section
...
llvm-svn: 68485
2009-04-07 02:55:53 +00:00
Ed Schouten
01aa6ec97a
Let the strcat optimizer return the pointer to the start of the buffer,
...
instead of the place where it started to perform the string copy.
- PR3661
- Patch by Benjamin Kramer!
llvm-svn: 68443
2009-04-06 13:06:48 +00:00
Owen Anderson
98f912bf13
Reapply r68211, with the miscompilations it caused fixed.
...
llvm-svn: 68262
2009-04-01 23:53:49 +00:00
Dan Gohman
c4971721ea
Revert r68172. It caused regressions in
...
Applications/Burg/burg
Applications/ClamAV/clamscan
and many other tests.
llvm-svn: 68211
2009-04-01 16:37:47 +00:00
Owen Anderson
ff5961b46c
Enhance GVN to propagate simple conditionals. This fixes PR3921.
...
llvm-svn: 68172
2009-04-01 01:20:45 +00:00
Chris Lattner
f72ce6ea8b
Make the key of ValueRankMap an AssertingVH, so that we die violently
...
if it dangles.
llvm-svn: 68150
2009-03-31 22:13:29 +00:00
Evan Cheng
826b6f0f7c
Throttle back "fold select into operand" transformation. InstCombine should not generate selects of two constants unless they are selects of 0 and 1.
...
e.g.
define i32 @t1(i32 %c, i32 %x) nounwind {
%t1 = icmp eq i32 %c, 0
%t2 = lshr i32 %x, 18
%t3 = select i1 %t1, i32 %t2, i32 %x
ret i32 %t3
}
was turned into
define i32 @t2(i32 %c, i32 %x) nounwind {
%t1 = icmp eq i32 %c, 0
%t2 = select i1 %t1, i32 18, i32 0
%t3 = lshr i32 %x, %t2
ret i32 %t3
}
For most targets, that means materializing two constants and then a select. e.g. On x86-64
movl %esi, %eax
shrl $18, %eax
testl %edi, %edi
cmovne %esi, %eax
ret
=>
xorl %eax, %eax
testl %edi, %edi
movl $18, %ecx
cmovne %eax, %ecx
movl %esi, %eax
shrl %cl, %eax
ret
Also, the optimizer and codegen can reason about shl / and / add, etc. by a constant. This optimization will hinder optimizations using ComputeMaskedBits.
llvm-svn: 68142
2009-03-31 20:42:45 +00:00
Devang Patel
4ce6e69022
Update call graph after inlining invoke.
...
Patch by Jay Foad.
llvm-svn: 68120
2009-03-31 17:36:12 +00:00
Devang Patel
6e68bd007a
Loop Index Split can eliminate a loop if it can determin if loop body is executed only once. There was a bug in determining IV based value of the iteration for which the loop body is executed. Fix it.
...
llvm-svn: 68071
2009-03-30 22:24:10 +00:00
Duncan Sands
3241b74f69
Revert r67798: it breaks llvm-gcc bootstrap on x86-64-linux, presumably due to
...
a miscompilation.
make[4]: Entering directory `gcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include'
if [ ! -d "./x86_64-unknown-linux-gnu/bits/stdtr1c++.h.gch" ]; then \
mkdir -p ./x86_64-unknown-linux-gnu/bits/stdtr1c++.h.gch; \
fi; \
gcc-4.2.llvm-objects/./gcc/xgcc -shared-libgcc -Bgcc-4.2.llvm-objects/./gcc -nostdinc++
-Lgcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/src -Lgcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-B/usr/local/gnat-llvm/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gnat-llvm/x86_64-unknown-linux-gnu/lib/ -isystem
/usr/local/gnat-llvm/x86_64-unknown-linux-gnu/include -isystem /usr/local/gnat-llvm/x86_64-unknown-linux-gnu/sys-include -Winvalid-pch -Wno-deprecated -x
c++-header -g -O2 -D_GNU_SOURCE -Igcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
-Igcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include -Igcc-4.2.llvm/libstdc++-v3/libsupc++ -O2 -g
gcc-4.2.llvm/libstdc++-v3/include/precompiled/stdtr1c++.h -o x86_64-unknown-linux-gnu/bits/stdtr1c++.h.gch/O2g.gch
In file included from gcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include/tr1/repeat.h:247,
from gcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include/tr1/functional:1098,
from gcc-4.2.llvm/libstdc++-v3/include/precompiled/stdtr1c++.h:53:
gcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include/tr1/functional_iterate.h:417: internal compiler error: in ggc_recalculate_in_use_p, at
ggc-page.c:1602
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://llvm.org/bugs/ > for instructions.
make[4]: *** [x86_64-unknown-linux-gnu/bits/stdtr1c++.h.gch/O2g.gch] Error 1
llvm-svn: 67839
2009-03-27 14:56:47 +00:00
Dale Johannesen
4026b041ce
One more place to skip debug info.
...
llvm-svn: 67811
2009-03-27 01:13:37 +00:00
Devang Patel
fe7c0492a0
While hoisting an instruction, update alias info set tracker.
...
llvm-svn: 67798
2009-03-26 23:48:52 +00:00
Dale Johannesen
db90560c1c
Skip debug info one more place. (This one gets
...
called from llc, not opt, but it's an IR level
optimization nevertheless.)
llvm-svn: 67724
2009-03-26 01:15:07 +00:00
Devang Patel
4555618854
Before deleting a basic block, give other loop passes a chance cleanup analysis values, related to the instructions in the basic block.
...
llvm-svn: 67719
2009-03-25 23:57:48 +00:00
Chris Lattner
c3b2111d97
Fix PR3874 by restoring a condition I removed, but making it more
...
precise than it used to be.
llvm-svn: 67662
2009-03-25 00:28:58 +00:00
Chris Lattner
9e94538005
oops, I intended to remove this, not comment it out. Thanks Duncan!
...
llvm-svn: 67657
2009-03-24 23:48:25 +00:00
Chris Lattner
306813cbbb
canonicalize inttoptr and ptrtoint instructions which cast pointers
...
to/from integer types that are not intptr_t to convert to intptr_t
then do an integer conversion to the dest type. This exposes the
cast to the optimizer.
llvm-svn: 67638
2009-03-24 18:35:40 +00:00
Chris Lattner
d9eb41177a
two changes:
...
1. Make instcombine always canonicalize trunc x to i1 into an icmp(x&1). This
exposes the AND to other instcombine xforms and is more of what the code
generator expects.
2. Rewrite the remaining trunc pattern match to use 'match', which
simplifies it a lot.
llvm-svn: 67635
2009-03-24 18:15:30 +00:00
Dale Johannesen
32dfb35281
Use a SmallPtrSet instead of std::set.
...
llvm-svn: 67578
2009-03-23 23:39:20 +00:00
Dan Gohman
4f2fea1a21
Now that errs() is properly non-buffered, there's no need to
...
explicitly flush it.
llvm-svn: 67526
2009-03-23 15:57:19 +00:00
Duncan Sands
1f15ca7c7a
Factorize out a concept - no functionality change.
...
llvm-svn: 67454
2009-03-21 21:27:31 +00:00
Chris Lattner
0a981d1d36
Fix instcombine to not introduce undefined shifts when merging two
...
shifts together. This fixes PR3851.
llvm-svn: 67411
2009-03-20 22:41:15 +00:00
Duncan Sands
a09e0afe74
Don't load values out of global constants with weak
...
linkage: the value may be replaced with something
different at link time. (Frontends that want to
allow values to be loaded out of weak constants can
give their constants weak_odr linkage).
llvm-svn: 67407
2009-03-20 21:53:29 +00:00
Dale Johannesen
2050968df9
Clear the cached cost when removing a function in
...
the inliner; prevents nondeterministic behavior
when the same address is reallocated.
Don't build call graph nodes for debug intrinsic calls;
they're useless, and there were typically a lot of them.
llvm-svn: 67311
2009-03-19 18:03:56 +00:00
Dale Johannesen
e4f361212b
Fix comment typo.
...
llvm-svn: 67307
2009-03-19 17:23:29 +00:00
Dale Johannesen
52bc2aac8a
This pass keeps a map of Instructions to Rank numbers,
...
and was deleting Instructions without clearing the
corresponding map entry. This led to nondeterministic
behavior if the same address got allocated to another
Instruction within a short time.
llvm-svn: 67306
2009-03-19 17:22:53 +00:00
Nick Lewycky
bfd4ad67c7
Remove strange extra semicolons.
...
llvm-svn: 67287
2009-03-19 05:51:39 +00:00
Chris Lattner
514fc5b143
aha, DAE does have to think about PHI nodes. Many thanks to "Dr Evil" (aka Duncan)
...
for pointing this out :)
llvm-svn: 67212
2009-03-18 16:48:45 +00:00
Chris Lattner
595923ff75
Fix PR3826 - InstComb assert with vector shift, by not calling ComputeNumSignBits on a vector.
...
llvm-svn: 67211
2009-03-18 16:32:19 +00:00
Chris Lattner
ab8022055a
add an assertion to make it clear that PHI nodes are not allowed.
...
llvm-svn: 67210
2009-03-18 16:23:56 +00:00
Zhou Sheng
4e2af3cb55
Explicitly check for StoreInst, do not lose the chance to delete
...
unused loads or bitcasts.
llvm-svn: 67202
2009-03-18 12:48:48 +00:00
Zhou Sheng
05bea906c1
Revert my previous change on Local.cpp, instead, fix the bug on scalarrepl.
...
If the instruction has no users, it is also not only used by debug info
and should not be deleted.
llvm-svn: 67194
2009-03-18 10:13:08 +00:00
Zhou Sheng
64a6a092b1
Fix a bug.
...
If I->use_empty(), this method should return false.
llvm-svn: 67180
2009-03-18 07:56:13 +00:00