1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 12:02:58 +02:00
Commit Graph

5478 Commits

Author SHA1 Message Date
Dan Gohman
922033d119 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.

llvm-svn: 72093
2009-05-19 02:15:55 +00:00
Dan Gohman
0a71520ce1 Rename UseTy to AccessTy, for consistency with getAccessType, and to
avoid ambiguity with the word "use" in IVStrideUse.

llvm-svn: 72012
2009-05-18 16:45:28 +00:00
Dale Johannesen
8bd6fc810a Reuse existing getUnderlyingObject instead of
adding another copy.

llvm-svn: 71783
2009-05-14 18:41:18 +00:00
Dale Johannesen
e740d81911 Use abs64 in one more place.
llvm-svn: 71775
2009-05-14 16:47:34 +00:00
Dale Johannesen
d0e1e29fb7 Handle some additonal cases of external weak globals.
llvm-svn: 71717
2009-05-13 20:55:30 +00:00
Dale Johannesen
a3b4fb31a1 Don't generate a select whose operand is load of a weak
external.  These may have address 0 and are not safe
to execute unconditionally.

llvm-svn: 71688
2009-05-13 18:25:07 +00:00
Chris Lattner
eb2f327449 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.

llvm-svn: 71676
2009-05-13 17:39:14 +00:00
Chris Lattner
927ebd34e2 Fix PR4206 - crash in simplify lib calls
llvm-svn: 71644
2009-05-13 06:26:11 +00:00
Dale Johannesen
18cc7c12b7 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.)

llvm-svn: 71612
2009-05-13 00:24:22 +00:00
Dan Gohman
d13f674130 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.

llvm-svn: 71535
2009-05-12 02:17:14 +00:00
Evan Cheng
9b27f3ec42 Teach LSR to optimize more loop exit compares, i.e. change them to use postinc iv value. Previously LSR would only optimize those which are in the loop latch block. However, if LSR can prove it is safe (and profitable), it's now possible to change those not in the latch blocks to use postinc values.
Also, if the compare is the only use, LSR would place the iv increment instruction before the compare instead in the latch.

llvm-svn: 71485
2009-05-11 22:33:01 +00:00
Dale Johannesen
f86e34065b Reverse a loop that is counting up to a maximum to
count down to 0 instead, under very restricted
circumstances.  Adjust 4 testcases in which this
optimization fires.

llvm-svn: 71439
2009-05-11 17:15:42 +00:00
Duncan Sands
f7af13b2d4 Rename PaddedSize to AllocSize, in the hope that this
will make it more obvious what it represents, and stop
it being confused with the StoreSize.

llvm-svn: 71349
2009-05-09 07:06:46 +00:00
Evan Cheng
bf67b0edef Factor out code that optimize loop terminating condition.
llvm-svn: 71305
2009-05-09 01:08:24 +00:00
Chris Lattner
0fd5aea274 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.

llvm-svn: 71224
2009-05-08 15:54:41 +00:00
Nick Lewycky
8d9ef77adc This transform requires valid TargetData info. Wrap it in 'if (TD)' in
preparation for the day we use null TargetData when no target is specified.

llvm-svn: 71210
2009-05-08 06:47:37 +00:00
Eli Friedman
a280375b23 PR4123: don't crash when inlining a call which uses its own result.
llvm-svn: 71199
2009-05-08 00:22:04 +00:00
Dan Gohman
679947f6ea Perform constant folding on operands of instructions with non-void
types, such as loads and calls.

llvm-svn: 71175
2009-05-07 19:43:39 +00:00
Evan Cheng
ecc4cc83a8 Unbreak the build.
llvm-svn: 71091
2009-05-06 18:00:56 +00:00
David Greene
be8ff09e46 Make sure to use signed arithmetic in APInt to fix a regression.
llvm-svn: 71090
2009-05-06 17:39:26 +00:00
Dan Gohman
33e1f0fcb5 Simplify code by using SmallVector's pop_back_val() instead of
separate back() and pop_back() calls.

llvm-svn: 71089
2009-05-06 17:22:41 +00:00
Duncan Sands
b71ad70b4e 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.

llvm-svn: 71077
2009-05-06 08:42:00 +00:00
Duncan Sands
880eaf5278 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.

llvm-svn: 71071
2009-05-06 06:49:50 +00:00
Dan Gohman
39d3c78f6a Fix a copy+pasto in a comment.
llvm-svn: 71035
2009-05-05 23:02:38 +00:00
Dan Gohman
c1169472a2 Delete a FIXME which is no longer relevant, and add a FIXME that is.
llvm-svn: 71033
2009-05-05 22:59:55 +00:00
Bill Wendling
5f4fcbeb10 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

llvm-svn: 71013
2009-05-05 20:49:46 +00:00
David Greene
2bb2b3840e Handle overflow of 64-bit loop conditions.
llvm-svn: 71008
2009-05-05 20:22:36 +00:00
Dan Gohman
00c4ac3add Re-apply 70645, converting ScalarEvolution to use
CallbackVH, with fixes. allUsesReplacedWith need to
walk the def-use chains and invalidate all users of a
value that is replaced. SCEVs of users need to be
recalcualted even if the new value is equivalent. Also,
make forgetLoopPHIs walk def-use chains, since any
SCEV that depends on a PHI should be recalculated when
more information about that PHI becomes available.

llvm-svn: 70927
2009-05-04 22:30:44 +00:00
Dan Gohman
6c425d29e7 Constify a bunch of SCEV-using code.
llvm-svn: 70919
2009-05-04 22:02:23 +00:00
Chris Lattner
84cf4d62a8 fix some problems spotted by Duncan and Nicolas Geoffray
llvm-svn: 70872
2009-05-04 16:29:24 +00:00
Chris Lattner
6807ddd3d9 * Sink 4 duplicates of edge threading validity checks and DOUT prints into
ThreadEdge directly.  This shares the code, but is just a refactoring.
* Make JumpThreading compute the set of loop headers and avoid threading
  across them.  This prevents jump threading from forming irreducible 
  loops (goodness) but also prevents it from threading in other cases that
  are beneficial (see the comment above FindFunctionBackedges).

llvm-svn: 70820
2009-05-04 02:28:08 +00:00
Chris Lattner
b07d558841 Factor loop backedge finding out of CodeGenPrepare into a new
FindFunctionBackedges function.

llvm-svn: 70819
2009-05-04 02:25:58 +00:00
Dan Gohman
8e4b9e586b Revert r70645 for now; it's causing a variety of regressions.
llvm-svn: 70661
2009-05-03 05:46:20 +00:00
Nick Lewycky
01b22399ef Revert r70630. Go back to appending ".b" to internal globals when shrinking
them to bool.

llvm-svn: 70653
2009-05-03 03:49:08 +00:00
Dan Gohman
7d98736ca6 Convert ScalarEvolution to use CallbackVH for its internal map. This
makes ScalarEvolution::deleteValueFromRecords, and it's code that
subtly needed to be called before ReplaceAllUsesWith, unnecessary.

It also makes ValueDeletionListener unnecessary.

llvm-svn: 70645
2009-05-02 21:19:20 +00:00
Dan Gohman
7c5f68dd5c The second argument to RecursivelyDeleteTriviallyDeadInstructions has
a default value, and will hopefully be going away soon.

llvm-svn: 70642
2009-05-02 20:22:10 +00:00
Dan Gohman
a79cce4aef 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.

llvm-svn: 70636
2009-05-02 18:29:22 +00:00
Dan Gohman
cc3edfaa6c Tell ScalarEvolution that the loop is being deleted before actually
deleting it.  This will let ScalarEvolution be more complete about
updating its records.

llvm-svn: 70632
2009-05-02 17:29:26 +00:00
Nick Lewycky
3e85ff61b3 Don't append ".b" to the names of globals that are being shrunk to booleans.
llvm-svn: 70630
2009-05-02 16:21:50 +00:00
Dan Gohman
a4b28ca3c9 Don't split critical edges during the AddUsersIfInteresting phase
of LSR. This makes the AddUsersIfInteresting phase of LSR a pure
analysis instead of a phase that potentially does CFG modifications.

The conditions where this code would actually perform a split are
rare, and in the cases where it actually would do a split the split
is usually undone by CodeGenPrepare, and in cases where splits
actually survive into codegen, they appear to hurt more often than
they help.

llvm-svn: 70625
2009-05-02 05:36:01 +00:00
Dan Gohman
bdc33dc988 Make RequiresTypeConversion canonicalize the types before calling the
target hooks canLosslesslyBitCastTo and isTruncateFree. This allows
targets to avoid worrying about handling all combinations of integer
and pointer types.

llvm-svn: 70555
2009-05-01 17:07:43 +00:00
Dan Gohman
9dd3e99217 Minor whitespace fix.
llvm-svn: 70551
2009-05-01 16:56:32 +00:00
Dan Gohman
a55fce998e Fix some code to work if TargetLowering is not available.
llvm-svn: 70546
2009-05-01 16:29:14 +00:00
Dale Johannesen
be38eaf1d4 Print correct instruction in dump.
llvm-svn: 70427
2009-04-29 22:57:20 +00:00
Dan Gohman
8b1b8d5891 Reword and tidy up some comments.
llvm-svn: 70416
2009-04-29 22:01:05 +00:00
Dan Gohman
418f294b3b Remove an obsolete comment.
llvm-svn: 70262
2009-04-27 22:12:34 +00:00
Dale Johannesen
626b0a32f7 Fix PR 4086, a bug in FP IV elimination.
llvm-svn: 70247
2009-04-27 21:03:15 +00:00
Dan Gohman
e1a532cb4f Permit ChangeCompareStride to rewrite a comparison when the factor
between the comparison's iv stride and the candidate stride is
exactly -1.

llvm-svn: 70244
2009-04-27 20:35:32 +00:00
Dan Gohman
d13f1a3b59 Return null instead of false, as appropriate.
llvm-svn: 70054
2009-04-25 17:28:45 +00:00
Dan Gohman
a7fae1f865 Add several more icmp simplifications. Transform signed comparisons
into unsigned ones when the operands are known to have the same
sign bit value.

llvm-svn: 70053
2009-04-25 17:12:48 +00:00
Sanjiv Gupta
f1177e1be7 Allow i16 type indices to gep.
llvm-svn: 69946
2009-04-24 02:37:54 +00:00
Dan Gohman
c0f47d6ec1 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.

llvm-svn: 69892
2009-04-23 15:16:49 +00:00
Evan Cheng
bdfff0ba69 Make sure both operands have binary instructions have the same type.
llvm-svn: 69844
2009-04-22 23:39:28 +00:00
Evan Cheng
faa208ae5f A few more places where the check of use_empty is needed.
llvm-svn: 69842
2009-04-22 23:09:16 +00:00
Evan Cheng
2af546d5fa Avoid deferencing use_begin() if value does not have a use.
llvm-svn: 69836
2009-04-22 22:45:37 +00:00
Owen Anderson
309568c469 Real fix for PR3549, by using caching for predecessor counts in addition to the predecessors themselves. This halves the time
to optimize the testcase, beyond what my previous patch did.

llvm-svn: 69792
2009-04-22 08:50:12 +00:00
Owen Anderson
b36babc111 Use PredIteratorCache in LCSSA, which gives a 37% overall speedup on the testcase from PR3549. More improvements to come.
llvm-svn: 69788
2009-04-22 08:09:13 +00:00
Chris Lattner
60c88b66da use predicate instead of hand-rolled loop
llvm-svn: 69752
2009-04-21 23:37:18 +00:00
Chris Lattner
95aad4d625 fix a crash on a pointless but valid zero-length memset, rdar://6808691
llvm-svn: 69680
2009-04-21 16:52:12 +00:00
Dan Gohman
4e3e945880 Factor out a common base class from SCEVTruncateExpr, SCEVZeroExtendExpr,
and SCEVSignExtendExpr.

llvm-svn: 69649
2009-04-21 01:25:57 +00:00
Dan Gohman
55d8490e7b Introduce encapsulation for ScalarEvolution's TargetData object, and refactor
the code to minimize dependencies on TargetData.

llvm-svn: 69644
2009-04-21 01:07:12 +00:00
Dale Johannesen
a263eac5f8 Adjust loop size estimate for full unrolling;
GEP's don't usually become instructions.

llvm-svn: 69631
2009-04-20 22:19:33 +00:00
Sanjiv Gupta
0cb9d67bcc Before trying to introduce/eliminate cast/ext/trunc to make indices type as
pointer type, make sure that the pointer size is a valid sequential index type.

llvm-svn: 69574
2009-04-20 06:05:54 +00:00
Dan Gohman
e2e949ee98 Use more const qualifiers with SCEV interfaces.
llvm-svn: 69450
2009-04-18 17:56:28 +00:00
Jim Grosbach
da399d8358 remove trailing whitespace
llvm-svn: 69402
2009-04-17 23:30:55 +00:00
David Greene
d9756224ce Use a safer iterator interface and get rid of std C++ library misuse.
This fixes a --enable-expensive-checks problem.

llvm-svn: 69353
2009-04-17 14:56:18 +00:00
Dan Gohman
61dc247292 Don't create ConstantInts with pointer type. This fixes a
regression in 403.gcc in PIC_CODEGEN=1 and DISABLE_LTO=1
mode.

llvm-svn: 69344
2009-04-17 02:02:52 +00:00
Dan Gohman
0b7e08929a Use TargetData::getTypeSizeInBits instead of getPrimitiveSizeInBits()
to get the correct answer for pointer types.

llvm-svn: 69321
2009-04-16 22:35:57 +00:00
Eli Friedman
13e59b3c41 Fix for PR3944: make mem2reg O(N) instead of O(N^2) in the number of
incoming edges for a block with many predecessors.

llvm-svn: 69312
2009-04-16 21:40:28 +00:00
Dan Gohman
f2bec6720f Minor code simplifications. Don't attempt LSR on theoretical
targets with pointers larger than 64 bits, due to the code not
yet being APInt clean.

llvm-svn: 69296
2009-04-16 16:49:48 +00:00
Dan Gohman
67ad4ee457 LSR is no longer a GEP optimizer. It is now an IV expression
optimizer, which just happen to frequently involve optimizing GEPs.

llvm-svn: 69295
2009-04-16 16:46:01 +00:00
Dan Gohman
b40c343360 Use ConstantExpr::getIntToPtr instead of SCEVExpander::InsertCastOfTo,
since the operand is always a constant.

llvm-svn: 69291
2009-04-16 15:48:38 +00:00
Dan Gohman
862f4743b8 Use a SCEV expression cast instead of immediately inserting a
new instruction with SCEVExpander::InsertCastOfTo.

llvm-svn: 69290
2009-04-16 15:47:35 +00:00
Dan Gohman
98aa1d9693 Expand GEPs in ScalarEvolution expressions. SCEV expressions can now
have pointer types, though in contrast to C pointer types, SCEV
addition is never implicitly scaled. This not only eliminates the
need for special code like IndVars' EliminatePointerRecurrence
and LSR's own GEP expansion code, it also does a better job because
it lets the normal optimizations handle pointer expressions just
like integer expressions.

Also, since LLVM IR GEPs can't directly index into multi-dimensional
VLAs, moving the GEP analysis out of client code and into the SCEV
framework makes it easier for clients to handle multi-dimensional
VLAs the same way as other arrays.

Some existing regression tests show improved optimization.
test/CodeGen/ARM/2007-03-13-InstrSched.ll in particular improved to
the point where if-conversion started kicking in; I turned it off
for this test to preserve the intent of the test.

llvm-svn: 69258
2009-04-16 03:18:22 +00:00
Dale Johannesen
ab8b46beca Eliminate zext over (iv | const) or (signed iv),
and sext over (iv | const), if a longer iv is
available.  Allow expressions to have more than
one zext/sext parent.  All from OpenSSL.

llvm-svn: 69241
2009-04-15 23:31:51 +00:00
Dale Johannesen
98c9716c34 Eliminate zext over (iv & const) or ((iv+const)&const)
if a longer iv is available.  These subscript forms are
not common; they're a bottleneck in OpenSSL.

llvm-svn: 69215
2009-04-15 20:41:02 +00:00
Dale Johannesen
427e9aade9 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.

llvm-svn: 69123
2009-04-15 01:10:12 +00:00
Evan Cheng
bd35a81da5 Avoid making the transformation enabled by my last patch if the new destinations have phi nodes.
llvm-svn: 69121
2009-04-15 00:43:54 +00:00
Devang Patel
7323064183 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.

llvm-svn: 69118
2009-04-15 00:17:06 +00:00
Evan Cheng
dba98a0669 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

llvm-svn: 69102
2009-04-14 23:40:03 +00:00
Owen Anderson
f127f4a7a9 LoopIndexSplit needs to inform the loop pass manager of the instructions it is
deleting, not just the basic block.

llvm-svn: 69011
2009-04-14 01:04:19 +00:00
Chris Lattner
57077413f1 eliminate unneeded parens.
llvm-svn: 68939
2009-04-13 05:38:23 +00:00
Chris Lattner
8ad1efdfe1 "There was a typo in my previous patch which leads to miscompilation of
strncat :(

strncat(foo, "bar", 99)
would be optimized to
memcpy(foo+strlen(foo), "bar", 100, 1)
instead of
memcpy(foo+strlen(foo), "bar", 4, 1)"

Patch by Benjamin Kramer!

llvm-svn: 68905
2009-04-12 18:22:33 +00:00
Chris Lattner
f03202e76d add some optimizations for strncpy/strncat and factor some
code.  Patch by Benjamin Kramer!

llvm-svn: 68885
2009-04-12 05:06:39 +00:00
Chris Lattner
7d75f78b92 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.

llvm-svn: 68598
2009-04-08 05:41:03 +00:00
Chris Lattner
2f520929d4 fix rdar://6762290, a crash compiling cxx filt with clang.
llvm-svn: 68500
2009-04-07 05:03:34 +00:00
Chris Lattner
e872752d66 remove empty section
llvm-svn: 68485
2009-04-07 02:55:53 +00:00
Ed Schouten
ff25f858fd 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!

llvm-svn: 68443
2009-04-06 13:06:48 +00:00
Owen Anderson
851ce6d1d5 Reapply r68211, with the miscompilations it caused fixed.
llvm-svn: 68262
2009-04-01 23:53:49 +00:00
Dan Gohman
a134448980 Revert r68172. It caused regressions in
Applications/Burg/burg
  Applications/ClamAV/clamscan
and many other tests.

llvm-svn: 68211
2009-04-01 16:37:47 +00:00
Owen Anderson
d7c837bb4b Enhance GVN to propagate simple conditionals. This fixes PR3921.
llvm-svn: 68172
2009-04-01 01:20:45 +00:00
Chris Lattner
87466e0995 Make the key of ValueRankMap an AssertingVH, so that we die violently
if it dangles.

llvm-svn: 68150
2009-03-31 22:13:29 +00:00
Evan Cheng
c419350132 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.

llvm-svn: 68142
2009-03-31 20:42:45 +00:00
Devang Patel
7fa69ef109 Update call graph after inlining invoke.
Patch by Jay Foad.

llvm-svn: 68120
2009-03-31 17:36:12 +00:00
Devang Patel
ec65625744 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.
llvm-svn: 68071
2009-03-30 22:24:10 +00:00
Duncan Sands
e13276db7f Revert r67798: it breaks llvm-gcc bootstrap on x86-64-linux, presumably due to
a miscompilation.

make[4]: Entering directory `gcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include'
if [ ! -d "./x86_64-unknown-linux-gnu/bits/stdtr1c++.h.gch" ]; then \
          mkdir -p ./x86_64-unknown-linux-gnu/bits/stdtr1c++.h.gch; \
        fi; \
        gcc-4.2.llvm-objects/./gcc/xgcc -shared-libgcc -Bgcc-4.2.llvm-objects/./gcc -nostdinc++ 
-Lgcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/src -Lgcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs 
-B/usr/local/gnat-llvm/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gnat-llvm/x86_64-unknown-linux-gnu/lib/ -isystem 
/usr/local/gnat-llvm/x86_64-unknown-linux-gnu/include -isystem /usr/local/gnat-llvm/x86_64-unknown-linux-gnu/sys-include -Winvalid-pch -Wno-deprecated -x 
c++-header -g -O2  -D_GNU_SOURCE -Igcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu 
-Igcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include -Igcc-4.2.llvm/libstdc++-v3/libsupc++ -O2 -g 
gcc-4.2.llvm/libstdc++-v3/include/precompiled/stdtr1c++.h -o x86_64-unknown-linux-gnu/bits/stdtr1c++.h.gch/O2g.gch
In file included from gcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include/tr1/repeat.h:247,
                 from gcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include/tr1/functional:1098,
                 from gcc-4.2.llvm/libstdc++-v3/include/precompiled/stdtr1c++.h:53:
gcc-4.2.llvm-objects/x86_64-unknown-linux-gnu/libstdc++-v3/include/tr1/functional_iterate.h:417: internal compiler error: in ggc_recalculate_in_use_p, at 
ggc-page.c:1602
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://llvm.org/bugs/> for instructions.
make[4]: *** [x86_64-unknown-linux-gnu/bits/stdtr1c++.h.gch/O2g.gch] Error 1

llvm-svn: 67839
2009-03-27 14:56:47 +00:00
Dale Johannesen
9fd8bb432f One more place to skip debug info.
llvm-svn: 67811
2009-03-27 01:13:37 +00:00
Devang Patel
a2211c26d7 While hoisting an instruction, update alias info set tracker.
llvm-svn: 67798
2009-03-26 23:48:52 +00:00
Dale Johannesen
03cedf1d8b Skip debug info one more place. (This one gets
called from llc, not opt, but it's an IR level
optimization nevertheless.)

llvm-svn: 67724
2009-03-26 01:15:07 +00:00
Devang Patel
8c31ea5290 Before deleting a basic block, give other loop passes a chance cleanup analysis values, related to the instructions in the basic block.
llvm-svn: 67719
2009-03-25 23:57:48 +00:00
Chris Lattner
c055403764 Fix PR3874 by restoring a condition I removed, but making it more
precise than it used to be.

llvm-svn: 67662
2009-03-25 00:28:58 +00:00
Chris Lattner
be6ee56fb2 oops, I intended to remove this, not comment it out. Thanks Duncan!
llvm-svn: 67657
2009-03-24 23:48:25 +00:00
Chris Lattner
aabd3eeeff 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.

llvm-svn: 67638
2009-03-24 18:35:40 +00:00
Chris Lattner
51a4134e1c 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.
   

llvm-svn: 67635
2009-03-24 18:15:30 +00:00
Dale Johannesen
0f8e2bcd98 Use a SmallPtrSet instead of std::set.
llvm-svn: 67578
2009-03-23 23:39:20 +00:00
Dan Gohman
18daca0895 Now that errs() is properly non-buffered, there's no need to
explicitly flush it.

llvm-svn: 67526
2009-03-23 15:57:19 +00:00
Duncan Sands
3c115770e7 Factorize out a concept - no functionality change.
llvm-svn: 67454
2009-03-21 21:27:31 +00:00
Chris Lattner
623662e8e1 Fix instcombine to not introduce undefined shifts when merging two
shifts together.  This fixes PR3851.

llvm-svn: 67411
2009-03-20 22:41:15 +00:00
Duncan Sands
926d062a48 Don't load values out of global constants with weak
linkage: the value may be replaced with something
different at link time.  (Frontends that want to
allow values to be loaded out of weak constants can
give their constants weak_odr linkage).

llvm-svn: 67407
2009-03-20 21:53:29 +00:00
Dale Johannesen
672ef54d0f Clear the cached cost when removing a function in
the inliner; prevents nondeterministic behavior
when the same address is reallocated.
Don't build call graph nodes for debug intrinsic calls;
they're useless, and there were typically a lot of them.

llvm-svn: 67311
2009-03-19 18:03:56 +00:00
Dale Johannesen
1d76ebc9ed Fix comment typo.
llvm-svn: 67307
2009-03-19 17:23:29 +00:00
Dale Johannesen
15de950459 This pass keeps a map of Instructions to Rank numbers,
and was deleting Instructions without clearing the
corresponding map entry.  This led to nondeterministic
behavior if the same address got allocated to another
Instruction within a short time.

llvm-svn: 67306
2009-03-19 17:22:53 +00:00
Nick Lewycky
a0dcd7e173 Remove strange extra semicolons.
llvm-svn: 67287
2009-03-19 05:51:39 +00:00
Chris Lattner
6dce8d4135 aha, DAE does have to think about PHI nodes. Many thanks to "Dr Evil" (aka Duncan)
for pointing this out :)

llvm-svn: 67212
2009-03-18 16:48:45 +00:00
Chris Lattner
0542f9f1ba Fix PR3826 - InstComb assert with vector shift, by not calling ComputeNumSignBits on a vector.
llvm-svn: 67211
2009-03-18 16:32:19 +00:00
Chris Lattner
e4f0e25d07 add an assertion to make it clear that PHI nodes are not allowed.
llvm-svn: 67210
2009-03-18 16:23:56 +00:00
Zhou Sheng
4e5f2198ff Explicitly check for StoreInst, do not lose the chance to delete
unused loads or bitcasts.

llvm-svn: 67202
2009-03-18 12:48:48 +00:00
Zhou Sheng
fd26fc58bd Revert my previous change on Local.cpp, instead, fix the bug on scalarrepl.
If the instruction has no users, it is also not only used by debug info 
and should not be deleted.

llvm-svn: 67194
2009-03-18 10:13:08 +00:00
Zhou Sheng
90fc23d03d Fix a bug.
If I->use_empty(), this method should return false.

llvm-svn: 67180
2009-03-18 07:56:13 +00:00
Chris Lattner
7bef74e92f Fix PR3807 by inserting 'insertelement' instructions in the normal dest of
an invoke instead of after the invoke (in its block), which is invalid.

llvm-svn: 67139
2009-03-18 00:31:45 +00:00
Chris Lattner
ee2d69fc7b LSR shouldn't ever try to hack on integer IV's larger than 64-bits. Right now
it is not APInt clean, but even when it is it needs to be evaluated carefully
to determine whether it is actually profitable.

This fixes a crash on PR3806

llvm-svn: 67134
2009-03-17 23:58:30 +00:00
Chris Lattner
43ae27a75e Remove a condition which is always true.
llvm-svn: 67089
2009-03-17 17:55:15 +00:00
Dale Johannesen
0e13f2b022 Fix a debug info dependency in jump threading.
llvm-svn: 67064
2009-03-17 00:38:24 +00:00
Dale Johannesen
7c23238784 Fix -strip-debug-declare to work when there are
llvm.global.variable's but no llvm.declare's.

llvm-svn: 66977
2009-03-13 22:59:47 +00:00
Evan Cheng
cda58e565f Fix PR3784: If the source of a phi comes from a bb ended with an invoke, make sure the copy is inserted before the try range (unless it's used as an input to the invoke, then insert it after the last use), not at the end of the bb.
Also re-apply r66140 which was disabled as a workaround.

llvm-svn: 66976
2009-03-13 22:59:14 +00:00
Bill Wendling
96e37540a0 Revert r66920. It was causing failures in the self-hosting buildbot (in release
mode).

Running /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/dg.exp ...
FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/crash-narrowfunctiontest.ll
Failed with signal(SIGBUS) at line 1
while running: bugpoint /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/crash-narrowfunctiontest.ll -bugpoint-crashcalls -silence-passes > /dev/null
0   bugpoint          0x0035dd25 llvm::sys::SetInterruptFunction(void (*)()) + 85
1   bugpoint          0x0035e382 llvm::sys::RemoveFileOnSignal(llvm::sys::Path const&, std::string*) + 706
2   libSystem.B.dylib 0x92f112bb _sigtramp + 43
3   libSystem.B.dylib 0xffffffff _sigtramp + 1829694831
4   bugpoint          0x00021d1c main + 92
5   bugpoint          0x00002106 start + 54
6   bugpoint          0x00000004 start + 18446744073709543220
Stack dump:
0.    Program arguments: bugpoint /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/crash-narrowfunctiontest.ll -bugpoint-crashcalls -silence-passes 

FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/misopt-basictest.ll
Failed with signal(SIGBUS) at line 1
while running: bugpoint /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/misopt-basictest.ll -dce -bugpoint-deletecalls -simplifycfg -silence-passes
0   bugpoint          0x0035dd25 llvm::sys::SetInterruptFunction(void (*)()) + 85
1   bugpoint          0x0035e382 llvm::sys::RemoveFileOnSignal(llvm::sys::Path const&, std::string*) + 706
2   libSystem.B.dylib 0x92f112bb _sigtramp + 43
3   libSystem.B.dylib 0xffffffff _sigtramp + 1829694831
4   bugpoint          0x00021d1c main + 92
5   bugpoint          0x00002106 start + 54
6   bugpoint          0x00000006 start + 18446744073709543222
Stack dump:
0.    Program arguments: bugpoint /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/misopt-basictest.ll -dce -bugpoint-deletecalls -simplifycfg -silence-passes 

FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/remove_arguments_test.ll
Failed with signal(SIGBUS) at line 1
while running: bugpoint /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/remove_arguments_test.ll  -bugpoint-crashcalls -silence-passes
0   bugpoint          0x0035dd25 llvm::sys::SetInterruptFunction(void (*)()) + 85
1   bugpoint          0x0035e382 llvm::sys::RemoveFileOnSignal(llvm::sys::Path const&, std::string*) + 706
2   libSystem.B.dylib 0x92f112bb _sigtramp + 43
3   libSystem.B.dylib 0xffffffff _sigtramp + 1829694831
4   bugpoint          0x00021d1c main + 92
5   bugpoint          0x00002106 start + 54
Stack dump:
0.    Program arguments: bugpoint /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/BugPoint/remove_arguments_test.ll -bugpoint-crashcalls -silence-passes 

--- Reverse-merging (from foreign repository) r66920 into '.':
U    include/llvm/Support/CallSite.h
U    include/llvm/Instructions.h
U    lib/Analysis/IPA/GlobalsModRef.cpp
U    lib/Analysis/IPA/Andersens.cpp
U    lib/Bitcode/Writer/BitcodeWriter.cpp
U    lib/VMCore/Instructions.cpp
U    lib/VMCore/Verifier.cpp
U    lib/VMCore/AsmWriter.cpp
U    lib/Transforms/Utils/LowerInvoke.cpp
U    lib/Transforms/Scalar/SimplifyCFGPass.cpp
U    lib/Transforms/IPO/PruneEH.cpp
U    lib/Transforms/IPO/DeadArgumentElimination.cpp

llvm-svn: 66953
2009-03-13 21:15:59 +00:00
Dale Johannesen
a4bb3e6d14 One more place where debug info affects codegen.
llvm-svn: 66930
2009-03-13 19:23:20 +00:00
Gabor Greif
6a76677e1b Second installment of "BasicBlock operands to the back"
changes.

For InvokeInst now all arguments begin at op_begin().
The Callee, Cont and Fail are now faster to get by
access relative to op_end().

This patch introduces some temporary uglyness in CallSite.
Next I'll bring CallInst up to a similar scheme and then
the uglyness will magically vanish.

This patch also exposes all the reliance of the libraries
on InvokeInst's operand ordering. I am thinking of taking
care of that too.

llvm-svn: 66920
2009-03-13 18:27:29 +00:00
Bill Wendling
5499163a0a Oops...I committed too much.
llvm-svn: 66867
2009-03-13 04:39:26 +00:00
Bill Wendling
02a239b837 Temporarily XFAIL this test.
llvm-svn: 66866
2009-03-13 04:37:11 +00:00
Dale Johannesen
3edb15a6c7 Fix one more place where debug info affected
codegen (speculative execution).

llvm-svn: 66859
2009-03-13 01:05:24 +00:00
Dale Johannesen
67278f57e8 Previous debug info fix to this code wasn't quite
right; did the wrong thing when there are exactly 11
non-debug instructions, followed by debug info.
Remove a FIXME since it's apparently been fixed along the way.

llvm-svn: 66840
2009-03-12 23:18:09 +00:00
Duncan Sands
968939fca2 Revert commit 66140 since it caused several failures
in the Ada testcase.  Reverting this only covers up
the real problem, which is a nasty conceptual difficulty
in the phi elimination pass: when eliminating phi nodes
in landing pads, the register copies need to come before
the invoke, not at the end of the basic block which is
too late...  See PR3784.

llvm-svn: 66826
2009-03-12 21:13:42 +00:00
Dale Johannesen
d9b24eba60 There already was a class to force deterministic
sorting of ConstantInt's; unreinvent wheel.

llvm-svn: 66824
2009-03-12 21:01:11 +00:00
Dale Johannesen
78eadcb3dc Another missing check for debug intrinsics.
llvm-svn: 66800
2009-03-12 17:42:45 +00:00
Dale Johannesen
6a856e8183 Allow for switch values bigger than 64 bits.
llvm-svn: 66751
2009-03-12 01:20:06 +00:00
Dale Johannesen
a63033a34c Fix some nondeterministic behavior when forwarding
from a switch table.  Multiple table entries that
branch to the same place were being sorted by the
pointer value of the ConstantInt*; changed to sort
by the actual value of the ConstantInt.

llvm-svn: 66749
2009-03-12 01:00:26 +00:00
Dale Johannesen
bc9067e872 Skip interleaved debug info when fast-forwarding through
allocations.  Apparently the assumption is there is an
instruction (terminator?) following the allocation so I
am allowing the same assumption.

llvm-svn: 66716
2009-03-11 22:19:43 +00:00
Anton Korobeynikov
60455b5097 I should definitely read make docs someday :(
llvm-svn: 66699
2009-03-11 20:40:15 +00:00
Anton Korobeynikov
a4b01bf40c Unbreak the build. Dunno, why it did not fail on mingw :(
llvm-svn: 66692
2009-03-11 20:16:05 +00:00
Anton Korobeynikov
fe336ae73e Disable plugins / shared stuff generation on windows targets.
This fixes fallout from recent PIC/delibtoolize changes and unbreaks
build on cygming.

llvm-svn: 66686
2009-03-11 19:49:42 +00:00
Dale Johannesen
7579673822 Don't consider debug intrinsics when checking
whether a callee to be inlined is a leaf.

llvm-svn: 66588
2009-03-10 22:20:02 +00:00
Dale Johannesen
f650b9b7da Removing a dead debug intrinsic shouldn't trigger
another instcombine pass if we weren't going to make
one without debug info.

llvm-svn: 66576
2009-03-10 21:19:49 +00:00
Devang Patel
eedb8ab91a Ignore dbg info, while estimating size of jump through block.
llvm-svn: 66554
2009-03-10 18:00:05 +00:00
John Criswell
d1fd7b1f72 Do not attempt to do parial redundancy elimination on void values.
Also fixed a punctuation error in the header comment.
This fixes PR3775.

llvm-svn: 66542
2009-03-10 15:04:53 +00:00
Evan Cheng
c147115cdf 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.
llvm-svn: 66539
2009-03-10 07:57:50 +00:00
Devang Patel
54b17d998a Ignore debug info while evaluating function.
llvm-svn: 66490
2009-03-09 23:04:12 +00:00
Dan Gohman
d22d16e519 Don't record the increment instruction; just recompute it from the Phi
if needed. This simplifies the code a little, and is needed for an
upcoming refactoring.

llvm-svn: 66479
2009-03-09 22:04:01 +00:00
Devang Patel
b01d0497e4 Remove llvm.dbg.global_variables also.
llvm-svn: 66471
2009-03-09 21:32:28 +00:00
Dan Gohman
cdabf073b9 Fix a few more places where induction variable types were used
where memory access types are needed.

llvm-svn: 66470
2009-03-09 21:22:12 +00:00
Dan Gohman
b65c69ed4b Use ReplacedTy instead of recomputing the same value.
llvm-svn: 66469
2009-03-09 21:19:58 +00:00
Dan Gohman
108b5dd79c Use LoopInfo's getLoopLatch() instead of doing what it does manualy.
llvm-svn: 66467
2009-03-09 21:14:16 +00:00
Dan Gohman
5a3a1117e7 Don't use an induction variable type as a memory access type.
Use VoidTy instead, to be properly conservative.

llvm-svn: 66463
2009-03-09 21:04:19 +00:00
Dan Gohman
2827ecebbe Factor out the code that determines the memory access type
of an instruction into a helper function.

llvm-svn: 66460
2009-03-09 21:01:17 +00:00
Devang Patel
f0b46d438a Add helper pass to remove llvm.dbg.declare intrinsics.
llvm-svn: 66454
2009-03-09 20:49:37 +00:00
Dan Gohman
c0b702199e Move the sorting of the StrideOrder array earlier so that it doesn't
have to be done twice.

llvm-svn: 66449
2009-03-09 20:46:50 +00:00
Dan Gohman
37c7177303 Delete the isOnlyStride argument, which is unused.
llvm-svn: 66446
2009-03-09 20:41:15 +00:00
Dan Gohman
ddec04d564 Tidy some LSR debug output: announce the loop it's about to process
before it does any processing.

llvm-svn: 66443
2009-03-09 20:34:59 +00:00
Duncan Sands
b185e63225 This debug info special case should no longer
be needed now that these intrinsics are marked
as not accessing memory.

llvm-svn: 66420
2009-03-09 11:57:08 +00:00
Chris Lattner
d5dd4590b5 reimplement AliasSetTracker in terms of DenseMap instead of hash_map,
hopefully no functionality change.

llvm-svn: 66398
2009-03-09 05:11:09 +00:00
Nick Lewycky
55ff36a552 Keep calling-convention and tail-call bit when creating new invoke or call.
llvm-svn: 66384
2009-03-08 19:02:17 +00:00
Nick Lewycky
5355d525f8 Fix comments, pointed out by Duncan Sands.
llvm-svn: 66381
2009-03-08 17:08:09 +00:00
Nick Lewycky
365f21b20f Mark function returns as noalias.
llvm-svn: 66369
2009-03-08 06:20:47 +00:00
Chris Lattner
f05ebf0849 teach SROA to handle promoting vector allocas with a memset into them into
a vector type instead of into an integer type.

llvm-svn: 66368
2009-03-08 04:17:04 +00:00
Chris Lattner
54d2292fe5 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.

llvm-svn: 66366
2009-03-08 04:04:21 +00:00
Chris Lattner
e367477979 change the MemIntrinsic get/setAlignment method to take an unsigned
instead of a Constant*, which is what the clients of it really want.

llvm-svn: 66364
2009-03-08 03:59:00 +00:00
Chris Lattner
7ddad92288 use MemTransferInst.
llvm-svn: 66362
2009-03-08 03:37:35 +00:00
Chris Lattner
f827ae4fa5 Introduce a new MemTransferInst pseudo class, which is a common
parent between MemCpyInst and MemMoveInst, simplify some code to
use it.

llvm-svn: 66361
2009-03-08 03:37:16 +00:00
Chris Lattner
fc43115972 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

llvm-svn: 66351
2009-03-07 23:32:02 +00:00
Duncan Sands
5ab54d488f Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr.  These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global.  In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time.   This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function.  If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body.  The
code generators on the other hand map weak and weak_odr linkage
to the same thing.

llvm-svn: 66339
2009-03-07 15:45:40 +00:00
Dale Johannesen
0643e4e36c Fix another case where debug info interferes with
an optimization.

llvm-svn: 66288
2009-03-06 21:08:33 +00:00
Chris Lattner
c5dba8954e add a bunch more passes to the C bindings (PR3734), patch by
Lennart Augustsson!

llvm-svn: 66272
2009-03-06 16:52:18 +00:00
Duncan Sands
26567dea82 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!

llvm-svn: 66267
2009-03-06 10:21:56 +00:00
Devang Patel
12e9aa7629 While converting an aggregate to scalare, ignore and remove aggregate's debug info.
llvm-svn: 66262
2009-03-06 07:03:54 +00:00
Devang Patel
3ae9d5d375 While hoisting instruction to speculatively execute simple bb, ignore dbg intrinsics.
llvm-svn: 66255
2009-03-06 06:00:17 +00:00
Chris Lattner
a66675581a this wasn't intended to go in.
llvm-svn: 66252
2009-03-06 05:42:30 +00:00
Chris Lattner
1b05680d5f Change various llvm utilities to use PrettyStackTraceProgram in
their main routines.  This makes the tools print their argc/argv
commands if they crash.

llvm-svn: 66248
2009-03-06 05:34:10 +00:00
Devang Patel
ff51ec061c Do not count DbgInfoIntrinsic while estimating loop header size.
llvm-svn: 66245
2009-03-06 03:51:30 +00:00
Devang Patel
9abfbc2e14 Skip DbgInfoIntrinsic.
llvm-svn: 66244
2009-03-06 02:59:27 +00:00
Dale Johannesen
e07f7b0e3d Don't assign rank numbers to debug intrinsic "calls".
This is needed so debug info doesn't change codegen.

llvm-svn: 66235
2009-03-06 01:41:59 +00:00
Devang Patel
c751e83e2b Revert 66224.
llvm-svn: 66233
2009-03-06 01:39:36 +00:00
Devang Patel
205f80b2f3 Revert rev. 66167.
We are still not out of woods yet.

llvm-svn: 66232
2009-03-06 01:37:41 +00:00
Evan Cheng
918955bbc4 SRThreshold is meant to be inclusive.
llvm-svn: 66227
2009-03-06 00:56:43 +00:00
Dale Johannesen
83c13c2ace Tweak the check for promotable alloca's to handle
debug intrinsics correctly.

llvm-svn: 66225
2009-03-06 00:42:50 +00:00
Devang Patel
f815005dfb Do not let debug info prevert globalopt from shriking a global vars to boolean.
llvm-svn: 66224
2009-03-06 00:21:00 +00:00
Devang Patel
28a28a2588 Add "check/remove dbg var" helper routines.
llvm-svn: 66223
2009-03-06 00:19:37 +00:00
Devang Patel
34889f5bed 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

llvm-svn: 66167
2009-03-05 18:12:02 +00:00
Evan Cheng
24c138a1cd Do not split edges to EH landing pads. It will cause code size explosion.
llvm-svn: 66140
2009-03-05 06:31:26 +00:00
Dale Johannesen
a73a4ee680 Fix another case where debug info was affecting
codegen.  I convinced myself it was OK to skip all
pointer bitcasts here too.

llvm-svn: 66122
2009-03-05 02:06:48 +00:00
Bill Wendling
edc936acb4 Add comment to emphasize that the while body is empty.
llvm-svn: 66115
2009-03-05 01:08:35 +00:00
Dale Johannesen
428972ecad Fix another case where a dbg.declare meant something
had 2 uses instead of 1.

llvm-svn: 66112
2009-03-05 00:39:02 +00:00
Bill Wendling
2eef9340a8 Temporarily revert r65994. It was causing rdar://6646455.
llvm-svn: 66083
2009-03-04 22:02:09 +00:00
Dale Johannesen
448293322b Re-commit 65975 and a fix for the problem that
was causing llvm-gcc to fail to build.  I've
verified it bootstraps now; good enough for me.

llvm-svn: 66073
2009-03-04 21:24:04 +00:00
Dan Gohman
5eb18fa0bf Fix this comment.
llvm-svn: 66065
2009-03-04 20:50:23 +00:00
Dan Gohman
70fd52251c Add an assertion for a condition that's always true, and not
immediately obvious.

llvm-svn: 66062
2009-03-04 20:49:01 +00:00
Chris Lattner
9cfff838eb complete comment.
llvm-svn: 66055
2009-03-04 19:23:25 +00:00
Chris Lattner
a0d9cc96fe this wasn't intended to be committed.
llvm-svn: 66054
2009-03-04 19:22:30 +00:00
Chris Lattner
5051e7afde Fix PR3720 by properly propagating alignment information from memcpy/memmove
onto element accesses.

llvm-svn: 66053
2009-03-04 19:20:50 +00:00
Dale Johannesen
8ca4d24371 Revert unintended commmit.
llvm-svn: 66001
2009-03-04 02:09:48 +00:00
Dale Johannesen
c6bfdb8253 Skip ptr-to-ptr bitcasts when counting in another case.
llvm-svn: 66000
2009-03-04 02:06:53 +00:00
Dale Johannesen
e184480072 Always skip ptr-to-ptr bitcasts when counting,
per Chris' suggestion.  Slightly faster.

llvm-svn: 65999
2009-03-04 01:53:05 +00:00
Devang Patel
94ef615585 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.
llvm-svn: 65994
2009-03-04 01:22:23 +00:00
Dale Johannesen
a6f7a45366 Make my earlier patch to skip debug intrinsics
when counting work; it was only off by 1.

llvm-svn: 65993
2009-03-04 01:20:34 +00:00
Dale Johannesen
e611f70764 Marking debug info intrinsics as not touching memory
caused them to be considered trivially dead.  Fix this.

llvm-svn: 65979
2009-03-03 23:30:00 +00:00
Dale Johannesen
81b6cd8ce5 Instruction counters must skip the bitcasts that
feed into llvm.dbg.declare nodes, as well as
the debug directives themselves.

llvm-svn: 65976
2009-03-03 22:36:47 +00:00
Devang Patel
9b7c78086b Recursively remove dead argument while removing llvm.dbg.declare intrinsic.
llvm-svn: 65971
2009-03-03 21:31:02 +00:00
Dale Johannesen
ceed180d4c When removing a store to an alloca that has only one
use, check also for the case where it has two uses,
the other being a llvm.dbg.declare.  This is needed so
debug info doesn't affect codegen.

llvm-svn: 65970
2009-03-03 21:26:39 +00:00
Bill Wendling
7fdda71ad7 Remove accidental check-ins in r65960. :-(
llvm-svn: 65961
2009-03-03 19:25:16 +00:00
Bill Wendling
8244b700bf Use > instead of >=. We want to promote aggregates of 128-bytes.
llvm-svn: 65960
2009-03-03 19:18:49 +00:00
Bill Wendling
a77bedb70b Reapply r65755, but reversing "<" to ">=".
llvm-svn: 65945
2009-03-03 12:12:58 +00:00
Dan Gohman
51d4e8db6a Fix a bunch of Doxygen syntax issues. Escape special characters,
and put @file directives on their own comment line.

llvm-svn: 65920
2009-03-03 02:55:14 +00:00
Dale Johannesen
d4a205b300 Don't count DebugInfo instructions in another limit
(lest they affect codegen).

llvm-svn: 65915
2009-03-03 01:43:03 +00:00
Dale Johannesen
33fa9dc8a9 When sinking an insn in InstCombine bring its debug
info with it.
Don't count debug info insns against the scan maximum
in FindAvailableLoadedValue (lest they affect codegen).

llvm-svn: 65910
2009-03-03 01:09:07 +00:00
Devang Patel
b69b449ce8 Ignore debug info intrinsics.
llvm-svn: 65908
2009-03-03 00:28:44 +00:00
Devang Patel
e98e6bc27c 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.
llvm-svn: 65902
2009-03-02 23:39:14 +00:00
Devang Patel
5220700e0d Remove all dbg symobls, including those with circular references.
This is ugly, but I can't figure out a quick way out of this.

llvm-svn: 65889
2009-03-02 22:50:58 +00:00
Duncan Sands
51ce06c788 Fix PR3694: add an instcombine micro-optimization that helps
clean up when using variable length arrays in llvm-gcc.

llvm-svn: 65832
2009-03-02 09:18:21 +00:00
Bill Wendling
0dd6d44518 Temporarily revert r65755. It was causing failures in the self-hosting
testsuite:

Running /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/CodeGen/X86/dg.exp ...
FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/CodeGen/X86/nancvt.ll
Failed with exit(1) at line 2
while running: grep 2147027116 nancvt.ll.tmp | count 3
count: expected 3 lines and got        0.
child process exited abnormally
FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/CodeGen/X86/vec_ins_extract.ll
Failed with exit(1) at line 1
while running:  llvm-as < /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/test/CodeGen/X86/vec_ins_extract.ll |  opt -scalarrepl -instcombine |   llc -march=x86 -mcpu=yonah | not /usr/bin/grep sub.*esp
      subl      $28, %esp
      subl      $28, %esp
child process exited abnormally

And more.

llvm-svn: 65758
2009-03-01 03:55:12 +00:00
Chris Lattner
7228db7662 hoist the check for alloca size up so that it controls CanConvertToScalar
as well as isSafeAllocaToScalarRepl.

llvm-svn: 65755
2009-03-01 02:26:47 +00:00
Nick Lewycky
44b8675102 Silence compiler warning about use of uninitialized variables (in reality these
are always set by reference on the path that uses them.) No functional change.

llvm-svn: 65621
2009-02-27 06:37:39 +00:00
Nick Lewycky
f5563f28d3 Fix compiler warning about uninitialized variables. No functional change.
llvm-svn: 65620
2009-02-27 06:29:31 +00:00
Zhou Sheng
670d50e102 Ignore dbg info intrinsics when folding conditional branch to
conditional branch predecessors.

llvm-svn: 65509
2009-02-26 06:56:37 +00:00
Chris Lattner
1443cb8f77 Fix PR3667
llvm-svn: 65464
2009-02-25 18:20:01 +00:00
Zhou Sheng
241d74737b Don't block basic block with only SwitchInst to fold into predecessors.
llvm-svn: 65456
2009-02-25 15:34:27 +00:00
Dan Gohman
dd9c79d45b Rename ScalarEvolution's getIterationCount to getBackedgeTakenCount,
to more accurately describe what it does. Expand its doxygen comment
to describe what the backedge-taken count is and how it differs
from the actual iteration count of the loop. Adjust names and
comments in associated code accordingly.

llvm-svn: 65382
2009-02-24 18:55:53 +00:00
Dan Gohman
1197d46ccf 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.

llvm-svn: 65364
2009-02-24 02:00:40 +00:00
Dan Gohman
f5bb2d8747 Generalize the ChangeCompareStride code, in preparation for
handling non-constant strides. No functionality change.

llvm-svn: 65363
2009-02-24 01:58:00 +00:00
Dan Gohman
3a3b51162b Preserve the DominanceFrontier analysis in the LoopDeletion pass.
llvm-svn: 65359
2009-02-24 01:21:53 +00:00
Devang Patel
702836b2dd 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

llvm-svn: 65353
2009-02-24 00:05:16 +00:00
Dan Gohman
1d93a1d2cb 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.

llvm-svn: 65347
2009-02-23 23:20:35 +00:00
Dan Gohman
f7d0d6fe22 LoopDeletion needs to inform ScalarEvolution when a loop is deleted,
so that ScalarEvolution doesn't hang onto a dangling Loop*, which
could be a problem if another Loop happens to get allocated at the
same address.

llvm-svn: 65323
2009-02-23 17:10:29 +00:00
Dan Gohman
67530bbc77 IndVarSimplify preserves ScalarEvolution. In the
-std-compile-opts sequence, this avoids the need for ScalarEvolution to
be rerun before LoopDeletion.

llvm-svn: 65318
2009-02-23 16:29:41 +00:00
Zhou Sheng
d3008c8b1c Should reset DBI_Prev if DBI_Next == 0.
llvm-svn: 65314
2009-02-23 10:14:11 +00:00
Mon P Wang
75d957dba4 Changed option name from inline-threshold to basic-inline-threshold because
inline-threshold option is used by the inliner.

llvm-svn: 65309
2009-02-23 07:07:56 +00:00
Chris Lattner
29437eb4c3 fix some typos that Duncan noticed
llvm-svn: 65306
2009-02-23 05:56:17 +00:00
Dan Gohman
b105ab4e42 Revert the part of 64623 that attempted to align the source in a
memcpy to match the alignment of the destination. It isn't necessary
for making loads and stores handled like the SSE loadu/storeu
intrinsics, and it was causing a performance regression in
MultiSource/Applications/JM/lencod.

The problem appears to have been a memcpy that copies from some
highly aligned array into an alloca; the alloca was then being
assigned a large alignment, which required codegen to perform
dynamic stack-pointer re-alignment, which forced the enclosing
function to have a frame pointer, which led to increased spilling.

llvm-svn: 65289
2009-02-22 18:06:32 +00:00
Dan Gohman
a78fb41553 Properly parenthesize this expression, fixing a real bug in the new
-full-lsr code, as well as a GCC warning.

llvm-svn: 65288
2009-02-22 16:40:52 +00:00
Evan Cheng
ba3f6fa814 Only try to sink immediate when TLI is not null. It needs to check if immediate would fit in target addressing field.
llvm-svn: 65268
2009-02-22 07:31:19 +00:00
Nick Lewycky
2c8f0fd57f Don't sign extend the char when expanding char -> int during
load(bitcast(char[4] to i32*)) evaluation.

llvm-svn: 65246
2009-02-21 20:50:42 +00:00
Evan Cheng
74d0dda00f Add AddrModeMatcher.cpp
llvm-svn: 65228
2009-02-21 07:05:11 +00:00
Evan Cheng
56b43045f6 Teach LSR sink to sink the immediate portion of the common expression back into uses if they fit in address modes of all the uses.
llvm-svn: 65215
2009-02-21 02:06:47 +00:00
Chris Lattner
3adae91c70 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.

llvm-svn: 65209
2009-02-21 00:46:50 +00:00
Evan Cheng
c2541a4450 Fix strange logic in CollectIVUsers used to determine whether all uses are
addresses, part 1. This fixes an obvious logic bug. Previously if the only
in-loop use is a PHI, it would return AllUsesAreAddresses as true.

llvm-svn: 65178
2009-02-20 22:16:49 +00:00
Dan Gohman
b8783d240b Simplify code and reduce indentation. No functionality change.
llvm-svn: 65167
2009-02-20 21:27:23 +00:00
Dan Gohman
4612c1d92f Fix 80-column violations.
llvm-svn: 65159
2009-02-20 21:06:57 +00:00
Dan Gohman
33c5714553 It's not necessary to check if Base is null here.
llvm-svn: 65157
2009-02-20 21:05:23 +00:00
Dan Gohman
271a6f1142 Add a comment about how Imm can be used for loop-variant values.
llvm-svn: 65147
2009-02-20 20:29:04 +00:00
Evan Cheng
d8aad94754 Factor address mode matcher out of codegen prepare to make it available to other passes, e.g. loop strength reduction.
llvm-svn: 65134
2009-02-20 18:24:38 +00:00
Zhou Sheng
0c2e862ad0 Just roll back the previous change to -mem2reg.
Will re-think about this according to Chris's comments.

llvm-svn: 65126
2009-02-20 17:49:33 +00:00
Zhou Sheng
580c176f47 patch to update the line number information in pass -mem2reg.
Currently this pass will delete the variable declaration info, 
and keep the line number info. But the kept line number info is not updated, 
and some is redundant or not correct, this patch just updates those info.

llvm-svn: 65123
2009-02-20 16:31:35 +00:00
Dan Gohman
4e8fc41d48 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.

llvm-svn: 65108
2009-02-20 04:17:46 +00:00
Dan Gohman
eb7aa11e26 Use DEBUG() instead of passing *DOUT to WriteAsOperand,
since the latter just passes a null reference when
debugging is not enabled.

llvm-svn: 65060
2009-02-19 19:32:06 +00:00
Dan Gohman
9c41f5e046 Make the debug output of LSR less cryptic and more informative.
llvm-svn: 65057
2009-02-19 19:23:27 +00:00
Duncan Sands
d1fef83598 In theory the aliasee may have dead constant users
here.  Since we only do the transform if there is
one use, strip off any such users in the hope of
making the transform fire more often.

llvm-svn: 64926
2009-02-18 17:55:38 +00:00
Dan Gohman
451474da4a 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.

llvm-svn: 64918
2009-02-18 17:22:41 +00:00
Dan Gohman
5530918aff Simplify by using dyn_cast instead of isa and cast.
llvm-svn: 64917
2009-02-18 16:54:33 +00:00
Dan Gohman
30770ee7b3 Add explicit keywords.
llvm-svn: 64915
2009-02-18 16:37:45 +00:00
Dan Gohman
0e73582689 Eliminate several more unnecessary intptr_t casts.
llvm-svn: 64888
2009-02-18 05:09:16 +00:00
Dan Gohman
3fc2e67140 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.

llvm-svn: 64866
2009-02-18 00:52:00 +00:00
Dan Gohman
4f0fccdf9b Fix a typo in a comment.
llvm-svn: 64859
2009-02-18 00:08:39 +00:00
Duncan Sands
e605b83258 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.

llvm-svn: 64844
2009-02-17 23:05:26 +00:00
Dan Gohman
ced54f0173 LoopIndexSplit doesn't actually use ScalarEvolution.
llvm-svn: 64811
2009-02-17 20:50:11 +00:00
Dan Gohman
59b08852dc Add a method to ScalarEvolution for telling it when a loop has been
modified in a way that may effect the trip count calculation. Change
IndVars to use this method when it rewrites pointer or floating-point
induction variables instead of using a doInitialization method to
sneak these changes in before ScalarEvolution has a chance to see
the loop. This eliminates the need for LoopPass to depend on
ScalarEvolution.

llvm-svn: 64810
2009-02-17 20:49:49 +00:00
Chris Lattner
0837686a2a 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.

llvm-svn: 64809
2009-02-17 20:47:23 +00:00
Dan Gohman
72f656f2ef Delete trailing whitespace.
llvm-svn: 64784
2009-02-17 19:13:57 +00:00
Duncan Sands
c0436287c2 This transform also applies to private linkage.
llvm-svn: 64773
2009-02-17 17:50:04 +00:00
Dan Gohman
07418e014e Fix 80-column violation.
llvm-svn: 64766
2009-02-17 15:57:39 +00:00
Evan Cheng
9a8e419015 Strengthen the "non-constant stride must dominate loop preheader" check.
llvm-svn: 64703
2009-02-17 00:13:06 +00:00
Dan Gohman
36c8002915 Simplify; fix some 80-column violations.
llvm-svn: 64702
2009-02-17 00:10:53 +00:00
Dan Gohman
e06ea828a2 Fix EnforceKnownAlignment so that it doesn't ever reduce the alignment
of an alloca or global variable.

llvm-svn: 64693
2009-02-16 23:02:21 +00:00
Nick Lewycky
6feb7523b8 Fix typo caused by too much surfing, dudes...
llvm-svn: 64626
2009-02-16 04:26:53 +00:00
Dan Gohman
47a6dc9ad1 Delete this long-commented-out code. The situation it seems to have
been written for is no longer relevant with the elimination of
signed and unsigned types.

llvm-svn: 64625
2009-02-16 02:57:42 +00:00
Dan Gohman
3d93bc5654 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.

llvm-svn: 64623
2009-02-16 00:44:23 +00:00
Nick Lewycky
9178be6059 Update the list of function annotations for nocapture. All of these came up
when I was looking at functions used by python.

Highlights include, better largefile support (64-bit file sizes on 32-bit
systems), fputs string is nocapture, popen/pclose added (popen being noalias
return), modf and frexp and friends. Also added some missing 'break' statements
and combined identical sections.

llvm-svn: 64615
2009-02-15 22:47:25 +00:00
Duncan Sands
6c1ce1dbd5 Make this more useful for cleaning up after the
one-definition-rule llvm-gcc changes (coming soon
to a tree near you!).

llvm-svn: 64588
2009-02-15 11:54:49 +00:00
Duncan Sands
0e6fcb078c 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.

llvm-svn: 64583
2009-02-15 09:56:08 +00:00
Evan Cheng
02d9156a8d 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.
llvm-svn: 64579
2009-02-15 06:06:15 +00:00
Evan Cheng
e0558412a4 ifdef out unneeded if statement.
llvm-svn: 64575
2009-02-15 03:20:37 +00:00
Dan Gohman
3695fd42a9 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.

llvm-svn: 64532
2009-02-14 02:31:09 +00:00
Dan Gohman
928d619b5e Clarify debug output.
llvm-svn: 64531
2009-02-14 02:26:50 +00:00
Dan Gohman
bd231d2e7b Simplify some code. hasComputableLoopEvolution is overkill in this case.
No functionality change.

llvm-svn: 64530
2009-02-14 02:25:19 +00:00
Dan Gohman
f01c6af944 In CodeGenPrepare's debug output, use WriteAsOperand instead of
printing getName(), so that unnamed values are printed correctly.

llvm-svn: 64468
2009-02-13 17:45:12 +00:00
Dan Gohman
484ce19297 Complete the sentance in this comment. I have reservations
about the code it describes, but at least now the comment
is right.

llvm-svn: 64465
2009-02-13 17:36:42 +00:00
Nick Lewycky
0a8e13fd8b Mark strto* as readonly when the endptr is null.
llvm-svn: 64460
2009-02-13 17:08:33 +00:00
Nick Lewycky
7ec551cfad On strtod and friends, mark 'endptr' nocapture in the function prototype, and
mark the first argument nocapture if endptr=NULL for each particular call.

llvm-svn: 64453
2009-02-13 15:31:46 +00:00
Dan Gohman
aec5be6b01 Fix the code that checked if a SCEVAddRecExpr Start contains an
addrec in a different loop to check the value being added to
the accumulated Start value, not the Start value before it has
the new value added to it. This prevents LSR from going crazy
on the included testcase. Dale, please review.

llvm-svn: 64440
2009-02-13 03:58:31 +00:00
Dan Gohman
3ade7d2346 Fix LSR's IV sorting function to explicitly sort by bitwidth
after sorting by stride value. This prevents it from missing
IV reuse opportunities in a host-sensitive manner.

llvm-svn: 64415
2009-02-13 00:26:43 +00:00
Dan Gohman
02d4601fcf Teach IndVarSimplify to optimize code using the C "int" type for
loop induction on LP64 targets. When the induction variable is
used in addressing, IndVars now is usually able to inserst a
64-bit induction variable and eliminates the sign-extending cast.
This is also useful for code using C "short" types for
induction variables on targets with 32-bit addressing.

Inserting a wider induction variable is easy; the tricky part is
determining when trunc(sext(i)) expressions are no-ops. This
requires range analysis of the loop trip count. A common case is
when the original loop iteration starts at 0 and exits when the
induction variable is signed-less-than a fixed value; this case
is now handled.

This replaces IndVarSimplify's OptimizeCanonicalIVType. It was
doing the same optimization, but it was limited to loops with
constant trip counts, because it was running after the loop
rewrite, and the information about the original induction
variable is lost by that point.

Rename ScalarEvolution's executesAtLeastOnce to
isLoopGuardedByCond, generalize it to be able to test for
ICMP_NE conditions, and move it to be a public function so that
IndVars can use it.

llvm-svn: 64407
2009-02-12 22:19:27 +00:00
Dan Gohman
f74d17b36a Add a utility function to LoopInfo to return the exit block
when the loop has exactly one exit, and make use of it in
LoopIndexSplit.

llvm-svn: 64388
2009-02-12 18:08:24 +00:00
Dan Gohman
faf109b851 This code doesn't actually use the ExitingBlocks list.
llvm-svn: 64376
2009-02-12 16:36:26 +00:00
Chris Lattner
5babade39e Fix a nasty bug (PR3550) where the inline pass could incorrectly mark
calls with the tail marker when inlining them through an invoke.  Patch,
testcase, and perfect analysis by Jay Foad!

llvm-svn: 64364
2009-02-12 07:06:42 +00:00
Chris Lattner
d093b49b81 improve naming of values in GVN, patch by Jay Foad!
llvm-svn: 64363
2009-02-12 07:00:35 +00:00
Chris Lattner
e5ec807aaf fix PR3537: if resetting bbi back to the start of a block, we need to
forget about already inserted expressions.

llvm-svn: 64362
2009-02-12 06:56:08 +00:00
Nick Lewycky
1a40fb2473 Don't mark all args to strtod and friends as nocapture.
llvm-svn: 64352
2009-02-12 03:18:34 +00:00
Nate Begeman
9b68eff12e the two non-mask arguments to a shufflevector must be the same width, but they do not have to be the same
width as the result value.

llvm-svn: 64335
2009-02-11 22:36:25 +00:00
Devang Patel
dd611eac76 If llvm.dbg.region.end is disappearing then remove corresponding llvm.dbg.func.start also.
llvm-svn: 64278
2009-02-11 01:29:06 +00:00
Devang Patel
60571be0de Ignore dbg intrinsic while folding unconditional branch.
llvm-svn: 64242
2009-02-10 22:14:17 +00:00
Devang Patel
db7596dbee Use early exits. Reduce indentation.
llvm-svn: 64226
2009-02-10 19:28:07 +00:00
Devang Patel
6c041de2ff Do not clone llvm.dbg.func.start and corresponding llvm.dbg.region.end during inlining.
llvm-svn: 64209
2009-02-10 07:48:18 +00:00
Devang Patel
7377e7aa89 Enable scalar replacement of AllocaInst whose one of the user is dbg info.
llvm-svn: 64207
2009-02-10 07:00:59 +00:00