Commit Graph

6690 Commits

Author SHA1 Message Date
Evan Cheng
fc8ccfedbb Transform @llvm.objectsize to integer if the argument is a result of malloc of known size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97860 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-06 01:01:42 +00:00
Ted Kremenek
e080b038bf Update CMake build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97846 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 22:34:16 +00:00
Eric Christopher
b6174e3605 Move SimplifyLibCalls's LibCall builders to a separate file so they
can be used in more places.  Add an argument for the TargetData that
most of them need. Update for the getInt8PtrTy() change.  Should be
no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97844 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 22:25:30 +00:00
Evan Cheng
a79eb387ac Safely turn memset_chk etc. to non-chk variant if the known object size is >= memset / memcpy / memmove size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97828 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 20:59:47 +00:00
Evan Cheng
a862326bc7 Instcombine should turn llvm.objectsize of a alloca with static size to an integer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97827 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 20:47:23 +00:00
Chris Lattner
4c5fb1a311 fix PR6512, a case where instcombine would incorrectly merge loads
from different addr spaces.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97813 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 18:53:28 +00:00
Chris Lattner
f34f48c578 Fix PR6503. This turned into a much more interesting and nasty bug. Various
parts of the cmp|cmp and cmp&cmp folding logic wasn't prepared for vectors
(unrelated to the bug but noticed while in the code) and the code was 
*definitely* not safe to use by the (cast icmp)|(cast icmp) handling logic
that I added in r95855.  Fix all this up by changing the various routines
to more consistently use IRBuilder and not pass in the I which had the wrong 
type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97801 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 08:46:26 +00:00
Chris Lattner
d6f645ac09 simplify some functions and make them work with vector
compares, noticed by inspection.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 07:47:57 +00:00
Chris Lattner
893075f46e fix a nice subtle reassociate bug which would only occur
in a very specific use pattern embodied in the carefully
reduced testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97794 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 07:18:54 +00:00
Eric Christopher
25ec483cfc Move GetStringLength and helper from SimplifyLibCalls to ValueTracking.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97793 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 06:58:57 +00:00
Evan Cheng
f79d6246e6 Add missing break for Intrinsic::objectsize case. It was falling through to the following Intrinsic::bswap code. I have no idea why it wasn't breaking stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97774 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 01:22:47 +00:00
Dan Gohman
087bd1e3a1 Make SCEVExpander and LSR more aggressive about hoisting expressions out
of loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97642 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03 05:29:13 +00:00
Bill Wendling
7d9f2b93a3 This test case:
long test(long x) { return (x & 123124) | 3; }

Currently compiles to:

_test:
        orl     $3, %edi
        movq    %rdi, %rax
        andq    $123127, %rax
        ret

This is because instruction and DAG combiners canonicalize

  (or (and x, C), D) -> (and (or, D), (C | D))

However, this is only profitable if (C & D) != 0. It gets in the way of the
3-addressification because the input bits are known to be zero.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97616 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03 00:35:56 +00:00
Dan Gohman
069d6f3396 Non-affine post-inc SCEV expansions have more code which must be
emitted after the increment. Make sure the insert position
reflects this. This fixes PR6453.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97537 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-02 01:59:21 +00:00
Dan Gohman
a9445e11c5 Floating-point add, sub, and mul are now spelled fadd, fsub, and fmul,
respectively.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97531 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-02 01:11:08 +00:00
Bob Wilson
3bd19d753b Don't attempt load PRE when there is no real redundancy (i.e., the load is in
a loop and is itself the only dependency).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97526 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-02 00:09:29 +00:00
Bob Wilson
70704978af When GVN needs to split critical edges for load PRE, check all of the
predecessors before returning.  Otherwise, if multiple predecessor edges need
splitting, we only get one of them per iteration.  This makes a small but
measurable compile time improvement with -enable-full-load-pre.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97521 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 23:37:32 +00:00
Evan Cheng
19d417c346 MemoryDepAnalysis is not used if redundant load processing is disabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97512 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 22:23:12 +00:00
Dan Gohman
c5e49c64d1 Add some debug output to LoopSimplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97458 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 17:55:27 +00:00
Dan Gohman
3f46a3abee Spelling fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97453 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 17:49:51 +00:00
Dan Gohman
fd6f338ab1 Prune #includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97448 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 17:42:17 +00:00
Bob Wilson
b29d7d2542 Revert r97245 which seems to be causing performance problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97366 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-28 05:34:05 +00:00
Chris Lattner
9fcd72b71a fix grammaro's pointed out by daniel
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97313 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 07:50:40 +00:00
Chris Lattner
d38cdb020e fix PR6414, a nondeterminism issue in IPSCCP which was because
of a subtle interation in a loop operating in densemap order.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97288 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 00:07:42 +00:00
Chris Lattner
e9fd444dcd Fix rdar://7694996 a miscompile of 183.equake from my patch yesterday,
confusing the old MAT variable with the new GlobalType one.  This caused
us to promote the @disp global pointer into:

@disp.body = internal global double*** undef

instead of:

@disp.body = internal global [3 x double**] undef




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97285 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26 23:42:13 +00:00
Chris Lattner
c6a669b6e7 remove dead code, by this point all uses of CI are gone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97283 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26 23:35:25 +00:00
Bob Wilson
8561dcd730 Move the EnableFullLoadPRE flag from a separate command-line option to an
argument of createGVNPass and set it automatically for -O3.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97245 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26 19:09:47 +00:00
Bob Wilson
60df9077eb Remove unused "NoPRE" parameter in GVN and createGVNPass().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97235 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26 18:35:19 +00:00
Chris Lattner
3f5e0b8114 fix PR6435 another bug from the MallocInst elimination work.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97231 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26 18:23:13 +00:00
Chris Lattner
a687465bae rewrite OptimizeGlobalAddressOfMalloc to fix PR6422, some bugs
introduced when mallocinst was eliminated. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97178 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 22:33:52 +00:00
Dan Gohman
8566963713 Make LoopSimplify change conditional branches in loop exiting blocks
which branch on undef to branch on a boolean constant for the edge
exiting the loop. This helps ScalarEvolution compute trip counts for
loops.

Teach ScalarEvolution to recognize single-value PHIs, when safe, and
ForgetSymbolicName to forget such single-value PHI nodes as apprpriate
in ForgetSymbolicName.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97126 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 06:57:05 +00:00
Nick Lewycky
e7ee59b6a4 Modernize comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97121 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 06:39:10 +00:00
Nick Lewycky
813636a97b Correct whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97120 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 06:38:51 +00:00
Daniel Dunbar
6d8f2ca646 Reapply r97010, the speculative revert failed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97036 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 08:48:04 +00:00
Daniel Dunbar
8c0c99016b Speculatively revert r97010, "Add an argument to PHITranslateValue to specify
the DominatorTree. ...", in hopes of restoring poor old PPC bootstrap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97027 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 06:55:22 +00:00
Dan Gohman
39516a6323 Fix indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97024 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 06:46:09 +00:00
Bob Wilson
9d2ed8e632 Add an argument to PHITranslateValue to specify the DominatorTree. If this
argument is non-null, pass it along to PHITranslateSubExpr so that it can
prefer using existing values that dominate the PredBB, instead of just
blindly picking the first equivalent value that it finds on a uselist.
Also when the DominatorTree is specified, have PHITranslateValue filter
out any result that does not dominate the PredBB.  This is basically just
refactoring the check that used to be in GetAvailablePHITranslatedSubExpr
and also in GVN.

Despite my initial expectations, this change does not affect the results
of GVN for any testcases that I could find, but it should help compile time.
Before this change, if PHITranslateSubExpr picked a value that does not
dominate, PHITranslateWithInsertion would then insert a new value, which GVN
would later determine to be redundant and would replace.  By picking a good
value to begin with, we save GVN the extra work of inserting and then
replacing a new value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97010 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 01:39:00 +00:00
Dan Gohman
21dc20cbd6 Don't do (X != Y) ? X : Y -> X for floating-point values; it doesn't
handle NaN properly.

Do (X une Y) ? X : Y  -> X if one of X and Y is not zero.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96955 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23 17:17:57 +00:00
Bob Wilson
188f428e4e Update memdep when load PRE inserts a new load, and add some debug output.
I don't have a small testcase for this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96890 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23 05:55:00 +00:00
Evan Cheng
6e5dfd4bf5 Instcombine constant folding can normalize gep with negative index to index with large offset. When instcombine objsize checking transformation sees these geps where the offset seemingly point out of bound, it should just return "i don't know" rather than asserting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96825 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22 23:34:00 +00:00
Bob Wilson
74175c2ca1 Erase deleted instructions from GVN's ValueTable. This fixes assertion
failures from ValueTable::verifyRemoved() when using -debug.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96805 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22 21:39:41 +00:00
Dan Gohman
454d26dc43 Remove unused variables and parameters.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96780 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22 04:11:59 +00:00
Dan Gohman
278f958c61 When emitting an instruction which depends on both a post-incremented
induction variable value and a loop-variant value, don't force the
insert position to be at the post-increment position, because it may
not be dominated by the loop-variant value. This fixes a
use-before-def problem noticed on PPC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96774 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22 03:59:54 +00:00
Dan Gohman
2444080ca4 This cast<Instruction> is unnecessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96771 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22 02:07:36 +00:00
Dan Gohman
f09b71233b Rename getSDiv to getExactSDiv to reflect its behavior in cases where
the division would have a remainder.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96693 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 19:35:48 +00:00
Dan Gohman
aae01f17a6 Check for overflow when scaling up an add or an addrec for
scaled reuse.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96692 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 19:32:49 +00:00
Dale Johannesen
45a2d7d44a recommit 96626, evidence that it broke things appears
to be spurious



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96662 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 07:14:22 +00:00
Dale Johannesen
efd9e95051 Revert 96626, which causes build failure on ppc Darwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96653 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 01:54:37 +00:00
Dan Gohman
1b7bf18def When determining the set of interesting reuse factors, consider
strides in foreign loops. This helps locate reuse opportunities
with existing induction variables in foreign loops and reduces
the need for inserting new ones. This fixes rdar://7657764.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96629 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 00:05:23 +00:00
Dan Gohman
aa11defd1c Indvars needs to explicitly notify ScalarEvolution when it is replacing
a loop exit value, so that if a loop gets deleted, ScalarEvolution
isn't stick holding on to dangling SCEVAddRecExprs for that loop. This
fixes PR6339.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96626 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 23:26:33 +00:00
Dan Gohman
814f2b2d19 Hoist this loop-invariant logic out of the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96614 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 21:34:02 +00:00
Dan Gohman
378c0b35a7 Delete some unneeded casts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96429 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 00:42:19 +00:00
Dan Gohman
968cb939e5 Don't attempt to divide INT_MIN by -1; consider such cases to
have overflowed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96428 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 00:41:53 +00:00
Bob Wilson
ae23daf63a Rename SuccessorNumber to GetSuccessorNumber.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96387 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 21:06:42 +00:00
Dan Gohman
3a02cbcd03 Refactor rewriting for PHI nodes into a separate function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96382 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 20:25:07 +00:00
Bob Wilson
484d4a30c0 Split critical edges as needed for load PRE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96378 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 19:51:59 +00:00
Bob Wilson
adb6f22671 Refactor to share code to find the position of a basic block successor in the
terminator's list of successors.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96377 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 19:49:17 +00:00
Dan Gohman
7fca2294da Fix whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96372 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 19:42:34 +00:00
Duncan Sands
1df9859c40 There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96344 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 11:11:14 +00:00
Dan Gohman
c2385a0741 Split the main for-each-use loop again, this time for GenerateTruncates,
as it also peeks at which registers are being used by other uses. This
makes LSR less sensitive to use-list order.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96308 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 01:42:53 +00:00
Chris Lattner
37914c8e83 fix PR6305 by handling BlockAddress in a helper function
called by jump threading.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96263 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-15 20:47:49 +00:00
Duncan Sands
b0bc6c361d Uniformize the names of type predicates: rather than having isFloatTy and
isInteger, we now have isFloatTy and isIntegerTy.  Requested by Chris!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96223 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-15 16:12:20 +00:00
Dan Gohman
441a38993e Fix whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96179 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 18:51:39 +00:00
Dan Gohman
6020d85c41 Fix a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96178 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 18:51:20 +00:00
Dan Gohman
ce947366ec When complicated expressions are broken down into subexpressions
with multiplication by constants distributed through, occasionally
those subexpressions can include both x and -x. For now, if this
condition is discovered within LSR, just prune such cases away,
as they won't be profitable. This fixes a "zero allocated in a
base register" assertion failure.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96177 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 18:50:49 +00:00
Dan Gohman
590bfe8641 Actually, this code doesn't have to be quite so conservative in
the no-TLI case. But it should still default to declining the
transformation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96152 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 03:21:49 +00:00
Dan Gohman
2763dfdc70 Don't attempt aggressive post-inc uses if TargetLowering is not available,
because profitability can't be sufficiently approximated.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96148 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 02:45:21 +00:00
John McCall
6d09ab8ba2 Make LSR not crash if invoked without target lowering info, e.g. if invoked
from opt.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96135 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 23:40:16 +00:00
Eric Christopher
77ffe3b31e Fix a problem where we had bitcasted operands that gave us
odd offsets since the bitcasted pointer size and the offset pointer
size are going to be different types for the GEP vs base object.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 23:38:01 +00:00
Chris Lattner
c09687bb7e remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96109 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 19:07:06 +00:00
Chris Lattner
98d5c3141e Split some code out to a helper function (FindReusablePredBB)
and add a doxygen comment.

Cache the phi entry to avoid doing tons of 
PHINode::getBasicBlockIndex calls in the common case.

On my insane testcase from re2c, this speeds up CGP from
617.4s to 7.9s (78x).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96083 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 05:35:08 +00:00
Chris Lattner
6686c6bf68 Speed up codegen prepare from 3.58s to 0.488s.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96081 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 05:01:14 +00:00
Chris Lattner
277cccc58f PHINode::getBasicBlockIndex is O(n) in the number of inputs
to a PHI, avoid it in the common case where the BB occurs
in the same index for multiple phis.  This speeds up CGP on
an insane testcase from 8.35 to 3.58s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96080 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 04:24:19 +00:00
Chris Lattner
2f36ea8b74 iterate over preds using PHI information when available instead of
using pred_begin/end.  It is much faster.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96079 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 04:15:26 +00:00
Chris Lattner
3f65b5e733 speed up CGP a bit by scanning predecessors through phi operands
instead of with pred_begin/end.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96078 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 04:04:42 +00:00
Dan Gohman
9214b82c54 Fix a pruning heuristic which implicitly assumed that SmallPtrSet is
deterministically sorted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96071 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 02:06:02 +00:00
Jakob Stoklund Olesen
f0907fe590 Enable the inlinehint attribute in the Inliner.
Functions explicitly marked inline will get an inlining threshold slightly
more aggressive than the default for -O3. This means than -O3 builds are
mostly unaffected while -Os builds will be a bit bigger and faster.

The difference depends entirely on how many 'inline's are sprinkled on the
source.

In the CINT2006 suite, only these tests are significantly affected under -Os:

               Size   Time
471.omnetpp   +1.63% -1.85%
473.astar     +4.01% -6.02%
483.xalancbmk +4.60%  0.00%

Note that 483.xalancbmk runs too quickly to give useful timing results.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96066 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 01:51:53 +00:00
Dan Gohman
68d6da1f33 Reapply 95979, a compile-time speedup, now that the bug it exposed is fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96005 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 19:35:25 +00:00
Dan Gohman
cd045c08ca Fix this code to avoid dereferencing an end() iterator in
offset distributions it doesn't expect.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96002 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 19:20:37 +00:00
Chris Lattner
c3b6ffc431 1. modernize the constantmerge pass, using densemap/smallvector.
2. don't bother trying to merge globals in non-default sections,
   doing so is quite dubious at best anyway.
3. fix a bug reported by Arnaud de Grandmaison where we'd try to
   merge two globals in different address spaces.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95995 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 18:17:23 +00:00
Daniel Dunbar
ae08625085 Revert "Reverse the order for collecting the parts of an addrec. The order", it
is breaking llvm-gcc bootstrap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95988 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 17:27:08 +00:00
Dan Gohman
f21a2f15aa Reverse the order for collecting the parts of an addrec. The order
doesn't matter, except that ScalarEvolution tends to need less time
to fold the results this way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95979 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 11:08:26 +00:00
Dan Gohman
572645cf84 Reapply the new LoopStrengthReduction code, with compile time and
bug fixes, and with improved heuristics for analyzing foreign-loop
addrecs.

This change also flattens IVUsers, eliminating the stride-oriented
groupings, which makes it easier to work with.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95975 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 10:34:29 +00:00
Eric Christopher
dfdddd8ed6 Make sure that ConstantExpr offsets also aren't off of extern
symbols.

Thanks to Duncan Sands for the testcase!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95877 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-11 17:44:04 +00:00
Chris Lattner
8c5ad3a5da Rename ValueRequiresCast to ShouldOptimizeCast, to better reflect
what it does.  Enhance it to return false to optimizing vector
sign extensions from vector comparisions, which is the idiom used
to get a splatted vector for a vector comparison.

Doing this breaks vector-casts.ll, add some compensating 
transformations to handle the important case they cover without
depending on this canonicalization.

This fixes rdar://7434900 a serious pessimization of vector compares.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95855 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-11 06:26:33 +00:00
Chris Lattner
98df4f9cf2 Make DSE only scan blocks that are reachable from the entry
block.  Other blocks may have pointer cycles that will crash
basicaa and other alias analyses.  In any case, there is no
point wasting cycles optimizing dead blocks.  This fixes 
rdar://7635088


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95852 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-11 05:11:54 +00:00
Chris Lattner
1e452650c6 Make jump threading honor x|undef -> true and x&undef -> false,
instead of considering x|undef -> x, which may not be true.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95850 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-11 04:40:44 +00:00
Eric Christopher
26d0e892e3 Add ConstantExpr handling to Intrinsic::objectsize lowering.
Update testcase accordingly now that we can optimize another
section.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95846 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-11 01:48:54 +00:00
Devang Patel
be905e26f6 Ignore dbg info intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95828 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-11 00:20:49 +00:00
Devang Patel
df9292cbdd Strip new llvm.dbg.value intrinsic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95807 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-10 21:19:56 +00:00
Dan Gohman
f451cb870e Fix "the the" and similar typos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95781 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-10 16:03:48 +00:00
Eric Christopher
415326b4ed Move Intrinsic::objectsize lowering back to InstCombineCalls and
enable constant 0 offset lowering.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95691 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 21:24:27 +00:00
Eric Christopher
d2592ff69b Pull these back out, they're a little too aggressive and time
consuming for a simple optimization.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95671 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 17:29:18 +00:00
Chris Lattner
e576f292ee simplify this code, duh.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95643 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 01:14:06 +00:00
Chris Lattner
e538db4fb0 fix PR6193, only considering sign extensions *from i1* for this
xform.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95642 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 01:12:41 +00:00
Eric Christopher
940ab54755 Add file in here too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95641 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 01:11:03 +00:00
Eric Christopher
1926b648e1 Add a new pass to do llvm.objsize lowering using SCEV.
Initial skeleton and SCEVUnknown lowering implemented,
the rest should come relatively quickly.  Move testcase
to new directory.

Move pass to right before SimplifyLibCalls - which is
moved down a bit so we can take advantage of a few opts.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95628 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 00:35:38 +00:00
Chris Lattner
8609fda0f7 fix some problems handling large vectors reported in PR6230
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95616 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08 23:56:03 +00:00
Jakob Stoklund Olesen
570a4a5d9c Reintroduce the InlineHint function attribute.
This time it's for real! I am going to hook this up in the frontends as well.

The inliner has some experimental heuristics for dealing with the inline hint.
When given a -respect-inlinehint option, functions marked with the inline
keyword are given a threshold just above the default for -O3.

We need some experiments to determine if that is the right thing to do.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95466 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-06 01:16:28 +00:00
Jakob Stoklund Olesen
d450e5b886 Don't unroll loops containing function calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95454 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 23:21:31 +00:00
Jakob Stoklund Olesen
58e9ee85fd Teach SimplifyCFG about magic pointer constants.
Weird code sometimes uses pointer constants other than null. This patch
teaches SimplifyCFG to build switch instructions in those cases.

Code like this:

void f(const char *x) {
  if (!x)
    puts("null");
  else if ((uintptr_t)x == 1)
    puts("one");
  else if (x == (char*)2 || x == (char*)3)
    puts("two");
  else if ((intptr_t)x == 4)
    puts("four");
  else
    puts(x);
}

Now becomes a switch:

define void @f(i8* %x) nounwind ssp {
entry:
  %magicptr23 = ptrtoint i8* %x to i64            ; <i64> [#uses=1]
  switch i64 %magicptr23, label %if.else16 [
    i64 0, label %if.then
    i64 1, label %if.then2
    i64 2, label %if.then9
    i64 3, label %if.then9
    i64 4, label %if.then14
  ]

Note that LLVM's own DenseMap uses magic pointers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95439 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 22:03:18 +00:00
Chris Lattner
74529826a7 fix logical-select to invoke filecheck right, and fix hte instcombine
xform it is checking to actually pass.  There is no need to match
m_SelectCst<0, -1> since instcombine canonicalizes that into not(sext).

Add matches for sext(not(x)) in addition to not(sext(x)).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95420 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 19:53:02 +00:00
Dan Gohman
aa0e523287 Implement releaseMemory in CodeGenPrepare and free the BackEdges
container data. This prevents it from holding onto dangling
pointers and potentially behaving unpredictably.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95409 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 19:24:11 +00:00
Dan Gohman
17146baef5 Use a SmallSetVector instead of a SetVector; this code showed up as a
malloc caller in a profile.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95407 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 19:20:15 +00:00
Eric Christopher
724bea90b0 Remove this code for now. I have a better idea and will rewrite with
that in mind.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95402 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 19:04:06 +00:00
Bob Wilson
fc375d2200 Do not reassociate expressions with i1 type. SimplifyCFG converts some
short-circuited conditions to AND/OR expressions, and those expressions
are often converted back to a short-circuited form in code gen.  The
original source order may have been optimized to take advantage of the
expected values, and if we reassociate them, we change the order and
subvert that optimization.  Radar 7497329.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95333 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04 23:32:37 +00:00
Jakob Stoklund Olesen
f9c3b228e5 Increase inliner thresholds by 25.
This makes the inliner about as agressive as it was before my changes to the
inliner cost calculations. These levels give the same performance and slightly
smaller code than before.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95320 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04 18:48:20 +00:00
Eric Christopher
e7b97471f8 Temporarily revert this since it appears to have caused a build
failure.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95294 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04 06:41:27 +00:00
Eric Christopher
ea4b6dfd8f Rework constant expr and array handling for objectsize instcombining.
Fix bugs where we would compute out of bounds as in bounds, and where
we couldn't know that the linker could override the size of an array.

Add a few new testcases, change existing testcase to use a private
global array instead of extern.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95283 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04 02:55:34 +00:00
Eric Christopher
ec5ef6d8b0 If we're dealing with a zero-length array, don't lower to any
particular size, we just don't know what the length is yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95266 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 23:56:07 +00:00
Bob Wilson
3992feb075 Adjust the heuristics used to decide when SROA is likely to be profitable.
The SRThreshold value makes perfect sense for checking if an entire aggregate
should be promoted to a scalar integer, but it is not so good for splitting
an aggregate into its separate elements.  A struct may contain a large embedded
array along with some scalar fields that would benefit from being split apart
by SROA.  Even if the total aggregate size is large, it may still be good to
perform SROA.  Thus, the most important piece of this patch is simply moving
the aggregate size comparison vs. SRThreshold so that it guards only the
aggregate promotion.

We have also been checking the number of elements to decide if an aggregate
should be split up.  The limit of "SRThreshold/4" seemed rather arbitrary,
and I don't think it's very useful to derive this limit from SRThreshold
anyway.  I've collected some data showing that the current default limit of
32 (since SRThreshold defaults to 128) is a reasonable cutoff for struct
types.  One thing suggested by the data is that distinguishing between structs
and arrays might be useful.  There are (obviously) a lot more large arrays
than large structs (as measured by the number of elements and not the total
size -- a large array inside a struct still counts as a single element given
the way we do SROA right now).  Out of 8377 arrays where we successfully
performed SROA while compiling a large set of benchmarks, only 16 of them had
more than 8 elements.  And, for those 16 arrays, it's not at all clear that
SROA was actually beneficial.  So, to offset the compile time cost of
investigating more large structs for SROA, the patch lowers the limit on array
elements to 8.

This fixes Apple Radar 7563690.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95224 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 17:23:56 +00:00
Evan Cheng
febc81680c Revert 94937 and move the noreturn check to codegen.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95198 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 03:55:59 +00:00
Bob Wilson
e7b635f430 Fix some comment typos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95170 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 00:33:21 +00:00
Eric Christopher
0c6a8f9eda Recommit this, looks like it wasn't the cause.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95165 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 00:21:58 +00:00
Eric Christopher
9f34dd305b Hopefully temporarily revert this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95154 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 23:01:31 +00:00
Eric Christopher
8334f068c4 Reformat my last patch slightly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95147 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 22:29:26 +00:00
Eric Christopher
a6a089cd24 Re-add strcmp and known size object size checking optimization.
Passed bootstrap and nightly test run here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95145 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 22:10:43 +00:00
Chris Lattner
39ceb471b7 don't turn (A & (C0?-1:0)) | (B & ~(C0?-1:0)) -> C0 ? A : B
for vectors.  Codegen is generating awful code or segfaulting
in various cases (e.g. PR6204).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95058 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 02:43:51 +00:00
Chris Lattner
3d606bbc92 fix a crash in loop unswitch on a loop invariant vector condition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95055 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 02:26:54 +00:00
Dan Gohman
3b5487e627 LangRef.html says that inttoptr and ptrtoint always use zero-extension
when the cast is extending.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95046 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 01:44:02 +00:00
Eric Christopher
11225dd710 Don't need to check the last argument since it'll always be bool. We also
don't use TargetData here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95040 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 00:51:45 +00:00
Eric Christopher
3a8bb73690 More indentation/tabification fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95036 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 00:13:06 +00:00
Eric Christopher
eae6ed1084 Untabify previous commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95035 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 00:06:55 +00:00
Eric Christopher
6ddf0430e1 Formatting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95027 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-01 23:25:03 +00:00
Bob Wilson
6cad41778e Add an option to GVN to remove all partially redundant loads. This is currently
disabled by default.  This divides the existing load PRE code into 2 phases:
first it checks that it is safe to move the load to each of the predecessors
where it is unavailable, and then if it is safe, the code is changed to move
the load.  Radar 7571861.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95007 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-01 21:17:14 +00:00
Chris Lattner
5f670d4131 cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94995 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-01 19:54:45 +00:00
Chris Lattner
d569561835 fix rdar://7590304, a miscompilation of objc apps on arm. The caller
of objc message send was getting marked arm_apcscc, but the prototype
isn't.  This is fine at runtime because objcmsgsend is implemented in
assembly.  Only turn a mismatched caller and callee into 'unreachable'
if the callee is a definition.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94986 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-01 18:11:34 +00:00
Chris Lattner
830f3f205d fix rdar://7590304, an infinite loop in instcombine. In the invoke
case, instcombine can't zap the invoke for fear of changing the CFG.
However, we have to do something to prevent the next iteration of
instcombine from inserting another store -> undef before the invoke
thereby getting into infinite iteration between dead store elim and
store insertion.

Just zap the callee to null, which will prevent the next iteration
from doing anything.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94985 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-01 18:04:58 +00:00
Bob Wilson
3cb8509b68 Fix pr6198 by moving the isSized() check to an outer conditional.
The testcase from pr6198 does not crash for me -- I don't know what's up with
that -- so I'm not adding it to the tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94984 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-01 17:41:44 +00:00
Eli Friedman
be7cfa6033 Simplify/generalize the xor+add->sign-extend instcombine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94943 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31 04:29:12 +00:00
Eli Friedman
694488f477 Add a small transform: transform -(X<<Y) to (-X<<Y) when the shift has a single
use and X is free to negate.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94941 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31 02:30:23 +00:00
Evan Cheng
56a5886b20 Do not mark no-return calls tail calls. It'll screw up special calls like longjmp and it doesn't make much sense for performance reason. If my logic is faulty, please let me know.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94937 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31 00:59:31 +00:00
Bob Wilson
49db68fba0 Check alignment of loads when deciding whether it is safe to execute them
unconditionally.  Besides checking the offset, also check that the underlying
object is aligned as much as the load itself.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94875 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 04:42:39 +00:00
Bob Wilson
6ecfccfd55 Use more specific types to avoid casts. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94863 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 00:41:10 +00:00
Jakob Stoklund Olesen
b489d0f88a Keep iterating over all uses when meeting a phi node in AllUsesOfValueWillTrapIfNull().
This bug was exposed by my inliner cost changes in r94615, and caused failures
of lencod on most architectures when building with LTO.

This patch fixes lencod and 464.h264ref on x86-64 (and likely others).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94858 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 23:54:14 +00:00
Bob Wilson
fb2ea6130d Preserve load alignment in instcombine transformations. I've been unable to
create a testcase where this matters.  The select+load transformation only
occurs when isSafeToLoadUnconditionally is true, and in those situations,
instcombine also changes the underlying objects to be aligned.  This seems
like a good idea regardless, and I've verified that it doesn't pessimize
the subsequent realignment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94850 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 22:39:21 +00:00
Eric Christopher
36664bfc7a Revert my last couple of patches. They appear to have broken bison.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94841 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 21:16:24 +00:00
Bob Wilson
963e84f9fc Use uint64_t instead of unsigned for offsets and sizes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94835 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 20:34:28 +00:00
Bob Wilson
3eb4f7e2dd Improve isSafeToLoadUnconditionally to recognize that GEPs with constant
indices are safe if the result is known to be within the bounds of the
underlying object.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94829 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 19:19:08 +00:00
Duncan Sands
ac512171ff Having RHSKnownZero and RHSKnownOne be alternative names for KnownZero and KnownOne
(via APInt &RHSKnownZero = KnownZero, etc) seems dangerous and confusing to me: it
is easy not to notice this, and then wonder why KnownZero/RHSKnownZero changed
underneath you when you modified RHSKnownZero/KnownZero etc.  So get rid of this.
No intended functionality change (tested with "make check" + llvm-gcc bootstrap).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94802 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 06:18:46 +00:00
Eric Christopher
407e47c21e Make strcpy_chk lower to strcpy if we have a safe size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94783 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 01:37:11 +00:00
Eric Christopher
949124ce0f Add constant support to object size handling and remove default
lowering. We'll either figure it out, or not and be lowered by
SelectionDAGBuild.

Add test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94775 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 01:09:57 +00:00
Bill Wendling
466f37befb Generic reformatting and comment fixing. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94771 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 00:52:43 +00:00
Bill Wendling
9f9113a44b Add newline to debugging output, and fix some grammar-os in comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94765 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 00:27:39 +00:00
Victor Hernandez
1897ed3d37 mem2reg erases the dbg.declare intrinsics that it converts to dbg.val intrinsics
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94763 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 00:01:35 +00:00
Duncan Sands
2c47368a7d Fix PR6165. The bug was that LHSKnownZero was being and'd with DemandedMask
when it should have been and'd with LowBits.  Fix that and while there beef
up the logic in the case of a negative LHS.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94745 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28 17:22:42 +00:00
Bob Wilson
e98585eb36 Avoid creating redundant PHIs in SSAUpdater::GetValueInMiddleOfBlock.
This was already being done in SSAUpdater::GetValueAtEndOfBlock so I've
just changed SSAUpdater to check for existing PHIs in both places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94690 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27 22:01:02 +00:00
Jeffrey Yasskin
f0356fe140 Kill ModuleProvider and ghost linkage by inverting the relationship between
Modules and ModuleProviders. Because the "ModuleProvider" simply materializes
GlobalValues now, and doesn't provide modules, it's renamed to
"GVMaterializer". Code that used to need a ModuleProvider to materialize
Functions can now materialize the Functions directly. Functions no longer use a
magic linkage to record that they're materializable; they simply ask the
GVMaterializer.

Because the C ABI must never change, we can't remove LLVMModuleProviderRef or
the functions that refer to it. Instead, because Module now exposes the same
functionality ModuleProvider used to, we store a Module* in any
LLVMModuleProviderRef and translate in the wrapper methods.  The bindings to
other languages still use the ModuleProvider concept.  It would probably be
worth some time to update them to follow the C++ more closely, but I don't
intend to do it.

Fixes http://llvm.org/PR5737 and http://llvm.org/PR5735.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94686 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27 20:34:15 +00:00
Benjamin Kramer
5deb57c685 Don't bother with sprintf, just pass the Twine through.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94684 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27 19:58:47 +00:00
Benjamin Kramer
2d64ca09d4 Use the less expensive getName function instead of getNameStr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94683 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27 19:46:52 +00:00
Chris Lattner
3511c70d18 some cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94649 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27 02:12:20 +00:00
Chris Lattner
5b718e3e4d no need to check for null
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94648 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27 02:04:20 +00:00
Victor Hernandez
b7ae53f035 When converting dbg.declare to dbg.value, attach promoted store's debug metadata to dbg.value
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94634 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27 00:44:36 +00:00
Victor Hernandez
0c81e34a54 Avoid extra calls to MD->getNumOperands()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94618 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 23:29:09 +00:00
Victor Hernandez
d044612489 Switch AllocaDbgDeclares to SmallVector and don't leak DIFactory
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94567 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 18:57:53 +00:00
Victor Hernandez
b9768b0731 In mem2reg, for all alloca/stores that get promoted where the alloca has an associated llvm.dbg.declare instrinsic, insert an llvm.dbg.var intrinsic before each store.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94493 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 02:42:15 +00:00
Bob Wilson
0988639963 Remove check for an impossible condition: the condition of the while loop has
already checked that TmpBB->getSinglePredecessor() is non-null.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94451 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 21:28:05 +00:00
Bob Wilson
032742972f Change Value::getUnderlyingObject to have the MaxLookup value specified as a
parameter with a default value, instead of just hardcoding it in the
implementation.  The limit of MaxLookup = 6 was introduced in r69151 to fix
a performance problem with O(n^2) behavior in instcombine, but the scalarrepl
pass is relying on getUnderlyingObject to go all the way back to an AllocaInst.
Making the limit part of the method signature makes it clear that by default
the result is limited and should help avoid similar problems in the future.
This fixes pr6126.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94433 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 18:26:54 +00:00
Victor Hernandez
aee6a656e8 Revert r94260 until findDbgDeclare() is made more efficient
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94432 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 17:52:13 +00:00
Chris Lattner
43b5f9312d make -fno-rtti the default unless a directory builds with REQUIRES_RTTI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94378 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-24 20:43:08 +00:00
Chris Lattner
abb992d6a3 change the canonical form of "cond ? -1 : 0" to be
"sext cond" instead of a select.  This simplifies some instcombine
code, matches the policy for zext (cond ? 1 : 0 -> zext), and allows
us to generate better code for a testcase on ppc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94339 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-24 00:09:49 +00:00
Chris Lattner
f7d0d163c5 fix a potential overflow issue Eli pointed out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94336 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 23:31:46 +00:00
Nick Lewycky
44540740ae Speculatively revert r94322 to see if it fixes darwin selfhost buildbot.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94331 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 20:32:12 +00:00
Chris Lattner
d668839cb9 third bug from PR6119: the xor dupe extension allows
for arbitrary terminators in predecessors, don't assume
it is a conditional or uncond branch.  The testcase shows
an example where they can happen with switches.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94323 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 19:21:31 +00:00
Nick Lewycky
dbeecede80 Teach DAE that even though it can't modify the function signature of an
externally visible function, it can still find all callers of it and replace
the parameters to a dead argument with undef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94322 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 19:19:34 +00:00
Chris Lattner
2dd7657a5b add an early out to ProcessBranchOnXOR to speed it up,
handle the case when we can infer an input to the xor
from all inputs that agree, instead of going into an
infinite loop.  Another part of PR6199


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94321 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 19:16:25 +00:00
Chris Lattner
8231fd1e6c fix a crash in jump threading, PR6119
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94319 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 18:56:07 +00:00
Chris Lattner
818ff34bc0 implement a simple instcombine xform that has been in the
readme forever.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94318 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 18:49:30 +00:00
Eric Christopher
7672d04f77 Reapply 94059 while fixing the calling convention setup
for strcpy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94287 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 05:29:06 +00:00
Victor Hernandez
b6aebc2f46 In mem2reg, for all alloca/stores that get promoted where the alloca has an associated llvm.dbg.declare instrinsic, insert an llvm.dbg.var intrinsic before each store
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94260 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 00:17:34 +00:00
Benjamin Kramer
b0706d1859 Another strncmp -> StringRef.startswith simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94203 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 20:00:21 +00:00
Bob Wilson
8a23e0b07b Revert 94059. It is breaking the MultiSource/Benchmarks/Prolangs-C/bison
test on ARM.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94198 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 19:16:40 +00:00
Victor Hernandez
29fa5e9886 Keep ignoring pointer-to-pointer bitcasts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94194 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 19:05:05 +00:00
Chris Lattner
e73a31f667 Stop building RTTI information for *most* llvm libraries. Notable
missing ones are libsupport, libsystem and libvmcore.  libvmcore is
currently blocked on bugpoint, which uses EH.  Once it stops using
EH, we can switch it off.

This #if 0's out 3 unit tests, because gtest requires RTTI information.
Suggestions welcome on how to fix this.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94164 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 06:49:46 +00:00
Dan Gohman
7979b72feb Revert LoopStrengthReduce.cpp to pre-r94061 for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94123 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 00:46:49 +00:00
Victor Hernandez
edd7966809 No need to look through bitcasts for DbgInfoIntrinsic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94114 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 23:09:12 +00:00
Victor Hernandez
e31dc355b2 DbgInfoIntrinsic no longer appear in an instruction's use list
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94113 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 23:08:36 +00:00
Victor Hernandez
a4c77622f7 No need to look through bitcasts for DbgInfoIntrinsic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94112 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 23:07:15 +00:00
Victor Hernandez
6c146eefbf DbgInfoIntrinsics no longer appear in an instruction's use list; so clean up looking for them in use iterations and remove OnlyUsedByDbgInfoIntrinsics()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94111 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 23:05:53 +00:00
Dan Gohman
eca35b76ce When inserting expressions for post-increment users which contain
loop-variant components, adds must be inserted after the increment.
Keep track of the increment position for this case, and insert
these adds in the correct location.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94110 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 23:01:22 +00:00
Dan Gohman
940bd3e236 Include IVUsers information in LSR's debug output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94108 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 22:46:32 +00:00
Dan Gohman
8b0ade3eb8 Prune the search for candidate formulae if the number of register
operands exceeds the number of registers used in the initial
solution, as that wouldn't lead to a profitable solution anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94107 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 22:42:49 +00:00
Dan Gohman
2f524587b6 Add a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94104 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 21:31:09 +00:00
Chris Lattner
839a0159c4 It turns out that this #include is needed because otherwise
ValueMapper.cpp ends up calling an out of line 
__ZNK4llvm12PATypeHolder3getEv, which is a template and llvm-config
determines arbitrarily to use the one in libipo.  This sucks, but
keeping the #include is a reasonable workaround.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94103 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 21:29:25 +00:00
Chris Lattner
7bc3bcebb0 unbreak the build, apparently without this transformutils starts depending on libipa?
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94102 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 21:20:51 +00:00
Chris Lattner
1b3ef34b75 tidy up
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94101 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 21:05:54 +00:00
Victor Hernandez
589423cd63 Don't need to include IntrinsicInst.h any more
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94092 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 19:33:59 +00:00
Victor Hernandez
f42fae1674 No need to map NULL operands of metadata
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94091 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 19:26:20 +00:00
Dan Gohman
a10756ee65 Re-implement the main strength-reduction portion of LoopStrengthReduction.
This new version is much more aggressive about doing "full" reduction in
cases where it reduces register pressure, and also more aggressive about
rewriting induction variables to count down (or up) to zero when doing so
reduces register pressure.

It currently uses fairly simplistic algorithms for finding reuse
opportunities, but it introduces a new framework allows it to combine
multiple strategies at once to form hybrid solutions, instead of doing
all full-reduction or all base+index.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94061 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 02:09:26 +00:00
Eric Christopher
ed1a4c7eab Add strcpy_chk -> strcpy support for "don't know" object size
answers.  This will update as object size checking gets better information.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94059 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 01:04:38 +00:00
Chris Lattner
0527344853 simplify this code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94048 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 23:30:28 +00:00
Jakob Stoklund Olesen
f8526cb711 Move per-function inline threshold calculation to a method.
No functional change except the forgotten test for
InlineLimit.getNumOccurrences() == 0 in the CurrentThreshold2 calculation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94007 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 17:51:28 +00:00
Victor Hernandez
acf1831596 Switch Elts from vector to SmallVector
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93989 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 06:56:16 +00:00
Victor Hernandez
f58c34d531 Map operands of all function-local metadata, not just metadata passed to llvm.dbg.declare intrinsics
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93979 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 05:49:59 +00:00
Dan Gohman
d8d0b6a42c When doing address-mode sinking, expand the base register first, rather
than the scaled register. This makes it more likely that subsequent
AddrModeMatcher queries will match the new address the same way as the
old, instead of accidentally matching what had been the base register
as the new scaled register, and then failing to match the scaled register.
This fixes some problems with address-mode sinking multiple muls into a
block, which will be a lot more common with some upcoming
LoopStrengthReduction changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93935 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:45:06 +00:00
Chris Lattner
c0404b3715 optimize ~(~X >>s Y) --> (X >>s Y), patch by Edmund Grimley
Evans!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93884 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 18:16:19 +00:00
Bob Wilson
a756b1d914 Fix a crash in scalarrepl for memcpy/memmove where the source and destination
are the same.  I had already fixed a similar problem where the source and
destination were different bitcasts derived from the same alloca, but the
previous fix still did not handle the case where both operands are exactly
the same value.  Radar 7552893.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93848 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 04:32:48 +00:00
Eric Christopher
d3dc3cc98f Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93831 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 01:20:15 +00:00
Chris Lattner
cd5adbbc0c my instcombine transformations to make extension elimination more
aggressive changed the canonical form from sext(trunc(x)) to ashr(lshr(x)),
make sure to transform a couple more things into that canonical form,
and catch a case where we missed turning zext/shl/ashr into a single sext.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93787 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:19:16 +00:00
Devang Patel
f9d5c5cf9f While mapping llvm.dbg.declare intrinsic manually map its operand, if possible,
because it points to an alloca instruction through metadata.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93757 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 19:52:14 +00:00
Owen Anderson
a81e241fcc Convert some of the dynamic opcode lookups into static ones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93693 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-17 19:33:27 +00:00
Owen Anderson
5b39620e2d Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93679 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-17 06:49:03 +00:00
Bob Wilson
5cd8770412 Fix a comment typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93560 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 21:55:02 +00:00
Bill Wendling
22f3b9faac When the visitSub method was split into visitSub and visitFSub, this xform was
added to the FSub version. However, the original version of this xform guarded
against doing this for floating point (!Op0->getType()->isFPOrFPVector()).

This is causing LLVM to perform incorrect xforms for code like:

void func(double *rhi, double *rlo, double xh, double xl, double yh, double yl){
  double mh, ml;
  double c = 134217729.0;
  double up, u1, u2, vp, v1, v2;
        
  up = xh*c;
  u1 = (xh - up) + up;
  u2 = xh - u1;
        
  vp = yh*c;
  v1 = (yh - vp) + vp;
  v2 = yh - v1;
        
  mh = xh*yh;
  ml = (((u1*v1 - mh) + (u1*v2)) + (u2*v1)) + (u2*v2);
  ml += xh*yl + xl*yh;
        
  *rhi = mh + ml;
  *rlo = (mh - (*rhi)) + ml;
}

The last line was optimized away, but rl is intended to be the difference
between the infinitely precise result of mh + ml and after it has been rounded
to double precision.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93369 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 23:23:17 +00:00
Chris Lattner
972a46c96a 1) Use the new SimplifyInstructionsInBlock routine instead of the copy
in JT.

2) When cloning blocks for PHI or xor conditions, use
instsimplify to simplify the code as we go.  This allows us to 
squish common cases early in JT which opens up opportunities for
subsequent iterations, and allows it to completely simplify the
testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93253 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 20:41:47 +00:00
Chris Lattner
e234a30a28 add a helper function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93251 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 19:40:54 +00:00
Chris Lattner
797c440caf tidy up
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93222 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 02:07:50 +00:00
Chris Lattner
2249a0b1bd Teach jump threading to duplicate small blocks when the branch
condition is a xor with a phi node.  This eliminates nonsense
like this from 176.gcc in several places:

 LBB166_84:
        testl   %eax, %eax
-       setne   %al
-       xorb    %cl, %al
-       notb    %al
-       testb   $1, %al
-       je      LBB166_85
+       je      LBB166_69
+       jmp     LBB166_85

This is rdar://7391699



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93221 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 02:07:17 +00:00
Chris Lattner
77beb479f5 some cleanup, and make it obvious that ProcessJumpOnPHI only works
on branches by renaming it and checking for a branch at the call site.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93208 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 23:41:09 +00:00
Chris Lattner
53af2d13e7 reenable the piece that turns trunc(zext(x)) -> x even if zext has multiple uses,
codegen has no apparent problem with the trunc version of this, because it turns
into a simple subreg idiom


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93202 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 22:49:40 +00:00
Chris Lattner
a958cbfe36 Disable folding sext(trunc(x)) -> x (and other similar cast/cast cases) when the
trunc has multiple uses.  Codegen is not able to coalesce the subreg case 
correctly and so this leads to higher register pressure and spilling (see PR5997).

This speeds up 256.bzip2 from 8.60 -> 8.04s on my machine, ~7%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93200 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 22:45:25 +00:00
Chris Lattner
8e76764de8 add one more bitfield optimization, allowing clang to generate
good code on PR4216:

_test_bitfield:                                             ## @test_bitfield
	orl	$32962, %edi
	movl	$4294941946, %eax
	andq	%rdi, %rax
	ret

instead of:

_test_bitfield:
        movl    $4294941696, %ecx
        movl    %edi, %eax
        orl     $194, %edi
        orl     $32768, %eax
        andq    $250, %rdi
        andq    %rax, %rcx
        movq    %rdi, %rax
        orq     %rcx, %rax
        ret

Evan is looking into the remaining andq+imm -> andl optimization.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93147 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 06:55:24 +00:00
Chris Lattner
7acc4b1281 Extend CanEvaluateZExtd to handle and/or/xor more aggressively in the
BitsToClear case.  This allows it to promote expressions which have an
and/or/xor after the lshr, promoting cases like test2 (from PR4216) 
and test3 (random extample extracted from a spec benchmark).

clang now compiles the code in PR4216 into:

_test_bitfield:                                             ## @test_bitfield
	movl	%edi, %eax
	orl	$194, %eax
	movl	$4294902010, %ecx
	andq	%rax, %rcx
	orl	$32768, %edi
	andq	$39936, %rdi
	movq	%rdi, %rax
	orq	%rcx, %rax
	ret

instead of:

_test_bitfield:                                             ## @test_bitfield
	movl	%edi, %eax
	orl	$194, %eax
	movl	$4294902010, %ecx
	andq	%rax, %rcx
	shrl	$8, %edi
	orl	$128, %edi
	shlq	$8, %rdi
	andq	$39936, %rdi
	movq	%rdi, %rax
	orq	%rcx, %rax
	ret

which is still not great, but is progress.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93145 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 04:05:13 +00:00
Chris Lattner
789162a309 Remove the dead TD argument to CanEvaluateZExtd, and add a
new BitsToClear result which allows us to start promoting
expressions that end with a lshr-by-constant.  This is
conservatively correct and better than what we had before
(see testcases) but still needs to be extended further.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93144 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 03:32:00 +00:00
Chris Lattner
8cf4f6f3dd improve comments, remove dead TD argument to CanEvaluateSExtd.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93143 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 02:43:35 +00:00
Chris Lattner
11ea812424 teach sext optimization to handle truncs from types that are not
the dest of the sext.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93128 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 20:30:41 +00:00
Chris Lattner
9ee947c224 teach zext optimization how to deal with truncs that don't come from
the zext dest type.  This allows us to handle test52/53 in cast.ll,
and allows llvm-gcc to generate much better code for PR4216 in -m64
mode:

_test_bitfield:                                             ## @test_bitfield
	orl	$32962, %edi
	movl	%edi, %eax
	andl	$-25350, %eax
	ret

This also fixes a bug handling vector extends, ensuring that the
mask produced is a vector constant, not an integer constant.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93127 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 20:25:54 +00:00
Chris Lattner
aa9c894523 simplify CanEvaluateSExtd to return a bool now that we have a
simpler profitability predicate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93111 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 07:57:20 +00:00
Chris Lattner
6954ceec1a the NumCastsRemoved argument to CanEvaluateSExtd is dead, remove it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93110 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 07:42:21 +00:00
Chris Lattner
dde5ee5d37 now that the cost model has changed, we can always consider
elimination of a sign extend to be a win, which simplifies 
the client of CanEvaluateSExtd, and allows us to eliminate
more casts (examples taken from real code).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93109 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 07:40:50 +00:00
Chris Lattner
f4fb91181c change the preferred canonical form for a sign extension to be
lshr+ashr instead of trunc+sext.  We want to avoid type 
conversions whenever possible, it is easier to codegen expressions
without truncates and extensions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93107 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 07:08:30 +00:00
Chris Lattner
abff82d99e fix indentation of switch statements, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93106 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 06:59:55 +00:00
Chris Lattner
6091e0289b fix pasto that broke bootstrap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93105 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 06:50:04 +00:00
Chris Lattner
9e390ddf91 simplify CanEvaluateZExtd now that we don't care about the number of
bits known clear in the result and don't care about the # casts 
eliminated.  TD is also dead but keeping it for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93098 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 02:50:04 +00:00
Chris Lattner
5324d80283 two changes:
1) don't try to optimize a sext or zext that is only used by a trunc, let
   the trunc get optimized first.  This avoids some pointless effort in
   some common cases since instcombine scans down a block in the first pass.
2) Change the cost model for zext elimination to consider an 'and' cheaper
   than a zext.  This allows us to do it more aggressively, and for the next
   patch to simplify the code quite a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93097 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 02:39:31 +00:00
Chris Lattner
d26c9e183e enhance CanEvaluateZExtd to handle shift left and sext, allowing
more expressions to be promoted and casts eliminated.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93096 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 02:22:12 +00:00
Chris Lattner
3f7dc880c4 remove an xform subsumed by EvaluateInDifferentType.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93095 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 01:35:55 +00:00
Julien Lerouge
5c1735a4df Fix nondeterministic behavior.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93093 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 01:07:22 +00:00
Chris Lattner
4f37978b90 clean up this xform by using m_Trunc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93092 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 01:04:31 +00:00
Chris Lattner
d84dfa43f2 inline and remove the rest of commonIntCastTransforms.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93091 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 01:00:46 +00:00
Chris Lattner
75215c9e39 Inline the expression type promotion/demotion stuff out of
commonIntCastTransforms into the callers, eliminating a switch,
and allowing the static predicate  methods to be moved down to
live next to the corresponding function.  No functionality 
change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93089 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 00:58:42 +00:00
Chris Lattner
c2d1b6949c only factor from expressions whose uses are empty and whose
base is the right expression type.  This fixes PR5981.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93045 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-09 06:01:36 +00:00
Julien Lerouge
c5dd34209b Fix nondeterministic behavior.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93038 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-09 01:06:49 +00:00
Eric Christopher
4d1f58861d Remove unnecessary dyn_cast and add a comment. Part of a WIP.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93026 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 21:37:11 +00:00
Chris Lattner
c8b3fce5c5 mplement a theoretical fixme.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93024 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 19:28:47 +00:00
Chris Lattner
14bf8f0285 rename CanEvaluateInDifferentType -> CanEvaluateTruncated and
simplify it now that it is only used for truncates.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93021 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 19:19:23 +00:00
Chris Lattner
a85732fa3b teach instcombine to delete sign extending shift pairs (sra(shl X, C), C) when
the input is already sign extended.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93019 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 19:04:21 +00:00
Duncan Sands
54a57045eb Suppress an unused variable warning when assertions are off;
remove some trailing whitespace while there.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93008 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 17:51:48 +00:00
Chris Lattner
9aa1e246dd tidy up some stuff duncan pointed out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93007 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 17:48:19 +00:00
Chris Lattner
8d10f9d4a8 teach ComputeNumSignBits to look through PHI nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92964 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 23:44:37 +00:00
Chris Lattner
075f692939 Enhance instcombine to reason more strongly about promoting computation
that feeds into a zext, similar to the patch I did yesterday for sext.
There is a lot of room for extension beyond this patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92962 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 23:41:00 +00:00
Benjamin Kramer
66b581ef49 Use a do-while loop instead of while + boolean.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92912 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 13:50:07 +00:00
Duncan Sands
5d8ea117a0 Be less stingy as to how many selects and phi nodes we
are prepared to look through.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92898 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 05:48:42 +00:00
Chris Lattner
4039bd0550 handle ConstantVector while I'm in here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92892 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 01:20:20 +00:00
Chris Lattner
a0e9a2475c fix a globalopt crash on 'bullet' (handling evaluation of a store
to an element of a vector in a static ctor) which occurs with an 
unrelated patch I'm testing.  Annoyingly, EvaluateStoreInto basically 
does exactly the same stuff as InsertElement constant folding, but it
now handles vectors, and you can't insertelement into a vector.  It
would be 'really nice' if GEP into a vector were not legal.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92889 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 01:16:21 +00:00
Eric Christopher
130063207d Move the object size intrinsic optimization to inst-combine and make
it work for any integer size return type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92853 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 20:04:44 +00:00
Duncan Sands
e10920d678 Fix a README item: have functionattrs look through selects and
phi nodes when deciding which pointers point to local memory.
I actually checked long ago how useful this is, and it isn't
very: it hardly ever fires in the testsuite, but since Chris
wants it here it is!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 15:37:47 +00:00
Mikhail Glushenkov
0ecbdeb14f Formatting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92831 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 09:20:39 +00:00
Duncan Sands
7c422ac216 Partially address a README by having functionattrs consider calls to
memcpy, memset and other intrinsics that only access their arguments
to be readnone if the intrinsic's arguments all point to local memory.
This improves the testcase in the README to readonly, but it could in
theory be made readnone, however this would involve more sophisticated
analysis that looks through the memcpy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92829 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 08:45:52 +00:00
Chris Lattner
5c24a6da29 tweaks suggested by Duncan
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92824 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 05:32:15 +00:00