Commit Graph

3176 Commits

Author SHA1 Message Date
Dan Gohman
97b6e2cc99 LoopIndexSplit doesn't actually use ScalarEvolution.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64811 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 20:50:11 +00:00
Dan Gohman
60f8a63e25 Add a method to ScalarEvolution for telling it when a loop has been
modified in a way that may effect the trip count calculation. Change
IndVars to use this method when it rewrites pointer or floating-point
induction variables instead of using a doInitialization method to
sneak these changes in before ScalarEvolution has a chance to see
the loop. This eliminates the need for LoopPass to depend on
ScalarEvolution.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64810 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 20:49:49 +00:00
Chris Lattner
a84f47c3e7 commit a tweaked version of Daniel's patch for PR3599. We now
eliminate all the extensions and all but the one required truncate
from the testcase, but the or/and/shift stuff still isn't zapped.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64809 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 20:47:23 +00:00
Dan Gohman
cafb81337b Delete trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64784 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 19:13:57 +00:00
Dan Gohman
a575871884 Fix 80-column violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64766 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 15:57:39 +00:00
Evan Cheng
5a6c1a840a Strengthen the "non-constant stride must dominate loop preheader" check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64703 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 00:13:06 +00:00
Dan Gohman
1a5e936c53 Simplify; fix some 80-column violations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 00:10:53 +00:00
Dan Gohman
ecd0fb51cb Fix EnforceKnownAlignment so that it doesn't ever reduce the alignment
of an alloca or global variable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64693 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 23:02:21 +00:00
Dan Gohman
ebcd4af387 Delete this long-commented-out code. The situation it seems to have
been written for is no longer relevant with the elimination of
signed and unsigned types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64625 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 02:57:42 +00:00
Dan Gohman
926b0a27b9 Change these tests to use regular loads instead of llvm.x86.sse2.loadu.dq.
Enhance instcombine to use the preferred field of
GetOrEnforceKnownAlignment in more cases, so that regular IR operations are
optimized in the same way that the intrinsics currently are.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64623 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 00:44:23 +00:00
Nick Lewycky
225f747486 Update the list of function annotations for nocapture. All of these came up
when I was looking at functions used by python.

Highlights include, better largefile support (64-bit file sizes on 32-bit
systems), fputs string is nocapture, popen/pclose added (popen being noalias
return), modf and frexp and friends. Also added some missing 'break' statements
and combined identical sections.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64615 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 22:47:25 +00:00
Evan Cheng
8f40afe62d Fix pr3571: If stride is a value defined by an instruction, make sure it dominates the loop preheader. When IV users are strength reduced, the stride is inserted into the preheader. It could create a use before def situation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64579 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 06:06:15 +00:00
Evan Cheng
f8546f10c2 ifdef out unneeded if statement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64575 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 03:20:37 +00:00
Dan Gohman
aa03649af2 Extend the IndVarSimplify support for promoting induction variables:
- Test for signed and unsigned wrapping conditions, instead of just
   testing for non-negative induction ranges. 
 - Handle loops with GT comparisons, in addition to LT comparisons.
 - Support more cases of induction variables that don't start at 0.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64532 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14 02:31:09 +00:00
Dan Gohman
f108e2eaaa Clarify debug output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64531 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14 02:26:50 +00:00
Dan Gohman
cd3eb9b098 Simplify some code. hasComputableLoopEvolution is overkill in this case.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64530 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14 02:25:19 +00:00
Dan Gohman
03ce042d70 In CodeGenPrepare's debug output, use WriteAsOperand instead of
printing getName(), so that unnamed values are printed correctly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64468 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 17:45:12 +00:00
Dan Gohman
e698696569 Complete the sentance in this comment. I have reservations
about the code it describes, but at least now the comment
is right.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64465 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 17:36:42 +00:00
Nick Lewycky
02b6a6a75f Mark strto* as readonly when the endptr is null.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64460 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 17:08:33 +00:00
Nick Lewycky
4c49841f34 On strtod and friends, mark 'endptr' nocapture in the function prototype, and
mark the first argument nocapture if endptr=NULL for each particular call.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64453 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 15:31:46 +00:00
Dan Gohman
9194e8b0c8 Fix the code that checked if a SCEVAddRecExpr Start contains an
addrec in a different loop to check the value being added to
the accumulated Start value, not the Start value before it has
the new value added to it. This prevents LSR from going crazy
on the included testcase. Dale, please review.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64440 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 03:58:31 +00:00
Dan Gohman
bc511725f0 Fix LSR's IV sorting function to explicitly sort by bitwidth
after sorting by stride value. This prevents it from missing
IV reuse opportunities in a host-sensitive manner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64415 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 00:26:43 +00:00
Dan Gohman
c2390b14c9 Teach IndVarSimplify to optimize code using the C "int" type for
loop induction on LP64 targets. When the induction variable is
used in addressing, IndVars now is usually able to inserst a
64-bit induction variable and eliminates the sign-extending cast.
This is also useful for code using C "short" types for
induction variables on targets with 32-bit addressing.

Inserting a wider induction variable is easy; the tricky part is
determining when trunc(sext(i)) expressions are no-ops. This
requires range analysis of the loop trip count. A common case is
when the original loop iteration starts at 0 and exits when the
induction variable is signed-less-than a fixed value; this case
is now handled.

This replaces IndVarSimplify's OptimizeCanonicalIVType. It was
doing the same optimization, but it was limited to loops with
constant trip counts, because it was running after the loop
rewrite, and the information about the original induction
variable is lost by that point.

Rename ScalarEvolution's executesAtLeastOnce to
isLoopGuardedByCond, generalize it to be able to test for
ICMP_NE conditions, and move it to be a public function so that
IndVars can use it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64407 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 22:19:27 +00:00
Dan Gohman
c83324682f Add a utility function to LoopInfo to return the exit block
when the loop has exactly one exit, and make use of it in
LoopIndexSplit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64388 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 18:08:24 +00:00
Dan Gohman
d0ffa73924 This code doesn't actually use the ExitingBlocks list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64376 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 16:36:26 +00:00
Chris Lattner
0aefc0eb2c improve naming of values in GVN, patch by Jay Foad!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64363 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 07:00:35 +00:00
Chris Lattner
65c02fbf9b fix PR3537: if resetting bbi back to the start of a block, we need to
forget about already inserted expressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64362 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 06:56:08 +00:00
Nick Lewycky
b7c9eeeede Don't mark all args to strtod and friends as nocapture.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64352 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 03:18:34 +00:00
Nate Begeman
7b25467d06 the two non-mask arguments to a shufflevector must be the same width, but they do not have to be the same
width as the result value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64335 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-11 22:36:25 +00:00
Devang Patel
7afe8fa066 Use early exits. Reduce indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64226 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-10 19:28:07 +00:00
Devang Patel
4afc90dacf Enable scalar replacement of AllocaInst whose one of the user is dbg info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64207 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-10 07:00:59 +00:00
Dale Johannesen
1de17d574c Fix PR 3471, and some cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64177 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-09 22:14:15 +00:00
Bill Wendling
b805030e02 Mistakenly turned this on.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64065 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-08 01:32:00 +00:00
Bill Wendling
7f51fd3ea9 Revert r63999. It was breaking self-hosting builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64062 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-08 00:58:05 +00:00
Mon P Wang
6753f959d2 Instrcombine should not change load(cast p) to cast(load p) if the cast
changes the address space of the pointer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64035 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 22:19:29 +00:00
Mike Stump
f344d83d39 Insert space to avoid warning and make code more readable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64003 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 03:36:02 +00:00
Devang Patel
d96c60df3f Ignore DbgInfoIntrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63923 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 06:19:06 +00:00
Chris Lattner
e991ced7cb fix PR3489, use bits instead of bytes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63916 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 04:34:07 +00:00
Devang Patel
32d9701d68 Ignore dbg intrinsics while propagating conditional expression info. Take 2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63898 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05 23:32:52 +00:00
Devang Patel
998cbb0444 Revert rev. 63876. It is causing llvm-gcc bootstrap failure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63888 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05 21:46:41 +00:00
Devang Patel
39c873e38f Remove dead blocks in the end.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63880 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05 19:59:42 +00:00
Devang Patel
1851db6b0f Ignore dbg intrinsics while propagating conditional expression info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63876 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05 19:15:39 +00:00
Devang Patel
28aa5de050 If "optimize for size" attribute is set then block non-trivial loop unswitches but allow trivial loop unswitches.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63670 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 22:04:27 +00:00
Chris Lattner
1aa7056b13 teach "convert from scalar" to handle loads of fca's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63659 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 21:08:45 +00:00
Chris Lattner
6e01115bb1 refactor the interface to ConvertUsesOfLoadToScalar,
renaming it to ConvertScalar_ExtractValue


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63658 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 21:01:03 +00:00
Chris Lattner
9bc67da0a9 convert ConvertUsesOfLoadToScalar to use IRBuilder,
no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63652 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 19:45:44 +00:00
Chris Lattner
65a650291d switch ConvertScalar_InsertValue to use an IRBuilder, no
functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63651 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 19:41:50 +00:00
Chris Lattner
9b872db775 make scalar conversion handle stores of first class
aggregate values.  loads are not yet handled (coming
soon to an sroa near you).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63649 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 19:30:11 +00:00
Chris Lattner
1a3257bbf5 Make SROA produce a vector only when the alloca is actually
accessed at least once as a vector.  This prevents it from
compiling the example in not-a-vector into:

define double @test(double %A, double %B) {
	%tmp4 = insertelement <7 x double> undef, double %A, i32 0
	%tmp = insertelement <7 x double> %tmp4, double %B, i32 4
	%tmp2 = extractelement <7 x double> %tmp, i32 4
	ret double %tmp2
}

instead, producing the integer code.  Producing vectors when they
aren't otherwise in the program is dangerous because a lot of other
code treats them carefully and doesn't want to break them down.
OTOH, many things want to break down tasty i448's.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63638 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 18:15:05 +00:00
Evan Cheng
388df627cc APInt'fy SimplifyDemandedVectorElts so it can analyze vectors with more than 64 elements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63631 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 10:05:09 +00:00
Chris Lattner
55a683d7f0 add another case of undefined behavior without crashing, PR3466.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63620 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 07:08:57 +00:00
Chris Lattner
3d730f7453 Teach ConvertUsesToScalar to handle memset, allowing it to handle
crazy cases like:

struct f {  int A, B, C, D, E, F; };
short test4() {
  struct f A;
  A.A = 1;
  memset(&A.B, 2, 12);
  return A.C;
}



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63596 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 02:01:43 +00:00
Chris Lattner
7809ecd5b0 rearrange how SRoA handles promotion of allocas to vectors.
With the new world order, it can handle cases where the first
store into the alloca is an element of the vector, instead of
requiring the first analyzed store to have the vector type 
itself.  This allows us to un-xfail 
test/CodeGen/X86/vec_ins_extract.ll.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63590 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 01:30:09 +00:00
Chris Lattner
15c8277903 inline SROA::ConvertToScalar, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63544 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-02 20:44:45 +00:00
Chris Lattner
996d7a97f9 Fix a bug which caused us to miscompile a couple of Ada
tests.  Thanks for the beautiful reduced testcase Duncan!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63529 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-02 18:02:59 +00:00
Duncan Sands
4b3dfbd220 Fix a comment (bytes -> bits), reformat a comment
and remove trailing whitespace.  No functionality
change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63511 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-02 10:06:20 +00:00
Duncan Sands
0e7c46bc7e Fix an obvious thinko.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-02 09:53:14 +00:00
Chris Lattner
f5db1fbf7a reduce indentation, (~XorCST->getValue()).isSignBit() -> isMaxSignedValue()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-02 07:15:30 +00:00
Nick Lewycky
4333f49afe Reinstate this optimization to fold icmp of xor when possible. Don't try to
turn icmp eq a+x, b+x into icmp eq a, b if a+x or b+x has other uses. This
may have been increasing register pressure leading to the bzip2 slowdown.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63487 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-31 21:30:05 +00:00
Chris Lattner
39c27eddc5 Fix PR3452 (an infinite loop bootstrapping) by disabling the recent
improvements to the EvaluateInDifferentType code.  This code works 
by just inserted a bunch of new code and then seeing if it is 
useful.  Instcombine is not allowed to do this: it can only insert
new code if it is useful, and only when it is converging to a more
canonical fixed point.  Now that we iterate when DCE makes progress,
this causes an infinite loop when the code ends up not being used.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63483 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-31 19:05:27 +00:00
Chris Lattner
d1b5e3fad9 now that all the pieces are in place, teach instcombine's
simplifydemandedbits to simplify instructions with *multiple
uses* in contexts where it can get away with it.  This allows
it to simplify the code in multi-use-or.ll into a single 'add 
double'.

This change is particularly interesting because it will cover
up for some common codegen bugs with large integers created due
to the recent SROA patch.  When working on fixing those bugs,
this should be disabled.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63481 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-31 08:40:03 +00:00
Chris Lattner
4598c943c0 simplify/clarify control flow and improve comments, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63480 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-31 08:24:16 +00:00
Chris Lattner
886ab6c49c make some fairly meaty internal changes to how SimplifyDemandedBits works.
Now, if it detects that "V" is the same as some other value, 
SimplifyDemandedBits returns the new value instead of RAUW'ing it immediately.
This has two benefits:
1) simpler code in the recursive SimplifyDemandedBits routine.
2) it allows future fun stuff in instcombine where an operation has multiple
   uses and can be simplified in one context, but not all.

#2 isn't implemented yet, this patch should have no functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63479 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-31 08:15:18 +00:00
Chris Lattner
08d2cc70fe minor cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63477 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-31 07:26:06 +00:00
Chris Lattner
1e19d603e0 make sure to set Changed=true when instcombine hacks on the code,
not doing so prevents it from properly iterating and prevents it
from deleting the entire body of dce-iterate.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63476 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-31 07:04:22 +00:00
Chris Lattner
2e0d5f8432 Simplify and generalize the SROA "convert to scalar" transformation to
be able to handle *ANY* alloca that is poked by loads and stores of 
bitcasts and GEPs with constant offsets.  Before the code had a number
of annoying limitations and caused it to miss cases such as storing into
holes in structs and complex casts (as in bitfield-sroa) where we had
unions of bitfields etc.  This also handles a number of important cases
that are exposed due to the ABI lowering stuff we do to pass stuff by
value.

One case that is pretty great is that we compile 
2006-11-07-InvalidArrayPromote.ll into:

define i32 @func(<4 x float> %v0, <4 x float> %v1) nounwind {
	%tmp10 = call <4 x i32> @llvm.x86.sse2.cvttps2dq(<4 x float> %v1)
	%tmp105 = bitcast <4 x i32> %tmp10 to i128
	%tmp1056 = zext i128 %tmp105 to i256	
	%tmp.upgrd.43 = lshr i256 %tmp1056, 96
	%tmp.upgrd.44 = trunc i256 %tmp.upgrd.43 to i32	
	ret i32 %tmp.upgrd.44
}

which turns into:

_func:
	subl	$28, %esp
	cvttps2dq	%xmm1, %xmm0
	movaps	%xmm0, (%esp)
	movl	12(%esp), %eax
	addl	$28, %esp
	ret

Which is pretty good code all things considering :).

One effect of this is that SROA will start generating arbitrary bitwidth 
integers that are a multiple of 8 bits.  In the case above, we got a 
256 bit integer, but the codegen guys assure me that it can handle the 
simple and/or/shift/zext stuff that we're doing on these operations.

This addresses rdar://6532315



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63469 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-31 02:28:54 +00:00
Chris Lattner
6e733d34ca Fix some issues with volatility, move "CanConvertToScalar" check
after the others.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63227 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 20:16:43 +00:00
Duncan Sands
1465d61bdd Rename getAnalysisToUpdate to getAnalysisIfAvailable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63198 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 13:14:17 +00:00
Mon P Wang
fe6d2cd9d1 Fixed optimization of combining two shuffles where the first shuffle inputs
has a different number of elements than the output.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62998 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 04:39:00 +00:00
Chris Lattner
18f02318a6 Handle single-entry phi nodes gracefully in condprop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62985 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 02:18:20 +00:00
Chris Lattner
3796a262c5 Fix PR3408 by making a non-obvious assumption very obvious, and
handling the flaw inherent in that assumption.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62984 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 02:11:30 +00:00
Chris Lattner
f6784a3262 More cleanups and simplifications, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62983 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 01:57:01 +00:00
Chris Lattner
2ba2543df2 tidy asserts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62982 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 01:38:24 +00:00
Torok Edwin
08ffee539e testcase for PR3381.
Also it was an empty struct, not a void after all.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62920 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-24 17:16:04 +00:00
Torok Edwin
629e92b63b void* is represented as pointer to empty struct {}.
Thus we need to check whether the struct is empty before trying to index into
it. This fixes PR3381.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62918 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-24 11:30:49 +00:00
Chris Lattner
3914f721cc Make InstCombineStoreToCast handle aggregates more aggressively,
handling the case in Transforms/InstCombine/cast-store-gep.ll, which
is a heavily reduced testcase from Clang on x86-64.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62904 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-24 01:00:13 +00:00
Gabor Greif
a36791da41 Simplify the logic of getting hold of a PHI predecessor block.
There is now a direct way from value-use-iterator to incoming block in PHINode's API.
This way we avoid the iterator->index->iterator trip, and especially the costly
getOperandNo() invocation. Additionally there is now an assertion that the iterator
really refers to one of the PHI's Uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62869 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23 19:40:15 +00:00
Chris Lattner
455e9abf36 Remove uses of uint32_t in favor of 'unsigned' for better
compatibility with cygwin.  Patch by Jay Foad!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62695 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 18:09:24 +00:00
Dale Johannesen
ed6af24e14 Make special cases (0 inf nan) work for frem.
Besides APFloat, this involved removing code
from two places that thought they knew the
result of frem(0., x) but were wrong.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62645 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 00:35:19 +00:00
Chris Lattner
2f39b29170 improve compatibility with cygwin, patch by Jay Foad!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62535 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 22:00:18 +00:00
Chris Lattner
2c7ed11d93 Fix PR3353, infinitely jump threading an infinite loop make from switches.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62529 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 21:20:34 +00:00
Chris Lattner
d62284a804 Fix rdar://6505632, an llc crash on 483.xalancbmk
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62470 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 20:35:00 +00:00
Nick Lewycky
0b6679d32f Fix copy and pasted typos that prevented strtok_r, realloc, getenv, ungetc,
putc, puts, perror, vscanf and vsscanf from getting annotations.

Add annotations for eight printf functions, memalign, pread and pwrite.

On Linux, llvm-gcc sometimes renames strdup, getc, putc, strtok_r, scanf and
sscanf. Match the alternate function names.

Fix a crash annotating opendir.

Don't mark fsetpos's second parameter as nocapture. It's supposed to be
captured.

Do mark fopen's path and mode strings as nocapture. Mark ferror as readonly,
but not fileno which may set errno.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62456 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 04:34:36 +00:00
Chris Lattner
71759c491c Fix PR3335 by not turning a store to one address space into a store to another.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62351 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 20:12:52 +00:00
Chris Lattner
1b8eaf5109 reduce indentation by using early exits, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62350 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 20:08:59 +00:00
Evan Cheng
4e56ab2cf4 Clean up previous cast optimization a bit. Also make zext elimination a bit more aggressive: if it's not necessary to emit an AND (i.e. high bits are already zero), it's profitable to evaluate the operand at a different type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62297 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 02:11:43 +00:00
Rafael Espindola
bb46f52027 Add the private linkage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62279 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 20:18:42 +00:00
Evan Cheng
661d9c35b0 Eliminate a redundant check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62264 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 17:09:07 +00:00
Evan Cheng
f35fd547ac - Teach CanEvaluateInDifferentType of this xform: sext (zext ty1), ty2 -> zext ty2
- Looking at the number of sign bits of the a sext instruction to determine  whether new trunc + sext pair should be added when its source is being evaluated in a different type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62263 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 17:01:23 +00:00
Chris Lattner
d9d46241ec Fix PR3325, a miscompilation of invokes by IPSCCP. Patch by Jay Foad!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62244 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-14 21:01:16 +00:00
Dale Johannesen
2f46bb8178 Fix the time regression I introduced in 464.h264ref with
my earlier patch to this file.

The issue there was that all uses of an IV inside a loop
are actually references to Base[IV*2], and there was one
use outside that was the same but LSR didn't see the base
or the scaling because it didn't recurse into uses outside
the loop; thus, it used base+IV*scale mode inside the loop
instead of pulling base out of the loop.  This was extra bad
because register pressure later forced both base and IV into
memory.  Doing that recursion, at least enough
to figure out addressing modes, is a good idea in general;
the change in AddUsersIfInteresting does this.  However,
there were side effects....

It is also possible for recursing outside the loop to
introduce another IV where there was only 1 before (if
the refs inside are not scaled and the ref outside is).
I don't think this is a common case, but it's in the testsuite.
It is right to be very aggressive about getting rid of
such introduced IVs (CheckForIVReuse and the handling of
nonzero RewriteFactor in StrengthReduceStridedIVUsers).
In the testcase in question the new IV produced this way
has both a nonconstant stride and a nonzero base, neither
of which was handled before.  And when inserting 
new code that feeds into a PHI, it's right to put such 
code at the original location rather than in the PHI's 
immediate predecessor(s) when the original location is outside 
the loop (a case that couldn't happen before)
(RewriteInstructionToUseNewBase); better to avoid making
multiple copies of it in this case.

Also, the mechanism for keeping SCEV's corresponding to GEP's
no longer works, as the GEP might change after its SCEV
is remembered, invalidating the SCEV, and we might get a bad
SCEV value when looking up the GEP again for a later loop.  
This also couldn't happen before, as we weren't recursing
into GEP's outside the loop.

Also, when we build an expression that involves a (possibly
non-affine) IV from a different loop as well as an IV from
the one we're interested in (containsAddRecFromDifferentLoop),
don't recurse into that.  We can't do much with it and will
get in trouble if we try to create new non-affine IVs or something.

More testcases are coming.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62212 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-14 02:35:31 +00:00
Dan Gohman
6893cd7615 Make instcombine ensure that all allocas are explicitly aligned at at
least their preferred alignment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 20:18:38 +00:00
Duncan Sands
ceb4d1aecb Rename getABITypeSize to getTypePaddedSize, as
suggested by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62099 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12 20:38:59 +00:00
Chris Lattner
31a69cb9ae Duncan is nervous about undefinedness of % with negatives. I'm
not thrilled about 64-bit % in general, so rewrite to use * instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62047 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 20:41:36 +00:00
Chris Lattner
1c412d9ce4 do not generated GEPs into vectors where they don't already exist.
We should treat vectors as atomic types, not like arrays.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62046 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 20:23:52 +00:00
Chris Lattner
dbc3bc2585 Make a couple of cleanups to the instcombine bitcast/gep
canonicalization transform based on duncan's comments:

1) improve the comment about %.
2) within our index loop make sure the offset stays 
   within the *type size*, instead of within the *abi size*.
   This allows us to reason explicitly about landing in tail
   padding and means that issues like non-zero offsets into
   [0 x foo] types don't occur anymore.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62045 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 20:15:20 +00:00
Chris Lattner
ed78f431ed fix typo Duncan noticed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61997 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 18:31:39 +00:00
Chris Lattner
583dd6072e Fix PR3304
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61995 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 18:18:43 +00:00
Misha Brukman
9b8f542e27 Removed trailing whitespace from Makefiles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 16:44:42 +00:00
Chris Lattner
a80d668215 Implement rdar://6480391, extending of equality icmp's to avoid a truncation.
I noticed this in the code compiled for a routine using std::map, which produced
this code:
	%25 = tail call i32 @memcmp(i8* %24, i8* %23, i32 6) nounwind readonly
	%.lobit.i = lshr i32 %25, 31		; <i32> [#uses=1]
	%tmp.i = trunc i32 %.lobit.i to i8		; <i8> [#uses=1]
	%toBool = icmp eq i8 %tmp.i, 0		; <i1> [#uses=1]
	br i1 %toBool, label %bb3, label %bb4
which compiled to:

	call	L_memcmp$stub
	shrl	$31, %eax
	testb	%al, %al
	jne	LBB1_11	## 

with this change, we compile it to:

	call	L_memcmp$stub
	testl	%eax, %eax
	js	LBB1_11

This triggers all the time in common code, with patters like this:

	%169 = and i32 %ply, 1		; <i32> [#uses=1]
	%170 = trunc i32 %169 to i8		; <i8> [#uses=1]
	%toBool = icmp ne i8 %170, 0		; <i1> [#uses=1]

 	%7 = lshr i32 %6, 24		; <i32> [#uses=1]
	%9 = trunc i32 %7 to i8		; <i8> [#uses=1]
	%10 = icmp ne i8 %9, 0		; <i1> [#uses=1]

etc



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61985 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 07:47:06 +00:00
Chris Lattner
6d6b410698 Remove some old code that looks like a remanant from signed-types days.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61984 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 07:10:58 +00:00
Chris Lattner
2a99b482a6 Fix PR3298, a crash in Jump Threading. Apparently even
jump threading can have bugs, who knew? ;-)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61983 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 06:08:12 +00:00
Chris Lattner
46cd5a13e5 Fix part 3/2 of PR3290, making instcombine zap (gep(bitcast)) when possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61980 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 05:44:56 +00:00
Chris Lattner
5840779cc9 move some code, check to see if the input to the GEP is a bitcast
(which is constant time and cheap) before checking hasAllZeroIndices.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61976 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 04:53:57 +00:00
Chris Lattner
5ffe6acd57 This implements the second half of the fix for PR3290, handling
loads from allocas that cover the entire aggregate.  This handles
some memcpy/byval cases that are produced by llvm-gcc.  This triggers
a few times in kc++ (with std::pair<std::_Rb_tree_const_iterator
<kc::impl_abstract_phylum*>,bool>) and once in 176.gcc (with %struct..0anon).




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61915 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-08 05:42:05 +00:00
Chris Lattner
d2fa781169 Implement the first half of PR3290: if there is a store of an
integer to a (transitive) bitcast the alloca and if that integer
has the full size of the alloca, then it clobbers the whole thing.
Handle this by extracting pieces out of the stored integer and 
filing them away in the SROA'd elements.

This triggers fairly frequently because the CFE uses integers to
pass small structs by value and the inliner exposes these.  For 
example, in kimwitu++, I see a bunch of these with i64 stores to
"%struct.std::pair<std::_Rb_tree_const_iterator<kc::impl_abstract_phylum*>,bool>"

In 176.gcc I see a few i32 stores to "%struct..0anon".

In the testcase, this is a difference between compiling test1 to:

_test1:
	subl	$12, %esp
	movl	20(%esp), %eax
	movl	%eax, 4(%esp)
	movl	16(%esp), %eax
	movl	%eax, (%esp)
	movl	(%esp), %eax
	addl	4(%esp), %eax
	addl	$12, %esp
	ret

vs:

_test1:
	movl	8(%esp), %eax
	addl	4(%esp), %eax
	ret

The second half of this will be to handle loads of the same form.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61853 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 08:11:13 +00:00
Chris Lattner
d93afec1db Factor a bunch of code out into a helper method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61852 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 07:18:45 +00:00
Chris Lattner
cf32186409 use continue to simplify code and reduce nesting, no functionality
change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61851 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 06:39:58 +00:00
Chris Lattner
56c3852fb4 Get TargetData once up front and cache as an ivar instead of
requerying it all over the place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61850 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 06:34:28 +00:00
Chris Lattner
d356a7ee0e Use the hasAllZeroIndices predicate to simplify some
code, no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61849 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07 06:25:07 +00:00
Chris Lattner
159c35b3ee Change m_ConstantInt and m_SelectCst to take their constant integers
as template arguments instead of as instance variables, exposing more
optimization opportunities to the compiler earlier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61776 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05 23:53:12 +00:00
Evan Cheng
7e66c0d43a Find loop back edges only after empty blocks are eliminated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61752 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05 21:17:27 +00:00
Nick Lewycky
6cd0c048b8 Move the libcall annotating part from doFinalization to doInitialization.
Finalization occurs after all the FunctionPasses in the group have run, which
is clearly not what we want.

This also means that we have to make sure that we apply the right param 
attributes when creating a new function.

Also, add a missed optimization: strdup and strndup. NoCapture and 
NoAlias return!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61658 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05 00:07:50 +00:00
Nick Lewycky
0f8df9a9ce Run a post-pass that marks known function declarations by name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61632 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-04 20:27:34 +00:00
Bill Wendling
d3d69781d3 Revert this transform. It was causing some dramatic slowdowns in a few tests. See PR3266.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61623 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-04 06:19:11 +00:00
Bill Wendling
94f0a38a00 Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61538 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-01 01:19:59 +00:00
Bill Wendling
3479be91c4 Add transformation:
xor (or (icmp, icmp), true) -> and(icmp, icmp)

This is possible because of De Morgan's law.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61537 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-01 01:18:23 +00:00
Dale Johannesen
f6727b01a5 Revert 61362 and 61402 until SPEC breakage is fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61403 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 23:21:35 +00:00
Dale Johannesen
2fa2517324 This fixes the bug in 175.vpr. It doesn't fix the
other SPEC breakage.  I'll be reverting all recent
changes shortly, this checking is mostly so this
change doesn't get lost.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61402 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 23:05:26 +00:00
Dale Johannesen
e6ec25543f Fix the time regression I introduced in 464.h264ref with
my last patch to this file.

The issue there was that all uses of an IV inside a loop
are actually references to Base[IV*2], and there was one
use outside that was the same but LSR didn't see the base
or the scaling because it didn't recurse into uses outside
the loop; thus, it used base+IV*scale mode inside the loop
instead of pulling base out of the loop.  This was extra bad
because register pressure later forced both base and IV into
memory.  Doing that recursion, at least enough
to figure out addressing modes, is a good idea in general;
the change in AddUsersIfInteresting does this.  However,
there were side effects....

It is also possible for recursing outside the loop to
introduce another IV where there was only 1 before (if
the refs inside are not scaled and the ref outside is).
I don't think this is a common case, but it's in the testsuite.
It is right to be very aggressive about getting rid of
such introduced IVs (CheckForIVReuse and the handling of
nonzero RewriteFactor in StrengthReduceStridedIVUsers).
In the testcase in question the new IV produced this way
has both a nonconstant stride and a nonzero base, neither
of which was handled before.  And when inserting 
new code that feeds into a PHI, it's right to put such 
code at the original location rather than in the PHI's 
immediate predecessor(s) when the original location is outside 
the loop (a case that couldn't happen before)
(RewriteInstructionToUseNewBase); better to avoid making
multiple copies of it in this case.

Also, the mechanism for keeping SCEV's corresponding to GEP's
no longer works, as the GEP might change after its SCEV
is remembered, invalidating the SCEV, and we might get a bad
SCEV value when looking up the GEP again for a later loop.  
This also couldn't happen before, as we weren't recursing
into GEP's outside the loop.

I owe some testcases for this, want to get it in for nightly runs.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61362 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 02:12:52 +00:00
Owen Anderson
ae53c932b9 Don't forget to remove phi nodes from the value numbering table after we collapse them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61358 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 00:49:51 +00:00
Bill Wendling
30788b828a Comment clean-ups. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61354 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 22:32:22 +00:00
Bill Wendling
6d463f2efc Check that the instruction isn't in the value numbering scope.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61353 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 22:28:56 +00:00
Bill Wendling
75f02ee771 Simplification: Negate the operator== method instead of implementing a full operator!= method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61352 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 22:16:31 +00:00
Bill Wendling
70ded19b3f Add verification that deleted instruction isn't hiding in the PHI map.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61350 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 22:14:07 +00:00
Bill Wendling
ec40d50aa4 Verify removed in a few more places.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61349 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 21:57:30 +00:00
Bill Wendling
246dbbb8be Add verification functions to GVN which check to see that an instruction was
truely deleted. These will be expanded with further checks of all of the data
structures.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61347 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-22 21:36:08 +00:00
Nick Lewycky
13a09e298c Turn strcmp into memcmp, such as strcmp(P, "x") --> memcmp(P, "x", 2).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61297 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-21 00:19:21 +00:00
Nick Lewycky
9dce873c1a Remove redundant test for vector-nature. Scan the vector first to see whether
our optz'n will apply to it, then build the replacement vector only if needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61279 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-20 16:48:00 +00:00
Evan Cheng
ab63152871 - CodeGenPrepare does not split loop back edges but it only knows about back edges of single block loops. It now does a DFS walk to find loop back edges.
- Use SplitBlockPredecessors to factor out common predecessors of the critical edge destination. This is disabled for now due to some regressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61248 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-19 18:03:11 +00:00
Bill Wendling
e533f4e343 Didn't mean to commit this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61222 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 22:19:50 +00:00
Bill Wendling
82c19ae10a Re-XFAIL this test until debug stuff settles down.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61219 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 22:13:31 +00:00
Nick Lewycky
19c2892677 Oops! Left out a line.
Simplifying the sdiv might allow further simplifications for our users.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61196 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 06:42:28 +00:00
Nick Lewycky
2a8f6597a3 Make all the vector elements positive in an srem of constant vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61195 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 06:31:11 +00:00
Dale Johannesen
a1d9cb1d46 Revert previous patch, appears to break bootstrap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61181 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 01:23:41 +00:00
Dale Johannesen
12b882cf53 Fix the time regression I introduced in 464.h264ref with
my last patch to this file.

The issue there was that all uses of an IV inside a loop
are actually references to Base[IV*2], and there was one
use outside that was the same but LSR didn't see the base
or the scaling because it didn't recurse into uses outside
the loop; thus, it used base+IV*scale mode inside the loop
instead of pulling base out of the loop.  This was extra bad
because register pressure later forced both base and IV into
memory.  Doing that recursion, at least enough
to figure out addressing modes, is a good idea in general;
the change in AddUsersIfInteresting does this.  However,
there were side effects....

It is also possible for recursing outside the loop to
introduce another IV where there was only 1 before (if
the refs inside are not scaled and the ref outside is).
I don't think this is a common case, but it's in the testsuite.
It is right to be very aggressive about getting rid of
such introduced IVs (CheckForIVReuse and the handling of
nonzero RewriteFactor in StrengthReduceStridedIVUsers).
In the testcase in question the new IV produced this way
has both a nonconstant stride and a nonzero base, neither
of which was handled before.  (This patch does not handle 
all the cases where this can happen.)  And when inserting 
new code that feeds into a PHI, it's right to put such 
code at the original location rather than in the PHI's 
immediate predecessor(s) when the original location is outside 
the loop (a case that couldn't happen before)
(RewriteInstructionToUseNewBase); better to avoid making
multiple copies of it in this case.

Everything above is exercised in
CodeGen/X86/lsr-negative-stride.ll (and ifcvt4 in ARM which is
the same IR).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61178 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 00:57:22 +00:00
Chris Lattner
5f4f84ba3e reapply this hunk from Bill's reversion in r61169, it is conservative
and safe and orthogonal from turning off load pre.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61177 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 00:51:32 +00:00
Bill Wendling
13d10096e1 Temporarily revert r61027. It was causing a bootstrap failure in "release" mode
with everyone's favorite error messages:

Comparing stages 2 and 3
warning: ./cc1-checksum.o differs
warning: ./cc1plus-checksum.o differs
Bootstrap comparison failure!
./c-decl.o differs
./cp/decl.o differs
./df-core.o differs
./gcc.o differs
./i386.o differs
./stor-layout.o differs
./tree-pretty-print.o differs
./tree.o differs
make[2]: *** [compare] Error 1
make[1]: *** [stage3-bubble] Error 2

See PR3227.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61169 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-17 23:31:20 +00:00
Dale Johannesen
b0390620d4 Clarify that the scale factor from CheckForIVReuse
can be negative.  Keep track of whether all uses of
an IV are outside the loop.  Some cosmetics; no
functional change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61109 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-16 22:16:28 +00:00
Chris Lattner
2ba3b62149 Enable Load PRE. This teaches GVN to push partially redundant loads up the
CFG when there is exactly one predecessor where the load is not available.
This is designed to not increase code size but still eliminate partially
redundant loads.  This fires 1765 times on 403.gcc even though it doesn't
do critical edge splitting yet (the most common reason for it to fail).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61027 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 05:28:29 +00:00
Owen Anderson
c34d112362 Ifdef out some code that I didn't mean to enable by default yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61024 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 03:52:17 +00:00
Chris Lattner
f33131685b make GVN try to rename inputs to the resultant replaced values, which
cleans up the generated code a bit.  This should have the added benefit of
not randomly renaming functions/globals like my previous patch did. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61023 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 03:46:38 +00:00
Owen Anderson
255dafc5de Add support for slow-path GVN with full phi construction for scalars. This is disabled for now, as it actually pessimizes code in the abscence
of phi translation for load elimination.  This slow down GVN a bit, by about 2% on 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61021 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 02:03:00 +00:00
Chris Lattner
528f16b9fa eliminate warning when asserts disabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61012 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-14 21:36:23 +00:00
Owen Anderson
cbe1d94031 Generalize GVN's phi construciton routine to work for things other than loads.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61009 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-14 19:10:35 +00:00
Bill Wendling
8295e49e76 Temporarily revert r60973. It's inexplicably causing a failure when self-hosting LLVM:
llvm[2]: Linking Release executable opt (without symbols)
...
Undefined symbols:
  "llvm::APFloat::IEEEsingle", referenced from:
      __ZN4llvm7APFloat10IEEEsingleE$non_lazy_ptr in libLLVMCore.a(Constants.o)
      __ZN4llvm7APFloat10IEEEsingleE$non_lazy_ptr in libLLVMCore.a(AsmWriter.o)
      __ZN4llvm7APFloat10IEEEsingleE$non_lazy_ptr in libLLVMCore.a(ConstantFold.o)
  "llvm::APFloat::IEEEdouble", referenced from:
      __ZN4llvm7APFloat10IEEEdoubleE$non_lazy_ptr in libLLVMCore.a(Constants.o)
      __ZN4llvm7APFloat10IEEEdoubleE$non_lazy_ptr in libLLVMCore.a(AsmWriter.o)
      __ZN4llvm7APFloat10IEEEdoubleE$non_lazy_ptr in libLLVMCore.a(ConstantFold.o)
ld: symbol(s) not found

This is in release mode. To replicate, compile llvm and llvm-gcc in optimized
mode. Then build llvm, in optimized mode, with the newly created compiler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60977 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-13 09:28:44 +00:00
Chris Lattner
879922932f make RLE preserve the name of the load that it replaces. This is just
a pretification of the IR.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60973 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-13 07:22:47 +00:00
Chris Lattner
bc99be10b8 Teach GVN to invalidate some memdep information when it does an RAUW
of a pointer.  This allows is to catch more equivalencies.  For example,
the type_lists_compatible_p function used to require two iterations of
the gvn pass (!) to delete its 18 redundant loads because the first pass
would CSE all the addressing computation cruft, which would unblock the
second memdep/gvn passes from recognizing them.  This change allows
memdep/gvn to catch all 18 when run just once on the function (as is 
typical :) instead of just 3.

On all of 403.gcc, this bumps up the # reundandancies found from:

     63 gvn    - Number of instructions PRE'd
 153991 gvn    - Number of instructions deleted
  50069 gvn    - Number of loads deleted
to:
     63 gvn    - Number of instructions PRE'd
 154137 gvn    - Number of instructions deleted
  50185 gvn    - Number of loads deleted

+120 loads deleted isn't bad.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60799 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 22:06:23 +00:00
Chris Lattner
1559b3625b rename getNonLocalDependency -> getNonLocalCallDependency, and remove
pointer stuff from it, simplifying the code a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60783 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 19:38:05 +00:00
Chris Lattner
91bcf6450a Switch GVN::processNonLocalLoad to using the new
MemDep::getNonLocalPointerDependency method.  There are
some open issues with this (missed optimizations) and
plenty of future work, but this does allow GVN to eliminate
*slightly* more loads (49246 vs 49033).

Switching over now allows simplification of the other code
path in memdep.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60780 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 19:25:07 +00:00
Chris Lattner
ae1993114f random cleanups, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60779 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 19:21:47 +00:00
Chris Lattner
46a879ebd3 Fix a really subtle off-by-one bug that Duncan noticed with valgrind
on test/CodeGen/Generic/2007-06-06-CriticalEdgeLandingPad.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60739 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 04:47:21 +00:00
Chris Lattner
20fa76ef6f remove DebugIterations option. Despite the accusations,
jump threading has been shown to only expose problems not
have bugs itself.  I'm sure it's completely bug free! ;-)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60725 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-08 22:44:07 +00:00
Devang Patel
042b877e84 Fix spelling.
Thanks Duncan!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60702 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-08 17:07:24 +00:00
Devang Patel
6d9896f153 Undo previous patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60701 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-08 17:02:37 +00:00
Chris Lattner
f760be1c7f don't bother touching volatile stores, they will just return clobber on
everything interesting anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60640 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 00:25:15 +00:00
Chris Lattner
5e600e67b1 Reimplement the inner loop of DSE. It now uniformly uses getDependence(),
doesn't do its own local caching, and is slightly more aggressive about
free/store dse (see testcase).  This eliminates the last external client 
of MemDep::getDependenceFrom().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60619 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-06 00:53:22 +00:00
Dale Johannesen
203af58aea Make LoopStrengthReduce smarter about hoisting things out of
loops when they can be subsumed into addressing modes.

Change X86 addressing mode check to realize that
some PIC references need an extra register.
(I believe this is correct for Linux, if not, I'm sure
someone will tell me.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60608 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 21:47:27 +00:00
Chris Lattner
b51deb929c Make a few major changes to memdep and its clients:
1. Merge the 'None' result into 'Normal', making loads
   and stores return their dependencies on allocations as Normal.
2. Split the 'Normal' result into 'Clobber' and 'Def' to
   distinguish between the cases when memdep knows the value is
   produced from when we just know if may be changed.
3. Move some of the logic for determining whether readonly calls
   are CSEs into memdep instead of it being in GVN.  This still
   leaves verification that the arguments are hte same to GVN to
   let it know about value equivalences in different contexts.
4. Change memdep's call/call dependency analysis to use 
   getModRefInfo(CallSite,CallSite) instead of doing something 
   very weak.  This only really matters for things like DSA, but
   someday maybe we'll have some other decent context sensitive
   analyses :)
5. This reimplements the guts of memdep to handle the new results.
6. This simplifies GVN significantly:
   a) readonly call CSE is slightly simpler
   b) I eliminated the "getDependencyFrom" chaining for load 
      elimination and load CSE doesn't have to worry about 
      volatile (they are always clobbers) anymore.
   c) GVN no longer does any 'lastLoad' caching, leaving it to 
      memdep.
7. The logic in DSE is simplified a bit and sped up.  A potentially
   unsafe case was eliminated.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60607 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 21:04:20 +00:00
Anton Korobeynikov
64b535608e Revert invalid r60393. It causes llvm-gcc bootstrap fails in release builds.
See PR3160 for details

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60604 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 19:38:49 +00:00
Chris Lattner
7f7c736682 Fix test/Transforms/GVN/pre-load.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60594 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 17:04:12 +00:00
Chris Lattner
72bc70d499 Make IsValueFullyAvailableInBlock safe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60588 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 07:49:08 +00:00
Devang Patel
3831005eb1 Rewrite code that 1) filters loops and 2) calculates new loop bounds.
This fixes many bugs. I will add more test cases in a separate check-in.

Some day, the code that manipulates CFG and updates dom. info could use refactoring help.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60554 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 21:38:42 +00:00
Chris Lattner
3cda3cdab1 Start simplifying a switch that has a successor that is a switch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60534 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 06:31:07 +00:00
Chris Lattner
77ee977fcf add a debugging option to help track down j-t problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60514 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 00:07:59 +00:00
Dale Johannesen
308f24d452 Remove an unused field.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60508 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 22:43:56 +00:00
Dale Johannesen
544e0d0e52 Fix a misspelled function name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60506 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 20:56:12 +00:00
Chris Lattner
29874e0dc6 Factor some code into a new FoldSingleEntryPHINodes method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60501 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 19:44:02 +00:00
Dale Johannesen
67c7989294 Fix a really wrong comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60494 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 19:25:46 +00:00
Chris Lattner
421fa9e32e Teach jump threading some more simple tricks:
1) have it fold "br undef", which does occur with
   surprising frequency as jump threading iterates.
2) teach j-t to delete dead blocks.  This removes the successor
   edges, reducing the in-edges of other blocks, allowing 
   recursive simplification.
3) Fold things like:
     br COND, BBX, BBY
  BBX:
     br COND, BBZ, BBW

   which also happens because jump threading iterates.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60470 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 07:48:08 +00:00
Dale Johannesen
fb10cd4901 Minor rewrite per review feedback.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60442 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 21:17:11 +00:00
Dale Johannesen
eccdd08d4c Make the code do what the comment says it does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60431 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 18:40:09 +00:00
Chris Lattner
c89c6a964c Implement PRE of loads in the GVN pass with a pretty cheap and
straight-forward implementation.  This does not require any extra
alias analysis queries beyond what we already do for non-local loads.

Some programs really really like load PRE.  For example, SPASS triggers
this ~1000 times, ~300 times in 255.vortex, and ~1500 times on 403.gcc.

The biggest limitation to the implementation is that it does not split
critical edges.  This is a huge killer on many programs and should be
addressed after the initial patch is enabled by default.

The implementation of this should incidentally speed up rejection of 
non-local loads because it avoids creating the repl densemap in cases 
when it won't be used for fully redundant loads.

This is currently disabled by default.
Before I turn this on, I need to fix a couple of miscompilations in
the testsuite, look at compile time performance numbers, and look at
perf impact.  This is pretty close to ready though.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60408 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 08:16:11 +00:00
Bill Wendling
286a054908 Remove some errors that crept in. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60403 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 06:24:20 +00:00
Bill Wendling
d16c6e9993 Merge two if-statements into one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60402 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 06:22:04 +00:00
Bill Wendling
29976b9e12 More styalistic changes. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60401 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 06:18:11 +00:00
Bill Wendling
3bdcda82a5 - Remove the buggy -X/C -> X/-C transform. This isn't valid when X isn't a
constant. If X is a constant, then this is folded elsewhere.

- Added a note to Target/README.txt to indicate that we'd like to implement
  this when we're able.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60399 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 05:12:47 +00:00
Bill Wendling
a8bb13f989 Improve comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60398 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 05:09:00 +00:00
Bill Wendling
dda74e0702 - Reduce nesting.
- No need to do a swap on a canonicalized pattern.

No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60397 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 05:06:43 +00:00
Chris Lattner
f8828eb41b some random comment improvements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60395 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 04:52:26 +00:00
Owen Anderson
912c49d169 Fix an issue that Chris noticed, where local PRE was not properly instantiating
a new value numbering set after splitting a critical edge.  This increases
the number of instances of PRE on 403.gcc from ~60 to ~570.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60393 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 04:09:22 +00:00
Dale Johannesen
589bf0865c Consider only references to an IV within the loop when
figuring out the base of the IV.  This produces better
code in the example.  (Addresses use (IV) instead of 
(BASE,IV) - a significant improvement on low-register
machines like x86).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60374 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 22:00:01 +00:00
Bill Wendling
57036da328 Don't rebuild RHSNeg. Just use the one that's already there.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60370 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 21:06:30 +00:00
Bill Wendling
69fffa5437 Document what this check is doing. Also, no need to cast to ConstantInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60369 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 21:03:43 +00:00
Bill Wendling
c25c68305c Use a simple comparison. Overflow on integer negation can only occur when the
integer is "minint".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60366 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 19:46:27 +00:00
Bill Wendling
d54d86038d Generalize the FoldOrWithConstant method to fold for any two constants which
don't have overlapping bits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60344 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 08:32:40 +00:00
Bill Wendling
a698a472f2 Reduce copy-and-paste code by splitting out the code into its own function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60343 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 08:23:25 +00:00
Bill Wendling
03aae5f7e1 Use m_Specific() instead of double matching.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60341 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 08:09:47 +00:00
Bill Wendling
9c531a0f07 Move pattern check outside of the if-then statement. This prevents us from fiddling with constants unless we have to.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60340 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 07:47:02 +00:00
Chris Lattner
d0f5bfc9be Rename some variables, only increment BI once at the start of the loop instead of throughout it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60339 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 07:35:54 +00:00
Chris Lattner
09713794c1 pull the predMap densemap out of the inner loop of performPRE, so
that it isn't reallocated all the time.  This is a tiny speedup for
GVN: 3.90->3.88s


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60338 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 07:29:03 +00:00
Chris Lattner
a3522000ab switch a couple more calls to use array_pod_sort.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60337 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 06:52:57 +00:00
Chris Lattner
99d0015735 Introduce a new array_pod_sort function and switch LSR to use it
instead of std::sort.  This shrinks the release-asserts LSR.o file
by 1100 bytes of code on my system.

We should start using array_pod_sort where possible.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60335 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 06:49:59 +00:00
Chris Lattner
09fb7dadf1 Eliminate use of setvector for the DeadInsts set, just use a smallvector.
This is a lot cheaper and conceptually simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60332 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 06:27:41 +00:00
Chris Lattner
a68d4ca73e DeleteTriviallyDeadInstructions is always passed the
DeadInsts ivar, just use it directly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60330 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 06:14:28 +00:00
Chris Lattner
bfcee36cd7 simplify DeleteTriviallyDeadInstructions again, unlike my previous
buggy rewrite, this notifies ScalarEvolution of a pending instruction
about to be removed and then erases it, instead of erasing it then 
notifying.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60329 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 06:11:32 +00:00
Chris Lattner
d8aafcb200 simplify these patterns using m_Specific. No need to grep for
xor in testcase (or is a substring).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60328 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 05:16:26 +00:00
Chris Lattner
ef0c6744d5 Teach jump threading to clean up after itself, DCE and constfolding the
new instructions it simplifies.  Because we're threading jumps on edges
with constants coming in from PHI's, we inherently are exposing a lot more
constants to the new block.  Folding them and deleting dead conditions
allows the cost model in jump threading to be more accurate as it iterates.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60327 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 04:48:07 +00:00
Chris Lattner
38b3dcc465 Change instcombine to use FoldPHIArgGEPIntoPHI to fold two operand PHIs
instead of using FoldPHIArgBinOpIntoPHI.  In addition to being more
obvious, this also fixes a problem where instcombine wouldn't merge two
phis that had different variable indices.  This prevented instcombine
from factoring big chunks of code in 403.gcc.  For example:

 insn_cuid.exit:                
-       %tmp336 = load i32** @uid_cuid, align 4      
-       %tmp337 = getelementptr %struct.rtx_def* %insn_addr.0.ph.i, i32 0, i32 3    
-       %tmp338 = bitcast [1 x %struct.rtunion]* %tmp337 to i32*               
-       %tmp339 = load i32* %tmp338, align 4           
-       %tmp340 = getelementptr i32* %tmp336, i32 %tmp339     
        br label %bb62
 
 bb61:       
-       %tmp341 = load i32** @uid_cuid, align 4     
-       %tmp342 = getelementptr %struct.rtx_def* %insn, i32 0, i32 3        
-       %tmp343 = bitcast [1 x %struct.rtunion]* %tmp342 to i32*           
-       %tmp344 = load i32* %tmp343, align 4        
-       %tmp345 = getelementptr i32* %tmp341, i32 %tmp344          
        br label %bb62
 
 bb62:      
-       %iftmp.62.0.in = phi i32* [ %tmp345, %bb61 ], [ %tmp340, %insn_cuid.exit ]         
+       %insn.pn2 = phi %struct.rtx_def* [ %insn, %bb61 ], [ %insn_addr.0.ph.i, %insn_cuid.exit ]         
+       %tmp344.pn.in.in = getelementptr %struct.rtx_def* %insn.pn2, i32 0, i32 3     
+       %tmp344.pn.in = bitcast [1 x %struct.rtunion]* %tmp344.pn.in.in to i32*  
+       %tmp341.pn = load i32** @uid_cuid     
+       %tmp344.pn = load i32* %tmp344.pn.in 
+       %iftmp.62.0.in = getelementptr i32* %tmp341.pn, i32 %tmp344.pn   
        %iftmp.62.0 = load i32* %iftmp.62.0.in     



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60325 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 03:42:51 +00:00
Chris Lattner
05f18920e1 Teach inst combine to merge GEPs through PHIs. This is really
important because it is sinking the loads using the GEPs, but
not the GEPs themselves.  This triggers 647 times on 403.gcc
and makes the .s file much much nicer.  For example before:

        je      LBB1_87 ## bb78
LBB1_62:        ## bb77
        leal    84(%esi), %eax
LBB1_63:        ## bb79
        movl    (%eax), %eax
...
LBB1_87:        ## bb78
        movl    $0, 4(%esp)
        movl    %esi, (%esp)
        call    L_make_decl_rtl$stub
        jmp     LBB1_62 ## bb77


after:

        jne     LBB1_63 ## bb79
LBB1_62:        ## bb78
        movl    $0, 4(%esp)
        movl    %esi, (%esp)
        call    L_make_decl_rtl$stub
LBB1_63:        ## bb79
        movl    84(%esi), %eax

The input code was (and the GEPs are merged and
the PHI is now eliminated by instcombine):

        br i1 %tmp233, label %bb78, label %bb77
bb77:           
        %tmp234 = getelementptr %struct.tree_node* %t_addr.3, i32 0, i32 0, i32 22              
        br label %bb79
bb78:           
        call void @make_decl_rtl(%struct.tree_node* %t_addr.3, i8* null) nounwind
        %tmp235 = getelementptr %struct.tree_node* %t_addr.3, i32 0, i32 0, i32 22              
        br label %bb79
bb79:           
        %iftmp.12.0.in = phi %struct.rtx_def** [ %tmp235, %bb78 ], [ %tmp234, %bb77 ]           
        %iftmp.12.0 = load %struct.rtx_def** %iftmp.12.0.in             



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60322 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 02:34:36 +00:00
Chris Lattner
978796eaad Make GVN be more intelligent about redundant load
elimination: when finding dependent load/stores, realize that
they are the same if aliasing claims must alias instead of relying
on the pointers to be exactly equal.  This makes load elimination
more aggressive.  For example, on 403.gcc, we had:

<     68 gvn    - Number of instructions PRE'd
< 152718 gvn    - Number of instructions deleted
<  49699 gvn    - Number of loads deleted
<   6153 memdep - Number of dirty cached non-local responses
< 169336 memdep - Number of fully cached non-local responses
< 162428 memdep - Number of uncached non-local responses

now we have:

>     64 gvn    - Number of instructions PRE'd
> 153623 gvn    - Number of instructions deleted
>  49856 gvn    - Number of loads deleted
>   5022 memdep - Number of dirty cached non-local responses
> 159030 memdep - Number of fully cached non-local responses
> 162443 memdep - Number of uncached non-local responses

That's an extra 157 loads deleted and extra 905 other instructions nuked.

This slows down GVN very slightly, from 3.91 to 3.96s.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60314 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 01:31:36 +00:00
Chris Lattner
bf145d6e2b Reimplement the non-local dependency data structure in terms of a sorted
vector instead of a densemap.  This shrinks the memory usage of this thing
substantially (the high water mark) as well as making operations like
scanning it faster.  This speeds up memdep slightly, gvn goes from
3.9376 to 3.9118s on 403.gcc

This also splits out the statistics for the cached non-local case to
differentiate between the dirty and clean cached case.  Here's the stats
for 403.gcc:

  6153 memdep - Number of dirty cached non-local responses
169336 memdep - Number of fully cached non-local responses
162428 memdep - Number of uncached non-local responses

yay for caching :)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60313 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 01:15:42 +00:00
Bill Wendling
b3833d1eb9 Implement ((A|B)&1)|(B&-2) -> (A&1) | B transformation. This also takes care of
permutations of this pattern.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60312 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 01:07:11 +00:00
Chris Lattner
663e441a75 Cache analyses in ivars and add some useful DEBUG output.
This speeds up GVN from 4.0386s to 3.9376s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60310 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 00:40:32 +00:00
Chris Lattner
1440ac5417 improve indentation, do cheap checks before expensive ones,
remove some fixme's.  This speeds up GVN very slightly on 403.gcc 
(4.06->4.03s)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60309 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 23:39:23 +00:00
Eli Friedman
8b019c8a45 Minor cleanup: use getTrue and getFalse where appropriate. No
functional change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60307 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 22:48:49 +00:00
Eli Friedman
d1fd1da143 Some minor cleanups to instcombine; no functionality change.
Note that the FoldOpIntoPhi call is dead because it's impossible for the 
first operand of a subtraction to be both a ConstantInt and a PHINode.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60306 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 21:09:11 +00:00
Bill Wendling
b01865c210 Add instruction combining for ((A&~B)|(~A&B)) -> A^B and all permutations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60291 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 13:52:49 +00:00
Bill Wendling
7f0ef6b325 Implement (A&((~A)|B)) -> A&B transformation in the instruction combiner. This
takes care of all permutations of this pattern.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60290 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 13:08:13 +00:00
Bill Wendling
7c7048ecc6 Forgot one remaining call to getSExtValue().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60289 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 12:41:09 +00:00
Bill Wendling
6e1783fb4a getSExtValue() doesn't work for ConstantInts with bitwidth > 64 bits. Use all
APInt calls instead.

This fixes PR3144.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60288 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 12:38:24 +00:00
Eli Friedman
d83ae7d698 Optimize memmove and memset into the LLVM builtins. Note that these
only show up in code from front-ends besides llvm-gcc, like clang.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60287 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 08:32:11 +00:00
Bill Wendling
3f93df5733 Don't make TwoToExp signed by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60279 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 05:29:33 +00:00
Bill Wendling
f0e44c4d7a From Hacker's Delight:
"For signed integers, the determination of overflow of x*y is not so simple. If
x and y have the same sign, then overflow occurs iff xy > 2**31 - 1. If they
have opposite signs, then overflow occurs iff xy < -2**31."

In this case, x == -1.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60278 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 05:01:05 +00:00
Bill Wendling
e1196d6d3e Instcombine was illegally transforming -X/C into X/-C when either X or C
overflowed on negation. This commit checks to make sure that neithe C nor X
overflows. This requires that the RHS of X (a subtract instruction) be a
constant integer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60275 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 03:42:12 +00:00
Chris Lattner
237a828745 Fix a fixme by making memdep's handling of allocations more logical.
If we see that a load depends on the allocation of its memory with no
intervening stores, we now return a 'None' depedency instead of "Normal".
This tweaks GVN to do its optimization with the new result.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60267 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 01:39:32 +00:00
Chris Lattner
4f8c18c7c7 Eliminate the dropInstruction method, which is not needed any more.
Fix a subtle iterator invalidation bug I introduced in the last commit.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60258 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 23:30:39 +00:00
Chris Lattner
396a4a55e5 Change MemDep::getNonLocalDependency to return its results as
a smallvector instead of a DenseMap.  This speeds up GVN by 5%
on 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60255 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 21:33:22 +00:00
Chris Lattner
86b29ef64a reimplement getNonLocalDependency with a simpler worklist
formulation that is faster and doesn't require nonLazyHelper.
Much less code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60253 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 21:22:42 +00:00
Chris Lattner
3a76be584b Fix a thinko that manifested as a crash on clamav last night.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60251 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 20:29:04 +00:00
Chris Lattner
5391a1d804 Split getDependency into getDependency and getDependencyFrom, the
former does caching, the later doesn't.  This dramatically simplifies
the logic in getDependency and getDependencyFrom.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60234 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 03:47:00 +00:00
Bill Wendling
411052bb96 Temporarily revert r60195. It's causing an optimized bootstrap of llvm-gcc to fail.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60233 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 03:43:04 +00:00
Chris Lattner
4c72400625 Introduce and use a new MemDepResult class to hold the results of a memdep
query.  This makes it crystal clear what cases can escape from MemDep that
the clients have to handle.  This also gives the clients a nice simplified
interface to it that is easy to poke at.

This patch also makes DepResultTy and MemoryDependenceAnalysis::DepType
private, yay.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60231 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 02:29:27 +00:00
Chris Lattner
39f372e23e Reimplement the internal abstraction used by MemDep in terms
of a pointer/int pair instead of a manually bitmangled pointer.
This forces clients to think a little more about checking the 
appropriate pieces and will be useful for internal 
implementation improvements later.

I'm not particularly happy with this.  After going through this
I don't think that the clients of memdep should be exposed to
the internal type at all.  I'll fix this in a subsequent commit.

This has no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60230 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 01:43:36 +00:00
Chris Lattner
5425f22fa3 don't revisit instructions off the beginning of the block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60221 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-28 22:50:08 +00:00
Chris Lattner
565f96b196 simplify some code, remove escaped newline.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60213 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-28 21:29:52 +00:00
Chris Lattner
f5102a0f08 don't call MergeBasicBlockIntoOnlyPred on a block whose only
predecessor is itself.  This doesn't make sense, and this is
a dead infinite loop anyway.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60210 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-28 19:54:49 +00:00
Chris Lattner
925451e020 rewrite a big chunk of how DSE does recursive dead operand
elimination to use more modern infrastructure.  Also do a bunch
of small cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60201 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-28 00:27:14 +00:00
Chris Lattner
1363949380 Simplify LoopStrengthReduce::DeleteTriviallyDeadInstructions by
making it use RecursivelyDeleteTriviallyDeadInstructions to do
the heavy lifting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60195 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 23:23:35 +00:00
Chris Lattner
a0d4486073 use continue to reduce indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60192 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 23:00:20 +00:00
Chris Lattner
3481f24c06 remove doConstantPropagation and dceInstruction, they are just
wrappers around the interesting code and use an obscure iterator
abstraction that dates back many many years.

Move EraseDeadInstructions to Transforms/Utils and name it
RecursivelyDeleteTriviallyDeadInstructions.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60191 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 22:57:53 +00:00
Chris Lattner
15678533f3 simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60190 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 22:56:14 +00:00
Chris Lattner
cb03f8547d simplify this logic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60189 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 22:46:09 +00:00
Nick Lewycky
8ca5248522 Chris prefers icmp/select over udiv!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60187 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 22:41:10 +00:00
Nick Lewycky
895f085385 Add a couple of missed optimizations on integer vectors. Multiply and divide
by 1, as well as multiply by -1.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60182 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 20:21:08 +00:00
Chris Lattner
9918fb5631 defensive patch: if CGP is merging a block with the entry block, make sure
it ends up being the entry block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60180 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 19:29:14 +00:00
Chris Lattner
3d86d242c6 Fix PR3138: if we merge the entry block into another block, make sure to
move the other block back up into the entry position!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60179 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 19:25:19 +00:00
Chris Lattner
4aebaee0e4 switch InstCombine::visitLoadInst to use
FindAvailableLoadedValue


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60169 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 08:56:30 +00:00
Chris Lattner
52c95856b4 move FindAvailableLoadedValue from JumpThreading to Transforms/Utils.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60166 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 08:10:05 +00:00
Chris Lattner
3c4f8b91ef Use the new MergeBasicBlockIntoOnlyPred function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60163 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 07:54:12 +00:00
Chris Lattner
b29714a10a move MergeBasicBlockIntoOnlyPred to Transforms/Utils.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60162 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 07:43:12 +00:00
Chris Lattner
c7bcbf6903 rename ThreadBlock to ProcessBlock, since it does other things than
just simple threading.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60157 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 07:20:04 +00:00
Chris Lattner
69e067fdd8 Make jump threading substantially more powerful, in the following ways:
1. Make it fold blocks separated by an unconditional branch.  This enables
   jump threading to see a broader scope.
2. Make jump threading able to eliminate locally redundant loads when they
   feed the branch condition of a block.  This frequently occurs due to
   reg2mem running.
3. Make jump threading able to eliminate *partially redundant* loads when
   they feed the branch condition of a block.  This is common in code with
   lots of loads and stores like C++ code and 255.vortex.

This implements thread-loads.ll and rdar://6402033.

Per the fixme's, several pieces of this should be moved into Transforms/Utils.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60148 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 05:07:53 +00:00
Chris Lattner
ab8b794a78 Turn on my codegen prepare heuristic by default. It doesn't affect
performance in most cases on the Grawp tester, but does speed some 
things up (like shootout/hash by 15%).  This also doesn't impact 
compile time in a noticable way on the Grawp tester.

It also, of course, gets the testcase it was designed for right :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60120 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 22:16:44 +00:00
Chris Lattner
695d8ec33b teach the new heuristic how to handle inline asm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60088 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 04:59:11 +00:00
Chris Lattner
896617b776 Improve ValueAlreadyLiveAtInst with a cheap and dirty, but effective
heuristic: the value is already live at the new memory operation if
it is used by some other instruction in the memop's block.  This is
cheap and simple to compute (moreso than full liveness).

This improves the new heuristic even more.  For example, it cuts two
out of three new instructions out of 255.vortex:DbmFileInGrpHdr, 
which is one of the functions that the heuristic regressed.  This
overall eliminates another 40 instructions from 403.gcc and visibly
reduces register pressure in 255.vortex (though this only actually
ends up saving the 2 instructions from the whole program).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60084 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 03:20:37 +00:00
Chris Lattner
84d1b40d44 Start rewroking a subpiece of the profitability heuristic to be
phrased in terms of liveness instead of as a horrible hack.  :)

In pratice, this doesn't change the generated code for either 
255.vortex or 403.gcc, but it could cause minor code changes in 
theory.  This is framework for coming changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60082 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 03:02:41 +00:00
Chris Lattner
653b2581df add a comment, make save/restore logic more obvious.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60076 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 02:11:11 +00:00
Chris Lattner
5eecb7f164 This adds in some code (currently disabled unless you pass
-enable-smarter-addr-folding to llc) that gives CGP a better
cost model for when to sink computations into addressing modes.
The basic observation is that sinking increases register 
pressure when part of the addr computation has to be available
for other reasons, such as having a use that is a non-memory
operation.  In cases where it works, it can substantially reduce
register pressure.

This code is currently an overall win on 403.gcc and 255.vortex
(the two things I've been looking at), but there are several 
things I want to do before enabling it by default:

1. This isn't doing any caching of results, so it is much slower 
   than it could be.  It currently slows down release-asserts llc 
   by 1.7% on 176.gcc: 27.12s -> 27.60s.
2. This doesn't think about inline asm memory operands yet.
3. The cost model botches the case when the needed value is live
   across the computation for other reasons.

I'll continue poking at this, and eventually turn it on as llcbeta.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60074 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 02:00:14 +00:00
Evan Cheng
794a7dbce0 Revert r60042. IndVarSimplify should check if APFloat is PPCDoubleDouble first before trying to convert it to an integer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60072 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 01:11:57 +00:00