Commit Graph

1998 Commits

Author SHA1 Message Date
Devang Patel
a009d2ef54 Remove.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56018 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 21:41:34 +00:00
Devang Patel
d22a849282 if loop induction variable is always sign or zero extended then
extend the type of induction variable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56017 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 21:41:07 +00:00
Devang Patel
4b3f08bac7 fix overflow check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56011 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 20:54:34 +00:00
Anton Korobeynikov
e4c6b61ebd Resolve aliases, when possible
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56001 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 19:04:59 +00:00
Dan Gohman
488fbfc69e Make SimplifyDemandedVectorElts simplify vectors with multiple
users, and teach it about shufflevector instructions.

Also, fix a subtle bug in SimplifyDemandedVectorElts'
insertelement code.

This is a patch that was originally written by Eli Friedman,
with some fixes and cleanup by me.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55995 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 18:11:14 +00:00
Devang Patel
e435a5d937 Fix simplifycfg crash in handing block merge.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55971 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 01:06:56 +00:00
Devang Patel
ac8ab789ac xfail
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55914 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-08 16:24:30 +00:00
Duncan Sands
34c8847b2d Update the callgraph correctly in ArgumentPromotion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55895 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-08 11:07:35 +00:00
Duncan Sands
fec2c2bf5e When PruneEH turned an invoke into an ordinary
call (thus changing the call site) it didn't
inform the callgraph about this.  But the
call site does matter - as shown by the testcase,
the callgraph become invalid after the inliner
ran (with an edge between two functions simply
missing), resulting in wrong deductions by
GlobalsModRef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55872 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-06 17:19:29 +00:00
Nick Lewycky
83c05e5d30 Don't crash when trying to constant fold a vector with some elements that can't
be folded. Instead, fail to fold the entire vector.

We could also return a vector with some elements folded and some not. If anyone
thinks that's a better approach, please speak up!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55689 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 05:54:33 +00:00
Devang Patel
a9348dc7ac Check iteration count.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55680 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 00:10:56 +00:00
Devang Patel
108f92e376 If all IV uses are extending integer IV then change the type of IV itself, if possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55674 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 22:18:08 +00:00
Devang Patel
691e52445e respect inline=never and inline=always notes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55673 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 22:16:13 +00:00
Devang Patel
a0b3909d43 If IV is used in a int-to-float cast inside the loop then try to eliminate the cast operation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55374 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-26 17:57:54 +00:00
Chris Lattner
88e6dc8bf1 Fix PR2423 by checking all indices for out of range access, not only
indices that start with an array subscript.  x->field[10000] is just 
as bad as (*X)[14][10000].


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55226 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 05:21:06 +00:00
Nick Lewycky
5d52c4501a Revert r54876 r54877 r54906 and r54907. Evan found that these caused a 20%
slowdown in bzip2.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55113 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-21 05:56:10 +00:00
Bill Wendling
2dcca3a6d8 XFAIL this test for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54929 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-18 18:29:54 +00:00
Nick Lewycky
91a0f78265 Consider the case where xor by -1 and xor by 128 have been combined already to
produce an xor by 127.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54906 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 19:58:24 +00:00
Evan Cheng
4e49c80289 Didn't mean to change this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54904 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 19:25:28 +00:00
Evan Cheng
0ac3fc2a61 Fix a (u)comiss intrinsic lowering bug. It was using anyext which can return junk in higher bits. Patch by Nate Begeman.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54903 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 19:22:34 +00:00
Nick Lewycky
1b344bc986 Xor'ing both sides of icmp by sign-bit is equivalent to swapping signedness of
the predicate.

Also, make this optz'n apply in more cases where it's safe to do so.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54876 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 07:34:14 +00:00
Owen Anderson
7c856c09cd Remove GCSE and LoadVN from the testsuite.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54832 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-16 00:00:54 +00:00
Devang Patel
35115f92e4 Reapply 54786. Add overflow and number of mantissa bits checks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54821 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-15 21:21:34 +00:00
Evan Cheng
21066541ae Revert 54786. It's not checking for overflows, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54813 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-15 08:12:11 +00:00
Devang Patel
79ceb4463e If IV is used in a int-to-float cast inside the loop then try to eliminate the cast opeation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54786 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-14 20:58:31 +00:00
Dan Gohman
a60832b018 Fix a bogus srem rule - a negative value srem'd by a power-of-2
can have a non-negative result; for example, -16%16 is 0. Also,
clarify the related comments. This fixes PR2670.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54767 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-13 23:12:35 +00:00
Dan Gohman
2edeb63ece Fix SCCP's handling of struct value loads and stores. SCCP doesn't
track individual leaf values in such cases, so it needs to treat
struct values as normal values in this case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54760 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-13 21:22:48 +00:00
Devang Patel
d16aba22c9 Check sign to detect overflow before changing compare stride.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54710 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-13 02:05:14 +00:00
Chris Lattner
b8cd4d3d49 Implement support for simplifying vector comparisons by 0.0 and 1.0 like we
do for scalars.  Patch contributed by Nicolas Capens

This also generalizes the previous xforms to work on long double, now that 
isExactlyValue works for long double.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54653 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 22:06:05 +00:00
Matthijs Kooijman
1d63d92092 Add a basic test for the SRETPromotion pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54466 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-07 15:55:18 +00:00
Matthijs Kooijman
0d4ee1a7cd Move two tests from SRETPromotion to Inline, since they only call opt -inline.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54465 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-07 15:36:46 +00:00
Dan Gohman
4ce9627e97 Fix a shufflevector instcombine that was emitting invalid masks indices
when it meant to be emitting undef indices.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54417 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 18:17:32 +00:00
Evan Cheng
d756f8820a PR2535, not PR2355.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54416 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 18:06:48 +00:00
Evan Cheng
f5e25f32c7 Fix PR2355: bug in ChangeCompareStride. When the loop termination compare is the only use of its iv stride, the stride can be eliminated by moving it to another stride. If the scale is negative, swap the predicate instead of using a inverse predicate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54415 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 18:04:43 +00:00
Chris Lattner
46bbad217b optimize a common idiom generated by clang for bitfield access, PR2638.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54408 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 07:35:52 +00:00
Chris Lattner
5af5f463e1 Zap sitofp/fptoui pairs. In all cases when the sign difference
matters, the result is undefined anyway.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54396 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 05:13:06 +00:00
Nick Lewycky
b30591ec64 Reinstate this optimization, but without the miscompile. Thanks to Bill for
tracking down that this was breaking llvm-gcc bootstrap on Linux.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54394 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 04:54:03 +00:00
Bill Wendling
5226698f67 Just grep for through the LL code instead of the ASM code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54389 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 00:10:32 +00:00
Bill Wendling
201bf25f83 Add default architecture.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54384 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 23:36:00 +00:00
Bill Wendling
0b101b0399 Testcase for PR2629.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54377 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 22:23:59 +00:00
Bill Wendling
021507be82 Revert r53282. This was causing a miscompile on Linux. Also, the transformation
looks bogus. Please see PR2629 for details on why this is breaking things.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54372 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 21:23:45 +00:00
Matthijs Kooijman
75cf9cc527 Add -unroll-allow-partial command line option that enabled the loop unroller to
partially unroll a loop when fully unrolling would not fit under the threshold.

Patch by Mikael Lepistö.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54160 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-29 13:21:23 +00:00
Matthijs Kooijman
477f5a2f11 Restructure ArgumentPromotion a bit. Instead of just having a single boolean
that says "unconditional loads from this argument are safe", we now keep track
of the safety per set of indices from which loads happen. This prevents
ArgPromotion from promoting loads that aren't really valid. As an added effect,
this will now disregard the the type of the indices passed to a GEP, so
"load GEP %A, i32 1" and "load GEP %A, i64 1" will result in a single argument,
not two.

This fixes PR2598, for which a testcase has been added as well.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54159 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-29 10:00:13 +00:00
Owen Anderson
8aa895b19a Add support for eliminating stores that store the same value that was just loaded.
This fixes PR2599.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54133 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-28 16:14:26 +00:00
Dan Gohman
3eee6542f5 Put the LICM of constant GlobalVariables, introduced in r53945, under a
command-line option, and disable it by default. It introduced performance
regressions because CodeGen is currently not able to remat such loads.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53997 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-24 23:57:25 +00:00
Chris Lattner
967948b4e2 "Allow LICM to sink or lift loads from constant memory. Also add a test
case for this.

This allows instructions like loads from global variables declared to
be constant to be moved out of loops."

Patch by Stefanus Du Toit!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53945 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-23 05:06:28 +00:00
Dan Gohman
fc74abfba5 Enable first-class aggregates support.
Remove the GetResultInst instruction. It is still accepted in LLVM assembly
and bitcode, where it is now auto-upgraded to ExtractValueInst. Also, remove
support for return instructions with multiple values. These are auto-upgraded
to use InsertValueInst instructions.

The IRBuilder still accepts multiple-value returns, and auto-upgrades them
to InsertValueInst instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53941 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-23 00:34:11 +00:00
Dan Gohman
1d8973b499 Add the PR number to the test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53880 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-21 21:50:25 +00:00
Dan Gohman
7375fbcbf2 Fix a bug in LSR's dead-PHI cleanup. If a PHI has a def-use chain that
leads into a cycle involving a different PHI, LSR got stuck running
around that cycle looking for the original PHI. To avoid this, keep
track of visited PHIs and stop searching if we see one more than once.
This fixes PR2570.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53879 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-21 21:45:02 +00:00
Matthijs Kooijman
bc1f989e3c Make GlobalOpt preserve address spaces when scalar replacing aggregate globals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53716 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-17 11:59:53 +00:00
Chris Lattner
d137ab4783 Fix PR2553
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53715 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-17 06:07:20 +00:00
Matthijs Kooijman
d8b4d60490 Add a few cases to instcombine's extractvalue testcase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53675 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-16 12:57:25 +00:00
Matthijs Kooijman
5f0028e211 Un-XFAIL multdeadretval, since instcombine now properly handles the mess deadargelim leaves behind :-)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53674 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-16 12:56:52 +00:00
Evan Cheng
be8efa54b6 Fix PR2296. Do not transform x86_sse2_storel_dq into a full-width store.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53666 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-16 07:28:14 +00:00
Matthijs Kooijman
b79d2a6bfa XFAIL the multdeadretval test for now, I will be fixing instcombine to make it work again tomorrow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53614 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 16:05:09 +00:00
Matthijs Kooijman
790dd75b97 Remove a few tests which no longer hold for deadargelim (since it is now
allowed to canonicalize return values).

Add a test that checks if return value and function attributes are not removed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53612 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 14:57:01 +00:00
Matthijs Kooijman
2439911ac5 Add a testcase for the canonicalizations now performed by deadargelim.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53611 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 14:42:58 +00:00
Matthijs Kooijman
eb32b453b3 Make deadargelim a bit less smart, so it doesn't choke on nested structs as
return values that are still (partially) live. Instead of updating all uses of
a call instruction after removing some elements, it now just rebuilds the
original struct (With undef gaps where the unused values were) and leaves it to
instcombine to clean this up.

The added testcase still fails currently, but this is due to instcombine which
isn't good enough yet. I will fix that part next.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53608 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 14:03:10 +00:00
Matthijs Kooijman
ae15ddf61b Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53605 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-15 13:15:10 +00:00
Chris Lattner
fdb19e5887 Fix PR2506 by being a bit more careful about reverse fact propagation when
disproving a condition.  This actually compiles the existing testcase
(udiv_select_to_select_shift) to:

define i64 @test(i64 %X, i1 %Cond) {
entry:
	%divisor1.t = lshr i64 %X, 3		; <i64> [#uses=1]
	%quotient2 = lshr i64 %X, 3		; <i64> [#uses=1]
	%sum = add i64 %divisor1.t, %quotient2		; <i64> [#uses=1]
	ret i64 %sum
}

instead of:

define i64 @test(i64 %X, i1 %Cond) {
entry:
	%quotient1.v = select i1 %Cond, i64 3, i64 4		; <i64> [#uses=1]
	%quotient1 = lshr i64 %X, %quotient1.v		; <i64> [#uses=1]
	%quotient2 = lshr i64 %X, 3		; <i64> [#uses=1]
	%sum = add i64 %quotient1, %quotient2		; <i64> [#uses=1]
	ret i64 %sum
}



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53534 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-14 00:15:52 +00:00
Chris Lattner
093a438502 Fix mishandling of the infinite loop case when merging two blocks. This
fixes PR2540.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53533 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-13 22:23:11 +00:00
Nick Lewycky
3ac9e109b2 Enhance analysis of srem.
Remove dead code analyzing urem. 'urem' of power-of-2 is canonicalized to an
'and' instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53506 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-12 05:04:38 +00:00
Nick Lewycky
4bf1e59819 Add another optimization from PR2330. Also catch some missing cases that are
similar.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53451 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 07:20:53 +00:00
Chris Lattner
85b5eb0505 Fix folding of icmp's of i1 where the comparison is signed. The code
was using the algorithm for folding unsigned comparisons which is
completely wrong.  This has been broken since the signless types change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53444 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 04:20:58 +00:00
Chris Lattner
f299184565 Fix a bogus optimization: folding (slt (zext i1 A to i32), 1) -> (slt i1 A, true)
This cause a regression in InstCombine/JavaCompare, which was doing the right
thing on accident.  To handle the missed case, generalize the comparisons based
on masked bits a little bit to handle comparisons against the max value. For 
example, we can now xform (slt i32 (and X, 4), 4) -> (setne i32 (and X, 4), 4)




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53443 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 04:09:09 +00:00
Chris Lattner
99672cb130 make this condition more precise.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53442 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 03:54:57 +00:00
Matthijs Kooijman
d16918f843 Restructure dead argument elimination, try #3 :-)
Rewrite the DeadArgumentElimination pass, to use a more explicit tracking of
dependencies between return values and/or arguments. Also make the handling of
arguments and return values the same.

The pass now looks properly inside returned structs, but only at the first
level (ie, not inside nested structs).

This version fixed a few more bugs and was cleaned up a bit. It now passes all
of LLVM's testing, and should still pass SPEC2006. There is still a minor bug
with regard to returning nested structs. Since there is currently nothing that
emits such IR, I will fix that in a seperate commit (partly because it requires
a non-trivial fix).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53400 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-10 10:24:08 +00:00
Nick Lewycky
5dcc41f5b3 Fix overzealous optimization. Thanks to Duncan Sands for pointing out my error!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53393 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-10 05:51:40 +00:00
Chris Lattner
fea85c46c0 Fix a case where vector comparison constant folding would cause an
infinite recursion.  part of PR2529


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53383 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-10 00:29:28 +00:00
Chris Lattner
330e7e4d25 elementwise comparison of vector constants was completely wrong. Fix
it for PR2529


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53380 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-10 00:08:17 +00:00
Nick Lewycky
9ee863ecc0 Fold (a < 8) && (b < 8) into (a|b) < 8 for unsigned less or greater than.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53282 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 07:29:11 +00:00
Nick Lewycky
d1f77bf931 Fold ((1 << a) & 1) to (a == 0).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53276 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 05:20:13 +00:00
Chris Lattner
2782ed1f14 Fix a broken test. Neither load is eliminable without changing the CFG.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53273 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 05:01:02 +00:00
Nick Lewycky
b4d1bc989e Reduce x - y to -y when we know the 'x' part will get masked off anyways.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53271 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 04:32:37 +00:00
Devang Patel
a5e27f8028 If loop induction variable's start value is less then its exit value then do not split the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53265 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 00:12:01 +00:00
Chris Lattner
d038c27516 'Optimize' test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53242 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-08 18:33:33 +00:00
Chris Lattner
895860e27b new testcase for PR2496
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53239 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-08 17:18:05 +00:00
Chris Lattner
155a490258 Fix three bugs:
1) evaluate [v]fcmp true/false with undefs to true or false instead
   of undef.
2) fix vector comparisons with undef to return a vector result instead 
   of i1
3) fix vector comparisons with evaluatable results to return vector
   true/false instead of i1 true/false (PR2529)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53220 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-08 05:46:34 +00:00
Nick Lewycky
b8cd6a49b5 Fix missed optimization opportunity when analyzing cast of mul and select.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53151 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-05 21:19:34 +00:00
Owen Anderson
9da02b844f Remove the ability for ADCE to remove unreachable blocks in loop nests, because, as Eli pointed out, SimplifyCFG already does this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53104 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 17:21:41 +00:00
Owen Anderson
77d76b7ef7 Add support to ADCE for pruning unreachable blocks. This addresses the final
part of PR2509.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53038 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 18:05:19 +00:00
Owen Anderson
f2aa160b35 A better fix for PR2503 that doesn't pessimize GVN in the presence of unreachable blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53032 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-02 17:20:16 +00:00
Evan Cheng
a7e4cc9263 XFAIL for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52795 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 22:09:29 +00:00
Owen Anderson
3987f8e1ac Use the -enable-pre flag so this test doesn't fail.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52784 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 17:03:28 +00:00
Chris Lattner
aa0bf52625 Fix PR2488, a case where we deleted stack restores too aggressively.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52702 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-25 05:59:28 +00:00
Dan Gohman
8dbe7f832e Revert 52645, the loop unroller changes. It caused a regression in 252.eon.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52688 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-24 20:44:42 +00:00
Matthijs Kooijman
1d9a277761 Commit the new DeadArgElim pass again, this time with the gcc bootstrap failures fixed.
Also add a testcase to reproduce the gcc bootstrap failure in very much reduced form.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52677 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-24 16:30:26 +00:00
Dan Gohman
55e283c71e Revamp the loop unroller, extending it to correctly update PHI nodes
in the presence of out-of-loop users of in-loop values and the trip
count is not a known multiple of the unroll count, and to be a bit
simpler overall. This fixes PR2253.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52645 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-23 21:29:41 +00:00
Dan Gohman
cbfe5bbe88 Improve LSR's dead-phi detection to handle use-def cycles
with more than two nodes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52617 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-22 20:44:02 +00:00
Chris Lattner
963a97f1a3 Fix PR2369 by making scalarrepl more careful about promoting
structures.  Its default threshold is to promote things that are
smaller than 128 bytes, which is sane.  However, it is not sane
to do this for things that turn into 128 *registers*.  Add a cap
on the number of registers introduced, defaulting to 128/4=32.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52611 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-22 17:46:21 +00:00
Eli Friedman
5c1f172213 Fix for PR2479: correctly optimize expressions like (a > 13) & (a ==
15).

See also PR1800, which is about the signed case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52608 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 23:36:13 +00:00
Duncan Sands
befc9c16fa This file is empty.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52596 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 20:26:50 +00:00
Evan Cheng
9f99b7c595 Back out Matthijs' DAE patches. It's miscompiling gcc driver.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52570 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 00:31:44 +00:00
Matthijs Kooijman
63691f13b6 Add testcase that checks that DeadArgElim doesn't touch stuff it shouldn't touch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52540 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 15:38:22 +00:00
Matthijs Kooijman
c95e44b4e0 Recommit r52459, rewriting of the dead argument elimination pass.
This is a fixed version that no longer uses multimap::equal_range, which
resulted in a pointer invalidation problem.

Also, DAE::InspectedFunctions was not really necessary, so it got removed.

Lastly, this version no longer applies the extra arg hack on functions who did
not have any arguments to start with.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52532 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 09:36:16 +00:00
Chris Lattner
2de3fec61c Fix PR2471, which is a bug involving an invalid promotion from a conditional load.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52525 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-20 05:12:56 +00:00
Matthijs Kooijman
3d2ff5f939 Modify some ipconstprop tests to also test with invokes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52491 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-19 09:27:44 +00:00
Owen Anderson
93d606a9b3 Remove this test until the corresponding patch is reapplied because it's causing make check to crash for some people.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52473 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 22:37:31 +00:00
Owen Anderson
b230372437 Add local PRE to GVN. This only operates in cases where it would not increase code size, namely when the instantiated expression
would only need to be created in one predecessor.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52471 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 21:41:49 +00:00
Matthijs Kooijman
ca85d65277 Rewrite the DeadArgumentElimination pass, to use a more explicit tracking of
dependencies between return values and/or arguments. Also make the handling of
arguments and return values the same.

The pass now looks properly inside returned structs, but only at the first                                                                                     
level (ie, not inside nested structs).

Also add a testcase for testing various variations of (multiple) dead rerturn
values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52459 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 11:12:53 +00:00
Matthijs Kooijman
c2afe89019 Reapply r52397 (make IPConstProp promote returned arguments), but fixed this
time. Sorry for the trouble!

This time, also add a testcase, which I should have done in the first place...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52455 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 08:30:37 +00:00
Matthijs Kooijman
8b0fcf38ef Reapply r52396, it was unrelated to the breakage (that was caused by r52397, my
commit after this).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52453 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 08:09:27 +00:00
Chris Lattner
0521e3cdc1 implement some simple bswap optimizations, rdar://5992453
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52442 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 04:33:20 +00:00
Chris Lattner
a2eec61607 temporarily revert this testcase since its patch was reverted.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52441 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 04:03:23 +00:00
Chris Lattner
8114b718c9 make truncate/sext elimination capable of changing phi's. This
implements rdar://6013816 and the testcase in Transforms/InstCombine/sext-misc.ll.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52440 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 04:00:49 +00:00
Devang Patel
64cd658223 Preserve dominance frontier while trivially unswitching loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52438 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 02:16:38 +00:00
Matthijs Kooijman
906e423724 Learn IPConstProp to look at individual return values and propagate them
individually.

Also learn IPConstProp how returning first class aggregates work, in addition
to old style multiple return instructions.

Modify the return-constants testscase to confirm this behaviour.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52396 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 12:02:52 +00:00
Dan Gohman
9b93dd1f1a Refine the change in r52258 for avoiding use-before-def conditions
when changing the stride of a comparison so that it's slightly
more precise, by having it scan the instruction list to determine
if there is a use of the condition after the point where the
condition will be inserted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52371 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 22:34:15 +00:00
Matthijs Kooijman
d47e6aeb93 Make testcase check for extractvalue instead of extractelement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52317 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 13:03:44 +00:00
Matthijs Kooijman
cdbada613e Store the result of multiple identical run lines in a temporary file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52314 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-16 12:21:25 +00:00
Wojciech Matyjewicz
8a08769bad Fix PR2434. When scanning for exising binary operator to reuse don't
take into account the instrucion pointed by InsertPt. Thanks to it, 
returning the new value of InsertPt to the InsertBinop() caller can be 
avoided. The bug was, actually, in visitAddRecExpr() method which wasn't 
correctly handling changes of InsertPt. There shouldn't be any 
performance regression, as -gvn pass (run after -indvars) removes any 
redundant binops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52291 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-15 19:07:39 +00:00
Eli Friedman
6100119620 Remove unnecessary target lines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52261 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 22:12:16 +00:00
Eli Friedman
6783cdcbd2 Remove unnecessary target lines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52260 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 22:10:32 +00:00
Eli Friedman
6903a24f32 Don't skip over instructions other than loads that might read memory
when trying to sink stores.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52259 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 22:02:12 +00:00
Dan Gohman
e562b1725e Protect ChangeCompareStride from situations in which it is possible
for it to generate use-before-def IR, such as in this testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52258 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 21:43:41 +00:00
Eli Friedman
66fe80aa57 Make sure SimplifyStoreAtEndOfBlock doesn't mess with loops; the
structure checks are incorrect if the blocks aren't distinct.
Fixes PR2435.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52257 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-13 21:17:49 +00:00
Evan Cheng
933b5065e5 Fix some tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52245 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-12 21:23:38 +00:00
Evan Cheng
0d0ca8572f Revert 52223.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52243 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-12 20:55:39 +00:00
Matthijs Kooijman
ca9bcb0fda Add line continuation character so the avoid dup loop header test actually runs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52228 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-12 08:49:04 +00:00
Evan Cheng
bb318c073e Avoid duplicating loop header which leads to unnatural loops (and just seem like general badness to me, likely to cause code explosion).
Patch by Florian Brandner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52223 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 19:07:54 +00:00
Matthijs Kooijman
a9012eca1a Teach instruction combining about the extractvalue. It can succesfully fold
useless insert-extract chains, similar to how it folds them for vectors.

Add a testcase for this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52217 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 14:05:05 +00:00
Matthijs Kooijman
61d858e3f0 Ignore stderr for some more tests that expect warnings there.
This fixes 2 testcases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52184 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-10 16:13:38 +00:00
Matthijs Kooijman
888fa33cfb Fix some escaping and quoting in RUN lines, mainly involving { and <. In two
cases quoting of <{ didn't work out, so I changed the grep to check for }>
instead.

This fixes 7 testcases that were not properly running before.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52182 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-10 16:04:47 +00:00
Matthijs Kooijman
7361f63b25 Let some more tests ignore expected output on stderr.
Also, use > %t instead of -o %t for output in one test since that also works
when %t already exists.

This fixes 6 testcases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52178 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-10 15:04:14 +00:00
Dan Gohman
9eb698b96d Fix two more not-grep tests that were missing llvm-dis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52159 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-09 22:36:45 +00:00
Duncan Sands
eddc8f1f8b Test that prune-eh doesn't make deductions based
on bodies of functions with weak linkage.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52141 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-09 11:28:41 +00:00
Chris Lattner
313f0e63f7 lower calls to abs to inline code, PR2337
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52138 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-09 08:26:51 +00:00
Chris Lattner
18d73c206e Fix PR2411, where ip constant prop would propagate the
result of a weak function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52137 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-09 07:58:07 +00:00
Chris Lattner
7d8ab4efbc Limit the icmp+phi merging optimization to the cases where it is profitable:
don't make i1 phis when it won't be possible to eliminate them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52097 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-08 20:52:11 +00:00
Evan Cheng
4d09efd7b8 Speculatively execute a block when the the block is the then part of a triangle shape and it contains a single, side effect free, cheap instruction. The branch is eliminated by adding a select instruction. i.e.
Turn                                                                                                                                                                                                       
BB:                                                                                                                                                                                                        
    %t1 = icmp                                                                                                                                                                                             
    br i1 %t1, label %BB1, label %BB2                                                                                                                                                                      
BB1:                                                                                                                                                                                                       
    %t3 = add %t2, c                                                                                                                                                                                       
    br label BB2                                                                                                                                                                                           
BB2:                                                                                                                                                                                                       
=>                                                                                                                                                                                                         
BB:                                                                                                                                                                                                        
    %t1 = icmp                                                                                                                                                                                             
    %t4 = add %t2, c                                                                                                                                                                                       
    %t3 = select i1 %t1, %t2, %t3


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52073 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-07 08:52:29 +00:00
Evan Cheng
cce302fded Fix run line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52072 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-07 08:40:16 +00:00
Zhou Sheng
b73afcf6dc Add a test case for opt -instcombine bug fix in revision 52003.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52004 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 14:25:11 +00:00
Matthijs Kooijman
02518140ac Learn ScalarReplAggregrates how stores and loads of first class aggregrates
work and how to replace them into individual values. Also, when trying to
replace an aggregrate that is used by load or store with a single (large)
integer, don't crash (but don't replace the aggregrate either).

Also adds a testcase for both structs and arrays.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51997 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 12:51:53 +00:00
Matthijs Kooijman
47c6fd7317 Let StructRetPromotion check if all if its users are really calls or invokesn,
not other instructions. This fixes a crash with the added testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51992 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 08:57:20 +00:00
Matthijs Kooijman
257da0a7fc Let StructRetPromotion check if it's users are really calling it and not
passing its pointer. Fixes test with added testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51991 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 08:48:32 +00:00
Owen Anderson
3637981050 Testcase for LoopIndexSplit and DomFrontier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51916 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-03 18:32:27 +00:00
Devang Patel
2f170997b5 Update dom tree. Fix PR 2372.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51887 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-02 22:52:56 +00:00
Owen Anderson
009e4f7609 Fix two issues that Eli Friedman pointed out, where would misoptimized code like:
char a[200];
init(a, a+200);

OR

int a[200];
char* b = (char*)a;
char* c = (char*)a;
foo(b, c);


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51850 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 22:26:26 +00:00
Owen Anderson
19d4d12ee0 Test for PR2401
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51849 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 21:55:55 +00:00
Duncan Sands
f413cdfb0b When simplifying a call to a bitcast function, tighten up
the conditions for performing the transform when only the
function declaration is available: no longer allow turning
i32 into i64 for example.  Only allow changing between
pointer types, and between pointer types and integers of
the same size.  For return values ptr -> intptr was already
allowed; I added ptr -> ptr and intptr -> ptr while there.
As shown by a recent objc testcase, changing the way
parameters/return values are passed can be fatal when calling
code written in assembler that directly manipulates call
arguments and return values unless the transform has no
impact on the way they are passed at the codegen level.
While it is possible to imagine an ABI that treats integers
of pointer size differently to pointers, I don't think LLVM
supports any so the transform should now be safe while still
being useful.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51834 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 07:38:42 +00:00
Nick Lewycky
517e1f5cd7 Peer through sext/zext when looking for not(cmp).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51819 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-31 19:01:33 +00:00
Nick Lewycky
9419ddb289 Add more i1 optimizations. add, sub, mul, s/udiv on i1 are now simplified away.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51817 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-31 17:59:52 +00:00
Nick Lewycky
fd12a0b20b Adding i1 is always Xor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51816 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-31 17:10:28 +00:00
Owen Anderson
038a8746c9 Replace the old ADCE implementation with a new one that more simply solves
the one case that ADCE catches that normal DCE doesn't: non-induction variable
loop computations.

This implementation handles this problem without using postdominators.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51668 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 08:45:13 +00:00
Chris Lattner
a935db8ea2 Implement PR2370: memmove(x,x,size) -> noop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51636 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-28 05:30:41 +00:00
Nick Lewycky
3dfd7bf511 "ret (constexpr)" can't be folded into a Constant. Add a method to
Analysis/ConstantFolding to fold ConstantExpr's, then make instcombine use it
to try to use targetdata to fold constant expressions on void instructions.

Also extend the icmp(inttoptr, inttoptr) folding to handle the case where
int size != ptr size.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51559 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-25 20:56:15 +00:00
Chris Lattner
393f7eb60a Fix a serious brain-o. Obviously no-one reviewed my patch :(
This fixes PR2359


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51536 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-24 04:06:28 +00:00
Chris Lattner
60301608f8 Fix PR2358 by resolving calls with undef arguments to overdefined.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51535 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-24 03:59:33 +00:00
Dan Gohman
3bf19e4c42 Remove lingering references to .llx and .tr in the tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51500 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 21:15:35 +00:00
Matthijs Kooijman
5e179a23e3 Restucture a part of the SimplifyCFG pass and include a testcase.
The SimplifyCFG pass looks at basic blocks that contain only phi nodes,
followed by an unconditional branch. In a lot of cases, such a block (BB) can
be merged into their successor (Succ).

This merging is performed by TryToSimplifyUncondBranchFromEmptyBlock. It does
this by taking all phi nodes in the succesor block Succ and expanding them to
include the predecessors of BB. Furthermore, any phi nodes in BB are moved to
Succ and expanded to include the predecessors of Succ as well.

Before attempting this merge, CanPropagatePredecessorsForPHIs checks to see if
all phi nodes can be properly merged. All functional changes are made to
this function, only comments were updated in
TryToSimplifyUncondBranchFromEmptyBlock.

In the original code, CanPropagatePredecessorsForPHIs looks quite convoluted
and more like stack of checks added to handle different kinds of situations
than a comprehensive check. In particular the first check in the function did
some value checking for the case that BB and Succ have a common predecessor,
while the last check in the function simply rejected all cases where BB and
Succ have a common predecessor. The first check was still useful in the case
that BB did not contain any phi nodes at all, though, so it was not completely
useless.

Now, CanPropagatePredecessorsForPHIs is restructured to to look a lot more
similar to the code that actually performs the merge. Both functions now look
at the same phi nodes in about the same order.  Any conflicts (phi nodes with
different values for the same source) that could arise from merging or moving
phi nodes are detected. If no conflicts are found, the merge can happen.

Apart from only restructuring the checks, two main changes in functionality
happened.

Firstly, the old code rejected blocks with common predecessors in most cases.
The new code performs some extra checks so common predecessors can be handled
in a lot of cases. Wherever common predecessors still pose problems, the
blocks are left untouched.

Secondly, the old code rejected the merge when values (phi nodes) from BB were
used in any other place than Succ. However, it does not seem that there is any
situation that would require this check. Even more, this can be proven.

Consider that BB is a block containing of a single phi node "%a" and a branch
to Succ. Now, since the definition of %a will dominate all of its uses, BB
will dominate all blocks that use %a. Furthermore, since the branch from BB to
Succ is unconditional, Succ will also dominate all uses of %a.

Now, assume that one predecessor of Succ is not dominated by BB (and thus not
dominated by Succ). Since at least one use of %a (but in reality all of them)
is reachable from Succ, you could end up at a use of %a without passing
through it's definition in BB (by coming from X through Succ). This is a
contradiction, meaning that our original assumption is wrong. Thus, all
predecessors of Succ must also be dominated by BB (and thus also by Succ).

This means that moving the phi node %a from BB to Succ does not pose any
problems when the two blocks are merged, and any use checks are not needed.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51478 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 09:09:41 +00:00
Nick Lewycky
18b3da6c34 Constant integer vectors may also be negated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51476 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 04:54:45 +00:00
Nick Lewycky
02d639fcc0 Revert X + X --> X * 2 optz'n which pessimizes heavily on x86.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51474 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 04:34:58 +00:00
Nick Lewycky
8539fe26b7 Implement X + X for vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51472 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 04:14:51 +00:00
Nick Lewycky
39ac3b57bc Fix a recently added optimization to not crash on vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51471 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 03:26:47 +00:00
Dan Gohman
a332f17c8c Generalize the new code in instcombine's ComputeNumSignBits for handling
and/or to handle more cases (such as this add-sitofp.ll testcase), and
port it to selectiondag's ComputeNumSignBits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51469 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 02:28:01 +00:00
Gabor Greif
5edf210bdf Eliminate questionable syntax for stdin redirection. This probably also speeds things up a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51357 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 22:07:21 +00:00
Chris Lattner
eb0fdc150a Fix PR2346 by marking vaarg as volatile so that licm doesn't try to
hoist them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51356 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 22:05:28 +00:00
Dan Gohman
7a9708b984 Oops, commit the version of this test that actually works.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51351 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 21:19:36 +00:00
Dan Gohman
f35c8822a3 Port SelectionDAG's ComputeNumSignBits-using code to instcombine,
now that instcombine also has ComputeNumSignBits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51350 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 21:01:12 +00:00
Gabor Greif
f6cadc440c sabre brings to my attention that the 'tr' suffix is also obsolete
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51349 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 21:00:03 +00:00
Gabor Greif
722243bd40 Rename the last test with .llx extension to .ll, resolve duplicate test by renaming to isnan2. Now that no test has llx ending there is no need to search for them from dg.exp too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51328 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 19:52:04 +00:00
Chris Lattner
3d28b1b35b Teach instcombine 4 new xforms:
(add (sext x), cst) --> (sext (add x, cst'))
  (add (sext x), (sext y)) --> (sext (add int x, y))
  (add double (sitofp x), fpcst) --> (sitofp (add int x, intcst))
  (add double (sitofp x), (sitofp y)) --> (sitofp (add int x, y))

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

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


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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51302 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 05:46:13 +00:00
Devang Patel
52abbf5d8a Do not erase induction variable increment if it is used outside the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51280 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-19 22:23:55 +00:00
Chris Lattner
0c7a9a04e7 convert fptosi(sitofp x) -> x if the fp value has enough bits in its mantissa
to accurately represent the integer.  This triggers 9 times in 471.omnetpp,
though 8 of those seem to be inlined from the same place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51271 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-19 20:25:04 +00:00
Chris Lattner
a540623ab1 Fold FP comparisons where one operand is converted from an integer
type and the other operand is a constant into integer comparisons.
This happens surprisingly frequently (e.g. 10 times in 471.omnetpp),
which are things like this:

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

Clearly comparing tmp82 against i32 0 is cheaper here.

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

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

which is comparing an integer against 81.5 :).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51268 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-19 20:18:56 +00:00
Chris Lattner
5e0d71877c be more aggressive about transforming add -> or when the operands have no
intersecting bits.  This triggers all over the place, for example in lencode,
with adds of stuff like:

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

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

etc.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51263 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-19 20:01:56 +00:00
Duncan Sands
ec00fcb33d Fix PR2341 - when the length is 4 use an i32 not
an i16!  Cleaned up trailing whitespace while there.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51240 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-19 09:27:24 +00:00
Chris Lattner
47c9909a26 Fix PR2339
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51226 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-18 04:11:26 +00:00
Chris Lattner
98f41d2ce7 remove empty file?
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51225 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-18 04:10:18 +00:00
Nick Lewycky
08de1e476c Revert constant-folding change that will miscompile in some cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51223 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-17 19:00:05 +00:00
Nick Lewycky
d24ae8703f Constant fold inttoptr and ptrtoint.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51216 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-17 09:03:26 +00:00
Evan Cheng
62df5c9599 Fix test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51191 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-16 17:08:51 +00:00
Owen Anderson
3dc73d398c Move this test from ADCE to loop deletion, where it is more appropriate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51181 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-16 04:34:19 +00:00
Owen Anderson
ce12a2b71a Use loop deletion instead of ADCE in these tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51180 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-16 04:33:37 +00:00
Owen Anderson
d870b9a4e3 Use loop deletion instead of ADCE for removing loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51178 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-16 04:27:38 +00:00
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