Commit Graph

710 Commits

Author SHA1 Message Date
Chris Lattner
65aedc1a4e Fold:
(X + (X << C2)) --> X * ((1 << C2) + 1)
   ((X << C2) + X) --> X * ((1 << C2) + 1)

This means that we now canonicalize "Y+Y+Y" into:

        %tmp.2 = mul long %Y, 3         ; <long> [#uses=1]

instead of:

        %tmp.10 = shl long %Y, ubyte 1          ; <long> [#uses=1]
        %tmp.6 = add long %Y, %tmp.10               ; <long> [#uses=1]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17701 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-13 19:31:40 +00:00
Chris Lattner
00a4fe48ac This is V9 specific, move it there.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17545 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-07 00:39:26 +00:00
Chris Lattner
f158092801 Fix some warnings on VC++
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17481 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-05 04:45:43 +00:00
Chris Lattner
d308f8a87f * Rearrange code slightly
* Disable broken transforms for simplifying (setcc (cast X to larger), CI)
  where CC is not != or ==


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17422 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-02 03:50:32 +00:00
Chris Lattner
7e54a01ddb Speed up the tail duplication pass on the testcase below from 68.2s to 1.23s:
#define CL0(a) case a: f(); goto c;
 #define CL1(a) CL0(a##0) CL0(a##1) CL0(a##2) CL0(a##3) CL0(a##4) CL0(a##5) \
 CL0(a##6) CL0(a##7) CL0(a##8) CL0(a##9)
 #define CL2(a) CL1(a##0) CL1(a##1) CL1(a##2) CL1(a##3) CL1(a##4) CL1(a##5) \
 CL1(a##6) CL1(a##7) CL1(a##8) CL1(a##9)
 #define CL3(a) CL2(a##0) CL2(a##1) CL2(a##2) CL2(a##3) CL2(a##4) CL2(a##5) \
 CL2(a##6) CL2(a##7) CL2(a##8) CL2(a##9)
 #define CL4(a) CL3(a##0) CL3(a##1) CL3(a##2) CL3(a##3) CL3(a##4) CL3(a##5) \
 CL3(a##6) CL3(a##7) CL3(a##8) CL3(a##9)

 void f();

 void a() {
     int b;
  c: switch (b) {
         CL4(1)
     }
 }

This comes from GCC PR 15524


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17390 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-01 07:05:07 +00:00
Reid Spencer
6cb21d443e Change Library Names Not To Conflict With Others When Installed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17286 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-27 23:18:45 +00:00
Chris Lattner
1fca5ff62b Convert 'struct' to 'class' in various places to adhere to the coding standards
and work better with VC++.  Patch contributed by Morten Ofstad!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17281 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-27 16:14:51 +00:00
Chris Lattner
dc78122242 Hrm, this code was severely botched. As it turns out, this patch:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20041018/019708.html

exposed ANOTHER latent bug in this xform, which caused Prolangs-C/bison to fill
the zion nightly tester disk up and make the tester barf.

This is obviously not a good thing, so lets fix this bug shall we? :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17276 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-27 05:57:15 +00:00
Chris Lattner
2f48686307 Initialize with the correct constant type
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17270 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-27 03:55:24 +00:00
Chris Lattner
13a166525c Fix compatibility with MSVC, patch by Morten Ofstad
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17218 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-25 18:45:16 +00:00
Chris Lattner
9b9918246c Fix a bug Nate noticed, where we miscompiled a simple testcase
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17157 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-22 04:53:16 +00:00
Reid Spencer
cac731ecbe We won't use automake
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17155 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-22 03:35:04 +00:00
Chris Lattner
3fd0e55de1 Hrm, some people complain when the compiler cheerfully tells them what it's
doing... I guess they're right.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17142 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-19 06:33:16 +00:00
Reid Spencer
86d341b204 Initial automake generated Makefile template
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17136 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-18 23:55:41 +00:00
Nate Begeman
eaa13851a7 Initial implementation of the strength reduction for GEP instructions in
loops.  This optimization is not turned on by default yet, but may be run
with the opt tool's -loop-reduce flag.  There are many FIXMEs listed in the
code that will make it far more applicable to a wide range of code, but you
have to start somewhere :)

This limited version currently triggers on the following tests in the
MultiSource directory:
pcompress2: 7 times
cfrac: 5 times
anagram: 2 times
ks: 6 times
yacr2: 2 times


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17134 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-18 21:08:22 +00:00
Reid Spencer
17e6e44298 Correction to allow compilation with Visual C++.
Patch contributed by Morten Ofstad. Thanks Morten!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17123 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-18 14:38:48 +00:00
Chris Lattner
fc5c1bb000 Turn store -> null/undef into the LLVM unreachable instruction! This simple
change hacks off 10K of bytecode from perlbmk (.5%) even though the front-end
is not generating them yet and we are not optimizing the resultant code.
This isn't too bad.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17111 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-18 03:00:50 +00:00
Chris Lattner
17be63552a Turn things with obviously undefined semantics into 'store -> null'
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17110 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-18 02:59:09 +00:00
Chris Lattner
77bcee74da My friend the invoke instruction does not dominate all basic blocks if it
occurs in the entry node of a function


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17109 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-18 01:48:31 +00:00
Chris Lattner
c7ff6c8029 Getting ADCE to interact well with unreachable instructions seems like a nontrivial
exercise that I'm not interested in tackling right now.  Just punt and treat them
like unwind's.

This 'fixes' test/Regression/Transforms/ADCE/unreachable-function.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17106 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-17 23:45:06 +00:00
Chris Lattner
ca45930548 Remove printout, realize that instructions in the entry block dominate all
other blocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17099 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-17 21:31:34 +00:00
Chris Lattner
c30bda7540 hasConstantValue will soon return instructions that don't dominate the PHI node,
so prepare for this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17095 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-17 21:22:38 +00:00
Chris Lattner
79a564caa7 Fix a type violation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17069 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-16 23:28:04 +00:00
Chris Lattner
6e758aee74 Kill the bogon that slipped into my buffer before I committed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17067 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-16 19:46:33 +00:00
Chris Lattner
061718cba8 Implement InstCombine/getelementptr.ll:test9, which is the source of many
ugly and giant constnat exprs in some programs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17066 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-16 19:44:59 +00:00
Chris Lattner
e87597fb75 Optimize instructions involving undef values. For example X+undef == undef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17047 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-16 18:11:37 +00:00
Chris Lattner
5d356a7c82 Handle undef values as undefined on the constant lattice
ignore unreachable instructions


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17044 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-16 18:09:41 +00:00
Chris Lattner
b2f59a2af7 Add note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17043 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-16 18:09:25 +00:00
Reid Spencer
d96cb6eaa0 Update to reflect changes in Makefile rules.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16950 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-13 11:46:52 +00:00
Chris Lattner
35b9e48cfd Transform memmove -> memcpy when the source is obviously constant memory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16932 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-12 04:52:52 +00:00
Chris Lattner
989cbd58fb Fix a REALLY obscure bug in my previous checkin, which was splicing the END
marker from one ilist into the middle of another basic block!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16925 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-12 01:02:29 +00:00
Chris Lattner
a4b9c7841f Handle a common case more carefully. In particular, instead of transforming
pointer recurrences into expressions from this:

  %P_addr.0.i.0 = phi sbyte* [ getelementptr ([8 x sbyte]* %.str_1, int 0, int 0), %entry ], [ %inc.0.i, %no_exit.i ]
  %inc.0.i = getelementptr sbyte* %P_addr.0.i.0, int 1            ; <sbyte*> [#uses=2]

into this:

  %inc.0.i = getelementptr sbyte* getelementptr ([8 x sbyte]* %.str_1, int 0, int 0), int %inc.0.i.rec

Actually create something nice, like this:

  %inc.0.i = getelementptr [8 x sbyte]* %.str_1, int 0, int %inc.0.i.rec


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16924 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-11 23:06:50 +00:00
Chris Lattner
6a9fdfaec8 Reenable the transform, turning X/-10 < 1 into X > -10
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16918 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-11 19:40:04 +00:00
Reid Spencer
81f76b324e Initial version of automake Makefile.am file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16893 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-10 22:20:40 +00:00
Chris Lattner
dd27827733 Use DEBUG instead of DebugFlag directly, as DebugFlag does not respect
-debug-only!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16868 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-09 19:30:36 +00:00
Chris Lattner
a052f8297a Implement sub.ll:test17, -X/C -> X/-C
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16863 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-09 02:50:40 +00:00
Chris Lattner
340a05fb3a Temporarily disable a buggy transformation until it can be fixed. This fixes
254.gap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16853 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-08 19:15:44 +00:00
Chris Lattner
b99d6b1cac Instcombine (X & FF00) + xx00 -> (X+xx00) & FF00, implementing and.ll:test27
This comes up when doing adds to bitfield elements.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16836 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-08 05:07:56 +00:00
Chris Lattner
1f7e160f77 Little patch to turn (shl (add X, 123), 4) -> (add (shl X, 4), 123 << 4)
This triggers in cases of bitfield additions, opening opportunities for
future improvements.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16834 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-08 03:46:20 +00:00
Chris Lattner
91ccc15b45 Instcombine: -(X sdiv C) -> (X sdiv -C), tested by sub.ll:test16
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16769 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-06 15:08:25 +00:00
Chris Lattner
c3e903fe65 Reduce code growth implied by the tail duplication pass by not duplicating
an instruction if it can be hoisted to a common dominator of the block.
This implements: test/Regression/Transforms/TailDup/MergeTest.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16758 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-06 03:27:37 +00:00
Chris Lattner
a71989f11b Hrm, debugging printouts do not need to be in here
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16598 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-29 21:21:14 +00:00
Chris Lattner
a96879a26d * Pull range optimization code out into new InsertRangeTest function.
* SubOne/AddOne functions always return ConstantInt, declare them as such
* Pull code for handling setcc X, cst, where cst is at the end of the range,
  or cc is LE or GE up earlier in visitSetCondInst.  This reduces #iterations
  in some cases.
* Fold: (div X, C1) op C2 -> range check, implementing div.ll:test6 - test9.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16588 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-29 17:40:11 +00:00
Chris Lattner
4e998b2fea Fold binary expressions and casts into PHI nodes that have all constant inputs.
This takes something like this:

%A = phi int [ 3, %cond_false.0 ], [ 2, %endif.0.i ], [ 2, %endif.1.i ]
%B = div int %tmp.243, 4

and turns it into:

%A = phi int [ 3/4, %cond_false.0 ], [ 2/4, %endif.0.i ], [ 2/4, %endif.1.i ]

which is later simplified (in this case) into %A = 0.

This triggers thousands of times in spec, for example, 269 times in 176.gcc.

This is tested by InstCombine/add.ll:test23 and set.ll:test18.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16582 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-29 05:07:12 +00:00
Chris Lattner
dd763f401e Hrm, really, all tests passed without this, but it is scary to think how...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16568 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-29 03:16:24 +00:00
Chris Lattner
f6d1d7d2ba Remove debugging printout
Instcombine (setcc (truncate X), C1).

This occurs THOUSANDS of times in many benchmarks.  Particularlly common
seem to be things like (seteq (cast bool X to int), int 0)

This turns it into (seteq bool %X, false), which then becomes (not %X).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16567 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-29 03:09:18 +00:00
Chris Lattner
b4f40d2059 Fold (X setcc C1) | (X setcc C2)
This implements or.ll:test1[89]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16561 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-28 22:33:08 +00:00
Chris Lattner
955f331a77 Fold (and (setcc X, C1), (setcc X, C2))
This is important for several reasons:

1. Benchmarks have lots of code that looks like this (perlbmk in particular):

  %tmp.2.i = setne int %tmp.0.i, 128              ; <bool> [#uses=1]
  %tmp.6343 = seteq int %tmp.0.i, 1               ; <bool> [#uses=1]
  %tmp.63 = and bool %tmp.2.i, %tmp.6343          ; <bool> [#uses=1]

   we now fold away the setne, a clear improvement.

2. In the more important cases, such as (X >= 10) & (X < 20), we now produce
   smaller code: (X-10) < 10.

3. Perhaps the nicest effect of this patch is that it really helps out the
   code generators.  In particular, for a 'range test' like the above,
   instead of generating this on X86 (the difference on PPC is even more
   pronounced):

        cmp %EAX, 50
        setge %CL
        cmp %EAX, 100
        setl %AL
        and %CL, %AL
        cmp %CL, 0

   we now generate this:

        add %EAX, -50
        cmp %EAX, 50

   Furthermore, this causes setcc's to be folded into branches more often.

These combinations trigger dozens of times in the spec benchmarks, particularly
in 176.gcc, 186.crafty, 253.perlbmk, 254.gap, & 099.go.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16559 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-28 21:48:02 +00:00
Chris Lattner
18d19ca6df Implement X / C1 / C2 folding
Implement (setcc (shl X, C1), C2) folding.

The second one occurs several dozen times in spec.  The first was added
just in case.  :)

These are tested by shift.ll:test2[12], and div.ll:test5


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16549 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-28 18:22:15 +00:00
Chris Lattner
0cba71b0d6 shl is always zero extending, so always use a zero extending shift right.
This latent bug was exposed by recent changes, and is tested as:
llvm/test/Regression/Transforms/InstCombine/2004-09-28-BadShiftAndSetCC.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16546 91177308-0d34-0410-b5e6-96231b3b80d8
2004-09-28 17:54:07 +00:00