Chris Lattner
229907cd11
land David Blaikie's patch to de-constify Type, with a few tweaks.
...
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Jay Foad
5bd375a6cc
Convert CallInst and InvokeInst APIs to use ArrayRef.
...
llvm-svn: 135265
2011-07-15 08:37:34 +00:00
Rafael Espindola
b10a0f223a
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.
llvm-svn: 134182
2011-06-30 20:14:24 +00:00
Chad Rosier
96ed721d9b
Temporarily revert r134057: "Let simplify cfg simplify bb with only debug and
...
lifetime intrinsics" due to buildbot failures.
llvm-svn: 134071
2011-06-29 16:22:11 +00:00
Rafael Espindola
4c0dfcec7e
Let simplify cfg simplify bb with only debug and lifetime intrinsics.
...
llvm-svn: 134057
2011-06-29 05:25:47 +00:00
Hans Wennborg
4ab4a8e63a
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.
llvm-svn: 133344
2011-06-18 10:28:47 +00:00
Bill Wendling
4f163dfed1
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
llvm-svn: 132638
2011-06-04 09:42:04 +00:00
Frits van Bommel
ad964559ef
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.
llvm-svn: 131855
2011-05-22 16:24:18 +00:00
Devang Patel
1407fb4bbe
Reapply r131605. This time with a fix, which is to use NoFolder.
...
llvm-svn: 131673
2011-05-19 20:52:46 +00:00
Rafael Espindola
964602d7ba
revert 131605 to fix PR9946.
...
llvm-svn: 131620
2011-05-19 02:26:30 +00:00
Devang Patel
3015a54813
Use IRBuilder.
...
llvm-svn: 131609
2011-05-19 00:13:33 +00:00
Devang Patel
31458a0002
Use IRBuilder while simplifying unreachable.
...
llvm-svn: 131607
2011-05-19 00:09:21 +00:00
Devang Patel
4b13f39b77
Use IRBuilder while simplifying conditional branch.
...
llvm-svn: 131605
2011-05-18 23:59:51 +00:00
Devang Patel
7de6c4bf75
Use IRBuilder while simplifying branch.
...
llvm-svn: 131598
2011-05-18 23:18:47 +00:00
Devang Patel
dd14e0f7fa
Use IRBuilder while simplifying return instruction.
...
llvm-svn: 131580
2011-05-18 21:33:11 +00:00
Devang Patel
583805530c
Spread use of IRBuilder even more.
...
llvm-svn: 131571
2011-05-18 20:53:17 +00:00
Devang Patel
a7ec47d23c
Use IRBuilder while simplifying switch instruction.
...
llvm-svn: 131566
2011-05-18 20:35:38 +00:00
Devang Patel
0b373dca1f
Use IRBuilder while simplifying unwind.
...
llvm-svn: 131561
2011-05-18 20:01:18 +00:00
Devang Patel
2c2ea226b7
Use IRBuilder while simplifying terminator.
...
llvm-svn: 131552
2011-05-18 18:43:31 +00:00
Devang Patel
767f6930bc
Use IRBuilder while simplifying unconditional branch.
...
llvm-svn: 131551
2011-05-18 18:28:48 +00:00
Devang Patel
5c810ce4a3
Use IRBuilder while folding two entry PHINode.
...
llvm-svn: 131548
2011-05-18 18:16:44 +00:00
Devang Patel
15ad6761da
Set up IRBuilder for use during simplification.
...
llvm-svn: 131545
2011-05-18 18:01:27 +00:00
Devang Patel
b849cd511b
Preseve line numbers while simplifying CFG.
...
llvm-svn: 131508
2011-05-17 23:29:05 +00:00
Benjamin Kramer
d96205c4e5
SimplifyCFG: Use ComputeMaskedBits to prune dead cases from switch instructions.
...
llvm-svn: 131345
2011-05-14 15:57:25 +00:00
Peter Collingbourne
616044acd5
SimplifyCFG: Expose phi node folding cost threshold as command line parameter
...
llvm-svn: 130528
2011-04-29 18:47:38 +00:00
Peter Collingbourne
e3511e15e0
SimplifyCFG: Add CostRemaining parameter to DominatesMergePoint
...
llvm-svn: 130527
2011-04-29 18:47:31 +00:00
Peter Collingbourne
61f6602acd
SimplifyCFG: Add Trunc, ZExt and SExt to the list of cheap instructions for phi node folding
...
llvm-svn: 130526
2011-04-29 18:47:25 +00:00
Chris Lattner
fba5cdfce1
rework FoldBranchToCommonDest to exit earlier when there is a bonus
...
instruction around, reducing work.
Greatly simplify handling of debug instructions. There is no need to
build up a vector of them and then move them into the one predecessor
if we're processing a block. Instead just rescan the block and *copy*
them into the pred. If a block gets merged into multiple preds, this
will retain more debug info.
llvm-svn: 129502
2011-04-14 02:44:53 +00:00
Chris Lattner
7d4cdae564
comment cleanup, use moveBefore instead of removeFromParent+insertBefore.
...
llvm-svn: 129319
2011-04-11 23:24:57 +00:00
Devang Patel
bc3d8b212f
Do not let debug info interfer with branch folding.
...
llvm-svn: 129114
2011-04-07 23:11:25 +00:00
Devang Patel
197c35298a
While hoisting common code from if/else, hoist debug info intrinsics if they match.
...
llvm-svn: 129078
2011-04-07 17:27:36 +00:00
Devang Patel
e48ddf863b
Simplify. isIdenticalToWhenDefined() checks opcode.
...
llvm-svn: 129041
2011-04-07 00:30:15 +00:00
Devang Patel
d715ec82b4
While folding branch to a common destination into a predecessor, copy dbg values also.
...
llvm-svn: 129035
2011-04-06 22:37:20 +00:00
Jay Foad
52131344a2
Remove PHINode::reserveOperandSpace(). Instead, add a parameter to
...
PHINode::Create() giving the (known or expected) number of operands.
llvm-svn: 128537
2011-03-30 11:28:46 +00:00
Jay Foad
e0938d8a87
(Almost) always call reserveOperandSpace() on newly created PHINodes.
...
llvm-svn: 128535
2011-03-30 11:19:20 +00:00
Eli Friedman
c4414c6e92
PR9450: Make switch optimization in SimplifyCFG not dependent on the ordering
...
of pointers in an std::map.
llvm-svn: 127650
2011-03-15 02:23:35 +00:00
Eli Friedman
aac35b3fbb
PR9420; an instruction before an unreachable is guaranteed not to have any
...
reachable uses, but there still might be uses in dead blocks. Use the
standard solution of replacing all the uses with undef. This is
a rare case because it's very sensitive to phase ordering in SimplifyCFG.
llvm-svn: 127299
2011-03-09 00:48:33 +00:00
Frits van Bommel
8ae07996c9
Teach SimplifyCFG that (switch (select cond, X, Y)) is better expressed as a branch.
...
Based on a patch by Alistair Lynn.
llvm-svn: 126647
2011-02-28 09:44:07 +00:00
Benjamin Kramer
ceb5daa567
Revert "SimplifyCFG: GEPs with just one non-constant index are also cheap."
...
Yes, there are other types than i8* and GEPs on them can produce an add+multiply.
We don't consider that cheap enough to be speculatively executed.
llvm-svn: 126481
2011-02-25 10:33:33 +00:00
Benjamin Kramer
dfdca1a14d
SimplifyCFG: GEPs with just one non-constant index are also cheap.
...
llvm-svn: 126452
2011-02-24 23:26:09 +00:00
Benjamin Kramer
27361a7124
SimplifyCFG: GEPs with constant indices are cheap enough to be executed unconditionally.
...
llvm-svn: 126445
2011-02-24 22:46:11 +00:00
Benjamin Kramer
8d6a8c130b
SimplifyCFG: Track the number of used icmps when turning a icmp chain into a switch. If we used only one icmp, don't turn it into a switch.
...
Also prevent the switch-to-icmp transform from creating identity adds, noticed by Marius Wachtler.
llvm-svn: 125056
2011-02-07 22:37:28 +00:00
Benjamin Kramer
62aa46b852
SimplifyCFG: Also transform switches that represent a range comparison but are not sorted into sub+icmp.
...
This transforms another 1000 switches in gcc.c.
llvm-svn: 124826
2011-02-03 22:51:41 +00:00
Benjamin Kramer
f4ea1d5f79
SimplifyCFG: Turn switches into sub+icmp+branch if possible.
...
This makes the job of the later optzn passes easier, allowing the vast amount of
icmp transforms to chew on it.
We transform 840 switches in gcc.c, leading to a 16k byte shrink of the resulting
binary on i386-linux.
The testcase from README.txt now compiles into
decl %edi
cmpl $3, %edi
sbbl %eax, %eax
andl $1, %eax
ret
llvm-svn: 124724
2011-02-02 15:56:22 +00:00
Evan Cheng
d983eba7dc
Re-apply r124518 with fix. Watch out for invalidated iterator.
...
llvm-svn: 124526
2011-01-29 04:46:23 +00:00
Evan Cheng
65b8ccf6ac
Revert r124518. It broke Linux self-host.
...
llvm-svn: 124522
2011-01-29 02:43:04 +00:00
Evan Cheng
d4eff31476
Re-commit r124462 with fixes. Tail recursion elim will now dup ret into unconditional predecessor to enable TCE on demand.
...
llvm-svn: 124518
2011-01-29 01:29:26 +00:00
Evan Cheng
aaa9606b2f
Revert r124462. There are a few big regressions that I need to fix first.
...
llvm-svn: 124478
2011-01-28 07:12:38 +00:00
Evan Cheng
417fca86c4
- Stop simplifycfg from duplicating "ret" instructions into unconditional
...
branches. PR8575, rdar://5134905, rdar://8911460.
- Allow codegen tail duplication to dup small return blocks after register
allocation is done.
llvm-svn: 124462
2011-01-28 02:19:21 +00:00
Frits van Bommel
8e158495f1
Factor the actual simplification out of SimplifyIndirectBrOnSelect and into a new helper function so it can be reused in e.g. an upcoming SimplifySwitchOnSelect.
...
No functional change.
llvm-svn: 123234
2011-01-11 12:52:11 +00:00