Commit Graph

3203 Commits

Author SHA1 Message Date
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
Chris Lattner
6cc8a93c48 Generalize instcombine's isSafeToLoadUnconditionally() function
to ignore readonly calls, and factor it out of instcombine so
that it can be used by other passes.  Patch by Frits van Bommel!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 17:23:12 +00:00
Dan Gohman
44118f0e25 Use Type::getScalarType.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73451 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 00:20:26 +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
Dan Gohman
c915c95978 Make the EnableLoadPRE variable static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73398 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 18:30:15 +00:00
Dan Gohman
a119de86a0 Fix old-style type names in comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73362 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 23:30:43 +00:00
Dan Gohman
a82752c9eb Convert several parts of the ScalarEvolution framework to use
SmallVector instead of std::vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73357 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 22:47:23 +00:00
Dan Gohman
ea73f3c2e1 Add another item to the list of things that indvars does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73355 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 22:38:41 +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
Chris Lattner
69074a51f9 second half of fix for PR4366: don't zap store to null of
non-default addrspaces.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73253 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 21:01:07 +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
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
Nick Lewycky
d7f20b6b98 Don't crash on multiple return value with no obvious inserted value.
Fixes PR4314.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73007 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-06 23:13:08 +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
Jay Foad
0906b1bf09 Use cast<> instead of dyn_cast<> for things that are known to be
Instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73002 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-06 17:49:35 +00:00
Devang Patel
da634298fc Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72965 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05 22:39:21 +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
77b81fe487 Don't do the X * 0.0 -> 0.0 transformation in instcombine, because
instcombine doesn't know when it's safe. To partially compensate
for this, introduce new code to do this transformation in
dagcombine, which can use UnsafeFPMath.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72872 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 17:12:12 +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
Dan Gohman
8b0d4f61bb Fix CodeGenPrepare's address-mode sinking to handle unusual
addresses, involving Base values which do not have Pointer type.
This fixes PR4297.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72739 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-02 21:29:13 +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
Bill Wendling
3c04296b83 Enable GVN Load PRE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72589 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 20:38:16 +00:00
Torok Edwin
70ac142560 just show the instruction, its not that slow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72577 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 16:58:36 +00:00
Torok Edwin
7e55a00d06 for instructions with void type we have no choice but print the instruction as
is, otherwise we get a <badref>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72567 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 10:28:44 +00:00
Torok Edwin
3f3c6d4e5b Add a DEBUG() output to GVN that prints the instruction clobbering a load.
This is useful when trying to figure out why GVN didn't eliminate redundant
loads.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72565 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 09:46:03 +00:00
Owen Anderson
246ddf55d1 Fix an issue where phiMap was not being updated properly when doing load PRE.
Diagnosis and patch thanks to Jakub Staszak.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72562 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 05:37:54 +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
d594e6f034 Change ScalarEvolution::getSCEVAtScope to always return the original value
in the case where a loop exit value cannot be computed, instead of only in
some cases while using SCEVCouldNotCompute in others. This simplifies
getSCEVAtScope's callers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72375 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 23:25:42 +00:00
Torok Edwin
3d431384f0 Move Rewriter.clear() earlier, to avoid triggerring the AssertingVH by
one of the RecursivelyDeleteTriviallyDeadInstructions.
Add a comment explaining why the cache needs to be cleared.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72372 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 20:08:21 +00:00
Torok Edwin
3790fb0c03 Instead of clearing the rewriter, don't attempt to rewrite dead phi nodes.
Also fix 80 column violation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72371 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 19:36:09 +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
14fba294e1 When replacing a floating-point comparison with an integer
comparison, use takeName to give the integer comparison a name.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72367 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 18:09:01 +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
Eli Friedman
f7cca7b8f8 Fix loop-index-split to correctly preserve dominance frontiers. Part of
PR4238.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72244 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 03:22:46 +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
c2c4cbf7b3 Remove an irrelevant comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72132 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 20:38:47 +00:00
Dan Gohman
cec8f9da54 Add some more comments to the top of this file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72131 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 20:37:36 +00:00
Dan Gohman
6bfa57b3b3 Trim unneeded #includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72130 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 20:35:26 +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
a537bf83ed Rename UseTy to AccessTy, for consistency with getAccessType, and to
avoid ambiguity with the word "use" in IVStrideUse.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72012 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 16:45:28 +00:00
Dale Johannesen
bae7d6dbeb Use abs64 in one more place.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71775 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 16:47:34 +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