Commit Graph

939 Commits

Author SHA1 Message Date
Evan Cheng
502a4f5162 Do not speculatively execute an instruction by hoisting it to its predecessor BB if any of its operands are defined but not used in BB. The transformation will prevent the operand from being sunk into the use block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52244 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-12 21:15:59 +00:00
Evan Cheng
797d95188d For now, avoid generating FP select instructions in order to speculatively execute integer arithmetic instructions. FP selects are more likely to be expensive (even compared to branch on fcmp). This is not a wonderful solution but I rather err on the side of conservative.
This fixes the heapsort performance regressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52224 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 19:18:20 +00:00
Gabor Greif
f7ea3638e0 op_iterator-ify loops
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52191 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-10 22:03:26 +00:00
Evan Cheng
4d09efd7b8 Speculatively execute a block when the the block is the then part of a triangle shape and it contains a single, side effect free, cheap instruction. The branch is eliminated by adding a select instruction. i.e.
Turn                                                                                                                                                                                                       
BB:                                                                                                                                                                                                        
    %t1 = icmp                                                                                                                                                                                             
    br i1 %t1, label %BB1, label %BB2                                                                                                                                                                      
BB1:                                                                                                                                                                                                       
    %t3 = add %t2, c                                                                                                                                                                                       
    br label BB2                                                                                                                                                                                           
BB2:                                                                                                                                                                                                       
=>                                                                                                                                                                                                         
BB:                                                                                                                                                                                                        
    %t1 = icmp                                                                                                                                                                                             
    %t4 = add %t2, c                                                                                                                                                                                       
    %t3 = select i1 %t1, %t2, %t3


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52073 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-07 08:52:29 +00:00
Devang Patel
4c37c07ee3 LoopSimplify preserves AA.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52053 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-06 17:50:58 +00:00
Owen Anderson
269db29bdb LoopIndexSplit can sometimes result in cases where a block in its own domfrontier.
Don't crash when we encounter one of these.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51915 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-03 18:29:48 +00:00
Dan Gohman
c702a9ed1c Fix whitespace in whitespace-significant pseudocode in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51890 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-03 00:57:21 +00:00
Gabor Greif
ba2c487424 rewrite operand loops to use iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51789 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 21:24:22 +00:00
Owen Anderson
427de86ada Since LCSSA switched over to DenseMap, we have to be more careful to avoid iterator invalidation. Fixes PR2385.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51777 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 17:31:01 +00:00
Duncan Sands
28c3cff825 Factor code to copy global value attributes like
the section or the visibility from one global
value to another: copyAttributesFrom.  This is
particularly useful for duplicating functions:
previously this was done by explicitly copying
each attribute in turn at each place where a
new function was created out of an old one, with
the result that obscure attributes were regularly
forgotten (like the collector or the section).
Hopefully now everything is uniform and nothing
is forgotten.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51567 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-26 19:58:59 +00:00
Owen Anderson
78ecf0d7b1 Use a DenseMap instead of an std::map, speeding up the testcase in PR2368 by about a third.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51565 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-26 10:07:43 +00:00
Dan Gohman
02dea8b39f Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places to
use it instead of duplicating its functionality.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51499 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 21:05:58 +00:00
Matthijs Kooijman
5e179a23e3 Restucture a part of the SimplifyCFG pass and include a testcase.
The SimplifyCFG pass looks at basic blocks that contain only phi nodes,
followed by an unconditional branch. In a lot of cases, such a block (BB) can
be merged into their successor (Succ).

This merging is performed by TryToSimplifyUncondBranchFromEmptyBlock. It does
this by taking all phi nodes in the succesor block Succ and expanding them to
include the predecessors of BB. Furthermore, any phi nodes in BB are moved to
Succ and expanded to include the predecessors of Succ as well.

Before attempting this merge, CanPropagatePredecessorsForPHIs checks to see if
all phi nodes can be properly merged. All functional changes are made to
this function, only comments were updated in
TryToSimplifyUncondBranchFromEmptyBlock.

In the original code, CanPropagatePredecessorsForPHIs looks quite convoluted
and more like stack of checks added to handle different kinds of situations
than a comprehensive check. In particular the first check in the function did
some value checking for the case that BB and Succ have a common predecessor,
while the last check in the function simply rejected all cases where BB and
Succ have a common predecessor. The first check was still useful in the case
that BB did not contain any phi nodes at all, though, so it was not completely
useless.

Now, CanPropagatePredecessorsForPHIs is restructured to to look a lot more
similar to the code that actually performs the merge. Both functions now look
at the same phi nodes in about the same order.  Any conflicts (phi nodes with
different values for the same source) that could arise from merging or moving
phi nodes are detected. If no conflicts are found, the merge can happen.

Apart from only restructuring the checks, two main changes in functionality
happened.

Firstly, the old code rejected blocks with common predecessors in most cases.
The new code performs some extra checks so common predecessors can be handled
in a lot of cases. Wherever common predecessors still pose problems, the
blocks are left untouched.

Secondly, the old code rejected the merge when values (phi nodes) from BB were
used in any other place than Succ. However, it does not seem that there is any
situation that would require this check. Even more, this can be proven.

Consider that BB is a block containing of a single phi node "%a" and a branch
to Succ. Now, since the definition of %a will dominate all of its uses, BB
will dominate all blocks that use %a. Furthermore, since the branch from BB to
Succ is unconditional, Succ will also dominate all uses of %a.

Now, assume that one predecessor of Succ is not dominated by BB (and thus not
dominated by Succ). Since at least one use of %a (but in reality all of them)
is reachable from Succ, you could end up at a use of %a without passing
through it's definition in BB (by coming from X through Succ). This is a
contradiction, meaning that our original assumption is wrong. Thus, all
predecessors of Succ must also be dominated by BB (and thus also by Succ).

This means that moving the phi node %a from BB to Succ does not pose any
problems when the two blocks are merged, and any use checks are not needed.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51478 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 09:09:41 +00:00
Gabor Greif
7cbd8a3e92 API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. Legacy interfaces will be in place for some time. (Merge from use-diet branch.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51200 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-16 19:29:10 +00:00
Gabor Greif
b1dbcd886a Fix a bunch of 80col violations that arose from the Create API change. Tweak makefile targets to find these better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51143 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-15 10:04:30 +00:00
Dan Gohman
45b3197090 Split the loop unroll mechanism logic out into a utility function.
Patch by Matthijs Kooijman!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51083 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-14 00:24:14 +00:00
Dan Gohman
6ddba2b933 Change class' public PassInfo variables to by initialized with the
address of the PassInfo directly instead of calling getPassInfo.
This eliminates a bunch of dynamic initializations of static data.

Also, fold RegisterPassBase into PassInfo, make a bunch of its
data members const, and rearrange some code to initialize data
members in constructors instead of using setter member functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51022 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-13 02:05:11 +00:00
Dan Gohman
844731a7f1 Clean up the use of static and anonymous namespaces. This turned up
several things that were neither in an anonymous namespace nor static
but not intended to be global.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51017 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-13 00:00:25 +00:00
Dan Gohman
4a3f6c8882 Make several variable declarations static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50696 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-06 01:53:16 +00:00
Dan Gohman
84b7df43fb Remove uses of llvm/System/IncludeFile.h that are no longer needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50695 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-06 01:32:53 +00:00
Devang Patel
7b39969528 Handle multiple return values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50604 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-03 01:12:15 +00:00
Chris Lattner
ffba5821ee Fix PR2256, yet another miscompilation in simplifycfg of i
multiple return values.

Bill, please pull this into Tak.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50332 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 00:19:07 +00:00
Nate Begeman
4182db4327 Feedback from chris
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50271 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25 17:45:52 +00:00
Nick Lewycky
280a6e607d Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989
r48047 r48084 r48085 r48086 r48088 r48096 r48099 r48109 and r48123.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50265 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25 16:53:59 +00:00
Nate Begeman
4be30ac0e2 Teach the PruningFunctionCloner how to look through loads with
ConstantExpression GEPs pointing into constant globals.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50256 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25 06:37:06 +00:00
Evan Cheng
79328661fa Adjust inline cost computation to be less aggressive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50222 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-24 18:42:47 +00:00
Chris Lattner
c9e495c534 Split some code out of the main SimplifyCFG loop into its own function.
Fix said code to handle merging return instructions together correctly
when handling multiple return values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50199 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-24 00:01:19 +00:00
Devang Patel
6829157f49 Check type instead of no. of operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50179 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23 20:18:29 +00:00
Chris Lattner
54b9c3ba2a Move SplitBlockPredecessors out of loopsimplify into BasicBlockUtils.h
as a global helper function.  At the same type, switch it from taking
a vector of predecessors to an arbitrary sequential input.  This allows
us to switch LoopSimplify to use a SmallVector for various temporary
vectors that it passed into SplitBlockPredecessors.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50020 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-21 01:28:02 +00:00
Chris Lattner
1b58678d54 Move domtree/frontier updating earlier, allowing us to use it to update phi
nodes, removing a hack.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50019 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-21 01:05:08 +00:00
Chris Lattner
b85979434d Factor dominator tree and frontier updating into SplitBlockPredecessors
instead of doing it after every call.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50018 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-21 00:54:38 +00:00
Chris Lattner
34093a634a simplify code, fit in 80 cols.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50015 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-21 00:23:14 +00:00
Chris Lattner
862f27ebab fit in 80 cols
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50014 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-21 00:19:16 +00:00
Scott Michel
5788bca1c2 Remove unused variable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49838 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-17 01:30:44 +00:00
Scott Michel
4bf393a13e Workaround for PR2207, in which pred_iterator assert gets triggered due to a
wee problem in Xcode 2.[45]/gcc 4.0.1.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49831 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-16 23:46:39 +00:00
Chuck Rose III
cc51c31953 VisualStudio project files updated. #include <algorithm> added to make VisualStudio happy. Also had to undefine setjmp because of #include <csetjmp> turning setjmp into _setjmp in VisualStudio.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49743 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-15 21:27:11 +00:00
Owen Anderson
6bc41e8a74 Revert r49614. As Dan pointed out, some of these aren't correct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49657 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-14 17:38:21 +00:00
Owen Anderson
386ea355e7 Replace calls of the form V1->setName(V2->getName()) with V1->takeName(V2),
which is significantly more efficient.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49614 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-13 19:15:17 +00:00
Devang Patel
34437f35e9 Fix insert point handling for multiple return values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49367 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-08 02:24:08 +00:00
Duncan Sands
3d292aca03 The "stacksave is not nounwind problem" no longer
needs to be fixed here - a previous commit made sure
that intrinsics always get the right attributes.
So remove no-longer needed code, and while there use
Intrinsic::getDeclaration rather than getOrInsertFunction. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49337 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-07 13:43:58 +00:00
Duncan Sands
a122043c2c Use Intrinsic::getDeclaration to get hold of
intrinsics.  Fix up the argument type (should
be i8*, was an array*).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49336 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-07 13:41:19 +00:00
Dale Johannesen
11b80a8e1c Mark calls to llvm.stacksave, llvm.stackrestore as
nounwind.  When such calls are inlined into something
else that is invoked, they were getting changed to invokes,
which is badness.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49299 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-07 00:08:48 +00:00
Gabor Greif
051a950000 API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49277 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-06 20:25:17 +00:00
Evan Cheng
7c3becd9d7 1. Drop default inline threshold back down to 200.
2. Do not use # of basic blocks as part of the cost computation since it doesn't really figure into function size.
3. More aggressively inline function with vector code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49061 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-01 23:59:29 +00:00
Dale Johannesen
b6d5b14390 Revert 49006 for the moment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49046 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-01 20:00:57 +00:00
Dale Johannesen
1544e4713b Emit exception handling info for functions which are
not marked nounwind, or for all functions when -enable-eh
is set, provided the target supports Dwarf EH.

llvm-gcc generates nounwind in the right places; other FEs
will need to do so also.  Given such a FE, -enable-eh should
no longer be needed.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49006 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-31 23:40:23 +00:00
Evan Cheng
8d84d5b62c Increasing the inline limit from (overly conservative) 200 to 300. Given each BB costs 20 and each instruction costs 5, 200 means a 4 BB function + 24 instructions (actually less because caller's size also contributes to it).
Furthermore, double the limit when more than 10% of the callee instructions are vector instructions. Multimedia kernels tend to love inlining.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48725 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-24 06:37:48 +00:00
Anton Korobeynikov
9e49f1bc58 Preserve calling convention during function cloning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48708 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-23 16:03:00 +00:00
Evan Cheng
71d83741d2 80 col violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48573 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-20 00:20:23 +00:00
Nick Lewycky
6e7aeb16fa Update -mem2reg to use succ_iterator instead of iterating across TerminatorInst
successors. This makes it support nounwind.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48320 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-13 02:42:41 +00:00