1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

296 Commits

Author SHA1 Message Date
Evan Cheng
6970be3ca4 Allow target to disable if-converting predicable instructions. e.g. NEON instructions under ARM mode.
llvm-svn: 89541
2009-11-21 06:20:26 +00:00
Bob Wilson
fc1194919b Revert r85346 change to control tail merging by CodeGenOpt::Level.
I'm going to redo this using the OptimizeForSize function attribute.

llvm-svn: 85426
2009-10-28 20:46:46 +00:00
Bob Wilson
98c9fb94ab Record CodeGen optimization level in the BranchFolding pass so that we can
use it to control tail merging when there is a tradeoff between performance
and code size.  When there is only 1 instruction in the common tail, we have
been merging.  That can be good for code size but is a definite loss for
performance.  Now we will avoid tail merging in that case when the
optimization level is "Aggressive", i.e., "-O3".  Radar 7338114.

Since the IfConversion pass invokes BranchFolding, it too needs to know
the optimization level.  Note that I removed the RegisterPass instantiation
for IfConversion because it required a default constructor.  If someone
wants to keep that for some reason, we can add a default constructor with
a hard-wired optimization level.

llvm-svn: 85346
2009-10-27 23:49:38 +00:00
Nick Lewycky
711c726c97 Remove VISIBILITY_HIDDEN from class/struct found inside anonymous namespaces.
Chris claims we should never have visibility_hidden inside any .cpp file but
that's still not true even after this commit.

llvm-svn: 85042
2009-10-25 06:33:48 +00:00
Evan Cheng
46e40befe7 Run branch folding if if-converter make some transformations.
llvm-svn: 80994
2009-09-04 07:47:40 +00:00
Chris Lattner
db2965c71f remove various std::ostream version of printing methods from
MachineInstr and MachineOperand.  This required eliminating a
bunch of stuff that was using DOUT, I hope that bill doesn't
mind me stealing his fun. ;-)

llvm-svn: 79813
2009-08-23 03:41:05 +00:00
Bill Wendling
295fc15497 Convert DOUT to DEBUG(errs()...).
llvm-svn: 79751
2009-08-22 20:11:17 +00:00
Daniel Dunbar
8496064116 More migration to raw_ostream, the water has dried up around the iostream hole.
- Some clients which used DOUT have moved to DEBUG. We are deprecating the
   "magic" DOUT behavior which avoided calling printing functions when the
   statement was disabled. In addition to being unnecessary magic, it had the
   downside of leaving code in -Asserts builds, and of hiding potentially
   unnecessary computations.

llvm-svn: 77019
2009-07-25 00:23:56 +00:00
Torok Edwin
f955a6ef49 llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").

llvm-svn: 75640
2009-07-14 16:55:14 +00:00
Torok Edwin
67153904ec Fix assert(0) conversion, as suggested by Chris.
llvm-svn: 75423
2009-07-12 20:07:01 +00:00
Torok Edwin
9b41a5faf2 Convert more assert(0)+abort() -> LLVM_UNREACHABLE,
and abort()/exit() -> llvm_report_error().

llvm-svn: 75363
2009-07-11 13:10:19 +00:00
Owen Anderson
a21f94d6ba Fewer static variables, part 3 of many.
llvm-svn: 74140
2009-06-24 23:41:44 +00:00
Evan Cheng
4b77794613 ifcvt should ignore cfg where true and false successors are the same.
llvm-svn: 73423
2009-06-15 21:24:34 +00:00
Bob Wilson
6571391191 Revert r71744. I must not have understood this correctly, because the
assertion is failing for some tests.

llvm-svn: 71779
2009-05-14 18:08:41 +00:00
Bob Wilson
35ad062490 The IfConverter::MergeBlocks method appears to be used only to merge a basic
block with its unique predecessor.  Change the code to assert if that is not
the case, instead of trying to handle situations where the block has
multiple predecessors.

llvm-svn: 71744
2009-05-13 23:54:13 +00:00
Bob Wilson
ab98a2c258 Revert a portion of Dan's change r71018 that I'm convinced is wrong.
Dan was trying to catch the case where a basic block ends with a conditional
branch to the fall-through block.  In this case, all the instructions have
been moved out of FromBBI, leaving it empty.  It cannot end with a
conditional branch.  As the existing comment indicates, it will always fall
through to the next block.  If the block already had the next block (NBB)
listed as a successor, the preceding loop has a check for that and does not
remove it.  Thus, we need to check and add the successor only when it is
not already listed.

With Dan's change, the empty block often ends up with the fall-through
successor listed twice.  This exposed the problem in pr4195, where
CodePlacementOpt did not handle the same predecessor listed more than once.
It is also at least partially responsible for pr4202 and probably a similar
issue with Thumb branches being out of range.

llvm-svn: 71742
2009-05-13 23:48:58 +00:00
Bob Wilson
8c8c81cd78 Merge adjacent conditional.
llvm-svn: 71741
2009-05-13 23:35:38 +00:00
Bob Wilson
516a55feaa Remove an unused variable.
llvm-svn: 71740
2009-05-13 23:31:30 +00:00
Bob Wilson
c739ce57db Fix some typos and spelling and grammar, mostly in comments, but also one
field name.  No functional changes.

llvm-svn: 71739
2009-05-13 23:25:24 +00:00
Dan Gohman
5e839321f2 If a MachineBasicBlock has multiple ways of reaching another block,
allow it to have multiple CFG edges to that block. This is needed
to allow MachineBasicBlock::isOnlyReachableByFallthrough to work
correctly. This fixes PR4126.

llvm-svn: 71018
2009-05-05 21:10:19 +00:00
Duncan Sands
aed2dfe3f6 Fix typo. Patch by nlewycky.
llvm-svn: 58709
2008-11-04 18:05:30 +00:00
Nuno Lopes
0995eae6b8 fix leakage of IfcvtTokens
llvm-svn: 58690
2008-11-04 13:02:59 +00:00
Dan Gohman
281881b8e2 Optimized FCMP_OEQ and FCMP_UNE for x86.
Where previously LLVM might emit code like this:

        ucomisd %xmm1, %xmm0
        setne   %al
        setp    %cl
        orb     %al, %cl
        jne     .LBB4_2

it now emits this:

        ucomisd %xmm1, %xmm0
        jne     .LBB4_2
        jp      .LBB4_2

It has fewer instructions and uses fewer registers, but it does
have more branches. And in the case that this code is followed by
a non-fallthrough edge, it may be followed by a jmp instruction,
resulting in three branch instructions in sequence. Some effort
is made to avoid this situation.

To achieve this, X86ISelLowering.cpp now recognizes FCMP_OEQ and
FCMP_UNE in lowered form, and replace them with code that emits
two branches, except in the case where it would require converting
a fall-through edge to an explicit branch.

Also, X86InstrInfo.cpp's branch analysis and transform code now
knows now to handle blocks with multiple conditional branches. It
uses loops instead of having fixed checks for up to two
instructions. It can now analyze and transform code generated
from FCMP_OEQ and FCMP_UNE.

llvm-svn: 57873
2008-10-21 03:29:32 +00:00
Dan Gohman
e1f9be27bc Tidy up several unbeseeming casts from pointer to intptr_t.
llvm-svn: 55779
2008-09-04 17:05:41 +00:00
Dan Gohman
3b4af81381 Fix SmallVector's size calculation so that a size of 0 is
handled correctly, and change a few SmallVector uses to use
size 0 to more clearly reflect their intent.

llvm-svn: 55181
2008-08-22 16:07:55 +00:00
Owen Anderson
600a8ca0d5 Convert uses of std::vector in TargetInstrInfo to SmallVector. This change had to be propoagated down into all the targets and up into all clients of this API.
llvm-svn: 54802
2008-08-14 22:49:33 +00:00
Dan Gohman
cd25487258 Pool-allocation for MachineInstrs, MachineBasicBlocks, and
MachineMemOperands. The pools are owned by MachineFunctions.

This drastically reduces the number of calls to malloc/free made
during the "Emit" phase of scheduling, as well as later phases
in CodeGen. Combined with other changes, this speeds up the
"instruction selection" phase of CodeGen by 10% in some cases.

llvm-svn: 53212
2008-07-07 23:14:23 +00:00
Evan Cheng
523ad8a09a Register if-converter pass for -debug-pass.
llvm-svn: 51931
2008-06-04 09:15:51 +00:00
Evan Cheng
f8b1257d2e Add a quick and dirty "loop aligner pass". x86 uses it to align its loops to 16-byte boundaries.
llvm-svn: 47703
2008-02-28 00:43:03 +00:00
Anton Korobeynikov
7dd00942cc Update gcc 4.3 warnings fix patch with recent head changes
llvm-svn: 47368
2008-02-20 11:10:28 +00:00
Dan Gohman
aad233ea10 Use empty() instead of comparing size() with zero.
llvm-svn: 46514
2008-01-29 13:02:09 +00:00
Chris Lattner
f83aae613c rename TargetInstrDescriptor -> TargetInstrDesc.
Make MachineInstr::getDesc return a reference instead
of a pointer, since it can never be null.

llvm-svn: 45695
2008-01-07 07:27:27 +00:00
Chris Lattner
18038a0aac simplify some code using new predicates
llvm-svn: 45689
2008-01-07 05:40:58 +00:00
Chris Lattner
f7f96d818f Rename MachineInstr::getInstrDescriptor -> getDesc(), which reflects
that it is cheap and efficient to get.

Move a variety of predicates from TargetInstrInfo into 
TargetInstrDescriptor, which makes it much easier to query a predicate
when you don't have TII around.  Now you can use MI->getDesc()->isBranch()
instead of going through TII, and this is much more efficient anyway. Not
all of the predicates have been moved over yet.

Update old code that used MI->getInstrDescriptor()->Flags to use the
new predicates in many places.

llvm-svn: 45674
2008-01-07 01:56:04 +00:00
Chris Lattner
ad9a6ccb83 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Evan Cheng
87e735c4be Somehow this wasn't committed last time. M_CLOBBERS_PRED is gone.
llvm-svn: 38495
2007-07-10 17:50:43 +00:00
Evan Cheng
4c7b04f24d Teach if-conversion about instructions that were already predicated, e.g. conditional move.
llvm-svn: 37964
2007-07-06 23:24:39 +00:00
Evan Cheng
5e2aabd3ad Avoid if-converting simple block that ends with unconditional branch or fallthrough unless it branches / falls to the 'false' block. Not profitable, may end up increasing code size.
llvm-svn: 37660
2007-06-19 21:45:13 +00:00
Evan Cheng
12b3002673 Replace TargetInstrInfo::CanBeDuplicated() with a M_NOT_DUPLICABLE bit.
llvm-svn: 37643
2007-06-19 01:26:51 +00:00
Evan Cheng
b752a87db1 Fix some fragile code wrt CFG edge updating.
llvm-svn: 37634
2007-06-18 22:44:57 +00:00
Evan Cheng
b3cefc0824 Properly remove duplicate instructions as result of diamond if-conversion. Other bug fixes.
llvm-svn: 37623
2007-06-18 08:37:25 +00:00
Evan Cheng
1732a41371 Really turn if-converter loose:
1. Consider all possible ifcvt cases at once. No longer restricted to bottom
   up iterative approach.
2. Sort all possible cases based on a cost function. Perform the most profitable
   ones first invalidate others that target the same blocks.
3. Fixed a number of bugs related to block duplication.

llvm-svn: 37613
2007-06-16 09:34:52 +00:00
Evan Cheng
759b3cca3c Not every predicable block can be safely duplicated.
llvm-svn: 37607
2007-06-15 21:18:05 +00:00
Evan Cheng
88c463eb8c MachineInstr::isPredicable() is no longer needed.
llvm-svn: 37599
2007-06-15 19:06:07 +00:00
Evan Cheng
a6504bc2e0 Extra edges are deleted later if needed.
llvm-svn: 37593
2007-06-15 17:34:48 +00:00
Evan Cheng
f4d3d695b2 Allow small blocks to be duplicated to enable if-conversion.
llvm-svn: 37590
2007-06-15 07:36:12 +00:00
Evan Cheng
6f348e1c75 No really, clear predcessors states.
llvm-svn: 37581
2007-06-14 23:34:09 +00:00
Evan Cheng
b1b1914582 If BB is predicated, invalidate its predecessor(s) which would if-convert it. It needs to be re-analyzed.
llvm-svn: 37580
2007-06-14 23:13:19 +00:00
Evan Cheng
26d68261ae Fix typo.
llvm-svn: 37577
2007-06-14 21:26:08 +00:00
Evan Cheng
a2c2479e22 Fix some stupid bugs that have effectively disabled if-conversion.
llvm-svn: 37575
2007-06-14 20:28:52 +00:00
Evan Cheng
d4e9443a78 Typo
llvm-svn: 37566
2007-06-13 00:04:00 +00:00
Evan Cheng
d5aaab210c Now if-converting all 4 variants of triangles.
llvm-svn: 37565
2007-06-12 23:54:05 +00:00
Evan Cheng
d6740b478b Restructure code to reduce ifcvt compile time cost.
llvm-svn: 37543
2007-06-11 22:26:22 +00:00
Reid Spencer
0c11f4ebd8 Fix the build.
llvm-svn: 37537
2007-06-10 00:19:17 +00:00
Evan Cheng
859dab4bda Don't change CFG during analysis stage. Do so during ifcvt and invalidate predecessors accordingly.
llvm-svn: 37531
2007-06-09 01:03:43 +00:00
Evan Cheng
7996fc5d23 Carefully remove extraneous CFG edges after each ifcvt.
llvm-svn: 37529
2007-06-08 22:01:07 +00:00
Evan Cheng
515e2537d7 Correct transfer predicate information.
llvm-svn: 37524
2007-06-08 19:17:12 +00:00
Evan Cheng
49720a7312 Hidden options to help debugging ifcvt issues.
llvm-svn: 37523
2007-06-08 19:10:51 +00:00
Evan Cheng
a41764f141 Allow more cmp / bcc to be predicated; clean up triangle ifcvt checking code.
llvm-svn: 37518
2007-06-08 09:36:04 +00:00
Evan Cheng
2b9e9abed1 Only remove the edge from entry to false if false block is merged.
llvm-svn: 37503
2007-06-07 22:31:28 +00:00
Evan Cheng
4f73706838 ifcvt a triangle: don't merge ifcvt block with rejoin block if it can fall through to it. If merged, the resulting block is not a candidate for iterative ifcvting since it contains both predicated and non-predicated code.
llvm-svn: 37487
2007-06-07 08:13:00 +00:00
Evan Cheng
d440a235a1 Lots of bug fixes. Now finally in a reasonable state.
llvm-svn: 37485
2007-06-07 02:12:15 +00:00
Owen Anderson
b333dd064e Quick patch to fix the build, based on what it appears Evan meant to write.
Evan, please check that this is in fact correct.

llvm-svn: 37471
2007-06-06 16:22:00 +00:00
Evan Cheng
aeccfbef8b Lots of bug fixes.
llvm-svn: 37467
2007-06-06 10:16:17 +00:00
Evan Cheng
4c42a30bad If a unconditional branch is added to branch to the false path during ifcvt, the predicated block cannot be iteratively ifcvted.
llvm-svn: 37456
2007-06-06 02:08:52 +00:00
Evan Cheng
cc7186df2b Minor statistics counting bug.
llvm-svn: 37451
2007-06-06 01:12:44 +00:00
Evan Cheng
2eefb6f4c3 Fix a couple of typos and be smarter about order of blocks when ifcvt a diamond.
llvm-svn: 37449
2007-06-06 00:57:55 +00:00
Evan Cheng
3db28ad9f2 Fix diamond shape ifcvt bugs.
llvm-svn: 37444
2007-06-05 23:46:14 +00:00
Evan Cheng
acf719bf83 ReplaceUsesOfBlockWith() can modify the predecessors list.
llvm-svn: 37441
2007-06-05 22:03:53 +00:00
Evan Cheng
f2a2a5a025 Do not ifcvt if either true / false path is a backedge. Not profitable in almost all cases.
llvm-svn: 37440
2007-06-05 20:38:42 +00:00
Evan Cheng
d495b2f9b9 I had a senior moment.
llvm-svn: 37433
2007-06-05 07:05:25 +00:00
Evan Cheng
a7f7c92dc9 If the predicated block requires an early exit, end the block there and add a unconditional branch to false block. AnalyzeBranch() does not understand early exits.
llvm-svn: 37430
2007-06-05 01:31:40 +00:00
Evan Cheng
7b113514d4 Fix some subtle bugs: bug during succeessor copying; incorrectly updating states of ifcvted blocks.
llvm-svn: 37429
2007-06-05 00:07:37 +00:00
Evan Cheng
79f53ff66d Forgot to check for if iterator reached the end.
llvm-svn: 37420
2007-06-04 20:33:36 +00:00
Evan Cheng
c86e3086da Let IfConverter loose. Allow more aggressive subsumptions; reorder basic blocks to expose more ifcvt opportunities; code clean up and fixes.
llvm-svn: 37409
2007-06-04 06:47:22 +00:00
Evan Cheng
d7793e4561 Correctly mark early-exit on the false path.
llvm-svn: 37387
2007-06-01 20:29:21 +00:00
Evan Cheng
ce6bae7667 Ifcvt triangle: don't ifcvt 'true' BB if it has other predecessors; don't merge 'false' BB if it has other predecessors.
llvm-svn: 37382
2007-06-01 07:41:07 +00:00
Evan Cheng
8e188afada Remove a bogus check. Even terminators in a ifcvt need to be predicated. Unconditional branches can usually be converted to conditional ones.
llvm-svn: 37380
2007-06-01 00:55:26 +00:00
Evan Cheng
7c081d0d02 Allow multiple ifcvt candidates to share children blocks; add some debugging code.
llvm-svn: 37379
2007-06-01 00:12:12 +00:00
Evan Cheng
7a6edf8eab Fix a typo.
llvm-svn: 37374
2007-05-31 20:53:33 +00:00
Evan Cheng
c9c6bbd273 Change traversal order to bottom up in preparation for more aggressive if-conversion.
llvm-svn: 37365
2007-05-30 19:49:19 +00:00
Evan Cheng
a1300649ba Don't merge in tail block of a diamond if it has more than one predecessors after if-conversion.
llvm-svn: 37353
2007-05-29 23:37:20 +00:00
Evan Cheng
b1ba206831 If there is an empty block between a source and its successor block, it still requires a unconditional branch.
llvm-svn: 37344
2007-05-29 22:31:16 +00:00
Evan Cheng
36164f93fd Silly boog.
llvm-svn: 37328
2007-05-25 00:59:01 +00:00
Evan Cheng
3f44824179 Preliminary iterative if-conversion support.
llvm-svn: 37309
2007-05-23 07:23:16 +00:00
Evan Cheng
d395b14837 If-convert early exit blocks (returns, etc.); bug fixes, etc.
llvm-svn: 37270
2007-05-21 22:22:58 +00:00
Evan Cheng
ca7bc898aa Clean up.
llvm-svn: 37237
2007-05-18 19:32:08 +00:00
Evan Cheng
ad9ce3c5b2 Change to depth-first traversal.
llvm-svn: 37236
2007-05-18 19:26:33 +00:00
Evan Cheng
1ed1741260 Some restructuring in preparation for most aggressive if-conversion.
llvm-svn: 37231
2007-05-18 18:14:37 +00:00
Evan Cheng
234f07808b Watch out for blocks that end with a return.
llvm-svn: 37227
2007-05-18 17:06:53 +00:00
Evan Cheng
40eecb3d06 If true / false blocks fallthrough before ifcvt, add unconditional branches to ifcvt'd block.
llvm-svn: 37200
2007-05-18 01:55:58 +00:00
Evan Cheng
c6aa69557a Make use of target specific block size limits; bug fixes.
llvm-svn: 37195
2007-05-18 00:20:58 +00:00
Evan Cheng
ab88e91c81 isBlockPredicable() always ignore terminal instructions; add comments.
llvm-svn: 37126
2007-05-16 21:54:37 +00:00
Evan Cheng
6f761adecb Rename M_PREDICATED to M_PREDICABLE; Moved isPredicable() to MachineInstr.
llvm-svn: 37121
2007-05-16 20:56:08 +00:00
Evan Cheng
3fb34a4fdd Devang points out that we need an assertion here.
llvm-svn: 37097
2007-05-16 05:11:10 +00:00
Evan Cheng
aafca4d4a2 Initial commit of (very basic) if converter.
llvm-svn: 37092
2007-05-16 02:00:57 +00:00