Commit Graph

23036 Commits

Author SHA1 Message Date
Evan Cheng 0609ab646b More local spiller complexity!
If local spiller optimization turns some instruction into an identity copy, it will be removed. If the output register happens to be dead (and source is obviously killed), transfer the kill / dead information to last use / def in the same MBB.

llvm-svn: 51306
2008-05-20 08:13:21 +00:00
Evan Cheng c8b028daa4 Don't spill dead def.
llvm-svn: 51305
2008-05-20 08:10:37 +00:00
Matthijs Kooijman 5148a4ba66 Fix typo.
llvm-svn: 51303
2008-05-20 07:26:45 +00:00
Chris Lattner 7ac943fffd Teach instcombine 4 new xforms:
(add (sext x), cst) --> (sext (add x, cst'))
  (add (sext x), (sext y)) --> (sext (add int x, y))
  (add double (sitofp x), fpcst) --> (sitofp (add int x, intcst))
  (add double (sitofp x), (sitofp y)) --> (sitofp (add int x, y))

This generally reduces conversions.  For example MiBench/telecomm-gsm
gets these simplifications:

HACK2: 	%tmp67.i142.i.i = sext i16 %tmp6.i141.i.i to i32		; <i32> [#uses=1]
	%tmp23.i139.i.i = sext i16 %tmp2.i138.i.i to i32		; <i32> [#uses=1]
	%tmp8.i143.i.i = add i32 %tmp67.i142.i.i, %tmp23.i139.i.i		; <i32> [#uses=3]
HACK2: 	%tmp67.i121.i.i = sext i16 %tmp6.i120.i.i to i32		; <i32> [#uses=1]
	%tmp23.i118.i.i = sext i16 %tmp2.i117.i.i to i32		; <i32> [#uses=1]
	%tmp8.i122.i.i = add i32 %tmp67.i121.i.i, %tmp23.i118.i.i		; <i32> [#uses=3]
HACK2: 	%tmp67.i.i190.i = sext i16 %tmp6.i.i189.i to i32		; <i32> [#uses=1]
	%tmp23.i.i187.i = sext i16 %tmp2.i.i186.i to i32		; <i32> [#uses=1]
	%tmp8.i.i191.i = add i32 %tmp67.i.i190.i, %tmp23.i.i187.i		; <i32> [#uses=3]
HACK2: 	%tmp67.i173.i.i.i = sext i16 %tmp6.i172.i.i.i to i32		; <i32> [#uses=1]
	%tmp23.i170.i.i.i = sext i16 %tmp2.i169.i.i.i to i32		; <i32> [#uses=1]
	%tmp8.i174.i.i.i = add i32 %tmp67.i173.i.i.i, %tmp23.i170.i.i.i		; <i32> [#uses=3]
HACK2: 	%tmp67.i152.i.i.i = sext i16 %tmp6.i151.i.i.i to i32		; <i32> [#uses=1]
	%tmp23.i149.i.i.i = sext i16 %tmp2.i148.i.i.i to i32		; <i32> [#uses=1]
	%tmp8.i153.i.i.i = add i32 %tmp67.i152.i.i.i, %tmp23.i149.i.i.i		; <i32> [#uses=3]
HACK2: 	%tmp67.i.i.i.i = sext i16 %tmp6.i.i.i.i to i32		; <i32> [#uses=1]
	%tmp23.i.i5.i.i = sext i16 %tmp2.i.i.i.i to i32		; <i32> [#uses=1]
	%tmp8.i.i7.i.i = add i32 %tmp67.i.i.i.i, %tmp23.i.i5.i.i		; <i32> [#uses=3]


This also fixes a bug in ComputeNumSignBits handling select and
makes it more aggressive with and/or.

llvm-svn: 51302
2008-05-20 05:46:13 +00:00
Chris Lattner 9c27f96d04 fix two issues Neil noticed, thanks!
llvm-svn: 51296
2008-05-20 03:50:52 +00:00
Chris Lattner f479856957 Add a bool to isEdgeFeasible that tells it whether to treat unknown
value as undef or untracked.

llvm-svn: 51295
2008-05-20 03:39:39 +00:00
Dan Gohman 69ddfbfe9e Fix ExecutionEngine's constant code to work properly when structs and arrays
will become first-class types.

llvm-svn: 51293
2008-05-20 03:20:09 +00:00
Dan Gohman e5572706e8 Refine the fix in r51169 to only apply when the operand val being
replaced is a PHI. This prevents it from inserting uses before defs
in the case that it isn't a PHI and it depends on other instructions
later in the block. This fixes the 447.dealII regression on x86-64.

llvm-svn: 51292
2008-05-20 03:01:48 +00:00
Evan Cheng 974722b16f runOnMachineFunction should set IsPIC because relocation model may have been changed.
llvm-svn: 51291
2008-05-20 01:56:59 +00:00
Dan Gohman d717761a2b Make AssociativeOpt static.
llvm-svn: 51290
2008-05-20 01:14:05 +00:00
Devang Patel ee7bf41c06 Do not erase induction variable increment if it is used outside the loop.
llvm-svn: 51280
2008-05-19 22:23:55 +00:00
Dan Gohman 123438cc05 Add a ComputeNumSignBits function for use by instcombine, based on the
code in SelectionDAG.

llvm-svn: 51279
2008-05-19 22:14:15 +00:00
Dale Johannesen 5bf742f2aa Handle quoted names when constructing $stub's,
$non_lazy_ptr's and $lazy_ptr's.

llvm-svn: 51277
2008-05-19 21:38:18 +00:00
Chris Lattner b42712288e switch to Type::getFPMantissaWidth instead of reinventing it.
llvm-svn: 51275
2008-05-19 21:17:23 +00:00
Chris Lattner ba9acbe6dc minor cleanups, teach instcombine that sitofp/uitofp cannot
produce a negative zero.

llvm-svn: 51272
2008-05-19 20:27:56 +00:00
Chris Lattner e35fe0f1c6 convert fptosi(sitofp x) -> x if the fp value has enough bits in its mantissa
to accurately represent the integer.  This triggers 9 times in 471.omnetpp,
though 8 of those seem to be inlined from the same place.

llvm-svn: 51271
2008-05-19 20:25:04 +00:00
Chris Lattner 5920a78034 Fold FP comparisons where one operand is converted from an integer
type and the other operand is a constant into integer comparisons.
This happens surprisingly frequently (e.g. 10 times in 471.omnetpp),
which are things like this:

	%tmp8283 = sitofp i32 %tmp82 to double	
	%tmp1013 = fcmp ult double %tmp8283, 0.0

Clearly comparing tmp82 against i32 0 is cheaper here.

this also triggers 8 times in gobmk, including this one:

	%tmp375376 = sitofp i32 %tmp375 to double
	%tmp377 = fcmp ogt double %tmp375376, 8.150000e+01

which is comparing an integer against 81.5 :).

llvm-svn: 51268
2008-05-19 20:18:56 +00:00
Chris Lattner 6e70830af9 remove debug output
llvm-svn: 51264
2008-05-19 20:03:53 +00:00
Chris Lattner fc365b60dc be more aggressive about transforming add -> or when the operands have no
intersecting bits.  This triggers all over the place, for example in lencode,
with adds of stuff like:

	%tmp580 = mul i32 %tmp579, 2	
	%tmp582 = and i32 %b8, 1
and

	%tmp28 = shl i32 %abs.i, 1		
	%sign.0 = select i1 %tmp23, i32 1, i32 0
and
	%tmp344 = shl i32 %tmp343, 2	
	%tmp346 = and i32 %tmp96, 3

etc.

llvm-svn: 51263
2008-05-19 20:01:56 +00:00
Duncan Sands eec7a3c071 Fix PR2341 - when the length is 4 use an i32 not
an i16!  Cleaned up trailing whitespace while there.

llvm-svn: 51240
2008-05-19 09:27:24 +00:00
Gordon Henriksen 8bd151d194 Reverting accidental commit of generated files.
llvm-svn: 51239
2008-05-19 05:57:12 +00:00
Gordon Henriksen 00889ccfca Remove a duplicative binding. Patch by Mahadevan R.
llvm-svn: 51238
2008-05-19 05:47:10 +00:00
Nate Begeman 65720c968c Teach GVN to not assert on vector comparisons
llvm-svn: 51230
2008-05-18 19:49:05 +00:00
Nate Begeman 7af15f17b5 Fix a backwards check in the JIT symbol table code
llvm-svn: 51229
2008-05-18 19:09:10 +00:00
Chris Lattner 4b2a724fb8 Fix PR2339
llvm-svn: 51226
2008-05-18 04:11:26 +00:00
Nick Lewycky eb185ca5e9 Revert constant-folding change that will miscompile in some cases.
llvm-svn: 51223
2008-05-17 19:00:05 +00:00
Chris Lattner 1bafa6c886 trip count computation deficiency
llvm-svn: 51222
2008-05-17 15:37:38 +00:00
Nick Lewycky 79d681dddd Unbreak the build.
llvm-svn: 51217
2008-05-17 09:05:22 +00:00
Nick Lewycky 1ba90bb69b Constant fold inttoptr and ptrtoint.
llvm-svn: 51216
2008-05-17 09:03:26 +00:00
Nick Lewycky 79376f4e02 Move isTrueWhenEqual to ICmpInst.
llvm-svn: 51215
2008-05-17 07:33:39 +00:00
Dale Johannesen 5610dabac9 Less conservative verison of previous patch,
suggested by Duncan.

llvm-svn: 51211
2008-05-16 23:18:52 +00:00
Dale Johannesen e7f5bc2c3b Weak functions not declared non-throwing might be
replaced at linktime with a body that throws, even
if the body in this file does not.  Make PruneEH
be more conservative in this case.
g++.dg/eh/weak1.C

llvm-svn: 51207
2008-05-16 21:31:48 +00:00
Eric Christopher 901b1a75c9 Add functions to enable adding a single attribute to a function and
its associated call site.

llvm-svn: 51204
2008-05-16 20:39:43 +00:00
Dale Johannesen 2e1d5e487b Record weak external linkage in a case where we were
missing it. gcc.dg/darwin-weakimport-2.c.
Handle common and weak differently for darwin ppc32.

llvm-svn: 51201
2008-05-16 20:09:25 +00:00
Gabor Greif e1f6e4b21d API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. Legacy interfaces will be in place for some time. (Merge from use-diet branch.)
llvm-svn: 51200
2008-05-16 19:29:10 +00:00
Evan Cheng 9ac3631fa3 If the result of a BIT_CONVERT is a v1* vector, it doesn't mean its source is a v1* vector.
llvm-svn: 51192
2008-05-16 17:19:05 +00:00
Duncan Sands 67933e6692 Bill pointed out that system headers should be
included after local headers.

llvm-svn: 51187
2008-05-16 09:30:00 +00:00
Duncan Sands 70424d195a Silence the compiler warning differently. The
original method caused gcc-4.2 to complain.

llvm-svn: 51186
2008-05-16 09:19:16 +00:00
Evan Cheng 173a53f87c Do not dup malloc, vector instructions, etc. Throttle the default theshold way down.
llvm-svn: 51183
2008-05-16 07:55:50 +00:00
Owen Anderson c7d6eceb69 Remove ADCE's ability to delete loops. This ability is now implemented in a
safer manner by loop deletion.

llvm-svn: 51182
2008-05-16 04:34:51 +00:00
Owen Anderson ad5f211b48 Clean ups for loop deletion based on Chris' feedback.
Also, use SCEV to determine the trip count of the loop, which is more powerful
and accurate that Loop::getTripCount.

llvm-svn: 51179
2008-05-16 04:32:45 +00:00
Chris Lattner 5c953b7d27 implement PR2328.
llvm-svn: 51176
2008-05-16 02:59:42 +00:00
Dale Johannesen 876dd3ca9e Treat common as distinct from weak global on Darwin x86.
llvm-svn: 51172
2008-05-16 00:52:06 +00:00
Dan Gohman 2f156ae850 Revert the change from r51157 in
test/Verifier/2002-11-05-GetelementptrPointers.ll, which was incorrect.
Instead, fix getIndexedType to not follow pointer types, as
PointerType is a subclass of CompositeType.

llvm-svn: 51171
2008-05-16 00:16:32 +00:00
Dan Gohman 0a0fa7cf78 Fix a bug in LoopStrengthReduce that caused it to emit IR with
use-before-def. The problem comes up in code with multiple PHIs where
one PHI is being rewritten in terms of the other, but the other needs
to be casted first. LLVM rules requre the cast instruction to be
inserted after any PHI instructions, but when instructions were
inserted to replace the second PHI value with a function of the first,
they were ended up going before the cast instruction. Avoid this
problem by remembering the location of the cast instruction, when one
is needed, and inserting the expansion of the new value after it.

This fixes a bug that surfaced in 255.vortex on x86-64 when
instcombine was removed from the middle of the loop optimization
passes. 

llvm-svn: 51169
2008-05-15 23:26:57 +00:00
Evan Cheng 29e59ad6c9 Fix typos and comments.
llvm-svn: 51165
2008-05-15 22:13:02 +00:00
Dale Johannesen 6ef726a066 Allow an extra bit for CommonLinkage.
This changes the .bc file format, but if I understand
how it works correctly, old .bc files continue to
be readable.

llvm-svn: 51161
2008-05-15 20:49:28 +00:00
Nate Begeman f79f52282c Actually scalarize the operand to BIT_CONVERT instead of asking someone to do
something with a v1 type.

llvm-svn: 51160
2008-05-15 20:40:58 +00:00
Dan Gohman 12fce7751b IR support for extractvalue and insertvalue instructions. Also, begin
moving toward making structs and arrays first-class types.

llvm-svn: 51157
2008-05-15 19:50:34 +00:00
Dan Gohman f52c8044ea Use static and anonymous namespaces consistently with other passes.
llvm-svn: 51156
2008-05-15 19:43:55 +00:00