Commit Graph

2409 Commits

Author SHA1 Message Date
Chris Lattner
e6dab05b03 rename test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76860 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23 05:25:12 +00:00
Dan Gohman
126b56659c Add a testcase for PR2831.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76527 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-21 01:02:18 +00:00
Dan Gohman
746f3b1a9b The upper argument of ConstantRange is exclusive, not inclusive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76492 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-20 22:34:18 +00:00
Dan Gohman
f241174421 Revert the addition of hasNoPointerOverflow to GEPOperator.
Getelementptrs that are defined to wrap are virtually useless to
optimization, and getelementptrs that are undefined on any kind
of overflow are too restrictive -- it's difficult to ensure that
all intermediate addresses are within bounds. I'm going to take
a different approach.

Remove a few optimizations that depended on this flag.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76437 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-20 17:43:30 +00:00
Eli Friedman
2451a64687 Canonicalize bitcasts between types like <1 x i64> and i64 to
insertelement/extractelement.

I'm not entirely sure this is precisely what we want to do: should we 
prefer bitcast(insertelement) or insertelement(bitcast)?  Similarly. should we 
prefer extractelement(bitcast) or bitcast(extractelement)?



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76345 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 23:06:53 +00:00
Eli Friedman
76e7ba893f Back out 76300; apparently the preference is to canonicalize the other
way (bitcast -> insert/extractelement).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76325 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 19:04:16 +00:00
Eli Friedman
8be17397c0 Add combine: X sdiv (1 << Y) -> X udiv (1 << Y) when X doesn't have the
sign bit set.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76304 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 09:53:21 +00:00
Eli Friedman
fc21f8ff14 Canonicalize insert/extractelement from single-element vectors into
bitcasts.

It would also be possible to canonicalize the other way; does anyone 
have a preference?



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76300 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 09:07:47 +00:00
Eli Friedman
62bb413435 Fix simplifylibcalls memset recognition to work on 64-bit platforms
where int is 32 bits.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76293 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 08:34:51 +00:00
Dan Gohman
850f791abc Fill in some holes in ScalarEvolution's loop iteration condition
analysis. This allows indvars to emit a simpler loop trip count
expression.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76085 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 17:34:36 +00:00
Eli Friedman
0c77db32dd Switch invars away from using isTrapping when it really shouldn't be
using it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75852 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 22:48:29 +00:00
Eli Friedman
fd2934f190 Don't restrict the set of instructions where we try to constant-fold the
operands; it's possible to end up with a constant-foldable operand to 
most instructions, even those which can't trap.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75845 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 22:13:34 +00:00
Dan Gohman
0196dc5733 Fix the expansion of umax and smax in the case where one or more of
the operands have pointer type, so that the resulting type matches
the original SCEV type, and so that unnecessary ptrtoints are
avoided in common cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75680 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 20:57:04 +00:00
Dan Gohman
533c67ba98 Add a testcase for a bug fixed by r75634.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75644 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 18:15:00 +00:00
Dale Johannesen
fa196e34b0 Revert 75571; I'm convinced this isn't the right thing to do.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75642 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 17:48:25 +00:00
Eli Friedman
b468709c91 Fix trivial todo in instcombine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75586 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 02:01:53 +00:00
Dan Gohman
0df6e09d43 Update LoopSimplify and LoopUnswitch to use the new makeLoopInvariant
function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75584 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 01:37:59 +00:00
Dan Gohman
65d1e2b6e7 Fix indvars to not assume that a loop with a single unique exit
block has a single unique exiting block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75579 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 01:09:02 +00:00
Dale Johannesen
4458ab0d83 Don't delete asm's just because their inputs are undefined;
xor R, R is a common and valid idiom for zeroing a register, for example.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75571 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 00:45:38 +00:00
Eli Friedman
070a981ab7 PR4548: optimize zext+udiv+trunc to udiv.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75539 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 22:46:01 +00:00
Eli Friedman
68f74712a9 Fix bug in run-line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75534 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 22:31:30 +00:00
Eli Friedman
709b33dc78 Canonicalize boolean +/- a constant to a select.
(I think it's reasonably clear that we want to have a canonical form for 
constructs like this; if anyone thinks that a select is not the best 
canonical form, please tell me.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75531 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 22:27:52 +00:00
Dan Gohman
85b05a2e60 Reapply 75252, with a fix to avoid the infinite recursion case. The
check for avoiding re-analyzing a widening cast needed to happen
earlier, as getSCEV itself may result in a isLoopGuardedByCond query.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75511 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 21:35:55 +00:00
Chris Lattner
6fbc1969e9 Move the re-sort of invalidated NonLocalPointerDeps cache earlier
so that all code paths get it.  PR4256 was about a case where the
phi translation loop would find all preds in the Visited cache, so
it could get by without re-sorting the NonLocalPointerDeps cache.
Fix this by resorting it earlier, there is no reason not to do this.

This patch inspired by Jakub Staszak's patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75476 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 17:14:23 +00:00
Nick Lewycky
d0cca24150 Revert r75252 which was causing some crashes at compile time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75384 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 20:38:25 +00:00
Dan Gohman
1b342583f6 Generalize ScalarEvolution's cast-folding code to support more kinds
of loops. Add several new functions to for working with ScalarEvolution's
add-hoc value-range analysis functionality.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75252 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 16:42:52 +00:00
Nick Lewycky
89f43a5c70 There's no need to consider PHI nodes in the same block as the instruction
we're inserting sigma/phi functions for. Patch by Andre Tavares.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75138 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 15:59:27 +00:00
Nick Lewycky
7f6aa2b162 Remove the vicmp and vfcmp instructions. Because we never had a release with
these instructions, no autoupgrade or backwards compatibility support is
provided.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 03:04:38 +00:00
Chris Lattner
0dabb0b177 do not try to analyze bitcasts from i64 to <2 x i32> in ComputedMaskedBits. While
we could do this, doing so requires adjusting the demanded mask and the code isn't 
doing that yet.  This fixes PR4495


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74699 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-02 16:04:08 +00:00
Dan Gohman
6cc18fedf8 Fix an instcombine abort on a scalar-to-vector bitcast. This fixes PR4487.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74646 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 21:38:46 +00:00
Dan Gohman
cffddcd726 Don't cache PHI exit values from exhaustive evaluations, because
an individual exhaustive evaluation reflects only the exit value
implied by an individual exit, which may differ from the actual
exit value of the loop if there are other exits. This fixes PR4477.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74447 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-29 20:34:13 +00:00
Dan Gohman
f7ca1611e2 Don't try to split a loop when the controlling icmp instruction
doesn't have an IV-based operand. This fixes PR4471.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74399 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 22:58:27 +00:00
Dan Gohman
4b35f83b91 Teach LoopSimplify how to merge multiple loop exits into a single exit,
when one of them can be converted to a trivial icmp and conditional
branch.

This addresses what is essentially a phase ordering problem.
SimplifyCFG knows how to do this transformation, but it doesn't do so
if the primary block has any instructions in it other than an icmp and
a branch. In the given testcase, the block contains other instructions,
however they are loop-invariant and can be hoisted. SimplifyCFG doesn't
have LoopInfo though, so it can't hoist them. And, it's important that
the blocks be merged before LoopRotation, as it doesn't support
multiple-exit loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74396 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 21:30:38 +00:00
Dan Gohman
de53dc03f5 When a value is used multiple times within a single PHI, instructions
inserted to replace that value must dominate all of of the basic
blocks associated with the uses of the value in the PHI, not just
one of them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74376 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 05:16:57 +00:00
Dan Gohman
16bdfdb178 Add some testcases for some of the recent ScalarEvolution bug fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74353 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 22:54:11 +00:00
Dan Gohman
6b9c959c61 Fix LCSSA to avoid emitting a PHI node for the unwind destination of
an invoke instruction, since the value isn't really live across that
edge.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74242 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 00:31:13 +00:00
Dan Gohman
e5aceed168 Simplify [su]max(MAX, n) to MAX. This comes up in loop tripcount
computations in loops with multiple exits.

Adjust the testcase for PR4436 so that the relevant portion isn't
optimized away.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74073 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 14:46:22 +00:00
Dan Gohman
32a81a3f6d When inserting code into a loop preheader, insert it before the
terminator, instead of after the last phi. This fixes a bug
exposed by ScalarEvolution analyzing more kinds of loops.
This fixes PR4436.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74072 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 14:31:06 +00:00
Dan Gohman
51f53b7f5a Fix ScalarEvolution's backedge-taken count computations to check for
overflow when computing a integer division to round up.

Thanks to Nick Lewycky for noticing this!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73862 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 23:46:38 +00:00
Nick Lewycky
e47f59db44 Expand this test to handle more cases (remainder and shifts) of zero.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73839 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 01:56:41 +00:00
Chris Lattner
1db6866147 implement PR4424: 0/x is always 0 for integer division.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73835 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 01:15:55 +00:00
Dan Gohman
97b52b2a88 Tweak this test to be a little less unusual.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73808 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 00:40:56 +00:00
Dan Gohman
763bad1a2b Generalize isLoopGuardedByCond's checking to consider two
SCEVUnknowns with identical Instructions to be equal. This allows
it to analze cases such as the attached testcase, where the front-end
has cloned the loop controlling expression. Along with r73805, this
lets IndVarSimplify eliminate all the sign-extend casts in the
loop in the attached testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73807 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 00:35:32 +00:00
Dan Gohman
958e292c7a Don't (unconditionally) use getSCEVAtScope to simplify the step
expression in IVUsers, because in the case of a use of a non-linear
addrec outside of a loop, this causes the addrec to be evaluated as
a linear addrec.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73774 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 17:33:15 +00:00
Chris Lattner
79c740ff47 make jump threading handle lexically identical compare instructions
as if they were multiple uses of the same instruction.  This interacts
well with the existing loadpre that j-t does to open up many new jump
threads earlier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73768 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 16:27:56 +00:00
Nick Lewycky
9683f18174 Teach jump threading to look at comparisons between phi nodes and non-constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73755 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 04:56:29 +00:00
Chris Lattner
6a35b40250 Improve tail call elim to move loads above readonly calls
when it allows forming a tail call.  Patch by Frits van
Bommel.  This implements PR4323.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73752 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 04:22:16 +00:00
Chris Lattner
849832c0fb part of PR4405: disable a contentious optimization for
strcmp -> memcmp when the lengths of the strings are unknown.

Patch by Nick Lewycky!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73751 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 04:17:36 +00:00
Dan Gohman
4e8a98519e Remove the code from IVUsers that attempted to handle
casted induction variables in cases where the cast
isn't foldable. It ended up being a pessimization in
many cases. This could be fixed, but it would require
a bunch of complicated code in IVUsers' clients. The
advantages of this approach aren't visible enough to
justify it at this time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73706 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:54:06 +00:00
Dan Gohman
fd3daa74c2 Generalize the zext(trunc(t) & C) instcombine to work even with
C is not a low-bits mask, and add a similar instcombine for
zext((trunc(t) & C) ^ C).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73705 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:30:21 +00:00
Dan Gohman
a392c788be Instcombine zext(trunc(x) & mask) to x&mask, even if the trunc has
multiple users.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73656 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 23:17:05 +00:00
Dan Gohman
559254b697 Add -disable-output to a bunch of tests that don't care about the output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73633 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 20:56:26 +00:00
Dale Johannesen
42c3f554f4 This fixes a bug introduced in 72661, which can
move loads back past a check that the load address
is valid, see new testcase.  The test that went
in with 72661 has exactly this case, except that
the conditional it's moving past is checking
something else; I've settled for changing that
test to reference a global, not a pointer.  It
may be possible to scan all the tests you pass and
make sure none of them are checking any component
of the address, but it's not trivial and I'm not
trying to do that here.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73632 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 20:48:23 +00:00
Eli Friedman
af79ae558f Correct an accidental duplication of the test (patch doesn't handle
creating new files very well).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73599 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 03:05:00 +00:00
Eli Friedman
a999a511f7 PR3439: Correct a silly mistake in the SimplifyDemandedUseBits code for
SRem.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73598 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 02:57:36 +00:00
Dan Gohman
c6ac322c1c Generalize a few more instcombines to be vector/scalar-independent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73541 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 19:55:29 +00:00
Dan Gohman
61ffa8e373 Instcombine's ShrinkDemandedConstant may strip bits out of constants,
obscuring what would otherwise be a low-bits mask.  Use ComputeMaskedBits
to compute what ShrinkDemandedConstant knew about to reconstruct a
low-bits mask value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73540 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 19:52:01 +00:00
Chris Lattner
3d0cbbe0ad Testcase for r73506
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73508 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 17:23:25 +00:00
Dan Gohman
6de29f8d96 Support vector casts in more places, fixing a variety of assertion
failures.

To support this, add some utility functions to Type to help support
vector/scalar-independent code. Change ConstantInt::get and
ConstantFP::get to support vector types, and add an overload to
ConstantInt::get that uses a static IntegerType type, for
convenience.

Introduce a new getConstant method for ScalarEvolution, to simplify
common use cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73431 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 22:12:54 +00:00
Dale Johannesen
c1f104054d Fix the crash in this test. This is basically the same
problem addressed in 31284, but the patch there only
addressed the case where an invoke is the first thing in
a block.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73416 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 20:59:27 +00:00
Chris Lattner
d3b295c23f fix testcase to properly check for the patch in r73195.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73380 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 05:46:02 +00:00
Dan Gohman
bd59d7b603 Implement more aggressive folding of add operand lists when
they contain multiplications of constants with add operations.
This helps simplify several kinds of things; in particular it
helps simplify expressions like ((-1 * (%a + %b)) + %a) to %b,
as expressions like this often come up in loop trip count
computations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73361 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 22:58:51 +00:00
Dan Gohman
4d8414f420 Teach SCEVExpander's visitAddRecExpr to reuse an existing canonical
induction variable when the addrec to be expanded does not require
a wider type. This eliminates the need for IndVarSimplify to
micro-manage SCEV expansions, because SCEVExpander now
automatically expands them in the form that IndVarSimplify considers
to be canonical. (LSR still micro-manages its SCEV expansions,
because it's optimizing for the target, rather than for
other optimizations.)

Also, this uses the new getAnyExtendExpr, which has more clever
expression simplification logic than the IndVarSimplify code it
replaces, and this cleans up some ugly expansions in code such as
the included masked-iv.ll testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73294 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-13 16:25:49 +00:00
Dan Gohman
e54aba5fa9 Don't do (x - (y - z)) --> (x + (z - y)) on floating-point types, because
it may round differently. This fixes PR4374.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73243 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 19:23:25 +00:00
Nick Lewycky
8728d7a3ea Given two identical weak functions, produce one internal function and two weak
thunks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73230 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 15:56:56 +00:00
Nick Lewycky
f343b69f47 This test is wrong. If you have two weak functions F and G you can't make
either one call the other since either one can be replaced at link time, and
they need to be independent.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73225 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 13:24:41 +00:00
Chris Lattner
3590abfda0 Fix 4366: store to null in non-default addr space should not be
turned into unreachable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73195 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-11 17:54:56 +00:00
Eli Friedman
b9a4cacc91 PR4340: Run SimplifyDemandedVectorElts on insertelement instructions;
sometimes it can find simplifications that won't be found otherwise.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73006 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-06 20:08:03 +00:00
Dan Gohman
ae3a0be92e Split the Add, Sub, and Mul instruction opcodes into separate
integer and floating-point opcodes, introducing
FAdd, FSub, and FMul.

For now, the AsmParser, BitcodeReader, and IRBuilder all preserve
backwards compatability, and the Core LLVM APIs preserve backwards
compatibility for IR producers. Most front-ends won't need to change
immediately.

This implements the first step of the plan outlined here:
http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72897 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 22:49:04 +00:00
Dan Gohman
0e19a3f89e Check in test changes that I accidentally left out of r72872.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72875 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 18:22:31 +00:00
Dan Gohman
68c9344056 Don't attempt to simplify an non-affine IV expression if it can't
be simplified to a loop-invariant value. This fixes PR4315.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72798 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-03 19:11:31 +00:00
Evan Cheng
5d16396a33 Avoid infinite looping in AllGlobalLoadUsesSimpleEnoughForHeapSRA(). This can happen when PHI uses are recursively dependent on each other.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72710 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-02 00:56:07 +00:00
Eli Friedman
41b33f437f PR4286: Make RewriteLoadUserOfWholeAlloca and
RewriteStoreUserOfWholeAlloca deal with tail padding because 
isSafeUseOfBitCastedAllocation expects them to.  Otherwise, we crash 
trying to erase the bitcast.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72688 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-01 09:14:32 +00:00
Owen Anderson
88554df4a2 Be more aggressive in doing LoadPRE by tracing backwards when a block only has
a single predecessor.

Patch by Jakub Staszak.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72661 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-31 09:03:40 +00:00
Chris Lattner
0e98e4d299 fix PR4284, a bug in simplifylibcalls handling memcmp. Patch by
Benjamin Kramer!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72625 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 18:43:04 +00:00
Nick Lewycky
e3f1fb1ee8 Use Operands.data() instead of &Operands[0] where Operands is a potentially
empty SmallVector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72512 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-28 04:08:10 +00:00
Dan Gohman
c2695eba57 Revert 72493 and replace it with a more conservative fix, for now: don't
rewrite the comparison if there is any implicit extension or truncation
on the induction variable. I'm planning for IVUsers to eventually take
over some of the work of this code, and for it to be generalized.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72496 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 21:10:47 +00:00
Dan Gohman
ead28bd04b In ChangeCompareStride, when the stride to be reused is truncated to
a smaller type, promoted its offset back up to the type of the new
comparison. This fixes PR4222.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72493 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 20:00:18 +00:00
Dan Gohman
4a4f767235 Teach SCEVExpander to avoid creating over-indexed GEP indices when
possible. For example, it now emits

  %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 2, i64 %tmp, i64 1

instead of the equivalent but less obvious

  %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %tmp, i64 19


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72452 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 02:00:53 +00:00
Dan Gohman
f876ad0a70 In cases where a pointer value is an operand of a multiplication or
division operation, don't attempt to use the operation's value as
the base of a getelementptr. This fixes PR4271.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72422 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-26 17:41:16 +00:00
Chris Lattner
ab9cf1282b make memdep use the getModRefInfo method for stores instead of the
low-level alias() method, allowing it to reason more aggressively
about pointers into constant memory.  PR4189


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72403 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-25 21:28:56 +00:00
Dan Gohman
95bdbfa066 When rewriting the loop exit test with the canonical induction variable,
leave the original comparison in place if it has other uses, since the
other uses won't be dominated by the new comparison instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72369 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 19:11:38 +00:00
Dan Gohman
453aa4fbf1 Generalize SCEVExpander::visitAddRecExpr's GEP persuit, and avoid
sending SCEVUnknowns to expandAddToGEP. This avoids the need for
expandAddToGEP to bend the rules and peek into SCEVUnknown
expressions.

Factor out the code for testing whether a SCEV can be factored by
a constant for use in a GEP index. This allows it to handle
SCEVAddRecExprs, by recursing.

As a result, SCEVExpander can now put more things in GEP indices,
so it emits fewer explicit mul instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72366 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 18:06:31 +00:00
Torok Edwin
b679de2a21 The rewriter may hold references to instructions that are deleted because they are trivially dead.
Fix by clearing the rewriter cache before deleting the trivially dead
instructions.
Also make InsertedExpressions use an AssertingVH to catch these
bugs easier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72364 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 14:23:16 +00:00
Evan Cheng
2ddb6f1440 Fix bug in FoldFCmp_IntToFP_Cst. If inttofp is a uintofp, use unsigned instead of signed integer constant.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72300 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 23:10:53 +00:00
Dan Gohman
d6d0294e35 Teach IndVarSimplify's FixUsesBeforeDefs to handle InvokeInsts by
assuming that the use of the value is in a block dominated by the
"normal" destination. LangRef.html and other documentation sources
don't explicitly guarantee this, but it seems to be assumed in
other places in LLVM at least.

This fixes an assertion failure on the included testcase, which
is derived from the Ada testsuite.

FixUsesBeforeDefs is a temporary measure which I'm looking to
replace with a more capable solution.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72266 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 16:47:11 +00:00
Dan Gohman
0d56b06f86 Fix a thinko in the code that adapted SCEVMulExpr operands for
use in expanding SCEVAddExprs with GEPs. The operands of a
SCEVMulExpr need to be multiplied together, not added.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72250 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 07:14:20 +00:00
Eli Friedman
15002a2b52 Fix broken logic in DominatorTreeBase::Split. Part of PR4238.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72231 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 21:47:54 +00:00
Eli Friedman
0f4012ca9d Fix some incorrect logic in DominanceFrontier::splitBlock. Part of
PR4238.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72223 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 20:40:30 +00:00
Dan Gohman
9004c8afd4 Teach ValueTracking a new way to analyze PHI nodes, and and teach
Instcombine to be more aggressive about using SimplifyDemandedBits
on shift nodes. This allows a shift to be simplified to zero in the
included test case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72204 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 02:28:33 +00:00
Dan Gohman
513fae2db5 Suppress the IV reversal transformation in the case that the RHS
of the comparison is defined inside the loop. This fixes a
use-before-def problem, because the transformation puts a use
of the RHS outside the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72149 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 00:34:08 +00:00
Dan Gohman
5be18e8476 Teach SCEVExpander to expand arithmetic involving pointers into GEP
instructions. It attempts to create high-level multi-operand GEPs,
though in cases where this isn't possible it falls back to casting
the pointer to i8* and emitting a GEP with that. Using GEP instructions
instead of ptrtoint+arithmetic+inttoptr helps pointer analyses that
don't use ScalarEvolution, such as BasicAliasAnalysis.

Also, make the AddrModeMatcher more aggressive in handling GEPs.
Previously it assumed that operand 0 of a GEP would require a register
in almost all cases. It now does extra checking and can do more
matching if operand 0 of the GEP is foldable. This fixes a problem
that was exposed by SCEVExpander using GEPs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72093 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 02:15:55 +00:00
Dan Gohman
04623272d2 Add nounwind to a few tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72002 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 15:16:49 +00:00
Dale Johannesen
6f21a8f636 Testcase for 71688.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71691 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 18:33:24 +00:00
Chris Lattner
aab6ec49d2 calls in nothrow functions can be marked nothrow even if the callee
is not known to be nothrow.  This allows readnone/readonly functions
to be deleted even if we don't know whether the callee can throw.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71676 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 17:39:14 +00:00
Chris Lattner
bcc2e7dc2c Fix PR4206 - crash in simplify lib calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71644 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 06:26:11 +00:00
Dan Gohman
81db61a2e6 Factor the code for collecting IV users out of LSR into an IVUsers class,
and generalize it so that it can be used by IndVarSimplify. Implement the
base IndVarSimplify transformation code using IVUsers. This removes
TestOrigIVForWrap and associated code, as ScalarEvolution now has enough
builtin overflow detection and folding logic to handle all the same cases,
and more. Run "opt -iv-users -analyze -disable-output" on your favorite
loop for an example of what IVUsers does.

This lets IndVarSimplify eliminate IV casts and compute trip counts in
more cases. Also, this happens to finally fix the remaining testcases
in PR1301.

Now that IndVarSimplify is being more aggressive, it occasionally runs
into the problem where ScalarEvolutionExpander's code for avoiding
duplicate expansions makes it difficult to ensure that all expanded
instructions dominate all the instructions that will use them. As a
temporary measure, IndVarSimplify now uses a FixUsesBeforeDefs function
to fix up instructions inserted by SCEVExpander. Fortunately, this code
is contained, and can be easily removed once a more comprehensive
solution is available.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71535 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 02:17:14 +00:00
Dan Gohman
efb9fbfdab When forgetting SCEVs for loop PHIs, don't forget SCEVUnknown values.
These values aren't analyzable, so they don't care if more information
about the loop trip count can be had. Also, SCEVUnknown is used for
a PHI while the PHI itself is being analyzed, so it needs to be left
in the Scalars map. This fixes a variety of subtle issues.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71533 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 01:27:58 +00:00
Chris Lattner
ef554846f0 fix RewriteStoreUserOfWholeAlloca to use the correct type size
method, fixing a crash on PR4146.  While the store will 
ultimately overwrite the "padded size" number of bits in memory,
the stored value may be a subset of this size.  This function
only wants to handle the case where all bits are stored.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71224 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-08 15:54:41 +00:00
Eli Friedman
5877ad7e90 PR4123: don't crash when inlining a call which uses its own result.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71199 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-08 00:22:04 +00:00
Dan Gohman
9a38e3e399 Revert 71165. It did more than just revert 71158 and it introduced
several regressions. The problem due to 71158 is now fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-07 19:46:24 +00:00
Duncan Sands
1978426a94 Revert r70876 and add a testcase (@c7) showing the problem:
bits captured, but the pointer marked nocapture.  In fact
I now recall that this problem is why only readnone functions
returning void were considered before!  However keep a small
fix that was also in r70876: a readnone function returning
void can result in bits being captured if it unwinds, so
test for this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71168 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-07 18:08:34 +00:00
Bill Wendling
5b8479c385 Temporarily revert r71158. It was causing a failure during a full bootstrap:
checking for bcopy... no
checking for getc_unlocked... Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decUtility.c:360: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[4]: *** [decUtility.o] Error 1
make[4]: *** Waiting for unfinished jobs....
Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decNumber.c:5591: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[4]: *** [decNumber.o] Error 1
make[3]: *** [all-stage2-libdecnumber] Error 2
make[3]: *** Waiting for unfinished jobs....



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71165 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-07 17:26:14 +00:00
Dan Gohman
704b6980b8 Constant-fold ptrtoint+add+inttoptr to gep when the pointer is an
array and the add is within range. This helps simplify expressions
expanded by ScalarEvolutionExpander.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71158 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-07 14:24:56 +00:00
Duncan Sands
cfd0ebea27 Fix PR3754: don't mark functions that wrap MallocInst with
the readnone.  Since MallocInst is scheduled for deletion
it doesn't seem worth doing anything more subtle, such as
having mayWriteToMemory return true for MallocInst.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71077 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-06 08:42:00 +00:00
Duncan Sands
7af1c78b98 Allow readonly functions to unwind exceptions. Teach
the optimizers about this.  For example, a readonly
function with no uses cannot be removed unless it is
also marked nounwind.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71071 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-06 06:49:50 +00:00
Bill Wendling
a48941087b Temporarily reverting r71008. It was causing this failure:
Running /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/test/
CodeGen/X86/dg.exp ...
FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/test/
CodeGen/X86/change-compare-stride-1.ll
Failed with exit(1) at line 2
while running: grep {cmpq       $-478,} change-compare-stride-1.ll.tmp
child process exited abnormally



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71013 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-05 20:49:46 +00:00
David Greene
58deef5559 Handle overflow of 64-bit loop conditions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71008 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-05 20:22:36 +00:00
Mike Stump
fe095f39e7 Restore minor deletion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70892 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-04 18:40:41 +00:00
Dan Gohman
afc36a9520 Previously, RecursivelyDeleteDeadInstructions provided an option
of returning a list of pointers to Values that are deleted. This was
unsafe, because the pointers in the list are, by nature of what
RecursivelyDeleteDeadInstructions does, always dangling. Replace this
with a simple callback mechanism. This may eventually be removed if
all clients can reasonably be expected to use CallbackVH.

Use this to factor out the dead-phi-cycle-elimination code from LSR
utility function, and generalize it to use the
RecursivelyDeleteTriviallyDeadInstructions utility function.

This makes LSR more aggressive about eliminating dead PHI cycles;
adjust tests to either be less trivial or to simply expect fewer
instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70636 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-02 18:29:22 +00:00
Dan Gohman
4acd12a0cb Don't try to mix integers and pointers in an icmp instruction
in getSCEVAtScope.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70495 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 16:40:30 +00:00
Dale Johannesen
c9cf35055f Fix recent regression in gcc.dg/pr26719.c (6835035).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 16:38:47 +00:00
Dan Gohman
ce66c6114f As with r70333, give the primary induction variable a use so
that it can't be trivially eliminated.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70334 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 22:05:13 +00:00
Dan Gohman
cab9cf01ce Make this testcase slightly less trivial, so that it doesn't fail
if indvars happens to optimize away the unused primary induction
variable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70333 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 22:03:26 +00:00
Dale Johannesen
617d108a63 Fix PR 4086, a bug in FP IV elimination.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70247 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 21:03:15 +00:00
Dan Gohman
01ecca20bf Teach getZeroExtendExpr and getSignExtendExpr to use trip-count
information to simplify [sz]ext({a,+,b}) to {zext(a),+,[zs]ext(b)},
as appropriate.

These functions and the trip count code each call into the other, so
this requires careful handling to avoid infinite recursion. During
the initial trip count computation, conservative SCEVs are used,
which are subsequently discarded once the trip count is actually
known.

Among other benefits, this change lets LSR automatically eliminate
some unnecessary zext-inreg and sext-inreg operation where the
operand is an induction variable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70241 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 20:16:15 +00:00
Dan Gohman
d6c329532b Handle ands with ~0 correctly too. This fixes PR4052.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 01:41:10 +00:00
Dan Gohman
1c8491ecc7 Add several more icmp simplifications. Transform signed comparisons
into unsigned ones when the operands are known to have the same
sign bit value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70053 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 17:12:48 +00:00
Dan Gohman
2c73d5fb9e Handle ands with 0 and shifts by 0 correctly. These aren't
common, but indvars shouldn't crash on them. This fixes PR4054.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70051 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 17:05:40 +00:00
Dan Gohman
e22d503ee5 Fix an error in this test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69893 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 15:22:28 +00:00
Dan Gohman
752ec7da50 Change SCEVExpander's expandCodeFor to provide more flexibility
with the persistent insertion point, and change IndVars to make
use of it. This fixes a bug where IndVars was holding on to a
stale insertion point and forcing the SCEVExpander to continue to
use it.

This fixes PR4038.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69892 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 15:16:49 +00:00
Owen Anderson
887fde88ca Testcase for PR2639.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69867 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 04:30:52 +00:00
Owen Anderson
d92395fe92 Testcase for PR2537.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69866 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 04:26:42 +00:00
Owen Anderson
f2a5c0a04c Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69865 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 04:24:19 +00:00
Owen Anderson
176aeb1afa Testcase for PR3085.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69863 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 04:21:14 +00:00
Owen Anderson
d49468aa50 Add testcase from PR3086.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69862 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 04:14:03 +00:00
Evan Cheng
9c15949967 Make sure both operands have binary instructions have the same type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69844 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 23:39:28 +00:00
Evan Cheng
1abe64663e Avoid deferencing use_begin() if value does not have a use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69836 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 22:45:37 +00:00
Dan Gohman
aabb04f527 SCEVExpander's InsertCastOfTo knows how to move existing cast
instructions in order to avoid inserting new ones. However, if
the cast instruction is the SCEVExpander's InsertPt, this
causes subsequently emitted instructions to be inserted near
the cast, and not at the location of the original insert point.
Fix this by adjusting the insert point in such cases.
This fixes PR4009.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69808 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 16:11:16 +00:00
Chris Lattner
33e24adc3b fix a crash on a pointless but valid zero-length memset, rdar://6808691
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69680 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 16:52:12 +00:00
Dale Johannesen
764eccf025 Another testcase for IV shortening.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69247 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 00:45:21 +00:00
Dale Johannesen
dd1f9e4bf6 Enhance induction variable code to remove the
sext around sext(shorter IV + constant), using a
longer IV instead, when it can figure out the
add can't overflow.  This comes up a lot in
subscripting; mainly affects 64 bit.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69123 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 01:10:12 +00:00
Devang Patel
517576d6f9 While inlining, clone llvm.dbg.func.start intrinsic and adjust
llvm.dbg.region.end instrinsic. This nested llvm.dbg.func.start/llvm.dbg.region.end pair now enables DW_TAG_inlined_subroutine support in code generator.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69118 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 00:17:06 +00:00
Evan Cheng
df2f1189a3 Optimize conditional branch on i1 phis with non-constant inputs.
This turns:

eq:
        %3 = icmp eq i32 %1, %2
        br label %join

ne:
        %4 = icmp ne i32 %1, %2
        br label %join

join:
        %5 = phi i1 [%3, %eq], [%4, %ne]
        br i1 %5, label %yes, label %no

=>

eq:
        %3 = icmp eq i32 %1, %2
        br i1 %3, label %yes, label %no

ne:
        %4 = icmp ne i32 %1, %2
        br i1 %4, label %yes, label %no


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69102 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 23:40:03 +00:00
Chris Lattner
266c7bbbbc Add a new "available_externally" linkage type. This is intended
to support C99 inline, GNU extern inline, etc.  Related bugzilla's
include PR3517, PR3100, & PR2933.  Nothing uses this yet, but it
appears to work.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68940 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-13 05:44:34 +00:00
Chris Lattner
f5b6bc7f0e add some optimizations for strncpy/strncat and factor some
code.  Patch by Benjamin Kramer!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68885 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-12 05:06:39 +00:00
Chris Lattner
ddfa57bd7b Instcombine should not promote whole computation trees to "strange"
integer types, unless they are already strange.  This prevents it from
turning the code produced by SROA into crazy libcalls and stuff that 
the code generator can't handle.  In the attached example, the result
was an i96 multiply that caused the x86 backend to assert.

Note that if TargetData had an idea of what the legal types are for
a target that this could be used to stop instcombine from introducing
i64 muls, as Scott wanted.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68598 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-08 05:41:03 +00:00
Chris Lattner
62ce3b31a7 fix rdar://6762290, a crash compiling cxx filt with clang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 05:03:34 +00:00
Ed Schouten
b5e0a96a8d Let the strcat optimizer return the pointer to the start of the buffer,
instead of the place where it started to perform the string copy.

- PR3661
- Patch by Benjamin Kramer!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68443 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-06 13:06:48 +00:00
Owen Anderson
e8a290fefc Reapply r68211, with the miscompilations it caused fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68262 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 23:53:49 +00:00
Dan Gohman
e63c4a2010 Revert r68172. It caused regressions in
Applications/Burg/burg
  Applications/ClamAV/clamscan
and many other tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68211 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 16:37:47 +00:00
Owen Anderson
f41fcbb60d Enhance GVN to propagate simple conditionals. This fixes PR3921.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68172 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 01:20:45 +00:00
Evan Cheng
de62192843 Throttle back "fold select into operand" transformation. InstCombine should not generate selects of two constants unless they are selects of 0 and 1.
e.g.
define i32 @t1(i32 %c, i32 %x) nounwind {
       %t1 = icmp eq i32 %c, 0
       %t2 = lshr i32 %x, 18
       %t3 = select i1 %t1, i32 %t2, i32 %x
       ret i32 %t3
}

was turned into

define i32 @t2(i32 %c, i32 %x) nounwind {
       %t1 = icmp eq i32 %c, 0
       %t2 = select i1 %t1, i32 18, i32 0
       %t3 = lshr i32 %x, %t2
       ret i32 %t3
}

For most targets, that means materializing two constants and then a select. e.g. On x86-64

movl    %esi, %eax
shrl    $18, %eax
testl   %edi, %edi
cmovne  %esi, %eax
ret

=>

xorl    %eax, %eax
testl   %edi, %edi
movl    $18, %ecx
cmovne  %eax, %ecx
movl    %esi, %eax
shrl    %cl, %eax
ret

Also, the optimizer and codegen can reason about shl / and / add, etc. by a constant. This optimization will hinder optimizations using ComputeMaskedBits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-31 20:42:45 +00:00
Devang Patel
b23c232fc8 Loop Index Split can eliminate a loop if it can determin if loop body is executed only once. There was a bug in determining IV based value of the iteration for which the loop body is executed. Fix it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68071 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-30 22:24:10 +00:00
Devang Patel
575ec806e0 Before deleting a basic block, give other loop passes a chance cleanup analysis values, related to the instructions in the basic block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67719 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-25 23:57:48 +00:00
Chris Lattner
e8e4921967 Fix PR3874 by restoring a condition I removed, but making it more
precise than it used to be.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67662 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-25 00:28:58 +00:00
Chris Lattner
a0e6969bbe canonicalize inttoptr and ptrtoint instructions which cast pointers
to/from integer types that are not intptr_t to convert to intptr_t
then do an integer conversion to the dest type.  This exposes the
cast to the optimizer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67638 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 18:35:40 +00:00
Chris Lattner
4f9797d683 two changes:
1. Make instcombine always canonicalize trunc x to i1 into an icmp(x&1).  This 
   exposes the AND to other instcombine xforms and is more of what the code
   generator expects.
2. Rewrite the remaining trunc pattern match to use 'match', which 
   simplifies it a lot.
   


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67635 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 18:15:30 +00:00
Chris Lattner
344c7c5cc4 Fix instcombine to not introduce undefined shifts when merging two
shifts together.  This fixes PR3851.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67411 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-20 22:41:15 +00:00
Chris Lattner
a5affdcf4c aha, DAE does have to think about PHI nodes. Many thanks to "Dr Evil" (aka Duncan)
for pointing this out :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67212 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 16:48:45 +00:00
Chris Lattner
b44b3666f9 Fix PR3826 - InstComb assert with vector shift, by not calling ComputeNumSignBits on a vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67211 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 16:32:19 +00:00
Zhou Sheng
df95a2f6a9 Fix a bug.
If I->use_empty(), this method should return false.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67180 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 07:56:13 +00:00
Chris Lattner
bda0765e07 Fix PR3807 by inserting 'insertelement' instructions in the normal dest of
an invoke instead of after the invoke (in its block), which is invalid.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67139 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 00:31:45 +00:00
Chris Lattner
7150371097 remove a test that depends on -debug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66937 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 20:31:48 +00:00
John Criswell
090c0a2ffd Do not attempt to do parial redundancy elimination on void values.
Also fixed a punctuation error in the header comment.
This fixes PR3775.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66542 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 15:04:53 +00:00
Evan Cheng
8c7848f17f If a function is marked alwaysinline, it must be inlined (possibly for correctness). Do so even if the callee has dynamic alloca and the caller doesn't.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66539 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 07:57:50 +00:00
Devang Patel
412a446974 Ignore debug info while evaluating function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66490 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-09 23:04:12 +00:00
Chris Lattner
29e641761e teach SROA to handle promoting vector allocas with a memset into them into
a vector type instead of into an integer type.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66368 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-08 04:17:04 +00:00
Chris Lattner
c570487d45 Enhance SROA to "promote to scalar" allocas which are
memcpy/memmove'd into or out of.  This fixes a serious
perf issue that Nate ran into.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66366 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-08 04:04:21 +00:00
Chris Lattner
6f6923fd4f fix a serious pessimization that Tron on IRC pointed out where we would
"boolify" pointers, generating really awful code because getting the pointer
value requires a load itself.  Before:

_foo:
	movb	$1, _X.b
	ret
_get:
	xorl	%ecx, %ecx
	movb	_X.b, %al
	testb	%al, %al
	movl	$_Y, %eax
	cmove	%ecx, %eax
	ret

With the xform disabled:

_foo:
	movl	$_Y, _X
	ret
_get:
	movl	_X, %eax
	ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66351 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-07 23:32:02 +00:00
Duncan Sands
fc5940d2a0 While thinking about the one-definition-rule and trying
to find a tiny mouse hole to squeeze through, it struck
me that globals without a name can be considered internal
since they can't be referenced from outside the current
module.  This patch makes GlobalOpt give them internal
linkage.  Also done for aliases even though they always
have names, since in my opinion anonymous aliases should
be allowed for consistency with global variables and
functions.  So if that happens one day, this code is ready!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66267 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 10:21:56 +00:00
Devang Patel
00e389c8c8 While converting an aggregate to scalare, ignore and remove aggregate's debug info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66262 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 07:03:54 +00:00
Devang Patel
06b1e67d44 While hoisting instruction to speculatively execute simple bb, ignore dbg intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66255 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 06:00:17 +00:00
Devang Patel
c64bc16cae Skip DbgInfoIntrinsic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66244 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 02:59:27 +00:00
Devang Patel
771281f180 Revert 66224.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66233 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 01:39:36 +00:00
Devang Patel
743cdf8edf Revert rev. 66167.
We are still not out of woods yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66232 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 01:37:41 +00:00
Devang Patel
f70bda2f81 Do not let debug info prevert globalopt from shriking a global vars to boolean.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66224 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 00:21:00 +00:00
Devang Patel
5049600672 GlobalOpt only process non constant local GVs while optimizing global vars.
If non constant local GV named A is used by a constant local GV named B (e.g. llvm.dbg.variable) and B is not used by anyone else then eliminate A as well as B.

In other words, debug info should not interfere in removal of unused GV.
--This life, and those below, will be ignored--

M    test/Transforms/GlobalOpt/2009-03-03-dbg.ll
M    lib/Transforms/IPO/GlobalOpt.cpp


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66167 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 18:12:02 +00:00
Bill Wendling
85435046ac Should have XFAILed this test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66086 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 22:29:34 +00:00
Bill Wendling
380c3ca093 Temporarily revert r65994. It was causing rdar://6646455.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66083 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 22:02:09 +00:00
Chris Lattner
1541e0f7da Fix PR3720 by properly propagating alignment information from memcpy/memmove
onto element accesses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66053 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 19:20:50 +00:00
Devang Patel
7f6179d1d8 If a global constant is dead then global's debug info should not prevent the optimizer in deleting the global. And while deleting global, delete global's debug info also.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65994 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 01:22:23 +00:00
Devang Patel
cf42ee42b1 If branch conditions' one successor is dominating another non-latch successor then this loop's iteration space can not be restricted. In this example block bb5 is always executed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65902 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 23:39:14 +00:00
Duncan Sands
5b7cfb02f7 Fix PR3694: add an instcombine micro-optimization that helps
clean up when using variable length arrays in llvm-gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65832 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 09:18:21 +00:00
Chris Lattner
585cfb6821 adjust for asmprinter change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65741 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-01 00:26:51 +00:00
Chris Lattner
3aa8f6bc11 adjust for asmprinter change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65740 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-01 00:25:46 +00:00
Chris Lattner
13397b97ee adjust test to make it more robust
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65739 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-01 00:24:40 +00:00
Zhou Sheng
a8d57fe96b Ignore dbg info intrinsics when folding conditional branch to
conditional branch predecessors.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65509 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 06:56:37 +00:00
Chris Lattner
58b1ac76d4 Fix PR3667
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65464 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-25 18:20:01 +00:00
Zhou Sheng
9a7c743fc0 Don't block basic block with only SwitchInst to fold into predecessors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65456 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-25 15:34:27 +00:00
Dan Gohman
85937de26b Add a testcase for the problem fixed in r65289.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65365 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 02:17:42 +00:00
Dan Gohman
0001e56f15 Fix a ValueTracking rule: RHS means operand 1, not 0. Add a simple
ashr instcombine to help expose this code. And apply the fix to
SelectionDAG's copy of this code too.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65364 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 02:00:40 +00:00
Devang Patel
5622f07a21 While folding unconditional return move DbgRegionEndInst into the predecessor, instead of removing it. This fixes following tests from llvmgcc42 testsuite.
gcc.c-torture/execute/20000605-3.c
gcc.c-torture/execute/20020619-1.c
gcc.c-torture/execute/20030920-1.c
gcc.c-torture/execute/loop-ivopts-1.c



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65353 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 00:05:16 +00:00
Dan Gohman
15cab2817b Back out the change in 64918 that used sign-extensions when promoting
trip counts that use signed comparisons. It's not obviously the best
approach for preserving trip count information, and at any rate there
isn't anything in the tree right now that makes use of that, so for
now always using zero-extensions is preferable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65347 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 23:20:35 +00:00
Nick Lewycky
2ec0dbf961 Don't sign extend the char when expanding char -> int during
load(bitcast(char[4] to i32*)) evaluation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65246 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21 20:50:42 +00:00
Chris Lattner
36d3e326df rename a function to indicate that it checks for profitability as well
as legality.  Make load sinking and gep sinking more careful: we only
do it when it won't pessimize loads from the stack.  This has the added
benefit of not producing code that is unanalyzable to SROA.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65209 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21 00:46:50 +00:00
Dan Gohman
c17e0cf6c0 Implement "superhero" strength reduction, or full strength
reduction of address calculations down to basic pointer arithmetic.
This is currently off by default, as it needs a few other features
before it becomes generally useful. And even when enabled, full
strength reduction is only performed when it doesn't increase
register pressure, and when several other conditions are true.

This also factors out a bunch of exisiting LSR code out of
StrengthReduceStridedIVUsers into separate functions, and tidies
up IV insertion. This actually decreases register pressure even
in non-superhero mode. The change in iv-users-in-other-loops.ll
is an example of this; there are two more adds because there are
two fewer leas, and there is less spilling.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65108 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 04:17:46 +00:00
Dan Gohman
f5a309e989 Use a sign-extend instead of a zero-extend when promoting a
trip count value when the original loop iteration condition is
signed and the canonical induction variable won't undergo signed
overflow. This isn't required for correctness; it just preserves
more information about original loop iteration values.

Add a getTruncateOrSignExtend method to ScalarEvolution,
following getTruncateOrZeroExtend.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64918 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 17:22:41 +00:00
Owen Anderson
a052fad720 Add a test for r61358, which I forgot to add way back when.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64904 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 07:50:22 +00:00
Dan Gohman
38ad0191e9 Change the argument type in this test to something less convoluted,
since it isn't actually used. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64883 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 04:25:04 +00:00
Dan Gohman
d2067fd730 Fix a corner case in the new indvars promotion logic: if there
are multiple IV's in a loop, some of them may under go signed
or unsigned wrapping even if the IV that's used in the loop
exit condition doesn't. Restrict sign-extension-elimination
and zero-extension-elimination to only those that operate on
the original loop-controlling IV.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64866 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 00:52:00 +00:00
Duncan Sands
cdf5ffb7fb If an alias is dead and so is its aliasee, then globaldce would
crash because the alias would still be using the aliasee when the
aliasee was deleted.


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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64809 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 20:47:23 +00:00
Evan Cheng
5a6c1a840a Strengthen the "non-constant stride must dominate loop preheader" check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64703 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 00:13:06 +00:00
Dan Gohman
ecd0fb51cb Fix EnforceKnownAlignment so that it doesn't ever reduce the alignment
of an alloca or global variable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64693 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 23:02:21 +00:00
Dan Gohman
74786c0f43 Rename IndVarsSimplify to IndVarSimplify, to be consistent with
the name used in the code that these tests are for.


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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64623 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 00:44:23 +00:00
Duncan Sands
4782b305c2 If the target of an alias has internal linkage, then the
alias can be morphed into the target.  Implement this
transform, and fix a crash in the existing transform at
the same time.


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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64532 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14 02:31:09 +00:00