Commit Graph

3400 Commits

Author SHA1 Message Date
Dan Gohman
ce9fe9fae5 Convert instcombine from using using getAnalysis<TargetData> to
getAnalysisIfAvailable<TargetData>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76676 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-21 23:21:54 +00:00
Owen Anderson
b3056faa55 Rename getConstantInt{True|False} to get{True|False} at Chris' behest.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76598 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-21 18:03:38 +00:00
Owen Anderson
f53c371983 Move a bit more state over to the LLVMContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76533 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-21 02:47:59 +00:00
Chris Lattner
8850b36d0f use ExpandInlineAsm on TargetLowering instead of TargetAsmInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76442 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-20 17:52:52 +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
191a0aee4f Remove no-op check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76302 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 09:21:25 +00:00
Eli Friedman
1694e095c0 Remove dead check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76301 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 09:12:15 +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
Nick Lewycky
3a4a884c16 Replace intersectWith with maximalIntersectWith. The latter guarantees that
all values belonging to the intersection will belong to the resulting range.
The former was inconsistent about that point (either way is fine, just pick
one.) This is part of PR4545.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76289 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 06:34:42 +00:00
Dan Gohman
016de81177 Convert more code to use Operator instead of explicitly handling both
ConstantExpr and Instruction. This involves duplicating some code
between GetElementPtrInst and GEPOperator, but it's not a lot.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76265 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 23:55:56 +00:00
Dan Gohman
3a7a68c108 Make BasicAliasAnalysis and Value::getUnderlyingObject use
GEPOperator's hasNoPointer0verflow(), and make a few places in instcombine
that create GEPs that may overflow clear the NoOverflow value. Among
other things, this partially addresses PR2831.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76252 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 22:25:10 +00:00
Dan Gohman
8f080f0233 Fix some typos in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76249 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 22:16:21 +00:00
Dan Gohman
ca178908c8 Add a new Operator class, for handling Instructions and ConstantExprs
in a convenient manner, factoring out some common code from
InstructionCombining and ValueTracking. Move the contents of
BinaryOperators.h into Operator.h and use Operator to generalize them
to support ConstantExprs as well as Instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76232 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 20:47:02 +00:00
Eli Friedman
0b79a7727d Replace isTrapping with a new, similar method called
isSafeToSpeculativelyExecute. The new method is a bit closer to what 
the callers actually care about in that it rejects more things callers 
don't want.  It also adds more precise handling for integer 
division, and unifies code for analyzing the legality of a speculative 
load.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76150 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-17 04:28:42 +00:00
Owen Anderson
001dbfebcb Move the ConstantInt uniquing table into LLVMContextImpl. This exposed a number of issues in
our current context-passing stuff, which is also fixed here


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76089 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 18:04:31 +00:00
Owen Anderson
50dead06ff Revert yesterday's change by removing the LLVMContext parameter to AllocaInst and MallocInst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75863 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 23:53:25 +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
5668cf77a7 Fix indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75723 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 01:26:32 +00:00
Dan Gohman
bdc017edac Make makeLoopInvariant report whether it made any changes or not,
and use this to simplify more code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75722 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-15 01:25:43 +00:00
Owen Anderson
9adc0abad3 Move EVER MORE stuff over to LLVMContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75703 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 23:09:55 +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
Torok Edwin
c23197a26f llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 16:55:14 +00:00
Dan Gohman
1b65253da6 Require IVUsers after LCSSA, since LCSSA does not preserve IVUsers.
This results in the pass manager running IVUsers only once for
indvars, instead of twice.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75633 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 14:26:23 +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
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
Owen Anderson
fa82b6eba4 These don't really need contexts either.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75528 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 22:18:28 +00:00
Dan Gohman
c8d76d5afb Make Loop and MachineLoop be subclasses of LoopBase, rather than typedefs,
using the Curiously Recurring Template Pattern with LoopBase.

This will help further refactoring, and future functionality for
Loop. Also, Headers can now foward-declare Loop, instead of pulling
in LoopInfo.h or doing tricks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75519 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 21:51:15 +00:00
Eli Friedman
65445c5b14 Misc simplifications to InstCombiner::commonIntCastTransforms. Most of
the changes are allowed by not calling this function for bitcasts.  
The Instruction::AShr case is dead because 
SimplifyDemandedInstructionBits handles that case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75514 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 21:45:57 +00:00
Eli Friedman
eb7f7a8665 Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75499 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 20:58:59 +00:00
Owen Anderson
73c6b7127a Move more functionality over to LLVMContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75497 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 20:58:05 +00:00
Eli Friedman
7e25d45cfb Don't bother to call commonIntCastTransforms for bitcasts; int->int
bitcasts will always be eliminated anyway.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75495 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 20:53:00 +00:00
Owen Anderson
0a5372ed3e Begin the painful process of tearing apart the rat'ss nest that is Constants.cpp and ConstantFold.cpp.
This involves temporarily hard wiring some parts to use the global context.  This isn't ideal, but it's
the only way I could figure out to make this process vaguely incremental.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75445 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 04:09:18 +00:00
Eli Friedman
6db1495558 Remove check which is duplicated in
InstCombiner::visitSelectInstWithICmp.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75409 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-12 02:00:05 +00:00
Torok Edwin
c25e7581b9 assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 20:10:48 +00:00
Torok Edwin
7d696d8040 Convert more assert(0)+abort() -> LLVM_UNREACHABLE,
and abort()/exit() -> llvm_report_error().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75363 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 13:10:19 +00:00
Nick Lewycky
bf8c7f0adf Move a method that creates constant ranges relative to another constant range
per icmp predicate out of predsimplify and into ConstantRange.

Add another utility method that determines whether one range is a subset of
another. Combine with the former to determine whether icmp pred range, range
is known to be true or not.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75357 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 06:15:39 +00:00
Owen Anderson
c7d2ce7047 Push LLVMContext through the PatternMatch API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75255 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 17:35:01 +00:00
Owen Anderson
333c400965 This started as a small change, I swear. Unfortunately, lots of things call the [I|F]CmpInst constructors. Who knew!?
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75200 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 23:48:35 +00:00
Owen Anderson
a547b4708b A little bit more LLVMContextification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75159 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-09 18:36:20 +00:00
Owen Anderson
d1fbd14294 Push LLVMContext _back_ through IRBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75040 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 20:50:47 +00:00
Dan Gohman
85ebb0f66c Tell ScalarEvolution to forget a loop before starting to delete it.
This way ScalarEvolution can examine the loop to determine what state
it needs to update, if it chooses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75029 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 19:14:29 +00:00
Owen Anderson
e9b11b4313 Switch GlobalVariable ctors to a sane API, where *either* a context or a module is required.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75025 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 19:03:57 +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
Owen Anderson
3d29df3e8a Push LLVMContext through GlobalVariables and IRBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74985 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 01:26:06 +00:00
Dan Gohman
0bba49cebc Change all SCEV* to SCEV *.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74918 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 17:06:11 +00:00
Owen Anderson
07cf79ef53 "LLVMContext* " --> "LLVMContext *"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74878 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 23:00:19 +00:00
Owen Anderson
76f600b205 Finish LLVMContext-ing lib/Analysis. This required pushing LLVMContext's through the ValueTracking API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74873 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 22:37:39 +00:00
Owen Anderson
508955156a Thread LLVMContext through the constant folding APIs, which touches a lot of files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74844 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 18:42:36 +00:00
Owen Anderson
0a205a4598 More LLVMContext-ification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74807 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-05 22:41:43 +00:00
Owen Anderson
fa5cbd6d0f Even more passes being LLVMContext'd.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74781 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-03 19:42:02 +00:00
Owen Anderson
1ff50b380e Second batch of passes using LLVMContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74753 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-03 00:54:20 +00:00
Owen Anderson
d672ecb017 Convert the first batch of passes to use LLVMContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74748 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-03 00:17:18 +00:00
Chris Lattner
62c762f329 fix inverted logic pointed out by John McCall, noticed by inspection.
This was considering vector intrinsics to have cost 2, but non-vector
intrinsics to have cost 1, which is backward.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74698 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-02 15:39:39 +00:00
Dan Gohman
f530c92cd5 Fix a bunch of other places that used operator[] to test whether
a key is present in a std::map or DenseMap to use find instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74676 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-02 00:17:47 +00:00
Dan Gohman
62476cceee Request LCSSA after LoopSimplify. This fixes a problem in which the
PassManager was scheduling LCSSA before LoopSimplify, which does not
preserve LCSSA.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74661 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 23:21:38 +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
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
cfb32203bc More minor code simplifications.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74395 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 21:23:40 +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
667d787c0a Incorporate the insertion point into the key of SCEVExpander's CSE map.
This helps it avoid reusing an instruction that doesn't dominate all
of the users, in cases where the original instruction was inserted
before all of the users were known.  This may result in redundant
expansions of sub-expressions that depend on loop-unpredictable values
in some cases, however this isn't very common, and it primarily impacts
IndVarSimplify, so GVN can be expected to clean these up.

This eliminates the need for IndVarSimplify's FixUsesBeforeDefs,
which fixes several bugs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74352 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 22:53:46 +00:00
Owen Anderson
afe0a083c1 Constify this value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74330 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 21:39:56 +00:00
Douglas Gregor
8947881444 Fix linking of llvm-ld and lli with CMake, from Xerxes Rånby
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74285 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 15:37:00 +00:00
Dan Gohman
e1047fbb97 Change this code to a form about which VC++ reportedly isn't unhappy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74243 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 00:35:12 +00:00
Dan Gohman
30d670f51f Minor code simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74240 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 00:26:03 +00:00
Dan Gohman
cc4e605721 Reword a few comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74146 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 00:22:44 +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
40a5a1b39e Extend ScalarEvolution's multiple-exit support to compute exact
trip counts in more cases.

Generalize ScalarEvolution's isLoopGuardedByCond code to recognize
And and Or conditions, splitting the code out into an
isNecessaryCond helper function so that it can evaluate Ands and Ors
recursively, and make SCEVExpander be much more aggressive about
hoisting instructions out of loops.

test/CodeGen/X86/pr3495.ll has an additional instruction now, but
it appears to be due to an arbitrary register allocation difference.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74048 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 01:18:18 +00:00
Dan Gohman
ea080be986 Don't emit a redundant BitCastInst if the value to be defined in the
preheader is already an instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74031 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 00:28:59 +00:00
Dan Gohman
469f3cdc13 Fix a few minor issues that were exposed by the removal of SCEVHandle.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73910 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 22:08:45 +00:00
Owen Anderson
372b46cad9 SCEVHandle is no more!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73906 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 21:39:50 +00:00
Dan Gohman
03ad6982c4 Fix this code to correctly handle loops with multiple exits. Until
now, this hasn't mattered, because ScalarEvolution hasn't been able
to compute trip counts for loops with multiple exits. But it will
soon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73864 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 00:15:15 +00:00
Dan Gohman
5392dce881 Rename a variable for consistency with the ExitBlock vs ExitingBlock
terminology that LoopInfo uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73863 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 23:48:38 +00:00
Dan Gohman
224a19c490 Fix a typo in a comment that Frits von Bommel noticed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73796 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:41:37 +00:00
Dan Gohman
2781f30eac Re-apply r73718, now that the fix in r73787 is in, and add a
hand-crafted testcase which demonstrates the bug that was exposed
in 254.gap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:23:27 +00:00
Dan Gohman
4d1c1efd80 Fix LSR's OptimizeSMax to ignore max operators with more than 2 operands,
which it isn't prepared to handle.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73787 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:03:46 +00:00
Evan Cheng
73a76736fb Revert 73718. It's breaking 254.gap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73783 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 21:15:06 +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
4658c9b4ea Generalize LSR's OptimizeSMax to handle unsigned max tests as well
as signed max tests. Along with r73717, this helps CodeGen avoid
emitting code for a maximum operation for this class of loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73718 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 20:23:18 +00:00
Anton Korobeynikov
9547cdfa35 Revert IRBuilder CC propagation. Fix SimplifyLibCalls instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73715 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 20:05:31 +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
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
Torok Edwin
4306b1a329 Add debug message about non-local loads being clobbered.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73625 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 18:48:18 +00:00
Dan Gohman
e3a6165423 Update comments to use doxygen syntax.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73621 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 17:51:33 +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
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
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
Dale Johannesen
7b9486ad43 Add an int64_t variant of abs, for host environments
without one.  Use it where we were using abs on
int64_t objects.
(I strongly suspect the casts to unsigned in the
fragments in LoopStrengthReduce are not doing whatever
the original intent was, but the obvious change to
uint64_t doesn't work.  Maybe later.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71612 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 00:24:22 +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