| Commit message (Collapse) | Author | Age | Files | Lines | 
| | 
| 
| 
|  | 
llvm-svn: 19900
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
* 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
 | 
| | 
| 
| 
|  | 
llvm-svn: 19786
 | 
| | 
| 
| 
| 
| 
|  | 
as long as they are the same size.
llvm-svn: 19734
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
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
 | 
| | 
| 
| 
| 
| 
|  | 
useness.
llvm-svn: 19629
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
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
 | 
| | 
| 
| 
|  | 
llvm-svn: 19553
 | 
| | 
| 
| 
|  | 
llvm-svn: 19552
 | 
| | 
| 
| 
| 
| 
|  | 
This allows us to better optimize begin() -> end() comparisons in common cases.
llvm-svn: 19542
 | 
| | 
| 
| 
|  | 
llvm-svn: 19541
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
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
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
_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
 | 
| | 
| 
| 
|  | 
llvm-svn: 19534
 | 
| | 
| 
| 
|  | 
llvm-svn: 19533
 | 
| | 
| 
| 
|  | 
llvm-svn: 19381
 | 
| | 
| 
| 
|  | 
llvm-svn: 19380
 | 
| | 
| 
| 
|  | 
llvm-svn: 19379
 | 
| | 
| 
| 
|  | 
llvm-svn: 19370
 | 
| | 
| 
| 
|  | 
llvm-svn: 19306
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
* 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
 | 
| | 
| 
| 
| 
| 
|  | 
Transforms/DeadStoreElimination/2004-12-28-PartialStore.ll
llvm-svn: 19180
 | 
| | 
| 
| 
|  | 
llvm-svn: 18958
 | 
| | 
| 
| 
| 
| 
|  | 
turning X - (constantexpr) into X + (-constantexpr) among other things.
llvm-svn: 18935
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
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
 | 
| | 
| 
| 
|  | 
llvm-svn: 18843
 | 
| | 
| 
| 
| 
| 
|  | 
in some cases.
llvm-svn: 18842
 | 
| | 
| 
| 
|  | 
llvm-svn: 18841
 | 
| | 
| 
| 
|  | 
llvm-svn: 18840
 | 
| | 
| 
| 
|  | 
llvm-svn: 18839
 | 
| | 
| 
| 
| 
| 
|  | 
In particular, implement div.ll:test10 and rem.ll:test4.
llvm-svn: 18838
 | 
| | 
| 
| 
| 
| 
| 
|  | 
This fixes a crash compiling TimberWolfMC that was exposed due to recent
optimizer changes.
llvm-svn: 18831
 | 
| | 
| 
| 
| 
| 
| 
| 
|  | 
if the other side is overdefined.
This allows us to fold conditions like:  if (X < Y || Y > Z) in some cases.
llvm-svn: 18807
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
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
 | 
| | 
| 
| 
|  | 
llvm-svn: 18795
 | 
| | 
| 
| 
| 
| 
|  | 
non-address-taken global variables.
llvm-svn: 18790
 | 
| | 
| 
| 
| 
| 
| 
|  | 
In functions where we fully constant prop the return value, replace all
ret instructions with 'ret undef'.
llvm-svn: 18786
 | 
| | 
| 
| 
|  | 
llvm-svn: 18781
 | 
| | 
| 
| 
|  | 
llvm-svn: 18776
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
|  | 
This implements SCCP/ipsccp-basic.ll, rips apart Olden/mst (as described in
PR415), and does other nice things.
There is still more to come with this, but it's a start.
llvm-svn: 18752
 | 
| | 
| 
| 
|  | 
llvm-svn: 18693
 | 
| | 
| 
| 
| 
| 
|  | 
loads in spec
llvm-svn: 18692
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
successor block.  This turns cases like this:
x = a op b
if (c) {
  use x
}
into:
if (c) {
  x = a op b
  use x
}
This triggers 3965 times in spec, and is tested by
Regression/Transforms/InstCombine/sink_instruction.ll
This appears to expose a bug in the X86 backend for 177.mesa, which I'm
looking in to.
llvm-svn: 18677
 | 
| | 
| 
| 
|  | 
llvm-svn: 18674
 | 
| | 
| 
| 
|  | 
llvm-svn: 18670
 | 
| | 
| 
| 
| 
| 
|  | 
Add doInitialization method to avoid overloaded virtuals
llvm-svn: 18602
 | 
| | 
| 
| 
|  | 
llvm-svn: 18439
 | 
| | 
| 
| 
|  | 
llvm-svn: 18387
 | 
| | 
| 
| 
|  | 
llvm-svn: 18363
 | 
| | 
| 
| 
| 
| 
| 
|  | 
* Make sure we handle signed to unsigned conversion correctly
* Move this visitSetCondInst case to its own method.
llvm-svn: 18312
 |