Chris Lattner
dd3ec92085
trivial simplification
...
llvm-svn: 20494
2005-03-06 21:35:38 +00:00
Chris Lattner
238f6df546
Fix a bug where we could corrupt a parent loop's header info if we unrolled
...
a nested loop. This fixes Transforms/LoopUnroll/2005-03-06-BadLoopInfoUpdate.ll
and PR532
llvm-svn: 20493
2005-03-06 20:57:32 +00:00
Jeff Cohen
4abcea3a69
Reformat comments to fix 80 columns.
...
llvm-svn: 20467
2005-03-05 22:45:40 +00:00
Jeff Cohen
be37fa07fd
Reuse induction variables created for strength-reduced GEPs by other similar GEPs.
...
llvm-svn: 20466
2005-03-05 22:40:34 +00:00
Chris Lattner
cfe2822cdf
Do not compute 1ULL << 64, which is undefined. This fixes Ptrdist/ks on the
...
sparc, and testcase Regression/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll
llvm-svn: 20445
2005-03-04 23:21:33 +00:00
Jeff Cohen
a2c59b7423
Add support for not strength reducing GEPs where the element size is a small
...
power of two. This emphatically includes the zeroeth power of two.
llvm-svn: 20429
2005-03-04 04:04:26 +00:00
Chris Lattner
ef1e989e4f
Add an optional argument to lower to a specific constant value instead of
...
to a "sizeof" expression.
llvm-svn: 20414
2005-03-03 01:03:43 +00:00
Jeff Cohen
8ea6f9e821
Fixed the following LSR bugs:
...
* Loop invariant code does not dominate the loop header, but rather
the end of the loop preheader.
* The base for a reduced GEP isn't a constant unless all of its
operands (preceding the induction variable) are constant.
* Allow induction variable elimination for the simple case after all.
Also made changes recommended by Chris for properly deleting
instructions.
llvm-svn: 20383
2005-03-01 03:46:11 +00:00
Jeff Cohen
dcaa48b5c4
Fix crash in LSR due to attempt to remove original induction variable. However,
...
for reasons explained in the comments, I also deactivated this code as it needs
more thought.
llvm-svn: 20367
2005-02-28 00:08:56 +00:00
Jeff Cohen
fd63d3af0d
PHI nodes were incorrectly placed when more than one GEP is reduced in a loop.
...
llvm-svn: 20360
2005-02-27 21:08:04 +00:00
Jeff Cohen
39751c3b7c
First pass at improved Loop Strength Reduction. Still not yet ready for prime time.
...
llvm-svn: 20358
2005-02-27 19:37:07 +00:00
Chris Lattner
52e931b37d
Remove use of bind_obj
...
llvm-svn: 20276
2005-02-22 23:22:58 +00:00
Chris Lattner
7b5d9e2217
Do not mark obviously unreachable blocks live when processing PHI nodes,
...
and handle incomplete control dependences correctly. This fixes:
Regression/Transforms/ADCE/dead-phi-edge.ll
-> a missed optimization
Regression/Transforms/ADCE/dead-phi-edge.ll
-> a compiler crash distilled from QT4
llvm-svn: 20227
2005-02-17 19:28:49 +00:00
Chris Lattner
31f3382b3b
Fix the second bug attached to PR504.
...
llvm-svn: 20181
2005-02-14 20:11:45 +00:00
Chris Lattner
e616fea3bc
Fix for testcase Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll
...
and PR504.
llvm-svn: 20129
2005-02-12 03:26:49 +00:00
Chris Lattner
82b42c5d85
API change.
...
llvm-svn: 19959
2005-02-01 01:23:49 +00:00
Chris Lattner
72684fecf8
Implement InstCombine/cast.ll:test25, a case that occurs many times
...
in spec
llvm-svn: 19953
2005-01-31 05:51:45 +00:00
Chris Lattner
31f486c775
Implement the trivial cases in InstCombine/store.ll
...
llvm-svn: 19950
2005-01-31 05:36:43 +00:00
Chris Lattner
fe1b0b8b24
Implement Transforms/InstCombine/cast-load-gep.ll, which allows us to devirtualize
...
11 indirect calls in perlbmk.
llvm-svn: 19947
2005-01-31 04:50:46 +00:00
Chris Lattner
d8e20188c6
Adjust to changes in instruction interfaces.
...
llvm-svn: 19900
2005-01-29 00:39:08 +00:00
Chris Lattner
cd517ff0c7
* add some DEBUG statements
...
* Properly compile this:
struct a {};
int test() {
struct a b[2];
if (&b[0] != &b[1])
abort ();
return 0;
}
to 'return 0', not abort().
llvm-svn: 19875
2005-01-28 19:32:01 +00:00
Chris Lattner
9e2c7facb2
Get rid of a several dozen more and instructions in specint.
...
llvm-svn: 19786
2005-01-23 20:26:55 +00:00
Chris Lattner
fc4429e7c1
Handle comparisons of gep instructions that have different typed indices
...
as long as they are the same size.
llvm-svn: 19734
2005-01-21 23:06:49 +00:00
Chris Lattner
411336fe04
Add two optimizations. The first folds (X+Y)-X -> Y
...
The second folds operations into selects, e.g. (select C, (X+Y), (Y+Z))
-> (Y+(select C, X, Z)
This occurs a few times across spec, e.g.
select add/sub
mesa: 83 0
povray: 5 2
gcc 4 2
parser 0 22
perlbmk 13 30
twolf 0 3
llvm-svn: 19706
2005-01-19 21:50:18 +00:00
Chris Lattner
715364364b
Delete PHI nodes that are not dead but are locked in a cycle of single
...
useness.
llvm-svn: 19629
2005-01-17 05:10:15 +00:00
Chris Lattner
03f06f11aa
Move code out of indentation one level to make it easier to read.
...
Disable the xform for < > cases. It turns out that the following is being
miscompiled:
bool %test(sbyte %S) {
%T = cast sbyte %S to uint
%V = setgt uint %T, 255
ret bool %V
}
llvm-svn: 19628
2005-01-17 03:20:02 +00:00
Chris Lattner
51726c47fe
Fix some bugs in an xform added yesterday. This fixes Prolangs-C/allroots.
...
llvm-svn: 19553
2005-01-14 17:35:12 +00:00
Chris Lattner
7aa41cfa88
Fix a compile crash on spiff
...
llvm-svn: 19552
2005-01-14 17:17:59 +00:00
Chris Lattner
4fa89827e2
if two gep comparisons only differ by one index, compare that index directly.
...
This allows us to better optimize begin() -> end() comparisons in common cases.
llvm-svn: 19542
2005-01-14 00:20:05 +00:00
Chris Lattner
d35d210ea0
Do not overrun iterators. This fixes a 176.gcc crash
...
llvm-svn: 19541
2005-01-13 23:26:48 +00:00
Chris Lattner
a04c904c4c
Turn select C, (X+Y), (X-Y) --> (X+(select C, Y, (-Y))). This occurs in
...
the 'sim' program and probably elsewhere. In sim, it comes up for cases
like this:
#define round(x) ((x)>0.0 ? (x)+0.5 : (x)-0.5)
double G;
void T(double X) { G = round(X); }
(it uses the round macro a lot). This changes the LLVM code from:
%tmp.1 = setgt double %X, 0.000000e+00 ; <bool> [#uses=1]
%tmp.4 = add double %X, 5.000000e-01 ; <double> [#uses=1]
%tmp.6 = sub double %X, 5.000000e-01 ; <double> [#uses=1]
%mem_tmp.0 = select bool %tmp.1, double %tmp.4, double %tmp.6
store double %mem_tmp.0, double* %G
to:
%tmp.1 = setgt double %X, 0.000000e+00 ; <bool> [#uses=1]
%mem_tmp.0.p = select bool %tmp.1, double 5.000000e-01, double -5.000000e-01
%mem_tmp.0 = add double %mem_tmp.0.p, %X
store double %mem_tmp.0, double* %G
ret void
llvm-svn: 19537
2005-01-13 22:52:24 +00:00
Chris Lattner
81e8417614
Implement an optimization for == and != comparisons like this:
...
_Bool test2(int X, int Y) {
return &arr[X][Y] == arr;
}
instead of generating this:
bool %test2(int %X, int %Y) {
%tmp.3.idx = mul int %X, 160 ; <int> [#uses=1]
%tmp.3.idx1 = shl int %Y, ubyte 2 ; <int> [#uses=1]
%tmp.3.offs2 = sub int 0, %tmp.3.idx ; <int> [#uses=1]
%tmp.7 = seteq int %tmp.3.idx1, %tmp.3.offs2 ; <bool> [#uses=1]
ret bool %tmp.7
}
generate this:
bool %test2(int %X, int %Y) {
seteq int %X, 0 ; <bool>:0 [#uses=1]
seteq int %Y, 0 ; <bool>:1 [#uses=1]
%tmp.7 = and bool %0, %1 ; <bool> [#uses=1]
ret bool %tmp.7
}
This idiom occurs in C++ programs when iterating from begin() to end(),
in a vector or array. For example, we now compile this:
void test(int X, int Y) {
for (int *i = arr; i != arr+100; ++i)
foo(*i);
}
to this:
no_exit: ; preds = %entry, %no_exit
...
%exitcond = seteq uint %indvar.next, 100 ; <bool> [#uses=1]
br bool %exitcond, label %return, label %no_exit
instead of this:
no_exit: ; preds = %entry, %no_exit
...
%inc5 = getelementptr [100 x [40 x int]]* %arr, int 0, int 0, int %inc.rec ; <int*> [#uses=1]
%tmp.8 = seteq int* %inc5, getelementptr ([100 x [40 x int]]* %arr, int 0, int 100, int 0) ; <bool> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
br bool %tmp.8, label %return, label %no_exit
llvm-svn: 19536
2005-01-13 22:25:21 +00:00
Chris Lattner
4cb9fa373b
Fix some bugs in code I didn't mean to check in.
...
llvm-svn: 19534
2005-01-13 20:40:58 +00:00
Chris Lattner
0798af33a5
Fix a crash compiling 129.compress
...
llvm-svn: 19533
2005-01-13 20:14:25 +00:00
Chris Lattner
fdfe3e49fe
Fix uint64_t -> unsigned VS warnings.
...
llvm-svn: 19381
2005-01-08 19:42:22 +00:00
Chris Lattner
47f395cd85
Silence VS warnings.
...
llvm-svn: 19380
2005-01-08 19:37:20 +00:00
Chris Lattner
ce274ce93d
Silence warnings
...
llvm-svn: 19379
2005-01-08 19:34:41 +00:00
Jeff Cohen
677babc4d4
Add more missing createXxxPass functions.
...
llvm-svn: 19370
2005-01-08 17:21:40 +00:00
Jeff Cohen
eca0d0f2da
Put createLoopUnswitchPass() into proper namespace
...
llvm-svn: 19306
2005-01-06 05:47:18 +00:00
Chris Lattner
86102b8ad5
This is a bulk commit that implements the following primary improvements:
...
* We can now fold cast instructions into select instructions that
have at least one constant operand.
* We now optimize expressions more aggressively based on bits that are
known to be zero. These optimizations occur a lot in code that uses
bitfields even in simple ways.
* We now turn more cast-cast sequences into AND instructions. Before we
would only do this if it if all types were unsigned. Now only the
middle type needs to be unsigned (guaranteeing a zero extend).
* We transform sign extensions into zero extensions in several cases.
This corresponds to these test/Regression/Transforms/InstCombine testcases:
2004-11-22-Missed-and-fold.ll
and.ll: test28-29
cast.ll: test21-24
and-or-and.ll
cast-cast-to-and.ll
zeroext-and-reduce.ll
llvm-svn: 19220
2005-01-01 16:22:27 +00:00
Chris Lattner
13516fe2e7
Fix PR491 and testcase Transforms/DeadStoreElimination/2004-12-28-PartialStore.ll
...
llvm-svn: 19180
2004-12-29 04:36:02 +00:00
Chris Lattner
b17f3e13ec
Adjust to new interfaces
...
llvm-svn: 18958
2004-12-15 07:22:25 +00:00
Chris Lattner
9ad0d55025
Constant exprs are not efficiently negatable in practice. This disables
...
turning X - (constantexpr) into X + (-constantexpr) among other things.
llvm-svn: 18935
2004-12-14 20:08:06 +00:00
Chris Lattner
8f430a3b59
Get rid of getSizeOf, using ConstantExpr::getSizeOf instead.
...
do not insert a prototype for malloc of: void* malloc(uint): on 64-bit u
targets this is not correct. Instead of prototype it as void *malloc(...),
and pass the correct intptr_t through the "...".
Finally, fix Regression/CodeGen/SparcV9/2004-12-13-MallocCrash.ll, by not
forming constantexpr casts from pointer to uint.
llvm-svn: 18908
2004-12-13 20:00:02 +00:00
Chris Lattner
a199e3c1e2
Change indentation of a whole bunch of code, no real changes here.
...
llvm-svn: 18843
2004-12-12 23:49:37 +00:00
Chris Lattner
14d07db44d
More substantial simplifications and speedups. This makes ADCE about 20% faster
...
in some cases.
llvm-svn: 18842
2004-12-12 23:40:17 +00:00
Chris Lattner
9115eb3024
More minor microoptimizations
...
llvm-svn: 18841
2004-12-12 22:44:30 +00:00
Chris Lattner
d4298781c1
Remove some more set operations
...
llvm-svn: 18840
2004-12-12 22:22:18 +00:00
Chris Lattner
a538439bf0
Reduce number of set operations.
...
llvm-svn: 18839
2004-12-12 22:16:13 +00:00
Chris Lattner
bf5b7cf638
Optimize div/rem + select combinations more.
...
In particular, implement div.ll:test10 and rem.ll:test4.
llvm-svn: 18838
2004-12-12 21:48:58 +00:00