Commit Graph

1011 Commits

Author SHA1 Message Date
Robert Bocchino
1d7456d0bf Added instcombine support for extractelement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25299 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-13 22:48:06 +00:00
Chris Lattner
a728ddc815 Do a simple instcombine xforms to delete llvm.stackrestore cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25294 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-13 21:28:09 +00:00
Chris Lattner
8b0ea313d9 Simplify this a tiny bit by using the new IntrinsicInst functionality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25292 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-13 20:11:04 +00:00
Chris Lattner
88cac3d2f7 Switch these to using ETForest instead of DominatorSet to compute itself.
Patch written by Daniel Berlin!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25202 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-11 05:10:20 +00:00
Chris Lattner
19ef3d5be2 Switch this to using ETForest instead of DominatorSet to compute itself.
Patch written by Daniel Berlin!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25201 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-11 05:09:40 +00:00
Robert Bocchino
56107e21a5 Added lower packed support for the extractelement operation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25180 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-10 19:05:05 +00:00
Chris Lattner
e8d56c536d fix some 176.gcc miscompilation from my previous patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25137 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-07 01:32:28 +00:00
Chris Lattner
4f637d4db1 silence some bogus gcc warnings on fenris
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25130 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-06 17:59:59 +00:00
Chris Lattner
ad0124c188 Enhance the shift-shift folding code to allow a no-op cast to occur in between
the shifts.

This allows us to fold this (which is the 'integer add a constant' sequence
from cozmic's scheme compmiler):

int %x(uint %anf-temporary776) {
        %anf-temporary777 = shr uint %anf-temporary776, ubyte 1
        %anf-temporary800 = cast uint %anf-temporary777 to int
        %anf-temporary804 = shl int %anf-temporary800, ubyte 1
        %anf-temporary805 = add int %anf-temporary804, -2
        %anf-temporary806 = or int %anf-temporary805, 1
        ret int %anf-temporary806
}

into this:

int %x(uint %anf-temporary776) {
        %anf-temporary776 = cast uint %anf-temporary776 to int
        %anf-temporary776.mask1 = add int %anf-temporary776, -2
        %anf-temporary805 = or int %anf-temporary776.mask1, 1
        ret int %anf-temporary805
}

note that instcombine already knew how to eliminate the AND that the two
shifts fold into.  This is tested by InstCombine/shift.ll:test26

-Chris


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25128 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-06 07:52:12 +00:00
Chris Lattner
830ed03e8b Simplify the code a bit more
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25126 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-06 07:22:22 +00:00
Chris Lattner
4d5542ce6e Extract a bunch of code out of visitShiftInst into FoldShiftByConstant. No
functionality changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25125 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-06 07:12:35 +00:00
Duraid Madina
b5186853f8 getting there...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25021 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-26 13:48:44 +00:00
Chris Lattner
6860f6a01c Fix Transforms/ScalarRepl/2005-12-14-UnionPromoteCrash.ll, a crash on undefined
behavior in 126.gcc on big-endian systems.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24708 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-14 17:23:59 +00:00
Chris Lattner
a188894d67 Implement a little hack for parity with GCC on crafty. This speeds up
186.crafty by about 16% (from 15.109s to 13.045s) on my system.

This turns allocas with unions/casts into scalars.  For example crafty has
something like this:

    union doub {
      unsigned short i[4];
      long long d;
    };
int f(long long a) {
  return ((union doub){.d=a}).i[1];
}

Instead of generating loads and stores to an alloca, we now promote the
whole thing to a scalar long value.

This implements: Transforms/ScalarRepl/AggregatePromote.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24667 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-12 07:19:13 +00:00
Chris Lattner
e08dc62b1a getRawValue zero extens for unsigned values, use getsextvalue so that we
know that small negative values fit into the immediate field of addressing
modes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24608 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-05 18:23:57 +00:00
Chris Lattner
2bd4cb597a Fix a bug where we didn't realize that vaarg reads memory. This fixes
Transforms/DeadStoreElimination/2005-11-30-vaarg.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24545 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-30 19:38:22 +00:00
Andrew Lenharth
b0826529f8 since reg2mem requires it, might as well mention that it preserves it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24491 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-25 16:04:54 +00:00
Andrew Lenharth
7c0c567058 Reg2Mem is something a pass may depend on, so allow that
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24488 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-22 22:14:23 +00:00
Andrew Lenharth
7045f6c56e turns out, demotion and invokes and critical edges don't mix
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24487 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-22 21:45:19 +00:00
Chris Lattner
1730078d5f Fix a crash building 176.gcc due to my recent patch, which only fixed
half the problem.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24414 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-18 18:30:47 +00:00
Chris Lattner
ceda605fd7 This was checking the wrong GEP expression. Fixing this fixes a gccas crash
compiling mysql reported by Ted Kremenek.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24402 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-17 19:35:42 +00:00
Andrew Lenharth
fa25e48412 the pain isn't gone unless the phinodes are spilled too
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24288 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-10 19:39:09 +00:00
Andrew Lenharth
99b8e26b84 this works with backedges to the existing entry block alot better
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24270 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-10 17:35:34 +00:00
Andrew Lenharth
183119cdf6 The pass everyone has been waiting for!
Reg2Mem

for fun you can opt -reg2mem -mem2reg


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24267 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-10 01:58:38 +00:00
Nate Begeman
14b0529532 Add support alignment of allocation instructions.
Add support for specifying alignment and size of setjmp jmpbufs.

No targets currently do anything with this information, nor is it presrved
in the bytecode representation.  That's coming up next.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24196 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-05 09:21:28 +00:00
Chris Lattner
3b5f45042b Implement Transforms/TailCallElim/return-undef.ll, a trivial case
that has been sitting in my inbox since May 18. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24194 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-05 08:21:11 +00:00
Chris Lattner
c812e5d6b8 Turn sdiv into udiv if both operands have a clear sign bit. This occurs
a few times in crafty:

OLD:    %tmp.36 = div int %tmp.35, 8            ; <int> [#uses=1]
NEW:    %tmp.36 = div uint %tmp.35, 8           ; <uint> [#uses=0]
OLD:    %tmp.19 = div int %tmp.18, 8            ; <int> [#uses=1]
NEW:    %tmp.19 = div uint %tmp.18, 8           ; <uint> [#uses=0]
OLD:    %tmp.117 = div int %tmp.116, 8          ; <int> [#uses=1]
NEW:    %tmp.117 = div uint %tmp.116, 8         ; <uint> [#uses=0]
OLD:    %tmp.92 = div int %tmp.91, 8            ; <int> [#uses=1]
NEW:    %tmp.92 = div uint %tmp.91, 8           ; <uint> [#uses=0]

Which all turn into shrs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24190 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-05 07:40:31 +00:00
Chris Lattner
11a49f2c0d Turn srem -> urem when neither input has their sign bit set. This triggers
8 times in vortex, allowing the srems to be turned into shrs:

OLD:    %tmp.104 = rem int %tmp.5.i37, 16               ; <int> [#uses=1]
NEW:    %tmp.104 = rem uint %tmp.5.i37, 16              ; <uint> [#uses=0]
OLD:    %tmp.98 = rem int %tmp.5.i24, 16                ; <int> [#uses=1]
NEW:    %tmp.98 = rem uint %tmp.5.i24, 16               ; <uint> [#uses=0]
OLD:    %tmp.91 = rem int %tmp.5.i19, 8         ; <int> [#uses=1]
NEW:    %tmp.91 = rem uint %tmp.5.i19, 8                ; <uint> [#uses=0]
OLD:    %tmp.88 = rem int %tmp.5.i14, 8         ; <int> [#uses=1]
NEW:    %tmp.88 = rem uint %tmp.5.i14, 8                ; <uint> [#uses=0]
OLD:    %tmp.85 = rem int %tmp.5.i9, 1024               ; <int> [#uses=2]
NEW:    %tmp.85 = rem uint %tmp.5.i9, 1024              ; <uint> [#uses=0]
OLD:    %tmp.82 = rem int %tmp.5.i, 512         ; <int> [#uses=2]
NEW:    %tmp.82 = rem uint %tmp.5.i1, 512               ; <uint> [#uses=0]
OLD:    %tmp.48.i = rem int %tmp.5.i.i161, 4            ; <int> [#uses=1]
NEW:    %tmp.48.i = rem uint %tmp.5.i.i161, 4           ; <uint> [#uses=0]
OLD:    %tmp.20.i2 = rem int %tmp.5.i.i, 4              ; <int> [#uses=1]
NEW:    %tmp.20.i2 = rem uint %tmp.5.i.i, 4             ; <uint> [#uses=0]

it also occurs 9 times in gcc, but with odd constant divisors (1009 and 61)
so the payoff isn't as great.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24189 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-05 07:28:37 +00:00
Andrew Lenharth
7bbff04f7f make this 64 bit clean, fixed test30 of /Regression/Transforms/InstCombine/add.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24158 91177308-0d34-0410-b5e6-96231b3b80d8
2005-11-02 18:35:40 +00:00
Chris Lattner
76ff2c7504 Limit the search depth of MaskedValueIsZero to 6 instructions, to avoid
bad cases.  This fixes Markus's second testcase in PR639, and should
seal it for good.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24123 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-31 18:35:52 +00:00
Chris Lattner
9fefdb5d66 This pass is now obsolete since all targets have moved to the SelectionDAG
infrastructure and the simple isels have been removed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24090 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-29 05:33:46 +00:00
Chris Lattner
cfd65100c4 Pull some code out into a function, give it the ability to see through +.
This allows us to turn code like malloc(4*x+4) -> malloc int, (x+1)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24081 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-29 04:36:15 +00:00
Chris Lattner
455fcc8d35 Remove a special case, allowing the general case to handle it. No functionality
change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24076 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-29 03:19:53 +00:00
Chris Lattner
325231c925 Fix a bit of backwards logic that broke exptree and smg2000
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24056 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-28 16:27:35 +00:00
Chris Lattner
108e902aeb Do not sink any instruction with side effects, including vaarg. This fixes
PR640


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24046 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-27 17:13:11 +00:00
Chris Lattner
0e026de6ac Fix typo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24033 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-27 06:26:26 +00:00
Chris Lattner
e679288a30 Teach instcombine to promote stuff like (cast (malloc sbyte, 8*X) to int*)
into: malloc int, (2*X)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24032 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-27 06:24:46 +00:00
Chris Lattner
8142b0a54b Promote cases like cast (malloc sbyte, 100) to int* into
(malloc [25 x int]) directly without having to convert to
(malloc [100 x sbyte]) first.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24031 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-27 06:12:00 +00:00
Chris Lattner
0ddac2a1c3 Minor change to this file to support obscure cases with constant array amounts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24030 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-27 05:53:56 +00:00
Chris Lattner
e9f15e538a fold nested and's early to avoid inefficiencies in MaskedValueIsZero. This
fixes a very slow compile in PR639.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24011 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-26 17:18:16 +00:00
Chris Lattner
39387a5c93 Handle allocations that, even after removing dead uses, still have more than
one use (but one is a cast).  This handles the very common case of:

 X = alloc [n x byte]
 Y = cast X to somethingbetter
 seteq X, null

In order to avoid infinite looping when there are multiple casts, we only
allow this if the xform is strictly increasing the alignment of the
allocation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23961 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-24 06:35:18 +00:00
Chris Lattner
18e78bb09e Fix a bug where we would 'promote' an allocation from one type to another
where the second has less alignment required.  If we had explicit alignment
support in the IR, we could handle this case, but we can't until we do.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23960 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-24 06:26:18 +00:00
Chris Lattner
b53c2382a9 Before promoting a malloc type, remove dead uses. This makes instcombine
more effective at promoting these allocations, catching them earlier in the
compile process.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23959 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-24 06:22:12 +00:00
Chris Lattner
b3f8397a3d Pull some code out into a function, no functionality change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23958 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-24 06:03:58 +00:00
Chris Lattner
f36aeedaa3 DONT_BUILD_RELINKED is gone and implied by BUILD_ARCHIVE now
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23940 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-24 02:26:13 +00:00
Chris Lattner
ab0ed3592b Only build .a file versions of these libraries, instead of .a and .o versions.
This should speed up build times.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23933 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-24 01:59:48 +00:00
Chris Lattner
492d4a9d84 Make sure that anything using the ADCE pass pulls in the UnifyFunctionExitNodes
code


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23931 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-24 01:40:23 +00:00
Jeff Cohen
66c5fd6c53 When a function takes a variable number of pointer arguments, with a zero
pointer marking the end of the list, the zero *must* be cast to the pointer
type.  An un-cast zero is a 32-bit int, and at least on x86_64, gcc will
not extend the zero to 64 bits, thus allowing the upper 32 bits to be
random junk.

The new END_WITH_NULL macro may be used to annotate a such a function
so that GCC (version 4 or newer) will detect the use of un-casted zero
at compile time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23888 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-23 04:37:20 +00:00
Chris Lattner
63ad7963e4 My previous patch was too conservative. Reject FP and void types, but do
allow pointer types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23859 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-21 05:45:41 +00:00
Chris Lattner
1e9f3af561 Do NOT touch FP ops with LSR. This fixes a testcase Nate sent me from an
inner loop like this:

LBB_RateConvertMono8AltiVec_2:  ; no_exit
        lis r2, ha16(.CPI_RateConvertMono8AltiVec_0)
        lfs f3, lo16(.CPI_RateConvertMono8AltiVec_0)(r2)
        fmr f3, f3
        fadd f0, f2, f0
        fadd f3, f0, f3
        fcmpu cr0, f3, f1
        bge cr0, LBB_RateConvertMono8AltiVec_2  ; no_exit

to an inner loop like this:

LBB_RateConvertMono8AltiVec_1:  ; no_exit
        fsub f2, f2, f1
        fcmpu cr0, f2, f1
        fmr f0, f2
        bge cr0, LBB_RateConvertMono8AltiVec_1  ; no_exit

Doh! good catch!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23838 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-20 04:47:10 +00:00