Commit Graph

7051 Commits

Author SHA1 Message Date
Owen Anderson
7c37f6d2d9 Don't perform an extra traversal of the function just to do cleanup. We can safely simplify instructions after each block has been processed without worrying about iterator invalidation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112594 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 07:55:56 +00:00
Owen Anderson
25e9405272 Rename ValuePropagation to a more descriptive CorrelatedValuePropagation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112591 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 07:48:34 +00:00
Owen Anderson
7aff1cd038 Rename file to something more descriptive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112590 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 07:41:39 +00:00
Owen Anderson
cb21190cbd More Chris-inspired JumpThreading fixes: use ConstantExpr to correctly constant-fold undef, and be more careful with its return value.
This actually exposed an infinite recursion bug in ComputeValueKnownInPredecessors which theoretically already existed (in JumpThreading's
handling of and/or of i1's), but never manifested before.  This patch adds a tracking set to prevent this case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112589 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 07:36:34 +00:00
Nick Lewycky
f53de86cba Switch to DenseSet, simplifying much more code. We now have a single iteration
where we hash, compare and fold, instead of one iteration where we build up
the hash buckets and a second one to fold.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112582 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 05:53:05 +00:00
Owen Anderson
c97fb52799 Remove r111665, which implemented store-narrowing in InstCombine. Chris discovered a miscompilation in it, and it's not easily
fixable at the optimizer level. I'll investigate reimplementing it in DAGCombine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112575 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 04:41:06 +00:00
Owen Anderson
49998ce46a Fix a typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112560 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-30 23:59:30 +00:00
Owen Anderson
a081d15b84 Cleanups suggested by Chris.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112553 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-30 23:34:17 +00:00
Owen Anderson
327ca7bec2 Re-apply r112539, being more careful to respect the return values of the constant folding methods. Additionally,
use the ConstantExpr::get*() methods to simplify some constant folding.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112550 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-30 23:22:36 +00:00
Owen Anderson
f523b3e087 Add statistics to evaluate this pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112545 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-30 22:45:55 +00:00
Owen Anderson
d930f205db Revert r112539. It accidentally introduced a miscompilation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112543 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-30 22:33:41 +00:00
Owen Anderson
1e35610f20 Fixes and cleanups pointed out by Chris. In general, be careful to handle 0 results from ComputeValueKnownInPredecessors
(indicating undef), and re-use existing constant folding APIs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112539 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-30 22:07:52 +00:00
Chris Lattner
4455608818 rewrite DwarfEHPrepare to use SSAUpdater to promote its allocas
instead of PromoteMemToReg.  This allows it to stop using DF and DT,
eliminating a computation of DT and DF from clang -O3.  Clang is now
down to 2 runs of DomFrontier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112457 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 19:54:28 +00:00
Chris Lattner
cb7f653422 two changes: 1) make AliasSet hold the list of call sites with an
assertingvh so we get a violent explosion if the pointer dangles.

2) Fix AliasSetTracker::deleteValue to remove call sites with
   by-pointer comparisons instead of by-alias queries.  Using
   findAliasSetForCallSite can cause alias sets to get merged
   when they shouldn't, and can also miss alias sets when the
   call is readonly.

#2 fixes PR6889, which only repros with a .c file :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112452 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 18:42:23 +00:00
Chris Lattner
0de5cad74d LICM does get dead instructions input to it. Instead of sinking them
out of loops, just delete them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112451 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 18:22:25 +00:00
Chris Lattner
d9a5daeb77 use moveBefore instead of remove+insert, it avoids some
symtab manipulation, so its faster (in addition to being
more elegant)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112450 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 18:18:40 +00:00
Chris Lattner
1b9c848d0a revert 112448 for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112449 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 18:11:16 +00:00
Chris Lattner
bb07ed3bb5 optimize LICM::hoist to use moveBefore. Correct its updating
of AST to remove the hoisted instruction from the AST, since it
is no longer in the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112448 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 18:03:33 +00:00
Chris Lattner
98917503c7 fix some bugs (found by inspection) where LICM would not update
LICM correctly.  When sinking an instruction, it should not add
entries for the sunk instruction to the AST, it should remove
the entry for the sunk instruction.  The blocks being sunk to
are not in the loop, so their instructions shouldn't be in the
AST (yet)!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112447 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 18:00:00 +00:00
Chris Lattner
4282e32712 rework the ownership of subloop alias information: instead of
keeping them around until the pass is destroyed, keep them
around a) just when useful (not for outer loops) and b) destroy
them right after we use them.  This should reduce memory use
and fixes potential bugs where a loop is deleted and another
loop gets allocated to the same address.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112446 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 17:46:00 +00:00
Chris Lattner
ea1092374c apparently unswitch had the same "Feature". Stop its
claims that it preserves domfrontier if it doesn't really.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112445 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 17:23:19 +00:00
Chris Lattner
937790195e now that loop passes don't use DomFrontier, there is no reason
for the unroller to pretend it supports updating it.  It still
has a horrible hack for DomTree.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112444 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 17:21:35 +00:00
Dan Gohman
4f7e18dee3 Optionally rerun dedicated-register filtering after applying
other filtering techniques, as those may allow it to filter
out more obviously unprofitable candidates.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112441 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 16:39:22 +00:00
Dan Gohman
25608f7f4b Fix several areas in LSR to do a better job keeping the main
LSRInstance data structures up to date. This fixes some
pessimizations caused by stale data which will be exposed
in an upcoming change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112440 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 16:32:54 +00:00
Dan Gohman
4aa5c2e90f Refactor the three main groups of code out of
NarrowSearchSpaceUsingHeuristics into separate functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112439 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 16:09:42 +00:00
Dan Gohman
e39a47c5b3 Delete a bogus check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112438 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 15:30:29 +00:00
Dan Gohman
6a83271532 Add some comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112437 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 15:27:08 +00:00
Dan Gohman
3902f9fca8 Move this debug output into GenerateAllReuseFormula, to declutter
the high-level logic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112436 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 15:21:38 +00:00
Dan Gohman
a7d0d64b7a Delete an unused declaration.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112435 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 15:19:11 +00:00
Dan Gohman
46fd7a6ef8 Do one lookup instead of two.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112434 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 15:18:49 +00:00
Chris Lattner
e418ac832c licm preserves the cfg, it doesn't have to explicitly say it
preserves domfrontier.  It does preserve AA though.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112419 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 07:02:56 +00:00
Chris Lattner
44e2bd31f1 now that it doesn't use the PromoteMemToReg function, LICM doesn't
require DomFrontier.  Dropping this doesn't actually save any runs
of the pass though.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112418 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 06:49:44 +00:00
Chris Lattner
e488064922 completely rewrite the memory promotion algorithm in LICM.
Among other things, this uses SSAUpdater instead of 
PromoteMemToReg.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112417 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 06:43:52 +00:00
Chris Lattner
63a75c13b1 use getUniqueExitBlocks instead of a manual set.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112412 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 05:12:21 +00:00
Chris Lattner
a6a36f59b4 reimplement LICM::sink to use SSAUpdater instead of PromoteMemToReg.
This leads to much simpler code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112410 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 04:55:06 +00:00
Chris Lattner
ffd9beefb8 implement SSAUpdater::RewriteUseAfterInsertions, a helpful form of RewriteUse.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112409 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 04:54:06 +00:00
Chris Lattner
abd2a75900 remove dead proto
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112408 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 04:53:24 +00:00
Chris Lattner
d7bc19dfee reduce indentation in LICM::sink by using early exits, use
getUniqueExitBlocks instead of getExitBlocks and a manual
set to eliminate dupes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112405 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 04:28:20 +00:00
Chris Lattner
dc1ceb370a modernize this pass a bit: use efficient set/map and reduce indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112404 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29 04:23:04 +00:00
Chris Lattner
61c70e98ac remove unions from LLVM IR. They are severely buggy and not
being actively maintained, improved, or extended.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112356 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-28 04:09:24 +00:00
Chris Lattner
5f88af5376 remove the ABCD and SSI passes. They don't have any clients that
I'm aware of, aren't maintained, and LVI will be replacing their value.
nlewycky approved this on irc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112355 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-28 03:51:24 +00:00
Chris Lattner
157d4ead36 for completeness, allow undef also.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112351 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-28 03:36:51 +00:00
Chris Lattner
b188a3789e squish dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112350 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-28 03:21:03 +00:00
Chris Lattner
7900779543 handle the constant case of vector insertion. For something
like this:

struct S { float A, B, C, D; };

struct S g;
struct S bar() { 
  struct S A = g;
  ++A.B;
  A.A = 42;
  return A;
}

we now generate:

_bar:                                   ## @bar
## BB#0:                                ## %entry
	movq	_g@GOTPCREL(%rip), %rax
	movss	12(%rax), %xmm0
	pshufd	$16, %xmm0, %xmm0
	movss	4(%rax), %xmm2
	movss	8(%rax), %xmm1
	pshufd	$16, %xmm1, %xmm1
	unpcklps	%xmm0, %xmm1
	addss	LCPI1_0(%rip), %xmm2
	pshufd	$16, %xmm2, %xmm2
	movss	LCPI1_1(%rip), %xmm0
	pshufd	$16, %xmm0, %xmm0
	unpcklps	%xmm2, %xmm0
	ret

instead of:

_bar:                                   ## @bar
## BB#0:                                ## %entry
	movq	_g@GOTPCREL(%rip), %rax
	movss	12(%rax), %xmm0
	pshufd	$16, %xmm0, %xmm0
	movss	4(%rax), %xmm2
	movss	8(%rax), %xmm1
	pshufd	$16, %xmm1, %xmm1
	unpcklps	%xmm0, %xmm1
	addss	LCPI1_0(%rip), %xmm2
	movd	%xmm2, %eax
	shlq	$32, %rax
	addq	$1109917696, %rax       ## imm = 0x42280000
	movd	%rax, %xmm0
	ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112345 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-28 01:50:57 +00:00
Chris Lattner
3dd08734c1 optimize bitcasts from large integers to vector into vector
element insertion from the pieces that feed into the vector.
This handles a pattern that occurs frequently due to code
generated for the x86-64 abi.  We now compile something like
this:

struct S { float A, B, C, D; };
struct S g;
struct S bar() { 
  struct S A = g;
  ++A.A;
  ++A.C;
  return A;
}

into all nice vector operations:

_bar:                                   ## @bar
## BB#0:                                ## %entry
	movq	_g@GOTPCREL(%rip), %rax
	movss	LCPI1_0(%rip), %xmm1
	movss	(%rax), %xmm0
	addss	%xmm1, %xmm0
	pshufd	$16, %xmm0, %xmm0
	movss	4(%rax), %xmm2
	movss	12(%rax), %xmm3
	pshufd	$16, %xmm2, %xmm2
	unpcklps	%xmm2, %xmm0
	addss	8(%rax), %xmm1
	pshufd	$16, %xmm1, %xmm1
	pshufd	$16, %xmm3, %xmm2
	unpcklps	%xmm2, %xmm1
	ret

instead of icky integer operations:

_bar:                                   ## @bar
	movq	_g@GOTPCREL(%rip), %rax
	movss	LCPI1_0(%rip), %xmm1
	movss	(%rax), %xmm0
	addss	%xmm1, %xmm0
	movd	%xmm0, %ecx
	movl	4(%rax), %edx
	movl	12(%rax), %esi
	shlq	$32, %rdx
	addq	%rcx, %rdx
	movd	%rdx, %xmm0
	addss	8(%rax), %xmm1
	movd	%xmm1, %eax
	shlq	$32, %rsi
	addq	%rax, %rsi
	movd	%rsi, %xmm1
	ret

This resolves rdar://8360454



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112343 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-28 01:20:38 +00:00
Benjamin Kramer
6cfabc7974 Update CMake build. Add newline at end of file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112332 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-28 00:11:12 +00:00
Owen Anderson
a0b59f6bd2 Add a prototype of a new peephole optimizing pass that uses LazyValue info to simplify PHIs and select's.
This pass addresses the missed optimizations from PR2581 and PR4420.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112325 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-27 23:31:36 +00:00
Chris Lattner
4ece577019 Enhance the shift propagator to handle the case when you have:
A = shl x, 42
...
B = lshr ..., 38

which can be transformed into:
A = shl x, 4
...

iff we can prove that the would-be-shifted-in bits
are already zero.  This eliminates two shifts in the testcase
and allows eliminate of the whole i128 chain in the real example.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112314 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-27 22:53:44 +00:00
Chris Lattner
29cc0b3660 Implement a pretty general logical shift propagation
framework, which is good at ripping through bitfield
operations.  This generalize a bunch of the existing
xforms that instcombine does, such as 
  (x << c) >> c -> and
to handle intermediate logical nodes.  This is useful for
ripping up the "promote to large integer" code produced by
SRoA.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112304 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-27 22:24:38 +00:00
Chris Lattner
2d0822a937 remove some special shift cases that have been subsumed into the
more general simplify demanded bits logic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112291 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-27 21:04:34 +00:00