Devang Patel
10c075a316
Revert 79977. It causes llvm-gcc bootstrap failures on some platforms.
...
llvm-svn: 80073
2009-08-26 05:01:18 +00:00
Dan Gohman
e298d55930
Special-case static allocas in IndVarSimplify's loop invariant
...
sinking code, since they are special. If the loop preheader happens
to be the entry block of a function, don't sink static allocas
out of it. This fixes PR4775.
llvm-svn: 80010
2009-08-25 17:42:10 +00:00
Dan Gohman
bf08e82d8e
Remove obsolete -f flags.
...
llvm-svn: 79992
2009-08-25 15:38:29 +00:00
Devang Patel
7d42bfab6c
Update DebugInfo interface to use metadata, instead of special named llvm.dbg.... global variables, to encode debugging information in llvm IR. This is mostly a mechanical change that tests metadata support very well.
...
This change speeds up llvm-gcc by more then 6% at "-O0 -g" (measured by compiling InstructionCombining.cpp!)
llvm-svn: 79977
2009-08-25 05:24:07 +00:00
Dan Gohman
d240c19451
Change getelementptr folding to use APInt instead of uint64_t for
...
offset computations. This fixes a truncation bug on targets that
don't have 64-bit pointers.
llvm-svn: 79639
2009-08-21 16:52:54 +00:00
Dan Gohman
e3245061a9
Add targetdata strings to these tests, since SimplifyLibCalls uses
...
TargetData to find the pointer size.
llvm-svn: 79490
2009-08-19 23:18:49 +00:00
Dan Gohman
cc511acf87
Fix a bug in the over-index constant folding. When over-indexing an
...
array member of a struct, it's possible to land in an arbitrary position
inside that struct, such that attempting to find further getelementptr
indices will fail. In such cases, folding cannot be done.
llvm-svn: 79485
2009-08-19 22:46:59 +00:00
Dan Gohman
bc59c24278
Canonicalize indices in a constantexpr GEP. If Indices exceed the
...
static extents of the static array type, it causes GlobalOpt and
other passes to be more conservative. This canonicalization also
allows the constant folder to add "inbounds" to GEPs.
llvm-svn: 79440
2009-08-19 18:18:36 +00:00
Nick Lewycky
47bc7e0bd0
Fix up PHI nodes correctly in the presence of unreachable BBs, part two. Also
...
delete a newed pointer, and improve readability a little bit.
llvm-svn: 79411
2009-08-19 07:16:57 +00:00
Dan Gohman
807652ac3a
Fix SimplifyLibcalls and ValueTracking to check mayBeOverridden
...
before performing optimizations based on constant string values.
llvm-svn: 79384
2009-08-19 00:11:12 +00:00
Dan Gohman
b0cf049a1e
Generalize ScalarEvolution to be able to analyze GEPs when
...
TargetData is not present. It still uses TargetData when available.
This generalization also fixed some limitations in the TargetData
case; the attached testcase covers this.
llvm-svn: 79344
2009-08-18 16:46:41 +00:00
Dan Gohman
0b1af29372
Fix a bug that caused globalopt to miscompile tramp3d: don't miss
...
unruly indices for arrays that are members of structs.
llvm-svn: 79337
2009-08-18 14:58:19 +00:00
Nick Lewycky
db9fe40304
Test the pass the test is actually for, instead of one that doesn't exist.
...
llvm-svn: 79257
2009-08-17 17:41:29 +00:00
Nick Lewycky
afaae7957e
Don't crash on critical edge. Patch by Andre Tavares.
...
llvm-svn: 79252
2009-08-17 17:00:57 +00:00
Nick Lewycky
3e2d98a039
Add a test that shows that SSI is working correctly.
...
llvm-svn: 79230
2009-08-17 07:32:08 +00:00
Nick Lewycky
e791519ea3
Don't crash trying to promote VLAs.
...
llvm-svn: 79226
2009-08-17 05:37:31 +00:00
Eli Friedman
ca19f19760
Fix for PR3016: detect the tricky case, where there are
...
unfoldable references to a PHI node in the block being folded, and disable
the transformation in that case. The correct transformation of such PHI
nodes depends on whether BB dominates Succ, and dominance is expensive
to compute here. (Alternatively, it's possible to check whether any
uses are live, but that's also essentially a dominance calculation.
Another alternative is to use reg2mem, but it probably isn't a good idea to
use that in simplifycfg.)
Also, remove some incorrect code from CanPropagatePredecessorsForPHIs
which is made unnecessary with this patch: it didn't consider the case
where a PHI node in BB has multiple uses.
llvm-svn: 79174
2009-08-16 04:23:49 +00:00
Nick Lewycky
de61ef6c5e
SSI construction should just go ahead and ignore instructions in unreachable
...
blocks.
llvm-svn: 79132
2009-08-15 20:12:18 +00:00
Mon P Wang
d56e4482fc
When InstCombine simplifies a load -> extract element to gep -> load, place
...
the new load by the old load instead of by the extract element because
a store could have occurred between the load and extract element.
llvm-svn: 78891
2009-08-13 05:12:13 +00:00
Dan Gohman
9f80d2be6b
Make LLVM Assembly dramatically easier to read by aligning the comments,
...
using formatted_raw_ostream's PadToColumn.
Before:
bb1: ; preds = %bb
%2 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
%3 = getelementptr double* %p, i64 %2 ; <double*> [#uses=1]
%4 = load double* %3, align 8 ; <double> [#uses=1]
%5 = fmul double %4, 1.100000e+00 ; <double> [#uses=1]
%6 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
%7 = getelementptr double* %p, i64 %6 ; <double*> [#uses=1]
After:
bb1: ; preds = %bb
%2 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
%3 = getelementptr double* %p, i64 %2 ; <double*> [#uses=1]
%4 = load double* %3, align 8 ; <double> [#uses=1]
%5 = fmul double %4, 1.100000e+00 ; <double> [#uses=1]
%6 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
%7 = getelementptr double* %p, i64 %6 ; <double*> [#uses=1]
Several tests required whitespace adjustments.
llvm-svn: 78816
2009-08-12 17:23:50 +00:00
Dan Gohman
00ee3a9a1a
Transform -X/C to X/-C, implementing a README.txt entry.
...
llvm-svn: 78812
2009-08-12 16:37:02 +00:00
Dan Gohman
d5b6e35080
Optimize (x/C)*C to x if the division is exact.
...
llvm-svn: 78811
2009-08-12 16:33:09 +00:00
Dan Gohman
8d69df5773
Optimize exact sdiv by a constant power of 2 to ashr.
...
llvm-svn: 78714
2009-08-11 20:47:47 +00:00
Dan Gohman
08e747855c
Don't assume that external global variables are aligned at their preferred
...
alignment. Only the minimum alignment guaranteed by the ABI may be assumed.
llvm-svn: 78668
2009-08-11 15:50:03 +00:00
Dan Gohman
aba682a290
Add -disable-output. Thanks Bill!
...
llvm-svn: 78009
2009-08-03 22:24:22 +00:00
Dan Gohman
39f93f6443
Add a new Constant::getIntegerValue helper function, and convert a
...
few places in InstCombine to use it, to fix problems handling pointer
types. This fixes the recent llvm-gcc bootstrap error.
llvm-svn: 78005
2009-08-03 22:07:33 +00:00
Eli Friedman
7bb0485237
PR4662: Fix a crash introduced by the recent LLVMContext changes.
...
llvm-svn: 77716
2009-07-31 19:36:47 +00:00
Daniel Dunbar
89cb72a6bc
Fix PR4645 which was fallout from the fix for PR4641.
...
- Call RAUW to delete all instructions (this is a patch from Nick Lewycky).
llvm-svn: 77512
2009-07-29 22:00:43 +00:00
Nick Lewycky
1961298b63
Just discard the output, no need to turn it back into text.
...
llvm-svn: 77439
2009-07-29 06:14:52 +00:00
Chris Lattner
e5f1099d05
don't dump .bc file to stdout, and simplify this to a trivial testcase.
...
llvm-svn: 77436
2009-07-29 05:32:07 +00:00
Nick Lewycky
e0524c1795
Bulk erasing instructions without RAUWing them is unsafe. Instead, break them
...
into a new BB that has no predecessors.
llvm-svn: 77433
2009-07-29 05:17:50 +00:00
Dan Gohman
0d0dd7b732
Teach instcombine to respect and preserve inbounds. Add inbounds
...
to a few tests where it is required for the expected transformation.
llvm-svn: 77290
2009-07-28 01:40:03 +00:00
Chris Lattner
0426853d67
merge vector-casts-0.ll into vector-casts.ll
...
llvm-svn: 76864
2009-07-23 05:33:39 +00:00
Chris Lattner
c687344f0c
Make some existing optimizations that would only trigger on scalars
...
also apply to vectors. This allows us to compile this:
#include <emmintrin.h>
__m128i a(__m128 a, __m128 b) { return a==a & b==b; }
__m128i b(__m128 a, __m128 b) { return a!=a | b!=b; }
to:
_a:
cmpordps %xmm1, %xmm0
ret
_b:
cmpunordps %xmm1, %xmm0
ret
with clang instead of to a ton of horrible code.
llvm-svn: 76863
2009-07-23 05:32:17 +00:00
Chris Lattner
f4474da353
convert a test to filecheck format. This fixes an endemic problem
...
with negative tests: this test wasn't checking what it thought it was
because it was grepping .bc, not .ll.
llvm-svn: 76861
2009-07-23 05:27:48 +00:00
Chris Lattner
7061a4300d
rename test
...
llvm-svn: 76860
2009-07-23 05:25:12 +00:00
Dan Gohman
f2c6e6a1bd
Add a testcase for PR2831.
...
llvm-svn: 76527
2009-07-21 01:02:18 +00:00
Dan Gohman
74a435e9f1
The upper argument of ConstantRange is exclusive, not inclusive.
...
llvm-svn: 76492
2009-07-20 22:34:18 +00:00
Dan Gohman
00b05492f1
Revert the addition of hasNoPointerOverflow to GEPOperator.
...
Getelementptrs that are defined to wrap are virtually useless to
optimization, and getelementptrs that are undefined on any kind
of overflow are too restrictive -- it's difficult to ensure that
all intermediate addresses are within bounds. I'm going to take
a different approach.
Remove a few optimizations that depended on this flag.
llvm-svn: 76437
2009-07-20 17:43:30 +00:00
Eli Friedman
e507c1afaa
Canonicalize bitcasts between types like <1 x i64> and i64 to
...
insertelement/extractelement.
I'm not entirely sure this is precisely what we want to do: should we
prefer bitcast(insertelement) or insertelement(bitcast)? Similarly. should we
prefer extractelement(bitcast) or bitcast(extractelement)?
llvm-svn: 76345
2009-07-18 23:06:53 +00:00
Eli Friedman
debc43cb11
Back out 76300; apparently the preference is to canonicalize the other
...
way (bitcast -> insert/extractelement).
llvm-svn: 76325
2009-07-18 19:04:16 +00:00
Eli Friedman
65a5fe312a
Add combine: X sdiv (1 << Y) -> X udiv (1 << Y) when X doesn't have the
...
sign bit set.
llvm-svn: 76304
2009-07-18 09:53:21 +00:00
Eli Friedman
f1878fcda1
Canonicalize insert/extractelement from single-element vectors into
...
bitcasts.
It would also be possible to canonicalize the other way; does anyone
have a preference?
llvm-svn: 76300
2009-07-18 09:07:47 +00:00
Eli Friedman
7b1597133d
Fix simplifylibcalls memset recognition to work on 64-bit platforms
...
where int is 32 bits.
llvm-svn: 76293
2009-07-18 08:34:51 +00:00
Dan Gohman
50e65d8c93
Fill in some holes in ScalarEvolution's loop iteration condition
...
analysis. This allows indvars to emit a simpler loop trip count
expression.
llvm-svn: 76085
2009-07-16 17:34:36 +00:00
Eli Friedman
6aa39dcd93
Switch invars away from using isTrapping when it really shouldn't be
...
using it.
llvm-svn: 75852
2009-07-15 22:48:29 +00:00
Eli Friedman
048d13f9bb
Don't restrict the set of instructions where we try to constant-fold the
...
operands; it's possible to end up with a constant-foldable operand to
most instructions, even those which can't trap.
llvm-svn: 75845
2009-07-15 22:13:34 +00:00
Dan Gohman
5329511fae
Fix the expansion of umax and smax in the case where one or more of
...
the operands have pointer type, so that the resulting type matches
the original SCEV type, and so that unnecessary ptrtoints are
avoided in common cases.
llvm-svn: 75680
2009-07-14 20:57:04 +00:00
Dan Gohman
9525cf679f
Add a testcase for a bug fixed by r75634.
...
llvm-svn: 75644
2009-07-14 18:15:00 +00:00
Dale Johannesen
35fc3243a8
Revert 75571; I'm convinced this isn't the right thing to do.
...
llvm-svn: 75642
2009-07-14 17:48:25 +00:00