Commit Graph

2409 Commits

Author SHA1 Message Date
Chris Lattner
d2c58366d8 generalize a transformation even more: we don't care whether the
input the the mul is a zext from bool, just that it is all zeros
other than the low bit.  This fixes some phase ordering issues
that would cause us to miss some xforms in mul.ll when the worklist
is visited differently.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83794 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 21:29:45 +00:00
Chris Lattner
0036e3a469 simplify a transformation by making it more general.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83792 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 21:22:21 +00:00
Torok Edwin
9289ae85b4 LICM shouldn't sink/delete debug information. Fix this and add a testcase.
For now the metadata of sinked/hoisted instructions is still wrong, but that'll
be fixed when instructions will have debug metadata directly attached.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83786 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 19:15:54 +00:00
Chris Lattner
5a06cf644f when folding duplicate conditions, delete the
now-probably-dead instruction tree feeding it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83778 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 18:39:58 +00:00
Chris Lattner
8af304ab3b implement rdar://7293527, a trivial instcombine that llvm-gcc
gets but clang doesn't, because it is implemented in GCC's
fold routine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83761 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 07:53:15 +00:00
Chris Lattner
78c552ef30 implement a transformation in jump threading that is currently
done by condprop, but do it in a much more general form.  The
basic idea is that we can do a limited form of tail duplication
in the case when we have a branch on a phi.  Moving the branch
up in to the predecessor block makes instruction selection
much easier and encourages chained jump threadings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83759 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 07:24:57 +00:00
Chris Lattner
113e4c6070 another testcase jump threading shouldn't crash on.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83758 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 07:11:11 +00:00
Chris Lattner
c6c167f3bf rename a file, remove a poorly reduced testcase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83757 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 07:10:28 +00:00
Chris Lattner
e33583b7c2 make jump threading on a phi with undef inputs happen.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83754 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 04:18:15 +00:00
Chris Lattner
41fb43bb1e merge two tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83751 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 03:55:30 +00:00
Chris Lattner
d98eb44dde simplify some run lines, convert a test to filecheck.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83750 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 03:54:21 +00:00
Chris Lattner
a09fbf0af0 switch GVN to use SSAUpdater. Besides removing a lot of complexity
from GVN, this also speeds it up, inserts fewer PHI nodes (see the
testcase) and allows it to remove more loads (due to fewer PHI nodes
standing in the way).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83746 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-10 23:50:30 +00:00
Dale Johannesen
e91b9a3b59 When considering whether to inline Callee into Caller,
and that will make Caller too big to inline, see if it
might be better to inline Caller into its callers instead.
This situation is described in PR 2973, although I haven't
tried the specific case in SPASS.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83602 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-09 00:11:32 +00:00
Chris Lattner
7963e15951 remove predicate simplifier, it never got the last bugs beaten
out of it, and jump threading, condprop and gvn are now getting
most of the benefit.  This was approved by Nicholas and Nicolas.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83390 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-06 16:59:46 +00:00
Evan Phoenix
1614e50d9f Extend ConstantFolding to understand signed overflow variants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83338 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-05 22:53:52 +00:00
Chris Lattner
e65cd40ab9 teach the optimizer how to constant fold uadd/usub intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83295 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-05 05:26:04 +00:00
Chris Lattner
bbc33853a5 instcombine shouldn't delete all null checks for mallocs.
This fixes PR5130.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83290 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-05 02:47:47 +00:00
Chris Lattner
99be299edb remove the GVNPRE pass. It has been subsumed by the GVN pass.
Ok'd by Owen.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-01 02:18:36 +00:00
Dan Gohman
ff2483a109 Add a testcase for r83011.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83012 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 21:03:02 +00:00
Dan Gohman
c60e0bec11 Add a testcase to help test analysis preservation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83002 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 18:40:27 +00:00
Chris Lattner
3ddfb21306 The select instruction is not neccesarily in the same block as the
phi nodes.  Make sure to phi translate from the right block. 

This fixes a llvm-building-llvm failure on GVN-PRE.cpp


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82970 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 06:49:44 +00:00
Dan Gohman
9450b0e1a6 Move the dominator verification code out of special code embedded within
the PassManager code into a regular verifyAnalysis method.

Also, reorganize loop verification. Make the LoopPass infrastructure
call verifyLoop as needed instead of having LoopInfo::verifyAnalysis
check every loop in the function after each looop pass. Add a new
command-line argument, -verify-loop-info, to enable the expensive
full checking.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82952 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 00:27:48 +00:00
Chris Lattner
c6df8f4d5f Enhance the previous fix for PR4895 to allow more values than just
simple constants for the true/false value of the select.  We now
do phi translation etc.  This really fixes PR4895 :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82917 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-27 20:18:49 +00:00
Chris Lattner
5d1704ddbf implement PR4895, by making FoldOpIntoPhi handle select conditions
that are phi nodes.  Also tighten up FoldOpIntoPhi to treat constantexpr
operands to phis just like other variables, avoiding moving constantexpr
computations around.

Patch by Daniel Dunbar.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82913 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-27 19:57:57 +00:00
Nick Lewycky
975f5917a2 Filecheckify this one test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82888 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-27 06:25:05 +00:00
Dan Gohman
76926b6789 Fix SimplifyLibCalls to transfer attributes from callees rather than
calls, since direct calls don't always reflect the attributes of their
callees.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82867 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 18:10:13 +00:00
Dan Gohman
c70c37794f Fix a case where ScalarEvolution was expanding pointer arithmetic
to inttoptr/ptrtoint unnecessarily.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82864 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 16:11:57 +00:00
Dan Gohman
22cb6579b3 I put the wrong rdar number in this test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82829 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 01:11:57 +00:00
Dan Gohman
79cb840136 Transform pow(x, 0.5) to (x == -inf ? inf : fabs(sqrt(x))), which is
typically faster then doing a general pow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82819 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 23:10:17 +00:00
Dale Johannesen
9d06175a15 Handle sqrt in CannotBeNegativeZero. absf and absl
appear to be misspellings, removed in favor of fabs*.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82796 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 20:54:50 +00:00
Victor Hernandez
3e0c99a26f Revert 82694 "Auto-upgrade malloc instructions to malloc calls." because it causes regressions in the nightly tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82784 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 18:11:52 +00:00
Torok Edwin
c338499525 Constant propagating byval pointer is safe if function is readonly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82700 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 18:33:42 +00:00
Victor Hernandez
96b930ddc7 Auto-upgrade malloc instructions to malloc calls.
Reviewed by Devang Patel.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82694 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 17:47:49 +00:00
Torok Edwin
30a94e3b42 Don't constant propagate byval pointers, since they are not really pointers, but
rather structs passed by value.
This fixes PR5038.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82689 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 09:47:18 +00:00
Chris Lattner
850c9178dc Fix PR5023: The instruction form of DominatorTree::dominates did not
take into consideration that the result of an invoke is only valid in
the normal dest, not the unwind dest.  This caused 'PHINode::hasConstantValue'
to return true in an invalid situation, causing mem2reg to delete a phi that
was actually needed.  This caused a crash building 483.xalancbmk.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82491 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 22:39:35 +00:00
Chris Lattner
8b2bc3d574 fix PR5016, a crash I introduced in GVN handing first class
arrays and structs, which cannot be bitcast to integers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82460 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 17:24:04 +00:00
Chris Lattner
4fbd14e80e enable non-local analysis and PRE of large store -> little load.
This doesn't kick in too much because of phi translation issues,
but this can be resolved in the future.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82447 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 06:48:08 +00:00
Chris Lattner
f716330c90 add pr#
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82440 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 05:57:47 +00:00
Chris Lattner
eed919b1ba Improve GVN to be able to forward substitute a small load
from a piece of a large store when both are in the same block.

This allows clang to compile the testcase in PR4216 to this code:

_test_bitfield:
	movl	4(%esp), %eax
	movl	%eax, %ecx
	andl	$-65536, %ecx
	orl	$32962, %eax
	andl	$40186, %eax
	orl	%ecx, %eax
	ret

This is not ideal, but is a whole lot better than the code produced
by llvm-gcc:

_test_bitfield:
	movw	$-32574, %ax
	orw	4(%esp), %ax
	andw	$-25350, %ax
	movw	%ax, 4(%esp)
	movw	7(%esp), %cx
	shlw	$8, %cx
	movzbl	6(%esp), %edx
	orw	%cx, %dx
	movzwl	%dx, %ecx
	shll	$16, %ecx
	movzwl	%ax, %eax
	orl	%ecx, %eax
	ret

and dramatically better than that produced by gcc 4.2:

_test_bitfield:
	pushl	%ebx
	call	L3
"L00000000001$pb":
L3:
	popl	%ebx
	movl	8(%esp), %eax
	leal	0(,%eax,4), %edx
	sarb	$7, %dl
	movl	%eax, %ecx
	andl	$7168, %ecx
	andl	$-7201, %ebx
	movzbl	%dl, %edx
	andl	$1, %edx
	sall	$5, %edx
	orl	%ecx, %ebx
	orl	%edx, %ebx
	andl	$24, %eax
	andl	$-58336, %ebx
	orl	%eax, %ebx
	orl	$32962, %ebx
	movl	%ebx, %eax
	popl	%ebx
	ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82439 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 05:57:11 +00:00
Chris Lattner
8111576521 fix a FileCheck bug where:
; CHECK: foo
; CHECK-NOT: foo
; CHECK: bar

would always fail.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82424 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 02:30:42 +00:00
Daniel Dunbar
3d4138bd58 Work around a FileCheck bug, for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82416 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 23:30:31 +00:00
Chris Lattner
66364346e0 Revert r82404, it is causing a bootstrap miscompile. This is very very
scary, as it indicates a lurking bug. yay.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82411 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 22:44:26 +00:00
Chris Lattner
6a089c3257 this was not supposed to be committed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82409 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 22:36:11 +00:00
Chris Lattner
f15380ba8a implement and document support for CHECK-NOT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82408 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 22:35:26 +00:00
Chris Lattner
386251341f improve memdep to eliminate bitcasts (and aliases, and noop geps)
early for the stated reasons: this allows it to find more 
equivalences and depend less on code layout.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82404 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 21:00:18 +00:00
Chris Lattner
771a5422e1 Move CoerceAvailableValueToLoadType earlier in GVN.cpp. Hook it up
so that nonlocal and partially redundant loads can use it as well.
The testcase shows examples of craziness this can handle.  This triggers
*many* times in 176.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82403 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 20:09:34 +00:00
Chris Lattner
bb6495cc67 enhance GVN to forward substitute a stored value to a load
(and load -> load) when the base pointers must alias but when
they are different types.  This occurs very very frequently in
176.gcc and other code that uses bitfields a lot.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82399 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 19:03:47 +00:00
Nick Lewycky
149cbc2a24 Peer through zext and sext to eliminate them when it is safe to do so.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82389 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 07:31:25 +00:00
Nick Lewycky
85958b059d Fold 'icmp eq (icmp), true' into an xor(icmp).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 07:21:39 +00:00
Nick Lewycky
04d7eed1d5 Rewrite this check so that it checks what it's supposed to and doesn't use
CHECK-NOT.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82383 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 07:00:24 +00:00