Commit Graph

1673 Commits

Author SHA1 Message Date
Chris Lattner
b2ae9e34db implement PR2328.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51176 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-16 02:59:42 +00:00
Bill Wendling
a6c3112b1f Situations can arise when you have a function called that returns a 'void', but
is bitcast to return a floating point value. The result of the instruction may
not be used by the program afterwards, and LLVM will happily remove all
instructions except the call. But, on some platforms, if a value is returned as
a floating point, it may need to be removed from the stack (like x87). Thus, we
can't get rid of the bitcast even if there isn't a use of the value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51134 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-14 22:45:20 +00:00
Devang Patel
ef3682a4fb Simplify internalize pass. Add test case.
Patch by Matthijs Kooijman!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51114 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-14 20:01:01 +00:00
Dale Johannesen
72997fedab Fix for PR 2323, infinite loop in tail dup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51063 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-13 20:06:43 +00:00
Owen Anderson
6513c1bf90 Add a testcase for non-local CSE of read-only calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51025 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-13 08:17:44 +00:00
Duncan Sands
eca2f99958 Testcase for PR2303.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50951 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-10 16:43:10 +00:00
Chris Lattner
7d2cbd2d43 Implement PR2298. This transforms:
~x < ~y --> y < x
   -x == -y --> x == y



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50882 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-09 05:19:28 +00:00
Chris Lattner
2539e33893 More than just loads can read from memory: readonly calls like strlen
also need to be checked for memory modifying instructions before we
can sink them.  THis fixes the second half of PR2297.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50860 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-08 17:37:37 +00:00
Chris Lattner
0ef546e639 Make instcombine's DSE respect loads as well as stores. It is not safe to
delete the first store in:

store x -> p
load p
store y -> p

This is for PR2297.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50859 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-08 17:20:30 +00:00
Dan Gohman
42ac929ed9 Fix a bug in the ComputeMaskedBits logic for multiply.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50793 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-07 00:35:55 +00:00
Owen Anderson
f092b64a49 Testcase for r50770.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50771 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-06 21:01:34 +00:00
Dan Gohman
23e1df8b8d Correct the value of LowBits in srem and urem handling in
ComputeMaskedBits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50692 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-06 00:51:48 +00:00
Chris Lattner
8554cc2ea7 Fix a crash when threading a block that includes a MRV call result.
DemoteRegToStack doesn't work with MRVs yet, because it relies on the
ability to load/store things.

This fixes PR2285.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50667 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05 20:21:22 +00:00
Dan Gohman
1d9cd50677 Fix a mistake in the computation of leading zeros for udiv.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50591 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-02 21:30:02 +00:00
Chris Lattner
e818f770bb strength reduce exp2 into ldexp, rdar://5852514
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50586 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-02 18:43:35 +00:00
Dan Gohman
fddaa3193c Update old-style syntax in some "not grep" tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50560 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 23:50:07 +00:00
Dale Johannesen
f1e94f74e5 New test for bug fixed in 50545.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50548 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 22:50:14 +00:00
Dan Gohman
e85b7585e9 Fix an overaggressive SimplifyDemandedBits optimization on urem. This
fixes the 254.gap regression on x86 and the 403.gcc regression on x86-64.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50537 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 19:13:24 +00:00
Chris Lattner
2facbddb76 fix typo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50519 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 06:16:48 +00:00
Chris Lattner
b1747f0b23 instcombine does memset optzns.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50518 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 06:16:38 +00:00
Chris Lattner
330a0c1527 simplifylibcalls doesn't optimize llvm.memmove, instcombine does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50517 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 06:14:24 +00:00
Chris Lattner
042232df74 move some tests from libcall optimizer suite.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50516 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 06:13:48 +00:00
Owen Anderson
0cad8444cc Move this test to LoopDeletion, where it now passes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50474 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30 07:17:22 +00:00
Chris Lattner
69ea9d2308 move lowering of llvm.memset -> store from simplify libcalls
to instcombine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50472 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30 06:39:11 +00:00
Chris Lattner
4103bb9fc6 no reason for simplifylibcalls to simplify intrinsics, instcombine does
a fine job.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50470 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30 06:12:15 +00:00
Chris Lattner
0c58cacb7a remove redundant check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50469 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30 06:06:37 +00:00
Owen Anderson
9dcace3caf Fix a bug in memcpyopt where the memcpy-memcpy transform was never being applied because
we were checking for it in the wrong order.  This caused a miscompilation because the
return slot optimization assumes that the call it is dealing with is NOT a memcpy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50444 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-29 21:26:06 +00:00
Chris Lattner
40700fe683 don't eliminate load from volatile value on paths where the load is dead.
This fixes the second half of PR2262


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50430 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-29 17:28:22 +00:00
Chris Lattner
68608e4dd0 make this test reduced and *valid*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50429 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-29 17:25:32 +00:00
Chris Lattner
54545ac023 fix a subtle volatile handling bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50428 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-29 17:13:43 +00:00
Chris Lattner
cea1fdd174 don't delete the last store to an alloca if the store is volatile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50390 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-29 04:58:38 +00:00
Dan Gohman
00acf97feb Fix DSE to not eliminate volatile loads with no uses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50370 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 19:51:27 +00:00
Dan Gohman
23e8b71526 Teach InstCombine's ComputeMaskedBits what SelectionDAG's
ComputeMaskedBits knows about cttz, ctlz, and ctpop. Teach
SelectionDAG's ComputeMaskedBits what InstCombine's knows
about SRem. And teach them both some things about high bits
in Mul, UDiv, URem, and Sub. This allows instcombine and
dagcombine to eliminate sign-extension operations in
several new cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50358 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 17:02:21 +00:00
Chris Lattner
ffba5821ee Fix PR2256, yet another miscompilation in simplifycfg of i
multiple return values.

Bill, please pull this into Tak.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50332 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 00:19:07 +00:00
Chris Lattner
998182b380 When SRoA'ing a global variable, make sure the new globals get the
appropriate alignment.  This fixes a miscompilation of 252.eon on
x86-64 (rdar://5891920).

Bill, please pull this into Tak.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50308 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-26 07:40:11 +00:00
Nick Lewycky
280a6e607d Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989
r48047 r48084 r48085 r48086 r48088 r48096 r48099 r48109 and r48123.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50265 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25 16:53:59 +00:00
Chris Lattner
eede65ce6c Don't infininitely thread branches when a threaded edge
goes back to the block, e.g.:

  Threading edge through bool from 'bb37.us.thread3829' to 'bb37.us' with cost: 1, across block:

bb37.us:		; preds = %bb37.us.thread3829, %bb37.us, %bb33
	%D1361.1.us = phi i32 [ %tmp36, %bb33 ], [ %D1361.1.us, %bb37.us ], [ 0, %bb37.us.thread3829 ]		; <i32> [#uses=2]
	%tmp39.us = icmp eq i32 %D1361.1.us, 0		; <i1> [#uses=1]
	br i1 %tmp39.us, label %bb37.us, label %bb42.us



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50251 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25 04:12:29 +00:00
Chris Lattner
c9e495c534 Split some code out of the main SimplifyCFG loop into its own function.
Fix said code to handle merging return instructions together correctly
when handling multiple return values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50199 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-24 00:01:19 +00:00
Chris Lattner
c6ee00b8ee Rewrite multiple return value handling in SCCP. Before, the -sccp pass
would turn every getresult instruction into undef.  This helps with
rdar://5778210


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50140 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23 05:38:20 +00:00
Chris Lattner
69e6317083 remove this testcase. It isn't testing loop rotate, it is testing all
of -std-compile-opts and is now failing because other passes are generating
IR that looks different to input of loop rotate.  Devang, please 
introduce a testcase that only runs loop rotate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50136 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23 05:36:04 +00:00
Chris Lattner
525af20937 make this test more interesting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50128 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23 03:49:32 +00:00
Chris Lattner
ed98501ab7 distill down the essense of this test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50125 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23 03:03:42 +00:00
Dale Johannesen
02dc1a7f1f new test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50123 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23 01:22:22 +00:00
Evan Cheng
f30752cbcc Don't do: "(X & 4) >> 1 == 2 --> (X & 4) == 4" if there are more than one uses of the shift result.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50118 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23 00:38:06 +00:00
Chris Lattner
a5ddb59a13 Start doing the significantly useful part of jump threading: handle cases
where a comparison has a phi input and that phi is a constant.  For example,
stuff like:

  Threading edge through bool from 'bb2149' to 'bb2231' with cost: 1, across block:
bb2237:		; preds = %bb2231, %bb2149
	%tmp2328.rle = phi i32 [ %tmp2232, %bb2231 ], [ %tmp2232439, %bb2149 ]		; <i32> [#uses=2]
	%done.0 = phi i32 [ %done.2, %bb2231 ], [ 0, %bb2149 ]		; <i32> [#uses=1]
	%tmp2239 = icmp eq i32 %done.0, 0		; <i1> [#uses=1]
	br i1 %tmp2239, label %bb2231, label %bb2327

or

bb38.i298:		; preds = %bb33.i295, %bb1693
	%tmp39.i296.rle = phi %struct.ibox* [ null, %bb1693 ], [ %tmp39.i296.rle1109, %bb33.i295 ]		; <%struct.ibox*> [#uses=2]
	%minspan.1.i291.reg2mem.1 = phi i32 [ 32000, %bb1693 ], [ %minspan.0.i288, %bb33.i295 ]		; <i32> [#uses=1]
	%tmp40.i297 = icmp eq %struct.ibox* %tmp39.i296.rle, null		; <i1> [#uses=1]
	br i1 %tmp40.i297, label %implfeeds.exit311, label %bb43.i301

This triggers thousands of times in spec.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50110 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-22 21:40:39 +00:00
Chris Lattner
ae65b3c791 Dig through multiple levels of AND to thread jumps if needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50106 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-22 20:46:09 +00:00
Chris Lattner
6bf77500c6 Teach jump threading to thread through blocks like:
br (and X, phi(Y, Z, false)), label L1, label L2

This triggers once on 252.eon and 6 times on 176.gcc.  Blocks 
in question often look like this:

bb262:		; preds = %bb261, %bb248
	%iftmp.251.0 = phi i1 [ true, %bb261 ], [ false, %bb248 ]		; <i1> [#uses=4]
	%tmp270 = icmp eq %struct.rtx_def* %tmp.0.i, null		; <i1> [#uses=1]
	%bothcond = or i1 %iftmp.251.0, %tmp270		; <i1> [#uses=1]
	br i1 %bothcond, label %bb288, label %bb273

In this case, it is clear that it doesn't matter if tmp.0.i is null when coming from bb261.  When coming from bb248, it is all that matters.


Another random example:

check_asm_operands.exit:		; preds = %check_asm_operands.exit.thr_comm, %bb30.i, %bb12.i, %bb6.i413
	%tmp.0.i420 = phi i1 [ true, %bb6.i413 ], [ true, %bb12.i ], [ true, %bb30.i ], [ false, %check_asm_operands.exit.thr_comm ; <i1> [#uses=1]
	call void @llvm.stackrestore( i8* %savedstack ) nounwind 
	%tmp4389 = icmp eq i32 %added_sets_1.0, 0		; <i1> [#uses=1]
	%tmp4394 = icmp eq i32 %added_sets_2.0, 0		; <i1> [#uses=1]
	%bothcond80 = and i1 %tmp4389, %tmp4394		; <i1> [#uses=1]
	%bothcond81 = and i1 %bothcond80, %tmp.0.i420		; <i1> [#uses=1]
	br i1 %bothcond81, label %bb4398, label %bb4397

Here is the case from 252.eon:

bb290.i.i:		; preds = %bb23.i57.i.i, %bb8.i39.i.i, %bb100.i.i, %bb100.i.i, %bb85.i.i110
	%myEOF.1.i.i = phi i1 [ true, %bb100.i.i ], [ true, %bb100.i.i ], [ true, %bb85.i.i110 ], [ true, %bb8.i39.i.i ], [ false, %bb23.i57.i.i ]		; <i1> [#uses=2]
	%i.4.i.i = phi i32 [ %i.1.i.i, %bb85.i.i110 ], [ %i.0.i.i, %bb100.i.i ], [ %i.0.i.i, %bb100.i.i ], [ %i.3.i.i, %bb8.i39.i.i ], [ %i.3.i.i, %bb23.i57.i.i ]		; <i32> [#uses=3]
	%tmp292.i.i = load i8* %tmp16.i.i100, align 1		; <i8> [#uses=1]
	%tmp293.not.i.i = icmp ne i8 %tmp292.i.i, 0		; <i1> [#uses=1]
	%bothcond.i.i = and i1 %tmp293.not.i.i, %myEOF.1.i.i		; <i1> [#uses=1]
	br i1 %bothcond.i.i, label %bb202.i.i, label %bb301.i.i
  Factoring out 3 common predecessors.

On the path from any blocks other than bb23.i57.i.i, the load and compare 
are dead.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50096 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-22 07:05:46 +00:00
Chris Lattner
f29984f695 add a basic testcase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50093 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-22 06:35:14 +00:00
Chris Lattner
10c0d9179e optimize "p != gep p, ..." better. This allows us to compile
getelementptr-seteq.ll into:

define i1 @test(i64 %X, %S* %P) {
	%C = icmp eq i64 %X, -1		; <i1> [#uses=1]
	ret i1 %C
}

instead of:

define i1 @test(i64 %X, %S* %P) {
	%A.idx.mask = and i64 %X, 4611686018427387903		; <i64> [#uses=1]
	%C = icmp eq i64 %A.idx.mask, 4611686018427387903		; <i1> [#uses=1]
	ret i1 %C
}

And fixes the second half of PR2235.  This speeds up the insertion sort
case by 45%, from 1.12s to 0.77s.  In practice, this will significantly
speed up for loops structured like:

for (double *P = Base + N; P != Base; --P)
  ...

Which happens frequently for C++ iterators.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50079 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-22 02:53:33 +00:00
Owen Anderson
a8bd65835b Refactor memcpyopt based on Chris' suggestions. Consolidate several functions
and simplify code that was fallout from the separation of memcpyopt and gvn.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50034 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-21 07:45:10 +00:00