Commit Graph

3652 Commits

Author SHA1 Message Date
Jakub Staszak
9da9934e27 Introduce "expect" intrinsic instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134516 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-06 18:22:43 +00:00
Benjamin Kramer
fc87cdc1f4 PR10267: Don't combine an equality compare with an AND into an inequality compare when the AND has more than one use.
This can pessimize code, inequalities are generally more expensive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134379 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-04 20:16:36 +00:00
Andrew Trick
4b02915386 indvars -disable-iv-rewrite: bug fix involving weird geps and related cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134306 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-02 02:34:25 +00:00
Dan Gohman
68c0dbc14f Improve constant folding of undef for cmp and select operators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134223 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 01:03:43 +00:00
Dan Gohman
30cb6dda5a Improve constant folding of undef for binary operators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134221 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 00:42:17 +00:00
Rafael Espindola
77a2c372fa Add r134057 back, but splice the predecessor after the successors phi
nodes.

Original message:
Let simplify cfg simplify bb with only debug and lifetime intrinsics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134182 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 20:14:24 +00:00
Andrew Trick
6e0ce24e0c indvars -disable-iv-rewrite: handle cloning binary operators that cannot overflow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134177 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 19:02:17 +00:00
Andrew Trick
60ac719c85 indvars -disable-iv-rewrite: handle an edge case involving identity phis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134124 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 01:27:23 +00:00
Andrew Trick
cc359d9fa2 indvars -disable-iv-rewrite: insert new trunc instructions carefully.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134112 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 23:03:57 +00:00
Chad Rosier
ce77aa3edc Temporarily revert r134057: "Let simplify cfg simplify bb with only debug and
lifetime intrinsics" due to buildbot failures.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134071 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 16:22:11 +00:00
Rafael Espindola
0fb7dcd48f Let simplify cfg simplify bb with only debug and lifetime intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134057 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 05:25:47 +00:00
Andrew Trick
11745d4c02 indvars -disable-iv-rewrite: just because SCEV ignores casts doesn't
mean they can be removed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134054 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 03:13:40 +00:00
Andrew Trick
4086bb5ba5 FileCheckify and prepare for -disable-iv-rewrite.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133998 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 06:34:10 +00:00
Nick Lewycky
9174d5c738 Teach one piece of scalarrepl to handle lifetime markers. When transforming an
alloca that only holds a copy of a global and we're going to replace the users
of the alloca with that global, just nuke the lifetime intrinsics. Part of
PR10121.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133905 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 05:40:02 +00:00
Eli Friedman
00805fae5b PR10180: Fix a instcombine crash with FP vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133756 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 20:40:23 +00:00
Jay Foad
80be2a2654 Add a reduced test case for the buildbot failure (clang self-hosted
build) caused by r133435.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133509 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 08:33:49 +00:00
Andrew Trick
2fabd464ae indvars -disable-iv-rewrite: Adds support for eliminating identity
ops.

This is a rewrite of the IV simplification algorithm used by
-disable-iv-rewrite. To avoid perturbing the default mode, I
temporarily split the driver and created SimplifyIVUsersNoRewrite. The
idea is to avoid doing opcode/pattern matching inside
IndVarSimplify. SCEV already does it. We want to optimize with the
full generality of SCEV, but optimize def-use chains top down on-demand rather
than rewriting the entire expression bottom-up. This was easy to do
for operations that SCEV can prove are identity function. So we're now
eliminating bitmasks and zero extends this way.

A result of this rewrite is that indvars -disable-iv-rewrite no longer
requires IVUsers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133502 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 03:22:38 +00:00
Jay Foad
5e27a1d468 This is an automatically reduced test case that crashed in GVN, at some
point during the development of the phi operand changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133436 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 14:46:47 +00:00
Chris Lattner
a53616d08b Remove support for parsing the "type i32" syntax for defining a numbered
top level type without a specified number.  This syntax isn't documented
and blocks forward progress.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133371 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-19 00:03:46 +00:00
Hans Wennborg
448da519cc Fix PR10103: Less code for enum type translation.
In cases such as the attached test, where the case value for a switch
destination is used in a phi node that follows the destination, it
might be better to replace that value with the condition value of the
switch, so that more blocks can be folded away with
TryToSimplifyUncondBranchFromEmptyBlock because there are less
conflicts in the phi node.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133344 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 10:28:47 +00:00
Nick Lewycky
5a72d9f0be Add test for r133251.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133339 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 07:23:25 +00:00
Cameron Zwarich
3ebb05d9a6 When scalar replacement returns a vector type, only accept it if the vector
type's bitwidth matches the (allocated) size of the alloca. This severely
pessimizes vector scalar replacement when the only vector type being used is
something like <3 x float> on x86 or ARM whose allocated size matches a
<4 x float>.

I hope to fix some of the flawed assumptions about allocated size throughout
scalar replacement and reenable this in most cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133338 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 06:17:51 +00:00
Chris Lattner
b85e4eba85 rip out a ton of intrinsic modernization logic from AutoUpgrade.cpp, which is
for pre-2.9 bitcode files.  We keep x86 unaligned loads, movnt, crc32, and the
target indep prefetch change.

As usual, updating the testsuite is a PITA.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133337 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 06:05:24 +00:00
Cameron Zwarich
6be41eb7f0 Fix an invalid bitcast crash that occurs when doing a partial memset of a vector
alloca. Fixes part of <rdar://problem/9580800>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133336 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 05:47:49 +00:00
Chris Lattner
a16546a70b Stop accepting and ignoring attributes in function types. Attributes are applied
to functions and call/invokes, not to types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133266 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 17:37:13 +00:00
Chris Lattner
d589099eec make the asmparser reject function and type redefinitions. 'Merging' hasn't been
needed since llvm-gcc 3.4 days.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133248 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 07:06:44 +00:00
Chris Lattner
424545e950 remove asmparser support for the old getresult instruction, which has been subsumed by extractvalue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133247 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 06:57:15 +00:00
Chris Lattner
437544f25c remove parser support for the obsolete "multiple return values" syntax, which
was replaced with return of a "first class aggregate".



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133245 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 06:49:41 +00:00
Chris Lattner
6b7c89ee09 stop accepting begin/end around function bodies in the .ll parser, this isn't pascal anymore.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133244 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 06:42:57 +00:00
Chris Lattner
7a1b9bdd2b Remove support for using "foo" as symbols instead of %"foo". This is ancient
syntax and has been long obsolete.  As usual, updating the tests is the nasty
part of this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133242 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 06:36:20 +00:00
Chris Lattner
26b0000166 manually upgrade a bunch of tests to modern syntax, and remove some that
are either unreduced or only test old syntax.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133228 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 03:14:27 +00:00
Dan Gohman
0860d0ba2f Fix ARCOpt to insert releases on both successors of an invoke rather
than trying to insert them immediately after the invoke.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133188 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 20:57:14 +00:00
John McCall
9fbd318d36 The ARC language-specific optimizer. Credit to Dan Gohman.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133108 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 23:37:01 +00:00
Stuart Hastings
7ac8f8f341 Avoid fusing bitcasts with dynamic allocas if the amount-to-allocate
might overflow.  Re-typing the alloca to a larger type (e.g. double)
hoists a shift into the alloca, potentially exposing overflow in the
expression.  rdar://problem/9265821


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132926 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-13 18:48:49 +00:00
Benjamin Kramer
e7fdcad2f2 InstCombine: Fold A-b == C --> b == A-C if A and C are constants.
The backend already knew this trick.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132915 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-13 15:24:24 +00:00
Benjamin Kramer
ffd0ae64c4 InstCombine: Shrink ((zext X) & C1) == C2 to fold away the cast if the "zext" and the "and" have one use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132897 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-12 22:48:00 +00:00
Benjamin Kramer
7e7c9cc31a Simplify code. No functionality changes, name changes aside.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132896 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-12 22:47:53 +00:00
John McCall
1dd94bbfa1 SplitCriticalEdge can sometimes split the edge from an invoke to a landing
pad, separating the exception and selector calls from the new lpad.  Teaching
it not to do that, or to properly adjust the CFG afterwards, is out of
scope because it would require the other edges to the landing pad to be split
as well (effectively).  Instead, just recover from the most likely cases
during inlining.  The best long-term solution is to change the exception
representation and commit to either requiring or not requiring the more
complex edge-splitting logic;  this is just a shorter-term hack.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132799 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-09 20:06:24 +00:00
Cameron Zwarich
96cc1d0dfb Fix PR10104 by adding a bounds check on a vector element access check. It was
assuming that all offsets are legal vector accesses, and thus trying to access
the float member of { <2 x float>, float } as the 3rd element of the first
member.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132766 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-09 01:45:33 +00:00
Cameron Zwarich
0398d6135d Fix an assymmetry between ConvertScalar_ExtractValue and ConvertScalar_InsertValue. The
former was using the size of the entire alloca, whereas the latter was correctly using
the allocated size of the immediate type being converted (which may differ from the size
of the alloca). This fixes PR10082.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132759 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-08 22:08:31 +00:00
Nick Lewycky
9071ac2797 This directory was missing the dg.exp to cause the tests to run. Some time since
it was added, the test has regressed, so XFAIL it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132686 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-06 20:23:00 +00:00
Bill Wendling
6a648b8538 If the block that we're threading through is jumped to by an indirect branch,
then we don't want to set the destination in the indirect branch to the
destination. This is because the indirect branch needs its destinations to have
had their block addresses taken. This isn't so of the new critical edge that's
split during this process. If it turns out that the destination block has only
one predecessor, and that being a BB with an indirect branch, then it won't be
marked as 'used' and may be removed.
PR10072


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132638 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 09:42:04 +00:00
Dan Gohman
f14d33d4cb Add a testcase to demonstrate the problem where phi translation is
ignored for clobbering partial-alias loads.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132633 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 07:05:05 +00:00
Dan Gohman
a3351a0e5d Disable the main feature of 130180, the elimination of loads that are
redundant with partially-aliasing loads.

When computing what portion of a clobbering load value is needed,
it doesn't consider phi-translation which may have occurred
between the clobbing load and the redundant load.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132631 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 06:48:50 +00:00
Nick Lewycky
444f297a78 Bail on unswitching a switch statement for a case with a critical edge. We name
which edge to split by pred/succ pair, which means that we can end up splitting
the wrong edge (by case value) in the switch statement entirely. Fixes PR10031!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132535 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 06:27:15 +00:00
Andrew Trick
98c521ceba Test case pasto (failed when run with IR verifier).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132516 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-02 23:57:27 +00:00
Eli Friedman
70d893e84b PR10067: Add missing safety check to call return transformation in MemCpyOpt::processStore. If something accesses the dest of the "copy" between the call and the copy, the performCallSlotOptzn transformation is not valid.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132485 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-02 21:24:42 +00:00
Eli Friedman
7c6a5a2c39 When marking a block as being unanalyzable, use "Clobber" on the terminator instead of the first instruction in the block. This is a bit of a hack; "Clobber" isn't really the right marking in the first place. memdep doesn't really have any way of properly expressing "unanalyzable" at the moment. Using it on the terminator is much less ambiguous than using it on an arbitrary instruction, though.
In the given testcase, the "Clobber" was pointing to a load, and GVN was incorrectly assuming that meant that the "Clobber" load overlapped the load being analyzed (when they are actually unrelated).

The included testcase tests both this commit and r132434.

Part two of rdar://9429882.  (r132434 was mislabeled.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132442 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-02 00:08:52 +00:00
Stuart Hastings
f1002828fd Reapply 132348 with fixes. rdar://problem/6501862
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132402 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 16:42:47 +00:00
John McCall
1edbd6f3f0 First, do no harm -- even if we can't find a selector for an enclosing
landing pad, forward llvm.eh.resume calls to it instead of turning them
invalidly into invokes.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132382 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 02:17:11 +00:00
Andrew Trick
b1ce4c09dd scev: Better sign-extend removal. Normalize postincrement recurrences
so that their sign extended forms are congruent when no overflow occurs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132360 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 21:17:47 +00:00
Stuart Hastings
3200c4b53c Revert to pacify a buildbot. rdar://problem/6501862
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132351 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 19:56:35 +00:00
Stuart Hastings
df48e84b5b Followup to 132316; accept arbitrary constants, add with a constant,
sub with a non-constant.  Fix comments, enlarge test case.
rdar://problem/6501862


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132348 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 19:29:55 +00:00
Stuart Hastings
acbf107d9b (1 - X) * (-2) -> (x - 1) * 2, for all positive nonzero powers of 2
rdar://problem/6501862


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132316 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-30 20:00:33 +00:00
John McCall
221d5de013 Add the test case for phis in the outer landing pad during the inliner's
forwarding of eh.resume that I promised yesterday.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132307 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-30 01:08:04 +00:00
Nick Lewycky
b45178a7fe Add testcase for r132290, to check for the crasher caught by the buildbots
doing llvm-gcc selfhost (or cross).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132292 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-29 19:41:14 +00:00
Nick Lewycky
1f237b0027 Obey the isVolatile bit on memory intrinsics when analyzing uses of a global
variable. Noticed by inspection.

Simulate memset in EvaluateFunction where the target of the memset and the
value we're setting are both the null value. Fixes PR10047!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132288 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-29 18:41:56 +00:00
Benjamin Kramer
2c5cc68874 ConstantFoldInstOperands doesn't like compares, hand it off to instsimplify instead.
Fixes PR10040.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132254 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 10:16:58 +00:00
John McCall
d7c1086201 Implement and document the llvm.eh.resume intrinsic, which is
transformed by the inliner into a branch to the enclosing landing pad
(when inlined through an invoke).  If not so optimized, it is lowered
DWARF EH preparation into a call to _Unwind_Resume (or _Unwind_SjLj_Resume
as appropriate).  Its chief advantage is that it takes both the
exception value and the selector value as arguments, meaning that there
is zero effort in recovering these;  however, the frontend is required
to pass these down, which is not actually particularly difficult.

Also document the behavior of landing pads a bit better, and make it
clearer that it's okay that personality functions don't always land at
landing pads.  This is just a fact of life.  Don't write optimizations that
rely on pushing things over an unwind edge.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132253 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 07:45:59 +00:00
John McCall
a3de16bc8f Fix the inliner to maintain the current de facto invoke semantics:
- the selector for the landing pad must provide all available information
    about the handlers, filters, and cleanups within that landing pad
  - calls to _Unwind_Resume must be converted to branches to the enclosing
    lpad so as to avoid re-entering the unwinder when the lpad claimed it
    was going to handle the exception in some way
This is quite specific to libUnwind-based unwinding.  In an effort to not
interfere too badly with other unwinders, and with existing hacks in frontends,
this only triggers on _Unwind_Resume (not _Unwind_Resume_or_Rethrow) and does
nothing with selectors if it cannot find a selector call for either lpad.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132200 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 18:34:38 +00:00
Benjamin Kramer
17c1bb5d55 InstCombine: Make switch folding with equality compares more aggressive by trying instsimplify on the arm where we know the compared value.
Stuff like "x == y ? y : x&y" now folds into "x&y".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132185 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 13:00:16 +00:00
Chad Rosier
62660310d9 Renamed llvm.x86.sse42.crc32 intrinsics; crc64 doesn't exist.
crc32.[8|16|32] have been renamed to .crc32.32.[8|16|32] and
crc64.[8|16|32] have been renamed to .crc32.64.[8|64].




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-26 23:13:19 +00:00
Andrew Trick
fcdc9a44e5 indvars: incremental fixes for -disable-iv-rewrite and testcases.
Use a proper worklist for use-def traversal without holding onto an
iterator. Now that we process all IV uses, we need complete logic for
resusing existing derived IV defs. See HoistStep.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132103 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-26 00:46:11 +00:00
Eli Friedman
a831a9b972 PR9998: ashr exact %x, 31 is not equivalent to sdiv exact %x, -2147483648.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132097 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 23:26:20 +00:00
Andrew Trick
03d3d3b361 indvars: fixed IV cloning in -disable-iv-rewrite mode with associated
cleanup and overdue test cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132038 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 04:42:22 +00:00
Cameron Zwarich
d05667e703 Fix "make check" in Release by removing debug-only options from an 'opt' invocation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131972 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 18:26:09 +00:00
Cameron Zwarich
c827939046 Make LoadAndStorePromoter preserve debug info and create llvm.dbg.values when
promoting allocas to SSA variables. Fixes <rdar://problem/9479036>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131953 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 03:10:43 +00:00
Andrew Trick
237f15d91f FileCheck-ize a couple of IV unit tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131946 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 01:02:49 +00:00
Andrew Trick
3a2f557bdc Test case for r130799 - indvars: Added canExpandBackEdgeTakenCount.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131939 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 00:17:53 +00:00
Chris Lattner
c10ecd8f23 fix a really nasty basicaa mod/ref calculation bug that was causing miscompilation of
UnitTests/ObjC/messages-2.m with the recent optimizer improvements.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131897 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-23 05:15:43 +00:00
Chris Lattner
05cd886561 Transform any logical shift of a power of two into an exact/NUW shift when
in a known-non-zero context.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131887 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-23 00:21:50 +00:00
Chris Lattner
b3f0673d52 Teach valuetracking that byval arguments with a specified alignment are
aligned.

Teach memcpyopt to not give up all hope when confonted with an underaligned
memcpy feeding an overaligned byval.  If the *source* of the memcpy can be
determined to be adequeately aligned, or if it can be forced to be, we can
eliminate the memcpy.

This addresses PR9794.  We now compile the example into:

define i32 @f(%struct.p* nocapture byval align 8 %q) nounwind ssp {
entry:
  %call = call i32 @g(%struct.p* byval align 8 %q) nounwind
  ret i32 %call
}

in both x86-64 and x86-32 mode.  We still don't get a tailcall though,
because tailcalls apparently can't handle byval.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131884 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-23 00:03:39 +00:00
Chris Lattner
805fa97a0f implement PR9315, constant folding exp2 in terms of pow (since hosts without
C99 runtimes don't have exp2).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131872 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 22:22:35 +00:00
Chris Lattner
1add46ddfa Carve out a place in instcombine to put transformations which work knowing that their
result is non-zero.  Implement an example optimization (PR9814), which allows us to
transform:
  A / ((1 << B) >>u 2)
into:
  A >>u (B-2)

which we compile into:

_divu3:                                 ## @divu3
	leal	-2(%rsi), %ecx
	shrl	%cl, %edi
	movl	%edi, %eax
	ret

instead of:

_divu3:                                 ## @divu3
	movb	%sil, %cl
	movl	$1, %esi
	shll	%cl, %esi
	shrl	$2, %esi
	movl	%edi, %eax
	xorl	%edx, %edx
	divl	%esi, %eax
	ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131860 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 18:18:41 +00:00
Chris Lattner
4f81b54192 Fix PR9815: I was trying to get out of "generating code and then
failing to form a memset, then having to delete it" but my approximation
isn't safe for self recurrent loops.  Instead of doign a hack, just
do it the right way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131858 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 17:39:56 +00:00
Frits van Bommel
5649ba70fb Add a parameter to ConstantFoldTerminator() that callers can use to ask it to also clean up the condition of any conditional terminator it folds to be unconditional, if that turns the condition into dead code. This just means it calls RecursivelyDeleteTriviallyDeadInstructions() in strategic spots. It defaults to the old behavior.
I also changed -simplifycfg, -jump-threading and -codegenprepare to use this to produce slightly better code without any extra cleanup passes (AFAICT this was the only place in -simplifycfg where now-dead conditions of replaced terminators weren't being cleaned up). The only other user of this function is -sccp, but I didn't read that thoroughly enough to figure out whether it might be holding pointers to instructions that could be deleted by this.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131855 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 16:24:18 +00:00
Chris Lattner
98a42b2fc3 fix PR9856, an incorrectly conservative assertion: a global can be
"stored once" even if its address is compared.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131849 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 07:15:13 +00:00
Chris Lattner
9e7bc05ad7 fix PR9841 by having GVN not process dead loads. This was
causing it to get into infinite loops when it would widen a 
load (which can necessarily leave around dead loads).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131847 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 07:03:34 +00:00
Chris Lattner
0e959394ad remove a trivial test, make some other tests less trivial.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131846 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 07:02:43 +00:00
Chris Lattner
208d92c143 make this test less trivial.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131845 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 06:59:33 +00:00
Nick Lewycky
bec6a19289 Commit test change, forgotten as part of r131838.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131839 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 05:31:47 +00:00
Nick Lewycky
6d55f2269e Teach the inliner to emit llvm.lifetime.start/end, to scope the local variables
of the inlinee to the code representing the original function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131838 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 05:22:10 +00:00
Nick Lewycky
c7e38e8f3f Fix grammar in test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131831 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 01:16:00 +00:00
Benjamin Kramer
cd89d4d524 Revert "InstCombine: Turn mul.with.overflow(X, 2) into the cheaper add.with.overflow(X, X)"
It's better to do this in codegen, mul.with.overflow(X, 2) is more canonical because it has only one use on "X".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131798 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-21 18:31:42 +00:00
Benjamin Kramer
c21b205f93 InstCombine: Turn mul.with.overflow(X, 2) into the cheaper add.with.overflow(X, X)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131789 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-21 09:22:06 +00:00
Evan Cheng
2e6496026f Revert r131664 and fix it in instcombine instead. rdar://9467055
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131708 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-20 00:54:37 +00:00
Stuart Hastings
26847d40db Move test to Transforms/InstCombine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131634 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 05:53:22 +00:00
Rafael Espindola
cf227d5ad9 Add test for PR9946.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131621 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 02:35:26 +00:00
Eli Friedman
e6f364b6c4 More instcombine cleanup, towards improving debug line info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131604 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 23:58:37 +00:00
Dan Gohman
673968ae78 When forming an ICmpZero LSRUse, normalize the non-IV operand
of the comparison, so that the resulting expression is fully
normalized. This fixes PR9939.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131576 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 21:02:18 +00:00
Eli Friedman
59f15918c2 More instcombine cleanup aimed towards improving debug line info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131559 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 19:57:14 +00:00
Eli Friedman
ef819d0ed8 Start trying to make InstCombine preserve more debug info. The idea here is to set the debug location on the IRBuilder, which will be then right location in most cases. This should magically give many transformations debug locations, and fixing places which are missing a debug location will usually just means changing the code creating it to use the IRBuilder.
As an example, the change to InstCombineCalls catches a common case where a call to a bitcast of a function is rewritten.

Chris, does this approach look reasonable?



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131516 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 01:28:27 +00:00
Stuart Hastings
71753050b1 Drop lli, revise test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131452 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 02:38:59 +00:00
Rafael Espindola
0e00c6c561 Don't do tail calls in a function that call setjmp. The stack might be
corrupted when setjmp returns again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131399 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-16 03:05:33 +00:00
Benjamin Kramer
dae3b57b91 Disable test harder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131363 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-14 19:30:39 +00:00
Stuart Hastings
47242e8680 Disable this test while I revise it. rdar://problem/9267970
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131350 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-14 18:39:05 +00:00
Benjamin Kramer
10fcfb53fd SimplifyCFG: Use ComputeMaskedBits to prune dead cases from switch instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131345 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-14 15:57:25 +00:00
Stuart Hastings
67f071e697 Avoid combining GEPs that might overflow at runtime.
rdar://problem/9267970

Patch by Julien Lerouge!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131339 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-14 05:55:10 +00:00
Duncan Sands
e864b5b840 The comparision "max(x,y)==x" is equivalent to "x>=y". Since the max is
often expressed as "x >= y ? x : y", there is a good chance we can extract
the existing "x >= y" from it and use that as a replacement for "max(x,y)==x".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131049 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-07 16:56:49 +00:00
Galina Kistanova
9dabb78519 Move few target-dependant tests to appropriate directories.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131002 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 18:24:46 +00:00