1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

1791 Commits

Author SHA1 Message Date
Chris Lattner
b035ec4a9c * 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
Alkis Evlogimenos
eb6bfe9cee Add a dependency to the trace library so that it gets pulled in
automatically.

llvm-svn: 19828
2005-01-25 16:23:57 +00:00
Chris Lattner
ab2ab313d3 Get rid of a several dozen more and instructions in specint.
llvm-svn: 19786
2005-01-23 20:26:55 +00:00
Chris Lattner
151c8e6390 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
5a9660aa71 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
302ea8908d Fix 'raise' to work with packed types. Patch by Morten Ofstad.
llvm-svn: 19693
2005-01-19 16:16:35 +00:00
Chris Lattner
3402945d52 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
de6b1ca556 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
708ff662ba 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
13fd87be57 Fix a compile crash on spiff
llvm-svn: 19552
2005-01-14 17:17:59 +00:00
Chris Lattner
6b519e3314 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
283b7d9809 Do not overrun iterators. This fixes a 176.gcc crash
llvm-svn: 19541
2005-01-13 23:26:48 +00:00
Chris Lattner
b3dfd0aecd 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
e59c6d1cbe 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
ee469241c3 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
aebad4db9a Fix a crash compiling 129.compress
llvm-svn: 19533
2005-01-13 20:14:25 +00:00
Reid Spencer
7e9642515c Add the LOADABLE_MODULE=1 directive to indicate that this shared library is
intended to be a dlopenable module and not a "plain" shared library.

llvm-svn: 19456
2005-01-11 04:33:32 +00:00
Jeff Cohen
8b03a55724 Apply feedback from Chris.
llvm-svn: 19432
2005-01-10 04:23:32 +00:00
Chris Lattner
c2821461e9 Fix VS warnings
llvm-svn: 19383
2005-01-08 19:48:40 +00:00
Chris Lattner
2e24bcf264 Fix VS warnings.
llvm-svn: 19382
2005-01-08 19:45:31 +00:00
Chris Lattner
131ada2668 Fix uint64_t -> unsigned VS warnings.
llvm-svn: 19381
2005-01-08 19:42:22 +00:00
Chris Lattner
ee218d4348 Silence VS warnings.
llvm-svn: 19380
2005-01-08 19:37:20 +00:00
Chris Lattner
d1e987d9ae Silence warnings
llvm-svn: 19379
2005-01-08 19:34:41 +00:00
Jeff Cohen
ce541ade79 Add more missing createXxxPass functions.
llvm-svn: 19370
2005-01-08 17:21:40 +00:00
Misha Brukman
22df7f894f Convert tabs to spaces
llvm-svn: 19320
2005-01-07 07:05:34 +00:00
Jeff Cohen
c07c54f5b4 Add missing createXxxPass functions
llvm-svn: 19319
2005-01-07 06:57:28 +00:00
Jeff Cohen
79dc6715bb Add missing include
llvm-svn: 19315
2005-01-07 05:42:13 +00:00
Jeff Cohen
67f737e5d1 Put createLoopUnswitchPass() into proper namespace
llvm-svn: 19306
2005-01-06 05:47:18 +00:00
Jeff Cohen
a8574e28a3 Add missing include
llvm-svn: 19305
2005-01-06 05:46:44 +00:00
Chris Lattner
14d51ed06a 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
5fff877f74 Implement SimplifyCFG/DeadSetCC.ll
SimplifyCFG is one of those passes that we use for final cleanup: it should
not rely on other passes to clean up its garbage.  This fixes the "why are
trivially dead setcc's in the output of gccas" problem.

llvm-svn: 19212
2005-01-01 16:02:12 +00:00
Chris Lattner
b49dd5c526 Fix PR491 and testcase Transforms/DeadStoreElimination/2004-12-28-PartialStore.ll
llvm-svn: 19180
2004-12-29 04:36:02 +00:00
Chris Lattner
3a260f9757 Adjust to new interfaces
llvm-svn: 18958
2004-12-15 07:22:25 +00:00
Chris Lattner
763e852e7a 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
Brian Gaeke
ca2d45f5c1 Fix link error in PPC optimized build of 'opt'.
llvm-svn: 18913
2004-12-13 21:28:39 +00:00
Chris Lattner
318f80ae39 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
bc889ab3c7 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
85776b0e99 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
deda69d473 More minor microoptimizations
llvm-svn: 18841
2004-12-12 22:44:30 +00:00
Chris Lattner
1629a92f18 Remove some more set operations
llvm-svn: 18840
2004-12-12 22:22:18 +00:00
Chris Lattner
a47e7e4093 Reduce number of set operations.
llvm-svn: 18839
2004-12-12 22:16:13 +00:00
Chris Lattner
2be8c4a870 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
Chris Lattner
0a2feabdc9 Properly implement copying of a global, fixing the 255.vortex & povray
failures from last night.

llvm-svn: 18832
2004-12-12 19:34:41 +00:00
Chris Lattner
9e7ce53b82 Simplify code and do not invalidate iterators.
This fixes a crash compiling TimberWolfMC that was exposed due to recent
optimizer changes.

llvm-svn: 18831
2004-12-12 18:23:20 +00:00
Chris Lattner
97adae1fa4 Though the previous xform applies to literally dozens (hundreds?) of variables
in SPEC, the subsequent optimziations that we are after don't play with
with FP values, so disable this xform for them.  Really we just don't want
stuff like:

double G;   (always 0 or 412312.312)
  = G;

turning into:

bool G_b;
  = G_b ? 412312.312 : 0;

We'd rather just do the load.

-Chris

llvm-svn: 18819
2004-12-12 06:03:06 +00:00
Chris Lattner
f125dc0e49 If a variable can only hold two values, and is not already a bool, shrink it
down to actually BE a bool.  This allows simple value range propagation
stuff work harder, deleting comparisons in bzip2 in some hot loops.

This implements GlobalOpt/integer-bool.ll, which is the essence of the
loop condition distilled into a testcase.

llvm-svn: 18817
2004-12-12 05:53:50 +00:00
Chris Lattner
02c04bbf45 If one side of and/or is known to be 0/-1, it doesn't matter
if the other side is overdefined.

This allows us to fold conditions like:  if (X < Y || Y > Z) in some cases.

llvm-svn: 18807
2004-12-11 23:15:19 +00:00
Chris Lattner
59ce936426 Only cound if we actually made a change.
llvm-svn: 18800
2004-12-11 17:00:14 +00:00
Chris Lattner
8378361f0c The split bb is really the exit of the old function
llvm-svn: 18799
2004-12-11 16:59:54 +00:00
Chris Lattner
06bfa390f6 Two bug fixes:
1. Actually increment the Statistic for the GV elim optzn
 2. When resolving undef branches, only resolve branches in executable blocks,
    avoiding marking a bunch of completely dead blocks live.  This has a big
    impact on the quality of the generated code.

With this patch, we positively rip up vortex, compiling Ut_MoveBytes to a
single memcpy call. In vortex we get this:

     12 ipsccp           - Number of globals found to be constant
    986 ipsccp           - Number of arguments constant propagated
   1378 ipsccp           - Number of basic blocks unreachable
   8919 ipsccp           - Number of instructions removed

llvm-svn: 18796
2004-12-11 06:05:53 +00:00